This packages is an enhancement of the alarmhandler package. It adds a mqtt interface and on top of that an command interface to interact with an alarmhandler. Since this is an implementation detail this more of an internal package.
Package not published
const alarmHandler = new AlarmHandlerMqtt("myAlarmHandler", {
numOfAlarms: 3,
traceFilePath: "path/to/tracefile",
presentAlarmsFilePath: "path/to/presentalarmfile",
alarmDefsPath: "path/to/alarmdefinitions",
additionalNewAlarmTopics: [
"topic01/newAlarms", //send alarms which are triggered to additional topics (in textual format)
"topic02/newAlarms"
]
presentAlarmWatchdogS: 3, //default 3s - max duration between the present alarm info (is triggered automatically after this time)
textCommand: {
commandTopicPrefix: "messenger/from",
commandResponseTopicPrefix: "messenger/to"
}
});
alarms/ack/<mqttClientId>
: Send a UINT32 to this topic in order to (try) to acknowledge the sent alarm number (send 0 in order to ack all) - no responsecmd/<mqttClientId>/<requesterClientId>/setAlarmText
: Requests to change the alarm text of an alarm expects a JSON array in the form[<commandId>, <alarmNumber>, <newAlarmText"]
sends a response tocmdRes/<requesterId>/<mqttClientId>/setAlarmText
with a JSON array in the form[<commandId>, <0/1>]
(1 success and 0 failure)cmd/<mqttClientId>/<requesterClientId>/getHistory
: Requests the alarm history expects a JSON array in the form[<commandId>, <UNIX timestamp "from">, <UNIX timestamp "to">]
sends a response tocmdRes/<requesterId>/<mqttClientId>/getHistory
with a JSON array in the form[<commandId>, <0/1>, [...<log file entries>]]
(1 success and 0 failure)
alarms/sources/<mqttClientId>/numberOfAlarms
: Sends the total number of alarms of this alarm handleralarms/present/<mqttClientId>
: Sends the present alarm information to this topicalarms/new/<mqttClientId>
: Sends the alarm info (JSON) of a new triggered alarm to this topic (see alsoadditionalNewAlarmTopics
)
<commandInTopic>
: Provides an interface similar to a command line. The idea is that one can send the command to a topic and receives the result on a second topic. The second topic is<commandOutTopic>
. The command starts with a stringalarms
targeting all alarm handler which are subscribed on the given topic. It is recommended to use only one alarm handler for one topic pair
alarms
is defaulted toalarms act
alarms ack [alarmIdToAck]
sends acknowledge ifalarmIdToAck
is "0" or omitted ack all alarmsalarms act
request present alarm information
The project is part of a monorepo. If the project is checked out in this environment use the following scripts:
TypeScript build:
pnpm run compile
Run tests:
pnpm test
- Get History?
- Help text for text command
- Sending of broadcast present alarms?