OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
CorrectorRep.cpp
Go to the documentation of this file.
1 //
2 // Class CorrectorRep
3 // Representation of a closed orbit corrector.
4 // The base class acts on both planes.
5 //
6 // Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
7 // All rights reserved
8 //
9 // This file is part of OPAL.
10 //
11 // OPAL is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
18 //
21 
22 
23 // Attribute access table.
24 // ------------------------------------------------------------------------
25 
26 namespace {
27  struct Entry {
28  const char *name;
29  double(CorrectorRep::*get)() const;
30  void (CorrectorRep::*set)(double);
31  };
32 
33  const Entry entries[] = {
34  {
35  "L",
38  },
39  {
40  "BY",
43  },
44  {
45  "BX",
48  },
49  { 0, 0, 0 }
50  };
51 }
52 
53 
55  Corrector(), geometry(), field(), active(true)
56 {}
57 
58 
60  Corrector(right), geometry(right.geometry), field(right.field), active(true)
61 {}
62 
63 
64 CorrectorRep::CorrectorRep(const std::string &name):
65  Corrector(name), geometry(), field(), active(true)
66 {}
67 
68 
70 {}
71 
72 
74  return new CorrectorRep(*this);
75 }
76 
77 
78 Channel *CorrectorRep::getChannel(const std::string &aKey, bool create) {
79  for(const Entry *table = entries; table->name != 0; ++table) {
80  if(aKey == table->name) {
81  return new IndirectChannel<CorrectorRep>(*this, table->get, table->set);
82  }
83  }
84 
85  return ElementBase::getChannel(aKey, create);
86 }
87 
88 
90  return geometry;
91 }
92 
93 
95  return geometry;
96 }
97 
98 
100  return active ? XY : OFF;
101 }
102 
103 
104 double CorrectorRep::getBx() const {
105  return field.getBx();
106 }
107 
108 
109 double CorrectorRep::getBy() const {
110  return field.getBy();
111 }
112 
113 
115  return field;
116 }
117 
118 
120  return field;
121 }
122 
123 
124 void CorrectorRep::setBx(double Bx) {
125  field.setBx(Bx);
126 }
127 
128 
129 void CorrectorRep::setBy(double By) {
130  field.setBy(By);
131 }
132 
133 void CorrectorRep::setActive(bool flag) {
134  active = flag;
135 }
const std::string name
Interface for general corrector.
Definition: Corrector.h:35
Plane
Plane selection.
Definition: Corrector.h:40
@ OFF
Corrector is off (inactive).
Definition: Corrector.h:42
@ XY
Corrector acts on both planes.
Definition: Corrector.h:48
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
virtual double getElementLength() const
Get design length.
Definition: ElementBase.h:432
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:436
virtual double getBy() const
Get vertical field component in Teslas.
bool active
The active/inactive flag.
Definition: CorrectorRep.h:92
virtual double getBx() const
Get horizontal field component in Teslas.
virtual BDipoleField & getField()
Get corrector field.
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
virtual ~CorrectorRep()
virtual void setBx(double)
Set horizontal field component in Teslas.
virtual void setBy(double)
Set vertical field component in Teslas.
virtual StraightGeometry & getGeometry()
Get geometry.
virtual Plane getPlane() const
Get plane(s) of action.
BDipoleField field
The corrector strengths.
Definition: CorrectorRep.h:89
StraightGeometry geometry
The corrector geometry.
Definition: CorrectorRep.h:86
virtual void setActive(bool flag=true)
Set active flag.
virtual ElementBase * clone() const
Return clone.
A geometry representing a straight line.
Abstract interface for read/write access to variable.
Definition: Channel.h:32
Access to a [b]double[/b] data member.
The field of a magnetic dipole.
Definition: BDipoleField.h:31
virtual double getBy() const
Get vertical component.
virtual double getBx() const
Get horizontal component.
virtual void setBy(double By)
Set vertical component.
virtual void setBx(double Bx)
Set horizontal component.