[Nut-upsdev] apc-hid.c: watts_to_av_conversion

Peter Selinger selinger at mathstat.dal.ca
Sat Aug 11 10:11:35 UTC 2007


Arjen de Korte wrote:
> 
> Peter,
> 
> Looking through the usbhid-ups subdrivers, I came across the following
> function in apc-hid.c, presumably added by you about two years ago (if
> not, my apologies):
> 
> 41 	/* returns statically allocated string - must not use it again before
> 42 	   done with result! */
> 43 	static char *watts_to_av_conversion_fun(long value) {
> 44 	        static char buf[20];
> 45
> 46 	        snprintf(buf, sizeof(buf), "%.0f", value * 1.4142136);
> 47 	        return buf;
> 48 	}
> 49
> 50 	static info_lkp_t watts_to_av_conversion[] = {
> 51 	        { 0, NULL, watts_to_av_conversion_fun }
> 52 	};
> 
> Being a power electronics engineer, the name of it made me wonder what the
> heck was going on. As far as I know, there is no way to convert between AV
> and W without knowing the phase relation between RMS voltage and -current.

Indeed, I remember having this discussion some time ago when we
introduced the ups.realpower.* variables. This was presumably much
after I wrote the above function, which went unnoticed at the time. 

> Could it be that for this particular UPS this works out to be correct by
> coincidence? 

Unlikely. It's at best a ballpark value. 

> Now that we have "ups.realpower.nominal", I think we should
> change line 215
> 
> 	{ "ups.power.nominal", 0, 0, "UPS.Output.ConfigActivePower", NULL, "%s",
> HU_FLAG_OK, watts_to_av_conversion }, /* CyberPower */
> 
> to
> 
> 	{ "ups.realpower.nominal", 0, 0, "UPS.Output.ConfigActivePower", NULL,
> "%.0f", HU_FLAG_OK, NULL }, /* CyberPower */

Sounds like a good idea to me. 
 
> Chances are, it also supports
> 
> 	{ "ups.power.nominal", 0, 0, "UPS.Output.ConfigApparentPower", NULL,
> "%.0f", HU_FLAG_OK, NULL }, /* CyberPower */

I have never seen a UPS that supports
UPS.Output.ConfigApparentPower. There are several that support one of
the following:

UPS.Flow.ConfigApparentPower
UPS.Flow.[4].ConfigApparentPower
00860004.Flow.ConfigApparentPower
UPS.BELKINConfig.BELKINConfigApparentPower

However, I don't think CyberPower supports any of these, or else I
would have put at least an "unmapped" entry in apc-hid.c. I haven't
seen the CyberPower report descriptor in a while and cannot find it
quickly in the mailing list archives. I wouldn't assume any UPS paths
exist unless they are mentioned in the subdriver.

> so that may be worthwhile adding too.

Probably not!

-- Peter



More information about the Nut-upsdev mailing list