Search in sources :

Example 6 with RepeatingAlarmConditionSpec

use of org.thingsboard.server.common.data.device.profile.RepeatingAlarmConditionSpec 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

RepeatingAlarmConditionSpec (org.thingsboard.server.common.data.device.profile.RepeatingAlarmConditionSpec)6 Test (org.junit.Test)4 AlarmConditionFilterKey (org.thingsboard.server.common.data.device.profile.AlarmConditionFilterKey)4 TbMsgMetaData (org.thingsboard.server.common.msg.TbMsgMetaData)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 List (java.util.List)3 DeviceProfile (org.thingsboard.server.common.data.DeviceProfile)3 AlarmCondition (org.thingsboard.server.common.data.device.profile.AlarmCondition)3 AlarmConditionFilter (org.thingsboard.server.common.data.device.profile.AlarmConditionFilter)3 AlarmRule (org.thingsboard.server.common.data.device.profile.AlarmRule)3 DeviceProfileAlarm (org.thingsboard.server.common.data.device.profile.DeviceProfileAlarm)3 DeviceProfileData (org.thingsboard.server.common.data.device.profile.DeviceProfileData)3 AttributeKvEntry (org.thingsboard.server.common.data.kv.AttributeKvEntry)3 DynamicValue (org.thingsboard.server.common.data.query.DynamicValue)3 NumericFilterPredicate (org.thingsboard.server.common.data.query.NumericFilterPredicate)3 TbMsg (org.thingsboard.server.common.msg.TbMsg)3 AttributeKvCompositeKey (org.thingsboard.server.dao.model.sql.AttributeKvCompositeKey)3 AttributeKvEntity (org.thingsboard.server.dao.model.sql.AttributeKvEntity)3 Device (org.thingsboard.server.common.data.Device)2 AlarmConditionSpec (org.thingsboard.server.common.data.device.profile.AlarmConditionSpec)2