Skip to content

Commit

Permalink
reset alarm timestamps when changing clock
Browse files Browse the repository at this point in the history
  • Loading branch information
emiltin committed Apr 3, 2024
1 parent f1e7839 commit 6198485
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
12 changes: 7 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,26 @@ GEM
async
colorize (0.8.1)
concurrent-ruby (1.2.2)
console (1.23.3)
console (1.23.6)
fiber-annotation
fiber-local
json
diff-lcs (1.5.0)
fiber-annotation (0.2.0)
fiber-local (1.0.0)
hana (1.3.7)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
io-event (1.3.3)
io-event (1.5.1)
json (2.7.1)
json_schemer (2.1.1)
hana (~> 1.3)
regexp_parser (~> 2.0)
simpleidn (~> 0.2)
minitest (5.20.0)
rake (13.0.6)
regexp_parser (2.8.3)
rsmp (0.26.1)
regexp_parser (2.9.0)
rsmp (0.27.0)
async (~> 2.6.4)
async-io (~> 1.36.0)
colorize (~> 0.8.1)
Expand All @@ -55,7 +57,7 @@ GEM
rspec-support (3.12.0)
simpleidn (0.2.1)
unf (~> 0.1.4)
thor (1.3.0)
thor (1.3.1)
timers (4.3.5)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ RSpec.describe "Traffic Light Controller" do
it 'is used for watchdog timestamp', sxl: '>=1.0.7' do |example|
Validator::Site.connected do |task,supervisor,site|
prepare task, site
with_clock_set CLOCK do
with_clock_set site, CLOCK do
Validator.log "Checking watchdog timestamp", level: :test
response = site.collect type: "Watchdog", num: 1, timeout: Validator.get_config('timeouts','watchdog')
max_diff = Validator.get_config('timeouts','command_response') + Validator.get_config('timeouts','status_response')
Expand Down
14 changes: 7 additions & 7 deletions spec/site/tlc/clock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
Validator::Site.connected do |task,supervisor,site|
prepare task, site
site.with_watchdog_disabled do # avoid time synchronization by disabling watchdogs
with_clock_set CLOCK do
with_clock_set site, CLOCK do
status_list = { S0096: [
:year,
:month,
Expand Down Expand Up @@ -104,7 +104,7 @@
Validator::Site.connected do |task,supervisor,site|
prepare task, site
site.with_watchdog_disabled do # avoid time synchronization by disabling watchdogs
with_clock_set CLOCK do
with_clock_set site, CLOCK do
status_list = { S0096: [
:year,
:month,
Expand Down Expand Up @@ -143,7 +143,7 @@
Validator::Site.connected do |task,supervisor,site|
prepare task, site
site.with_watchdog_disabled do # avoid time synchronization by disabling watchdogs
with_clock_set CLOCK do
with_clock_set site, CLOCK do
result = site.request_aggregated_status Validator.get_config('main_component'), collect!: {
timeout: Validator.get_config('timeouts','status_response')
}
Expand All @@ -169,7 +169,7 @@
Validator::Site.connected do |task,supervisor,site|
prepare task, site
site.with_watchdog_disabled do # avoid time synchronization by disabling watchdogs
with_clock_set CLOCK do
with_clock_set site, CLOCK do
result = set_functional_position 'NormalControl'
collector = result[:collector]
max_diff = Validator.get_config('timeouts','command_response') * 2
Expand All @@ -193,7 +193,7 @@
Validator::Site.connected do |task,supervisor,site|
prepare task, site
site.with_watchdog_disabled do # avoid time synchronization by disabling watchdogs
with_clock_set CLOCK do
with_clock_set site, CLOCK do
result = set_functional_position 'NormalControl'
collector = result[:collector]
max_diff = Validator.get_config('timeouts','command_response')
Expand Down Expand Up @@ -221,7 +221,7 @@
Validator::Site.connected do |task,supervisor,site|
prepare task, site
site.with_watchdog_disabled do # avoid time synchronization by disabling watchdogs
with_clock_set CLOCK do # set clock
with_clock_set site, CLOCK do # set clock
with_alarm_activated(task, site, 'A0302') do |alarm| # raise alarm, by activating input
alarm_time = Time.parse( alarm.attributes["aTs"] )
max_diff = Validator.get_config('timeouts','command_response') + Validator.get_config('timeouts','status_response')
Expand All @@ -245,7 +245,7 @@
Validator::Site.connected do |task,supervisor,site|
prepare task, site
site.with_watchdog_disabled do # avoid time synchronization by disabling watchdogs
with_clock_set CLOCK do
with_clock_set site, CLOCK do
log "Checking watchdog timestamp"
collector = RSMP::Collector.new site, task:task, type: "Watchdog", num: 1, timeout: Validator.get_config('timeouts','watchdog')
collector.collect!
Expand Down
3 changes: 2 additions & 1 deletion spec/support/command_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,9 @@ def site.send_watchdog now=nil
end
end

def with_clock_set clock, &block
def with_clock_set site, clock, &block
result = set_clock clock
site.clear_alarm_timestamps
yield result
ensure
reset_clock
Expand Down

0 comments on commit 6198485

Please # to comment.