openc3 5.0.11 → 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 +6 -2
- 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 +3 -0
- data/lib/openc3/interfaces/interface.rb +3 -0
- 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 -0
- 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 +3 -0
- 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 +33 -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 +3 -0
- 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 +47 -61
- 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 +3 -3
- 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 +70 -83
- 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 -220
- 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 'childprocess'
|
21
24
|
require 'openc3'
|
@@ -23,6 +26,56 @@ require 'fileutils'
|
|
23
26
|
require 'tempfile'
|
24
27
|
|
25
28
|
module OpenC3
|
29
|
+
# Class to prevent an infinitely growing log file
|
30
|
+
class OperatorProcessIO < Tempfile
|
31
|
+
def initialize(label, max_start_lines: 100, max_end_lines: 100)
|
32
|
+
super(label)
|
33
|
+
@max_start_lines = max_start_lines
|
34
|
+
@max_end_lines = max_end_lines
|
35
|
+
@start_lines = []
|
36
|
+
@end_lines = []
|
37
|
+
end
|
38
|
+
|
39
|
+
def extract
|
40
|
+
rewind()
|
41
|
+
data = read()
|
42
|
+
truncate(0)
|
43
|
+
rewind()
|
44
|
+
|
45
|
+
# Save a set number of lines for unexpected death messages
|
46
|
+
lines = data.split("\n")
|
47
|
+
lines.each do |line|
|
48
|
+
if @start_lines.length < @max_start_lines
|
49
|
+
@start_lines << line
|
50
|
+
else
|
51
|
+
@end_lines << line
|
52
|
+
end
|
53
|
+
end
|
54
|
+
if @end_lines.length > @max_end_lines
|
55
|
+
@end_lines = @end_lines[(@end_lines.length - @max_end_lines)..-1]
|
56
|
+
end
|
57
|
+
|
58
|
+
return data
|
59
|
+
end
|
60
|
+
|
61
|
+
def finalize
|
62
|
+
extract()
|
63
|
+
close()
|
64
|
+
unlink()
|
65
|
+
|
66
|
+
output = ''
|
67
|
+
output << @start_lines.join("\n")
|
68
|
+
if @end_lines.length >= @max_end_lines
|
69
|
+
output << "\n...\n"
|
70
|
+
output << @end_lines.join("\n")
|
71
|
+
elsif @end_lines.length > 0
|
72
|
+
output << @end_lines.join("\n")
|
73
|
+
end
|
74
|
+
output << "\n"
|
75
|
+
output
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
26
79
|
class OperatorProcess
|
27
80
|
attr_accessor :process_definition
|
28
81
|
attr_accessor :work_dir
|
@@ -48,21 +101,25 @@ module OpenC3
|
|
48
101
|
@config = config
|
49
102
|
end
|
50
103
|
|
51
|
-
def
|
52
|
-
@temp_dir = @new_temp_dir
|
53
|
-
@new_temp_dir = nil
|
54
|
-
|
104
|
+
def cmd_line
|
55
105
|
# In ProcessManager processes, the process_definition is the actual thing run
|
56
106
|
# e.g. OpenC3::ProcessManager.instance.spawn(["ruby", "/openc3/bin/openc3cli", "load", ...])
|
57
107
|
# However, if the MicroserviceOperator is spawning the proceses it sets
|
58
108
|
# process_definition = ["ruby", "plugin_microservice.rb"]
|
59
109
|
# which then calls exec(*@config["cmd"]) to actually run
|
60
110
|
# So check if the @config['cmd'] is defined to give the user more info in the log
|
61
|
-
|
111
|
+
cmd_line_text = @process_definition.join(' ')
|
62
112
|
if @config && @config['cmd']
|
63
|
-
|
113
|
+
cmd_line_text = @config['cmd'].join(' ')
|
64
114
|
end
|
65
|
-
|
115
|
+
return cmd_line_text
|
116
|
+
end
|
117
|
+
|
118
|
+
def start
|
119
|
+
@temp_dir = @new_temp_dir
|
120
|
+
@new_temp_dir = nil
|
121
|
+
|
122
|
+
Logger.info("Starting: #{cmd_line()}", scope: @scope)
|
66
123
|
|
67
124
|
@process = ChildProcess.build(*@process_definition)
|
68
125
|
# This lets the ChildProcess use the parent IO ... but it breaks unit tests
|
@@ -79,8 +136,8 @@ module OpenC3
|
|
79
136
|
@process.environment[key] = value
|
80
137
|
end
|
81
138
|
@process.environment['OPENC3_SCOPE'] = @scope
|
82
|
-
@process.io.stdout =
|
83
|
-
@process.io.stderr =
|
139
|
+
@process.io.stdout = OperatorProcessIO.new('microservice-stdout')
|
140
|
+
@process.io.stderr = OperatorProcessIO.new('microservice-stderr')
|
84
141
|
@process.start
|
85
142
|
end
|
86
143
|
|
@@ -102,14 +159,18 @@ module OpenC3
|
|
102
159
|
|
103
160
|
def soft_stop
|
104
161
|
Thread.new do
|
105
|
-
Logger.info("Soft shutting down process: #{
|
162
|
+
Logger.info("Soft shutting down process: #{cmd_line()}", scope: @scope)
|
106
163
|
Process.kill("SIGINT", @process.pid) if @process # Signal the process to stop
|
107
164
|
end
|
108
165
|
end
|
109
166
|
|
110
167
|
def hard_stop
|
111
168
|
if @process and !@process.exited?
|
112
|
-
|
169
|
+
# Redis may be down at this point so just catch any Logger errors
|
170
|
+
begin
|
171
|
+
Logger.info("Hard shutting down process: #{cmd_line()}", scope: @scope)
|
172
|
+
rescue Exception
|
173
|
+
end
|
113
174
|
@process.stop
|
114
175
|
end
|
115
176
|
FileUtils.remove_entry(@temp_dir) if @temp_dir and File.exist?(@temp_dir)
|
@@ -124,20 +185,37 @@ module OpenC3
|
|
124
185
|
@process.io.stderr
|
125
186
|
end
|
126
187
|
|
127
|
-
def
|
188
|
+
def output_increment
|
128
189
|
if @process
|
129
|
-
@process.io.stdout.
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
190
|
+
stdout = @process.io.stdout.extract
|
191
|
+
if stdout.length > 0
|
192
|
+
STDOUT.puts "STDOUT #{stdout.length} bytes from #{cmd_line()}:"
|
193
|
+
STDOUT.puts stdout
|
194
|
+
end
|
195
|
+
stderr = @process.io.stderr.extract
|
196
|
+
if stderr.length > 0
|
197
|
+
STDERR.puts "STDERR #{stderr.length} bytes from #{cmd_line()}:"
|
198
|
+
STDERR.puts stderr
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
# This is method is used in here and in ProcessManager
|
204
|
+
def extract_output
|
205
|
+
output = ''
|
206
|
+
if @process
|
207
|
+
stdout = @process.io.stdout.finalize
|
208
|
+
stderr = @process.io.stderr.finalize
|
209
|
+
|
210
|
+
# Always include the Stdout header for consistency and to show the option
|
211
|
+
output << "Stdout:\n"
|
212
|
+
output << stdout
|
213
|
+
|
214
|
+
# Always include the nStderr header for consistency and to show the option
|
215
|
+
output << "\nStderr:\n"
|
216
|
+
output << stderr
|
140
217
|
end
|
218
|
+
output
|
141
219
|
end
|
142
220
|
end
|
143
221
|
|
@@ -215,18 +293,11 @@ module OpenC3
|
|
215
293
|
@mutex.synchronize do
|
216
294
|
@processes.each do |name, p|
|
217
295
|
break if @shutdown
|
218
|
-
|
296
|
+
p.output_increment
|
219
297
|
unless p.alive?
|
220
298
|
# Respawn process
|
221
|
-
p.
|
222
|
-
output
|
223
|
-
p.stdout.close
|
224
|
-
p.stdout.unlink
|
225
|
-
p.stderr.rewind
|
226
|
-
err_output = p.stderr.read
|
227
|
-
p.stderr.close
|
228
|
-
p.stderr.unlink
|
229
|
-
Logger.error("Unexpected process died... respawning! #{p.process_definition.join(' ')}\nStdout:\n#{output}\nStderr:\n#{err_output}\n", scope: p.scope)
|
299
|
+
output = p.extract_output
|
300
|
+
Logger.error("Unexpected process died... respawning! #{p.cmd_line}\n#{output}\n", scope: p.scope)
|
230
301
|
p.start
|
231
302
|
end
|
232
303
|
end
|
@@ -235,7 +306,7 @@ module OpenC3
|
|
235
306
|
|
236
307
|
def shutdown_processes(processes)
|
237
308
|
processes.each { |name, p| p.soft_stop }
|
238
|
-
sleep(
|
309
|
+
sleep(4) # TODO: This is an arbitrary sleep of 4s ...
|
239
310
|
processes.each { |name, p| p.hard_stop }
|
240
311
|
end
|
241
312
|
|
@@ -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/packets/packet_config'
|
21
24
|
|
@@ -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
|
require 'json'
|
@@ -30,20 +33,63 @@ module OpenC3
|
|
30
33
|
attr_accessor :stored
|
31
34
|
attr_accessor :json_hash
|
32
35
|
|
33
|
-
def initialize(cmd_or_tlm, target_name, packet_name, time_nsec_from_epoch, stored, json_data)
|
36
|
+
def initialize(cmd_or_tlm, target_name, packet_name, time_nsec_from_epoch, stored, json_data, key_map = nil)
|
34
37
|
@cmd_or_tlm = cmd_or_tlm.intern
|
35
38
|
@target_name = target_name
|
36
39
|
@packet_name = packet_name
|
37
40
|
@packet_time = ::Time.from_nsec_from_epoch(time_nsec_from_epoch)
|
38
41
|
@stored = ConfigParser.handle_true_false(stored)
|
39
|
-
@json_hash =
|
42
|
+
@json_hash = json_data
|
43
|
+
@json_hash = JSON.parse(json_data, :allow_nan => true, :create_additions => true) if String === json_data
|
44
|
+
if key_map
|
45
|
+
uncompressed = {}
|
46
|
+
@json_hash.each do |key, value|
|
47
|
+
uncompressed_key = key_map[key]
|
48
|
+
uncompressed_key = key unless uncompressed_key
|
49
|
+
uncompressed[uncompressed_key] = value
|
50
|
+
end
|
51
|
+
@json_hash = uncompressed
|
52
|
+
end
|
40
53
|
end
|
41
54
|
|
42
55
|
# Read an item in the packet by name
|
43
56
|
#
|
44
57
|
# @param name [String] Name of the item to read - Should already by upcase
|
45
58
|
# @param value_type (see #read_item)
|
46
|
-
def read(name, value_type = :CONVERTED)
|
59
|
+
def read(name, value_type = :CONVERTED, reduced_type = nil)
|
60
|
+
if reduced_type
|
61
|
+
raise "Reduced types only support RAW or CONVERTED value types: #{value_type} unsupported" if value_type == :WITH_UNITS or value_type == :FORMATTED
|
62
|
+
if value_type == :CONVERTED
|
63
|
+
case reduced_type
|
64
|
+
when :AVG
|
65
|
+
value = @json_hash["#{name}__CA"]
|
66
|
+
return value if value
|
67
|
+
when :STDDEV
|
68
|
+
value = @json_hash["#{name}__CS"]
|
69
|
+
return value if value
|
70
|
+
when :MIN
|
71
|
+
value = @json_hash["#{name}__CN"]
|
72
|
+
return value if value
|
73
|
+
when :MAX
|
74
|
+
value = @json_hash["#{name}__CX"]
|
75
|
+
return value if value
|
76
|
+
end
|
77
|
+
end
|
78
|
+
case reduced_type
|
79
|
+
when :AVG
|
80
|
+
value = @json_hash["#{name}__A"]
|
81
|
+
return value if value
|
82
|
+
when :STDDEV
|
83
|
+
value = @json_hash["#{name}__S"]
|
84
|
+
return value if value
|
85
|
+
when :MIN
|
86
|
+
value = @json_hash["#{name}__N"]
|
87
|
+
return value if value
|
88
|
+
when :MAX
|
89
|
+
value = @json_hash["#{name}__X"]
|
90
|
+
return value if value
|
91
|
+
end
|
92
|
+
end
|
47
93
|
if value_type == :WITH_UNITS
|
48
94
|
value = @json_hash["#{name}__U"]
|
49
95
|
return value if value
|
@@ -68,8 +114,8 @@ module OpenC3
|
|
68
114
|
return value if value
|
69
115
|
end
|
70
116
|
|
71
|
-
def read_with_limits_state(name, value_type = :CONVERTED)
|
72
|
-
value = read(name, value_type)
|
117
|
+
def read_with_limits_state(name, value_type = :CONVERTED, reduced_type = nil)
|
118
|
+
value = read(name, value_type, reduced_type)
|
73
119
|
limits_state = @json_hash["#{name}__L"]
|
74
120
|
limits_state.intern if limits_state
|
75
121
|
return [value, limits_state]
|
@@ -79,11 +125,11 @@ module OpenC3
|
|
79
125
|
# [[item name, item value], ...]
|
80
126
|
#
|
81
127
|
# @param value_type (see #read_item)
|
82
|
-
def read_all(value_type = :CONVERTED, names = nil)
|
128
|
+
def read_all(value_type = :CONVERTED, reduced_type = nil, names = nil)
|
83
129
|
result = {}
|
84
130
|
names = read_all_names() unless names
|
85
131
|
names.each do |name|
|
86
|
-
result[name] = read(name, value_type)
|
132
|
+
result[name] = read(name, value_type, reduced_type)
|
87
133
|
end
|
88
134
|
return result
|
89
135
|
end
|
@@ -92,21 +138,48 @@ module OpenC3
|
|
92
138
|
# [[item name, item value], [item limits state], ...]
|
93
139
|
#
|
94
140
|
# @param value_type (see #read_all)
|
95
|
-
def read_all_with_limits_states(value_type = :CONVERTED, names = nil)
|
141
|
+
def read_all_with_limits_states(value_type = :CONVERTED, reduced_type = nil, names = nil)
|
96
142
|
result = {}
|
97
143
|
names = read_all_names() unless names
|
98
144
|
names.each do |name|
|
99
|
-
result[name] = read_with_limits_state(name, value_type)
|
145
|
+
result[name] = read_with_limits_state(name, value_type, reduced_type)
|
100
146
|
end
|
101
147
|
return result
|
102
148
|
end
|
103
149
|
|
104
150
|
# Read all the names of items in the packet
|
105
151
|
# Note: This is not very efficient, ideally only call once for discovery purposes
|
106
|
-
def read_all_names
|
152
|
+
def read_all_names(value_type = nil, reduced_type = nil)
|
107
153
|
result = {}
|
108
|
-
|
109
|
-
|
154
|
+
if value_type
|
155
|
+
case value_type
|
156
|
+
when :RAW
|
157
|
+
postfix = ''
|
158
|
+
when :CONVERTED
|
159
|
+
postfix = 'C'
|
160
|
+
when :FORMATTED
|
161
|
+
postfix = 'F'
|
162
|
+
when :WITH_UNITS
|
163
|
+
postfix = 'U'
|
164
|
+
end
|
165
|
+
case reduced_type
|
166
|
+
when :MIN
|
167
|
+
postfix << 'N'
|
168
|
+
when :MAX
|
169
|
+
postfix << 'X'
|
170
|
+
when :AVG
|
171
|
+
postfix << 'A'
|
172
|
+
when :STDDEV
|
173
|
+
postfix << 'S'
|
174
|
+
else
|
175
|
+
postfix = nil if value_type == :RAW
|
176
|
+
end
|
177
|
+
@json_hash.each do |key, value|
|
178
|
+
key_split = key.split("__")
|
179
|
+
result[key_split[0]] = true if key_split[1] == postfix
|
180
|
+
end
|
181
|
+
else
|
182
|
+
@json_hash.each { |key, value| result[key.split("__")[0]] = true }
|
110
183
|
end
|
111
184
|
return result.keys
|
112
185
|
end
|
@@ -115,12 +188,12 @@ module OpenC3
|
|
115
188
|
#
|
116
189
|
# @param value_type (see #read_item)
|
117
190
|
# @param indent (see Structure#formatted)
|
118
|
-
def formatted(value_type = :CONVERTED, names = nil, indent = 0)
|
191
|
+
def formatted(value_type = :CONVERTED, reduced_type = nil, names = nil, indent = 0)
|
119
192
|
names = read_all_names() unless names
|
120
193
|
indent_string = ' ' * indent
|
121
194
|
string = ''
|
122
195
|
names.each do |name|
|
123
|
-
value = read(name, value_type)
|
196
|
+
value = read(name, value_type, reduced_type)
|
124
197
|
if String === value and value =~ File::NON_ASCII_PRINTABLE
|
125
198
|
string << "#{indent_string}#{name}:\n"
|
126
199
|
string << value.formatted(1, 16, ' ', indent + 2)
|
@@ -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/packets/packet_config'
|
21
24
|
|
@@ -234,7 +237,7 @@ module OpenC3
|
|
234
237
|
limits_for_set[4] = green_low.to_f
|
235
238
|
limits_for_set[5] = green_high.to_f
|
236
239
|
end
|
237
|
-
limits.enabled = enabled
|
240
|
+
limits.enabled = enabled if not enabled.nil?
|
238
241
|
limits.persistence_setting = Integer(persistence) if persistence
|
239
242
|
packet.update_limits_items_cache(item)
|
240
243
|
@config.limits_sets << limits_set
|
@@ -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
|
# This file implements a class to handle responses to limits state changes.
|
21
24
|
|
@@ -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 'digest'
|
21
24
|
require 'openc3/packets/structure'
|
@@ -558,7 +561,8 @@ module OpenC3
|
|
558
561
|
# can be any type.
|
559
562
|
def read_item(item, value_type = :CONVERTED, buffer = @buffer, given_raw = nil)
|
560
563
|
if given_raw
|
561
|
-
value
|
564
|
+
# Must clone this since value is returned
|
565
|
+
value = given_raw.clone
|
562
566
|
else
|
563
567
|
value = super(item, :RAW, buffer)
|
564
568
|
end
|
@@ -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/config/config_parser'
|
21
24
|
require 'openc3/packets/packet'
|
@@ -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/packets/structure_item'
|
21
24
|
require 'openc3/packets/packet_item_limits'
|
@@ -464,6 +467,8 @@ module OpenC3
|
|
464
467
|
config['write_conversion'] = self.write_conversion.as_json(*a) if self.write_conversion
|
465
468
|
|
466
469
|
if self.limits
|
470
|
+
config['limits'] ||= {}
|
471
|
+
config['limits']['enabled'] = true if self.limits.enabled
|
467
472
|
if self.limits.values
|
468
473
|
config['limits'] ||= {}
|
469
474
|
config['limits']['persistence_setting'] = self.limits.persistence_setting
|
@@ -527,17 +532,18 @@ module OpenC3
|
|
527
532
|
end
|
528
533
|
end
|
529
534
|
|
535
|
+
item.limits = PacketItemLimits.new
|
530
536
|
if hash['limits']
|
531
|
-
item.limits = PacketItemLimits.new
|
532
537
|
# Delete these keys so the only ones left are limits sets
|
533
|
-
|
538
|
+
persistence_setting = hash['limits'].delete('persistence_setting')
|
539
|
+
item.limits.persistence_setting = persistence_setting if persistence_setting
|
534
540
|
item.limits.enabled = true if hash['limits'].delete('enabled')
|
535
541
|
values = {}
|
536
542
|
hash['limits'].each do |set, items|
|
537
543
|
values[set.to_sym] = [items['red_low'], items['yellow_low'], items['yellow_high'], items['red_high']]
|
538
544
|
values[set.to_sym].concat([items['green_low'], items['green_high']]) if items['green_low'] && items['green_high']
|
539
545
|
end
|
540
|
-
item.limits.values = values
|
546
|
+
item.limits.values = values if values.length > 0
|
541
547
|
end
|
542
548
|
item.meta = hash['meta']
|
543
549
|
item
|
@@ -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/packets/limits_response'
|
21
24
|
|
@@ -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
|
module OpenC3
|
21
24
|
class FormatStringParser
|
@@ -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
|
module OpenC3
|
21
24
|
class LimitsResponseParser
|
@@ -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/packets/packet_item'
|
21
24
|
|
@@ -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/packets/packet_item'
|
21
24
|
|
@@ -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 'nokogiri'
|
21
24
|
require 'openc3/packets/parsers/xtce_parser'
|
@@ -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 'nokogiri'
|
21
24
|
require 'ostruct'
|
@@ -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/packets/binary_accessor'
|
21
24
|
require 'openc3/packets/structure_item'
|
@@ -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/ext/packet' if RUBY_ENGINE == 'ruby' and !ENV['OPENC3_NO_EXT']
|
21
24
|
|
@@ -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/packets/packet_config'
|
21
24
|
require 'openc3/ext/telemetry' if RUBY_ENGINE == 'ruby' and !ENV['OPENC3_NO_EXT']
|
@@ -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/processors/processor'
|
21
24
|
|
@@ -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/processors/processor'
|
21
24
|
|