Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ https://github.com/networkupstools/nut/milestone/9
Driver-code related test-cases were updated to reflect these changes.
[issue #2928, PRs #2931 and #2934]

- `dummy-ups` driver updates:
* A new instruction `ALARM` was added for the `Dummy Mode` operation
of the driver, enabling simulation of UPS alarm states more closely
in line with modern, real-world UPS driver implementations. This
follows the updated principle of keeping alarm states decoupled from
the `ups.status` variable, with alarms now raised via common alarm
functions rather than direct manipulation. [issue #2928, PR #2936]

- `clone`, `clone-outlet`, `nhs_ser` driver and `nutdrv_qx_ablerex`
subdriver updates:
* Refactored to follow modern handling of status and alarm conditions,
aligning with current driver design practices. This includes fixing
copy-paste related issues in alarm reporting and removing some alarm
messages that should instead be reflected as status flags. [#2936]

- `nutdrv_qx` driver updates:
* Introduced `innovart33` protocol support for Ippon Innova RT 3/3 topology
UPSes. [#2938]
Expand Down
25 changes: 25 additions & 0 deletions docs/man/dummy-ups.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,31 @@ a bit between file-reading cycles (currently this delay is hardcoded to one
second), independently of (and/or in addition to) any `TIMER` keywords and
possibly the common `pollinterval` setting.

Another, more recently introduced instruction is `ALARM`, which allows
the simulation of UPS alarms in much the same way they would be raised
by real driver implementations. Modern drivers decouple alarm states
from the `ups.status` variable, and raising `ALARM` by setting it as a
status token is discouraged in favor of using modern, common functions
for raising alarms within the driver code.

The `ALARM` instruction is intended to simulate this behavior as closely
as possible. The value following an `ALARM` instruction is treated as
the alarm message and is eventually published as the `ups.alarm`
variable, with the `ALARM` token also set in `ups.status` by internal
driver mechanisms, rather than by directly manipulating the variable.
Multiple `ALARM` instructions will have their messages combined into
the `ups.alarm` variable, just as would happen with real driver logic.

Conversely, any `ALARM` instruction on its own will clear active alarm
states. See below for an example of setting and resetting alarms:

ALARM [UPS too warm to charge]
ALARM [UPS circuit is overheating]
TIMER 5
ALARM
TIMER 5
ALARM [UPS too cold to charge]

Repeater Mode
~~~~~~~~~~~~~

Expand Down
18 changes: 10 additions & 8 deletions drivers/clone-outlet.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#endif /* !WIN32 */

#define DRIVER_NAME "Clone outlet UPS driver"
#define DRIVER_VERSION "0.07"
#define DRIVER_VERSION "0.08"

/* driver description structure */
upsdrv_info_t upsdrv_info = {
Expand Down Expand Up @@ -303,7 +303,9 @@ static TYPE_FD sstate_connect(void)
dumpdone = 0;

/* set ups.status to "WAIT" while waiting for the driver response to dumpcmd */
dstate_setinfo("ups.status", "WAIT");
status_init();
status_set("WAIT");
status_commit();

upslogx(LOG_INFO, "Connected to UPS [%s]", device_path);
return fd;
Expand Down Expand Up @@ -491,20 +493,20 @@ void upsdrv_updateinfo(void)
return;
}

status_init();

if (outlet.status == 0) {
upsdebugx(2, "OFF flag set (%s: switched off)", prefix.status);
dstate_setinfo("ups.status", "%s OFF", ups.status);
return;
status_set("OFF");
}

if ((outlet.timer.shutdown > -1) && (outlet.timer.shutdown <= outlet.delay.shutdown)) {
upsdebugx(2, "FSD flag set (%s: -1 < [%ld] <= %ld)", prefix.timer.shutdown, outlet.timer.shutdown, outlet.delay.shutdown);
dstate_setinfo("ups.status", "FSD %s", ups.status);
return;
status_set("FSD");
}

upsdebugx(3, "%s: power state not critical", getval("prefix"));
dstate_setinfo("ups.status", "%s", ups.status);
status_set(ups.status); /* FIXME: Split token words? */
status_commit();
Comment on lines +496 to +509
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting, with no judgement, that this also subtly changes the logic: previously the driver applied either "OFF" or "FSD" to existing ups.status and returned; now it can apply both.

It also no longer reports that the "power state is not critical" in debug log, though that may be not too useful as such.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intended because the user should see all actual statuses and OFF/FSD should not be mutually exclusive, I did drop the debug message - sorry - but I think it made no sense when a UPS may well be OB LB or OVER even if not OFF or FSD yet, which would also be somewhat critical.

I did also pave it over for ease of coding around it, other than the argument above, truth be told, since all statuses (also critical ones) are reported summarily now.


last_poll = now;
}
Expand Down
Loading