openc3 5.0.6
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 +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,162 @@
|
|
|
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/limits_response'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
# Maintains knowledge of limits for a PacketItem
|
|
24
|
+
class PacketItemLimits
|
|
25
|
+
# Array of all limit states
|
|
26
|
+
LIMITS_STATES = [:RED, :RED_HIGH, :RED_LOW, :YELLOW, :YELLOW_HIGH, :YELLOW_LOW, :GREEN, :GREEN_HIGH, :GREEN_LOW, :BLUE, :STALE, nil]
|
|
27
|
+
# Array of all limit states which should be considered in error
|
|
28
|
+
OUT_OF_LIMITS_STATES = [:RED, :RED_HIGH, :RED_LOW, :YELLOW, :YELLOW_HIGH, :YELLOW_LOW]
|
|
29
|
+
|
|
30
|
+
# Hash of arrays - Hash key is uppercase symbol designating limits set.
|
|
31
|
+
# :DEFAULT limits set is required if item has limits. nil indicates the
|
|
32
|
+
# item does not have limits. For defined limits, each array in the hash
|
|
33
|
+
# contains [:RED_LOW, :YELLOW_LOW, :YELLOW_HIGH, :RED_HIGH,
|
|
34
|
+
# :GREEN_LOW (optional), GREEN_HIGH (optional)].
|
|
35
|
+
# @return [Hash{Symbol=>Array}] Hash of all the limits defined for this
|
|
36
|
+
# item. Must include a hash key of :DEFAULT which returns the default
|
|
37
|
+
# limits.
|
|
38
|
+
attr_reader :values
|
|
39
|
+
|
|
40
|
+
# Every item effectively always has "limits" enabled because it can go from
|
|
41
|
+
# :STALE to nil as needed. This flag indicates whether an item with defined
|
|
42
|
+
# limit values can transition from nil to the various other states.
|
|
43
|
+
#
|
|
44
|
+
# @return [Boolean] Whether limits are enabled on this item
|
|
45
|
+
attr_accessor :enabled
|
|
46
|
+
|
|
47
|
+
# Current limits state of the item. One of nil, :STALE, :BLUE, :GREEN,
|
|
48
|
+
# :GREEN_HIGH, :GREEN_LOW, :YELLOW, :YELLOW_HIGH, :YELLOW_LOW,
|
|
49
|
+
# :RED, :RED_HIGH, :RED_LOW. Items initialize to :STALE and change states
|
|
50
|
+
# as the item value changes. If the limits are disabled the state changes
|
|
51
|
+
# to nil. If a packet becomes stale the items state changes to :STALE.
|
|
52
|
+
# @return [Symbol, nil] Current limits state of the item
|
|
53
|
+
attr_reader :state
|
|
54
|
+
|
|
55
|
+
# @return [LimitsResponse] Response method to be called on limits changes
|
|
56
|
+
attr_reader :response
|
|
57
|
+
|
|
58
|
+
# @return [Integer] Number of out of limits samples at which the limits
|
|
59
|
+
# state will change
|
|
60
|
+
attr_reader :persistence_setting
|
|
61
|
+
|
|
62
|
+
# Current persistent count. The count will be reset to zero if the limits
|
|
63
|
+
# state hasn't changed (i.e. remained :GREEN).
|
|
64
|
+
# @return [Integer] Current running persistence count
|
|
65
|
+
attr_reader :persistence_count
|
|
66
|
+
|
|
67
|
+
# Create a PacketItemLimits
|
|
68
|
+
def initialize
|
|
69
|
+
@values = nil
|
|
70
|
+
@enabled = false
|
|
71
|
+
@state = :STALE
|
|
72
|
+
@response = nil
|
|
73
|
+
@persistence_setting = 1
|
|
74
|
+
@persistence_count = 0
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def values=(values)
|
|
78
|
+
if values
|
|
79
|
+
raise ArgumentError, "values must be a Hash but is a #{values.class}" unless Hash === values
|
|
80
|
+
raise ArgumentError, "values must be a Hash with a :DEFAULT key" unless values.keys.include?(:DEFAULT)
|
|
81
|
+
|
|
82
|
+
@values = values.clone
|
|
83
|
+
else
|
|
84
|
+
@values = nil
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def state=(state)
|
|
89
|
+
raise ArgumentError, "state must be one of #{LIMITS_STATES} but is #{state}" unless LIMITS_STATES.include?(state)
|
|
90
|
+
|
|
91
|
+
@state = state
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def response=(response)
|
|
95
|
+
if response
|
|
96
|
+
raise ArgumentError, "response must be a OpenC3::LimitsResponse but is a #{response.class}" unless OpenC3::LimitsResponse === response
|
|
97
|
+
|
|
98
|
+
@response = response.clone
|
|
99
|
+
else
|
|
100
|
+
@response = nil
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def persistence_setting=(persistence_setting)
|
|
105
|
+
if 0.class == Integer
|
|
106
|
+
# Ruby version >= 2.4.0
|
|
107
|
+
raise ArgumentError, "persistence_setting must be an Integer but is a #{persistence_setting.class}" unless Integer === persistence_setting
|
|
108
|
+
else
|
|
109
|
+
# Ruby version < 2.4.0
|
|
110
|
+
raise ArgumentError, "persistence_setting must be a Fixnum but is a #{persistence_setting.class}" unless Fixnum === persistence_setting
|
|
111
|
+
end
|
|
112
|
+
@persistence_setting = persistence_setting
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def persistence_count=(persistence_count)
|
|
116
|
+
if 0.class == Integer
|
|
117
|
+
# Ruby version >= 2.4.0
|
|
118
|
+
raise ArgumentError, "persistence_count must be an Integer but is a #{persistence_count.class}" unless Integer === persistence_count
|
|
119
|
+
else
|
|
120
|
+
# Ruby version < 2.4.0
|
|
121
|
+
raise ArgumentError, "persistence_count must be a Fixnum but is a #{persistence_count.class}" unless Fixnum === persistence_count
|
|
122
|
+
end
|
|
123
|
+
@persistence_count = persistence_count
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Make a light weight clone of this limits
|
|
127
|
+
def clone
|
|
128
|
+
limits = super()
|
|
129
|
+
limits.values = self.values.clone if self.values
|
|
130
|
+
limits.response = self.response.clone if self.response
|
|
131
|
+
limits
|
|
132
|
+
end
|
|
133
|
+
alias dup clone
|
|
134
|
+
|
|
135
|
+
def as_json(*a)
|
|
136
|
+
hash = {}
|
|
137
|
+
hash['values'] = self.values
|
|
138
|
+
hash['enabled'] = self.enabled
|
|
139
|
+
hash['state'] = self.state
|
|
140
|
+
if self.response
|
|
141
|
+
hash['response'] = self.response.to_s
|
|
142
|
+
else
|
|
143
|
+
hash['response'] = nil
|
|
144
|
+
end
|
|
145
|
+
hash['persistence_setting'] = self.persistence_setting
|
|
146
|
+
hash['persistence_count'] = self.persistence_count
|
|
147
|
+
hash
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def self.from_json(hash)
|
|
151
|
+
limits = PacketItemLimits.new
|
|
152
|
+
limits.values = hash['values'].transform_keys(&:to_sym) if hash['values']
|
|
153
|
+
limits.enabled = hash['enabled']
|
|
154
|
+
limits.state = hash['state'] ? hash['state'].to_sym : nil
|
|
155
|
+
# Can't recreate a LimitsResponse class
|
|
156
|
+
# limits.response = hash['response']
|
|
157
|
+
limits.persistence_setting = hash['persistence_setting'] if hash['persistence_setting']
|
|
158
|
+
limits.persistence_count = hash['persistence_count'] if hash['persistence_count']
|
|
159
|
+
limits
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
module OpenC3
|
|
21
|
+
class FormatStringParser
|
|
22
|
+
# @param parser [ConfigParser] Configuration parser
|
|
23
|
+
# @param item [Packet] The current item
|
|
24
|
+
def self.parse(parser, item)
|
|
25
|
+
@parser = FormatStringParser.new(parser)
|
|
26
|
+
@parser.verify_parameters()
|
|
27
|
+
@parser.create_format_string(item)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @param parser [ConfigParser] Configuration parser
|
|
31
|
+
def initialize(parser)
|
|
32
|
+
@parser = parser
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def verify_parameters
|
|
36
|
+
@usage = "FORMAT_STRING <PRINTF STYLE STRING>"
|
|
37
|
+
@parser.verify_num_parameters(1, 1, @usage)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @param item [PacketItem] The item the limits response should be added to
|
|
41
|
+
def create_format_string(item)
|
|
42
|
+
item.format_string = @parser.parameters[0]
|
|
43
|
+
# Only test the format string if there is not a read conversion because
|
|
44
|
+
# read conversion can return any type
|
|
45
|
+
test_format_string(item) unless item.read_conversion
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
def test_format_string(item)
|
|
51
|
+
case item.data_type
|
|
52
|
+
when :INT, :UINT
|
|
53
|
+
sprintf(item.format_string, 0)
|
|
54
|
+
when :FLOAT
|
|
55
|
+
sprintf(item.format_string, 0.0)
|
|
56
|
+
when :STRING, :BLOCK
|
|
57
|
+
sprintf(item.format_string, 'Hello')
|
|
58
|
+
else
|
|
59
|
+
# Nothing to do
|
|
60
|
+
end
|
|
61
|
+
rescue Exception
|
|
62
|
+
raise @parser.error("Invalid FORMAT_STRING specified for type #{item.data_type}: #{@parser.parameters[0]}", @usage)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,159 @@
|
|
|
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
|
+
module OpenC3
|
|
21
|
+
class LimitsParser
|
|
22
|
+
# @param parser [ConfigParser] Configuration parser
|
|
23
|
+
# @param packet [Packet] The current packet
|
|
24
|
+
# @param cmd_or_tlm [String] Whether this is a command or telemetry packet
|
|
25
|
+
# @param item [PacketItem] The packet item to create limits on
|
|
26
|
+
# @param warnings [Array<String>] Array of string warnings which will be
|
|
27
|
+
# appended with any warnings found when parsing the limits
|
|
28
|
+
def self.parse(parser, packet, cmd_or_tlm, item, warnings)
|
|
29
|
+
raise parser.error("Items with STATE can't define LIMITS") if item.states
|
|
30
|
+
|
|
31
|
+
@parser = LimitsParser.new(parser)
|
|
32
|
+
@parser.verify_parameters(cmd_or_tlm)
|
|
33
|
+
@parser.create_limits(packet, item, warnings)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def initialize(parser)
|
|
37
|
+
@parser = parser
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @param cmd_or_tlm [String] Whether this is a command or telemetry packet
|
|
41
|
+
def verify_parameters(cmd_or_tlm)
|
|
42
|
+
if cmd_or_tlm == PacketConfig::COMMAND
|
|
43
|
+
raise @parser.error("LIMITS only applies to telemetry items")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
@usage = "LIMITS <LIMITS SET> <PERSISTENCE> <ENABLED/DISABLED> <RED LOW LIMIT> <YELLOW LOW LIMIT> <YELLOW HIGH LIMIT> <RED HIGH LIMIT> <GREEN LOW LIMIT (Optional)> <GREEN HIGH LIMIT (Optional)>"
|
|
47
|
+
@parser.verify_num_parameters(7, 9, @usage)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# @param packet [Packet] The packet the item should be added to
|
|
51
|
+
def create_limits(packet, item, warnings)
|
|
52
|
+
limits_set = get_limits_set()
|
|
53
|
+
initialize_limits_values(packet, item)
|
|
54
|
+
ensure_consistency_with_default(packet, item, warnings)
|
|
55
|
+
|
|
56
|
+
item.limits.values[limits_set] = get_values()
|
|
57
|
+
item.limits.enabled = get_enabled()
|
|
58
|
+
item.limits.persistence_setting = get_persistence()
|
|
59
|
+
item.limits.persistence_count = 0
|
|
60
|
+
|
|
61
|
+
packet.update_limits_items_cache(item)
|
|
62
|
+
limits_set
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
private
|
|
66
|
+
|
|
67
|
+
def initialize_limits_values(packet, item)
|
|
68
|
+
limits_set = get_limits_set()
|
|
69
|
+
# Values must be initialized with a :DEFAULT key
|
|
70
|
+
if !item.limits.values
|
|
71
|
+
if limits_set == :DEFAULT
|
|
72
|
+
item.limits.values = { :DEFAULT => [] }
|
|
73
|
+
else
|
|
74
|
+
raise @parser.error("DEFAULT limits set must be defined for #{packet.target_name} #{packet.packet_name} #{item.name} before setting limits set #{limits_set}")
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def ensure_consistency_with_default(packet, item, warnings)
|
|
80
|
+
# Nothing to do if we're already :DEFAULT
|
|
81
|
+
return if get_limits_set() == :DEFAULT
|
|
82
|
+
|
|
83
|
+
msg = "TELEMETRY Item #{packet.target_name} #{packet.packet_name} #{item.name} #{get_limits_set()} limits _TYPE_ setting conflict with DEFAULT"
|
|
84
|
+
# XOR our setting with the items current setting
|
|
85
|
+
# If it returns true then we have a mismatch and log the error
|
|
86
|
+
if get_enabled() ^ item.limits.enabled
|
|
87
|
+
warnings << msg.sub('_TYPE_', 'enable')
|
|
88
|
+
Logger.instance.warn warnings[-1]
|
|
89
|
+
end
|
|
90
|
+
if item.limits.persistence_setting != get_persistence()
|
|
91
|
+
warnings << msg.sub('_TYPE_', 'persistence')
|
|
92
|
+
Logger.instance.warn warnings[-1]
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def get_limits_set
|
|
97
|
+
@parser.parameters[0].upcase.to_sym
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def get_persistence
|
|
101
|
+
Integer(@parser.parameters[1])
|
|
102
|
+
rescue
|
|
103
|
+
raise @parser.error("Persistence must be an integer.", @usage)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def get_enabled
|
|
107
|
+
enabled = @parser.parameters[2].upcase
|
|
108
|
+
if enabled != 'ENABLED' and enabled != 'DISABLED'
|
|
109
|
+
raise @parser.error("Initial LIMITS state must be ENABLED or DISABLED.", @usage)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
enabled == 'ENABLED' ? true : false
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def get_values
|
|
116
|
+
values = get_red_yellow_values()
|
|
117
|
+
values += get_green_values(values[1], values[2])
|
|
118
|
+
values
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def get_red_yellow_values
|
|
122
|
+
params = @parser.parameters
|
|
123
|
+
err = nil
|
|
124
|
+
red_low = Float(params[3]) rescue err = "red low"
|
|
125
|
+
yellow_low = Float(params[4]) rescue err = "yellow low"
|
|
126
|
+
yellow_high = Float(params[5]) rescue err = "yellow high"
|
|
127
|
+
red_high = Float(params[6]) rescue err = "red high"
|
|
128
|
+
raise @parser.error("Invalid #{err} limit value. Limits can be integers or floats.", @usage) if err
|
|
129
|
+
|
|
130
|
+
# Verify valid limits are specified
|
|
131
|
+
if (red_low > yellow_low) or (yellow_low >= yellow_high) or (yellow_high > red_high)
|
|
132
|
+
raise @parser.error("Invalid limits specified. Ensure yellow limits are within red limits.", @usage)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
[red_low, yellow_low, yellow_high, red_high]
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def get_green_values(yellow_low, yellow_high)
|
|
139
|
+
params = @parser.parameters
|
|
140
|
+
# Since our initial parameter check verifies between 7 and 9 we do a
|
|
141
|
+
# special check for 8 parameters which is an error
|
|
142
|
+
if params.length == 8
|
|
143
|
+
raise @parser.error("Must give both a green low and green high value.", @usage)
|
|
144
|
+
end
|
|
145
|
+
return [] unless params.length == 9
|
|
146
|
+
|
|
147
|
+
err = nil
|
|
148
|
+
green_low = Float(params[7]) rescue err = "green low"
|
|
149
|
+
green_high = Float(params[8]) rescue err = "green high"
|
|
150
|
+
raise @parser.error("Invalid #{err} limit value. Limits can be integers or floats.", @usage) if err
|
|
151
|
+
|
|
152
|
+
if (yellow_low > green_low) or (green_low >= green_high) or (green_high > yellow_high)
|
|
153
|
+
raise @parser.error("Invalid limits specified. Ensure green limits are within yellow limits.", @usage)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
[green_low, green_high]
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
module OpenC3
|
|
21
|
+
class LimitsResponseParser
|
|
22
|
+
# @param parser [ConfigParser] Configuration parser
|
|
23
|
+
# @param item [Packet] The current item
|
|
24
|
+
# @param cmd_or_tlm [String] Whether this is a command or telemetry packet
|
|
25
|
+
def self.parse(parser, item, cmd_or_tlm)
|
|
26
|
+
@parser = LimitsResponseParser.new(parser)
|
|
27
|
+
@parser.verify_parameters(cmd_or_tlm)
|
|
28
|
+
@parser.create_limits_response(item)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# @param parser [ConfigParser] Configuration parser
|
|
32
|
+
def initialize(parser)
|
|
33
|
+
@parser = parser
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# @param cmd_or_tlm [String] Whether this is a command or telemetry packet
|
|
37
|
+
def verify_parameters(cmd_or_tlm)
|
|
38
|
+
if cmd_or_tlm == PacketConfig::COMMAND
|
|
39
|
+
raise @parser.error("LIMITS_RESPONSE only applies to telemetry items")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
@usage = "LIMITS_RESPONSE <RESPONSE CLASS FILENAME> <RESPONSE SPECIFIC OPTIONS>"
|
|
43
|
+
@parser.verify_num_parameters(1, nil, @usage)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# @param item [PacketItem] The item the limits response should be added to
|
|
47
|
+
def create_limits_response(item)
|
|
48
|
+
# require should be performed in target.txt
|
|
49
|
+
klass = @parser.parameters[0].filename_to_class_name.to_class
|
|
50
|
+
raise @parser.error("#{@parser.parameters[0].filename_to_class_name} class not found. Did you require the file in target.txt?", @usage) unless klass
|
|
51
|
+
|
|
52
|
+
if @parser.parameters[1]
|
|
53
|
+
item.limits.response = klass.new(*@parser.parameters[1..(@parser.parameters.length - 1)])
|
|
54
|
+
else
|
|
55
|
+
item.limits.response = klass.new
|
|
56
|
+
end
|
|
57
|
+
rescue Exception => err
|
|
58
|
+
raise @parser.error(err, @usage)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|