Class: RTP::SimulationField

Inherits:
Record
  • Object
show all
Defined in:
lib/rtp-connect/simulation_field.rb

Overview

Note:

Relations:

  • Parent: Prescription

  • Children: none

The simulation field class.

Instance Attribute Summary collapse

Attributes inherited from Record

#crc, #keyword

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Record

#encode, #get_parent, #to_record

Constructor Details

#initialize(parent) ⇒ SimulationField

Creates a new SimulationField.

Parameters:

  • parent (Record)

    a record which is used to determine the proper parent of this instance



141
142
143
144
145
146
# File 'lib/rtp-connect/simulation_field.rb', line 141

def initialize(parent)
  # Parent relation (may get more than one type of record here):
  @parent = get_parent(parent.to_record, Prescription)
  @parent.add_simulation_field(self)
  @keyword = 'SIM_DEF'
end

Instance Attribute Details

#ap_separationObject

Returns the value of attribute ap_separation.



34
35
36
# File 'lib/rtp-connect/simulation_field.rb', line 34

def ap_separation
  @ap_separation
end

#blade_xObject

Returns the value of attribute blade_x.



51
52
53
# File 'lib/rtp-connect/simulation_field.rb', line 51

def blade_x
  @blade_x
end

#blade_x1Object

Returns the value of attribute blade_x1.



52
53
54
# File 'lib/rtp-connect/simulation_field.rb', line 52

def blade_x1
  @blade_x1
end

#blade_x2Object

Returns the value of attribute blade_x2.



53
54
55
# File 'lib/rtp-connect/simulation_field.rb', line 53

def blade_x2
  @blade_x2
end

#blade_x_modeObject

Returns the value of attribute blade_x_mode.



50
51
52
# File 'lib/rtp-connect/simulation_field.rb', line 50

def blade_x_mode
  @blade_x_mode
end

#blade_yObject

Returns the value of attribute blade_y.



55
56
57
# File 'lib/rtp-connect/simulation_field.rb', line 55

def blade_y
  @blade_y
end

#blade_y1Object

Returns the value of attribute blade_y1.



56
57
58
# File 'lib/rtp-connect/simulation_field.rb', line 56

def blade_y1
  @blade_y1
end

#blade_y2Object

Returns the value of attribute blade_y2.



57
58
59
# File 'lib/rtp-connect/simulation_field.rb', line 57

def blade_y2
  @blade_y2
end

#blade_y_modeObject

Returns the value of attribute blade_y_mode.



54
55
56
# File 'lib/rtp-connect/simulation_field.rb', line 54

def blade_y_mode
  @blade_y_mode
end

#collimator_angleObject

Returns the value of attribute collimator_angle.



19
20
21
# File 'lib/rtp-connect/simulation_field.rb', line 19

def collimator_angle
  @collimator_angle
end

#collimator_x1Object

Returns the value of attribute collimator_x1.



22
23
24
# File 'lib/rtp-connect/simulation_field.rb', line 22

def collimator_x1
  @collimator_x1
end

#collimator_x2Object

Returns the value of attribute collimator_x2.



23
24
25
# File 'lib/rtp-connect/simulation_field.rb', line 23

def collimator_x2
  @collimator_x2
end

#collimator_y1Object

Returns the value of attribute collimator_y1.



26
27
28
# File 'lib/rtp-connect/simulation_field.rb', line 26

def collimator_y1
  @collimator_y1
end

#collimator_y2Object

Returns the value of attribute collimator_y2.



27
28
29
# File 'lib/rtp-connect/simulation_field.rb', line 27

def collimator_y2
  @collimator_y2
end

#couch_angleObject

Returns the value of attribute couch_angle.



31
32
33
# File 'lib/rtp-connect/simulation_field.rb', line 31

def couch_angle
  @couch_angle
end

#couch_lateralObject

Returns the value of attribute couch_lateral.



29
30
31
# File 'lib/rtp-connect/simulation_field.rb', line 29

def couch_lateral
  @couch_lateral
end

#couch_longitudinalObject

Returns the value of attribute couch_longitudinal.



30
31
32
# File 'lib/rtp-connect/simulation_field.rb', line 30

def couch_longitudinal
  @couch_longitudinal
end

#couch_pedestalObject

Returns the value of attribute couch_pedestal.



32
33
34
# File 'lib/rtp-connect/simulation_field.rb', line 32

def couch_pedestal
  @couch_pedestal
end

