sync bug fix
Former-commit-id: 119b858e73eafa2be8c0dcde46b1ac24feae5e5b
This commit is contained in:
parent
8b42e5bbc9
commit
6e6cae0427
3 changed files with 10 additions and 15 deletions
|
|
@ -105,7 +105,7 @@ public class PCDataSynchronizationDaemon extends ThreadedTCPNetworkServer implem
|
||||||
SensorDataListDTO list = new SensorDataListDTO();
|
SensorDataListDTO list = new SensorDataListDTO();
|
||||||
while (result.next()) {
|
while (result.next()) {
|
||||||
SensorDataDTO data = new SensorDataDTO();
|
SensorDataDTO data = new SensorDataDTO();
|
||||||
data.sequenceId = result.getLong("sensor_id");
|
data.sequenceId = result.getLong("sequence_id");
|
||||||
data.timestampStart = result.getLong("timestamp_start");
|
data.timestampStart = result.getLong("timestamp_start");
|
||||||
data.timestampEnd = result.getLong("timestamp_end");
|
data.timestampEnd = result.getLong("timestamp_end");
|
||||||
data.data = result.getInt("data");
|
data.data = result.getInt("data");
|
||||||
|
|
|
||||||
|
|
@ -46,30 +46,20 @@ public abstract class AbstractDevice<T> extends DBBean {
|
||||||
}
|
}
|
||||||
return deviceData;
|
return deviceData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeviceData(T data) {
|
public void setDeviceData(T data) {
|
||||||
this.deviceData = data;
|
this.deviceData = data;
|
||||||
updateConfig();
|
updateConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getConfig() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
public void setConfig(String config) {
|
public void setConfig(String config) {
|
||||||
if (this.config == null || !this.config.equals(config)) {
|
if (this.config == null || !this.config.equals(config)) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.deviceData = null; // invalidate current sensor data object
|
this.deviceData = null; // invalidate current sensor data object
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateConfig() {
|
|
||||||
Configurator<T> configurator = new Configurator<>(deviceData);
|
|
||||||
this.config = JSONWriter.toString(configurator.getValuesAsNode());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getConfig() {
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void save(DBConnection db) throws SQLException {
|
public void save(DBConnection db) throws SQLException {
|
||||||
if (deviceData != null)
|
if (deviceData != null)
|
||||||
updateConfig();
|
updateConfig();
|
||||||
|
|
@ -77,6 +67,11 @@ public abstract class AbstractDevice<T> extends DBBean {
|
||||||
this.config = null;
|
this.config = null;
|
||||||
super.save(db);
|
super.save(db);
|
||||||
}
|
}
|
||||||
|
protected void updateConfig() {
|
||||||
|
Configurator<T> configurator = new Configurator<>(deviceData);
|
||||||
|
this.config = JSONWriter.toString(configurator.getValuesAsNode());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ public class Sensor extends AbstractDevice<HalSensorData>{
|
||||||
PreparedStatement stmt = HalContext.getDB().getPreparedStatement("SELECT MAX(sequence_id) FROM sensor_data_aggr WHERE sensor_id == ?");
|
PreparedStatement stmt = HalContext.getDB().getPreparedStatement("SELECT MAX(sequence_id) FROM sensor_data_aggr WHERE sensor_id == ?");
|
||||||
stmt.setLong(1, sensorId);
|
stmt.setLong(1, sensorId);
|
||||||
Integer id = DBConnection.exec(stmt, new SimpleSQLResult<Integer>());
|
Integer id = DBConnection.exec(stmt, new SimpleSQLResult<Integer>());
|
||||||
return (id != null ? id+1 : 1);
|
return (id != null ? id : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue