LMG_modbus 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/LICENSE +0 -2
  2. data/Rakefile +2 -2
  3. data/lib/LMG_modbus.rb +5 -2
  4. data/lib/example.rb +32 -17
  5. metadata +5 -5
data/LICENSE CHANGED
@@ -1,3 +1 @@
1
1
  == LMG_modbus
2
-
3
- Put appropriate LICENSE for your project here.
data/Rakefile CHANGED
@@ -12,12 +12,12 @@ require 'rake/testtask'
12
12
 
13
13
  spec = Gem::Specification.new do |s|
14
14
  s.name = 'LMG_modbus'
15
- s.version = '1.0.2'
15
+ s.version = '1.0.3'
16
16
  s.has_rdoc = true
17
17
  s.extra_rdoc_files = ['README', 'LICENSE']
18
18
  s.summary = 'Useful set of test automation classes for bulk polling and bulk writing modbus registers'
19
19
  s.description = s.summary
20
- s.author = ''
20
+ s.author = 'Scott Shanks'
21
21
  s.email = ''
22
22
  # s.executables = ['your_executable_here']
23
23
  s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,lib,spec}/**/*")
data/lib/LMG_modbus.rb CHANGED
@@ -125,7 +125,7 @@ module LMG_Modbus_Client
125
125
  end
126
126
  epoch << val
127
127
  end
128
- puts Time.at(epoch.to_i(2))
128
+ puts Time.at(epoch.to_i(2)).getgm
129
129
  end
130
130
  def write_time_register(addr,val)
131
131
  time = val.to_i.to_s(2)
@@ -277,7 +277,7 @@ class ModbusPollerTCP
277
277
  # path_to_base_ss:: the spreadsheet that contains the modbus datapoints to poll.
278
278
  # path_to_modpoll:: the path to the modpoll executable.
279
279
  # encapsulation:: whether or not to use encapsulated RTU over TCP
280
- def initialize(slave_addr, ip,path_to_base_ss,path_to_modpoll,encapsulation)
280
+ def initialize(slave_addr, ip,path_to_base_ss,path_to_modpoll,encapsulation='rtu')
281
281
 
282
282
  prepare_test(path_to_base_ss,path_to_modpoll)
283
283
  case encapsulation
@@ -327,3 +327,6 @@ class ModbusTCP < ModBus::TCPClient
327
327
  include ModbusPoller
328
328
  end
329
329
 
330
+ test = ModbusTCP.new('126.4.202.199')
331
+ print "Time from UUT (Modbus Server: "
332
+ test.read_time_register(9998)
data/lib/example.rb CHANGED
@@ -12,10 +12,10 @@ RESULT_DEFAULT = 'K'
12
12
  RESULT_POSITIVE = 'L'
13
13
  RESULT_NEGATIVE = 'M'
14
14
 
15
- ## Example - Write register test 485
16
-
17
- #test = Modbus485.new('com1')
18
- #test.create_test('C:\Documents and Settings\shanksstemp\My Documents\Testing\V4Cooling2\CR\CRV_FDM_462_write_driver.xls')
15
+ ## Example - Write register test tcp
16
+ #
17
+ #test = ModbusTCP.new('126.4.202.199')
18
+ #test.create_test('C:\Documents and Settings\shanksstemp\My Documents\Testing\V4Cooling2\HPC\MediumBoard\HPC_FDM_26_mediumboard_tcp_write_driver.xls')
19
19
  #puts "Running Positive Tests"
20
20
  #test.run_modbus_write(WRITE_POSITIVE,RESULT_POSITIVE)
21
21
  #puts "Running Negative Tests"
@@ -24,25 +24,40 @@ RESULT_NEGATIVE = 'M'
24
24
  #test.run_modbus_write(WRITE_DEFAULT,RESULT_DEFAULT) #default
25
25
  #test.close
26
26
 
27
- # Example - Write register test TCP
27
+ ## Example - Write register test 485
28
28
  #
29
- #test = ModbusTCP.new('126.4.202.199')
30
- #test.create_test('C:\Documents and Settings\shanksstemp\Desktop\PA\DS\LiebertDS_FDM_35_writedriver.xls')
31
- #test.run_modbus_write('g','k')
29
+ #test = Modbus485.new('com1')
30
+ #test.create_test('C:\Documents and Settings\shanksstemp\My Documents\Testing\V4Cooling2\HPC\MediumBoard\HPC_FDM_26_mediumboard_485_write_driver.xls')
31
+ #puts "Running Positive Tests"
32
+ #test.run_modbus_write(WRITE_POSITIVE,RESULT_POSITIVE)
33
+ #puts "Running Negative Tests"
34
+ #test.run_modbus_write(WRITE_NEGATIVE,RESULT_NEGATIVE)
35
+ #puts "Restoring Default"
36
+ #test.run_modbus_write(WRITE_DEFAULT,RESULT_DEFAULT) #default
32
37
  #test.close
33
38
 
34
- # Example - Static Test using modpoll
39
+ # Example - Static Test using modpoll 485
40
+
41
+ #test = ModbusPoller485.new(1, 'com1','C:\Documents and Settings\shanksstemp\My Documents\Testing\V4Cooling2\HPC\MediumBoard\HPC_FDM_26_mediumboard.xls','c:\win32')
42
+ #test.run
43
+
44
+ # Example - Static Test using modpoll TCP
35
45
 
36
- #test = ModbusPoller485.new(1, 'com1','C:\Documents and Settings\shanksstemp\My Documents\Testing\V4Cooling2\CR\CRV_FDM_462.xls','c:\win32')
46
+ #test = ModbusPollerTCP.new(1, '126.4.202.199','C:\Documents and Settings\shanksstemp\My Documents\Testing\V4Cooling2\HPC\MediumBoard\HPC_FDM_26_mediumboard.xls','c:\win32', 'rtu')
37
47
  #test.run
38
48
 
39
- #Example - Read time and set time
49
+ #Example - Read time and set time TCP
50
+
51
+ #test = ModbusTCP.new('126.4.202.199')
52
+ #test.read_time_register(9998)
53
+ #test.write_time_register(9998,Time.now-10*YEAR)
54
+ #sleep(10)
55
+ #test.read_time_register(9998)
56
+
57
+ #Example - Read time and set time 485
58
+
40
59
  test = Modbus485.new('com1')
41
- #test.read_time_register(258)
42
- #test.read_time_register(260)
43
- #test.read_time_register(265)
44
60
  test.read_time_register(9998)
45
-
46
- test.write_time_register(9998,Time.now-30*YEAR)
47
- sleep(60)
61
+ test.write_time_register(9998,Time.now-YEAR)
62
+ sleep(10)
48
63
  test.read_time_register(9998)
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: LMG_modbus
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 2
10
- version: 1.0.2
9
+ - 3
10
+ version: 1.0.3
11
11
  platform: ruby
12
12
  authors:
13
- - ""
13
+ - Scott Shanks
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-02 00:00:00 -04:00
18
+ date: 2010-06-08 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies: []
21
21