Search in sources :

Example 1 with AlarmConditionSpecType

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;
}
Also used : DurationAlarmConditionSpec(org.thingsboard.server.common.data.device.profile.DurationAlarmConditionSpec) TimeUnit(java.util.concurrent.TimeUnit) AlarmConditionSpecType(org.thingsboard.server.common.data.device.profile.AlarmConditionSpecType) SimpleAlarmConditionSpec(org.thingsboard.server.common.data.device.profile.SimpleAlarmConditionSpec) DurationAlarmConditionSpec(org.thingsboard.server.common.data.device.profile.DurationAlarmConditionSpec) AlarmConditionSpec(org.thingsboard.server.common.data.device.profile.AlarmConditionSpec) RepeatingAlarmConditionSpec(org.thingsboard.server.common.data.device.profile.RepeatingAlarmConditionSpec)

Example 2 with AlarmConditionSpecType

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;
}
Also used : RepeatingAlarmConditionSpec(org.thingsboard.server.common.data.device.profile.RepeatingAlarmConditionSpec) AlarmConditionSpecType(org.thingsboard.server.common.data.device.profile.AlarmConditionSpecType) SimpleAlarmConditionSpec(org.thingsboard.server.common.data.device.profile.SimpleAlarmConditionSpec) DurationAlarmConditionSpec(org.thingsboard.server.common.data.device.profile.DurationAlarmConditionSpec) AlarmConditionSpec(org.thingsboard.server.common.data.device.profile.AlarmConditionSpec) RepeatingAlarmConditionSpec(org.thingsboard.server.common.data.device.profile.RepeatingAlarmConditionSpec)

Example 3 with AlarmConditionSpecType

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;
    }
}
Also used : DurationAlarmConditionSpec(org.thingsboard.server.common.data.device.profile.DurationAlarmConditionSpec) RepeatingAlarmConditionSpec(org.thingsboard.server.common.data.device.profile.RepeatingAlarmConditionSpec) AlarmConditionSpecType(org.thingsboard.server.common.data.device.profile.AlarmConditionSpecType) AlarmConditionFilterKey(org.thingsboard.server.common.data.device.profile.AlarmConditionFilterKey) DurationAlarmConditionSpec(org.thingsboard.server.common.data.device.profile.DurationAlarmConditionSpec) AlarmConditionSpec(org.thingsboard.server.common.data.device.profile.AlarmConditionSpec) RepeatingAlarmConditionSpec(org.thingsboard.server.common.data.device.profile.RepeatingAlarmConditionSpec)

Aggregations

AlarmConditionSpec (org.thingsboard.server.common.data.device.profile.AlarmConditionSpec)3 AlarmConditionSpecType (org.thingsboard.server.common.data.device.profile.AlarmConditionSpecType)3 DurationAlarmConditionSpec (org.thingsboard.server.common.data.device.profile.DurationAlarmConditionSpec)3 RepeatingAlarmConditionSpec (org.thingsboard.server.common.data.device.profile.RepeatingAlarmConditionSpec)3 SimpleAlarmConditionSpec (org.thingsboard.server.common.data.device.profile.SimpleAlarmConditionSpec)2 TimeUnit (java.util.concurrent.TimeUnit)1 AlarmConditionFilterKey (org.thingsboard.server.common.data.device.profile.AlarmConditionFilterKey)1