OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
RBendRep.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: RBendRep.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.2.2.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: RBendRep
10 // Defines a concrete representation for rectangular (straight) bend.
11 //
12 // ------------------------------------------------------------------------
13 // Class category: BeamlineCore
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2004/11/12 18:57:53 $
17 // $Author: adelmann $
18 //
19 // ------------------------------------------------------------------------
20 
21 #include "BeamlineCore/RBendRep.h"
26 #include <cctype>
27 
28 // Attribute access table.
29 // ------------------------------------------------------------------------
30 
31 namespace {
32  struct Entry {
33  const char *name;
34  double(RBendRep::*get)() const;
35  void (RBendRep::*set)(double);
36  };
37 
38  const Entry entries[] = {
39  {
40  "L",
43  },
44  { 0, 0, 0 }
45  };
46 }
47 
48 
49 // Class RBendRep
50 // ------------------------------------------------------------------------
51 
53  RBend(),
54  geometry(0.0, 0.0),
55  field() {
56  rEntry = rExit = hEntry = hExit = 0.0;
57 }
58 
59 
61  RBend(rhs),
62  geometry(rhs.geometry),
63  field(rhs.field) {
64  rEntry = rhs.rEntry;
65  rExit = rhs.hExit;
66  hEntry = rhs.rEntry;
67  hExit = rhs.hExit;
68 }
69 
70 
71 RBendRep::RBendRep(const std::string &name):
72  RBend(name),
73  geometry(0.0, 0.0),
74  field() {
75  rEntry = rExit = hEntry = hExit = 0.0;
76 }
77 
78 
80 {}
81 
82 
84  return new RBendRep(*this);
85 }
86 
87 
88 Channel *RBendRep::getChannel(const std::string &aKey, bool create) {
89  return ElementBase::getChannel(aKey, create);
90 }
91 
92 
94  return field;
95 }
96 
98  return field;
99 }
100 
101 
103  return geometry;
104 }
105 
107  return geometry;
108 }
109 
110 
113 
114  for(const Entry *entry = entries; entry->name != 0; ++entry) {
115  image->setAttribute(entry->name, (this->*(entry->get))());
116  }
117 
118  return image;
119 }
120 
121 
122 double RBendRep::getB() const {
123  return field.getNormalComponent(1);
124 }
125 
126 void RBendRep::setB(double B) {
128 }
129 
130 
132  return rEntry;
133 }
134 
135 
137  return rExit;
138 }
139 
141  rEntry = e1;
142 }
143 
145  rExit = e2;
146 }
147 
149  return hEntry;
150 }
151 
153  return hExit;
154 }
155 
157  hEntry = h1;
158 }
159 
161  hExit = h2;
162 }
163 
164 
165 double RBendRep::getSlices() const {
166  return slices;
167 }
168 
169 double RBendRep::getStepsize() const {
170  return stepsize;
171 }
172 
173 void RBendRep::setSlices(double sl) {
174  slices = sl;
175 }
176 
177 void RBendRep::setStepsize(double ds) {
178  stepsize = ds;
179 }
180 
181 
183  field = f;
184 }
185 
186 
188  ElementBase *wrap = new RBendWrapper(this);
189  wrap->setName(getName());
190  return wrap;
191 }
virtual double getSlices() const
Get number of slices.
Definition: RBendRep.cpp:165
virtual double getExitFaceCurvature() const
Get exit pole face curvature.
Definition: RBendRep.cpp:152
virtual void setSlices(double sl)
Set number of slices.
Definition: RBendRep.cpp:173
Interface for basic beam line object.
Definition: ElementBase.h:128
virtual double getEntryFaceRotation() const
Get pole entry face rotation.
Definition: RBendRep.cpp:131
virtual ElementImage * getImage() const
Construct an image.
Definition: RBendRep.cpp:111
Representation for a rectangular bend magnet.
Definition: RBendRep.h:34
void setNormalComponent(int n, double Bn)
Set component.
virtual void setName(const std::string &name)
Set element name.
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:515
Definition: RBend.h:73
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
virtual void setStepsize(double ds)
Set stepsize.
Definition: RBendRep.cpp:177
virtual const std::string & getName() const
Get element name.
Definition: ElementBase.cpp:95
virtual double getEntryFaceCurvature() const
Get entry pole face curvature.
Definition: RBendRep.cpp:148
virtual void setExitFaceRotation(double e2)
Set exit pole face rotation.
Definition: RBendRep.cpp:144
virtual double getStepsize() const
Get stepsize.
Definition: RBendRep.cpp:169
virtual BMultipoleField & getField()
Get field.
Definition: RBendRep.cpp:93
virtual double getB() const
Get field.
Definition: RBendRep.cpp:122
virtual ElementBase * clone() const
Return clone.
Definition: RBendRep.cpp:83
virtual void setB(double By)
Set vertical component.
Definition: RBendRep.cpp:126
virtual void setEntryFaceRotation(double e1)
Set pole entry face rotation.
Definition: RBendRep.cpp:140
double rEntry
Definition: RBendRep.h:161
virtual double getElementLength() const
Get design length.
Definition: ElementBase.h:511
double getNormalComponent(int n) const
Get component.
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 void setEntryFaceCurvature(double h1)
Set entry pole face curvature.
Definition: RBendRep.cpp:156
virtual void setField(const BMultipoleField &field)
Set field.
Definition: RBendRep.cpp:182
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Definition: RBendRep.cpp:88
virtual ~RBendRep()
Definition: RBendRep.cpp:79
The geometry for a RBend element.
Definition: RBendGeometry.h:41
virtual void setExitFaceCurvature(double h2)
Set exit pole face curvature.
Definition: RBendRep.cpp:160
virtual ElementBase * makeFieldWrapper()
Allow field errors.
Definition: RBendRep.cpp:187
Abstract interface for read/write access to variable.
Definition: Channel.h:32
The magnetic field of a multipole.
double hEntry
Definition: RBendRep.h:163
double rExit
Definition: RBendRep.h:162
const std::string name
RBendRep()
Definition: RBendRep.cpp:52
BMultipoleField field
The multipole expansion.
Definition: RBendRep.h:158
virtual RBendGeometry & getGeometry()
Get geometry.
Definition: RBendRep.cpp:102
Representation of a perturbed rectangular bend.
Definition: RBendWrapper.h:37
virtual double getExitFaceRotation() const
Get exit pole face rotation.
Definition: RBendRep.cpp:136
double stepsize
Definition: RBendRep.h:168
double hExit
Definition: RBendRep.h:164
double slices
Definition: RBendRep.h:167
RBendGeometry geometry
The bend geometry.
Definition: RBendRep.h:155