#couch_verticalObject

Returns the value of attribute couch_vertical.



28
29
30
# File 'lib/rtp-connect/simulation_field.rb', line 28

def couch_vertical
  @couch_vertical
end

#field_idObject

Returns the value of attribute field_id.



15
16
17
# File 'lib/rtp-connect/simulation_field.rb', line 15

def field_id
  @field_id
end

#field_nameObject

Returns the value of attribute field_name.



14
15
16
# File 'lib/rtp-connect/simulation_field.rb', line 14

def field_name
  @field_name
end

#field_noteObject

Returns the value of attribute field_note.



16
17
18
# File 'lib/rtp-connect/simulation_field.rb', line 16

def field_note
  @field_note
end

#field_xObject

Returns the value of attribute field_x.



21
22
23
# File 'lib/rtp-connect/simulation_field.rb', line 21

def field_x
  @field_x
end

#field_x_modeObject

Returns the value of attribute field_x_mode.



20
21
22
# File 'lib/rtp-connect/simulation_field.rb', line 20

def field_x_mode
  @field_x_mode
end

#field_yObject

Returns the value of attribute field_y.



25
26
27
# File 'lib/rtp-connect/simulation_field.rb', line 25

def field_y
  @field_y
end

#field_y_modeObject

Returns the value of attribute field_y_mode.



24
25
26
# File 'lib/rtp-connect/simulation_field.rb', line 24

def field_y_mode
  @field_y_mode
end

#gantry_angleObject

Returns the value of attribute gantry_angle.



18
19
20
# File 'lib/rtp-connect/simulation_field.rb', line 18

def gantry_angle
  @gantry_angle
end

#ii_lateralObject

Returns the value of attribute ii_lateral.



58
59
60
# File 'lib/rtp-connect/simulation_field.rb', line 58

def ii_lateral
  @ii_lateral
end

#ii_longitudinalObject

Returns the value of attribute ii_longitudinal.



59
60
61
# File 'lib/rtp-connect/simulation_field.rb', line 59

def ii_longitudinal
  @ii_longitudinal
end

#ii_verticalObject

Returns the value of attribute ii_vertical.



60
61
62
# File 'lib/rtp-connect/simulation_field.rb', line 60

def ii_vertical
  @ii_vertical
end

#kvpObject

Returns the value of attribute kvp.



61
62
63
# File 'lib/rtp-connect/simulation_field.rb', line 61

def kvp
  @kvp
end

#lateral_separationObject

Returns the value of attribute lateral_separation.



36
37
38
# File 'lib/rtp-connect/simulation_field.rb', line 36

def lateral_separation
  @lateral_separation
end

#maObject

Returns the value of attribute ma.



62
63
64
# File 'lib/rtp-connect/simulation_field.rb', line 62

def ma
  @ma
end

#other_label_1Object

Returns the value of attribute other_label_1.



38
39
40
# File 'lib/rtp-connect/simulation_field.rb', line 38

def other_label_1
  @other_label_1
end

#other_label_2Object

Returns the value of attribute other_label_2.



41
42
43
# File 'lib/rtp-connect/simulation_field.rb', line 41

def other_label_2
  @other_label_2
end

#other_label_3Object

Returns the value of attribute other_label_3.



44
45
46
# File 'lib/rtp-connect/simulation_field.rb', line 44

def other_label_3
  @other_label_3
end

#other_label_4Object

Returns the value of attribute other_label_4.



47
48
49
# File 'lib/rtp-connect/simulation_field.rb', line 47

def other_label_4
  @other_label_4
end

#other_measurement_1Object

Returns the value of attribute other_measurement_1.



42
43
44
# File 'lib/rtp-connect/simulation_field.rb', line 42

def other_measurement_1
  @other_measurement_1
end

#other_measurement_2Object

Returns the value of attribute other_measurement_2.



43
44
45
# File 'lib/rtp-connect/simulation_field.rb', line 43

def other_measurement_2
  @other_measurement_2
end

#other_measurement_3Object

Returns the value of attribute other_measurement_3.



45
46
47
# File 'lib/rtp-connect/simulation_field.rb', line 45

def other_measurement_3
  @other_measurement_3
end

#other_measurement_4Object

Returns the value of attribute other_measurement_4.



46
47
48
# File 'lib/rtp-connect/simulation_field.rb', line 46

def other_measurement_4
  @other_measurement_4
end

#other_measurement_5Object

Returns the value of attribute other_measurement_5.



