openc3 7.5.0 → 7.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/openc3/api/limits_api.rb +149 -160
- data/lib/openc3/api/tlm_api.rb +219 -61
- data/lib/openc3/logs/log_writer.rb +9 -8
- data/lib/openc3/microservices/decom_microservice.rb +23 -1
- data/lib/openc3/microservices/interface_decom_common.rb +3 -1
- data/lib/openc3/models/cvt_model.rb +7 -2
- data/lib/openc3/models/target_model.rb +9 -6
- data/lib/openc3/packets/packet_item.rb +13 -8
- data/lib/openc3/script/api_shared.rb +10 -8
- data/lib/openc3/script/extract.rb +52 -5
- data/lib/openc3/script/script.rb +1 -1
- data/lib/openc3/topics/limits_event_topic.rb +90 -3
- data/lib/openc3/topics/router_topic.rb +6 -2
- data/lib/openc3/topics/system_events_topic.rb +9 -6
- data/lib/openc3/topics/topic.rb +8 -1
- data/lib/openc3/utilities/bucket.rb +5 -0
- data/lib/openc3/utilities/questdb_client.rb +126 -32
- data/lib/openc3/utilities/secrets.rb +5 -0
- data/lib/openc3/utilities/store_autoload.rb +3 -1
- data/lib/openc3/version.rb +5 -5
- data/templates/tool_angular/package.json +2 -2
- data/templates/tool_react/package.json +1 -1
- data/templates/tool_svelte/package.json +1 -1
- data/templates/tool_vue/package.json +3 -3
- data/templates/widget/package.json +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f72a662e14c8daa5866c844e519021cc51515020245d05de5b121af4a85465d8
|
|
4
|
+
data.tar.gz: 84b48fb4c32934ff568c1696474657d84dbcbab793e89d872fc83d6a202013ba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1dafbf8d89fc0599fb46463f66686f5b82e251af28349ff607122727ce862cb58c95f391739ac6f06b4efda52388731cdde5f49254e0151815fee97394f166c5
|
|
7
|
+
data.tar.gz: 23ba309134de54d6a2f7b2be28d834b03355cb2df7ca0a830dd03625ec59cbdd3fa2d8dd97f4846da3c78219faa8f98613cd660c91b0b47ed2f80538c1533fba
|
|
@@ -26,6 +26,7 @@ module OpenC3
|
|
|
26
26
|
'get_out_of_limits',
|
|
27
27
|
'get_overall_limits_state',
|
|
28
28
|
'limits_enabled?',
|
|
29
|
+
'limits_enabled', # Python scripts call this alias since Python method names can't end in ?
|
|
29
30
|
'enable_limits',
|
|
30
31
|
'disable_limits',
|
|
31
32
|
'get_limits',
|
|
@@ -121,29 +122,16 @@ module OpenC3
|
|
|
121
122
|
#
|
|
122
123
|
# Favor the first syntax where possible as it is more succinct.
|
|
123
124
|
#
|
|
124
|
-
# @param args [String|Array<String>] See the description for calling style
|
|
125
|
+
# @param args [String|Array<String>] See the description for calling style.
|
|
126
|
+
# A packet name of LATEST applies to every packet which contains the item.
|
|
125
127
|
def enable_limits(*args, manual: false, scope: $openc3_scope, token: $openc3_token)
|
|
126
|
-
target_name,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
item['limits']['enabled'] = true
|
|
133
|
-
found_item = item
|
|
134
|
-
break
|
|
135
|
-
end
|
|
128
|
+
target_name, packet_names, item_name = _tlm_process_args_all_packets(args, 'enable_limits', scope: scope)
|
|
129
|
+
packet_names.each do |packet_name|
|
|
130
|
+
authorize(permission: 'tlm_set', target_name: target_name, packet_name: packet_name, manual: manual, scope: scope, token: token)
|
|
131
|
+
end
|
|
132
|
+
packet_names.each do |packet_name|
|
|
133
|
+
_set_limits_enabled(target_name, packet_name, item_name, true, scope: scope)
|
|
136
134
|
end
|
|
137
|
-
raise "Item '#{target_name} #{packet_name} #{item_name}' does not exist while enabling limits" unless found_item
|
|
138
|
-
|
|
139
|
-
TargetModel.set_packet(target_name, packet_name, packet, scope: scope)
|
|
140
|
-
|
|
141
|
-
message = "Enabling Limits For '#{target_name} #{packet_name} #{item_name}'"
|
|
142
|
-
Logger.info(message, scope: scope)
|
|
143
|
-
|
|
144
|
-
event = { type: :LIMITS_ENABLE_STATE, target_name: target_name, packet_name: packet_name,
|
|
145
|
-
item_name: item_name, enabled: true, time_nsec: Time.now.to_nsec_from_epoch, message: message }
|
|
146
|
-
LimitsEventTopic.write(event, scope: scope)
|
|
147
135
|
end
|
|
148
136
|
|
|
149
137
|
# Disable limit checking for a telemetry item
|
|
@@ -154,29 +142,16 @@ module OpenC3
|
|
|
154
142
|
#
|
|
155
143
|
# Favor the first syntax where possible as it is more succinct.
|
|
156
144
|
#
|
|
157
|
-
# @param args [String|Array<String>] See the description for calling style
|
|
145
|
+
# @param args [String|Array<String>] See the description for calling style.
|
|
146
|
+
# A packet name of LATEST applies to every packet which contains the item.
|
|
158
147
|
def disable_limits(*args, manual: false, scope: $openc3_scope, token: $openc3_token)
|
|
159
|
-
target_name,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
item['limits']['enabled'] = false
|
|
166
|
-
found_item = item
|
|
167
|
-
break
|
|
168
|
-
end
|
|
148
|
+
target_name, packet_names, item_name = _tlm_process_args_all_packets(args, 'disable_limits', scope: scope)
|
|
149
|
+
packet_names.each do |packet_name|
|
|
150
|
+
authorize(permission: 'tlm_set', target_name: target_name, packet_name: packet_name, manual: manual, scope: scope, token: token)
|
|
151
|
+
end
|
|
152
|
+
packet_names.each do |packet_name|
|
|
153
|
+
_set_limits_enabled(target_name, packet_name, item_name, false, scope: scope)
|
|
169
154
|
end
|
|
170
|
-
raise "Item '#{target_name} #{packet_name} #{item_name}' does not exist while disabling limits" unless found_item
|
|
171
|
-
|
|
172
|
-
TargetModel.set_packet(target_name, packet_name, packet, scope: scope)
|
|
173
|
-
|
|
174
|
-
message = "Disabling Limits for '#{target_name} #{packet_name} #{item_name}'"
|
|
175
|
-
Logger.info(message, scope: scope)
|
|
176
|
-
|
|
177
|
-
event = { type: :LIMITS_ENABLE_STATE, target_name: target_name, packet_name: packet_name,
|
|
178
|
-
item_name: item_name, enabled: false, time_nsec: Time.now.to_nsec_from_epoch, message: message }
|
|
179
|
-
LimitsEventTopic.write(event, scope: scope)
|
|
180
155
|
end
|
|
181
156
|
|
|
182
157
|
# Get a Hash of all the limits sets defined for an item. Hash keys are the limit
|
|
@@ -189,9 +164,16 @@ module OpenC3
|
|
|
189
164
|
#
|
|
190
165
|
# @return [Hash{String => Array<Number, Number, Number, Number, Number, Number>}]
|
|
191
166
|
def get_limits(target_name, packet_name, item_name, cache_timeout: nil, manual: false, scope: $openc3_scope, token: $openc3_token)
|
|
167
|
+
target_name = target_name.upcase
|
|
168
|
+
packet_name = packet_name.upcase
|
|
169
|
+
item_name = item_name.upcase
|
|
170
|
+
# Resolve LATEST before authorizing so the real packet is authorized
|
|
171
|
+
if packet_name == 'LATEST'
|
|
172
|
+
packet_name = CvtModel.determine_latest_packet_for_item(target_name, item_name, cache_timeout: cache_timeout, scope: scope)
|
|
173
|
+
end
|
|
192
174
|
authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, manual: manual, scope: scope, token: token)
|
|
193
175
|
limits = {}
|
|
194
|
-
item =
|
|
176
|
+
item = TargetModel.packet_item(target_name, packet_name, item_name, scope: scope)
|
|
195
177
|
item['limits'].each do |key, vals|
|
|
196
178
|
next unless vals.is_a?(Hash)
|
|
197
179
|
|
|
@@ -202,56 +184,58 @@ module OpenC3
|
|
|
202
184
|
end
|
|
203
185
|
|
|
204
186
|
# Change the limits settings for a given item. By default, a new limits set called 'CUSTOM'
|
|
205
|
-
# is created to avoid overriding existing limits.
|
|
187
|
+
# is created to avoid overriding existing limits. A packet name of LATEST
|
|
188
|
+
# applies to every packet which contains the item.
|
|
206
189
|
def set_limits(target_name, packet_name, item_name, red_low, yellow_low, yellow_high, red_high,
|
|
207
190
|
green_low = nil, green_high = nil, limits_set = 'CUSTOM', persistence = nil, enabled = true,
|
|
208
191
|
manual: false, scope: $openc3_scope, token: $openc3_token)
|
|
209
|
-
|
|
192
|
+
target_name = target_name.upcase
|
|
193
|
+
packet_name = packet_name.upcase
|
|
194
|
+
item_name = item_name.upcase
|
|
195
|
+
packet_names = (packet_name == 'LATEST') ? _tlm_packet_names(target_name, packet_name, item_name, scope: scope) : [packet_name]
|
|
196
|
+
packet_names.each do |name|
|
|
197
|
+
authorize(permission: 'tlm_set', target_name: target_name, packet_name: name, manual: manual, scope: scope, token: token)
|
|
198
|
+
end
|
|
210
199
|
if (red_low > yellow_low) || (yellow_low >= yellow_high) || (yellow_high > red_high)
|
|
211
200
|
raise "Invalid limits specified. Ensure yellow limits are within red limits."
|
|
212
201
|
end
|
|
213
202
|
if (green_low && green_high) && ((yellow_low > green_low) || (green_low >= green_high) || (green_high > yellow_high))
|
|
214
203
|
raise "Invalid limits specified. Ensure green limits are within yellow limits."
|
|
215
204
|
end
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
205
|
+
# Validate every packet before changing any so an error doesn't leave a partial update.
|
|
206
|
+
# TargetModel.packet returns a cached hash so it must not be modified until validated.
|
|
207
|
+
items = packet_names.map do |name|
|
|
208
|
+
packet = TargetModel.packet(target_name, name, scope: scope)
|
|
209
|
+
item = packet['items'].find { |packet_item| packet_item['name'] == item_name }
|
|
210
|
+
raise "Item '#{target_name} #{name} #{item_name}' does not exist while setting limits" unless item
|
|
211
|
+
raise "Cannot set_limits on item without any limits" unless item['limits']
|
|
212
|
+
[name, packet, item]
|
|
213
|
+
end
|
|
214
|
+
items.each do |name, packet, item|
|
|
215
|
+
item['limits']['persistence_setting'] = persistence if persistence
|
|
216
|
+
item['limits']['enabled'] = enabled ? true : false
|
|
217
|
+
limits = {}
|
|
218
|
+
limits['red_low'] = red_low
|
|
219
|
+
limits['yellow_low'] = yellow_low
|
|
220
|
+
limits['yellow_high'] = yellow_high
|
|
221
|
+
limits['red_high'] = red_high
|
|
222
|
+
limits['green_low'] = green_low if green_low && green_high
|
|
223
|
+
limits['green_high'] = green_high if green_low && green_high
|
|
224
|
+
item['limits'][limits_set] = limits
|
|
225
|
+
|
|
226
|
+
message = "Setting '#{target_name} #{name} #{item_name}' limits to #{red_low} #{yellow_low} #{yellow_high} #{red_high}"
|
|
227
|
+
message << " #{green_low} #{green_high}" if green_low && green_high
|
|
228
|
+
message << " in set #{limits_set} with persistence #{persistence} as enabled #{enabled}"
|
|
229
|
+
Logger.info(message, scope: scope)
|
|
230
|
+
|
|
231
|
+
TargetModel.set_packet(target_name, name, packet, scope: scope)
|
|
232
|
+
|
|
233
|
+
event = { type: :LIMITS_SETTINGS, target_name: target_name, packet_name: name,
|
|
234
|
+
item_name: item_name, red_low: red_low, yellow_low: yellow_low, yellow_high: yellow_high, red_high: red_high,
|
|
235
|
+
green_low: green_low, green_high: green_high, limits_set: limits_set, persistence: persistence, enabled: enabled,
|
|
236
|
+
time_nsec: Time.now.to_nsec_from_epoch, message: message }
|
|
237
|
+
LimitsEventTopic.write(event, scope: scope)
|
|
241
238
|
end
|
|
242
|
-
raise "Item '#{target_name} #{packet_name} #{item_name}' does not exist while setting limits" unless found_item
|
|
243
|
-
message = "Setting '#{target_name} #{packet_name} #{item_name}' limits to #{red_low} #{yellow_low} #{yellow_high} #{red_high}"
|
|
244
|
-
message << " #{green_low} #{green_high}" if green_low && green_high
|
|
245
|
-
message << " in set #{limits_set} with persistence #{persistence} as enabled #{enabled}"
|
|
246
|
-
Logger.info(message, scope: scope)
|
|
247
|
-
|
|
248
|
-
TargetModel.set_packet(target_name, packet_name, packet, scope: scope)
|
|
249
|
-
|
|
250
|
-
event = { type: :LIMITS_SETTINGS, target_name: target_name, packet_name: packet_name,
|
|
251
|
-
item_name: item_name, red_low: red_low, yellow_low: yellow_low, yellow_high: yellow_high, red_high: red_high,
|
|
252
|
-
green_low: green_low, green_high: green_high, limits_set: limits_set, persistence: persistence, enabled: enabled,
|
|
253
|
-
time_nsec: Time.now.to_nsec_from_epoch, message: message }
|
|
254
|
-
LimitsEventTopic.write(event, scope: scope)
|
|
255
239
|
end
|
|
256
240
|
|
|
257
241
|
# Change the color associated with a telemetry item state in realtime.
|
|
@@ -266,9 +250,16 @@ module OpenC3
|
|
|
266
250
|
# or RED. Pass nil to clear (remove) the state color. Setting a color also
|
|
267
251
|
# enables limits for the item, but clearing the color (nil) does not change
|
|
268
252
|
# whether limits are enabled.
|
|
253
|
+
# A packet name of LATEST applies to every packet which contains the item.
|
|
269
254
|
def set_state_color(target_name, packet_name, item_name, state_name, color,
|
|
270
255
|
manual: false, scope: $openc3_scope, token: $openc3_token)
|
|
271
|
-
|
|
256
|
+
target_name = target_name.upcase
|
|
257
|
+
packet_name = packet_name.upcase
|
|
258
|
+
item_name = item_name.upcase
|
|
259
|
+
packet_names = (packet_name == 'LATEST') ? _tlm_packet_names(target_name, packet_name, item_name, scope: scope) : [packet_name]
|
|
260
|
+
packet_names.each do |name|
|
|
261
|
+
authorize(permission: 'tlm_set', target_name: target_name, packet_name: name, manual: manual, scope: scope, token: token)
|
|
262
|
+
end
|
|
272
263
|
state_name = state_name.to_s.upcase
|
|
273
264
|
unless color.nil?
|
|
274
265
|
color = color.to_s.upcase
|
|
@@ -276,40 +267,42 @@ module OpenC3
|
|
|
276
267
|
raise "Invalid state color '#{color}'. Must be one of #{PacketItem::STATE_COLORS.join(', ')}."
|
|
277
268
|
end
|
|
278
269
|
end
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
# Clear the state color
|
|
288
|
-
item['states'][state_name].delete('color')
|
|
289
|
-
else
|
|
290
|
-
item['states'][state_name]['color'] = color
|
|
291
|
-
# Defining a state color implies limits are enabled for the item
|
|
292
|
-
item['limits'] ||= {}
|
|
293
|
-
item['limits']['enabled'] = true
|
|
294
|
-
end
|
|
295
|
-
found_item = item
|
|
296
|
-
break
|
|
270
|
+
# Validate every packet before changing any so an error doesn't leave a partial update.
|
|
271
|
+
# TargetModel.packet returns a cached hash so it must not be modified until validated.
|
|
272
|
+
items = packet_names.map do |name|
|
|
273
|
+
packet = TargetModel.packet(target_name, name, scope: scope)
|
|
274
|
+
item = packet['items'].find { |packet_item| packet_item['name'] == item_name }
|
|
275
|
+
raise "Item '#{target_name} #{name} #{item_name}' does not exist while setting state color" unless item
|
|
276
|
+
unless item['states'] && item['states'][state_name]
|
|
277
|
+
raise "State '#{state_name}' does not exist for item '#{target_name} #{name} #{item_name}'"
|
|
297
278
|
end
|
|
279
|
+
[name, packet, item]
|
|
298
280
|
end
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
281
|
+
items.each do |name, packet, item|
|
|
282
|
+
if color.nil?
|
|
283
|
+
# Clear the state color
|
|
284
|
+
item['states'][state_name].delete('color')
|
|
285
|
+
else
|
|
286
|
+
item['states'][state_name]['color'] = color
|
|
287
|
+
# Defining a state color implies limits are enabled for the item
|
|
288
|
+
item['limits'] ||= {}
|
|
289
|
+
item['limits']['enabled'] = true
|
|
290
|
+
end
|
|
306
291
|
|
|
307
|
-
|
|
292
|
+
if color.nil?
|
|
293
|
+
message = "Clearing '#{target_name} #{name} #{item_name}' state #{state_name} color"
|
|
294
|
+
else
|
|
295
|
+
message = "Setting '#{target_name} #{name} #{item_name}' state #{state_name} color to #{color}"
|
|
296
|
+
end
|
|
297
|
+
Logger.info(message, scope: scope)
|
|
308
298
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
299
|
+
TargetModel.set_packet(target_name, name, packet, scope: scope)
|
|
300
|
+
|
|
301
|
+
event = { type: :LIMITS_STATE_COLOR, target_name: target_name, packet_name: name,
|
|
302
|
+
item_name: item_name, state_name: state_name, color: color,
|
|
303
|
+
time_nsec: Time.now.to_nsec_from_epoch, message: message }
|
|
304
|
+
LimitsEventTopic.write(event, scope: scope)
|
|
305
|
+
end
|
|
313
306
|
end
|
|
314
307
|
|
|
315
308
|
# Returns all limits_groups and their members
|
|
@@ -407,58 +400,54 @@ module OpenC3
|
|
|
407
400
|
def _limits_group(group_name, action:, manual:, scope:, token:)
|
|
408
401
|
authorize(permission: 'tlm_set', manual: manual, scope: scope, token: token)
|
|
409
402
|
group_name.upcase!
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
TargetModel.set_packet(last_target_name, last_packet_name, packet, scope: scope)
|
|
421
|
-
end
|
|
403
|
+
# Items grouped by target and packet so each packet is read and written once
|
|
404
|
+
items = LimitsEventTopic.limits_group_items(group_name, scope: scope)
|
|
405
|
+
raise "LIMITS_GROUP #{group_name} undefined. Ensure your telemetry definition contains the line: LIMITS_GROUP #{group_name}" unless items
|
|
406
|
+
|
|
407
|
+
enabled = (action == :enable)
|
|
408
|
+
message = "#{enabled ? 'Enabling' : 'Disabling'} Limits Group: #{group_name}"
|
|
409
|
+
Logger.info(message, scope: scope)
|
|
410
|
+
|
|
411
|
+
items.each do |target_name, packets|
|
|
412
|
+
packets.each do |packet_name, item_names|
|
|
422
413
|
packet = TargetModel.packet(target_name, packet_name, scope: scope)
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
if action == :enable
|
|
427
|
-
enabled = true
|
|
428
|
-
item['limits']['enabled'] = true
|
|
429
|
-
message = "Enabling Limits for '#{target_name} #{packet_name} #{item_name}'"
|
|
430
|
-
elsif action == :disable
|
|
431
|
-
enabled = false
|
|
432
|
-
item['limits']['enabled'] = false
|
|
433
|
-
message = "Disabling Limits for '#{target_name} #{packet_name} #{item_name}'"
|
|
434
|
-
end
|
|
435
|
-
Logger.info(message, scope: scope)
|
|
436
|
-
|
|
437
|
-
event = { type: :LIMITS_ENABLE_STATE, target_name: target_name, packet_name: packet_name,
|
|
438
|
-
item_name: item_name, enabled: enabled, time_nsec: Time.now.to_nsec_from_epoch, message: message }
|
|
439
|
-
LimitsEventTopic.write(event, scope: scope)
|
|
440
|
-
break
|
|
414
|
+
item_names_hash = item_names.to_h { |name| [name, true] }
|
|
415
|
+
packet['items'].each do |item|
|
|
416
|
+
item['limits']['enabled'] = enabled if item_names_hash[item['name']]
|
|
441
417
|
end
|
|
418
|
+
TargetModel.set_packet(target_name, packet_name, packet, scope: scope)
|
|
442
419
|
end
|
|
443
|
-
last_target_name = target_name
|
|
444
|
-
last_packet_name = packet_name
|
|
445
|
-
end
|
|
446
|
-
if last_target_name && last_packet_name
|
|
447
|
-
TargetModel.set_packet(last_target_name, last_packet_name, packet, scope: scope)
|
|
448
420
|
end
|
|
421
|
+
|
|
422
|
+
# Write a single event for the entire group. Writing one event per item
|
|
423
|
+
# floods the limits event stream, which is trimmed to ~1000 entries, so
|
|
424
|
+
# decom microservices could miss events and leave limits enabled.
|
|
425
|
+
# The event only names the group (readers look up the items) so it stays
|
|
426
|
+
# small no matter how many items the group contains.
|
|
427
|
+
event = { type: :LIMITS_GROUP_ENABLE_STATE, group_name: group_name,
|
|
428
|
+
enabled: enabled, time_nsec: Time.now.to_nsec_from_epoch, message: message }
|
|
429
|
+
LimitsEventTopic.write(event, scope: scope)
|
|
449
430
|
end
|
|
450
431
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
432
|
+
def _set_limits_enabled(target_name, packet_name, item_name, enabled, scope:)
|
|
433
|
+
packet = TargetModel.packet(target_name, packet_name, scope: scope)
|
|
434
|
+
item = packet['items'].find { |packet_item| packet_item['name'] == item_name }
|
|
435
|
+
action = enabled ? 'enabling' : 'disabling'
|
|
436
|
+
raise "Item '#{target_name} #{packet_name} #{item_name}' does not exist while #{action} limits" unless item
|
|
437
|
+
|
|
438
|
+
item['limits']['enabled'] = enabled
|
|
439
|
+
TargetModel.set_packet(target_name, packet_name, packet, scope: scope)
|
|
440
|
+
|
|
441
|
+
if enabled
|
|
442
|
+
message = "Enabling Limits For '#{target_name} #{packet_name} #{item_name}'"
|
|
443
|
+
else
|
|
444
|
+
message = "Disabling Limits for '#{target_name} #{packet_name} #{item_name}'"
|
|
445
|
+
end
|
|
446
|
+
Logger.info(message, scope: scope)
|
|
447
|
+
|
|
448
|
+
event = { type: :LIMITS_ENABLE_STATE, target_name: target_name, packet_name: packet_name,
|
|
449
|
+
item_name: item_name, enabled: enabled, time_nsec: Time.now.to_nsec_from_epoch, message: message }
|
|
450
|
+
LimitsEventTopic.write(event, scope: scope)
|
|
462
451
|
end
|
|
463
452
|
end
|
|
464
453
|
end
|