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,94 @@
|
|
|
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/interfaces/stream_interface'
|
|
21
|
+
require 'openc3/streams/serial_stream'
|
|
22
|
+
|
|
23
|
+
module OpenC3
|
|
24
|
+
# Provides a base class for interfaces that use serial ports
|
|
25
|
+
class SerialInterface < StreamInterface
|
|
26
|
+
# Creates a serial interface which uses the specified stream protocol.
|
|
27
|
+
#
|
|
28
|
+
# @param write_port_name [String] The name of the serial port to write
|
|
29
|
+
# @param read_port_name [String] The name of the serial port to read
|
|
30
|
+
# @param baud_rate [Integer] The serial port baud rate
|
|
31
|
+
# @param parity [Symbol] The parity which is normally :NONE.
|
|
32
|
+
# Must be one of :NONE, :EVEN, or :ODD.
|
|
33
|
+
# @param stop_bits [Integer] The number of stop bits which is normally 1.
|
|
34
|
+
# @param write_timeout [Integer] The number of seconds to attempt the write
|
|
35
|
+
# before aborting
|
|
36
|
+
# @param read_timeout [Integer] The number of seconds to attempt to read
|
|
37
|
+
# data from the serial port before aborting
|
|
38
|
+
# @param protocol_type [String] Combined with 'Protocol' to resolve
|
|
39
|
+
# to a OpenC3 protocol class
|
|
40
|
+
# @param protocol_args [Array] Arguments to pass to the protocol constructor
|
|
41
|
+
def initialize(write_port_name,
|
|
42
|
+
read_port_name,
|
|
43
|
+
baud_rate,
|
|
44
|
+
parity,
|
|
45
|
+
stop_bits,
|
|
46
|
+
write_timeout,
|
|
47
|
+
read_timeout,
|
|
48
|
+
protocol_type = nil,
|
|
49
|
+
*protocol_args)
|
|
50
|
+
super(protocol_type, protocol_args)
|
|
51
|
+
|
|
52
|
+
@write_port_name = ConfigParser.handle_nil(write_port_name)
|
|
53
|
+
@read_port_name = ConfigParser.handle_nil(read_port_name)
|
|
54
|
+
@baud_rate = baud_rate
|
|
55
|
+
@parity = parity.to_s.intern
|
|
56
|
+
@stop_bits = stop_bits
|
|
57
|
+
@write_timeout = write_timeout
|
|
58
|
+
@read_timeout = read_timeout
|
|
59
|
+
@write_allowed = false unless @write_port_name
|
|
60
|
+
@write_raw_allowed = false unless @write_port_name
|
|
61
|
+
@read_allowed = false unless @read_port_name
|
|
62
|
+
@flow_control = :NONE
|
|
63
|
+
@data_bits = 8
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Creates a new {SerialStream} using the parameters passed in the constructor
|
|
67
|
+
def connect
|
|
68
|
+
@stream = SerialStream.new(
|
|
69
|
+
@write_port_name,
|
|
70
|
+
@read_port_name,
|
|
71
|
+
@baud_rate,
|
|
72
|
+
@parity,
|
|
73
|
+
@stop_bits,
|
|
74
|
+
@write_timeout,
|
|
75
|
+
@read_timeout,
|
|
76
|
+
@flow_control,
|
|
77
|
+
@data_bits
|
|
78
|
+
)
|
|
79
|
+
super()
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Supported Options
|
|
83
|
+
# FLOW_CONTROL - Flow control method NONE or RTSCTS. Defaults to NONE
|
|
84
|
+
def set_option(option_name, option_values)
|
|
85
|
+
super(option_name, option_values)
|
|
86
|
+
case option_name.upcase
|
|
87
|
+
when 'FLOW_CONTROL'
|
|
88
|
+
@flow_control = option_values[0]
|
|
89
|
+
when 'DATA_BITS'
|
|
90
|
+
@data_bits = option_values[0].to_i
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -0,0 +1,168 @@
|
|
|
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/interfaces/interface'
|
|
21
|
+
require 'openc3/interfaces/protocols/override_protocol'
|
|
22
|
+
|
|
23
|
+
module OpenC3
|
|
24
|
+
# An interface class that provides simulated telemetry and command responses
|
|
25
|
+
class SimulatedTargetInterface < Interface
|
|
26
|
+
# @param sim_target_file [String] Filename of the simulator target class
|
|
27
|
+
def initialize(sim_target_file)
|
|
28
|
+
super()
|
|
29
|
+
@connected = false
|
|
30
|
+
@initialized = false
|
|
31
|
+
@count_100hz = 0
|
|
32
|
+
@next_tick_time = nil
|
|
33
|
+
@pending_packets = []
|
|
34
|
+
@sim_target_class = OpenC3.require_class sim_target_file
|
|
35
|
+
@sim_target = nil
|
|
36
|
+
@write_raw_allowed = false
|
|
37
|
+
@raw_logger_pair = nil
|
|
38
|
+
add_protocol(OverrideProtocol, [], :READ)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Initialize the simulated target object and "connect" to the target
|
|
42
|
+
def connect
|
|
43
|
+
unless @initialized
|
|
44
|
+
# Create Simulated Target Object
|
|
45
|
+
@sim_target = @sim_target_class.new(@target_names[0])
|
|
46
|
+
# Set telemetry rates
|
|
47
|
+
@sim_target.set_rates
|
|
48
|
+
|
|
49
|
+
@initialized = true
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
@count_100hz = 0
|
|
53
|
+
|
|
54
|
+
# Save the current time + delta as the next expected tick time
|
|
55
|
+
@next_tick_time = Time.now.sys + @sim_target.tick_period_seconds
|
|
56
|
+
|
|
57
|
+
@connected = true
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# @return [Boolean] Whether the simulated target is connected (initialized)
|
|
61
|
+
def connected?
|
|
62
|
+
@connected
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# @return [Packet] Returns a simulated target packet from the simulator
|
|
66
|
+
def read
|
|
67
|
+
packet = nil
|
|
68
|
+
if @connected
|
|
69
|
+
packet = first_pending_packet()
|
|
70
|
+
if packet
|
|
71
|
+
# Support read_packet (but not read data) in protocols
|
|
72
|
+
# Generic protocol use is not supported
|
|
73
|
+
@read_protocols.each do |protocol|
|
|
74
|
+
packet = protocol.read_packet(packet)
|
|
75
|
+
if packet == :DISCONNECT
|
|
76
|
+
Logger.info("#{@name}: Protocol #{protocol.class} read_packet requested disconnect")
|
|
77
|
+
return nil
|
|
78
|
+
end
|
|
79
|
+
break if packet == :STOP
|
|
80
|
+
end
|
|
81
|
+
return packet unless packet == :STOP
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
while true
|
|
85
|
+
# Calculate time to sleep to make ticks the right distance apart
|
|
86
|
+
now = Time.now.sys
|
|
87
|
+
delta = @next_tick_time - now
|
|
88
|
+
if delta > 0.0
|
|
89
|
+
sleep(delta) # Sleep between packets
|
|
90
|
+
return nil unless @connected
|
|
91
|
+
elsif delta < -1.0
|
|
92
|
+
# Fell way behind - jump next tick time
|
|
93
|
+
@next_tick_time = Time.now.sys
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
@pending_packets = @sim_target.read(@count_100hz, @next_tick_time)
|
|
97
|
+
@next_tick_time += @sim_target.tick_period_seconds
|
|
98
|
+
@count_100hz += @sim_target.tick_increment
|
|
99
|
+
|
|
100
|
+
packet = first_pending_packet()
|
|
101
|
+
if packet
|
|
102
|
+
# Support read_packet (but not read data) in protocols
|
|
103
|
+
# Generic protocol use is not supported
|
|
104
|
+
@read_protocols.each do |protocol|
|
|
105
|
+
packet = protocol.read_packet(packet)
|
|
106
|
+
if packet == :DISCONNECT
|
|
107
|
+
Logger.info("#{@name}: Protocol #{protocol.class} read_packet requested disconnect")
|
|
108
|
+
return nil
|
|
109
|
+
end
|
|
110
|
+
break if packet == :STOP
|
|
111
|
+
end
|
|
112
|
+
next if packet == :STOP
|
|
113
|
+
|
|
114
|
+
return packet
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
else
|
|
118
|
+
raise "Interface not connected"
|
|
119
|
+
end
|
|
120
|
+
return packet
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# @param packet [Packet] Command packet to send to the simulator
|
|
124
|
+
def write(packet)
|
|
125
|
+
if @connected
|
|
126
|
+
# Update count of commands sent through this interface
|
|
127
|
+
@write_count += 1
|
|
128
|
+
@bytes_written += packet.length
|
|
129
|
+
@written_raw_data_time = Time.now
|
|
130
|
+
@written_raw_data = packet.buffer
|
|
131
|
+
|
|
132
|
+
# Have simulated target handle the packet
|
|
133
|
+
@sim_target.write(packet)
|
|
134
|
+
else
|
|
135
|
+
raise "Interface not connected"
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# write_raw is not implemented and will raise a RuntimeError
|
|
140
|
+
def write_raw(data)
|
|
141
|
+
raise "write_raw not implemented for SimulatedTargetInterface"
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Raise an error because raw logging is not supported for this interface
|
|
145
|
+
def raw_logger_pair=(raw_logger_pair)
|
|
146
|
+
raise "Raw logging not supported for SimulatedTargetInterface"
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Disconnect from the simulator
|
|
150
|
+
def disconnect
|
|
151
|
+
@connected = false
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
protected
|
|
155
|
+
|
|
156
|
+
def first_pending_packet
|
|
157
|
+
packet = nil
|
|
158
|
+
unless @pending_packets.empty?
|
|
159
|
+
@read_count += 1
|
|
160
|
+
packet = @pending_packets.pop.clone
|
|
161
|
+
@bytes_read += packet.length
|
|
162
|
+
@read_raw_data_time = Time.now
|
|
163
|
+
@read_raw_data = packet.buffer
|
|
164
|
+
end
|
|
165
|
+
packet
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
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/interfaces/interface'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
# Base class for interfaces that act read and write from a stream
|
|
24
|
+
class StreamInterface < Interface
|
|
25
|
+
attr_accessor :stream
|
|
26
|
+
|
|
27
|
+
def initialize(protocol_type = nil, protocol_args = [])
|
|
28
|
+
super()
|
|
29
|
+
@stream = nil
|
|
30
|
+
@protocol_type = ConfigParser.handle_nil(protocol_type)
|
|
31
|
+
@protocol_args = protocol_args
|
|
32
|
+
if @protocol_type
|
|
33
|
+
protocol_class_name = protocol_type.to_s.capitalize << 'Protocol'
|
|
34
|
+
klass = OpenC3.require_class(protocol_class_name.class_name_to_filename)
|
|
35
|
+
add_protocol(klass, protocol_args, :READ_WRITE)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def connect
|
|
40
|
+
super()
|
|
41
|
+
@stream.connect if @stream
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def connected?
|
|
45
|
+
if @stream
|
|
46
|
+
@stream.connected?
|
|
47
|
+
else
|
|
48
|
+
false
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def disconnect
|
|
53
|
+
@stream.disconnect if @stream
|
|
54
|
+
super()
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def read_interface
|
|
58
|
+
timeout = false
|
|
59
|
+
begin
|
|
60
|
+
data = @stream.read
|
|
61
|
+
rescue Timeout::Error
|
|
62
|
+
Logger.error "#{@name}: Timeout waiting for data to be read"
|
|
63
|
+
timeout = true
|
|
64
|
+
data = nil
|
|
65
|
+
end
|
|
66
|
+
if data.nil? or data.length <= 0
|
|
67
|
+
Logger.info "#{@name}: #{@stream.class} read returned nil" if data.nil? and not timeout
|
|
68
|
+
Logger.info "#{@name}: #{@stream.class} read returned 0 bytes (stream closed)" if not data.nil? and data.length <= 0
|
|
69
|
+
return nil
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
read_interface_base(data)
|
|
73
|
+
data
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def write_interface(data)
|
|
77
|
+
write_interface_base(data)
|
|
78
|
+
@stream.write(data)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
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/interfaces/stream_interface'
|
|
21
|
+
require 'openc3/streams/tcpip_client_stream'
|
|
22
|
+
|
|
23
|
+
module OpenC3
|
|
24
|
+
# Base class for interfaces that act as a TCP/IP client
|
|
25
|
+
class TcpipClientInterface < StreamInterface
|
|
26
|
+
# @param hostname [String] Machine to connect to
|
|
27
|
+
# @param write_port [Integer] Port to write commands to
|
|
28
|
+
# @param read_port [Integer] Port to read telemetry from
|
|
29
|
+
# @param write_timeout [Integer] Seconds to wait before aborting writes
|
|
30
|
+
# @param read_timeout [Integer] Seconds to wait before aborting reads
|
|
31
|
+
# @param protocol_type [String] Name of the protocol to use
|
|
32
|
+
# with this interface
|
|
33
|
+
# @param protocol_args [Array<String>] Arguments to pass to the protocol
|
|
34
|
+
def initialize(
|
|
35
|
+
hostname,
|
|
36
|
+
write_port,
|
|
37
|
+
read_port,
|
|
38
|
+
write_timeout,
|
|
39
|
+
read_timeout,
|
|
40
|
+
protocol_type = nil,
|
|
41
|
+
*protocol_args
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
super(protocol_type, protocol_args)
|
|
45
|
+
|
|
46
|
+
@hostname = hostname
|
|
47
|
+
@write_port = ConfigParser.handle_nil(write_port)
|
|
48
|
+
@read_port = ConfigParser.handle_nil(read_port)
|
|
49
|
+
@write_timeout = write_timeout
|
|
50
|
+
@read_timeout = read_timeout
|
|
51
|
+
@read_allowed = false unless @read_port
|
|
52
|
+
@write_allowed = false unless @write_port
|
|
53
|
+
@write_raw_allowed = false unless @write_port
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Connects the {TcpipClientStream} by passing the
|
|
57
|
+
# initialization parameters to the {TcpipClientStream}.
|
|
58
|
+
def connect
|
|
59
|
+
@stream = TcpipClientStream.new(
|
|
60
|
+
@hostname,
|
|
61
|
+
@write_port,
|
|
62
|
+
@read_port,
|
|
63
|
+
@write_timeout,
|
|
64
|
+
@read_timeout
|
|
65
|
+
)
|
|
66
|
+
super()
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|