OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
CorrectorRep.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: CorrectorRep.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: CorrectorRep
10 // Defines a concrete representation for an orbit corrector acting on
11 // both planes.
12 //
13 // ------------------------------------------------------------------------
14 // Class category: BeamlineCore
15 // ------------------------------------------------------------------------
16 //
17 // $Date: 2000/03/27 09:32:33 $
18 // $Author: fci $
19 //
20 // ------------------------------------------------------------------------
21 
26 
27 
28 // Attribute access table.
29 // ------------------------------------------------------------------------
30 
31 namespace {
32  struct Entry {
33  const char *name;
34  double(CorrectorRep::*get)() const;
35  void (CorrectorRep::*set)(double);
36  };
37 
38  const Entry entries[] = {
39  {
40  "L",
43  },
44  {
45  "BY",
48  },
49  {
50  "BX",
53  },
54  { 0, 0, 0 }
55  };
56 }
57 
58 
59 // Class CorrectorRep
60 // ------------------------------------------------------------------------
61 
63  Corrector(), geometry(), field(), active(true)
64 {}
65 
66 
68  Corrector(right), geometry(right.geometry), field(right.field), active(true)
69 {}
70 
71 
72 CorrectorRep::CorrectorRep(const std::string &name):
73  Corrector(name), geometry(), field(), active(true)
74 {}
75 
76 
78 {}
79 
80 
82  return new CorrectorRep(*this);
83 }
84 
85 
86 Channel *CorrectorRep::getChannel(const std::string &aKey, bool create) {
87  for(const Entry *table = entries; table->name != 0; ++table) {
88  if(aKey == table->name) {
89  return new IndirectChannel<CorrectorRep>(*this, table->get, table->set);
90  }
91  }
92 
93  return ElementBase::getChannel(aKey, create);
94 }
95 
96 
98  return geometry;
99 }
100 
101 
103  return geometry;
104 }
105 
106 
109 
110  for(const Entry *table = entries; table->name != 0; ++table) {
111  image->setAttribute(table->name, (this->*(table->get))());
112  }
113 
114  return image;
115 }
116 
117 
119  return active ? XY : OFF;
120 }
121 
122 
123 double CorrectorRep::getBx() const {
124  return field.getBx();
125 }
126 
127 
128 double CorrectorRep::getBy() const {
129  return field.getBy();
130 }
131 
132 
134  return field;
135 }
136 
137 
139  return field;
140 }
141 
142 
143 void CorrectorRep::setBx(double Bx) {
144  field.setBx(Bx);
145 }
146 
147 
148 void CorrectorRep::setBy(double By) {
149  field.setBy(By);
150 }
151 
152 
154  ElementBase *wrap = new CorrectorWrapper(this);
155  wrap->setName(getName());
156  return wrap;
157 }
158 
159 
160 void CorrectorRep::setActive(bool flag) {
161  active = flag;
162 }
Representation of a closed orbit corrector.
Definition: CorrectorRep.h:33
StraightGeometry geometry
The corrector geometry.
Definition: CorrectorRep.h:103
Interface for basic beam line object.
Definition: ElementBase.h:128
The field of a magnetic dipole.
Definition: BDipoleField.h:31
Corrector acts on both planes.
Definition: Corrector.h:48
virtual void setName(const std::string &name)
Set element name.
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Corrector is off (inactive).
Definition: Corrector.h:42
virtual void setBx(double Bx)
Set horizontal component.
Interface for general corrector.
Definition: Corrector.h:35
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:515
virtual ElementImage * getImage() const
Construct an image.
virtual StraightGeometry & getGeometry()
Get geometry.
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
virtual double getBy() const
Get vertical component.
virtual const std::string & getName() const
Get element name.
Definition: ElementBase.cpp:95
virtual ~CorrectorRep()
virtual double getBy() const
Get vertical field component in Teslas.
virtual ElementBase * makeFieldWrapper()
Allow field errors.
virtual Plane getPlane() const
Get plane(s) of action.
virtual double getBx() const
Get horizontal field component in Teslas.
Plane
Plane selection.
Definition: Corrector.h:40
BDipoleField field
The corrector strengths.
Definition: CorrectorRep.h:106
virtual double getElementLength() const
Get design length.
Definition: ElementBase.h:511
virtual ElementBase * clone() const
Return clone.
An image of an element.
Definition: ElementImage.h:35
virtual ElementImage * getImage() const
Construct an image.
void setAttribute(const std::string &aKey, double val)
Set value of an attribute.
virtual double getBx() const
Get horizontal component.
virtual BDipoleField & getField()
Get corrector field.
virtual void setBy(double)
Set vertical field component in Teslas.
Representation for a perturbed closed orbit corrector.
A geometry representing a straight line.
Abstract interface for read/write access to variable.
Definition: Channel.h:32
virtual void setBy(double By)
Set vertical component.
const std::string name
virtual void setActive(bool flag=true)
Set active flag.
virtual void setBx(double)
Set horizontal field component in Teslas.
bool active
The active/inactive flag.
Definition: CorrectorRep.h:109
Access to a [b]double[/b] data member.