rsmp 0.19.3 → 0.19.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rsmp/alarm_state.rb +51 -40
- 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/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: 8f188c0b34f0877ae12b9948d0784b5e1f3f2a44e52e11995ba2adf12e299f4a
|
4
|
+
data.tar.gz: a2b8097b5d73897840d093ce8fbf1690bd7c8bee1e1a2102a605565d12c22ddb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '04258e76affbf8e3def87f12edaed2bde5ccf6bf36dfba175c47488082bfaa1e4e8e9c0c8c749295b098e73a39b0ca28bcb0ed4d0e0c90c054486f29a8e0d02d'
|
7
|
+
data.tar.gz: 516d8818dc1737648afdb7cb1496d3c96ea2e9870dc61d185d3bb5a40897ea85ecb930cfece5e5f8dbd1bf8abaf6a62244c5f6188498b082e4c896c02551b190
|
data/Gemfile.lock
CHANGED
data/lib/rsmp/alarm_state.rb
CHANGED
@@ -1,33 +1,55 @@
|
|
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
|
-
|
31
|
+
@suspended = !!suspended
|
32
|
+
@acknowledged = !!acknowledged
|
33
|
+
@active = !!active
|
34
|
+
@timestamp = timestamp
|
35
|
+
@category = category || 'D'
|
36
|
+
@priority = priority || 2
|
37
|
+
@rvs = rvs
|
38
|
+
|
39
|
+
update_timestamp unless @timestamp
|
18
40
|
end
|
19
41
|
|
20
42
|
def to_hash
|
21
43
|
{
|
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
|
44
|
+
'cId' => @component_id,
|
45
|
+
'aCId' => @code,
|
46
|
+
'aTs' => Clock.to_s(@timestamp),
|
47
|
+
'ack' => (@acknowledged ? 'Acknowledged' : 'notAcknowledged'),
|
48
|
+
'sS' => (@suspended ? 'suspended' : 'notSuspended'),
|
49
|
+
'aS' => (@active ? 'Active' : 'inActive'),
|
50
|
+
'cat' => @category,
|
51
|
+
'pri' => @priority.to_s,
|
52
|
+
'rvs' => @rvs
|
31
53
|
}
|
32
54
|
end
|
33
55
|
|
@@ -65,42 +87,31 @@ module RSMP
|
|
65
87
|
end
|
66
88
|
|
67
89
|
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
|
-
)
|
90
|
+
@timestamp = @component.now
|
84
91
|
end
|
85
92
|
|
86
93
|
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') == '
|
94
|
+
return true if RSMP::Clock.to_s(@timestamp) != message.attribute('aTs')
|
95
|
+
return true if message.attribute('ack') && @acknowledged != (message.attribute('ack') == 'Acknowledged')
|
96
|
+
return true if message.attribute('sS') && @suspended != (message.attribute('sS') == 'suspended')
|
97
|
+
return true if message.attribute('aS') && @active != (message.attribute('aS') == 'Active')
|
91
98
|
return true if message.attribute('cat') && @category != message.attribute('cat')
|
92
99
|
return true if message.attribute('pri') && @priority != message.attribute('pri').to_i
|
93
100
|
#return true @rvs = message.attribute('rvs')
|
94
101
|
false
|
95
102
|
end
|
96
103
|
|
104
|
+
def message_is_older? message
|
105
|
+
Time.parse(message.attribute('aTs')) < @timestamp
|
106
|
+
end
|
107
|
+
|
97
108
|
# update from rsmp message
|
98
109
|
# component id, alarm code and specialization are not updated
|
99
110
|
def update_from_message message
|
100
111
|
unless differ_from_message? message
|
101
112
|
raise RepeatedAlarmError.new("no changes from previous alarm #{message.m_id_short}")
|
102
113
|
end
|
103
|
-
if
|
114
|
+
if message_is_older? message
|
104
115
|
raise TimestampError.new("timestamp is earlier than previous alarm #{message.m_id_short}")
|
105
116
|
end
|
106
117
|
ensure
|
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/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.4
|
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
|