ruby_astm 1.2.6 → 1.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby_astm/astm_server.rb +19 -7
- data/lib/ruby_astm/lab_interface.rb +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07c1a180206229cb23f7ab6bbb5e8034ab4fedbb8735ab0a1b1317a960cc29e2
|
4
|
+
data.tar.gz: e500c6b8b4fc9cceece797bfca1d09756a0b7723dd6c28ee67680e318d8215e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edbd9f93955c24d7a051bbb346054d5efe48f7fe76778c2a670a1d41c142f3585d5519bacc03b1ec8f2d7152b13bd6963bac4ef9a79473a0939d60036fff1efe
|
7
|
+
data.tar.gz: ce93d38cb89612fbc319d7c3270530d6963730a11aad61e3f6501dfd4bbc9be700328fc3ed57ef08fa99f0523a8ac4addb5472830d82b12dc9bf8941194595e8
|
@@ -32,9 +32,14 @@ class AstmServer
|
|
32
32
|
|
33
33
|
## DEFAULT SERIAL PORT : /dev/ttyS0
|
34
34
|
## DEFAULT USB PORT : /dev/ttyUSB0
|
35
|
-
|
35
|
+
## @param[Array] ethernet_connections : each element is expected to be a hash, with keys for :server_ip, :server_port.
|
36
|
+
## @param[Array] serial_connections : each element is expected to be a hash with port_address, baud_rate, and parity
|
37
|
+
#def initialize(server_ip=nil,server_port=nil,mpg=nil,respond_to_queries=false,serial_port='/dev/ttyS0',usb_port='/dev/ttyUSB0',serial_baud=9600,serial_parity=8,usb_baud=19200,usb_parity=8)
|
38
|
+
def initialize(ethernet_connections,serial_connections,mpg=nil,respond_to_queries=nil)
|
36
39
|
$redis = Redis.new
|
37
40
|
AstmServer.log("Initializing AstmServer")
|
41
|
+
self.ethernet_connections = ethernet_connections
|
42
|
+
self.serial_connections = serial_connections
|
38
43
|
self.server_ip = server_ip || "127.0.0.1"
|
39
44
|
self.server_port = server_port || 3000
|
40
45
|
self.respond_to_queries = respond_to_queries
|
@@ -49,14 +54,21 @@ class AstmServer
|
|
49
54
|
|
50
55
|
def start_server
|
51
56
|
EventMachine.run {
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
57
|
+
self.ethernet_connections.each do |econn|
|
58
|
+
raise "please provide a valid ethernet configuration with ip address" unless econn[:server_ip]
|
59
|
+
raise "please provide a valid ethernet configuration with port" unless econn[:server_port]
|
60
|
+
EventMachine::start_server econn[:server_ip], econn[:server_port], LabInterface
|
61
|
+
AstmServer.log("Running ETHERNET with configuration #{econn}")
|
62
|
+
end
|
63
|
+
self.serial_connections.each do |sconn|
|
64
|
+
raise "please provide a valid serial configuration with port address" unless sconn[:port_address]
|
65
|
+
raise "please provide a valid serial configuration with baud rate" unless sconn[:baud_rate]
|
66
|
+
raise "please provide a valid serial configuration with parity" unless sconn[:parity]
|
67
|
+
EventMachine.open_serial(sconn[:port_address], sconn[:baud_rate], sconn[:parity],LabInterface)
|
68
|
+
puts "RUNNING SERIAL port with configuration : #{sconn}"
|
69
|
+
end
|
56
70
|
|
57
71
|
}
|
58
72
|
end
|
59
73
|
|
60
74
|
end
|
61
|
-
|
62
|
-
#sudham61@gmail.com
|