Class: Simatic::Sessions::OpenSession
- Inherits:
-
ExchangeSession
- Object
- Session
- ExchangeSession
- Simatic::Sessions::OpenSession
- Defined in:
- lib/simatic/sessions/open_session.rb
Overview
Open Communication Request->Response session class going second
Instance Method Summary collapse
-
#initialize(max_pdu_length = nil) ⇒ OpenSession
constructor
A new instance of OpenSession.
- #make_request ⇒ Object
- #parse_response(raw_data) ⇒ Object
Methods inherited from Session
Constructor Details
#initialize(max_pdu_length = nil) ⇒ OpenSession
Returns a new instance of OpenSession.
7 8 9 |
# File 'lib/simatic/sessions/open_session.rb', line 7 def initialize max_pdu_length = nil @@max_pdu_length = max_pdu_length if max_pdu_length end |
Instance Method Details
#make_request ⇒ Object
11 12 13 14 |
# File 'lib/simatic/sessions/open_session.rb', line 11 def make_request param = [FuncOpenS7Connection, 0x00, 0x00, 0x01, 0x00, 0x01, @@max_pdu_length].pack('C6n') super param end |
#parse_response(raw_data) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/simatic/sessions/open_session.rb', line 16 def parse_response raw_data super unless FuncOpenS7Connection == @function raise "unknown function 0x#{@function.to_s(16)} in #{self.class} response" end @@max_pdu_length = @params[6,2].unpack('n').first end |