4 mapi_timetoaverage(), 5 mapi_getenergyused(), Mapi_timetoaverage() – Maxim Integrated 78M6612 M-API Library User Manual
Page 30: Mapi_getenergyused()

78M6612 M-API Library User Guide
UG_6612_036
30
Rev. 1.00
4.4.4 MAPI_TimeToAverage()
Purpose
Set/Get the time increment (in seconds) in which the power (in Watts) is to be
averaged. If a Time Interval has been set previously, it will be reset from this
point forward and the accumulator’s value will also be reset. Default value will be
10 seconds if this API is not called or if it is called with TimeInterval = 0. This
time is global time that is applicable to both channels.
Synopsis
Void MAPI_TimeToAverage ( IN Bool SetTIME,
IN unsigned int TimeInterval);
Parameters
SetTIME
Input parameter.
TRUE (1) will set the time to TimeInterval seconds.
FALSE(0) will return the current Time Increment Query to
TimeInterval.
TimeInterval
Input parameter (SetTIME = TRUE), Output parameter
(SetTIME = FALSE). Time in units of seconds, used to
average the Watts used.
Return Codes None.
4.4.5 MAPI_GetEnergyUsed()
Purpose
Get the energy used per time increment query. This API will return the current
values as recorded according to Index and the Time Increment Interval.
Synopsis
Void MAPI_GetEnergyUsed(OUT struct E_Query_t *EQuery);
Where E_Query_t is defined as:
struct E_Query_t
{
Unsigned char
Chan;
//Channel/Outlet number
float
mWattsUsed;
float
WattHrsUsed;
Unsigned char Index;
Unsigned int cLineFreq;
}
Parameters
Chan
Input parameter.
Channel/Outlet number to get the energy information from.
mWattsUsed Output parameter.
Instantaneous Power used in milli-Watts.
WattHrsUsed
Output parameter.
WattHour used over the past hour as pointed to by Index.
Index
Output parameter.
Number of hours past since power up. This value will reset to
0 (wrap-around) once the maximum is reached, i.e. 255 hours.
cLineFreq
Output: Current line frequency value in ##.##Hz format.
Return Codes None.