Class: Snap7::Server
- Inherits:
-
Object
- Object
- Snap7::Server
- Defined in:
- lib/ffi-snap7/server/server.rb
Constant Summary collapse
- S7AreaPE =
0
- S7AreaPA =
1
- S7AreaMK =
2
- S7AreaCT =
3
- S7AreaTM =
4
- S7AreaDB =
5
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Server
constructor
A new instance of Server.
- #local_port ⇒ Integer
- #local_port=(port) ⇒ Object
- #register_area(area_code, index, size) ⇒ Object
- #register_db(index, size) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
-
#to_ptr ⇒ FFI::MemoryPointer
Pointer to the native object.
Constructor Details
Class Method Details
.finalizer(ptr) ⇒ Proc
18 19 20 21 22 23 24 |
# File 'lib/ffi-snap7/server/server.rb', line 18 def self.finalizer(ptr) proc do ptrptr = FFI::MemoryPointer.new :pointer ptrptr.write_pointer ptr Snap7.srv_destroy ptrptr end end |
Instance Method Details
#local_port ⇒ Integer
70 71 72 73 74 |
# File 'lib/ffi-snap7/server/server.rb', line 70 def local_port p_port = FFI::MemoryPointer.new(:uint16) check_rc Snap7.srv_get_param(@srv, P_u16_LocalPort, p_port) p_port.read_uint16 end |
#local_port=(port) ⇒ Object
62 63 64 65 66 |
# File 'lib/ffi-snap7/server/server.rb', line 62 def local_port=(port) p_port = FFI::MemoryPointer.new(:uint16) p_port.write_uint16 port check_rc Snap7.srv_set_param(@srv, P_u16_LocalPort, p_port) end |
#register_area(area_code, index, size) ⇒ Object
50 51 52 53 |
# File 'lib/ffi-snap7/server/server.rb', line 50 def register_area(area_code, index, size) p_usr_data = FFI::MemoryPointer.new :uchar, size check_rc Snap7.srv_register_area @srv, area_code, index, p_usr_data, size end |
#register_db(index, size) ⇒ Object
56 57 58 |
# File 'lib/ffi-snap7/server/server.rb', line 56 def register_db(index, size) register_area S7AreaDB, index, size end |
#start ⇒ Object
40 41 42 |
# File 'lib/ffi-snap7/server/server.rb', line 40 def start check_rc Snap7.srv_start(@srv) end |
#stop ⇒ Object
45 46 47 |
# File 'lib/ffi-snap7/server/server.rb', line 45 def stop check_rc Snap7.srv_stop(@srv) end |
#to_ptr ⇒ FFI::MemoryPointer
Returns pointer to the native object.
35 36 37 |
# File 'lib/ffi-snap7/server/server.rb', line 35 def to_ptr @srv end |