rsmp 0.6.3 → 0.7.1

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: 4072d3e93ef2223bfc9ac2cb1a1e34b3668456e52a622a2b6f059087dd442c2e
4
- data.tar.gz: 37603275646789fec0db5ec4c85baf731bebe6786693e6ad57eae7be3b3c29ed
3
+ metadata.gz: 75a0ca211283d5cb97be9e6f6eaf24209a68884b8e368358d0933feef870c743
4
+ data.tar.gz: 4ca8a761d69ae30d8dab706cbe93cdd2dc3ae7667f73d8a9c217467f2f52844a
5
5
  SHA512:
6
- metadata.gz: 84a5e06ed20c8cb3331cf13ebd9bfc8d2baaf6c81ec14d67e83900d198153d86b89aeb09485f87afa9ef5c2aa7ca4469caa190a745dc9936caedc31bbb14d5a5
7
- data.tar.gz: 9aa602447f391353632bf59fccd2ca48ab2eea492913cab875614c50279c362f04ebbf89559d1ea6a72878ef22e632a29160379b682356e8411568710a9d8525
6
+ metadata.gz: f21887cb5550e4f7b242bbd2fbc42c3d5ffaeb99eddcebf4a5af64e8766961c50f20c9fb885d6e8a7e718615b18e6731f01256162b57c437283f50e94646427b
7
+ data.tar.gz: 3875d442deeb61c61c75d46099967da3b7f93b7e35fbc206a7d87cc9f5474004a42b91d6dafe59f2eff5fd94f8b9d1eadbb1ae66ce63e2d4ae793ed6fc38692b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rsmp (0.6.3)
4
+ rsmp (0.7.1)
5
5
  async (~> 1.29.1)
6
6
  async-io (~> 1.32.1)
7
7
  colorize (~> 0.8.1)
data/README.md CHANGED
@@ -125,7 +125,7 @@ This will output messages form both the site and the supervisor, ordered chronol
125
125
  ```console
126
126
  RN+SU0001 Starting supervisor RN+SU0001 on port 12111
127
127
  RN+SI0001 Starting site RN+SI0001
128
- RN+SI0001 Connecting to superviser at 127.0.0.1:12111
128
+ RN+SI0001 Connecting to supervisor at 127.0.0.1:12111
129
129
  RN+SI0001 <-- f8c7 Sent Version
130
130
  RN+SU0001 Site connected from 127.0.0.1:53500
131
131
  RN+SU0001 RN+SI0001 --> f8c7 Received Version message for sites [RN+SI0001] using RSMP 3.1.4
@@ -156,7 +156,7 @@ The ```site``` command will start an RSMP site, which will try to connect to one
156
156
  ```console
157
157
  % rsmp site
158
158
  2019-11-11 12:22:00 UTC Starting site RN+SI0001
159
- 2019-11-11 12:22:00 UTC Connecting to superviser at 127.0.0.1:12111
159
+ 2019-11-11 12:22:00 UTC Connecting to supervisor at 127.0.0.1:12111
160
160
  2019-11-11 12:22:00 UTC <-- 792f Sent Version
161
161
  2019-11-11 12:22:00 UTC RN+SU0001 --> e70e Received Version message, using RSMP 3.1.4
162
162
  2019-11-11 12:22:00 UTC RN+SU0001 Connection to supervisor established
@@ -15,5 +15,3 @@ log:
15
15
  level: false
16
16
  debug: true
17
17
  json: true
18
- acknowledgements: false
19
- watchdogs: false
data/config/tlc.yaml CHANGED
@@ -48,5 +48,3 @@ log:
48
48
  level: false
49
49
  debug: true
50
50
  json: true
51
- acknowledgements: false
52
- watchdogs: false
@@ -79,16 +79,17 @@ module RSMP
79
79
 
80
80
  def handle_alarm message
81
81
  code = message.attribute('aCId')
82
- alarm = @alarms[code]
83
- if alarm
84
- if alarm.differ? message
85
- @alarms[code] = alarm
86
- else
87
- raise RepeatedAlarmError.new("no changes from previous alarm #{alarm.m_id_short}")
82
+ previous = @alarms[code]
83
+ if previous
84
+ unless message.differ?(previous)
85
+ raise RepeatedAlarmError.new("no changes from previous alarm #{previous.m_id_short}")
86
+ end
87
+ if Time.parse(message.attribute('aTs')) < Time.parse(previous.attribute('aTs'))
88
+ raise TimestampError.new("timestamp is earlier than previous alarm #{previous.m_id_short}")
88
89
  end
89
- else
90
- @alarms[code] = message
91
90
  end
91
+ ensure
92
+ @alarms[code] = message
92
93
  end
93
94
 
94
95
  # Handle an incoming status respone, by storing the values
data/lib/rsmp/error.rb CHANGED
@@ -64,4 +64,7 @@ module RSMP
64
64
 
65
65
  class RepeatedStatusError < Error
66
66
  end
67
+
68
+ class TimestampError < Error
69
+ end
67
70
  end
