rsmp 0.19.3 → 0.19.5
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rsmp/alarm_state.rb +51 -41
- data/lib/rsmp/component_base.rb +4 -0
- data/lib/rsmp/message.rb +1 -1
- data/lib/rsmp/node.rb +5 -1
- data/lib/rsmp/proxy.rb +5 -0
- data/lib/rsmp/rsmp.rb +3 -0
- data/lib/rsmp/site.rb +3 -6
- data/lib/rsmp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ece63f3127c2afec9954b9395079a4f6bd755c1edfa1ebd86a5b656e0eb3ae7b
|
4
|
+
data.tar.gz: d2649a64d7905095f0c418bc3ad8dcae3e6b5c891a784e7fbdc1841f4b17e2db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70a4b8297b24a0f7d5ffeba0b86ec26bae1d196e01d46d6b06a1cc8ab50b14705f28ecf50ca30f0d4e2487c790781e71e80e6a4c0c4d39dda08ccc98c8e1235c
|
7
|
+
data.tar.gz: f5f4071e92f737153bc989787626d09cd96cf24204f13e2aaf91a49383876cc6bb2ae6ee763f82a08f779806e908e7236790b98315076c652078e95670a04a11
|
data/Gemfile.lock
CHANGED
data/lib/rsmp/alarm_state.rb
CHANGED
@@ -1,33 +1,53 @@
|
|
1
1
|
module RSMP
|
2
|
-
|
2
|
+
|
3
|
+
# The state of an alarm on a component.
|
4
|
+
# The alarm state is for a particular alarm code,
|
5
|
+
# a component typically have an alarm state for each
|
6
|
+
# alarm code that is defined for the component type.
|
7
|
+
|
3
8
|
class AlarmState
|
4
9
|
attr_reader :component_id, :code, :acknowledged, :suspended, :active, :timestamp, :category, :priority, :rvs
|
5
10
|
|
6
|
-
def
|
11
|
+
def self.create_from_message component, message
|
12
|
+
self.new(
|
13
|
+
component: component,
|
14
|
+
code: message.attribute("aCId"),
|
15
|
+
timestamp: RSMP::Clock.parse(message.attribute('aTs')),
|
16
|
+
acknowledged: message.attribute('ack') == 'Acknowledged',
|
17
|
+
suspended: message.attribute('aS') == 'suspended',
|
18
|
+
active: message.attribute('sS') == 'Active',
|
19
|
+
category: message.attribute('cat'),
|
20
|
+
priority: message.attribute('pri').to_i,
|
21
|
+
rvs: message.attribute('rvs')
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize component:, code:,
|
26
|
+
suspended: false, acknowledged: false, active: false, timestamp: nil,
|
27
|
+
category: 'D', priority: 2, rvs: []
|
7
28
|
@component = component
|
8
29
|
@component_id = component.c_id
|
9
30
|
@code = code
|
10
|
-
@suspended =
|
11
|
-
@acknowledged =
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@rvs = []
|
31
|
+
@suspended = !!suspended
|
32
|
+
@acknowledged = !!acknowledged
|
33
|
+
@active = !!active
|
34
|
+
@timestamp = timestamp
|
35
|
+
@category = category || 'D'
|
36
|
+
@priority = priority || 2
|
37
|
+
@rvs = rvs
|
18
38
|
end
|
19
39
|
|
20
40
|
def to_hash
|
21
41
|
{
|
22
|
-
'cId' => component_id,
|
23
|
-
'aCId' => code,
|
24
|
-
'aTs' => Clock.to_s(timestamp),
|
25
|
-
'ack' => (acknowledged ? 'Acknowledged' : 'notAcknowledged'),
|
26
|
-
'sS' => (suspended ? 'suspended' : 'notSuspended'),
|
27
|
-
'aS' => (active ? 'Active' : 'inActive'),
|
28
|
-
'cat' => category,
|
29
|
-
'pri' => priority.to_s,
|
30
|
-
'rvs' => rvs
|
42
|
+
'cId' => @component_id,
|
43
|
+
'aCId' => @code,
|
44
|
+
'aTs' => Clock.to_s(@timestamp),
|
45
|
+
'ack' => (@acknowledged ? 'Acknowledged' : 'notAcknowledged'),
|
46
|
+
'sS' => (@suspended ? 'suspended' : 'notSuspended'),
|
47
|
+
'aS' => (@active ? 'Active' : 'inActive'),
|
48
|
+
'cat' => @category,
|
49
|
+
'pri' => @priority.to_s,
|
50
|
+
'rvs' => @rvs
|
31
51
|
}
|
32
52
|
end
|
33
53
|
|
@@ -65,46 +85,36 @@ module RSMP
|
|
65
85
|
end
|
66
86
|
|
67
87
|
def update_timestamp
|
68
|
-
@timestamp = @component.
|
69
|
-
end
|
70
|
-
|
71
|
-
def to_message specialization:
|
72
|
-
Alarm.new(
|
73
|
-
'cId' => @component_id,
|
74
|
-
'aSp' => specialization,
|
75
|
-
'aCId' => @code,
|
76
|
-
'aTs' => Clock.to_s(@timestamp),
|
77
|
-
'ack' => (@acknowledged ? 'Acknowledged' : 'notAcknowledged'),
|
78
|
-
'sS' => (@suspended ? 'suspended' : 'notSuspended'),
|
79
|
-
'aS' => (@active ? 'Active' : 'inActive'),
|
80
|
-
'cat' => @category,
|
81
|
-
'pri' => @priority.to_s,
|
82
|
-
'rvs' => @rvs
|
83
|
-
)
|
88
|
+
@timestamp = @component.now
|
84
89
|
end
|
85
90
|
|
86
91
|
def differ_from_message? message
|
87
|
-
return true if @timestamp != message.attribute('aTs')
|
88
|
-
return true if message.attribute('ack') && @acknowledged != (message.attribute('ack') == '
|
89
|
-
return true if message.attribute('sS') && @suspended != (message.attribute('sS') == '
|
90
|
-
return true if message.attribute('aS') && @active != (message.attribute('aS') == '
|
92
|
+
return true if RSMP::Clock.to_s(@timestamp) != message.attribute('aTs')
|
93
|
+
return true if message.attribute('ack') && @acknowledged != (message.attribute('ack') == 'Acknowledged')
|
94
|
+
return true if message.attribute('sS') && @suspended != (message.attribute('sS') == 'suspended')
|
95
|
+
return true if message.attribute('aS') && @active != (message.attribute('aS') == 'Active')
|
91
96
|
return true if message.attribute('cat') && @category != message.attribute('cat')
|
92
97
|
return true if message.attribute('pri') && @priority != message.attribute('pri').to_i
|
93
98
|
#return true @rvs = message.attribute('rvs')
|
94
99
|
false
|
95
100
|
end
|
96
101
|
|
102
|
+
def older_message? message
|
103
|
+
return false if @timestamp == nil
|
104
|
+
RSMP::Clock.parse(message.attribute('aTs')) < @timestamp
|
105
|
+
end
|
106
|
+
|
97
107
|
# update from rsmp message
|
98
108
|
# component id, alarm code and specialization are not updated
|
99
109
|
def update_from_message message
|
100
110
|
unless differ_from_message? message
|
101
111
|
raise RepeatedAlarmError.new("no changes from previous alarm #{message.m_id_short}")
|
102
112
|
end
|
103
|
-
if
|
113
|
+
if older_message? message
|
104
114
|
raise TimestampError.new("timestamp is earlier than previous alarm #{message.m_id_short}")
|
105
115
|
end
|
106
116
|
ensure
|
107
|
-
@timestamp = message.attribute('aTs')
|
117
|
+
@timestamp = RSMP::Clock.parse message.attribute('aTs')
|
108
118
|
@acknowledged = message.attribute('ack') == 'True'
|
109
119
|
@suspended = message.attribute('sS') == 'True'
|
110
120
|
@active = message.attribute('aS') == 'True'
|
data/lib/rsmp/component_base.rb
CHANGED
data/lib/rsmp/message.rb
CHANGED
data/lib/rsmp/node.rb
CHANGED
@@ -8,7 +8,7 @@ module RSMP
|
|
8
8
|
|
9
9
|
attr_reader :archive, :logger, :task, :deferred, :error_queue, :clock, :collector
|
10
10
|
|
11
|
-
def initialize options
|
11
|
+
def initialize options={}
|
12
12
|
initialize_logging options
|
13
13
|
initialize_task
|
14
14
|
@deferred = []
|
@@ -18,6 +18,10 @@ module RSMP
|
|
18
18
|
@collect = options[:collect]
|
19
19
|
end
|
20
20
|
|
21
|
+
def now
|
22
|
+
clock.now
|
23
|
+
end
|
24
|
+
|
21
25
|
# stop proxies, then call super
|
22
26
|
def stop_subtasks
|
23
27
|
@proxies.each { |proxy| proxy.stop }
|
data/lib/rsmp/proxy.rb
CHANGED
data/lib/rsmp/rsmp.rb
CHANGED
data/lib/rsmp/site.rb
CHANGED
@@ -97,18 +97,15 @@ module RSMP
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def alarm_acknowledged alarm_state
|
100
|
-
|
101
|
-
send_alarm alarm
|
100
|
+
send_alarm AlarmAcknowledged.new( alarm_state.to_hash )
|
102
101
|
end
|
103
102
|
|
104
103
|
def alarm_suspended_or_resumed alarm_state
|
105
|
-
|
106
|
-
send_alarm alarm
|
104
|
+
send_alarm AlarmSuspended.new( alarm_state.to_hash )
|
107
105
|
end
|
108
106
|
|
109
107
|
def alarm_activated_or_deactivated alarm_state
|
110
|
-
|
111
|
-
send_alarm alarm
|
108
|
+
send_alarm AlarmIssue.new( alarm_state.to_hash )
|
112
109
|
end
|
113
110
|
|
114
111
|
def send_alarm alarm
|
data/lib/rsmp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsmp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.19.
|
4
|
+
version: 0.19.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emil Tin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|