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,455 @@
|
|
|
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/models/target_model'
|
|
21
|
+
require 'openc3/models/cvt_model'
|
|
22
|
+
require 'openc3/packets/packet'
|
|
23
|
+
require 'openc3/topics/telemetry_topic'
|
|
24
|
+
require 'openc3/utilities/s3'
|
|
25
|
+
|
|
26
|
+
module OpenC3
|
|
27
|
+
module Api
|
|
28
|
+
WHITELIST ||= []
|
|
29
|
+
WHITELIST.concat([
|
|
30
|
+
'tlm',
|
|
31
|
+
'tlm_raw',
|
|
32
|
+
'tlm_formatted',
|
|
33
|
+
'tlm_with_units',
|
|
34
|
+
'tlm_variable',
|
|
35
|
+
'set_tlm',
|
|
36
|
+
'inject_tlm',
|
|
37
|
+
'override_tlm',
|
|
38
|
+
'normalize_tlm',
|
|
39
|
+
'get_tlm_buffer',
|
|
40
|
+
'get_tlm_packet',
|
|
41
|
+
'get_tlm_values',
|
|
42
|
+
'get_all_telemetry',
|
|
43
|
+
'get_all_telemetry_names',
|
|
44
|
+
'get_telemetry',
|
|
45
|
+
'get_item',
|
|
46
|
+
'subscribe_packets',
|
|
47
|
+
'get_packets',
|
|
48
|
+
'get_tlm_cnt',
|
|
49
|
+
'get_tlm_cnts',
|
|
50
|
+
'get_packet_derived_items',
|
|
51
|
+
'get_oldest_logfile',
|
|
52
|
+
])
|
|
53
|
+
|
|
54
|
+
# Request a telemetry item from a packet.
|
|
55
|
+
#
|
|
56
|
+
# Accepts two different calling styles:
|
|
57
|
+
# tlm("TGT PKT ITEM")
|
|
58
|
+
# tlm('TGT','PKT','ITEM')
|
|
59
|
+
#
|
|
60
|
+
# Favor the first syntax where possible as it is more succinct.
|
|
61
|
+
#
|
|
62
|
+
# @param args [String|Array<String>] See the description for calling style
|
|
63
|
+
# @param type [Symbol] Telemetry type, :RAW, :CONVERTED (default), :FORMATTED, or :WITH_UNITS
|
|
64
|
+
# @return [Object] The telemetry value formatted as requested
|
|
65
|
+
def tlm(*args, type: :CONVERTED, scope: $openc3_scope, token: $openc3_token)
|
|
66
|
+
target_name, packet_name, item_name = tlm_process_args(args, 'tlm', scope: scope)
|
|
67
|
+
authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
|
|
68
|
+
CvtModel.get_item(target_name, packet_name, item_name, type: type.intern, scope: scope)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# @deprecated Use tlm with type: :RAW
|
|
72
|
+
def tlm_raw(*args, scope: $openc3_scope, token: $openc3_token)
|
|
73
|
+
tlm(*args, type: :RAW, scope: scope, token: token)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# @deprecated Use tlm with type: :FORMATTED
|
|
77
|
+
def tlm_formatted(*args, scope: $openc3_scope, token: $openc3_token)
|
|
78
|
+
tlm(*args, type: :FORMATTED, scope: scope, token: token)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# @deprecated Use tlm with type: :WITH_UNITS
|
|
82
|
+
def tlm_with_units(*args, scope: $openc3_scope, token: $openc3_token)
|
|
83
|
+
tlm(*args, type: :WITH_UNITS, scope: scope, token: token)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# @deprecated Use tlm with type:
|
|
87
|
+
def tlm_variable(*args, scope: $openc3_scope, token: $openc3_token)
|
|
88
|
+
tlm(*args[0..-2], type: args[-1].intern, scope: scope, token: token)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Set a telemetry item in the current value table.
|
|
92
|
+
#
|
|
93
|
+
# Note: If this is done while OpenC3 is currently receiving telemetry,
|
|
94
|
+
# this value could get overwritten at any time. Thus this capability is
|
|
95
|
+
# best used for testing or for telemetry items that are not received
|
|
96
|
+
# regularly through the target interface.
|
|
97
|
+
#
|
|
98
|
+
# Accepts two different calling styles:
|
|
99
|
+
# set_tlm("TGT PKT ITEM = 1.0")
|
|
100
|
+
# set_tlm('TGT','PKT','ITEM', 10.0)
|
|
101
|
+
#
|
|
102
|
+
# Favor the first syntax where possible as it is more succinct.
|
|
103
|
+
#
|
|
104
|
+
# @param args [String|Array<String>] See the description for calling style
|
|
105
|
+
# @param type [Symbol] Telemetry type, :RAW, :CONVERTED (default), :FORMATTED, or :WITH_UNITS
|
|
106
|
+
def set_tlm(*args, type: :CONVERTED, scope: $openc3_scope, token: $openc3_token)
|
|
107
|
+
target_name, packet_name, item_name, value = set_tlm_process_args(args, __method__, scope: scope)
|
|
108
|
+
authorize(permission: 'tlm_set', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
|
|
109
|
+
CvtModel.set_item(target_name, packet_name, item_name, value, type: type.intern, scope: scope)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Injects a packet into the system as if it was received from an interface
|
|
113
|
+
#
|
|
114
|
+
# @param target_name [String] Target name of the packet
|
|
115
|
+
# @param packet_name [String] Packet name of the packet
|
|
116
|
+
# @param item_hash [Hash] Hash of item_name and value for each item you want to change from the current value table
|
|
117
|
+
# @param type [Symbol] Telemetry type, :RAW, :CONVERTED (default), :FORMATTED, or :WITH_UNITS
|
|
118
|
+
def inject_tlm(target_name, packet_name, item_hash = nil, type: :CONVERTED, scope: $openc3_scope, token: $openc3_token)
|
|
119
|
+
authorize(permission: 'tlm_set', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
|
|
120
|
+
unless CvtModel::VALUE_TYPES.include?(type.intern)
|
|
121
|
+
raise "Unknown type '#{type}' for #{target_name} #{packet_name}"
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
if item_hash
|
|
125
|
+
# Check that the items exist ... exceptions are raised if not
|
|
126
|
+
TargetModel.packet_items(target_name, packet_name, item_hash.keys, scope: scope)
|
|
127
|
+
else
|
|
128
|
+
# Check that the packet exists ... exceptions are raised if not
|
|
129
|
+
TargetModel.packet(target_name, packet_name, scope: scope)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
packet_hash = get_telemetry(target_name, packet_name, scope: scope, token: token)
|
|
133
|
+
packet = Packet.from_json(packet_hash)
|
|
134
|
+
if item_hash
|
|
135
|
+
item_hash.each do |name, value|
|
|
136
|
+
packet.write(name.to_s, value, type)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
packet.received_time = Time.now.sys
|
|
140
|
+
# TODO: New packet so received_count is not correct
|
|
141
|
+
packet.received_count += 1
|
|
142
|
+
TelemetryTopic.write_packet(packet, scope: scope)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Override the current value table such that a particular item always
|
|
146
|
+
# returns the same value (for a given type) even when new telemetry
|
|
147
|
+
# packets are received from the target.
|
|
148
|
+
#
|
|
149
|
+
# Accepts two different calling styles:
|
|
150
|
+
# override_tlm("TGT PKT ITEM = 1.0")
|
|
151
|
+
# override_tlm('TGT','PKT','ITEM', 10.0)
|
|
152
|
+
#
|
|
153
|
+
# Favor the first syntax where possible as it is more succinct.
|
|
154
|
+
#
|
|
155
|
+
# @param args The args must either be a string followed by a value or
|
|
156
|
+
# three strings followed by a value (see the calling style in the
|
|
157
|
+
# description).
|
|
158
|
+
# @param type [Symbol] Telemetry type, :RAW, :CONVERTED (default), :FORMATTED, or :WITH_UNITS
|
|
159
|
+
def override_tlm(*args, type: :CONVERTED, scope: $openc3_scope, token: $openc3_token)
|
|
160
|
+
target_name, packet_name, item_name, value = set_tlm_process_args(args, __method__, scope: scope)
|
|
161
|
+
authorize(permission: 'tlm_set', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
|
|
162
|
+
CvtModel.override(target_name, packet_name, item_name, value, type: type.intern, scope: scope)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# Normalize a telemetry item in a packet to its default behavior. Called
|
|
166
|
+
# after override_tlm to restore standard processing.
|
|
167
|
+
#
|
|
168
|
+
# Accepts two different calling styles:
|
|
169
|
+
# normalize_tlm("TGT PKT ITEM")
|
|
170
|
+
# normalize_tlm('TGT','PKT','ITEM')
|
|
171
|
+
#
|
|
172
|
+
# Favor the first syntax where possible as it is more succinct.
|
|
173
|
+
#
|
|
174
|
+
# @param args The args must either be a string or three strings
|
|
175
|
+
# (see the calling style in the description).
|
|
176
|
+
# @param type [Symbol] Telemetry type, :RAW, :CONVERTED (default), :FORMATTED, or :WITH_UNITS
|
|
177
|
+
# Also takes :ALL which means to normalize all telemetry types
|
|
178
|
+
def normalize_tlm(*args, type: :ALL, scope: $openc3_scope, token: $openc3_token)
|
|
179
|
+
target_name, packet_name, item_name = tlm_process_args(args, __method__, scope: scope)
|
|
180
|
+
authorize(permission: 'tlm_set', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
|
|
181
|
+
CvtModel.normalize(target_name, packet_name, item_name, type: type.intern, scope: scope)
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# Returns the raw buffer for a telemetry packet.
|
|
185
|
+
#
|
|
186
|
+
# @param target_name [String] Name of the target
|
|
187
|
+
# @param packet_name [String] Name of the packet
|
|
188
|
+
# @return [Hash] telemetry hash with last telemetry buffer
|
|
189
|
+
def get_tlm_buffer(target_name, packet_name, scope: $openc3_scope, token: $openc3_token)
|
|
190
|
+
authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
|
|
191
|
+
TargetModel.packet(target_name, packet_name, scope: scope)
|
|
192
|
+
topic = "#{scope}__TELEMETRY__{#{target_name}}__#{packet_name}"
|
|
193
|
+
msg_id, msg_hash = Topic.get_newest_message(topic)
|
|
194
|
+
if msg_id
|
|
195
|
+
msg_hash['buffer'] = msg_hash['buffer'].b
|
|
196
|
+
return msg_hash
|
|
197
|
+
end
|
|
198
|
+
return nil
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# Returns all the values (along with their limits state) for a packet.
|
|
202
|
+
#
|
|
203
|
+
# @param target_name [String] Name of the target
|
|
204
|
+
# @param packet_name [String] Name of the packet
|
|
205
|
+
# @param type [Symbol] Types returned, :RAW, :CONVERTED (default), :FORMATTED, or :WITH_UNITS
|
|
206
|
+
# @return (see OpenC3::Packet#read_all_with_limits_states)
|
|
207
|
+
def get_tlm_packet(target_name, packet_name, type: :CONVERTED, scope: $openc3_scope, token: $openc3_token)
|
|
208
|
+
authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
|
|
209
|
+
packet = TargetModel.packet(target_name, packet_name, scope: scope)
|
|
210
|
+
t = _validate_tlm_type(type)
|
|
211
|
+
raise ArgumentError, "Unknown type '#{type}' for #{target_name} #{packet_name}" if t.nil?
|
|
212
|
+
items = packet['items'].map { | item | item['name'] }
|
|
213
|
+
cvt_items = items.map { | item | "#{target_name}__#{packet_name}__#{item}__#{type}" }
|
|
214
|
+
current_values = CvtModel.get_tlm_values(cvt_items, scope: scope)
|
|
215
|
+
items.zip(current_values).map { | item , values | [item, values[0], values[1]]}
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# Returns all the item values (along with their limits state). The items
|
|
219
|
+
# can be from any target and packet and thus must be fully qualified with
|
|
220
|
+
# their target and packet names.
|
|
221
|
+
#
|
|
222
|
+
# @since 5.0.0
|
|
223
|
+
# @param items [Array<String>] Array of items consisting of 'tgt__pkt__item__type'
|
|
224
|
+
# @return [Array<Object, Symbol>]
|
|
225
|
+
# Array consisting of the item value and limits state
|
|
226
|
+
# given as symbols such as :RED, :YELLOW, :STALE
|
|
227
|
+
def get_tlm_values(items, scope: $openc3_scope, token: $openc3_token)
|
|
228
|
+
if !items.is_a?(Array) || !items[0].is_a?(String)
|
|
229
|
+
raise ArgumentError, "items must be array of strings: ['TGT__PKT__ITEM__TYPE', ...]"
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
items.each_with_index do |item, index|
|
|
233
|
+
target_name, packet_name, item_name, item_type = item.split('__')
|
|
234
|
+
if packet_name == 'LATEST'
|
|
235
|
+
_, packet_name, _ = tlm_process_args([target_name, packet_name, item_name], 'get_tlm_values', scope: scope) # Figure out which packet is LATEST
|
|
236
|
+
items[index] = "#{target_name}__#{packet_name}__#{item_name}__#{item_type}" # Replace LATEST with the real packet name
|
|
237
|
+
end
|
|
238
|
+
authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
|
|
239
|
+
end
|
|
240
|
+
CvtModel.get_tlm_values(items, scope: scope)
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
# Returns an array of all the telemetry packet hashes
|
|
244
|
+
#
|
|
245
|
+
# @since 5.0.0
|
|
246
|
+
# @param target_name [String] Name of the target
|
|
247
|
+
# @return [Array<Hash>] Array of all telemetry packet hashes
|
|
248
|
+
def get_all_telemetry(target_name, scope: $openc3_scope, token: $openc3_token)
|
|
249
|
+
authorize(permission: 'tlm', target_name: target_name, scope: scope, token: token)
|
|
250
|
+
TargetModel.packets(target_name, type: :TLM, scope: scope)
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
# Returns an array of all the telemetry packet names
|
|
254
|
+
#
|
|
255
|
+
# @since 5.0.6
|
|
256
|
+
# @param target_name [String] Name of the target
|
|
257
|
+
# @return [Array<String>] Array of all telemetry packet names
|
|
258
|
+
def get_all_telemetry_names(target_name, scope: $openc3_scope, token: $openc3_token)
|
|
259
|
+
authorize(permission: 'cmd_info', target_name: target_name, scope: scope, token: token)
|
|
260
|
+
TargetModel.packet_names(target_name, type: :TLM, scope: scope)
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
# Returns a telemetry packet hash
|
|
264
|
+
#
|
|
265
|
+
# @since 5.0.0
|
|
266
|
+
# @param target_name [String] Name of the target
|
|
267
|
+
# @param packet_name [String] Name of the packet
|
|
268
|
+
# @return [Hash] Telemetry packet hash
|
|
269
|
+
def get_telemetry(target_name, packet_name, scope: $openc3_scope, token: $openc3_token)
|
|
270
|
+
authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
|
|
271
|
+
TargetModel.packet(target_name, packet_name, scope: scope)
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
# Returns a telemetry packet item hash
|
|
275
|
+
#
|
|
276
|
+
# @since 5.0.0
|
|
277
|
+
# @param target_name [String] Name of the target
|
|
278
|
+
# @param packet_name [String] Name of the packet
|
|
279
|
+
# @param item_name [String] Name of the packet
|
|
280
|
+
# @return [Hash] Telemetry packet item hash
|
|
281
|
+
def get_item(target_name, packet_name, item_name, scope: $openc3_scope, token: $openc3_token)
|
|
282
|
+
authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
|
|
283
|
+
TargetModel.packet_item(target_name, packet_name, item_name, scope: scope)
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
# 2x double underscore since __ is reserved
|
|
287
|
+
SUBSCRIPTION_DELIMITER = '____'
|
|
288
|
+
|
|
289
|
+
# Subscribe to a list of packets. An ID is returned which is passed to
|
|
290
|
+
# get_packets(id) to return packets.
|
|
291
|
+
#
|
|
292
|
+
# @param packets [Array<Array<String, String>>] Array of arrays consisting of target name, packet name
|
|
293
|
+
# @return [String] ID which should be passed to get_packets
|
|
294
|
+
def subscribe_packets(packets, scope: $openc3_scope, token: $openc3_token)
|
|
295
|
+
if !packets.is_a?(Array) || !packets[0].is_a?(Array)
|
|
296
|
+
raise ArgumentError, "packets must be nested array: [['TGT','PKT'],...]"
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
result = {}
|
|
300
|
+
packets.each do |target_name, packet_name|
|
|
301
|
+
authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
|
|
302
|
+
topic = "#{scope}__DECOM__{#{target_name}}__#{packet_name}"
|
|
303
|
+
id, _ = Topic.get_newest_message(topic)
|
|
304
|
+
result[topic] = id ? id : '0-0'
|
|
305
|
+
end
|
|
306
|
+
result.to_a.join(SUBSCRIPTION_DELIMITER)
|
|
307
|
+
end
|
|
308
|
+
# Alias the singular as well since that matches COSMOS 4
|
|
309
|
+
alias subscribe_packet subscribe_packets
|
|
310
|
+
|
|
311
|
+
# Get packets based on ID returned from subscribe_packet.
|
|
312
|
+
# @param id [String] ID returned from subscribe_packets or last call to get_packets
|
|
313
|
+
# @param block [Integer] Number of milliseconds to block when requesting packets
|
|
314
|
+
# @param count [Integer] Maximum number of packets to return from EACH packet stream
|
|
315
|
+
# @return [Array<String, Array<Hash>] Array of the ID and array of all packets found
|
|
316
|
+
def get_packets(id, block: nil, count: 1000, scope: $openc3_scope, token: $openc3_token)
|
|
317
|
+
authorize(permission: 'tlm', scope: scope, token: token)
|
|
318
|
+
# Split the list of topic, ID values and turn it into a hash for easy updates
|
|
319
|
+
lookup = Hash[*id.split(SUBSCRIPTION_DELIMITER)]
|
|
320
|
+
xread = Topic.read_topics(lookup.keys, lookup.values, block, count)
|
|
321
|
+
# Return the original ID and nil if we didn't get anything
|
|
322
|
+
return [id, nil] if xread.empty?
|
|
323
|
+
packets = []
|
|
324
|
+
xread.each do |topic, data|
|
|
325
|
+
data.each do |id, msg_hash|
|
|
326
|
+
lookup[topic] = id # save the new ID
|
|
327
|
+
json_hash = JSON.parse(msg_hash['json_data'], :allow_nan => true, :create_additions => true)
|
|
328
|
+
msg_hash.delete('json_data')
|
|
329
|
+
packets << msg_hash.merge(json_hash)
|
|
330
|
+
end
|
|
331
|
+
end
|
|
332
|
+
return [lookup.to_a.join(SUBSCRIPTION_DELIMITER), packets]
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
# Get the receive count for a telemetry packet
|
|
336
|
+
#
|
|
337
|
+
# @param target_name [String] Name of the target
|
|
338
|
+
# @param packet_name [String] Name of the packet
|
|
339
|
+
# @return [Numeric] Receive count for the telemetry packet
|
|
340
|
+
def get_tlm_cnt(target_name, packet_name, scope: $openc3_scope, token: $openc3_token)
|
|
341
|
+
authorize(permission: 'system', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
|
|
342
|
+
TargetModel.packet(target_name, packet_name, scope: scope)
|
|
343
|
+
Topic.get_cnt("#{scope}__TELEMETRY__{#{target_name}}__#{packet_name}")
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
# Get the transmit counts for telemetry packets
|
|
347
|
+
#
|
|
348
|
+
# @param target_packets [Array<Array<String, String>>] Array of arrays containing target_name, packet_name
|
|
349
|
+
# @return [Numeric] Transmit count for the command
|
|
350
|
+
def get_tlm_cnts(target_packets, scope: $openc3_scope, token: $openc3_token)
|
|
351
|
+
authorize(permission: 'system', scope: scope, token: token)
|
|
352
|
+
counts = []
|
|
353
|
+
target_packets.each do |target_name, packet_name|
|
|
354
|
+
counts << Topic.get_cnt("#{scope}__TELEMETRY__{#{target_name}}__#{packet_name}")
|
|
355
|
+
end
|
|
356
|
+
counts
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
# Get the list of derived telemetry items for a packet
|
|
360
|
+
#
|
|
361
|
+
# @param target_name [String] Target name
|
|
362
|
+
# @param packet_name [String] Packet name
|
|
363
|
+
# @return [Array<String>] All of the ignored telemetry items for a packet.
|
|
364
|
+
def get_packet_derived_items(target_name, packet_name, scope: $openc3_scope, token: $openc3_token)
|
|
365
|
+
authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
|
|
366
|
+
packet = TargetModel.packet(target_name, packet_name, scope: scope)
|
|
367
|
+
return packet['items'].select { |item| item['data_type'] == 'DERIVED' }.map { |item| item['name'] }
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
def get_oldest_logfile(scope: $openc3_scope, token: $openc3_token)
|
|
371
|
+
authorize(permission: 'tlm', scope: scope, token: token)
|
|
372
|
+
_, list = S3Utilities.get_total_size_and_oldest_list('logs', "#{scope}/decom_logs", 1_000_000_000)
|
|
373
|
+
# The list is a S3 structure containing the file paths
|
|
374
|
+
# Request the path by calling the key method. Returns something like this:
|
|
375
|
+
# DEFAULT/decom_logs/tlm/INST2/MECH/20220104/20220104165449021942700__20220104170449148642700__DEFAULT__INST2__MECH__rt__decom.bin
|
|
376
|
+
# Thus we split and take the start date/time part of the filename
|
|
377
|
+
if list and list[0]
|
|
378
|
+
start = list[0].key.split('/')[-1].split('__')[0]
|
|
379
|
+
# Format as YYYY-MM-DD HH:MM:SS for use by the frontend
|
|
380
|
+
# utc_time = Time.utc(start[0,4], start[4,2], start[6,2], start[8,2], start[10,2], start[12,2])
|
|
381
|
+
return "#{start[0,4]}-#{start[4,2]}-#{start[6,2]} #{start[8,2]}:#{start[10,2]}:#{start[12,2]}"
|
|
382
|
+
else
|
|
383
|
+
return Time.now.utc.to_s[0..18]
|
|
384
|
+
end
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
# PRIVATE
|
|
388
|
+
|
|
389
|
+
def _validate_tlm_type(type)
|
|
390
|
+
case type.intern
|
|
391
|
+
when :RAW
|
|
392
|
+
return ''
|
|
393
|
+
when :CONVERTED
|
|
394
|
+
return 'C'
|
|
395
|
+
when :FORMATTED
|
|
396
|
+
return 'F'
|
|
397
|
+
when :WITH_UNITS
|
|
398
|
+
return 'U'
|
|
399
|
+
end
|
|
400
|
+
return nil
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
def tlm_process_args(args, function_name, scope: $openc3_scope, token: $openc3_token)
|
|
404
|
+
case args.length
|
|
405
|
+
when 1
|
|
406
|
+
target_name, packet_name, item_name = extract_fields_from_tlm_text(args[0])
|
|
407
|
+
when 3
|
|
408
|
+
target_name = args[0]
|
|
409
|
+
packet_name = args[1]
|
|
410
|
+
item_name = args[2]
|
|
411
|
+
else
|
|
412
|
+
# Invalid number of arguments
|
|
413
|
+
raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
|
|
414
|
+
end
|
|
415
|
+
if packet_name == 'LATEST'
|
|
416
|
+
latest = -1
|
|
417
|
+
TargetModel.packets(target_name, scope: scope).each do |packet|
|
|
418
|
+
item = packet['items'].find { |item| item['name'] == item_name }
|
|
419
|
+
if item
|
|
420
|
+
_, msg_hash = Topic.get_oldest_message("#{scope}__DECOM__{#{target_name}}__#{packet['packet_name']}")
|
|
421
|
+
if msg_hash && msg_hash['time'] && msg_hash['time'].to_i > latest
|
|
422
|
+
packet_name = packet['packet_name']
|
|
423
|
+
latest = msg_hash['time'].to_i
|
|
424
|
+
end
|
|
425
|
+
end
|
|
426
|
+
end
|
|
427
|
+
raise "Item '#{target_name} LATEST #{item_name}' does not exist" if latest == -1
|
|
428
|
+
else
|
|
429
|
+
# Determine if this item exists, it will raise appropriate errors if not
|
|
430
|
+
TargetModel.packet_item(target_name, packet_name, item_name, scope: scope)
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
return [target_name, packet_name, item_name]
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
def set_tlm_process_args(args, function_name, scope: $openc3_scope, token: $openc3_token)
|
|
437
|
+
case args.length
|
|
438
|
+
when 1
|
|
439
|
+
target_name, packet_name, item_name, value = extract_fields_from_set_tlm_text(args[0])
|
|
440
|
+
when 4
|
|
441
|
+
target_name = args[0]
|
|
442
|
+
packet_name = args[1]
|
|
443
|
+
item_name = args[2]
|
|
444
|
+
value = args[3]
|
|
445
|
+
else
|
|
446
|
+
# Invalid number of arguments
|
|
447
|
+
raise "ERROR: Invalid number of arguments (#{args.length}) passed to #{function_name}()"
|
|
448
|
+
end
|
|
449
|
+
# Determine if this item exists, it will raise appropriate errors if not
|
|
450
|
+
TargetModel.packet_item(target_name, packet_name, item_name, scope: scope)
|
|
451
|
+
|
|
452
|
+
return [target_name, packet_name, item_name, value]
|
|
453
|
+
end
|
|
454
|
+
end
|
|
455
|
+
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'
|
|
21
|
+
require 'openc3/bridge/bridge_config'
|
|
22
|
+
require 'openc3/bridge/bridge_interface_thread'
|
|
23
|
+
require 'openc3/bridge/bridge_router_thread'
|
|
24
|
+
|
|
25
|
+
module OpenC3
|
|
26
|
+
class Bridge
|
|
27
|
+
def initialize(filename)
|
|
28
|
+
@config = BridgeConfig.new(filename)
|
|
29
|
+
@threads = []
|
|
30
|
+
|
|
31
|
+
# Start Interface Threads
|
|
32
|
+
@config.interfaces.each do |interface_name, interface|
|
|
33
|
+
@threads << BridgeInterfaceThread.new(interface)
|
|
34
|
+
@threads[-1].start
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Start Router Threads
|
|
38
|
+
@config.routers.each do |router_name, router|
|
|
39
|
+
@threads << BridgeRouterThread.new(router)
|
|
40
|
+
@threads[-1].start
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
at_exit() do
|
|
44
|
+
shutdown()
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def shutdown
|
|
49
|
+
@threads.each do |thread|
|
|
50
|
+
thread.stop
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,167 @@
|
|
|
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/utilities/logger'
|
|
21
|
+
require 'openc3/config/config_parser'
|
|
22
|
+
|
|
23
|
+
module OpenC3
|
|
24
|
+
class BridgeConfig
|
|
25
|
+
# @return [Hash<String, Interface>] Interfaces hash
|
|
26
|
+
attr_accessor :interfaces
|
|
27
|
+
# @return [Hash<String, Interface>] Routers hash
|
|
28
|
+
attr_accessor :routers
|
|
29
|
+
|
|
30
|
+
def initialize(filename)
|
|
31
|
+
@interfaces = {}
|
|
32
|
+
@routers = {}
|
|
33
|
+
process_file(filename)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.generate_default(filename)
|
|
37
|
+
default_config = <<~EOF
|
|
38
|
+
# Example Host Bridge Configuration for a Serial Port
|
|
39
|
+
#
|
|
40
|
+
# INTERFACE <Interface Name> <Interface File> <Interface Params...>
|
|
41
|
+
# INTERFACE <Interface Name> serial_interface.rb <Write Port> <Read Port> <Baud Rate> <Parity ODD/EVEN/NONE> <Stop Bits> <Write Timeout> <Read Timeout> <Protocol Name> <Protocol Params>
|
|
42
|
+
# INTERFACE <Interface Name> serial_interface.rb <Write Port> <Read Port> <Baud Rate> <Parity ODD/EVEN/NONE> <Stop Bits> <Write Timeout> <Read Timeout> BURST <Discard Leading Bytes> <Sync Pattern> <Add Sync On Write>
|
|
43
|
+
# INTERFACE SERIAL_INT serial_interface.rb /dev/ttyS1 /dev/ttyS1 38400 ODD 1 10.0 nil BURST 4 0xDEADBEEF
|
|
44
|
+
INTERFACE SERIAL_INT serial_interface.rb COM1 COM1 9600 NONE 1 10.0 nil BURST
|
|
45
|
+
#{' '}
|
|
46
|
+
# ROUTER <Router Name> <Interface File> <Interface Params...>
|
|
47
|
+
# ROUTER SERIAL_ROUTER tcpip_server_interface.rb <Write Port> <Read Port> <Write Timeout> <Read Timeout> <Protocol Name> <Protocol Params>
|
|
48
|
+
# ROUTER SERIAL_ROUTER tcpip_server_interface.rb <Write Port> <Read Port> <Write Timeout> <Read Timeout> BURST <Discard Leading Bytes> <Sync Pattern> <Add Sync On Write>
|
|
49
|
+
ROUTER SERIAL_ROUTER tcpip_server_interface.rb 2950 2950 10.0 nil BURST
|
|
50
|
+
# ROUTE <Interface Name>
|
|
51
|
+
ROUTE SERIAL_INT
|
|
52
|
+
#{' '}
|
|
53
|
+
EOF
|
|
54
|
+
|
|
55
|
+
Logger.info "Writing #{filename}"
|
|
56
|
+
File.open(filename, 'w') do |file|
|
|
57
|
+
file.write(default_config)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
protected
|
|
62
|
+
|
|
63
|
+
# Processes a file and adds in the configuration defined in the file
|
|
64
|
+
#
|
|
65
|
+
# @param filename [String] The name of the configuration file to parse
|
|
66
|
+
# @param recursive [Boolean] Whether process_file is being called
|
|
67
|
+
# recursively
|
|
68
|
+
def process_file(filename, recursive = false)
|
|
69
|
+
current_interface_or_router = nil
|
|
70
|
+
current_type = nil
|
|
71
|
+
current_interface_log_added = false
|
|
72
|
+
|
|
73
|
+
Logger.info "Processing Bridge configuration in file: #{File.expand_path(filename)}"
|
|
74
|
+
|
|
75
|
+
parser = ConfigParser.new
|
|
76
|
+
parser.parse_file(filename) do |keyword, params|
|
|
77
|
+
case keyword
|
|
78
|
+
|
|
79
|
+
when 'INTERFACE'
|
|
80
|
+
usage = "INTERFACE <Name> <Filename> <Specific Parameters>"
|
|
81
|
+
parser.verify_num_parameters(2, nil, usage)
|
|
82
|
+
interface_name = params[0].upcase
|
|
83
|
+
raise parser.error("Interface '#{interface_name}' defined twice") if @interfaces[interface_name]
|
|
84
|
+
|
|
85
|
+
interface_class = OpenC3.require_class(params[1])
|
|
86
|
+
if params[2]
|
|
87
|
+
current_interface_or_router = interface_class.new(*params[2..-1])
|
|
88
|
+
else
|
|
89
|
+
current_interface_or_router = interface_class.new
|
|
90
|
+
end
|
|
91
|
+
current_type = :INTERFACE
|
|
92
|
+
current_interface_or_router.name = interface_name
|
|
93
|
+
current_interface_or_router.config_params = params[1..-1]
|
|
94
|
+
@interfaces[interface_name] = current_interface_or_router
|
|
95
|
+
|
|
96
|
+
when 'RECONNECT_DELAY', 'LOG_RAW', 'OPTION', 'PROTOCOL'
|
|
97
|
+
raise parser.error("No current interface or router for #{keyword}") unless current_interface_or_router
|
|
98
|
+
|
|
99
|
+
case keyword
|
|
100
|
+
|
|
101
|
+
when 'RECONNECT_DELAY'
|
|
102
|
+
parser.verify_num_parameters(1, 1, "#{keyword} <Delay in Seconds>")
|
|
103
|
+
current_interface_or_router.reconnect_delay = Float(params[0])
|
|
104
|
+
|
|
105
|
+
when 'LOG_RAW',
|
|
106
|
+
parser.verify_num_parameters(0, nil, "#{keyword} <Raw Logger Class File (optional)> <Raw Logger Parameters (optional)>")
|
|
107
|
+
current_interface_or_router.raw_logger_pair = RawLoggerPair.new(current_interface_or_router.name, Dir.pwd, params)
|
|
108
|
+
current_interface_or_router.start_raw_logging
|
|
109
|
+
|
|
110
|
+
when 'OPTION'
|
|
111
|
+
parser.verify_num_parameters(2, nil, "#{keyword} <Option Name> <Option Value 1> <Option Value 2 (optional)> <etc>")
|
|
112
|
+
current_interface_or_router.set_option(params[0], params[1..-1])
|
|
113
|
+
|
|
114
|
+
when 'PROTOCOL'
|
|
115
|
+
usage = "#{keyword} <READ WRITE READ_WRITE> <protocol filename or classname> <Protocol specific parameters>"
|
|
116
|
+
parser.verify_num_parameters(2, nil, usage)
|
|
117
|
+
unless %w(READ WRITE READ_WRITE).include? params[0].upcase
|
|
118
|
+
raise parser.error("Invalid protocol type: #{params[0]}", usage)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
begin
|
|
122
|
+
klass = OpenC3.require_class(params[1])
|
|
123
|
+
current_interface_or_router.add_protocol(klass, params[2..-1], params[0].upcase.intern)
|
|
124
|
+
rescue LoadError, StandardError => error
|
|
125
|
+
raise parser.error(error.message, usage)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
end # end case keyword for all keywords that require a current interface or router
|
|
129
|
+
|
|
130
|
+
when 'ROUTER'
|
|
131
|
+
usage = "ROUTER <Name> <Filename> <Specific Parameters>"
|
|
132
|
+
parser.verify_num_parameters(2, nil, usage)
|
|
133
|
+
router_name = params[0].upcase
|
|
134
|
+
raise parser.error("Router '#{router_name}' defined twice") if @routers[router_name]
|
|
135
|
+
|
|
136
|
+
router_class = OpenC3.require_class(params[1])
|
|
137
|
+
if params[2]
|
|
138
|
+
current_interface_or_router = router_class.new(*params[2..-1])
|
|
139
|
+
else
|
|
140
|
+
current_interface_or_router = router_class.new
|
|
141
|
+
end
|
|
142
|
+
current_type = :ROUTER
|
|
143
|
+
current_interface_or_router.name = router_name
|
|
144
|
+
@routers[router_name] = current_interface_or_router
|
|
145
|
+
|
|
146
|
+
when 'ROUTE'
|
|
147
|
+
raise parser.error("No current router for #{keyword}") unless current_interface_or_router and current_type == :ROUTER
|
|
148
|
+
|
|
149
|
+
usage = "ROUTE <Interface Name>"
|
|
150
|
+
parser.verify_num_parameters(1, 1, usage)
|
|
151
|
+
interface_name = params[0].upcase
|
|
152
|
+
interface = @interfaces[interface_name]
|
|
153
|
+
raise parser.error("Unknown interface #{interface_name} mapped to router #{current_interface_or_router.name}") unless interface
|
|
154
|
+
|
|
155
|
+
unless current_interface_or_router.interfaces.include? interface
|
|
156
|
+
current_interface_or_router.interfaces << interface
|
|
157
|
+
interface.routers << current_interface_or_router
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
else
|
|
161
|
+
# blank lines will have a nil keyword and should not raise an exception
|
|
162
|
+
raise parser.error("Unknown keyword: #{keyword}") unless keyword.nil?
|
|
163
|
+
end # case
|
|
164
|
+
end # loop
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|