openc3 5.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +18 -0
- data/Guardfile +35 -0
- data/LICENSE.txt +727 -0
- data/README.md +37 -0
- data/Rakefile +131 -0
- data/bin/cstol_converter +1178 -0
- data/bin/openc3cli +531 -0
- data/bin/rubysloc +139 -0
- data/data/config/_array_params.yaml +23 -0
- data/data/config/_id_items.yaml +24 -0
- data/data/config/_id_params.yaml +58 -0
- data/data/config/_interfaces.yaml +214 -0
- data/data/config/_interfaces.yaml.err +1017 -0
- data/data/config/_items.yaml +20 -0
- data/data/config/_params.yaml +60 -0
- data/data/config/cmd_tlm_server.yaml +136 -0
- data/data/config/command.yaml +44 -0
- data/data/config/command_modifiers.yaml +160 -0
- data/data/config/command_telemetry.yaml +3 -0
- data/data/config/interface_modifiers.yaml +104 -0
- data/data/config/item_modifiers.yaml +221 -0
- data/data/config/microservice.yaml +78 -0
- data/data/config/param_item_modifiers.yaml +52 -0
- data/data/config/parameter_modifiers.yaml +200 -0
- data/data/config/plugins.yaml +80 -0
- data/data/config/protocols.yaml +290 -0
- data/data/config/screen.yaml +147 -0
- data/data/config/table_manager.yaml +89 -0
- data/data/config/table_parameter_modifiers.yaml +9 -0
- data/data/config/target.yaml +142 -0
- data/data/config/target_config.yaml +94 -0
- data/data/config/telemetry.yaml +87 -0
- data/data/config/telemetry_modifiers.yaml +159 -0
- data/data/config/tool.yaml +63 -0
- data/data/config/unknown.yaml +3 -0
- data/data/config/widgets.yaml +1505 -0
- data/ext/mkrf_conf.rb +49 -0
- data/ext/openc3/ext/array/array.c +122 -0
- data/ext/openc3/ext/array/extconf.rb +13 -0
- data/ext/openc3/ext/buffered_file/buffered_file.c +198 -0
- data/ext/openc3/ext/buffered_file/extconf.rb +13 -0
- data/ext/openc3/ext/config_parser/config_parser.c +280 -0
- data/ext/openc3/ext/config_parser/extconf.rb +13 -0
- data/ext/openc3/ext/crc/crc.c +351 -0
- data/ext/openc3/ext/crc/extconf.rb +13 -0
- data/ext/openc3/ext/openc3_io/extconf.rb +13 -0
- data/ext/openc3/ext/openc3_io/openc3_io.c +158 -0
- data/ext/openc3/ext/packet/extconf.rb +13 -0
- data/ext/openc3/ext/packet/packet.c +318 -0
- data/ext/openc3/ext/platform/extconf.rb +13 -0
- data/ext/openc3/ext/platform/platform.c +134 -0
- data/ext/openc3/ext/polynomial_conversion/extconf.rb +13 -0
- data/ext/openc3/ext/polynomial_conversion/polynomial_conversion.c +79 -0
- data/ext/openc3/ext/string/extconf.rb +13 -0
- data/ext/openc3/ext/string/string.c +63 -0
- data/ext/openc3/ext/structure/structure.c +1719 -0
- data/ext/openc3/ext/tabbed_plots_config/extconf.rb +13 -0
- data/ext/openc3/ext/tabbed_plots_config/tabbed_plots_config.c +62 -0
- data/ext/openc3/ext/telemetry/extconf.rb +13 -0
- data/ext/openc3/ext/telemetry/telemetry.c +336 -0
- data/lib/cosmos.rb +20 -0
- data/lib/cosmosc2.rb +20 -0
- data/lib/openc3/api/api.rb +39 -0
- data/lib/openc3/api/authorized_api.rb +30 -0
- data/lib/openc3/api/cmd_api.rb +451 -0
- data/lib/openc3/api/config_api.rb +58 -0
- data/lib/openc3/api/interface_api.rb +117 -0
- data/lib/openc3/api/limits_api.rb +375 -0
- data/lib/openc3/api/router_api.rb +117 -0
- data/lib/openc3/api/settings_api.rb +70 -0
- data/lib/openc3/api/target_api.rb +78 -0
- data/lib/openc3/api/tlm_api.rb +455 -0
- data/lib/openc3/bridge/bridge.rb +54 -0
- data/lib/openc3/bridge/bridge_config.rb +167 -0
- data/lib/openc3/bridge/bridge_interface_thread.rb +42 -0
- data/lib/openc3/bridge/bridge_router_thread.rb +42 -0
- data/lib/openc3/ccsds/ccsds_packet.rb +68 -0
- data/lib/openc3/ccsds/ccsds_parser.rb +148 -0
- data/lib/openc3/config/config_parser.rb +549 -0
- data/lib/openc3/config/meta_config_parser.rb +74 -0
- data/lib/openc3/conversions/conversion.rb +70 -0
- data/lib/openc3/conversions/generic_conversion.rb +83 -0
- data/lib/openc3/conversions/packet_time_formatted_conversion.rb +43 -0
- data/lib/openc3/conversions/packet_time_seconds_conversion.rb +43 -0
- data/lib/openc3/conversions/polynomial_conversion.rb +87 -0
- data/lib/openc3/conversions/processor_conversion.rb +70 -0
- data/lib/openc3/conversions/received_count_conversion.rb +38 -0
- data/lib/openc3/conversions/received_time_formatted_conversion.rb +42 -0
- data/lib/openc3/conversions/received_time_seconds_conversion.rb +42 -0
- data/lib/openc3/conversions/segmented_polynomial_conversion.rb +171 -0
- data/lib/openc3/conversions/unix_time_conversion.rb +68 -0
- data/lib/openc3/conversions/unix_time_formatted_conversion.rb +49 -0
- data/lib/openc3/conversions/unix_time_seconds_conversion.rb +49 -0
- data/lib/openc3/conversions.rb +34 -0
- data/lib/openc3/core_ext/array.rb +416 -0
- data/lib/openc3/core_ext/binding.rb +29 -0
- data/lib/openc3/core_ext/class.rb +72 -0
- data/lib/openc3/core_ext/exception.rb +61 -0
- data/lib/openc3/core_ext/file.rb +83 -0
- data/lib/openc3/core_ext/hash.rb +37 -0
- data/lib/openc3/core_ext/io.rb +134 -0
- data/lib/openc3/core_ext/kernel.rb +42 -0
- data/lib/openc3/core_ext/math.rb +128 -0
- data/lib/openc3/core_ext/matrix.rb +156 -0
- data/lib/openc3/core_ext/objectspace.rb +36 -0
- data/lib/openc3/core_ext/openc3_io.rb +57 -0
- data/lib/openc3/core_ext/range.rb +27 -0
- data/lib/openc3/core_ext/socket.rb +38 -0
- data/lib/openc3/core_ext/string.rb +389 -0
- data/lib/openc3/core_ext/stringio.rb +33 -0
- data/lib/openc3/core_ext/time.rb +508 -0
- data/lib/openc3/core_ext.rb +36 -0
- data/lib/openc3/interfaces/interface.rb +498 -0
- data/lib/openc3/interfaces/linc_interface.rb +475 -0
- data/lib/openc3/interfaces/protocols/burst_protocol.rb +192 -0
- data/lib/openc3/interfaces/protocols/crc_protocol.rb +193 -0
- data/lib/openc3/interfaces/protocols/fixed_protocol.rb +155 -0
- data/lib/openc3/interfaces/protocols/ignore_packet_protocol.rb +56 -0
- data/lib/openc3/interfaces/protocols/length_protocol.rb +165 -0
- data/lib/openc3/interfaces/protocols/override_protocol.rb +60 -0
- data/lib/openc3/interfaces/protocols/preidentified_protocol.rb +206 -0
- data/lib/openc3/interfaces/protocols/protocol.rb +82 -0
- data/lib/openc3/interfaces/protocols/template_protocol.rb +261 -0
- data/lib/openc3/interfaces/protocols/terminated_protocol.rb +93 -0
- data/lib/openc3/interfaces/serial_interface.rb +94 -0
- data/lib/openc3/interfaces/simulated_target_interface.rb +168 -0
- data/lib/openc3/interfaces/stream_interface.rb +81 -0
- data/lib/openc3/interfaces/tcpip_client_interface.rb +69 -0
- data/lib/openc3/interfaces/tcpip_server_interface.rb +629 -0
- data/lib/openc3/interfaces/udp_interface.rb +169 -0
- data/lib/openc3/interfaces.rb +44 -0
- data/lib/openc3/io/buffered_file.rb +109 -0
- data/lib/openc3/io/io_multiplexer.rb +80 -0
- data/lib/openc3/io/json_api_object.rb +208 -0
- data/lib/openc3/io/json_drb.rb +335 -0
- data/lib/openc3/io/json_drb_object.rb +114 -0
- data/lib/openc3/io/json_drb_rack.rb +84 -0
- data/lib/openc3/io/json_rpc.rb +420 -0
- data/lib/openc3/io/openc3_snmp.rb +58 -0
- data/lib/openc3/io/posix_serial_driver.rb +156 -0
- data/lib/openc3/io/raw_logger.rb +167 -0
- data/lib/openc3/io/raw_logger_pair.rb +77 -0
- data/lib/openc3/io/serial_driver.rb +105 -0
- data/lib/openc3/io/stderr.rb +43 -0
- data/lib/openc3/io/stdout.rb +43 -0
- data/lib/openc3/io/udp_sockets.rb +194 -0
- data/lib/openc3/io/win32_serial_driver.rb +196 -0
- data/lib/openc3/logs/log_writer.rb +302 -0
- data/lib/openc3/logs/packet_log_constants.rb +62 -0
- data/lib/openc3/logs/packet_log_reader.rb +345 -0
- data/lib/openc3/logs/packet_log_writer.rb +299 -0
- data/lib/openc3/logs/text_log_writer.rb +68 -0
- data/lib/openc3/logs.rb +25 -0
- data/lib/openc3/microservices/cleanup_microservice.rb +68 -0
- data/lib/openc3/microservices/decom_microservice.rb +136 -0
- data/lib/openc3/microservices/interface_microservice.rb +532 -0
- data/lib/openc3/microservices/log_microservice.rb +108 -0
- data/lib/openc3/microservices/microservice.rb +204 -0
- data/lib/openc3/microservices/plugin_microservice.rb +43 -0
- data/lib/openc3/microservices/reaction_microservice.rb +541 -0
- data/lib/openc3/microservices/reducer_microservice.rb +313 -0
- data/lib/openc3/microservices/router_microservice.rb +44 -0
- data/lib/openc3/microservices/text_log_microservice.rb +84 -0
- data/lib/openc3/microservices/timeline_microservice.rb +363 -0
- data/lib/openc3/microservices/trigger_group_microservice.rb +638 -0
- data/lib/openc3/models/activity_model.rb +319 -0
- data/lib/openc3/models/auth_model.rb +65 -0
- data/lib/openc3/models/cvt_model.rb +185 -0
- data/lib/openc3/models/environment_model.rb +58 -0
- data/lib/openc3/models/gem_model.rb +137 -0
- data/lib/openc3/models/info_model.rb +31 -0
- data/lib/openc3/models/interface_model.rb +281 -0
- data/lib/openc3/models/interface_status_model.rb +117 -0
- data/lib/openc3/models/metadata_model.rb +139 -0
- data/lib/openc3/models/metric_model.rb +59 -0
- data/lib/openc3/models/microservice_model.rb +206 -0
- data/lib/openc3/models/microservice_status_model.rb +74 -0
- data/lib/openc3/models/model.rb +204 -0
- data/lib/openc3/models/note_model.rb +122 -0
- data/lib/openc3/models/notification_model.rb +40 -0
- data/lib/openc3/models/ping_model.rb +35 -0
- data/lib/openc3/models/plugin_model.rb +292 -0
- data/lib/openc3/models/process_status_model.rb +76 -0
- data/lib/openc3/models/reaction_model.rb +322 -0
- data/lib/openc3/models/reducer_model.rb +65 -0
- data/lib/openc3/models/router_model.rb +35 -0
- data/lib/openc3/models/router_status_model.rb +27 -0
- data/lib/openc3/models/scope_model.rb +153 -0
- data/lib/openc3/models/settings_model.rb +55 -0
- data/lib/openc3/models/sorted_model.rb +167 -0
- data/lib/openc3/models/target_model.rb +759 -0
- data/lib/openc3/models/timeline_model.rb +154 -0
- data/lib/openc3/models/tool_config_model.rb +38 -0
- data/lib/openc3/models/tool_model.rb +262 -0
- data/lib/openc3/models/trigger_group_model.rb +186 -0
- data/lib/openc3/models/trigger_model.rb +330 -0
- data/lib/openc3/models/widget_model.rb +138 -0
- data/lib/openc3/operators/microservice_operator.rb +128 -0
- data/lib/openc3/operators/operator.rb +277 -0
- data/lib/openc3/packets/binary_accessor.rb +1207 -0
- data/lib/openc3/packets/commands.rb +373 -0
- data/lib/openc3/packets/json_packet.rb +134 -0
- data/lib/openc3/packets/limits.rb +271 -0
- data/lib/openc3/packets/limits_response.rb +53 -0
- data/lib/openc3/packets/packet.rb +1168 -0
- data/lib/openc3/packets/packet_config.rb +625 -0
- data/lib/openc3/packets/packet_item.rb +586 -0
- data/lib/openc3/packets/packet_item_limits.rb +162 -0
- data/lib/openc3/packets/parsers/format_string_parser.rb +65 -0
- data/lib/openc3/packets/parsers/limits_parser.rb +159 -0
- data/lib/openc3/packets/parsers/limits_response_parser.rb +61 -0
- data/lib/openc3/packets/parsers/packet_item_parser.rb +272 -0
- data/lib/openc3/packets/parsers/packet_parser.rb +134 -0
- data/lib/openc3/packets/parsers/processor_parser.rb +73 -0
- data/lib/openc3/packets/parsers/state_parser.rb +127 -0
- data/lib/openc3/packets/parsers/xtce_converter.rb +442 -0
- data/lib/openc3/packets/parsers/xtce_parser.rb +722 -0
- data/lib/openc3/packets/structure.rb +553 -0
- data/lib/openc3/packets/structure_item.rb +365 -0
- data/lib/openc3/packets/telemetry.rb +487 -0
- data/lib/openc3/processors/processor.rb +86 -0
- data/lib/openc3/processors/statistics_processor.rb +82 -0
- data/lib/openc3/processors/watermark_processor.rb +58 -0
- data/lib/openc3/processors.rb +24 -0
- data/lib/openc3/script/api_shared.rb +828 -0
- data/lib/openc3/script/calendar.rb +89 -0
- data/lib/openc3/script/commands.rb +227 -0
- data/lib/openc3/script/exceptions.rb +29 -0
- data/lib/openc3/script/extract.rb +161 -0
- data/lib/openc3/script/limits.rb +60 -0
- data/lib/openc3/script/script.rb +299 -0
- data/lib/openc3/script/script_runner.rb +238 -0
- data/lib/openc3/script/storage.rb +146 -0
- data/lib/openc3/script/suite.rb +542 -0
- data/lib/openc3/script/suite_results.rb +196 -0
- data/lib/openc3/script/suite_runner.rb +217 -0
- data/lib/openc3/script.rb +21 -0
- data/lib/openc3/streams/serial_stream.rb +167 -0
- data/lib/openc3/streams/stream.rb +63 -0
- data/lib/openc3/streams/tcpip_client_stream.rb +116 -0
- data/lib/openc3/streams/tcpip_socket_stream.rb +195 -0
- data/lib/openc3/system/system.rb +127 -0
- data/lib/openc3/system/system_config.rb +411 -0
- data/lib/openc3/system/target.rb +269 -0
- data/lib/openc3/system.rb +24 -0
- data/lib/openc3/tools/cmd_tlm_server/api.rb +20 -0
- data/lib/openc3/tools/cmd_tlm_server/cmd_tlm_server_config.rb +320 -0
- data/lib/openc3/tools/cmd_tlm_server/interface_thread.rb +294 -0
- data/lib/openc3/tools/table_manager/table.rb +77 -0
- data/lib/openc3/tools/table_manager/table_config.rb +273 -0
- data/lib/openc3/tools/table_manager/table_item.rb +90 -0
- data/lib/openc3/tools/table_manager/table_item_parser.rb +66 -0
- data/lib/openc3/tools/table_manager/table_manager_core.rb +333 -0
- data/lib/openc3/tools/table_manager/table_parser.rb +93 -0
- data/lib/openc3/tools/test_runner/test.rb +67 -0
- data/lib/openc3/top_level.rb +595 -0
- data/lib/openc3/topics/autonomic_topic.rb +52 -0
- data/lib/openc3/topics/calendar_topic.rb +44 -0
- data/lib/openc3/topics/command_decom_topic.rb +76 -0
- data/lib/openc3/topics/command_topic.rb +83 -0
- data/lib/openc3/topics/config_topic.rb +68 -0
- data/lib/openc3/topics/interface_topic.rb +73 -0
- data/lib/openc3/topics/limits_event_topic.rb +109 -0
- data/lib/openc3/topics/notifications_topic.rb +28 -0
- data/lib/openc3/topics/router_topic.rb +85 -0
- data/lib/openc3/topics/telemetry_decom_topic.rb +54 -0
- data/lib/openc3/topics/telemetry_topic.rb +36 -0
- data/lib/openc3/topics/timeline_topic.rb +45 -0
- data/lib/openc3/topics/topic.rb +53 -0
- data/lib/openc3/utilities/authentication.rb +141 -0
- data/lib/openc3/utilities/authorization.rb +51 -0
- data/lib/openc3/utilities/crc.rb +278 -0
- data/lib/openc3/utilities/csv.rb +153 -0
- data/lib/openc3/utilities/logger.rb +187 -0
- data/lib/openc3/utilities/message_log.rb +91 -0
- data/lib/openc3/utilities/metric.rb +141 -0
- data/lib/openc3/utilities/process_manager.rb +139 -0
- data/lib/openc3/utilities/quaternion.rb +257 -0
- data/lib/openc3/utilities/ruby_lex_utils.rb +568 -0
- data/lib/openc3/utilities/s3.rb +202 -0
- data/lib/openc3/utilities/s3_autoload.rb +9 -0
- data/lib/openc3/utilities/s3_file_cache.rb +274 -0
- data/lib/openc3/utilities/simulated_target.rb +117 -0
- data/lib/openc3/utilities/sleeper.rb +51 -0
- data/lib/openc3/utilities/store.rb +23 -0
- data/lib/openc3/utilities/store_autoload.rb +237 -0
- data/lib/openc3/utilities/zip.rb +21 -0
- data/lib/openc3/utilities.rb +35 -0
- data/lib/openc3/version.rb +14 -0
- data/lib/openc3/win32/excel.rb +132 -0
- data/lib/openc3/win32/win32.rb +402 -0
- data/lib/openc3/win32/win32_main.rb +333 -0
- data/lib/openc3.rb +49 -0
- data/tasks/gemfile_stats.rake +113 -0
- data/tasks/spec.rake +30 -0
- data/templates/plugin-template/README.md +15 -0
- data/templates/plugin-template/Rakefile +12 -0
- data/templates/plugin-template/plugin.gemspec +23 -0
- data/templates/plugin-template/plugin.txt +9 -0
- data/templates/plugin-template/targets/TARGET/cmd_tlm/cmd.txt +8 -0
- data/templates/plugin-template/targets/TARGET/cmd_tlm/tlm.txt +8 -0
- data/templates/plugin-template/targets/TARGET/lib/target.rb +10 -0
- data/templates/plugin-template/targets/TARGET/procedures/procedure.rb +3 -0
- data/templates/plugin-template/targets/TARGET/screens/status.txt +9 -0
- data/templates/plugin-template/targets/TARGET/target.txt +5 -0
- metadata +849 -0
@@ -0,0 +1,271 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
|
3
|
+
# Copyright 2022 Ball Aerospace & Technologies Corp.
|
4
|
+
# All Rights Reserved.
|
5
|
+
#
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
7
|
+
# under the terms of the GNU Affero General Public License
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Affero General Public License for more details.
|
15
|
+
|
16
|
+
# Modified by OpenC3, Inc.
|
17
|
+
# All changes Copyright 2022, OpenC3, Inc.
|
18
|
+
# All Rights Reserved
|
19
|
+
|
20
|
+
require 'openc3/packets/packet_config'
|
21
|
+
|
22
|
+
module OpenC3
|
23
|
+
# Limits uses PacketConfig to parse the command and telemetry
|
24
|
+
# configuration files. It provides the API layer which other classes use to
|
25
|
+
# access information about and manipulate limits. This includes getting,
|
26
|
+
# setting and checking individual limit items as well as manipulating limits
|
27
|
+
# groups.
|
28
|
+
class Limits
|
29
|
+
# @param config [PacketConfig] The packet configuration which controls all other outputs
|
30
|
+
attr_accessor :config
|
31
|
+
|
32
|
+
LATEST_PACKET_NAME = 'LATEST'.freeze
|
33
|
+
|
34
|
+
# @param config [PacketConfig] Packet configuration to use to access the
|
35
|
+
# limits information
|
36
|
+
def initialize(config)
|
37
|
+
@config = config
|
38
|
+
end
|
39
|
+
|
40
|
+
# (see PacketConfig#warnings)
|
41
|
+
def warnings
|
42
|
+
return @config.warnings
|
43
|
+
end
|
44
|
+
|
45
|
+
# (see PacketConfig#limits_sets)
|
46
|
+
def sets
|
47
|
+
return @config.limits_sets
|
48
|
+
end
|
49
|
+
|
50
|
+
# (see OpenC3::Packet#out_of_limits)
|
51
|
+
def out_of_limits
|
52
|
+
items = []
|
53
|
+
@config.telemetry.each do |target_name, target_packets|
|
54
|
+
target_packets.each do |packet_name, packet|
|
55
|
+
new_items = packet.out_of_limits
|
56
|
+
items.concat(new_items)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
return items
|
60
|
+
end
|
61
|
+
|
62
|
+
# @param ignored_items [Array<Array<String, String, String>>] Items to ignore from the consideration
|
63
|
+
# @return [Symbol] The overall limits state for the system
|
64
|
+
def overall_limits_state(ignored_items = nil)
|
65
|
+
overall = :GREEN
|
66
|
+
limits_packet_stale = false
|
67
|
+
items_out_of_limits = []
|
68
|
+
# Note: If anything with limits is stale then overall limits state cannot be green or blue
|
69
|
+
@config.telemetry.each do |target_name, target_packets|
|
70
|
+
target_packets.each do |packet_name, packet|
|
71
|
+
if packet.stale && !packet.limits_items.empty?
|
72
|
+
if ignored_items
|
73
|
+
all_ignored = true
|
74
|
+
packet.limits_items.each do |item|
|
75
|
+
all_ignored = false unless includes_item?(ignored_items, target_name, packet_name, item.name)
|
76
|
+
end
|
77
|
+
else
|
78
|
+
all_ignored = false
|
79
|
+
end
|
80
|
+
limits_packet_stale = true unless all_ignored
|
81
|
+
end
|
82
|
+
items_out_of_limits.concat(packet.out_of_limits)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
items_out_of_limits.each do |target_name, packet_name, item_name, limits_state|
|
86
|
+
next if ignored_items && includes_item?(ignored_items, target_name, packet_name, item_name)
|
87
|
+
|
88
|
+
case overall
|
89
|
+
# If our overall state is currently blue or green we can go to any state
|
90
|
+
when :BLUE, :GREEN, :GREEN_HIGH, :GREEN_LOW
|
91
|
+
overall = limits_state
|
92
|
+
# If our overal state is yellow we can only go higher to red
|
93
|
+
when :YELLOW, :YELLOW_HIGH, :YELLOW_LOW
|
94
|
+
if limits_state == :RED || limits_state == :RED_HIGH || limits_state == :RED_LOW
|
95
|
+
overall = limits_state
|
96
|
+
break # Red is as high as we go so no need to look for more
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
overall = :GREEN if overall == :GREEN_HIGH || overall == :GREEN_LOW || overall == :BLUE
|
101
|
+
overall = :YELLOW if overall == :YELLOW_HIGH || overall == :YELLOW_LOW
|
102
|
+
overall = :RED if overall == :RED_HIGH || overall == :RED_LOW
|
103
|
+
overall = :STALE if (overall == :GREEN || overall == :BLUE) && limits_packet_stale
|
104
|
+
return overall
|
105
|
+
end
|
106
|
+
|
107
|
+
# @return [Hash(String, Array)] The defined limits groups
|
108
|
+
def groups
|
109
|
+
return @config.limits_groups
|
110
|
+
end
|
111
|
+
|
112
|
+
# Enables limit checking for all the items in the given group.
|
113
|
+
#
|
114
|
+
# @param group_name [String] Name of the group to enable
|
115
|
+
def enable_group(group_name)
|
116
|
+
group_upcase = group_name.to_s.upcase
|
117
|
+
limits_group = @config.limits_groups[group_upcase]
|
118
|
+
if limits_group
|
119
|
+
limits_group.each do |target_name, packet_name, item_name|
|
120
|
+
enable(target_name, packet_name, item_name)
|
121
|
+
end
|
122
|
+
else
|
123
|
+
raise "LIMITS_GROUP #{group_upcase} undefined. Ensure your telemetry definition contains the line: LIMITS_GROUP #{group_upcase}"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
# Disables limit checking for all the items in the given group.
|
128
|
+
#
|
129
|
+
# @param group_name [String] Name of the group to disable
|
130
|
+
def disable_group(group_name)
|
131
|
+
group_upcase = group_name.to_s.upcase
|
132
|
+
limits_group = @config.limits_groups[group_upcase]
|
133
|
+
if limits_group
|
134
|
+
limits_group.each do |target_name, packet_name, item_name|
|
135
|
+
disable(target_name, packet_name, item_name)
|
136
|
+
end
|
137
|
+
else
|
138
|
+
raise "LIMITS_GROUP #{group_upcase} undefined. Ensure your telemetry definition contains the line: LIMITS_GROUP #{group_upcase}"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# Checks whether the limits are enabled for the specified item
|
143
|
+
#
|
144
|
+
# @param target_name [String] The target name
|
145
|
+
# @param packet_name [String] The packet name. Must be a defined packet name and not 'LATEST'.
|
146
|
+
# @param item_name [String] The item name
|
147
|
+
def enabled?(target_name, packet_name, item_name)
|
148
|
+
get_packet(target_name, packet_name).get_item(item_name).limits.enabled
|
149
|
+
end
|
150
|
+
|
151
|
+
# Enables limit checking for the specified item
|
152
|
+
#
|
153
|
+
# @param (see #enabled?)
|
154
|
+
def enable(target_name, packet_name, item_name)
|
155
|
+
get_packet(target_name, packet_name).enable_limits(item_name)
|
156
|
+
end
|
157
|
+
|
158
|
+
# Disables limit checking for the specified item
|
159
|
+
#
|
160
|
+
# @param (see #enabled?)
|
161
|
+
def disable(target_name, packet_name, item_name)
|
162
|
+
get_packet(target_name, packet_name).disable_limits(item_name)
|
163
|
+
end
|
164
|
+
|
165
|
+
# Get the limits for a telemetry item
|
166
|
+
#
|
167
|
+
# @param target_name [String] Target Name
|
168
|
+
# @param packet_name [String] Packet Name
|
169
|
+
# @param item_name [String] Item Name
|
170
|
+
# @param limits_set [String or Symbol or nil] Desired Limits set. nil = current limits set
|
171
|
+
# @return [Array<limits_set, persistence, enabled, red_low, yellow_low, red_high, yellow_high, green_low (optional), green_high (optional)] Limits information
|
172
|
+
def get(target_name, packet_name, item_name, limits_set = nil)
|
173
|
+
limits = get_packet(target_name, packet_name).get_item(item_name).limits
|
174
|
+
if limits.values
|
175
|
+
if limits_set
|
176
|
+
limits_set = limits_set.to_s.upcase.intern
|
177
|
+
else
|
178
|
+
limits_set = System.limits_set
|
179
|
+
end
|
180
|
+
limits_for_set = limits.values[limits_set]
|
181
|
+
if limits_for_set
|
182
|
+
return [limits_set, limits.persistence_setting, limits.enabled, limits_for_set[0], limits_for_set[1], limits_for_set[2], limits_for_set[3], limits_for_set[4], limits_for_set[5]]
|
183
|
+
else
|
184
|
+
return [nil, nil, nil, nil, nil, nil, nil, nil, nil]
|
185
|
+
end
|
186
|
+
else
|
187
|
+
return [nil, nil, nil, nil, nil, nil, nil, nil, nil]
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
# Set the limits for a telemetry item
|
192
|
+
#
|
193
|
+
# @param target_name [String] Target Name
|
194
|
+
# @param packet_name [String] Packet Name
|
195
|
+
# @param item_name [String] Item Name
|
196
|
+
# @param red_low [Float] Red Low Limit
|
197
|
+
# @param yellow_low [Float] Yellow Low Limit
|
198
|
+
# @param yellow_high [Float] Yellow High Limit
|
199
|
+
# @param red_high [Float] Red High Limit
|
200
|
+
# @param green_low [Float] Green Low Limit
|
201
|
+
# @param green_high [Float] Green High Limit
|
202
|
+
# @param limits_set [String or Symbol or nil] Desired Limits set. nil = current limits set, recommend using :CUSTOM
|
203
|
+
# @param persistence [Integer] The number of samples the value must be out of limits before detecting a limits change. nil = Leave unchanged
|
204
|
+
# @param enabled [Boolean] If limits monitoring is enabled for this item
|
205
|
+
# @return [Array<limits_set, persistence, enabled, red_low, yellow_low, red_high, yellow_high, green_low (optional), green_high (optional)] Limits information
|
206
|
+
def set(target_name, packet_name, item_name, red_low, yellow_low, yellow_high, red_high, green_low = nil, green_high = nil, limits_set = :CUSTOM, persistence = nil, enabled = true)
|
207
|
+
packet = get_packet(target_name, packet_name)
|
208
|
+
item = packet.get_item(item_name)
|
209
|
+
limits = item.limits
|
210
|
+
if limits_set
|
211
|
+
limits_set = limits_set.to_s.upcase.intern
|
212
|
+
else
|
213
|
+
limits_set = System.limits_set
|
214
|
+
end
|
215
|
+
if !limits.values
|
216
|
+
if limits_set == :DEFAULT
|
217
|
+
limits.values = { :DEFAULT => [] }
|
218
|
+
else
|
219
|
+
raise "DEFAULT limits must be defined for #{target_name} #{packet_name} #{item_name} before setting limits set #{limits_set}"
|
220
|
+
end
|
221
|
+
end
|
222
|
+
limits_for_set = limits.values[limits_set]
|
223
|
+
unless limits_for_set
|
224
|
+
limits.values[limits_set] = []
|
225
|
+
limits_for_set = limits.values[limits_set]
|
226
|
+
end
|
227
|
+
limits_for_set[0] = red_low.to_f
|
228
|
+
limits_for_set[1] = yellow_low.to_f
|
229
|
+
limits_for_set[2] = yellow_high.to_f
|
230
|
+
limits_for_set[3] = red_high.to_f
|
231
|
+
limits_for_set.delete_at(5) if limits_for_set[5]
|
232
|
+
limits_for_set.delete_at(4) if limits_for_set[4]
|
233
|
+
if green_low && green_high
|
234
|
+
limits_for_set[4] = green_low.to_f
|
235
|
+
limits_for_set[5] = green_high.to_f
|
236
|
+
end
|
237
|
+
limits.enabled = enabled
|
238
|
+
limits.persistence_setting = Integer(persistence) if persistence
|
239
|
+
packet.update_limits_items_cache(item)
|
240
|
+
@config.limits_sets << limits_set
|
241
|
+
@config.limits_sets.uniq!
|
242
|
+
return [limits_set, limits.persistence_setting, limits.enabled, limits_for_set[0], limits_for_set[1], limits_for_set[2], limits_for_set[3], limits_for_set[4], limits_for_set[5]]
|
243
|
+
end
|
244
|
+
|
245
|
+
protected
|
246
|
+
|
247
|
+
def get_packet(target_name, packet_name)
|
248
|
+
raise "LATEST packet not valid" if packet_name.upcase == LATEST_PACKET_NAME
|
249
|
+
|
250
|
+
packets = @config.telemetry[target_name.to_s.upcase]
|
251
|
+
raise "Telemetry target '#{target_name.to_s.upcase}' does not exist" unless packets
|
252
|
+
|
253
|
+
packet = packets[packet_name.to_s.upcase]
|
254
|
+
raise "Telemetry packet '#{target_name.to_s.upcase} #{packet_name.to_s.upcase}' does not exist" unless packet
|
255
|
+
|
256
|
+
return packet
|
257
|
+
end
|
258
|
+
|
259
|
+
def includes_item?(ignored_items, target_name, packet_name, item_name)
|
260
|
+
ignored_items.each do |array_target_name, array_packet_name, array_item_name|
|
261
|
+
if (array_target_name == target_name) &&
|
262
|
+
(array_packet_name == packet_name) &&
|
263
|
+
# If the item name is nil we're ignoring an entire packet
|
264
|
+
(array_item_name == item_name || array_item_name.nil?)
|
265
|
+
return true
|
266
|
+
end
|
267
|
+
end
|
268
|
+
return false
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
|
3
|
+
# Copyright 2022 Ball Aerospace & Technologies Corp.
|
4
|
+
# All Rights Reserved.
|
5
|
+
#
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
7
|
+
# under the terms of the GNU Affero General Public License
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Affero General Public License for more details.
|
15
|
+
|
16
|
+
# Modified by OpenC3, Inc.
|
17
|
+
# All changes Copyright 2022, OpenC3, Inc.
|
18
|
+
# All Rights Reserved
|
19
|
+
|
20
|
+
# This file implements a class to handle responses to limits state changes.
|
21
|
+
|
22
|
+
require 'openc3/api/api'
|
23
|
+
|
24
|
+
module OpenC3
|
25
|
+
# This class defines a #call method which is called when a PacketItem
|
26
|
+
# goes out of limits. This class must be subclassed and the call method
|
27
|
+
# implemented. Do NOT use this class directly.
|
28
|
+
class LimitsResponse
|
29
|
+
include Api
|
30
|
+
|
31
|
+
# @param packet [Packet] Packet the limits response is assigned to
|
32
|
+
# @param item [PacketItem] PacketItem the limits response is assigned to
|
33
|
+
# @param old_limits_state [Symbol] Previous value of the limit. One of nil,
|
34
|
+
# :GREEN_HIGH, :GREEN_LOW, :YELLOW, :YELLOW_HIGH, :YELLOW_LOW,
|
35
|
+
# :RED, :RED_HIGH, :RED_LOW. nil if the previous limit state has not yet
|
36
|
+
# been established.
|
37
|
+
def call(packet, item, old_limits_state)
|
38
|
+
raise "call method must be defined by subclass"
|
39
|
+
end
|
40
|
+
|
41
|
+
def to_s
|
42
|
+
self.class.to_s.split('::')[-1]
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_config
|
46
|
+
" LIMITS_RESPONSE #{self.class.name.class_name_to_filename}\n"
|
47
|
+
end
|
48
|
+
|
49
|
+
def as_json(*a)
|
50
|
+
{ "class" => self.class.name.to_s }
|
51
|
+
end
|
52
|
+
end # class LimitsResponse
|
53
|
+
end
|