48
49
50
# File 'lib/rtp-connect/simulation_field.rb', line 48

def other_measurement_5
  @other_measurement_5
end

#other_measurement_6Object

Returns the value of attribute other_measurement_6.



49
50
51
# File 'lib/rtp-connect/simulation_field.rb', line 49

def other_measurement_6
  @other_measurement_6
end

#pa_separationObject

Returns the value of attribute pa_separation.



35
36
37
# File 'lib/rtp-connect/simulation_field.rb', line 35

def pa_separation
  @pa_separation
end

#parentObject (readonly)

The Record which this instance belongs to.



12
13
14
# File 'lib/rtp-connect/simulation_field.rb', line 12

def parent
  @parent
end

#rx_site_nameObject

Returns the value of attribute rx_site_name.



13
14
15
# File 'lib/rtp-connect/simulation_field.rb', line 13

def rx_site_name
  @rx_site_name
end

#sadObject

Returns the value of attribute sad.



33
34
35
# File 'lib/rtp-connect/simulation_field.rb', line 33

def sad
  @sad
end

#secondsObject

Returns the value of attribute seconds.



63
64
65
# File 'lib/rtp-connect/simulation_field.rb', line 63

def seconds
  @seconds
end

#sfd_1Object

Returns the value of attribute sfd_1.



40
41
42
# File 'lib/rtp-connect/simulation_field.rb', line 40

def sfd_1
  @sfd_1
end

#ssd_1Object

Returns the value of attribute ssd_1.



39
40
41
# File 'lib/rtp-connect/simulation_field.rb', line 39

def ssd_1
  @ssd_1
end

#tangential_separationObject

Returns the value of attribute tangential_separation.



37
38
39
# File 'lib/rtp-connect/simulation_field.rb', line 37

def tangential_separation
  @tangential_separation
end

#treatment_machineObject

Returns the value of attribute treatment_machine.



17
18
19
# File 'lib/rtp-connect/simulation_field.rb', line 17

def treatment_machine
  @treatment_machine
end

Class Method Details

.load(string, parent) ⇒ Field

Creates a new SimulationField by parsing a RTPConnect string line.

