openc3 5.0.10 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of openc3 might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Guardfile +3 -0
- data/LICENSE.txt +7 -5
- data/README.md +11 -9
- data/Rakefile +3 -0
- data/bin/cstol_converter +3 -0
- data/bin/openc3cli +29 -18
- data/bin/rubysloc +3 -0
- data/data/config/screen.yaml +10 -2
- data/data/config/target.yaml +1 -1
- data/data/config/widgets.yaml +6 -6
- data/ext/mkrf_conf.rb +3 -0
- data/ext/openc3/ext/array/array.c +3 -0
- data/ext/openc3/ext/buffered_file/buffered_file.c +3 -0
- data/ext/openc3/ext/config_parser/config_parser.c +3 -0
- data/ext/openc3/ext/crc/crc.c +3 -0
- data/ext/openc3/ext/openc3_io/openc3_io.c +3 -0
- data/ext/openc3/ext/packet/packet.c +3 -0
- data/ext/openc3/ext/platform/platform.c +3 -0
- data/ext/openc3/ext/polynomial_conversion/polynomial_conversion.c +3 -0
- data/ext/openc3/ext/string/string.c +3 -0
- data/ext/openc3/ext/structure/structure.c +3 -0
- data/ext/openc3/ext/tabbed_plots_config/tabbed_plots_config.c +3 -0
- data/ext/openc3/ext/telemetry/telemetry.c +3 -0
- data/lib/cosmos.rb +3 -0
- data/lib/cosmosc2.rb +3 -0
- data/lib/openc3/accessors/accessor.rb +3 -0
- data/lib/openc3/accessors/binary_accessor.rb +3 -0
- data/lib/openc3/accessors/cbor_accessor.rb +3 -0
- data/lib/openc3/accessors/html_accessor.rb +3 -0
- data/lib/openc3/accessors/json_accessor.rb +4 -1
- data/lib/openc3/accessors/xml_accessor.rb +3 -0
- data/lib/openc3/accessors.rb +3 -0
- data/lib/openc3/api/api.rb +3 -0
- data/lib/openc3/api/authorized_api.rb +3 -0
- data/lib/openc3/api/cmd_api.rb +6 -3
- data/lib/openc3/api/config_api.rb +3 -0
- data/lib/openc3/api/interface_api.rb +16 -5
- data/lib/openc3/api/limits_api.rb +54 -61
- data/lib/openc3/api/router_api.rb +6 -3
- data/lib/openc3/api/settings_api.rb +3 -0
- data/lib/openc3/api/target_api.rb +3 -0
- data/lib/openc3/api/tlm_api.rb +27 -32
- data/lib/openc3/bridge/bridge.rb +3 -0
- data/lib/openc3/bridge/bridge_config.rb +3 -0
- data/lib/openc3/bridge/bridge_interface_thread.rb +3 -0
- data/lib/openc3/bridge/bridge_router_thread.rb +3 -0
- data/lib/openc3/ccsds/ccsds_packet.rb +3 -0
- data/lib/openc3/ccsds/ccsds_parser.rb +3 -0
- data/lib/openc3/config/config_parser.rb +3 -0
- data/lib/openc3/config/meta_config_parser.rb +3 -0
- data/lib/openc3/conversions/conversion.rb +3 -0
- data/lib/openc3/conversions/generic_conversion.rb +3 -0
- data/lib/openc3/conversions/packet_time_formatted_conversion.rb +3 -0
- data/lib/openc3/conversions/packet_time_seconds_conversion.rb +3 -0
- data/lib/openc3/conversions/polynomial_conversion.rb +3 -0
- data/lib/openc3/conversions/processor_conversion.rb +3 -0
- data/lib/openc3/conversions/received_count_conversion.rb +3 -0
- data/lib/openc3/conversions/received_time_formatted_conversion.rb +3 -0
- data/lib/openc3/conversions/received_time_seconds_conversion.rb +3 -0
- data/lib/openc3/conversions/segmented_polynomial_conversion.rb +3 -0
- data/lib/openc3/conversions/unix_time_conversion.rb +3 -0
- data/lib/openc3/conversions/unix_time_formatted_conversion.rb +3 -0
- data/lib/openc3/conversions/unix_time_seconds_conversion.rb +3 -0
- data/lib/openc3/conversions.rb +3 -0
- data/lib/openc3/core_ext/array.rb +3 -0
- data/lib/openc3/core_ext/binding.rb +3 -0
- data/lib/openc3/core_ext/class.rb +3 -0
- data/lib/openc3/core_ext/exception.rb +3 -0
- data/lib/openc3/core_ext/file.rb +3 -0
- data/lib/openc3/core_ext/hash.rb +3 -0
- data/lib/openc3/core_ext/io.rb +3 -0
- data/lib/openc3/core_ext/kernel.rb +3 -0
- data/lib/openc3/core_ext/math.rb +3 -0
- data/lib/openc3/core_ext/matrix.rb +3 -0
- data/lib/openc3/core_ext/objectspace.rb +3 -0
- data/lib/openc3/core_ext/openc3_io.rb +3 -0
- data/lib/openc3/core_ext/range.rb +3 -0
- data/lib/openc3/core_ext/socket.rb +3 -0
- data/lib/openc3/core_ext/string.rb +3 -0
- data/lib/openc3/core_ext/stringio.rb +3 -0
- data/lib/openc3/core_ext/tempfile.rb +3 -0
- data/lib/openc3/core_ext/time.rb +3 -0
- data/lib/openc3/core_ext.rb +4 -0
- data/lib/openc3/interfaces/interface.rb +4 -1
- data/lib/openc3/interfaces/linc_interface.rb +3 -0
- data/lib/openc3/interfaces/protocols/burst_protocol.rb +3 -0
- data/lib/openc3/interfaces/protocols/crc_protocol.rb +3 -0
- data/lib/openc3/interfaces/protocols/fixed_protocol.rb +3 -0
- data/lib/openc3/interfaces/protocols/ignore_packet_protocol.rb +3 -0
- data/lib/openc3/interfaces/protocols/length_protocol.rb +3 -0
- data/lib/openc3/interfaces/protocols/override_protocol.rb +3 -0
- data/lib/openc3/interfaces/protocols/preidentified_protocol.rb +3 -0
- data/lib/openc3/interfaces/protocols/protocol.rb +3 -0
- data/lib/openc3/interfaces/protocols/template_protocol.rb +3 -0
- data/lib/openc3/interfaces/protocols/terminated_protocol.rb +3 -0
- data/lib/openc3/interfaces/serial_interface.rb +3 -0
- data/lib/openc3/interfaces/simulated_target_interface.rb +3 -0
- data/lib/openc3/interfaces/stream_interface.rb +3 -0
- data/lib/openc3/interfaces/tcpip_client_interface.rb +3 -0
- data/lib/openc3/interfaces/tcpip_server_interface.rb +3 -0
- data/lib/openc3/interfaces/udp_interface.rb +3 -0
- data/lib/openc3/interfaces.rb +3 -0
- data/lib/openc3/io/buffered_file.rb +3 -0
- data/lib/openc3/io/io_multiplexer.rb +8 -0
- data/lib/openc3/io/json_api_object.rb +5 -2
- data/lib/openc3/io/json_drb.rb +3 -0
- data/lib/openc3/io/json_drb_object.rb +5 -2
- data/lib/openc3/io/json_drb_rack.rb +3 -0
- data/lib/openc3/io/json_rpc.rb +3 -0
- data/lib/openc3/io/openc3_snmp.rb +3 -0
- data/lib/openc3/io/posix_serial_driver.rb +3 -0
- data/lib/openc3/io/raw_logger.rb +3 -0
- data/lib/openc3/io/raw_logger_pair.rb +3 -0
- data/lib/openc3/io/serial_driver.rb +3 -0
- data/lib/openc3/io/stderr.rb +3 -0
- data/lib/openc3/io/stdout.rb +3 -0
- data/lib/openc3/io/udp_sockets.rb +3 -0
- data/lib/openc3/io/win32_serial_driver.rb +3 -0
- data/lib/openc3/logs/buffered_packet_log_reader.rb +65 -0
- data/lib/openc3/logs/buffered_packet_log_writer.rb +118 -0
- data/lib/openc3/logs/log_writer.rb +94 -41
- data/lib/openc3/logs/packet_log_constants.rb +9 -0
- data/lib/openc3/logs/packet_log_reader.rb +34 -3
- data/lib/openc3/logs/packet_log_writer.rb +85 -20
- data/lib/openc3/logs/text_log_writer.rb +9 -5
- data/lib/openc3/logs.rb +8 -2
- data/lib/openc3/microservices/cleanup_microservice.rb +18 -18
- data/lib/openc3/microservices/decom_microservice.rb +30 -24
- data/lib/openc3/microservices/interface_microservice.rb +136 -91
- data/lib/openc3/microservices/log_microservice.rb +35 -13
- data/lib/openc3/microservices/microservice.rb +16 -14
- data/lib/openc3/microservices/plugin_microservice.rb +3 -1
- data/lib/openc3/microservices/reaction_microservice.rb +4 -1
- data/lib/openc3/microservices/reducer_microservice.rb +332 -149
- data/lib/openc3/microservices/router_microservice.rb +3 -0
- data/lib/openc3/microservices/text_log_microservice.rb +5 -2
- data/lib/openc3/microservices/timeline_microservice.rb +4 -1
- data/lib/openc3/microservices/trigger_group_microservice.rb +3 -0
- data/lib/openc3/models/activity_model.rb +3 -0
- data/lib/openc3/models/auth_model.rb +3 -1
- data/lib/openc3/models/cvt_model.rb +14 -5
- data/lib/openc3/models/environment_model.rb +3 -0
- data/lib/openc3/models/gem_model.rb +30 -51
- data/lib/openc3/models/info_model.rb +3 -0
- data/lib/openc3/models/interface_model.rb +3 -0
- data/lib/openc3/models/interface_status_model.rb +4 -1
- data/lib/openc3/models/metadata_model.rb +3 -0
- data/lib/openc3/models/metric_model.rb +3 -0
- data/lib/openc3/models/microservice_model.rb +9 -6
- data/lib/openc3/models/microservice_status_model.rb +4 -1
- data/lib/openc3/models/model.rb +3 -0
- data/lib/openc3/models/note_model.rb +8 -5
- data/lib/openc3/models/notification_model.rb +3 -0
- data/lib/openc3/models/ping_model.rb +3 -0
- data/lib/openc3/models/plugin_model.rb +20 -14
- data/lib/openc3/models/process_status_model.rb +4 -1
- data/lib/openc3/models/reaction_model.rb +3 -0
- data/lib/openc3/models/reducer_model.rb +31 -24
- data/lib/openc3/models/router_model.rb +3 -0
- data/lib/openc3/models/router_status_model.rb +3 -0
- data/lib/openc3/models/scope_model.rb +3 -4
- data/lib/openc3/models/settings_model.rb +3 -0
- data/lib/openc3/models/sorted_model.rb +3 -0
- data/lib/openc3/models/target_model.rb +61 -94
- data/lib/openc3/models/timeline_model.rb +4 -1
- data/lib/openc3/models/tool_config_model.rb +3 -0
- data/lib/openc3/models/tool_model.rb +11 -9
- data/lib/openc3/models/trigger_group_model.rb +3 -0
- data/lib/openc3/models/trigger_model.rb +3 -0
- data/lib/openc3/models/widget_model.rb +18 -11
- data/lib/openc3/operators/microservice_operator.rb +3 -0
- data/lib/openc3/operators/operator.rb +105 -34
- data/lib/openc3/packets/commands.rb +3 -0
- data/lib/openc3/packets/json_packet.rb +87 -14
- data/lib/openc3/packets/limits.rb +4 -1
- data/lib/openc3/packets/limits_response.rb +3 -0
- data/lib/openc3/packets/packet.rb +5 -1
- data/lib/openc3/packets/packet_config.rb +3 -0
- data/lib/openc3/packets/packet_item.rb +9 -3
- data/lib/openc3/packets/packet_item_limits.rb +3 -0
- data/lib/openc3/packets/parsers/format_string_parser.rb +3 -0
- data/lib/openc3/packets/parsers/limits_parser.rb +3 -0
- data/lib/openc3/packets/parsers/limits_response_parser.rb +3 -0
- data/lib/openc3/packets/parsers/packet_item_parser.rb +3 -0
- data/lib/openc3/packets/parsers/packet_parser.rb +3 -0
- data/lib/openc3/packets/parsers/processor_parser.rb +3 -0
- data/lib/openc3/packets/parsers/state_parser.rb +3 -0
- data/lib/openc3/packets/parsers/xtce_converter.rb +3 -0
- data/lib/openc3/packets/parsers/xtce_parser.rb +3 -0
- data/lib/openc3/packets/structure.rb +3 -0
- data/lib/openc3/packets/structure_item.rb +3 -0
- data/lib/openc3/packets/telemetry.rb +3 -0
- data/lib/openc3/processors/processor.rb +3 -0
- data/lib/openc3/processors/statistics_processor.rb +3 -0
- data/lib/openc3/processors/watermark_processor.rb +3 -0
- data/lib/openc3/processors.rb +3 -0
- data/lib/openc3/script/api_shared.rb +35 -6
- data/lib/openc3/script/calendar.rb +3 -0
- data/lib/openc3/script/commands.rb +3 -0
- data/lib/openc3/script/exceptions.rb +3 -0
- data/lib/openc3/script/extract.rb +3 -0
- data/lib/openc3/script/limits.rb +3 -24
- data/lib/openc3/script/script.rb +11 -7
- data/lib/openc3/script/script_runner.rb +3 -0
- data/lib/openc3/script/storage.rb +34 -16
- data/lib/openc3/script/suite.rb +3 -0
- data/lib/openc3/script/suite_results.rb +3 -0
- data/lib/openc3/script/suite_runner.rb +3 -0
- data/lib/openc3/script/telemetry.rb +43 -0
- data/lib/openc3/script.rb +3 -0
- data/lib/openc3/streams/serial_stream.rb +3 -0
- data/lib/openc3/streams/stream.rb +3 -0
- data/lib/openc3/streams/tcpip_client_stream.rb +3 -0
- data/lib/openc3/streams/tcpip_socket_stream.rb +3 -0
- data/lib/openc3/system/system.rb +23 -10
- data/lib/openc3/system/system_config.rb +3 -0
- data/lib/openc3/system/target.rb +3 -0
- data/lib/openc3/system.rb +3 -0
- data/lib/openc3/tools/cmd_tlm_server/api.rb +3 -0
- data/lib/openc3/tools/cmd_tlm_server/cmd_tlm_server_config.rb +3 -0
- data/lib/openc3/tools/cmd_tlm_server/interface_thread.rb +3 -0
- data/lib/openc3/tools/table_manager/table.rb +3 -0
- data/lib/openc3/tools/table_manager/table_config.rb +3 -0
- data/lib/openc3/tools/table_manager/table_item.rb +3 -0
- data/lib/openc3/tools/table_manager/table_item_parser.rb +3 -0
- data/lib/openc3/tools/table_manager/table_manager_core.rb +3 -0
- data/lib/openc3/tools/table_manager/table_parser.rb +3 -0
- data/lib/openc3/tools/test_runner/test.rb +3 -0
- data/lib/openc3/top_level.rb +3 -0
- data/lib/openc3/topics/autonomic_topic.rb +3 -0
- data/lib/openc3/topics/calendar_topic.rb +3 -0
- data/lib/openc3/topics/command_decom_topic.rb +4 -1
- data/lib/openc3/topics/command_topic.rb +6 -1
- data/lib/openc3/topics/config_topic.rb +3 -0
- data/lib/openc3/topics/interface_topic.rb +9 -2
- data/lib/openc3/topics/limits_event_topic.rb +144 -10
- data/lib/openc3/topics/notifications_topic.rb +3 -0
- data/lib/openc3/topics/router_topic.rb +10 -3
- data/lib/openc3/topics/telemetry_decom_topic.rb +26 -20
- data/lib/openc3/topics/telemetry_reduced_topics.rb +92 -0
- data/lib/openc3/topics/telemetry_topic.rb +5 -2
- data/lib/openc3/topics/timeline_topic.rb +3 -0
- data/lib/openc3/topics/topic.rb +3 -0
- data/lib/openc3/utilities/authentication.rb +9 -4
- data/lib/openc3/utilities/authorization.rb +3 -0
- data/lib/openc3/utilities/aws_bucket.rb +199 -0
- data/lib/openc3/utilities/bucket.rb +82 -0
- data/lib/openc3/utilities/bucket_file_cache.rb +264 -0
- data/lib/openc3/utilities/bucket_utilities.rb +109 -0
- data/lib/openc3/utilities/crc.rb +3 -0
- data/lib/openc3/utilities/csv.rb +3 -0
- data/lib/openc3/utilities/local_bucket.rb +28 -0
- data/lib/openc3/utilities/local_mode.rb +54 -62
- data/lib/openc3/utilities/logger.rb +7 -1
- data/lib/openc3/utilities/message_log.rb +7 -4
- data/lib/openc3/utilities/metric.rb +4 -1
- data/lib/openc3/utilities/open_telemetry.rb +96 -0
- data/lib/openc3/utilities/process_manager.rb +3 -0
- data/lib/openc3/utilities/quaternion.rb +3 -0
- data/lib/openc3/utilities/ruby_lex_utils.rb +3 -0
- data/lib/openc3/utilities/s3_autoload.rb +8 -6
- data/lib/openc3/utilities/simulated_target.rb +3 -0
- data/lib/openc3/utilities/sleeper.rb +3 -0
- data/lib/openc3/utilities/store.rb +3 -0
- data/lib/openc3/utilities/store_autoload.rb +30 -23
- data/lib/openc3/utilities/target_file.rb +89 -63
- data/lib/openc3/utilities/zip.rb +3 -0
- data/lib/openc3/utilities.rb +3 -0
- data/lib/openc3/version.rb +6 -6
- data/lib/openc3/win32/excel.rb +3 -0
- data/lib/openc3/win32/win32.rb +3 -0
- data/lib/openc3/win32/win32_main.rb +3 -0
- data/lib/openc3.rb +3 -0
- data/tasks/gemfile_stats.rake +3 -0
- data/tasks/spec.rake +3 -0
- data/templates/plugin-template/plugin.gemspec +1 -1
- metadata +112 -6
- data/lib/openc3/utilities/s3.rb +0 -218
- data/lib/openc3/utilities/s3_file_cache.rb +0 -274
@@ -16,6 +16,9 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'openc3/microservices/microservice'
|
21
24
|
require 'openc3/models/interface_model'
|
@@ -55,106 +58,112 @@ module OpenC3
|
|
55
58
|
|
56
59
|
def run
|
57
60
|
InterfaceTopic.receive_commands(@interface, scope: @scope) do |topic, msg_hash|
|
58
|
-
|
59
|
-
|
60
|
-
if
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
61
|
+
OpenC3.with_context(msg_hash) do
|
62
|
+
# Check for a raw write to the interface
|
63
|
+
if topic =~ /CMD}INTERFACE/
|
64
|
+
if msg_hash['shutdown']
|
65
|
+
Logger.info "#{@interface.name}: Shutdown requested"
|
66
|
+
return
|
67
|
+
end
|
68
|
+
if msg_hash['connect']
|
69
|
+
Logger.info "#{@interface.name}: Connect requested"
|
70
|
+
params = []
|
71
|
+
if msg_hash['params']
|
72
|
+
params = JSON.parse(msg_hash['params'], :allow_nan => true, :create_additions => true)
|
73
|
+
end
|
74
|
+
@interface = @tlm.attempting(*params)
|
75
|
+
next 'SUCCESS'
|
76
|
+
end
|
77
|
+
if msg_hash['disconnect']
|
78
|
+
Logger.info "#{@interface.name}: Disconnect requested"
|
79
|
+
@tlm.disconnect(false)
|
80
|
+
next 'SUCCESS'
|
81
|
+
end
|
82
|
+
if msg_hash['raw']
|
83
|
+
Logger.info "#{@interface.name}: Write raw"
|
84
|
+
# A raw interface write results in an UNKNOWN packet
|
85
|
+
command = System.commands.packet('UNKNOWN', 'UNKNOWN')
|
86
|
+
command.received_count += 1
|
87
|
+
command = command.clone
|
88
|
+
command.buffer = msg_hash['raw']
|
89
|
+
command.received_time = Time.now
|
90
|
+
CommandTopic.write_packet(command, scope: @scope)
|
91
|
+
@interface.write_raw(msg_hash['raw'])
|
92
|
+
next 'SUCCESS'
|
93
|
+
end
|
94
|
+
if msg_hash.key?('log_raw')
|
95
|
+
if msg_hash['log_raw'] == 'true'
|
96
|
+
Logger.info "#{@interface.name}: Enable raw logging"
|
97
|
+
@interface.start_raw_logging
|
98
|
+
else
|
99
|
+
Logger.info "#{@interface.name}: Disable raw logging"
|
100
|
+
@interface.stop_raw_logging
|
101
|
+
end
|
102
|
+
next 'SUCCESS'
|
93
103
|
end
|
94
|
-
next 'SUCCESS'
|
95
104
|
end
|
96
|
-
end
|
97
105
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
106
|
+
target_name = msg_hash['target_name']
|
107
|
+
cmd_name = msg_hash['cmd_name']
|
108
|
+
cmd_params = nil
|
109
|
+
cmd_buffer = nil
|
110
|
+
hazardous_check = nil
|
111
|
+
if msg_hash['cmd_params']
|
112
|
+
cmd_params = JSON.parse(msg_hash['cmd_params'], :allow_nan => true, :create_additions => true)
|
113
|
+
range_check = ConfigParser.handle_true_false(msg_hash['range_check'])
|
114
|
+
raw = ConfigParser.handle_true_false(msg_hash['raw'])
|
115
|
+
hazardous_check = ConfigParser.handle_true_false(msg_hash['hazardous_check'])
|
116
|
+
elsif msg_hash['cmd_buffer']
|
117
|
+
cmd_buffer = msg_hash['cmd_buffer']
|
118
|
+
end
|
111
119
|
|
112
|
-
begin
|
113
120
|
begin
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
121
|
+
begin
|
122
|
+
if cmd_params
|
123
|
+
command = System.commands.build_cmd(target_name, cmd_name, cmd_params, range_check, raw)
|
124
|
+
elsif cmd_buffer
|
125
|
+
if target_name
|
126
|
+
command = System.commands.identify(cmd_buffer, [target_name])
|
127
|
+
else
|
128
|
+
command = System.commands.identify(cmd_buffer, @target_names)
|
129
|
+
end
|
130
|
+
unless command
|
131
|
+
command = System.commands.packet('UNKNOWN', 'UNKNOWN')
|
132
|
+
command.received_count += 1
|
133
|
+
command = command.clone
|
134
|
+
command.buffer = cmd_buffer
|
135
|
+
end
|
119
136
|
else
|
120
|
-
command
|
121
|
-
end
|
122
|
-
unless command
|
123
|
-
command = System.commands.packet('UNKNOWN', 'UNKNOWN')
|
124
|
-
command.received_count += 1
|
125
|
-
command = command.clone
|
126
|
-
command.buffer = cmd_buffer
|
137
|
+
raise "Invalid command received:\n #{msg_hash}"
|
127
138
|
end
|
128
|
-
|
129
|
-
|
139
|
+
command.received_time = Time.now
|
140
|
+
rescue => e
|
141
|
+
Logger.error "#{@interface.name}: #{msg_hash}"
|
142
|
+
Logger.error "#{@interface.name}: #{e.formatted}"
|
143
|
+
next e.message
|
130
144
|
end
|
131
|
-
command.received_time = Time.now
|
132
|
-
rescue => e
|
133
|
-
Logger.error "#{@interface.name}: #{msg_hash}"
|
134
|
-
Logger.error "#{@interface.name}: #{e.formatted}"
|
135
|
-
next e.message
|
136
|
-
end
|
137
145
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
146
|
+
if hazardous_check
|
147
|
+
hazardous, hazardous_description = System.commands.cmd_pkt_hazardous?(command)
|
148
|
+
# Return back the error, description, and the formatted command
|
149
|
+
# This allows the error handler to simply re-send the command
|
150
|
+
next "HazardousError\n#{hazardous_description}\n#{System.commands.format(command)}" if hazardous
|
151
|
+
end
|
144
152
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
153
|
+
begin
|
154
|
+
@interface.write(command)
|
155
|
+
CommandTopic.write_packet(command, scope: @scope)
|
156
|
+
CommandDecomTopic.write_packet(command, scope: @scope)
|
157
|
+
InterfaceStatusModel.set(@interface.as_json(:allow_nan => true), scope: @scope)
|
158
|
+
next 'SUCCESS'
|
159
|
+
rescue => e
|
160
|
+
Logger.error "#{@interface.name}: #{e.formatted}"
|
161
|
+
next e.message
|
162
|
+
end
|
151
163
|
rescue => e
|
152
164
|
Logger.error "#{@interface.name}: #{e.formatted}"
|
153
165
|
next e.message
|
154
166
|
end
|
155
|
-
rescue => e
|
156
|
-
Logger.error "#{@interface.name}: #{e.formatted}"
|
157
|
-
next e.message
|
158
167
|
end
|
159
168
|
end
|
160
169
|
end
|
@@ -194,7 +203,11 @@ module OpenC3
|
|
194
203
|
end
|
195
204
|
if msg_hash['connect']
|
196
205
|
Logger.info "#{@router.name}: Connect requested"
|
197
|
-
|
206
|
+
params = []
|
207
|
+
if msg_hash['params']
|
208
|
+
params = JSON.parse(msg_hash['params'], :allow_nan => true, :create_additions => true)
|
209
|
+
end
|
210
|
+
@router = @tlm.attempting(*params)
|
198
211
|
end
|
199
212
|
if msg_hash['disconnect']
|
200
213
|
Logger.info "#{@router.name}: Disconnect requested"
|
@@ -250,9 +263,21 @@ module OpenC3
|
|
250
263
|
end
|
251
264
|
@interface.name = interface_name
|
252
265
|
# Map the interface to the interface's targets
|
253
|
-
@interface.target_names do |target_name|
|
266
|
+
@interface.target_names.each do |target_name|
|
254
267
|
target = System.targets[target_name]
|
255
268
|
target.interface = @interface
|
269
|
+
|
270
|
+
# Initialize the target's packet counters based on the Topic stream
|
271
|
+
# Prevents packet count resetting to 0 when interface restarts
|
272
|
+
System.telemetry.packets(target_name).each do |packet_name, packet|
|
273
|
+
topic = "#{@scope}__TELEMETRY__{#{target_name}}__#{packet_name}"
|
274
|
+
msg_id, msg_hash = Topic.get_newest_message(topic)
|
275
|
+
if msg_id
|
276
|
+
packet.received_count = msg_hash['received_count'].to_i
|
277
|
+
else
|
278
|
+
packet.received_count = 0
|
279
|
+
end
|
280
|
+
end
|
256
281
|
end
|
257
282
|
if @interface.connect_on_startup
|
258
283
|
@interface.state = 'ATTEMPTING'
|
@@ -278,15 +303,35 @@ module OpenC3
|
|
278
303
|
@handler_thread.start
|
279
304
|
end
|
280
305
|
|
281
|
-
#
|
282
|
-
#
|
283
|
-
|
306
|
+
# Called to connect the interface/router. It takes optional parameters to
|
307
|
+
# rebuilt the interface/router. Once we set the state to 'ATTEMPTING' the
|
308
|
+
# run method handles the actual connection.
|
309
|
+
def attempting(*params)
|
310
|
+
unless params.empty?
|
311
|
+
@interface.disconnect()
|
312
|
+
# Build New Interface, this can fail if passed bad parameters
|
313
|
+
new_interface = @interface.class.new(*params)
|
314
|
+
@interface.copy_to(new_interface)
|
315
|
+
|
316
|
+
# Replace interface for targets
|
317
|
+
@interface.target_names.each do |target_name|
|
318
|
+
target = System.targets[target_name]
|
319
|
+
target.interface = new_interface
|
320
|
+
end
|
321
|
+
@interface = new_interface
|
322
|
+
end
|
323
|
+
|
284
324
|
@interface.state = 'ATTEMPTING'
|
285
325
|
if @interface_or_router == 'INTERFACE'
|
286
326
|
InterfaceStatusModel.set(@interface.as_json(:allow_nan => true), scope: @scope)
|
287
327
|
else
|
288
328
|
RouterStatusModel.set(@interface.as_json(:allow_nan => true), scope: @scope)
|
289
329
|
end
|
330
|
+
@interface # Return the interface/router since we may have recreated it
|
331
|
+
# Need to rescue Exception so we cover LoadError
|
332
|
+
rescue Exception => error
|
333
|
+
Logger.error("Attempting connection failed with params #{params} due to #{error.message}")
|
334
|
+
@interface # Return the original interface/router in case of error
|
290
335
|
end
|
291
336
|
|
292
337
|
def run
|
@@ -16,9 +16,14 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'openc3/microservices/microservice'
|
21
24
|
require 'openc3/topics/topic'
|
25
|
+
require 'openc3/logs/buffered_packet_log_writer'
|
26
|
+
require 'openc3/config/config_parser'
|
22
27
|
|
23
28
|
module OpenC3
|
24
29
|
class LogMicroservice < Microservice
|
@@ -34,6 +39,8 @@ module OpenC3
|
|
34
39
|
@cycle_time = option[1].to_i
|
35
40
|
when 'CYCLE_SIZE' # Maximum size of a log file
|
36
41
|
@cycle_size = option[1].to_i
|
42
|
+
when 'BUFFER_DEPTH' # Buffer depth to write in time order
|
43
|
+
@buffer_depth = option[1].to_i
|
37
44
|
else
|
38
45
|
Logger.error("Unknown option passed to microservice #{@name}: #{option}")
|
39
46
|
end
|
@@ -44,41 +51,41 @@ module OpenC3
|
|
44
51
|
# These settings limit the log file to 10 minutes or 50MB of data, whichever comes first
|
45
52
|
@cycle_time = 600 unless @cycle_time # 10 minutes
|
46
53
|
@cycle_size = 50_000_000 unless @cycle_size # ~50 MB
|
54
|
+
|
55
|
+
@buffer_depth = 10 unless @buffer_depth
|
47
56
|
end
|
48
57
|
|
49
58
|
def run
|
50
|
-
|
59
|
+
setup_plws()
|
51
60
|
while true
|
52
61
|
break if @cancel_thread
|
53
62
|
|
54
63
|
Topic.read_topics(@topics) do |topic, msg_id, msg_hash, redis|
|
55
64
|
break if @cancel_thread
|
56
|
-
|
57
|
-
log_data(plws, topic, msg_id, msg_hash, redis)
|
65
|
+
log_data(topic, msg_id, msg_hash, redis)
|
58
66
|
end
|
59
67
|
end
|
60
68
|
end
|
61
69
|
|
62
70
|
def setup_plws
|
63
|
-
plws = {}
|
71
|
+
@plws = {}
|
64
72
|
@topics.each do |topic|
|
65
73
|
topic_split = topic.gsub(/{|}/, '').split("__") # Remove the redis hashtag curly braces
|
66
74
|
scope = topic_split[0]
|
67
75
|
target_name = topic_split[2]
|
68
76
|
packet_name = topic_split[3]
|
69
77
|
type = @raw_or_decom.to_s.downcase
|
70
|
-
remote_log_directory = "#{scope}/#{type}_logs/#{@cmd_or_tlm.to_s.downcase}/#{target_name}
|
71
|
-
rt_label = "#{scope}__#{target_name}
|
72
|
-
stored_label = "#{scope}__#{target_name}
|
73
|
-
plws[
|
74
|
-
:RT =>
|
75
|
-
:STORED =>
|
78
|
+
remote_log_directory = "#{scope}/#{type}_logs/#{@cmd_or_tlm.to_s.downcase}/#{target_name}"
|
79
|
+
rt_label = "#{scope}__#{target_name}__ALL__rt__#{type}"
|
80
|
+
stored_label = "#{scope}__#{target_name}__ALL__stored__#{type}"
|
81
|
+
@plws[target_name] ||= {
|
82
|
+
:RT => BufferedPacketLogWriter.new(remote_log_directory, rt_label, true, @cycle_time, @cycle_size, nil, nil, @buffer_depth),
|
83
|
+
:STORED => BufferedPacketLogWriter.new(remote_log_directory, stored_label, true, @cycle_time, @cycle_size, nil, nil, @buffer_depth)
|
76
84
|
}
|
77
85
|
end
|
78
|
-
return plws
|
79
86
|
end
|
80
87
|
|
81
|
-
def log_data(
|
88
|
+
def log_data(topic, msg_id, msg_hash, redis)
|
82
89
|
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
83
90
|
topic_split = topic.gsub(/{|}/, '').split("__") # Remove the redis hashtag curly braces
|
84
91
|
target_name = topic_split[2]
|
@@ -93,7 +100,7 @@ module OpenC3
|
|
93
100
|
packet_type = :JSON_PACKET
|
94
101
|
data_key = "json_data"
|
95
102
|
end
|
96
|
-
plws[
|
103
|
+
@plws[target_name][rt_or_stored].buffered_write(packet_type, @cmd_or_tlm, target_name, packet_name, msg_hash["time"].to_i, rt_or_stored == :STORED, msg_hash[data_key], nil, topic, msg_id)
|
97
104
|
@count += 1
|
98
105
|
diff = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start # seconds as a float
|
99
106
|
metric_labels = { "packet" => packet_name, "target" => target_name, "raw_or_decom" => @raw_or_decom.to_s, "cmd_or_tlm" => @cmd_or_tlm.to_s }
|
@@ -102,6 +109,21 @@ module OpenC3
|
|
102
109
|
@error = err
|
103
110
|
Logger.error("#{@name} error: #{err.formatted}")
|
104
111
|
end
|
112
|
+
|
113
|
+
def shutdown
|
114
|
+
# Make sure all the existing logs are properly closed down
|
115
|
+
threads = []
|
116
|
+
@plws.each do |target_name, plw_hash|
|
117
|
+
plw_hash.each do |type, plw|
|
118
|
+
threads.concat(plw.shutdown)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
# Wait for all the logging threads to move files to buckets
|
122
|
+
threads.flatten.compact.each do |thread|
|
123
|
+
thread.join
|
124
|
+
end
|
125
|
+
super()
|
126
|
+
end
|
105
127
|
end
|
106
128
|
end
|
107
129
|
|
@@ -16,6 +16,9 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'openc3'
|
21
24
|
OpenC3.require_file 'json'
|
@@ -23,8 +26,9 @@ OpenC3.require_file 'redis'
|
|
23
26
|
OpenC3.require_file 'fileutils'
|
24
27
|
OpenC3.require_file 'openc3/utilities/zip'
|
25
28
|
OpenC3.require_file 'openc3/utilities/store'
|
26
|
-
OpenC3.require_file 'openc3/utilities/
|
29
|
+
OpenC3.require_file 'openc3/utilities/bucket'
|
27
30
|
OpenC3.require_file 'openc3/utilities/sleeper'
|
31
|
+
OpenC3.require_file 'openc3/utilities/open_telemetry'
|
28
32
|
OpenC3.require_file 'openc3/models/microservice_model'
|
29
33
|
OpenC3.require_file 'openc3/models/microservice_status_model'
|
30
34
|
OpenC3.require_file 'tmpdir'
|
@@ -71,6 +75,7 @@ module OpenC3
|
|
71
75
|
end
|
72
76
|
|
73
77
|
def initialize(name, is_plugin: false)
|
78
|
+
Logger.info("Microservice running from: ruby #{$0} #{ARGV.join(" ")}")
|
74
79
|
raise "Microservice must be named" unless name
|
75
80
|
|
76
81
|
@name = name
|
@@ -85,6 +90,8 @@ module OpenC3
|
|
85
90
|
Logger.microservice_name = @name
|
86
91
|
Logger.tag = @name + "__openc3.log"
|
87
92
|
|
93
|
+
OpenC3.setup_open_telemetry(@name, false)
|
94
|
+
|
88
95
|
# Create temp folder for this microservice
|
89
96
|
@temp_dir = Dir.mktmpdir
|
90
97
|
|
@@ -100,7 +107,7 @@ module OpenC3
|
|
100
107
|
Logger.info("Microservice initialized with config:\n#{@config}")
|
101
108
|
@topics ||= []
|
102
109
|
|
103
|
-
# Get configuration for any targets
|
110
|
+
# Get configuration for any targets
|
104
111
|
@target_names = @config["target_names"]
|
105
112
|
@target_names ||= []
|
106
113
|
System.setup_targets(@target_names, @temp_dir, scope: @scope) unless is_plugin
|
@@ -120,24 +127,17 @@ module OpenC3
|
|
120
127
|
@work_dir = @config["work_dir"]
|
121
128
|
cmd_array = @config["cmd"]
|
122
129
|
|
123
|
-
# Get Microservice files from
|
130
|
+
# Get Microservice files from bucket storage
|
124
131
|
temp_dir = Dir.mktmpdir
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
# Ensure config bucket exists
|
129
|
-
begin
|
130
|
-
rubys3_client.head_bucket(bucket: bucket)
|
131
|
-
rescue Aws::S3::Errors::NotFound
|
132
|
-
rubys3_client.create_bucket(bucket: bucket)
|
133
|
-
end
|
132
|
+
bucket = ENV['OPENC3_CONFIG_BUCKET']
|
133
|
+
client = Bucket.getClient()
|
134
134
|
|
135
135
|
prefix = "#{@scope}/microservices/#{@name}/"
|
136
136
|
file_count = 0
|
137
|
-
|
137
|
+
client.list_objects(bucket: bucket, prefix: prefix).each do |object|
|
138
138
|
response_target = File.join(temp_dir, object.key.split(prefix)[-1])
|
139
139
|
FileUtils.mkdir_p(File.dirname(response_target))
|
140
|
-
|
140
|
+
client.get_object(bucket: bucket, key: object.key, path: response_target)
|
141
141
|
file_count += 1
|
142
142
|
end
|
143
143
|
|
@@ -194,11 +194,13 @@ module OpenC3
|
|
194
194
|
end
|
195
195
|
|
196
196
|
def shutdown
|
197
|
+
Logger.info("Shutting down microservice: #{@name}")
|
197
198
|
@cancel_thread = true
|
198
199
|
@microservice_sleeper.cancel if @microservice_sleeper
|
199
200
|
MicroserviceStatusModel.set(as_json(:allow_nan => true), scope: @scope)
|
200
201
|
FileUtils.remove_entry(@temp_dir) if File.exist?(@temp_dir)
|
201
202
|
@metric.destroy
|
203
|
+
Logger.info("Shutting down microservice complete: #{@name}")
|
202
204
|
end
|
203
205
|
end
|
204
206
|
end
|
@@ -16,10 +16,12 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'openc3/microservices/microservice'
|
21
24
|
require 'openc3/topics/topic'
|
22
|
-
require 'openc3/utilities/s3'
|
23
25
|
|
24
26
|
module OpenC3
|
25
27
|
class PluginMicroservice < Microservice
|
@@ -16,6 +16,9 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'openc3/microservices/microservice'
|
21
24
|
require 'openc3/models/reaction_model'
|
@@ -324,7 +327,7 @@ module OpenC3
|
|
324
327
|
'reaction' => reaction.name,
|
325
328
|
'id' => Time.now.to_i
|
326
329
|
})
|
327
|
-
hostname = ENV['OPENC3_SCRIPT_HOSTNAME'] || 'openc3-script-runner-api'
|
330
|
+
hostname = ENV['OPENC3_SCRIPT_HOSTNAME'] || 'openc3-cosmos-script-runner-api'
|
328
331
|
response = Net::HTTP.new(hostname, 2902).request(request)
|
329
332
|
raise "failed to call #{hostname}, for script: #{action['value']}, response code: #{response.code}" if response.code != '200'
|
330
333
|
|