Added power, voltage and current to MQTT parsing
This commit is contained in:
parent
f68ec9a8e9
commit
17026db07e
11 changed files with 484 additions and 42 deletions
41
hal-core/src/se/hal/struct/devicedata/CurrentSensorData.java
Normal file
41
hal-core/src/se/hal/struct/devicedata/CurrentSensorData.java
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package se.hal.struct.devicedata;
|
||||
|
||||
import se.hal.intf.HalSensorData;
|
||||
|
||||
|
||||
public class CurrentSensorData extends HalSensorData {
|
||||
|
||||
private double current;
|
||||
|
||||
|
||||
public CurrentSensorData() { }
|
||||
public CurrentSensorData(double current, long timestamp) {
|
||||
this.current = current;
|
||||
super.setTimestamp(timestamp);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
if (current < 0.1)
|
||||
return current / 100 + " mA";
|
||||
return current + " A";
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
// Storage methods
|
||||
// ----------------------------------------
|
||||
|
||||
/**
|
||||
* @return number representing Volts measured
|
||||
*/
|
||||
@Override
|
||||
public double getData() {
|
||||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(double current){
|
||||
this.current = current;
|
||||
}
|
||||
}
|
||||
39
hal-core/src/se/hal/struct/devicedata/VoltageSensorData.java
Normal file
39
hal-core/src/se/hal/struct/devicedata/VoltageSensorData.java
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package se.hal.struct.devicedata;
|
||||
|
||||
import se.hal.intf.HalSensorData;
|
||||
|
||||
|
||||
public class VoltageSensorData extends HalSensorData {
|
||||
|
||||
private double voltage;
|
||||
|
||||
|
||||
public VoltageSensorData() { }
|
||||
public VoltageSensorData(double voltage, long timestamp) {
|
||||
this.voltage = voltage;
|
||||
super.setTimestamp(timestamp);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return voltage+" V";
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
// Storage methods
|
||||
// ----------------------------------------
|
||||
|
||||
/**
|
||||
* @return number representing Volts measured
|
||||
*/
|
||||
@Override
|
||||
public double getData() {
|
||||
return voltage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(double voltage){
|
||||
this.voltage = voltage;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue