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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34dfde956008c06eeb01284d7094a1a641eeee761688883c15973d82b27b395b
4
- data.tar.gz: e82af600dfdb7f790e3f18282a14b2963cd307a9eaa9281b6f00bc1a8c72edd3
3
+ metadata.gz: 07c1a180206229cb23f7ab6bbb5e8034ab4fedbb8735ab0a1b1317a960cc29e2
4
+ data.tar.gz: e500c6b8b4fc9cceece797bfca1d09756a0b7723dd6c28ee67680e318d8215e8
5
5
  SHA512:
6
- metadata.gz: 137bbe38d4e0273d68db494c313a969d6bda3e6ce078e048551364b2f086e7358edde9236ce21aeb8e2484d0d205b92804813b3c1a4858d7dc3da0d5bc59c955
7
- data.tar.gz: 283cac2f5215effe5d55d379f8984b37caac8bd15fa7aa6d44b6a3e803ce2c28697444203ba4d7bd465fe7231d0ba3f68b396c0cc91e8a6d3a635238e6a50c5c
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
- 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)
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
- serial = EventMachine.open_serial(serial_port, serial_baud, serial_parity,LabInterface)
53
- puts "RUNNING SERIAL ON #{serial_port} ------------ #{serial.to_s}"
54
- self.ethernet_server = EventMachine::start_server self.server_ip, self.server_port, LabInterface
55
- AstmServer.log("Running ETHERNET SERVER on #{server_port}")
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
@@ -11,6 +11,9 @@ module LabInterface
11
11
  EOT = "\x04"
12
12
 
13
13
 
14
+ mattr_accessor :ethernet_connections
15
+ mattr_accessor :serial_connections
16
+
14
17
  mattr_accessor :ethernet_server
15
18
  mattr_accessor :server_ip
16
19
  mattr_accessor :server_port
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_astm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bhargav Raut