From 7c293e0517ff487d057a366e36373427823c5246 Mon Sep 17 00:00:00 2001 From: Jason Thomas Date: Fri, 25 Aug 2023 21:29:07 -0600 Subject: [PATCH 1/4] Various python logs and test install --- .../openc3/logs/buffered_packet_log_writer.rb | 3 +- openc3/lib/openc3/logs/log_writer.rb | 12 +- openc3/python/openc3/interfaces/__init__.py | 0 openc3/python/openc3/interfaces/interface.py | 549 ++++++++++++++++++ openc3/python/openc3/logs/__init__.py | 0 openc3/python/openc3/logs/log_writer.py | 399 +++++++++++++ openc3/python/openc3/logs/stream_log.py | 119 ++++ openc3/python/openc3/logs/stream_log_pair.py | 61 ++ .../packets/parsers/format_string_parser.py | 2 - .../openc3/packets/parsers/limits_parser.py | 2 - .../packets/parsers/limits_response_parser.py | 25 +- .../packets/parsers/packet_item_parser.py | 2 - .../openc3/packets/parsers/packet_parser.py | 2 - .../openc3/packets/parsers/state_parser.py | 2 - openc3/python/openc3/system/system.py | 2 +- openc3/python/openc3/system/target.py | 57 +- openc3/python/openc3/top_level.py | 29 + .../openc3/utilities/bucket_utilities.py | 3 +- openc3/python/openc3/utilities/extract.py | 9 +- openc3/python/openc3/utilities/string.py | 88 ++- openc3/python/openc3/utilities/time.py | 35 ++ openc3/python/requirements-dev.txt | 3 +- openc3/python/requirements.txt | 7 +- openc3/python/ruby_to_python.py | 10 +- openc3/python/test/api/test_cmd_api.py | 5 +- .../python/test/install/config/data/data.txt | 1 + .../test/install/config/system/system.txt | 27 + .../install/config/targets/EMPTY/target.txt | 1 + .../config/targets/INST/cmd_tlm/inst_cmds.txt | 121 ++++ .../config/targets/INST/cmd_tlm/inst_tlm.txt | 206 +++++++ .../config/targets/INST/cmd_tlm_server.txt | 5 + .../config/targets/INST/lib/sim_inst.rb | 314 ++++++++++ .../config/targets/INST/screens/hs.txt | 37 ++ .../install/config/targets/INST/target.txt | 22 + .../targets/SYSTEM/cmd_tlm/limits_groups.txt | 7 + .../targets/SYSTEM/cmd_tlm/meta_tlm.txt | 10 + .../targets/SYSTEM/cmd_tlm/system_cmds.txt | 41 ++ .../targets/SYSTEM/cmd_tlm/system_tlm.txt | 7 + .../config/targets/SYSTEM/cmd_tlm_server.txt | 6 + .../config/targets/SYSTEM/screens/status.txt | 12 + .../install/config/targets/SYSTEM/target.txt | 12 + .../tools/cmd_tlm_server/cmd_tlm_server.txt | 2 + openc3/python/test/install/lib/README.txt | 1 + .../test/install/lib/my_other_test_class.rb | 2 + .../python/test/install/lib/my_test_class.rb | 2 + .../python/test/install/lib/my_test_file.rb | 3 + .../microservices/EXAMPLE/example_target.rb | 127 ++++ openc3/python/test/install/test1.txt | 1 + openc3/python/test/install/test2.txt | 1 + .../python/test/install/tools/DEMO/index.html | 8 + openc3/python/test/logs/__init__.py | 0 openc3/python/test/logs/test_stream_log.py | 143 +++++ .../parsers/test_limits_response_parser.py | 31 +- .../parsers/test_packet_item_parser.py | 12 +- openc3/python/test/test_helper.py | 13 + openc3/python/test/utilities/__init__.py | 0 openc3/python/test/utilities/test_string.py | 161 +++++ openc3/python/test/utilities/test_time.py | 37 ++ .../logs/buffered_packet_log_writer_spec.rb | 110 ++++ openc3/spec/logs/stream_log_spec.rb | 1 + playwright/tests/data-extractor.spec.ts | 4 +- 61 files changed, 2816 insertions(+), 98 deletions(-) create mode 100644 openc3/python/openc3/interfaces/__init__.py create mode 100644 openc3/python/openc3/interfaces/interface.py create mode 100644 openc3/python/openc3/logs/__init__.py create mode 100644 openc3/python/openc3/logs/log_writer.py create mode 100644 openc3/python/openc3/logs/stream_log.py create mode 100644 openc3/python/openc3/logs/stream_log_pair.py create mode 100644 openc3/python/openc3/utilities/time.py create mode 100644 openc3/python/test/install/config/data/data.txt create mode 100644 openc3/python/test/install/config/system/system.txt create mode 100644 openc3/python/test/install/config/targets/EMPTY/target.txt create mode 100644 openc3/python/test/install/config/targets/INST/cmd_tlm/inst_cmds.txt create mode 100644 openc3/python/test/install/config/targets/INST/cmd_tlm/inst_tlm.txt create mode 100644 openc3/python/test/install/config/targets/INST/cmd_tlm_server.txt create mode 100644 openc3/python/test/install/config/targets/INST/lib/sim_inst.rb create mode 100644 openc3/python/test/install/config/targets/INST/screens/hs.txt create mode 100644 openc3/python/test/install/config/targets/INST/target.txt create mode 100644 openc3/python/test/install/config/targets/SYSTEM/cmd_tlm/limits_groups.txt create mode 100644 openc3/python/test/install/config/targets/SYSTEM/cmd_tlm/meta_tlm.txt create mode 100644 openc3/python/test/install/config/targets/SYSTEM/cmd_tlm/system_cmds.txt create mode 100644 openc3/python/test/install/config/targets/SYSTEM/cmd_tlm/system_tlm.txt create mode 100644 openc3/python/test/install/config/targets/SYSTEM/cmd_tlm_server.txt create mode 100644 openc3/python/test/install/config/targets/SYSTEM/screens/status.txt create mode 100644 openc3/python/test/install/config/targets/SYSTEM/target.txt create mode 100644 openc3/python/test/install/config/tools/cmd_tlm_server/cmd_tlm_server.txt create mode 100644 openc3/python/test/install/lib/README.txt create mode 100644 openc3/python/test/install/lib/my_other_test_class.rb create mode 100644 openc3/python/test/install/lib/my_test_class.rb create mode 100644 openc3/python/test/install/lib/my_test_file.rb create mode 100644 openc3/python/test/install/microservices/EXAMPLE/example_target.rb create mode 100644 openc3/python/test/install/test1.txt create mode 100644 openc3/python/test/install/test2.txt create mode 100644 openc3/python/test/install/tools/DEMO/index.html create mode 100644 openc3/python/test/logs/__init__.py create mode 100644 openc3/python/test/logs/test_stream_log.py create mode 100644 openc3/python/test/utilities/__init__.py create mode 100644 openc3/python/test/utilities/test_string.py create mode 100644 openc3/python/test/utilities/test_time.py create mode 100644 openc3/spec/logs/buffered_packet_log_writer_spec.rb diff --git a/openc3/lib/openc3/logs/buffered_packet_log_writer.rb b/openc3/lib/openc3/logs/buffered_packet_log_writer.rb index bfa98e22c..783a554a1 100644 --- a/openc3/lib/openc3/logs/buffered_packet_log_writer.rb +++ b/openc3/lib/openc3/logs/buffered_packet_log_writer.rb @@ -90,8 +90,7 @@ def buffered_write(entry_type, cmd_or_tlm, target_name, packet_name, time_nsec_s end def buffered_first_time_nsec - time = first_time() - return time.to_nsec_from_epoch if time + return @first_time if @first_time return @buffer[0][4] if @buffer[0] return nil end diff --git a/openc3/lib/openc3/logs/log_writer.rb b/openc3/lib/openc3/logs/log_writer.rb index 2db699734..866b28386 100644 --- a/openc3/lib/openc3/logs/log_writer.rb +++ b/openc3/lib/openc3/logs/log_writer.rb @@ -350,20 +350,12 @@ def extension '.log'.freeze end - def first_time - Time.from_nsec_from_epoch(@first_time) - end - - def last_time - Time.from_nsec_from_epoch(@last_time) - end - def first_timestamp - first_time().to_timestamp # "YYYYMMDDHHmmSSNNNNNNNNN" + Time.from_nsec_from_epoch(@first_time).to_timestamp # "YYYYMMDDHHmmSSNNNNNNNNN" end def last_timestamp - last_time().to_timestamp # "YYYYMMDDHHmmSSNNNNNNNNN" + Time.from_nsec_from_epoch(@last_time).to_timestamp # "YYYYMMDDHHmmSSNNNNNNNNN" end end end diff --git a/openc3/python/openc3/interfaces/__init__.py b/openc3/python/openc3/interfaces/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/openc3/python/openc3/interfaces/interface.py b/openc3/python/openc3/interfaces/interface.py new file mode 100644 index 000000000..7bd7c9398 --- /dev/null +++ b/openc3/python/openc3/interfaces/interface.py @@ -0,0 +1,549 @@ +# Copyright 2023 OpenC3, Inc. +# All Rights Reserved. +# +# This program is free software; you can modify and/or redistribute it +# under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation; version 3 with +# attribution addendums as found in the LICENSE.txt +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# This file may also be used under the terms of a commercial license +# if purchased from OpenC3, Inc. + +# require 'openc3/api/api' +# require 'openc3/logs/stream_log_pair' +# require 'openc3/utilities/secrets' + +from datetime import datetime +from threading import Lock +from openc3.api import * +from openc3.utilities.logger import Logger +from openc3.logs.stream_log_pair import StreamLogPair + + +class WriteRejectError(RuntimeError): + pass + # Define a class to allow interfaces and protocols to reject commands without + # disconnecting the interface + + # Defines all the attributes and methods common to all interface classes + # used by OpenC3. + + +class Interface: + # # self.return [String] Name of the interface + # attr_reader :name + + # # self.return [String] State of the interface= CONNECTED, ATTEMPTING, DISCONNECTED + # attr_accessor :state + + # # self.return [Array] Array of target names associated with this interface + # attr_accessor :target_names + + # # self.return [Array] Array of cmd target names associated with this interface + # attr_accessor :cmd_target_names + + # # self.return [Array] Array of tlm target names associated with this interface + # attr_accessor :tlm_target_names + + # # self.return [Boolean] Flag indicating if the interface should be connected: + # # to on startup + # attr_accessor :connect_on_startup + + # # self.return [Boolean] Flag indicating if the interface should automatically: + # # reconnect after losing connection + # attr_accessor :auto_reconnect + + # # self.return [Integer[ Delay between reconnect attempts + # attr_accessor :reconnect_delay + + # # self.return [Boolean] Flag indicating if the user is allowed to disconnect: + # # this interface + # attr_accessor :disable_disconnect + + # # self.return [Array] Array of packet logger classes for this interface + # attr_accessor :packet_log_writer_pairs + + # # self.return [Array] Array of stored packet log writers + # attr_accessor :stored_packet_log_writer_pairs + + # # self.return [StreamLogPair] StreamLogPair instance or None + # attr_accessor :stream_log_pair + + # # self.return [Array] Array of routers that receive packets + # # read from the interface + # attr_accessor :routers + + # # self.return [Array] Array of cmd routers that mirror packets + # # sent from the interface + # attr_accessor :cmd_routers + + # # self.return [Integer] The number of packets read from this interface + # attr_accessor :read_count + + # # self.return [Integer] The number of packets written to this interface + # attr_accessor :write_count + + # # self.return [Integer] The number of bytes read from this interface + # attr_accessor :bytes_read + + # # self.return [Integer] The number of bytes written to this interface + # attr_accessor :bytes_written + + # # self.return [Integer] The number of active clients + # # (when used as a Router) + # attr_accessor :num_clients + + # # self.return [Integer] The number of packets in the read queue + # # (when used as a Router) + # attr_accessor :read_queue_size + + # # self.return [Integer] The number of packets in the write queue + # # (when used as a Router) + # attr_accessor :write_queue_size + + # # self.return [Hash