pl.grzeslowski.jsupla.protocol.api.structs.ElectricityMeterExtendedValue Maven / Gradle / Ivy
package pl.grzeslowski.jsupla.protocol.api.structs;
import pl.grzeslowski.jsupla.protocol.api.structs.*;
import pl.grzeslowski.jsupla.protocol.api.types.ProtoWithSize;
import static pl.grzeslowski.jsupla.protocol.api.JavaConsts.*;
import static pl.grzeslowski.jsupla.protocol.api.Preconditions.*;
import static pl.grzeslowski.jsupla.protocol.api.consts.ProtoConsts.*;
/**
Original code:
typedef struct {
unsigned _supla_int64_t total_forward_active_energy[3]; // * 0.00001 kWh
unsigned _supla_int64_t total_reverse_active_energy[3]; // * 0.00001 kWh
unsigned _supla_int64_t total_forward_reactive_energy[3]; // * 0.00001 kvarh
unsigned _supla_int64_t total_reverse_reactive_energy[3]; // * 0.00001 kvarh
// The price per unit, total cost and currency is overwritten by the server
// total_cost == SUM(total_forward_active_energy[n] * price_per_unit
_supla_int_t total_cost; // * 0.01
_supla_int_t price_per_unit; // * 0.0001
// Currency Code A https://www.nationsonline.org/oneworld/currencies.htm
char currency[3];
_supla_int_t measured_values;
_supla_int_t period; // Approximate period between measurements in seconds
_supla_int_t m_count;
TElectricityMeter_Measurement m[EM_MEASUREMENT_COUNT]; // Last variable in
// struct!
} TElectricityMeter_ExtendedValue;
*/
@lombok.EqualsAndHashCode @lombok.ToString
@javax.annotation.Generated(value="Struct original name: TElectricityMeter_ExtendedValue", date = "2024-08-03T11:49:42.252Z[Etc/UTC]")
public class ElectricityMeterExtendedValue implements pl.grzeslowski.jsupla.protocol.api.types.ProtoWithSize {
/**
* * 0.00001 kWh
*
* unsigned long
*/
public final long[] totalForwardActiveEnergy;
/**
* * 0.00001 kWh
*
* unsigned long
*/
public final long[] totalReverseActiveEnergy;
/**
* * 0.00001 kvarh
*
* unsigned long
*/
public final long[] totalForwardReactiveEnergy;
/**
* * 0.00001 kvarh The price per unit, total cost and currency is overwritten by the server total_cost == SUM(total_forward_active_energy[n] * price_per_unit
*
* unsigned long
*/
public final long[] totalReverseReactiveEnergy;
/**
* * 0.01
*/
public final int totalCost;
/**
* * 0.0001 Currency Code A https://www.nationsonline.org/oneworld/currencies.htm
*/
public final int pricePerUnit;
public final byte[] currency;
public final int measuredValues;
/**
* Approximate period between measurements in seconds
*/
public final int period;
public final int mCount;
/**
* Last variable in struct!
*/
public final pl.grzeslowski.jsupla.protocol.api.structs.ElectricityMeterMeasurement[] m;
public ElectricityMeterExtendedValue(long[] totalForwardActiveEnergy,
long[] totalReverseActiveEnergy,
long[] totalForwardReactiveEnergy,
long[] totalReverseReactiveEnergy,
int totalCost,
int pricePerUnit,
byte[] currency,
int measuredValues,
int period,
int mCount,
pl.grzeslowski.jsupla.protocol.api.structs.ElectricityMeterMeasurement[] m) {
this.totalForwardActiveEnergy = unsigned(checkArrayLength(totalForwardActiveEnergy, (int) 3));
this.totalReverseActiveEnergy = unsigned(checkArrayLength(totalReverseActiveEnergy, (int) 3));
this.totalForwardReactiveEnergy = unsigned(checkArrayLength(totalForwardReactiveEnergy, (int) 3));
this.totalReverseReactiveEnergy = unsigned(checkArrayLength(totalReverseReactiveEnergy, (int) 3));
this.totalCost = totalCost;
this.pricePerUnit = pricePerUnit;
this.currency = checkArrayLength(currency, (int) 3);
this.measuredValues = measuredValues;
this.period = period;
this.mCount = sizeMax(mCount, EM_MEASUREMENT_COUNT);
this.m = checkArrayLength(m, (int) mCount);
}
/* no call type */
@Override
public int size() {
return LONG_SIZE // totalForwardActiveEnergy
+ LONG_SIZE // totalReverseActiveEnergy
+ LONG_SIZE // totalForwardReactiveEnergy
+ LONG_SIZE // totalReverseReactiveEnergy
+ INT_SIZE // totalCost
+ INT_SIZE // pricePerUnit
+ (int) 3 * BYTE_SIZE // currency
+ INT_SIZE // measuredValues
+ INT_SIZE // period
+ INT_SIZE // mCount
+ arraySize(m) // m
;
}
}