Commit 4528e2230f9b9f53d01dba6d7ec9622c7ec1a282
1 parent
ade282fd
Added support of new alarm flaf in Alarm Processor
Showing
1 changed file
with
8 additions
and
5 deletions
1 | 1 | /** |
2 | 2 | * Copyright © 2016-2017 The Thingsboard Authors |
3 | - * | |
3 | + * <p> | |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
6 | 6 | * You may obtain a copy of the License at |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
7 | + * <p> | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * <p> | |
10 | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
... | ... | @@ -53,6 +53,8 @@ public class AlarmProcessor implements RuleProcessor<AlarmProcessorConfiguration |
53 | 53 | static final String IS_NEW_ALARM = "isNewAlarm"; |
54 | 54 | static final String IS_EXISTING_ALARM = "isExistingAlarm"; |
55 | 55 | static final String IS_CLEARED_ALARM = "isClearedAlarm"; |
56 | + static final String IS_NEW_OR_CLEARED_ALARM = "isNewOrClearedAlarm"; | |
57 | + | |
56 | 58 | |
57 | 59 | protected NashornJsEvaluator newAlarmEvaluator; |
58 | 60 | protected NashornJsEvaluator clearAlarmEvaluator; |
... | ... | @@ -133,6 +135,7 @@ public class AlarmProcessor implements RuleProcessor<AlarmProcessorConfiguration |
133 | 135 | if (existing.getStartTs() == alarm.getStartTs()) { |
134 | 136 | log.debug("[{}][{}] New Active Alarm detected", ctx.getRuleId(), existing.getId()); |
135 | 137 | md.put(IS_NEW_ALARM, Boolean.TRUE); |
138 | + md.put(IS_NEW_OR_CLEARED_ALARM, Boolean.TRUE); | |
136 | 139 | } else { |
137 | 140 | log.debug("[{}][{}] Existing Active Alarm detected", ctx.getRuleId(), existing.getId()); |
138 | 141 | md.put(IS_EXISTING_ALARM, Boolean.TRUE); |
... | ... | @@ -144,10 +147,10 @@ public class AlarmProcessor implements RuleProcessor<AlarmProcessorConfiguration |
144 | 147 | ctx.clearAlarm(alarm.get().getId(), System.currentTimeMillis()); |
145 | 148 | log.debug("[{}][{}] Existing Active Alarm cleared"); |
146 | 149 | md.put(IS_CLEARED_ALARM, Boolean.TRUE); |
150 | + md.put(IS_NEW_OR_CLEARED_ALARM, Boolean.TRUE); | |
147 | 151 | existing = alarm.get(); |
148 | 152 | } |
149 | 153 | } |
150 | - //TODO: handle cleared alarms | |
151 | 154 | |
152 | 155 | if (existing != null) { |
153 | 156 | md.put("alarmId", existing.getId().getId()); | ... | ... |