Class: SGS::Alarm
Overview
Deal with alarm subsystem.
Constant Summary collapse
- MISSION_SWITCH =
Alarms generated by Otto.
0- RUDDSRV_FAULT =
1- SAILSRV_FAULT =
2- VBATT_CRITICAL =
3- VBATT_UNDERVOLTAGE =
4- VBATT_OVERVOLTAGE =
5- IBATT_INRUSH =
6- IBATT_DRAIN =
7- VSOLAR_OVERVOLTAGE =
8- COMPASS_ERROR =
9- COMPASS_NOREAD =
10- WDI_STUCK =
11- WDI_NOREAD =
12- RUDDER_NOZERO =
13- SAIL_NOZERO =
14- MOTHER_UNRESP =
15- OTTO_RESTART =
Alarms generated by Mother.
16- MISSION_COMMENCE =
17- MISSION_COMPLETE =
18- MISSION_ABORT =
19- WAYPOINT_REACHED =
20- CROSS_TRACK_ERROR =
21- INSIDE_FENCE =
22- ALARM_NAMES =
[ "Mission Activation Switch", "Rudder Servo Fault", "Sail Servo Fault", "Battery voltage is critically low", "Battery voltage is low", "Battery voltage is too high", "Battery inrush current", "Battery drain current", "Solar voltage is too high", "Compass module error", "Compass not responding", "WDI reading is misaligned", "Cannot read from the WDI", "Cannot zero the rudder position", "Cannot zero the sail position", "Mother is unresponsive", "OTTO Restarted", "Mission has commenced", "Mission is completed", "*** MISSION ABORT ***", "Waypoint has been reached", "Significant cross-track error", "Vessel is inside the fence" ].freeze
Instance Attribute Summary collapse
-
#last_report ⇒ Object
Returns the value of attribute last_report.
-
#time ⇒ Object
Returns the value of attribute time.
Class Method Summary collapse
-
.build_include(fname) ⇒ Object
Build a C include file based on the current alarm definitions.
-
.daemon ⇒ Object
Main daemon function (called from executable).
Instance Method Summary collapse
-
#initialize ⇒ Alarm
constructor
A new instance of Alarm.
-
#name(alarmno) ⇒ Object
Convert an alarm number into a string.
Methods inherited from RedisBase
#count, #count_name, #load, load, #make_redis_name, #publish, redis, redis_handle, #redis_read_var, #save, #save_and_publish, setup, subscribe, to_redis, var_init
Constructor Details
#initialize ⇒ Alarm
Returns a new instance of Alarm.
101 102 103 104 105 106 |
# File 'lib/sgs/alarm.rb', line 101 def initialize @count = 0 @last_report = nil @time = Array.new(32, Time.at(0)) super end |
Instance Attribute Details
#last_report ⇒ Object
Returns the value of attribute last_report.
45 46 47 |
# File 'lib/sgs/alarm.rb', line 45 def last_report @last_report end |
#time ⇒ Object
Returns the value of attribute time.
45 46 47 |
# File 'lib/sgs/alarm.rb', line 45 def time @time end |
Class Method Details
.build_include(fname) ⇒ Object
Build a C include file based on the current alarm definitions
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/sgs/alarm.rb', line 123 def self.build_include(fname) alarm = new File.open(fname, "w") do |f| f.puts "/*\n * Autogenerated by #{__FILE__}.\n * DO NOT HAND-EDIT!\n */" constants.sort.each do |c| unless c == :ALARM_NAMES cval = Alarm.const_get(c) str = "#define SGS_ALARM_#{c.to_s}" str += "\t" if str.length < 32 str += "\t#{cval}\t/* #{alarm.name(cval)} */" f.puts str end end end end |
.daemon ⇒ Object
Main daemon function (called from executable)
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/sgs/alarm.rb', line 110 def self.daemon puts "Alarm daemon starting up..." otto = RPCClient.new(:otto) loop do #puts "Check for any alarms..." #resp = otto.command "A?" #puts "Response: #{resp}" sleep 30 end end |
Instance Method Details
#name(alarmno) ⇒ Object
Convert an alarm number into a string.
141 142 143 |
# File 'lib/sgs/alarm.rb', line 141 def name(alarmno) ALARM_NAMES[alarmno] end |