Skip to content

Commit

Permalink
Merge pull request #1280 from geoghegan/master
Browse files Browse the repository at this point in the history
  • Loading branch information
jimklimov committed Feb 11, 2022
2 parents 12b0030 + c10459d commit 3d04a01
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
27 changes: 23 additions & 4 deletions drivers/riello_ser.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
#include "riello.h"

#define DRIVER_NAME "Riello serial driver"
#define DRIVER_VERSION "0.04"
#define DRIVER_VERSION "0.07"

#define DEFAULT_OFFDELAY 5
#define DEFAULT_BOOTDELAY 5

/* driver description structure */
upsdrv_info_t upsdrv_info = {
Expand All @@ -63,6 +66,9 @@ static uint8_t typeRielloProtocol;
static uint8_t input_monophase;
static uint8_t output_monophase;

static unsigned int offdelay = DEFAULT_OFFDELAY;
static unsigned int bootdelay = DEFAULT_BOOTDELAY;

static TRielloData DevData;

/**********************************************************************
Expand Down Expand Up @@ -761,6 +767,14 @@ void upsdrv_initinfo(void)
dstate_addcmd("shutdown.stop");
dstate_addcmd("test.battery.start");

dstate_setinfo("ups.delay.shutdown", "%u", offdelay);
dstate_setflags("ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING);
dstate_setaux("ups.delay.shutdown", 3);
dstate_setinfo("ups.delay.reboot", "%u", bootdelay);
dstate_setflags("ups.delay.reboot", ST_FLAG_RW | ST_FLAG_STRING);
dstate_setaux("ups.delay.reboot", 3);


if (typeRielloProtocol == DEV_RIELLOGPSER)
dstate_addcmd("test.panel.start");

Expand Down Expand Up @@ -813,9 +827,14 @@ void upsdrv_updateinfo(void)
dstate_setinfo("input.bypass.frequency", "%.2f", DevData.Fbypass/10.0);
dstate_setinfo("output.frequency", "%.2f", DevData.Fout/10.0);
dstate_setinfo("battery.voltage", "%.1f", DevData.Ubat/10.0);
dstate_setinfo("battery.charge", "%u", DevData.BatCap);
dstate_setinfo("battery.runtime", "%u", DevData.BatTime*60);
dstate_setinfo("ups.temperature", "%u", DevData.Tsystem);

if ((DevData.BatCap < 0xFFFF) && (DevData.BatTime < 0xFFFF)) {
dstate_setinfo("battery.charge", "%u", DevData.BatCap);
dstate_setinfo("battery.runtime", "%u", DevData.BatTime*60);
}

if (DevData.Tsystem < 0xFF)
dstate_setinfo("ups.temperature", "%u", DevData.Tsystem);

if (input_monophase) {
dstate_setinfo("input.voltage", "%u", DevData.Uinp1);
Expand Down
27 changes: 23 additions & 4 deletions drivers/riello_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
#include "riello.h"

#define DRIVER_NAME "Riello USB driver"
#define DRIVER_VERSION "0.06"
#define DRIVER_VERSION "0.07"

#define DEFAULT_OFFDELAY 5 /*!< seconds (max 0xFF) */
#define DEFAULT_BOOTDELAY 5 /*!< seconds (max 0xFF) */

/* driver description structure */
upsdrv_info_t upsdrv_info = {
Expand All @@ -55,6 +58,10 @@ static uint8_t gpser_error_control;
static uint8_t input_monophase;
static uint8_t output_monophase;

/*! Time in seconds to delay before shutting down. */
static unsigned int offdelay = DEFAULT_OFFDELAY;
static unsigned int bootdelay = DEFAULT_BOOTDELAY;

static TRielloData DevData;

static usb_communication_subdriver_t *usb = &usb_subdriver;
Expand Down Expand Up @@ -972,6 +979,13 @@ void upsdrv_initinfo(void)
dstate_addcmd("test.battery.start");
dstate_addcmd("test.panel.start");

dstate_setinfo("ups.delay.shutdown", "%u", offdelay);
dstate_setflags("ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING);
dstate_setaux("ups.delay.shutdown", 3);
dstate_setinfo("ups.delay.reboot", "%u", bootdelay);
dstate_setflags("ups.delay.reboot", ST_FLAG_RW | ST_FLAG_STRING);
dstate_setaux("ups.delay.reboot", 3);

/* install handlers */
/* upsh.setvar = hid_set_value; setvar; */

Expand Down Expand Up @@ -1058,9 +1072,14 @@ void upsdrv_updateinfo(void)
dstate_setinfo("input.bypass.frequency", "%.2f", DevData.Fbypass/10.0);
dstate_setinfo("output.frequency", "%.2f", DevData.Fout/10.0);
dstate_setinfo("battery.voltage", "%.1f", DevData.Ubat/10.0);
dstate_setinfo("battery.charge", "%u", DevData.BatCap);
dstate_setinfo("battery.runtime", "%u", DevData.BatTime*60);
dstate_setinfo("ups.temperature", "%u", DevData.Tsystem);
if ((DevData.BatCap < 0xFFFF) && (DevData.BatTime < 0xFFFF)) {
dstate_setinfo("battery.charge", "%u", DevData.BatCap);
dstate_setinfo("battery.runtime", "%u", DevData.BatTime*60);
}

if (DevData.Tsystem < 0xFF)
dstate_setinfo("ups.temperature", "%u", DevData.Tsystem);


if (input_monophase) {
dstate_setinfo("input.voltage", "%u", DevData.Uinp1);
Expand Down

0 comments on commit 3d04a01

Please sign in to comment.