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,76 @@
|
|
|
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/topics/topic'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
class CommandDecomTopic < Topic
|
|
24
|
+
def self.topics(scope:)
|
|
25
|
+
super(scope, 'DECOMCMD')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.write_packet(packet, scope:)
|
|
29
|
+
topic = "#{scope}__DECOMCMD__{#{packet.target_name}}__#{packet.packet_name}"
|
|
30
|
+
msg_hash = { time: packet.received_time.to_nsec_from_epoch,
|
|
31
|
+
target_name: packet.target_name,
|
|
32
|
+
packet_name: packet.packet_name,
|
|
33
|
+
stored: packet.stored,
|
|
34
|
+
received_count: packet.received_count }
|
|
35
|
+
json_hash = {}
|
|
36
|
+
packet.sorted_items.each do |item|
|
|
37
|
+
json_hash[item.name] = packet.read_item(item, :RAW)
|
|
38
|
+
json_hash[item.name + "__C"] = packet.read_item(item, :CONVERTED) if item.write_conversion or item.states
|
|
39
|
+
json_hash[item.name + "__F"] = packet.read_item(item, :FORMATTED) if item.format_string
|
|
40
|
+
json_hash[item.name + "__U"] = packet.read_item(item, :WITH_UNITS) if item.units
|
|
41
|
+
end
|
|
42
|
+
msg_hash['json_data'] = JSON.generate(json_hash.as_json(:allow_nan => true))
|
|
43
|
+
Topic.write_topic(topic, msg_hash)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.get_cmd_item(target_name, packet_name, param_name, type: :WITH_UNITS, scope: $openc3_scope)
|
|
47
|
+
msg_id, msg_hash = Topic.get_newest_message("#{scope}__DECOMCMD__{#{target_name}}__#{packet_name}")
|
|
48
|
+
if msg_id
|
|
49
|
+
# TODO: We now have these reserved items directly on command packets
|
|
50
|
+
# Do we still calculate from msg_hash['time'] or use the times directly?
|
|
51
|
+
#
|
|
52
|
+
# if param_name == 'RECEIVED_TIMESECONDS' || param_name == 'PACKET_TIMESECONDS'
|
|
53
|
+
# Time.from_nsec_from_epoch(msg_hash['time'].to_i).to_f
|
|
54
|
+
# elsif param_name == 'RECEIVED_TIMEFORMATTED' || param_name == 'PACKET_TIMEFORMATTED'
|
|
55
|
+
# Time.from_nsec_from_epoch(msg_hash['time'].to_i).formatted
|
|
56
|
+
if param_name == 'RECEIVED_COUNT'
|
|
57
|
+
msg_hash['received_count'].to_i
|
|
58
|
+
else
|
|
59
|
+
json = msg_hash['json_data']
|
|
60
|
+
hash = JSON.parse(json, :allow_nan => true, :create_additions => true)
|
|
61
|
+
# Start from the most complex down to the basic raw value
|
|
62
|
+
value = hash["#{param_name}__U"]
|
|
63
|
+
return value if value && type == :WITH_UNITS
|
|
64
|
+
|
|
65
|
+
value = hash["#{param_name}__F"]
|
|
66
|
+
return value if value && (type == :WITH_UNITS || type == :FORMATTED)
|
|
67
|
+
|
|
68
|
+
value = hash["#{param_name}__C"]
|
|
69
|
+
return value if value && (type == :WITH_UNITS || type == :FORMATTED || type == :CONVERTED)
|
|
70
|
+
|
|
71
|
+
return hash[param_name]
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
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/topics/topic'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
class CommandTopic < Topic
|
|
24
|
+
COMMAND_ACK_TIMEOUT_S = 5
|
|
25
|
+
|
|
26
|
+
def self.write_packet(packet, scope:)
|
|
27
|
+
topic = "#{scope}__COMMAND__{#{packet.target_name}}__#{packet.packet_name}"
|
|
28
|
+
msg_hash = { time: packet.received_time.to_nsec_from_epoch,
|
|
29
|
+
target_name: packet.target_name,
|
|
30
|
+
packet_name: packet.packet_name,
|
|
31
|
+
received_count: packet.received_count,
|
|
32
|
+
stored: packet.stored,
|
|
33
|
+
buffer: packet.buffer(false) }
|
|
34
|
+
Topic.write_topic(topic, msg_hash)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# @param command [Hash] Command hash structure read to be written to a topic
|
|
38
|
+
def self.send_command(command, scope:)
|
|
39
|
+
ack_topic = "{#{scope}__ACKCMD}TARGET__#{command['target_name']}"
|
|
40
|
+
Topic.update_topic_offsets([ack_topic])
|
|
41
|
+
# Save the existing cmd_params Hash and JSON generate before writing to the topic
|
|
42
|
+
cmd_params = command['cmd_params']
|
|
43
|
+
command['cmd_params'] = JSON.generate(command['cmd_params'].as_json(:allow_nan => true))
|
|
44
|
+
cmd_id = Topic.write_topic("{#{scope}__CMD}TARGET__#{command['target_name']}", command, '*', 100)
|
|
45
|
+
# TODO: This timeout is fine for most but can we get the write_timeout from the interface here?
|
|
46
|
+
time = Time.now
|
|
47
|
+
while (Time.now - time) < COMMAND_ACK_TIMEOUT_S
|
|
48
|
+
Topic.read_topics([ack_topic]) do |topic, msg_id, msg_hash, redis|
|
|
49
|
+
if msg_hash["id"] == cmd_id
|
|
50
|
+
if msg_hash["result"] == "SUCCESS"
|
|
51
|
+
return [command['target_name'], command['cmd_name'], cmd_params]
|
|
52
|
+
# Check for HazardousError which is a special case
|
|
53
|
+
elsif msg_hash["result"].include?("HazardousError")
|
|
54
|
+
raise_hazardous_error(msg_hash, command['target_name'], command['cmd_name'], cmd_params)
|
|
55
|
+
else
|
|
56
|
+
raise msg_hash["result"]
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
raise "Timeout waiting for cmd ack"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
###########################################################################
|
|
65
|
+
# PRIVATE implementation details
|
|
66
|
+
###########################################################################
|
|
67
|
+
|
|
68
|
+
def self.raise_hazardous_error(msg_hash, target_name, cmd_name, cmd_params)
|
|
69
|
+
_, description, formatted = msg_hash["result"].split("\n")
|
|
70
|
+
# Create and populate a new HazardousError and raise it up
|
|
71
|
+
# The _cmd method in script/commands.rb rescues this and calls prompt_for_hazardous
|
|
72
|
+
error = HazardousError.new
|
|
73
|
+
error.target_name = target_name
|
|
74
|
+
error.cmd_name = cmd_name
|
|
75
|
+
error.cmd_params = cmd_params
|
|
76
|
+
error.hazardous_description = description
|
|
77
|
+
error.formatted = formatted
|
|
78
|
+
|
|
79
|
+
# No Logger.info because the error is already logged by the Logger.info "Ack Received ...
|
|
80
|
+
raise error
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
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/topics/topic'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
class ConfigTopic < Topic
|
|
24
|
+
PRIMARY_KEY = "__CONFIG"
|
|
25
|
+
|
|
26
|
+
# Helper method to initialize the stream and ensure a consistent key
|
|
27
|
+
def self.initialize_stream(scope)
|
|
28
|
+
self.initialize_streams(["#{scope}#{PRIMARY_KEY}"])
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Write a configuration change to the topic
|
|
32
|
+
# @param config [Hash] Hash with required keys 'kind', 'name', 'type'
|
|
33
|
+
def self.write(config, scope:)
|
|
34
|
+
unless config.keys.include?(:kind)
|
|
35
|
+
raise "ConfigTopic error, required key kind: not given"
|
|
36
|
+
end
|
|
37
|
+
unless ['created', 'deleted'].include?(config[:kind])
|
|
38
|
+
raise "ConfigTopic error unknown kind: #{config[:kind]}"
|
|
39
|
+
end
|
|
40
|
+
unless config.keys.include?(:name)
|
|
41
|
+
raise "ConfigTopic error, required key name: not given"
|
|
42
|
+
end
|
|
43
|
+
unless config.keys.include?(:type)
|
|
44
|
+
raise "ConfigTopic error, required key type: not given"
|
|
45
|
+
end
|
|
46
|
+
# Limit the configuration topics to 1000 entries
|
|
47
|
+
Topic.write_topic("#{scope}#{PRIMARY_KEY}", config, '*', 1000)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def self.read(offset = nil, count: 100, scope:)
|
|
51
|
+
topic = "#{scope}#{PRIMARY_KEY}"
|
|
52
|
+
if offset
|
|
53
|
+
result = Topic.read_topics([topic], [offset], nil, count)
|
|
54
|
+
if result.empty?
|
|
55
|
+
[] # We want to return an empty array rather than an empty hash
|
|
56
|
+
else
|
|
57
|
+
# result is a hash with the topic key followed by an array of results
|
|
58
|
+
# This returns just the array of arrays [[offset, hash], [offset, hash], ...]
|
|
59
|
+
result[topic]
|
|
60
|
+
end
|
|
61
|
+
else
|
|
62
|
+
result = Topic.get_newest_message(topic)
|
|
63
|
+
return [result] if result
|
|
64
|
+
return []
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
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/topics/topic'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
class InterfaceTopic < Topic
|
|
24
|
+
# Generate a list of topics for this interface. This includes the interface itself
|
|
25
|
+
# and all the targets which are assigned to this interface.
|
|
26
|
+
def self.topics(interface, scope:)
|
|
27
|
+
topics = []
|
|
28
|
+
topics << "{#{scope}__CMD}INTERFACE__#{interface.name}"
|
|
29
|
+
interface.target_names.each do |target_name|
|
|
30
|
+
topics << "{#{scope}__CMD}TARGET__#{target_name}"
|
|
31
|
+
end
|
|
32
|
+
topics
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.receive_commands(interface, scope:)
|
|
36
|
+
while true
|
|
37
|
+
Topic.read_topics(InterfaceTopic.topics(interface, scope: scope)) do |topic, msg_id, msg_hash, redis|
|
|
38
|
+
result = yield topic, msg_hash
|
|
39
|
+
ack_topic = topic.split("__")
|
|
40
|
+
ack_topic[1] = 'ACK' + ack_topic[1]
|
|
41
|
+
ack_topic = ack_topic.join("__")
|
|
42
|
+
Topic.write_topic(ack_topic, { 'result' => result, 'id' => msg_id }, '*', 100)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def self.write_raw(interface_name, data, scope:)
|
|
48
|
+
Topic.write_topic("{#{scope}__CMD}INTERFACE__#{interface_name}", { 'raw' => data }, '*', 100)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def self.connect_interface(interface_name, scope:)
|
|
52
|
+
Topic.write_topic("{#{scope}__CMD}INTERFACE__#{interface_name}", { 'connect' => 'true' }, '*', 100)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def self.disconnect_interface(interface_name, scope:)
|
|
56
|
+
Topic.write_topic("{#{scope}__CMD}INTERFACE__#{interface_name}", { 'disconnect' => 'true' }, '*', 100)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def self.start_raw_logging(interface_name, scope:)
|
|
60
|
+
Topic.write_topic("{#{scope}__CMD}INTERFACE__#{interface_name}", { 'log_raw' => 'true' }, '*', 100)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def self.stop_raw_logging(interface_name, scope:)
|
|
64
|
+
Topic.write_topic("{#{scope}__CMD}INTERFACE__#{interface_name}", { 'log_raw' => 'false' }, '*', 100)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def self.shutdown(interface, scope:)
|
|
68
|
+
Topic.write_topic("{#{scope}__CMD}INTERFACE__#{interface.name}", { 'shutdown' => 'true' }, '*', 100)
|
|
69
|
+
sleep 1 # Give some time for the interface to shutdown
|
|
70
|
+
InterfaceTopic.clear_topics(InterfaceTopic.topics(interface, scope: scope))
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,109 @@
|
|
|
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/topics/topic'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
# LimitsEventTopic keeps track of not only the <SCOPE>__openc3_limits_events topic
|
|
24
|
+
# but also the ancillary key value stores. The LIMITS_CHANGE event updates the
|
|
25
|
+
# <SCOPE>__current_limits key. The LIMITS_SET event updates the <SCOPE>__limits_sets.
|
|
26
|
+
# While this isn't a clean separation of topics (streams) and models (key-value)
|
|
27
|
+
# it helps maintain consistency as the topic and model are linked.
|
|
28
|
+
class LimitsEventTopic < Topic
|
|
29
|
+
def self.write(event, scope:)
|
|
30
|
+
case event[:type]
|
|
31
|
+
when :LIMITS_CHANGE
|
|
32
|
+
# The current_limits hash keeps only the current limits state of items
|
|
33
|
+
# It is used by the API to determine the overall limits state
|
|
34
|
+
field = "#{event[:target_name]}__#{event[:packet_name]}__#{event[:item_name]}"
|
|
35
|
+
Store.hset("#{scope}__current_limits", field, event[:new_limits_state])
|
|
36
|
+
|
|
37
|
+
when :LIMITS_SETTINGS
|
|
38
|
+
# Limits updated in limits_api.rb to avoid circular reference to TargetModel
|
|
39
|
+
unless sets(scope: scope).has_key?(event[:limits_set])
|
|
40
|
+
Store.hset("#{scope}__limits_sets", event[:limits_set], 'false')
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
when :LIMITS_SET
|
|
44
|
+
sets = sets(scope: scope)
|
|
45
|
+
raise "Set '#{event[:set]}' does not exist!" unless sets.key?(event[:set])
|
|
46
|
+
|
|
47
|
+
# Set all existing sets to "false"
|
|
48
|
+
sets = sets.transform_values! { |_key, _value| "false" }
|
|
49
|
+
sets[event[:set]] = "true" # Enable the requested set
|
|
50
|
+
Store.hmset("#{scope}__limits_sets", *sets)
|
|
51
|
+
else
|
|
52
|
+
raise "Invalid limits event type '#{event[:type]}'"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
Topic.write_topic("#{scope}__openc3_limits_events", event, '*', 1000)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def self.read(offset = nil, count: 100, scope:)
|
|
59
|
+
topic = "#{scope}__openc3_limits_events"
|
|
60
|
+
if offset
|
|
61
|
+
result = Topic.read_topics([topic], [offset], nil, count)
|
|
62
|
+
if result.empty?
|
|
63
|
+
[] # We want to return an empty array rather than an empty hash
|
|
64
|
+
else
|
|
65
|
+
# result is a hash with the topic key followed by an array of results
|
|
66
|
+
# This returns just the array of arrays [[offset, hash], [offset, hash], ...]
|
|
67
|
+
result[topic]
|
|
68
|
+
end
|
|
69
|
+
else
|
|
70
|
+
result = Topic.get_newest_message(topic)
|
|
71
|
+
return [result] if result
|
|
72
|
+
return []
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def self.out_of_limits(scope:)
|
|
77
|
+
out_of_limits = []
|
|
78
|
+
limits = Store.hgetall("#{scope}__current_limits")
|
|
79
|
+
limits.each do |item, limits_state|
|
|
80
|
+
if %w(RED RED_HIGH RED_LOW YELLOW YELLOW_HIGH YELLOW_LOW).include?(limits_state)
|
|
81
|
+
target_name, packet_name, item_name = item.split('__')
|
|
82
|
+
out_of_limits << [target_name, packet_name, item_name, limits_state]
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
out_of_limits
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Returns all the limits sets as keys with the value 'true' or 'false'
|
|
89
|
+
# where only the active set is 'true'
|
|
90
|
+
#
|
|
91
|
+
# @return [Hash{String => String}] Set name followed by 'true' if enabled else 'false'
|
|
92
|
+
def self.sets(scope:)
|
|
93
|
+
Store.hgetall("#{scope}__limits_sets")
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def self.current_set(scope:)
|
|
97
|
+
sets(scope: scope).key('true') || "DEFAULT"
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def self.delete(target_name, packet_name, scope:)
|
|
101
|
+
limits = Store.hgetall("#{scope}__current_limits")
|
|
102
|
+
limits.each do |item, _limits_state|
|
|
103
|
+
if item =~ /^#{target_name}__#{packet_name}__/
|
|
104
|
+
Store.hdel("#{scope}__current_limits", item)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
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/topics/topic'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
class NotificationsTopic < Topic
|
|
24
|
+
def self.write_notification(notification, scope:)
|
|
25
|
+
Topic.write_topic("#{scope}__openc3_notifications", notification)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
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/topics/topic'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
class RouterTopic < Topic
|
|
24
|
+
# Generate a list of topics for this router. This includes the router itself
|
|
25
|
+
# and all the targets which are assigned to this router.
|
|
26
|
+
def self.topics(router, scope:)
|
|
27
|
+
topics = []
|
|
28
|
+
topics << "{#{scope}__CMD}ROUTER__#{router.name}"
|
|
29
|
+
router.target_names.each do |target_name|
|
|
30
|
+
System.telemetry.packets(target_name).each do |packet_name, packet|
|
|
31
|
+
topics << "#{scope}__TELEMETRY__{#{packet.target_name}}__#{packet.packet_name}"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
topics
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.receive_telemetry(router, scope:)
|
|
38
|
+
while true
|
|
39
|
+
Topic.read_topics(RouterTopic.topics(router, scope: scope)) do |topic, msg_id, msg_hash, redis|
|
|
40
|
+
result = yield topic, msg_hash
|
|
41
|
+
if /CMD}ROUTER/.match?(topic)
|
|
42
|
+
ack_topic = topic.split("__")
|
|
43
|
+
ack_topic[1] = 'ACK' + ack_topic[1]
|
|
44
|
+
ack_topic = ack_topic.join("__")
|
|
45
|
+
Topic.write_topic(ack_topic, { 'result' => result }, msg_id, 100)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def self.route_command(packet, target_names, scope:)
|
|
52
|
+
if packet.identified?
|
|
53
|
+
topic = "{#{scope}__CMD}TARGET__#{packet.target_name}"
|
|
54
|
+
Topic.write_topic(topic, { 'target_name' => packet.target_name, 'cmd_name' => packet.packet_name, 'cmd_buffer' => packet.buffer(false) }, '*', 100)
|
|
55
|
+
elsif target_names.length == 1
|
|
56
|
+
topic = "{#{scope}__CMD}TARGET__#{target_names[0]}"
|
|
57
|
+
Topic.write_topic(topic, { 'target_name' => packet.target_name, 'cmd_name' => 'UNKNOWN', 'cmd_buffer' => packet.buffer(false) }, '*', 100)
|
|
58
|
+
else
|
|
59
|
+
raise "No route for command: #{packet.target_name} #{packet.packet_name}"
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def self.connect_router(router_name, scope:)
|
|
64
|
+
Topic.write_topic("{#{scope}__CMD}ROUTER__#{router_name}", { 'connect' => true }, '*', 100)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def self.disconnect_router(router_name, scope:)
|
|
68
|
+
Topic.write_topic("{#{scope}__CMD}ROUTER__#{router_name}", { 'disconnect' => true }, '*', 100)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def self.start_raw_logging(router_name, scope:)
|
|
72
|
+
Topic.write_topic("{#{scope}__CMD}ROUTER__#{router_name}", { 'log_raw' => 'true' }, '*', 100)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def self.stop_raw_logging(router_name, scope:)
|
|
76
|
+
Topic.write_topic("{#{scope}__CMD}ROUTER__#{router_name}", { 'log_raw' => 'false' }, '*', 100)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def self.shutdown(router, scope:)
|
|
80
|
+
Topic.write_topic("{#{scope}__CMD}ROUTER__#{router.name}", { 'shutdown' => 'true' }, '*', 100)
|
|
81
|
+
sleep 1 # Give some time for the interface to shutdown
|
|
82
|
+
RouterTopic.clear_topics(RouterTopic.topics(router, scope: scope))
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
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/topics/topic'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
class TelemetryDecomTopic < Topic
|
|
24
|
+
def self.topics(scope:)
|
|
25
|
+
super(scope, 'DECOM')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.write_packet(packet, id: nil, scope:)
|
|
29
|
+
# Need to build a JSON hash of the decommutated data
|
|
30
|
+
# Support "downward typing"
|
|
31
|
+
# everything base name is RAW (including DERIVED)
|
|
32
|
+
# Request for WITH_UNITS, etc will look down until it finds something
|
|
33
|
+
# If nothing - item does not exist - nil
|
|
34
|
+
# __ as seperators ITEM1, ITEM1__C, ITEM1__F, ITEM1__U
|
|
35
|
+
|
|
36
|
+
json_hash = CvtModel.build_json_from_packet(packet)
|
|
37
|
+
# Write to stream
|
|
38
|
+
msg_hash = {
|
|
39
|
+
:time => packet.packet_time.to_nsec_from_epoch,
|
|
40
|
+
:stored => packet.stored,
|
|
41
|
+
:target_name => packet.target_name,
|
|
42
|
+
:packet_name => packet.packet_name,
|
|
43
|
+
:received_count => packet.received_count,
|
|
44
|
+
:json_data => JSON.generate(json_hash.as_json(:allow_nan => true)),
|
|
45
|
+
}
|
|
46
|
+
Topic.write_topic("#{scope}__DECOM__{#{packet.target_name}}__#{packet.packet_name}", msg_hash, id)
|
|
47
|
+
|
|
48
|
+
unless packet.stored
|
|
49
|
+
# Also update the current value table with the latest decommutated data
|
|
50
|
+
CvtModel.set(json_hash, target_name: packet.target_name, packet_name: packet.packet_name, scope: scope)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
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/topics/topic'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
class TelemetryTopic < Topic
|
|
24
|
+
def self.write_packet(packet, scope:)
|
|
25
|
+
msg_hash = {
|
|
26
|
+
:time => packet.received_time.to_nsec_from_epoch,
|
|
27
|
+
:stored => packet.stored,
|
|
28
|
+
:target_name => packet.target_name,
|
|
29
|
+
:packet_name => packet.packet_name,
|
|
30
|
+
:received_count => packet.received_count,
|
|
31
|
+
:buffer => packet.buffer(false),
|
|
32
|
+
}
|
|
33
|
+
Topic.write_topic("#{scope}__TELEMETRY__{#{packet.target_name}}__#{packet.packet_name}", msg_hash)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
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/topics/topic'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
class TimelineTopic < Topic
|
|
24
|
+
PRIMARY_KEY = "__openc3_timelines"
|
|
25
|
+
|
|
26
|
+
# Write an activity to the topic
|
|
27
|
+
#
|
|
28
|
+
# ```json
|
|
29
|
+
# "timeline" => "foobar",
|
|
30
|
+
# "kind" => "created",
|
|
31
|
+
# "type" => "activity",
|
|
32
|
+
# "data" => {
|
|
33
|
+
# "name" => "foobar",
|
|
34
|
+
# "start" => 1621875570,
|
|
35
|
+
# "stop" => 1621875585,
|
|
36
|
+
# "kind" => "cmd",
|
|
37
|
+
# "data" => {"cmd"=>"INST ABORT"}
|
|
38
|
+
# "events" => [{"event"=>"created"}]
|
|
39
|
+
# }
|
|
40
|
+
# ```
|
|
41
|
+
def self.write_activity(activity, scope:)
|
|
42
|
+
Topic.write_topic("#{scope}#{PRIMARY_KEY}", activity, '*', 1000)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|