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,9 +16,13 @@
|
|
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/logs/log_writer'
|
21
24
|
require 'openc3/logs/packet_log_constants'
|
25
|
+
require 'cbor'
|
22
26
|
|
23
27
|
module OpenC3
|
24
28
|
# Creates a packet log. Can automatically cycle the log based on an elasped
|
@@ -26,7 +30,9 @@ module OpenC3
|
|
26
30
|
class PacketLogWriter < LogWriter
|
27
31
|
include PacketLogConstants
|
28
32
|
|
29
|
-
|
33
|
+
attr_accessor :data_format
|
34
|
+
|
35
|
+
# @param remote_log_directory [String] The path to store the log files
|
30
36
|
# @param label [String] Label to apply to the log filename
|
31
37
|
# @param logging_enabled [Boolean] Whether to start with logging enabled
|
32
38
|
# @param cycle_time [Integer] The amount of time in seconds before creating
|
@@ -40,8 +46,6 @@ module OpenC3
|
|
40
46
|
# will be cycled hourly at the specified cycle_minute.
|
41
47
|
# @param cycle_minute [Integer] The time at which to cycle the log. See cycle_hour
|
42
48
|
# for more information.
|
43
|
-
# @param redis_topic [String] The key of the Redis stream to trim when files are
|
44
|
-
# moved to S3
|
45
49
|
def initialize(
|
46
50
|
remote_log_directory,
|
47
51
|
label,
|
@@ -49,8 +53,7 @@ module OpenC3
|
|
49
53
|
cycle_time = nil,
|
50
54
|
cycle_size = 1_000_000_000,
|
51
55
|
cycle_hour = nil,
|
52
|
-
cycle_minute = nil
|
53
|
-
redis_topic: nil
|
56
|
+
cycle_minute = nil
|
54
57
|
)
|
55
58
|
super(
|
56
59
|
remote_log_directory,
|
@@ -58,19 +61,21 @@ module OpenC3
|
|
58
61
|
cycle_time,
|
59
62
|
cycle_size,
|
60
63
|
cycle_hour,
|
61
|
-
cycle_minute
|
62
|
-
redis_topic: redis_topic
|
64
|
+
cycle_minute
|
63
65
|
)
|
64
66
|
@label = label
|
65
67
|
@index_file = nil
|
66
68
|
@index_filename = nil
|
67
69
|
@cmd_packet_table = {}
|
68
70
|
@tlm_packet_table = {}
|
71
|
+
@key_map_table = {}
|
69
72
|
@target_dec_entries = []
|
70
73
|
@packet_dec_entries = []
|
74
|
+
@key_map_entries = []
|
71
75
|
@next_packet_index = 0
|
72
76
|
@target_indexes = {}
|
73
77
|
@next_target_index = 0
|
78
|
+
@data_format = :CBOR # Default to CBOR for improved compression
|
74
79
|
|
75
80
|
# This is an optimization to avoid creating a new entry object
|
76
81
|
# each time we create an entry which we do a LOT!
|
@@ -83,7 +88,7 @@ module OpenC3
|
|
83
88
|
# created.
|
84
89
|
#
|
85
90
|
# @param entry_type [Symbol] Type of entry to write. Must be one of
|
86
|
-
# :TARGET_DECLARATION, :PACKET_DECLARATION, :RAW_PACKET, :JSON_PACKET
|
91
|
+
# :TARGET_DECLARATION, :PACKET_DECLARATION, :RAW_PACKET, :JSON_PACKET, :OFFSET_MARKER, :KEY_MAP
|
87
92
|
# @param cmd_or_tlm [Symbol] One of :CMD or :TLM
|
88
93
|
# @param target_name [String] Name of the target
|
89
94
|
# @param packet_name [String] Name of the packet
|
@@ -92,11 +97,11 @@ module OpenC3
|
|
92
97
|
# @param data [String] Binary string of data
|
93
98
|
# @param id [Integer] Target ID
|
94
99
|
# @param redis_offset [Integer] The offset of this packet in its Redis stream
|
95
|
-
def write(entry_type, cmd_or_tlm, target_name, packet_name, time_nsec_since_epoch, stored, data, id = nil, redis_offset = '0-0')
|
100
|
+
def write(entry_type, cmd_or_tlm, target_name, packet_name, time_nsec_since_epoch, stored, data, id = nil, redis_topic = nil, redis_offset = '0-0')
|
96
101
|
return if !@logging_enabled
|
97
102
|
|
98
103
|
@mutex.synchronize do
|
99
|
-
prepare_write(time_nsec_since_epoch, data.length, redis_offset)
|
104
|
+
prepare_write(time_nsec_since_epoch, data.length, redis_topic, redis_offset)
|
100
105
|
write_entry(entry_type, cmd_or_tlm, target_name, packet_name, time_nsec_since_epoch, stored, data, id) if @file
|
101
106
|
end
|
102
107
|
rescue => err
|
@@ -119,10 +124,12 @@ module OpenC3
|
|
119
124
|
|
120
125
|
@cmd_packet_table = {}
|
121
126
|
@tlm_packet_table = {}
|
127
|
+
@key_map_table = {}
|
122
128
|
@next_packet_index = 0
|
123
129
|
@target_indexes = {}
|
124
130
|
@target_dec_entries = []
|
125
131
|
@packet_dec_entries = []
|
132
|
+
@key_map_entries = []
|
126
133
|
Logger.debug "Index Log File Opened : #{@index_filename}"
|
127
134
|
rescue => err
|
128
135
|
Logger.error "Error starting new log file: #{err.formatted}"
|
@@ -131,20 +138,26 @@ module OpenC3
|
|
131
138
|
end
|
132
139
|
|
133
140
|
# Closing a log file isn't critical so we just log an error
|
141
|
+
# Returns threads that moves log to bucket
|
134
142
|
def close_file(take_mutex = true)
|
135
|
-
|
136
|
-
super
|
137
|
-
|
143
|
+
threads = []
|
138
144
|
@mutex.lock if take_mutex
|
139
145
|
begin
|
146
|
+
# Need to write the OFFSET_MARKER for each packet
|
147
|
+
@last_offsets.each do |redis_topic, last_offset|
|
148
|
+
write_entry(:OFFSET_MARKER, nil, nil, nil, nil, nil, last_offset + ',' + redis_topic, nil) if @file
|
149
|
+
end
|
150
|
+
|
151
|
+
threads << super(false)
|
152
|
+
|
140
153
|
if @index_file
|
141
154
|
begin
|
142
155
|
write_index_file_footer()
|
143
156
|
@index_file.close unless @index_file.closed?
|
144
157
|
Logger.debug "Index Log File Closed : #{@index_filename}"
|
145
158
|
date = first_timestamp[0..7] # YYYYMMDD
|
146
|
-
|
147
|
-
|
159
|
+
bucket_key = File.join(@remote_log_directory, date, "#{first_timestamp}__#{last_timestamp}__#{@label}.idx")
|
160
|
+
threads << BucketUtilities.move_log_file_to_bucket(@index_filename, bucket_key)
|
148
161
|
rescue Exception => err
|
149
162
|
Logger.instance.error "Error closing #{@index_filename} : #{err.formatted}"
|
150
163
|
end
|
@@ -155,9 +168,10 @@ module OpenC3
|
|
155
168
|
ensure
|
156
169
|
@mutex.unlock if take_mutex
|
157
170
|
end
|
171
|
+
return threads
|
158
172
|
end
|
159
173
|
|
160
|
-
def get_packet_index(cmd_or_tlm, target_name, packet_name)
|
174
|
+
def get_packet_index(cmd_or_tlm, target_name, packet_name, entry_type, data)
|
161
175
|
if cmd_or_tlm == :CMD
|
162
176
|
target_table = @cmd_packet_table[target_name]
|
163
177
|
else
|
@@ -200,6 +214,26 @@ module OpenC3
|
|
200
214
|
# No packet def
|
201
215
|
end
|
202
216
|
write_entry(:PACKET_DECLARATION, cmd_or_tlm, target_name, packet_name, nil, nil, nil, id)
|
217
|
+
if entry_type == :JSON_PACKET
|
218
|
+
key_map = @key_map_table[packet_index]
|
219
|
+
unless key_map
|
220
|
+
parsed = data
|
221
|
+
parsed = JSON.parse(data, :allow_nan => true, :create_additions => true) if String === parsed
|
222
|
+
keys = parsed.keys
|
223
|
+
key_map = {}
|
224
|
+
reverse_key_map = {}
|
225
|
+
keys.each_with_index do |key, index|
|
226
|
+
key_map[index.to_s] = key
|
227
|
+
reverse_key_map[key] = index.to_s
|
228
|
+
end
|
229
|
+
@key_map_table[packet_index] = reverse_key_map
|
230
|
+
if @data_format == :CBOR
|
231
|
+
write_entry(:KEY_MAP, cmd_or_tlm, target_name, packet_name, nil, nil, key_map.to_cbor, nil)
|
232
|
+
else # JSON
|
233
|
+
write_entry(:KEY_MAP, cmd_or_tlm, target_name, packet_name, nil, nil, JSON.generate(key_map, :allow_nan => true), nil)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
203
237
|
return packet_index
|
204
238
|
end
|
205
239
|
|
@@ -238,19 +272,44 @@ module OpenC3
|
|
238
272
|
@entry << [length, flags, target_index].pack(OPENC3_PACKET_DECLARATION_PACK_DIRECTIVE) << packet_name
|
239
273
|
@entry << [id].pack('H*') if id
|
240
274
|
@packet_dec_entries << @entry.dup
|
275
|
+
when :KEY_MAP
|
276
|
+
flags |= OPENC3_KEY_MAP_ENTRY_TYPE_MASK
|
277
|
+
flags |= OPENC3_CBOR_FLAG_MASK if @data_format == :CBOR
|
278
|
+
length += OPENC3_KEY_MAP_SECONDARY_FIXED_SIZE + data.length
|
279
|
+
packet_index = get_packet_index(cmd_or_tlm, target_name, packet_name, entry_type, data)
|
280
|
+
@entry.clear
|
281
|
+
@entry << [length, flags, packet_index].pack(OPENC3_KEY_MAP_PACK_DIRECTIVE) << data
|
282
|
+
@key_map_entries << @entry.dup
|
241
283
|
when :OFFSET_MARKER
|
242
284
|
flags |= OPENC3_OFFSET_MARKER_ENTRY_TYPE_MASK
|
243
|
-
length += OPENC3_OFFSET_MARKER_SECONDARY_FIXED_SIZE +
|
285
|
+
length += OPENC3_OFFSET_MARKER_SECONDARY_FIXED_SIZE + data.length
|
244
286
|
@entry.clear
|
245
|
-
@entry << [length, flags].pack(OPENC3_OFFSET_MARKER_PACK_DIRECTIVE) <<
|
287
|
+
@entry << [length, flags].pack(OPENC3_OFFSET_MARKER_PACK_DIRECTIVE) << data
|
246
288
|
when :RAW_PACKET, :JSON_PACKET
|
247
289
|
target_name = 'UNKNOWN'.freeze unless target_name
|
248
290
|
packet_name = 'UNKNOWN'.freeze unless packet_name
|
249
|
-
packet_index = get_packet_index(cmd_or_tlm, target_name, packet_name)
|
291
|
+
packet_index = get_packet_index(cmd_or_tlm, target_name, packet_name, entry_type, data)
|
250
292
|
if entry_type == :RAW_PACKET
|
251
293
|
flags |= OPENC3_RAW_PACKET_ENTRY_TYPE_MASK
|
252
294
|
else
|
253
295
|
flags |= OPENC3_JSON_PACKET_ENTRY_TYPE_MASK
|
296
|
+
key_map = @key_map_table[packet_index]
|
297
|
+
if key_map
|
298
|
+
# Compress data using key map
|
299
|
+
data = JSON.parse(data, :allow_nan => true, :create_additions => true) if String === data
|
300
|
+
compressed = {}
|
301
|
+
data.each do |key, value|
|
302
|
+
compressed_key = key_map[key]
|
303
|
+
compressed_key = key unless compressed_key
|
304
|
+
compressed[compressed_key] = value
|
305
|
+
end
|
306
|
+
if @data_format == :CBOR
|
307
|
+
flags |= OPENC3_CBOR_FLAG_MASK
|
308
|
+
data = compressed.to_cbor
|
309
|
+
else
|
310
|
+
data = JSON.generate(compressed, :allow_nan => true)
|
311
|
+
end
|
312
|
+
end
|
254
313
|
end
|
255
314
|
if cmd_or_tlm == :CMD
|
256
315
|
flags |= OPENC3_CMD_FLAG_MASK
|
@@ -285,10 +344,16 @@ module OpenC3
|
|
285
344
|
@index_file.write(packet_dec_entry)
|
286
345
|
footer_length += packet_dec_entry.length
|
287
346
|
end
|
347
|
+
@index_file.write([@key_map_entries.length].pack('n'))
|
348
|
+
footer_length += 2
|
349
|
+
@key_map_entries.each do |key_map_entry|
|
350
|
+
@index_file.write(key_map_entry)
|
351
|
+
footer_length += key_map_entry.length
|
352
|
+
end
|
288
353
|
@index_file.write([footer_length].pack('N'))
|
289
354
|
end
|
290
355
|
|
291
|
-
def
|
356
|
+
def bucket_filename
|
292
357
|
"#{first_timestamp}__#{last_timestamp}__#{@label}" + extension
|
293
358
|
end
|
294
359
|
|
@@ -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/logs/log_writer'
|
21
24
|
|
@@ -31,11 +34,11 @@ module OpenC3
|
|
31
34
|
# @param time_nsec_since_epoch [Integer] 64 bit integer nsecs since EPOCH
|
32
35
|
# @param data [String] String of data
|
33
36
|
# @param redis_offset [Integer] The offset of this packet in its Redis stream
|
34
|
-
def write(time_nsec_since_epoch, data, redis_offset)
|
37
|
+
def write(time_nsec_since_epoch, data, redis_topic, redis_offset)
|
35
38
|
return if !@logging_enabled
|
36
39
|
|
37
40
|
@mutex.synchronize do
|
38
|
-
prepare_write(time_nsec_since_epoch, data.length, redis_offset)
|
41
|
+
prepare_write(time_nsec_since_epoch, data.length, redis_topic, redis_offset)
|
39
42
|
write_entry(time_nsec_since_epoch, data) if @file
|
40
43
|
end
|
41
44
|
rescue => err
|
@@ -53,11 +56,12 @@ module OpenC3
|
|
53
56
|
@last_time = time_nsec_since_epoch if !@last_time or time_nsec_since_epoch > @last_time
|
54
57
|
end
|
55
58
|
|
56
|
-
def
|
59
|
+
def bucket_filename
|
57
60
|
# Put the name of the redis topic in the filename, but remove the scope
|
58
61
|
# because we're already in a directory with the scope name
|
59
|
-
|
60
|
-
|
62
|
+
redis_topic = @last_offsets.keys[0].to_s
|
63
|
+
split_index = redis_topic.index("__") + 2
|
64
|
+
topic_name = redis_topic[split_index, redis_topic.length - split_index]
|
61
65
|
"#{first_timestamp}__#{last_timestamp}__#{topic_name}" + extension
|
62
66
|
end
|
63
67
|
|
data/lib/openc3/logs.rb
CHANGED
@@ -16,10 +16,16 @@
|
|
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
|
-
autoload(:
|
22
|
-
autoload(:
|
24
|
+
autoload(:BufferedPacketLogReader, 'openc3/logs/buffered_packet_log_reader.rb')
|
25
|
+
autoload(:BufferedPacketLogWriter, 'openc3/logs/buffered_packet_log_writer.rb')
|
26
|
+
autoload(:LogWriter, 'openc3/logs/log_writer.rb')
|
27
|
+
autoload(:PacketLogConstants, 'openc3/logs/packet_log_constants.rb')
|
23
28
|
autoload(:PacketLogReader, 'openc3/logs/packet_log_reader.rb')
|
29
|
+
autoload(:PacketLogWriter, 'openc3/logs/packet_log_writer.rb')
|
24
30
|
autoload(:TextLogWriter, 'openc3/logs/text_log_writer.rb')
|
25
31
|
end
|
@@ -16,10 +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/models/target_model'
|
21
24
|
require 'openc3/microservices/microservice'
|
22
|
-
require 'openc3/utilities/
|
25
|
+
require 'openc3/utilities/bucket'
|
26
|
+
require 'openc3/utilities/bucket_utilities'
|
23
27
|
|
24
28
|
module OpenC3
|
25
29
|
class CleanupMicroservice < Microservice
|
@@ -28,33 +32,29 @@ module OpenC3
|
|
28
32
|
target_name = split_name[-1]
|
29
33
|
target = TargetModel.get_model(name: target_name, scope: @scope)
|
30
34
|
|
31
|
-
|
35
|
+
bucket = Bucket.getClient()
|
32
36
|
while true
|
33
37
|
break if @cancel_thread
|
34
38
|
|
35
39
|
@state = 'GETTING_OBJECTS'
|
36
40
|
start_time = Time.now
|
37
41
|
[
|
38
|
-
["#{@scope}/raw_logs/cmd/#{target_name}
|
39
|
-
["#{@scope}/decom_logs/cmd/#{target_name}
|
40
|
-
["#{@scope}/raw_logs/tlm/#{target_name}
|
41
|
-
["#{@scope}/decom_logs/tlm/#{target_name}
|
42
|
-
["#{@scope}/reduced_minute_logs/tlm/#{target_name}
|
43
|
-
["#{@scope}/reduced_hour_logs/tlm/#{target_name}
|
44
|
-
["#{@scope}/reduced_day_logs/tlm/#{target_name}
|
42
|
+
["#{@scope}/raw_logs/cmd/#{target_name}", target.cmd_log_retain_time],
|
43
|
+
["#{@scope}/decom_logs/cmd/#{target_name}", target.cmd_decom_log_retain_time],
|
44
|
+
["#{@scope}/raw_logs/tlm/#{target_name}", target.tlm_log_retain_time],
|
45
|
+
["#{@scope}/decom_logs/tlm/#{target_name}", target.tlm_decom_log_retain_time],
|
46
|
+
["#{@scope}/reduced_minute_logs/tlm/#{target_name}", target.reduced_minute_log_retain_time],
|
47
|
+
["#{@scope}/reduced_hour_logs/tlm/#{target_name}", target.reduced_hour_log_retain_time],
|
48
|
+
["#{@scope}/reduced_day_logs/tlm/#{target_name}", target.reduced_day_log_retain_time],
|
45
49
|
].each do |prefix, retain_time|
|
46
50
|
next unless retain_time
|
47
51
|
time = start_time - retain_time
|
48
|
-
|
49
|
-
|
50
|
-
oldest_list.each do |item|
|
51
|
-
delete_items << { :key => item.key }
|
52
|
-
end
|
53
|
-
if delete_items.length > 0
|
52
|
+
oldest_list = BucketUtilities.list_files_before_time(ENV['OPENC3_LOGS_BUCKET'], prefix, time)
|
53
|
+
if oldest_list.length > 0
|
54
54
|
@state = 'DELETING_OBJECTS'
|
55
|
-
|
56
|
-
|
57
|
-
Logger.info("Deleted #{
|
55
|
+
oldest_list.each_slice(1000) do |slice|
|
56
|
+
bucket.delete_objects(bucket: ENV['OPENC3_LOGS_BUCKET'], keys: slice)
|
57
|
+
Logger.info("Deleted #{slice.length} #{target_name} log files")
|
58
58
|
end
|
59
59
|
end
|
60
60
|
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/microservices/microservice'
|
21
24
|
require 'openc3/topics/telemetry_decom_topic'
|
@@ -33,6 +36,7 @@ module OpenC3
|
|
33
36
|
super(*args)
|
34
37
|
Topic.update_topic_offsets(@topics)
|
35
38
|
System.telemetry.limits_change_callback = method(:limits_change_callback)
|
39
|
+
LimitsEventTopic.sync_system(scope: @scope)
|
36
40
|
end
|
37
41
|
|
38
42
|
def run
|
@@ -40,12 +44,15 @@ module OpenC3
|
|
40
44
|
break if @cancel_thread
|
41
45
|
|
42
46
|
begin
|
43
|
-
|
44
|
-
|
47
|
+
OpenC3.in_span("read_topics") do
|
48
|
+
Topic.read_topics(@topics) do |topic, msg_id, msg_hash, redis|
|
49
|
+
break if @cancel_thread
|
45
50
|
|
46
|
-
|
47
|
-
|
51
|
+
decom_packet(topic, msg_id, msg_hash, redis)
|
52
|
+
@count += 1
|
53
|
+
end
|
48
54
|
end
|
55
|
+
LimitsEventTopic.sync_system_thread_body(scope: @scope)
|
49
56
|
rescue => e
|
50
57
|
@error = e
|
51
58
|
Logger.error("Decom error: #{e.formatted}")
|
@@ -54,23 +61,23 @@ module OpenC3
|
|
54
61
|
end
|
55
62
|
|
56
63
|
def decom_packet(topic, _msg_id, msg_hash, _redis)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
64
|
+
OpenC3.in_span("decom_packet") do
|
65
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
66
|
+
target_name = msg_hash["target_name"]
|
67
|
+
packet_name = msg_hash["packet_name"]
|
68
|
+
|
69
|
+
packet = System.telemetry.packet(target_name, packet_name)
|
70
|
+
packet.stored = ConfigParser.handle_true_false(msg_hash["stored"])
|
71
|
+
packet.received_time = Time.from_nsec_from_epoch(msg_hash["time"].to_i)
|
72
|
+
packet.received_count = msg_hash["received_count"].to_i
|
73
|
+
packet.buffer = msg_hash["buffer"]
|
74
|
+
packet.check_limits(System.limits_set) # Process all the limits and call the limits_change_callback (as necessary)
|
75
|
+
|
76
|
+
TelemetryDecomTopic.write_packet(packet, scope: @scope)
|
77
|
+
diff = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start # seconds as a float
|
78
|
+
metric_labels = { "packet" => packet_name, "target" => target_name }
|
79
|
+
@metric.add_sample(name: DECOM_METRIC_NAME, value: diff, labels: metric_labels)
|
80
|
+
end
|
74
81
|
end
|
75
82
|
|
76
83
|
# Called when an item in any packet changes limits states.
|
@@ -96,7 +103,6 @@ module OpenC3
|
|
96
103
|
when :YELLOW, :YELLOW_LOW, :YELLOW_HIGH
|
97
104
|
Logger.warn message
|
98
105
|
when :RED, :RED_LOW, :RED_HIGH
|
99
|
-
# TODO: Is this necessary? The LimitsEventTopic is what communicates with LimitsMonitor
|
100
106
|
notification = NotificationModel.new(
|
101
107
|
time: time_nsec,
|
102
108
|
severity: "critical",
|
@@ -111,8 +117,8 @@ module OpenC3
|
|
111
117
|
|
112
118
|
# The openc3_limits_events topic can be listened to for all limits events, it is a continuous stream
|
113
119
|
event = { type: :LIMITS_CHANGE, target_name: packet.target_name, packet_name: packet.packet_name,
|
114
|
-
item_name: item.name, old_limits_state: old_limits_state, new_limits_state: item.limits.state,
|
115
|
-
time_nsec: time_nsec, message: message }
|
120
|
+
item_name: item.name, old_limits_state: old_limits_state.to_s, new_limits_state: item.limits.state.to_s,
|
121
|
+
time_nsec: time_nsec, message: message.to_s }
|
116
122
|
LimitsEventTopic.write(event, scope: @scope)
|
117
123
|
|
118
124
|
if item.limits.response
|