rsmp 0.6.4 → 0.7.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33b8c859b9c8450af6a45d52a9d42d982c5becdaf1d4424f398b417bc1c387d8
4
- data.tar.gz: 7f194bb392a69555f7ba30364466dfed9eeb1b04996505fa13af13d9045bb071
3
+ metadata.gz: 1a5a515a9a42c794ebc27efd12ab9d87a1b0281544e06050bfe63f433bdf4a80
4
+ data.tar.gz: 51e2cca7f3e44cf5c4fe6447151436474f1d5001715e8a4ce54c070ce867565e
5
5
  SHA512:
6
- metadata.gz: 2d9da45e5f1a96756cd50f58ea3ce16dc0de51138daa45aa114f432e0531595883c5cf3dba86ad63dd0a33aed7ba02d706f058378c257129a8b877eb45e2246b
7
- data.tar.gz: 59965992a0e7bcdd6e401fac5baa2e8839c392713812da579865020d6cf5d9cf73d51b250f9be72cab3264fd5a9edd287e85619e2ebab0259fb303da9cfe25ff
6
+ metadata.gz: ac5c99fb01e74f49a7bab931fefe9314c1d4279e7c0be9d688de622c60892edb0138ac72b676261fc6e86681e01e30f7b59d28ee33e853389af509b9229f5982
7
+ data.tar.gz: 8050ccd64dc78c49704f403fea069ab62c6f68778a3b3f2fdabba359d74620027959f8ab2bc5ce0fc22193a403301d7454a186fe01f14fd54800534ac640e541
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rsmp (0.6.4)
4
+ rsmp (0.7.2)
5
5
  async (~> 1.29.1)
6
6
  async-io (~> 1.32.1)
7
7
  colorize (~> 0.8.1)
@@ -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
 
@@ -44,6 +45,15 @@ module RSMP
44
45
  'id'=>4,
45
46
  }
46
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
+
47
57
  if settings
48
58
  @settings = defaults.merge settings
49
59
  else
@@ -96,10 +106,15 @@ module RSMP
96
106
  if item[:message]
97
107
  type = item[:message].type
98
108
  ack = type == "MessageAck" || type == "MessageNotAck"
99
- if @settings["watchdogs"] == false
100
- return false if type == "Watchdog"
101
- if ack
102
- 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
103
118
  end
104
119
  end
105
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
@@ -68,7 +68,7 @@ module RSMP
68
68
  else
69
69
  super message
70
70
  end
71
- rescue RSMP::RepeatedAlarmError, RSMP::RepeatedStatusError => e
71
+ rescue RSMP::RepeatedAlarmError, RSMP::RepeatedStatusError, TimestampError => e
72
72
  str = "Rejected #{message.type} message,"
73
73
  dont_acknowledge message, str, "#{e}"
74
74
  notify_error e.exception("#{str}#{e.message} #{message.json}")
@@ -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.4"
2
+ VERSION = "0.7.2"
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.4
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emil Tin