added deviceCreationTime to the DeviceStateData

This commit is contained in:
YevhenBondarenko 2020-10-08 13:15:49 +03:00 committed by Andrew Shvayka
parent 1423074485
commit 62748eef60
2 changed files with 4 additions and 3 deletions

View File

@ -393,7 +393,7 @@ public class DefaultDeviceStateService implements DeviceStateService {
if (stateData != null) { if (stateData != null) {
DeviceState state = stateData.getState(); DeviceState state = stateData.getState();
state.setActive(ts < state.getLastActivityTime() + state.getInactivityTimeout()); state.setActive(ts < state.getLastActivityTime() + state.getInactivityTimeout());
if (!state.isActive() && (state.getLastInactivityAlarmTime() == 0L || state.getLastInactivityAlarmTime() < state.getLastActivityTime()) && UUIDs.unixTimestamp(deviceId.getId()) + state.getInactivityTimeout() < ts) { if (!state.isActive() && (state.getLastInactivityAlarmTime() == 0L || state.getLastInactivityAlarmTime() < state.getLastActivityTime()) && stateData.getDeviceCreationTime() + state.getInactivityTimeout() < ts) {
state.setLastInactivityAlarmTime(ts); state.setLastInactivityAlarmTime(ts);
pushRuleEngineMessage(stateData, INACTIVITY_EVENT); pushRuleEngineMessage(stateData, INACTIVITY_EVENT);
save(deviceId, INACTIVITY_ALARM_TIME, ts); save(deviceId, INACTIVITY_ALARM_TIME, ts);
@ -480,6 +480,7 @@ public class DefaultDeviceStateService implements DeviceStateService {
return DeviceStateData.builder() return DeviceStateData.builder()
.tenantId(device.getTenantId()) .tenantId(device.getTenantId())
.deviceId(device.getId()) .deviceId(device.getId())
.deviceCreationTime(device.getCreatedTime())
.metaData(md) .metaData(md)
.state(deviceState).build(); .state(deviceState).build();
} catch (Exception e) { } catch (Exception e) {

View File

@ -30,8 +30,8 @@ class DeviceStateData {
private final TenantId tenantId; private final TenantId tenantId;
private final DeviceId deviceId; private final DeviceId deviceId;
private final long deviceCreationTime;
private TbMsgMetaData metaData; private TbMsgMetaData metaData;
private final DeviceState state; private final DeviceState state;
} }