Class: OutputState
Overview
Constant Summary
collapse
- PORTS =
{
:a => 0x00,
:b => 0x01,
:c => 0x02,
:all => 0xff
}
- REGULATION_MODES =
{
:idle => RegulationMode.IDLE,
:motor_speed => RegulationMode.MOTOR_SPEED,
:motor_sync => RegulationMode.MOTOR_SYNC
}
- RUN_STATES =
{
:idle => RunState.IDLE,
:ramp_up => RunState.RAMPUP,
:running => RunState.RUNNING,
:ramp_down => RunState.RAMPDOWN
}
MessageTranslator::FILENAME_MAX_LENGTH
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#add_default_extension_if_missing, #boolean_as_bytes, #boolean_from_bytes, #integer_as_bytes, #integer_as_ulong_bytes, #integer_as_uword_bytes, #integer_from_bytes, #string_as_bytes, #string_from_bytes
Constructor Details
#initialize(options = {}) ⇒ OutputState
Returns a new instance of OutputState.
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 117
def initialize(options={})
options = {
:port => :all,
:power => 0,
:mode_flags => 0,
:regulation_mode => :idle,
:turn_ratio => 0,
:run_state => :idle,
:tacho_limit => 0
}.merge(options)
options.keys.each do |key|
self.send("#{key}=", options[key])
end
end
|
Instance Attribute Details
#mode_flags ⇒ Object
Returns the value of attribute mode_flags.
75
76
77
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 75
def mode_flags
@mode_flags
end
|
#port ⇒ Object
Returns the value of attribute port.
75
76
77
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 75
def port
@port
end
|
#power ⇒ Object
Returns the value of attribute power.
75
76
77
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 75
def power
@power
end
|
#regulation_mode ⇒ Object
Returns the value of attribute regulation_mode.
75
76
77
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 75
def regulation_mode
@regulation_mode
end
|
#run_state ⇒ Object
Returns the value of attribute run_state.
75
76
77
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 75
def run_state
@run_state
end
|
#tacho_limit ⇒ Object
Returns the value of attribute tacho_limit.
75
76
77
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 75
def tacho_limit
@tacho_limit
end
|
#turn_ratio ⇒ Object
Returns the value of attribute turn_ratio.
75
76
77
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 75
def turn_ratio
@turn_ratio
end
|
Class Method Details
.ports ⇒ Object
99
100
101
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 99
def ports
PORTS.keys
end
|
.regulation_modes ⇒ Object
103
104
105
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 103
def regulation_modes
REGULATION_MODES.keys
end
|
.RUN_FOREVER ⇒ Object
used with the tacho_limit
112
113
114
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 112
def RUN_FOREVER
0
end
|
.run_states ⇒ Object
107
108
109
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 107
def run_states
RUN_STATES.keys
end
|
Instance Method Details
#as_bytes ⇒ Object
216
217
218
219
220
221
222
223
224
225
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 216
def as_bytes
[
PORTS[port],
power,
mode_flags,
REGULATION_MODES[regulation_mode],
turn_ratio,
RUN_STATES[run_state]
].concat(integer_as_ulong_bytes(tacho_limit))
end
|
#for_port(the_port) ⇒ Object
143
144
145
146
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 143
def for_port(the_port)
self.port = the_port
self
end
|
#ports ⇒ Object
133
134
135
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 133
def ports
self.class.ports
end
|
#regulation_modes ⇒ Object
168
169
170
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 168
def regulation_modes
self.class.regulation_modes
end
|
#run_states ⇒ Object
192
193
194
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 192
def run_states
self.class.run_states
end
|
#with_mode_flags(mode_flags) ⇒ Object
163
164
165
166
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 163
def with_mode_flags(mode_flags)
self.mode_flags = mode_flags
self
end
|
#with_power(power) ⇒ Object
153
154
155
156
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 153
def with_power(power)
self.power = power
self
end
|
#with_regulation_mode(regulation_mode) ⇒ Object
177
178
179
180
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 177
def with_regulation_mode(regulation_mode)
self.regulation_mode = regulation_mode
self
end
|
#with_run_state(run_state) ⇒ Object
201
202
203
204
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 201
def with_run_state(run_state)
self.run_state = run_state
self
end
|
#with_tacho_limit(tacho_limit) ⇒ Object
211
212
213
214
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 211
def with_tacho_limit(tacho_limit)
self.tacho_limit = tacho_limit
self
end
|
#with_turn_ratio(turn_ratio) ⇒ Object
187
188
189
190
|
# File 'lib/telegrams/commands/direct/output_state.rb', line 187
def with_turn_ratio(turn_ratio)
self.turn_ratio = turn_ratio
self
end
|