Parameters:

  • string (#to_s)

    the simulation field definition record string line

  • parent (Record)

    a record which is used to determine the proper parent of this instance

Returns:

  • (Field)

    the created SimulationField instance

Raises:

  • (ArgumentError)

    if given a string containing an invalid number of elements



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/rtp-connect/simulation_field.rb', line 72

def self.load(string, parent)
  # Get the quote-less values:
  values = string.to_s.values
  low_limit = 17
  high_limit = 53
  raise ArgumentError, "Invalid argument 'string': Expected at least #{low_limit} elements, got #{values.length}." if values.length < low_limit
  RTP.logger.warn "The number of elements (#{values.length}) for this Simulation Field record exceeds the known number of data items for this record (#{high_limit}). This may indicate an invalid record or that the RTP format has recently been expanded with new items." if values.length > high_limit
  sf = self.new(parent)
  # Assign the values to attributes:
  sf.keyword = values[0]
  sf.rx_site_name = values[1]
  sf.field_name = values[2]
  sf.field_id = values[3]
  sf.field_note = values[4]
  sf.treatment_machine = values[5]
  sf.gantry_angle = values[6]
  sf.collimator_angle = values[7]
  sf.field_x_mode = values[8]
  sf.field_x = values[9]
  sf.collimator_x1 = values[10]
  sf.collimator_x2 = values[11]
  sf.field_y_mode = values[12]
  sf.field_y = values[13]
  sf.collimator_y1 = values[14]
  sf.collimator_y2 = values[15]
  sf.couch_vertical = values[16]
  sf.couch_lateral = values[17]
  sf.couch_longitudinal = values[18]
  sf.couch_angle = values[19]
  sf.couch_pedestal = values[20]
  sf.sad = values[21]
  sf.ap_separation = values[22]
  sf.pa_separation = values[23]
  sf.lateral_separation = values[24]
  sf.tangential_separation = values[25]
  sf.other_label_1 = values[26]
  sf.ssd_1 = values[27]
  sf.sfd_1 = values[28]
  sf.other_label_2 = values[29]
  sf.other_measurement_1 = values[30]
  sf.other_measurement_2 = values[31]
  sf.other_label_3 = values[32]
  sf.other_measurement_3 = values[33]
  sf.other_measurement_4 = values[34]
  sf.other_label_4 = values[35]
  sf.other_measurement_5 = values[36]
  sf.other_measurement_6 = values[37]
  sf.blade_x_mode = values[38]
  sf.blade_x = values[39]
  sf.blade_x1 = values[40]
  sf.blade_x2 = values[41]
  sf.blade_y_mode = values[42]
  sf.blade_y = values[43]
  sf.blade_y1 = values[44]
  sf.blade_y2 = values[45]
  sf.ii_lateral = values[46]
  sf.ii_longitudinal = values[47]
  sf.ii_vertical = values[48]
  sf.kvp = values[49]
  sf.ma = values[50]
  sf.seconds = values[51]
  sf.crc = values[-1]
  return sf
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Checks for equality.

Other and self are considered equivalent if they are of compatible types and their attributes are equivalent.

Parameters:

  • other

    an object to be compared with self.

Returns:

  • (Boolean)

    true if self and other are considered equivalent



156
157
158
159
160
# File 'lib/rtp-connect/simulation_field.rb', line 156

def ==(other)
  if other.respond_to?(:to_simulation_field)
    other.send(:state) == state
  end
end

#childrenArray

Collects the child records of this instance in a properly sorted array.

Returns:

  • (Array)

    an emtpy array



168
169
170
# File 'lib/rtp-connect/simulation_field.rb', line 168

def children
  return Array.new
end

#hashFixnum

Note:

Two objects with the same attributes will have the same hash code.

Computes a hash code for this object.

Returns:

  • (Fixnum)

    the object’s hash code



178
179
180
# File 'lib/rtp-connect/simulation_field.rb', line 178

def hash
  state.hash
end

#keyword=(value) ⇒ Object

Note:

Since only a specific string is accepted, this is more of an argument check than a traditional setter method

Sets the keyword attribute.

Parameters:

  • value (#to_s)

    the new attribute value

Raises:

  • (ArgumentError)

    if given an unexpected keyword



275
276
277
278
279
# File 'lib/rtp-connect/simulation_field.rb', line 275

def keyword=(value)
  value = value.to_s.upcase
  raise ArgumentError, "Invalid keyword. Expected 'SIM_DEF', got #{value}." unless value == "SIM_DEF"
  @keyword = value
end

#to_sString Also known as: to_str

Encodes the SimulationField object + any hiearchy of child objects, to a properly formatted RTPConnect ascii string.

Returns:

  • (String)

    an RTP string with a single or multiple lines/records



257
258
259
260
261
262
263
264
265
# File 'lib/rtp-connect/simulation_field.rb', line 257

def to_s
  str = encode
  if children
    children.each do |child|
      str += child.to_s
    end
  end
  return str
end

#to_simulation_fieldSimulationField

Returns self.

Returns:



248
249
250
# File 'lib/rtp-connect/simulation_field.rb', line 248

def to_simulation_field
  self
end

#valuesArray<String> Also known as: state

Note:

The CRC is not considered part of the actual values and is excluded.

Collects the values (attributes) of this instance.

Returns:

  • (Array<String>)

    an array of attributes (in the same order as they appear in the RTP string)



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/rtp-connect/simulation_field.rb', line 187

def values
  return [
    @keyword,
    @rx_site_name,
    @field_name,
    @field_id,
    @field_note,
    @treatment_machine,
    @gantry_angle,
    @collimator_angle,
    @field_x_mode,
    @field_x,
    @collimator_x1,
    @collimator_x2,
    @field_y_mode,
    @field_y,
    @collimator_y1,
    @collimator_y2,
    @couch_vertical,
    @couch_lateral,
    @couch_longitudinal,
    @couch_angle,
    @couch_pedestal,
    @sad,
    @ap_separation,
    @pa_separation,
    @lateral_separation,
    @tangential_separation,
    @other_label_1,
    @ssd_1,
    @sfd_1,
    @other_label_2,
    @other_measurement_1,
    @other_measurement_2,
    @other_label_3,
    @other_measurement_3,
    @other_measurement_4,
    @other_label_4,
    @other_measurement_5,
    @other_measurement_6,
    @blade_x_mode,
    @blade_x,
    @blade_x1,
    @blade_x2,
    @blade_y_mode,
    @blade_y,
    @blade_y1,
    @blade_y2,
    @ii_lateral,
    @ii_longitudinal,
    @ii_vertical,
    @kvp,
    @ma,
    @seconds
  ]
end