use of org.thingsboard.server.common.data.device.profile.AlarmConditionSpecType in project thingsboard by thingsboard.
the class AlarmRuleState method resolveRequiredDurationInMs.
private long resolveRequiredDurationInMs(DataSnapshot data) {
long durationTimeInMs = 0;
AlarmConditionSpec alarmConditionSpec = getSpec();
AlarmConditionSpecType specType = alarmConditionSpec.getType();
if (specType.equals(AlarmConditionSpecType.DURATION)) {
DurationAlarmConditionSpec duration = (DurationAlarmConditionSpec) spec;
TimeUnit timeUnit = duration.getUnit();
durationTimeInMs = timeUnit.toMillis(resolveDynamicValue(data, duration.getPredicate()));
}
return durationTimeInMs;
}
use of org.thingsboard.server.common.data.device.profile.AlarmConditionSpecType in project thingsboard by thingsboard.
the class AlarmRuleState method resolveRequiredRepeats.
private long resolveRequiredRepeats(DataSnapshot data) {
long repeatingTimes = 0;
AlarmConditionSpec alarmConditionSpec = getSpec();
AlarmConditionSpecType specType = alarmConditionSpec.getType();
if (specType.equals(AlarmConditionSpecType.REPEATING)) {
RepeatingAlarmConditionSpec repeating = (RepeatingAlarmConditionSpec) spec;
repeatingTimes = resolveDynamicValue(data, repeating.getPredicate());
}
return repeatingTimes;
}
use of org.thingsboard.server.common.data.device.profile.AlarmConditionSpecType in project thingsboard by thingsboard.
the class ProfileState method addEntityKeysFromAlarmConditionSpec.
private void addEntityKeysFromAlarmConditionSpec(AlarmRule alarmRule) {
AlarmConditionSpec spec = alarmRule.getCondition().getSpec();
if (spec == null) {
return;
}
AlarmConditionSpecType specType = spec.getType();
switch(specType) {
case DURATION:
DurationAlarmConditionSpec duration = (DurationAlarmConditionSpec) spec;
if (duration.getPredicate().getDynamicValue() != null && duration.getPredicate().getDynamicValue().getSourceAttribute() != null) {
entityKeys.add(new AlarmConditionFilterKey(AlarmConditionKeyType.ATTRIBUTE, duration.getPredicate().getDynamicValue().getSourceAttribute()));
}
break;
case REPEATING:
RepeatingAlarmConditionSpec repeating = (RepeatingAlarmConditionSpec) spec;
if (repeating.getPredicate().getDynamicValue() != null && repeating.getPredicate().getDynamicValue().getSourceAttribute() != null) {
entityKeys.add(new AlarmConditionFilterKey(AlarmConditionKeyType.ATTRIBUTE, repeating.getPredicate().getDynamicValue().getSourceAttribute()));
}
break;
}
}
Aggregations