data/lib/rsmp/logger.rb CHANGED
@@ -14,6 +14,7 @@ module RSMP
14
14
  'hide_ip_and_port' => false,
15
15
  'acknowledgements' => false,
16
16
  'watchdogs' => false,
17
+ 'alarms' => true,
17
18
  'json'=>false,
18
19
  'tabs'=>'-',
19
20
 
@@ -24,6 +25,7 @@ module RSMP
24
25
  'ip'=>false,
25
26
  'port'=>false,
26
27
  'site_id'=>true,
28
+ 'component'=>true,
27
29
  'direction'=>false,
28
30
  'level'=>false,
29
31
  'id'=>true,
@@ -43,6 +45,15 @@ module RSMP
43
45
  'id'=>4,
44
46
  }
45
47
 
48
+ @ignorable = {
49
+ 'versions' => ['Version'],
50
+ 'statuses' => ['StatusRequest','StatusSubscribe','StatusUnsubscribe','StatusResponse','StatusUpdate'],
51
+ 'commands' => ['CommandRequest','CommandResponse'],
52
+ 'watchdogs' => 'Watchdog',
53
+ 'alarms' => ['AlarmIssue','AlarmRequest','AlarmAcknowledged','AlarmSuspend','AlarmResume'],
54
+ 'aggregated_status' => ['AggregatedStatus','AggregatedStatusRequest']
55
+ }
56
+
46
57
  if settings
47
58
  @settings = defaults.merge settings
48
59
  else
@@ -95,10 +106,15 @@ module RSMP
95
106
  if item[:message]
96
107
  type = item[:message].type
97
108
  ack = type == "MessageAck" || type == "MessageNotAck"
98
- if @settings["watchdogs"] == false
99
- return false if type == "Watchdog"
100
- if ack
101
- return false if item[:message].original && item[:message].original.type == "Watchdog"
109
+ @ignorable.each_pair do |key,types|
110
+ next unless types
111
+ ignore = [types].flatten
112
+ if @settings[key] == false
113
+ #p [type,ignore_type, [ignore_type].flatten.include?(type)]
114
+ return false if ignore.include?(type)
115
+ if ack
116
+ return false if item[:message].original && ignore.include?(item[:message].original.type)
117
+ end
102
118
  end
103
119
  end
104
120
  return false if ack && @settings["acknowledgements"] == false &&
data/lib/rsmp/message.rb CHANGED
@@ -126,7 +126,7 @@ module RSMP
126
126
  end
127
127
 
128
128
  def initialize attributes = {}
129
- @timestamp = Time.now # this timestamp is for internal use, and does not the clock
129
+ @timestamp = Time.now # this timestamp is for internal use, and does not use the clock
130
130
  # in the node, which can be set by an rsmp supervisor
131
131
 
132
132
  @attributes = { "mType"=> "rSMsg" }.merge attributes
@@ -23,15 +23,22 @@ module RSMP
23
23
  end
24
24
 
25
25
  def start
26
- log "Connecting to superviser at #{@ip}:#{@port}", level: :info
26
+ log "Connecting to supervisor at #{@ip}:#{@port}", level: :info
27
27
  super
28
28
  connect
29
29
  @logger.unmute @ip, @port
30
- log "Connected to superviser at #{@ip}:#{@port}", level: :info
30
+ log "Connected to supervisor at #{@ip}:#{@port}", level: :info
31
31
  start_reader
32
32
  send_version @site_settings['site_id'], @site_settings["rsmp_versions"]
33
- rescue Errno::ECONNREFUSED
34
- log "No connection to supervisor at #{@ip}:#{@port}", level: :error
33
+ rescue SystemCallError => e
34
+ log "Could not connect to supervisor at #{@ip}:#{@port}: Errno #{e.errno} #{e}", level: :error
35
+ retry_notice
36
+ rescue StandardError => e
37
+ log "Error while connecting to supervisor at #{@ip}:#{@port}: #{e}", level: :error
38
+ retry_notice
39
+ end
40
+
41
+ def retry_notice
35
42
  unless @site.site_settings['intervals']['reconnect'] == :no
36
43
  log "Will try to reconnect again every #{@site.site_settings['intervals']['reconnect']} seconds..", level: :info
37
44
  @logger.mute @ip, @port
@@ -19,7 +19,12 @@ module RSMP
19
19
  @signal_plans = {}
20
20
  return unless signal_plans
21
21
  signal_plans.each_pair do |id,settings|
22
- @signal_plans[id.to_i] = SignalPlan.new(nr: id.to_i, states:settings['states'],dynamic_bands:settings['dynamic_bands'])
22
+ states = nil
23
+ bands = nil
24
+ states = settings['states'] if settings
25
+ dynamic_bands = settings['dynamic_bands'] if settings
26
+
27
+ @signal_plans[id.to_i] = SignalPlan.new(nr: id.to_i, states:states,dynamic_bands:dynamic_bands)
23
28
  end
24
29
  end
25
30
 
data/lib/rsmp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RSMP
2
- VERSION = "0.6.3"
2
+ VERSION = "0.7.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsmp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emil Tin