OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
TravelingWaveRep.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: RFCavityRep.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: RFCavityRep
10 // Defines a representation for a RF cavity.
11 //
12 // ------------------------------------------------------------------------
13 // Class category: BeamlineCore
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2000/03/27 09:32:34 $
17 // $Author: fci $
18 //
19 // ------------------------------------------------------------------------
20 
24 
25 
26 // Attribute access table.
27 // ------------------------------------------------------------------------
28 
30 
31 namespace {
32  struct Entry {
33  const char *name;
34  double(TravelingWaveRep::*get)() const;
35  void (TravelingWaveRep::*set)(double);
36  };
37 
38  static const Entry entries[] = {
39  {
40  "L",
43  },
44  {
45  "AMPLITUDE",
48  },
49  {
50  "FREQUENCY",
53  },
54  {
55  "PHASE",
58  },
59  { 0, 0, 0 }
60  };
61 }
62 
63 
64 // Class TravelingWaveRep
65 // ------------------------------------------------------------------------
66 
69 {}
70 
71 
73  TravelingWave(right)
74 {}
75 
76 
78  TravelingWave(name)
79 {}
80 
81 
83 {}
84 
85 
87  return new TravelingWaveRep(*this);
88 }
89 
90 
91 Channel *TravelingWaveRep::getChannel(const std::string &aKey, bool create) {
92  for(const Entry *entry = entries; entry->name != 0; ++entry) {
93  if(aKey == entry->name) {
94 
95  return new IndirectChannel<TravelingWaveRep>(*this, entry->get, entry->set);
96  }
97  }
98 
99  return ElementBase::getChannel(aKey, create);
100 }
101 
102 
104  return field;
105 }
106 
108  return field;
109 }
110 
111 
113  return geometry;
114 }
115 
117  return geometry;
118 }
119 
120 
123 
124  for(const Entry *entry = entries; entry->name != 0; ++entry) {
125  image->setAttribute(entry->name, (this->*(entry->get))());
126  }
127 
128  return image;
129 }
130 
131 
133  return ignoreCavities ? 0.0 : field.getEz();
134 }
135 
136 
138  return field.getFrequency();
139 }
140 
141 
143  return field.getPhase();
144 }
145 
146 
147 void TravelingWaveRep::setAmplitude(double amplitude) {
148  field.setEz(amplitude);
149 }
150 
151 
152 void TravelingWaveRep::setFrequency(double frequency) {
153  field.setFrequency(frequency);
154 }
155 
156 
157 void TravelingWaveRep::setPhase(double phase) {
158  field.setPhase(phase);
159 }
160 
161 void TravelingWaveRep::setIgnore(bool ignore) {
162  ignoreCavities = ignore;
163 }
virtual StraightGeometry & getGeometry()
Get geometry.
Interface for basic beam line object.
Definition: ElementBase.h:128
Representation for a RF cavity.
virtual double getPhase() const
Return the RF phase in rad.
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:515
virtual ~TravelingWaveRep()
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
virtual void setPhase(double phi)
Assign the RF phase in rad.
AcceleratingField field
The cavity&#39;s field.
virtual AcceleratingField & getField()
Get field.
virtual void setFrequency(double f)
Assign the RF frequency in Hz.
static bool ignoreCavities
Cavities are ignored (amplitude = 0) when this switch is set.
virtual void setPhase(double phi)
Set phase.
virtual double getElementLength() const override
Get design length.
An image of an element.
Definition: ElementImage.h:35
virtual ElementImage * getImage() const
Construct an image.
virtual ElementImage * getImage() const
Construct an image.
void setAttribute(const std::string &aKey, double val)
Set value of an attribute.
virtual double getFrequency() const
Return the RF frequency in Hz.
Interface for RF cavity.
Definition: TravelingWave.h:37
virtual void setEz(double)
Set component.
static void setIgnore(bool ignore=false)
Set ignore switch.
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
A geometry representing a straight line.
virtual void setFrequency(double f)
Set frequency.
Abstract interface for read/write access to variable.
Definition: Channel.h:32
virtual ElementBase * clone() const
Return clone.
virtual double getPhase() const
Get phase.
const std::string name
virtual double getAmplitude() const
Get amplitude.
virtual double getFrequency() const
Get frequency.
virtual void setAmplitude(double V)
Set amplitude.
StraightGeometry geometry
The cavity&#39;s geometry.
Access to a [b]double[/b] data member.
virtual double getEz() const
Get component.