Class: Escalator::Uploader
- Inherits:
-
Object
- Object
- Escalator::Uploader
- Includes:
- PlcDefine
- Defined in:
- lib/escalator/uploader.rb
Constant Summary
Constants included from PlcDefine
PlcDefine::ESC_STATUS_FROM_PLC_ACK_CLEAR_PROGRAM, PlcDefine::ESC_STATUS_FROM_PLC_CYCLE_RUN, PlcDefine::ESC_STATUS_TO_PLC_CLEAR_PROGRAM, PlcDefine::ESC_STATUS_TO_PLC_STOP_PLC_FLAG
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Uploader
constructor
A new instance of Uploader.
- #upload ⇒ Object
- #word_data ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Uploader
Returns a new instance of Uploader.
36 37 38 |
# File 'lib/escalator/uploader.rb', line 36 def initialize ={} @protocol = [:protocol] if [:protocol] end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
34 35 36 |
# File 'lib/escalator/uploader.rb', line 34 def data @data end |
#protocol ⇒ Object
Returns the value of attribute protocol.
32 33 34 |
# File 'lib/escalator/uploader.rb', line 32 def protocol @protocol end |
#source ⇒ Object
Returns the value of attribute source.
33 34 35 |
# File 'lib/escalator/uploader.rb', line 33 def source @source end |
Instance Method Details
#upload ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/escalator/uploader.rb', line 40 def upload # stop plc stop_plc clear_program write_program run_plc end |
#word_data ⇒ Object
55 56 57 58 59 60 |
# File 'lib/escalator/uploader.rb', line 55 def word_data data.each_slice(2).map do |pair| pair << 0 if pair.size == 1 pair.pack("c*").unpack("n*") end.flatten end |