openc3 5.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +18 -0
- data/Guardfile +35 -0
- data/LICENSE.txt +727 -0
- data/README.md +37 -0
- data/Rakefile +131 -0
- data/bin/cstol_converter +1178 -0
- data/bin/openc3cli +531 -0
- data/bin/rubysloc +139 -0
- data/data/config/_array_params.yaml +23 -0
- data/data/config/_id_items.yaml +24 -0
- data/data/config/_id_params.yaml +58 -0
- data/data/config/_interfaces.yaml +214 -0
- data/data/config/_interfaces.yaml.err +1017 -0
- data/data/config/_items.yaml +20 -0
- data/data/config/_params.yaml +60 -0
- data/data/config/cmd_tlm_server.yaml +136 -0
- data/data/config/command.yaml +44 -0
- data/data/config/command_modifiers.yaml +160 -0
- data/data/config/command_telemetry.yaml +3 -0
- data/data/config/interface_modifiers.yaml +104 -0
- data/data/config/item_modifiers.yaml +221 -0
- data/data/config/microservice.yaml +78 -0
- data/data/config/param_item_modifiers.yaml +52 -0
- data/data/config/parameter_modifiers.yaml +200 -0
- data/data/config/plugins.yaml +80 -0
- data/data/config/protocols.yaml +290 -0
- data/data/config/screen.yaml +147 -0
- data/data/config/table_manager.yaml +89 -0
- data/data/config/table_parameter_modifiers.yaml +9 -0
- data/data/config/target.yaml +142 -0
- data/data/config/target_config.yaml +94 -0
- data/data/config/telemetry.yaml +87 -0
- data/data/config/telemetry_modifiers.yaml +159 -0
- data/data/config/tool.yaml +63 -0
- data/data/config/unknown.yaml +3 -0
- data/data/config/widgets.yaml +1505 -0
- data/ext/mkrf_conf.rb +49 -0
- data/ext/openc3/ext/array/array.c +122 -0
- data/ext/openc3/ext/array/extconf.rb +13 -0
- data/ext/openc3/ext/buffered_file/buffered_file.c +198 -0
- data/ext/openc3/ext/buffered_file/extconf.rb +13 -0
- data/ext/openc3/ext/config_parser/config_parser.c +280 -0
- data/ext/openc3/ext/config_parser/extconf.rb +13 -0
- data/ext/openc3/ext/crc/crc.c +351 -0
- data/ext/openc3/ext/crc/extconf.rb +13 -0
- data/ext/openc3/ext/openc3_io/extconf.rb +13 -0
- data/ext/openc3/ext/openc3_io/openc3_io.c +158 -0
- data/ext/openc3/ext/packet/extconf.rb +13 -0
- data/ext/openc3/ext/packet/packet.c +318 -0
- data/ext/openc3/ext/platform/extconf.rb +13 -0
- data/ext/openc3/ext/platform/platform.c +134 -0
- data/ext/openc3/ext/polynomial_conversion/extconf.rb +13 -0
- data/ext/openc3/ext/polynomial_conversion/polynomial_conversion.c +79 -0
- data/ext/openc3/ext/string/extconf.rb +13 -0
- data/ext/openc3/ext/string/string.c +63 -0
- data/ext/openc3/ext/structure/structure.c +1719 -0
- data/ext/openc3/ext/tabbed_plots_config/extconf.rb +13 -0
- data/ext/openc3/ext/tabbed_plots_config/tabbed_plots_config.c +62 -0
- data/ext/openc3/ext/telemetry/extconf.rb +13 -0
- data/ext/openc3/ext/telemetry/telemetry.c +336 -0
- data/lib/cosmos.rb +20 -0
- data/lib/cosmosc2.rb +20 -0
- data/lib/openc3/api/api.rb +39 -0
- data/lib/openc3/api/authorized_api.rb +30 -0
- data/lib/openc3/api/cmd_api.rb +451 -0
- data/lib/openc3/api/config_api.rb +58 -0
- data/lib/openc3/api/interface_api.rb +117 -0
- data/lib/openc3/api/limits_api.rb +375 -0
- data/lib/openc3/api/router_api.rb +117 -0
- data/lib/openc3/api/settings_api.rb +70 -0
- data/lib/openc3/api/target_api.rb +78 -0
- data/lib/openc3/api/tlm_api.rb +455 -0
- data/lib/openc3/bridge/bridge.rb +54 -0
- data/lib/openc3/bridge/bridge_config.rb +167 -0
- data/lib/openc3/bridge/bridge_interface_thread.rb +42 -0
- data/lib/openc3/bridge/bridge_router_thread.rb +42 -0
- data/lib/openc3/ccsds/ccsds_packet.rb +68 -0
- data/lib/openc3/ccsds/ccsds_parser.rb +148 -0
- data/lib/openc3/config/config_parser.rb +549 -0
- data/lib/openc3/config/meta_config_parser.rb +74 -0
- data/lib/openc3/conversions/conversion.rb +70 -0
- data/lib/openc3/conversions/generic_conversion.rb +83 -0
- data/lib/openc3/conversions/packet_time_formatted_conversion.rb +43 -0
- data/lib/openc3/conversions/packet_time_seconds_conversion.rb +43 -0
- data/lib/openc3/conversions/polynomial_conversion.rb +87 -0
- data/lib/openc3/conversions/processor_conversion.rb +70 -0
- data/lib/openc3/conversions/received_count_conversion.rb +38 -0
- data/lib/openc3/conversions/received_time_formatted_conversion.rb +42 -0
- data/lib/openc3/conversions/received_time_seconds_conversion.rb +42 -0
- data/lib/openc3/conversions/segmented_polynomial_conversion.rb +171 -0
- data/lib/openc3/conversions/unix_time_conversion.rb +68 -0
- data/lib/openc3/conversions/unix_time_formatted_conversion.rb +49 -0
- data/lib/openc3/conversions/unix_time_seconds_conversion.rb +49 -0
- data/lib/openc3/conversions.rb +34 -0
- data/lib/openc3/core_ext/array.rb +416 -0
- data/lib/openc3/core_ext/binding.rb +29 -0
- data/lib/openc3/core_ext/class.rb +72 -0
- data/lib/openc3/core_ext/exception.rb +61 -0
- data/lib/openc3/core_ext/file.rb +83 -0
- data/lib/openc3/core_ext/hash.rb +37 -0
- data/lib/openc3/core_ext/io.rb +134 -0
- data/lib/openc3/core_ext/kernel.rb +42 -0
- data/lib/openc3/core_ext/math.rb +128 -0
- data/lib/openc3/core_ext/matrix.rb +156 -0
- data/lib/openc3/core_ext/objectspace.rb +36 -0
- data/lib/openc3/core_ext/openc3_io.rb +57 -0
- data/lib/openc3/core_ext/range.rb +27 -0
- data/lib/openc3/core_ext/socket.rb +38 -0
- data/lib/openc3/core_ext/string.rb +389 -0
- data/lib/openc3/core_ext/stringio.rb +33 -0
- data/lib/openc3/core_ext/time.rb +508 -0
- data/lib/openc3/core_ext.rb +36 -0
- data/lib/openc3/interfaces/interface.rb +498 -0
- data/lib/openc3/interfaces/linc_interface.rb +475 -0
- data/lib/openc3/interfaces/protocols/burst_protocol.rb +192 -0
- data/lib/openc3/interfaces/protocols/crc_protocol.rb +193 -0
- data/lib/openc3/interfaces/protocols/fixed_protocol.rb +155 -0
- data/lib/openc3/interfaces/protocols/ignore_packet_protocol.rb +56 -0
- data/lib/openc3/interfaces/protocols/length_protocol.rb +165 -0
- data/lib/openc3/interfaces/protocols/override_protocol.rb +60 -0
- data/lib/openc3/interfaces/protocols/preidentified_protocol.rb +206 -0
- data/lib/openc3/interfaces/protocols/protocol.rb +82 -0
- data/lib/openc3/interfaces/protocols/template_protocol.rb +261 -0
- data/lib/openc3/interfaces/protocols/terminated_protocol.rb +93 -0
- data/lib/openc3/interfaces/serial_interface.rb +94 -0
- data/lib/openc3/interfaces/simulated_target_interface.rb +168 -0
- data/lib/openc3/interfaces/stream_interface.rb +81 -0
- data/lib/openc3/interfaces/tcpip_client_interface.rb +69 -0
- data/lib/openc3/interfaces/tcpip_server_interface.rb +629 -0
- data/lib/openc3/interfaces/udp_interface.rb +169 -0
- data/lib/openc3/interfaces.rb +44 -0
- data/lib/openc3/io/buffered_file.rb +109 -0
- data/lib/openc3/io/io_multiplexer.rb +80 -0
- data/lib/openc3/io/json_api_object.rb +208 -0
- data/lib/openc3/io/json_drb.rb +335 -0
- data/lib/openc3/io/json_drb_object.rb +114 -0
- data/lib/openc3/io/json_drb_rack.rb +84 -0
- data/lib/openc3/io/json_rpc.rb +420 -0
- data/lib/openc3/io/openc3_snmp.rb +58 -0
- data/lib/openc3/io/posix_serial_driver.rb +156 -0
- data/lib/openc3/io/raw_logger.rb +167 -0
- data/lib/openc3/io/raw_logger_pair.rb +77 -0
- data/lib/openc3/io/serial_driver.rb +105 -0
- data/lib/openc3/io/stderr.rb +43 -0
- data/lib/openc3/io/stdout.rb +43 -0
- data/lib/openc3/io/udp_sockets.rb +194 -0
- data/lib/openc3/io/win32_serial_driver.rb +196 -0
- data/lib/openc3/logs/log_writer.rb +302 -0
- data/lib/openc3/logs/packet_log_constants.rb +62 -0
- data/lib/openc3/logs/packet_log_reader.rb +345 -0
- data/lib/openc3/logs/packet_log_writer.rb +299 -0
- data/lib/openc3/logs/text_log_writer.rb +68 -0
- data/lib/openc3/logs.rb +25 -0
- data/lib/openc3/microservices/cleanup_microservice.rb +68 -0
- data/lib/openc3/microservices/decom_microservice.rb +136 -0
- data/lib/openc3/microservices/interface_microservice.rb +532 -0
- data/lib/openc3/microservices/log_microservice.rb +108 -0
- data/lib/openc3/microservices/microservice.rb +204 -0
- data/lib/openc3/microservices/plugin_microservice.rb +43 -0
- data/lib/openc3/microservices/reaction_microservice.rb +541 -0
- data/lib/openc3/microservices/reducer_microservice.rb +313 -0
- data/lib/openc3/microservices/router_microservice.rb +44 -0
- data/lib/openc3/microservices/text_log_microservice.rb +84 -0
- data/lib/openc3/microservices/timeline_microservice.rb +363 -0
- data/lib/openc3/microservices/trigger_group_microservice.rb +638 -0
- data/lib/openc3/models/activity_model.rb +319 -0
- data/lib/openc3/models/auth_model.rb +65 -0
- data/lib/openc3/models/cvt_model.rb +185 -0
- data/lib/openc3/models/environment_model.rb +58 -0
- data/lib/openc3/models/gem_model.rb +137 -0
- data/lib/openc3/models/info_model.rb +31 -0
- data/lib/openc3/models/interface_model.rb +281 -0
- data/lib/openc3/models/interface_status_model.rb +117 -0
- data/lib/openc3/models/metadata_model.rb +139 -0
- data/lib/openc3/models/metric_model.rb +59 -0
- data/lib/openc3/models/microservice_model.rb +206 -0
- data/lib/openc3/models/microservice_status_model.rb +74 -0
- data/lib/openc3/models/model.rb +204 -0
- data/lib/openc3/models/note_model.rb +122 -0
- data/lib/openc3/models/notification_model.rb +40 -0
- data/lib/openc3/models/ping_model.rb +35 -0
- data/lib/openc3/models/plugin_model.rb +292 -0
- data/lib/openc3/models/process_status_model.rb +76 -0
- data/lib/openc3/models/reaction_model.rb +322 -0
- data/lib/openc3/models/reducer_model.rb +65 -0
- data/lib/openc3/models/router_model.rb +35 -0
- data/lib/openc3/models/router_status_model.rb +27 -0
- data/lib/openc3/models/scope_model.rb +153 -0
- data/lib/openc3/models/settings_model.rb +55 -0
- data/lib/openc3/models/sorted_model.rb +167 -0
- data/lib/openc3/models/target_model.rb +759 -0
- data/lib/openc3/models/timeline_model.rb +154 -0
- data/lib/openc3/models/tool_config_model.rb +38 -0
- data/lib/openc3/models/tool_model.rb +262 -0
- data/lib/openc3/models/trigger_group_model.rb +186 -0
- data/lib/openc3/models/trigger_model.rb +330 -0
- data/lib/openc3/models/widget_model.rb +138 -0
- data/lib/openc3/operators/microservice_operator.rb +128 -0
- data/lib/openc3/operators/operator.rb +277 -0
- data/lib/openc3/packets/binary_accessor.rb +1207 -0
- data/lib/openc3/packets/commands.rb +373 -0
- data/lib/openc3/packets/json_packet.rb +134 -0
- data/lib/openc3/packets/limits.rb +271 -0
- data/lib/openc3/packets/limits_response.rb +53 -0
- data/lib/openc3/packets/packet.rb +1168 -0
- data/lib/openc3/packets/packet_config.rb +625 -0
- data/lib/openc3/packets/packet_item.rb +586 -0
- data/lib/openc3/packets/packet_item_limits.rb +162 -0
- data/lib/openc3/packets/parsers/format_string_parser.rb +65 -0
- data/lib/openc3/packets/parsers/limits_parser.rb +159 -0
- data/lib/openc3/packets/parsers/limits_response_parser.rb +61 -0
- data/lib/openc3/packets/parsers/packet_item_parser.rb +272 -0
- data/lib/openc3/packets/parsers/packet_parser.rb +134 -0
- data/lib/openc3/packets/parsers/processor_parser.rb +73 -0
- data/lib/openc3/packets/parsers/state_parser.rb +127 -0
- data/lib/openc3/packets/parsers/xtce_converter.rb +442 -0
- data/lib/openc3/packets/parsers/xtce_parser.rb +722 -0
- data/lib/openc3/packets/structure.rb +553 -0
- data/lib/openc3/packets/structure_item.rb +365 -0
- data/lib/openc3/packets/telemetry.rb +487 -0
- data/lib/openc3/processors/processor.rb +86 -0
- data/lib/openc3/processors/statistics_processor.rb +82 -0
- data/lib/openc3/processors/watermark_processor.rb +58 -0
- data/lib/openc3/processors.rb +24 -0
- data/lib/openc3/script/api_shared.rb +828 -0
- data/lib/openc3/script/calendar.rb +89 -0
- data/lib/openc3/script/commands.rb +227 -0
- data/lib/openc3/script/exceptions.rb +29 -0
- data/lib/openc3/script/extract.rb +161 -0
- data/lib/openc3/script/limits.rb +60 -0
- data/lib/openc3/script/script.rb +299 -0
- data/lib/openc3/script/script_runner.rb +238 -0
- data/lib/openc3/script/storage.rb +146 -0
- data/lib/openc3/script/suite.rb +542 -0
- data/lib/openc3/script/suite_results.rb +196 -0
- data/lib/openc3/script/suite_runner.rb +217 -0
- data/lib/openc3/script.rb +21 -0
- data/lib/openc3/streams/serial_stream.rb +167 -0
- data/lib/openc3/streams/stream.rb +63 -0
- data/lib/openc3/streams/tcpip_client_stream.rb +116 -0
- data/lib/openc3/streams/tcpip_socket_stream.rb +195 -0
- data/lib/openc3/system/system.rb +127 -0
- data/lib/openc3/system/system_config.rb +411 -0
- data/lib/openc3/system/target.rb +269 -0
- data/lib/openc3/system.rb +24 -0
- data/lib/openc3/tools/cmd_tlm_server/api.rb +20 -0
- data/lib/openc3/tools/cmd_tlm_server/cmd_tlm_server_config.rb +320 -0
- data/lib/openc3/tools/cmd_tlm_server/interface_thread.rb +294 -0
- data/lib/openc3/tools/table_manager/table.rb +77 -0
- data/lib/openc3/tools/table_manager/table_config.rb +273 -0
- data/lib/openc3/tools/table_manager/table_item.rb +90 -0
- data/lib/openc3/tools/table_manager/table_item_parser.rb +66 -0
- data/lib/openc3/tools/table_manager/table_manager_core.rb +333 -0
- data/lib/openc3/tools/table_manager/table_parser.rb +93 -0
- data/lib/openc3/tools/test_runner/test.rb +67 -0
- data/lib/openc3/top_level.rb +595 -0
- data/lib/openc3/topics/autonomic_topic.rb +52 -0
- data/lib/openc3/topics/calendar_topic.rb +44 -0
- data/lib/openc3/topics/command_decom_topic.rb +76 -0
- data/lib/openc3/topics/command_topic.rb +83 -0
- data/lib/openc3/topics/config_topic.rb +68 -0
- data/lib/openc3/topics/interface_topic.rb +73 -0
- data/lib/openc3/topics/limits_event_topic.rb +109 -0
- data/lib/openc3/topics/notifications_topic.rb +28 -0
- data/lib/openc3/topics/router_topic.rb +85 -0
- data/lib/openc3/topics/telemetry_decom_topic.rb +54 -0
- data/lib/openc3/topics/telemetry_topic.rb +36 -0
- data/lib/openc3/topics/timeline_topic.rb +45 -0
- data/lib/openc3/topics/topic.rb +53 -0
- data/lib/openc3/utilities/authentication.rb +141 -0
- data/lib/openc3/utilities/authorization.rb +51 -0
- data/lib/openc3/utilities/crc.rb +278 -0
- data/lib/openc3/utilities/csv.rb +153 -0
- data/lib/openc3/utilities/logger.rb +187 -0
- data/lib/openc3/utilities/message_log.rb +91 -0
- data/lib/openc3/utilities/metric.rb +141 -0
- data/lib/openc3/utilities/process_manager.rb +139 -0
- data/lib/openc3/utilities/quaternion.rb +257 -0
- data/lib/openc3/utilities/ruby_lex_utils.rb +568 -0
- data/lib/openc3/utilities/s3.rb +202 -0
- data/lib/openc3/utilities/s3_autoload.rb +9 -0
- data/lib/openc3/utilities/s3_file_cache.rb +274 -0
- data/lib/openc3/utilities/simulated_target.rb +117 -0
- data/lib/openc3/utilities/sleeper.rb +51 -0
- data/lib/openc3/utilities/store.rb +23 -0
- data/lib/openc3/utilities/store_autoload.rb +237 -0
- data/lib/openc3/utilities/zip.rb +21 -0
- data/lib/openc3/utilities.rb +35 -0
- data/lib/openc3/version.rb +14 -0
- data/lib/openc3/win32/excel.rb +132 -0
- data/lib/openc3/win32/win32.rb +402 -0
- data/lib/openc3/win32/win32_main.rb +333 -0
- data/lib/openc3.rb +49 -0
- data/tasks/gemfile_stats.rake +113 -0
- data/tasks/spec.rake +30 -0
- data/templates/plugin-template/README.md +15 -0
- data/templates/plugin-template/Rakefile +12 -0
- data/templates/plugin-template/plugin.gemspec +23 -0
- data/templates/plugin-template/plugin.txt +9 -0
- data/templates/plugin-template/targets/TARGET/cmd_tlm/cmd.txt +8 -0
- data/templates/plugin-template/targets/TARGET/cmd_tlm/tlm.txt +8 -0
- data/templates/plugin-template/targets/TARGET/lib/target.rb +10 -0
- data/templates/plugin-template/targets/TARGET/procedures/procedure.rb +3 -0
- data/templates/plugin-template/targets/TARGET/screens/status.txt +9 -0
- data/templates/plugin-template/targets/TARGET/target.txt +5 -0
- metadata +849 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# encoding: ascii-8bit
|
|
2
|
+
|
|
3
|
+
# Copyright 2022 Ball Aerospace & Technologies Corp.
|
|
4
|
+
# All Rights Reserved.
|
|
5
|
+
#
|
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
|
7
|
+
# under the terms of the GNU Affero General Public License
|
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
|
10
|
+
#
|
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU Affero General Public License for more details.
|
|
15
|
+
|
|
16
|
+
# Modified by OpenC3, Inc.
|
|
17
|
+
# All changes Copyright 2022, OpenC3, Inc.
|
|
18
|
+
# All Rights Reserved
|
|
19
|
+
|
|
20
|
+
require 'openc3/conversions/conversion'
|
|
21
|
+
require 'openc3/packets/binary_accessor'
|
|
22
|
+
|
|
23
|
+
module OpenC3
|
|
24
|
+
# Performs a generic conversion by evaluating Ruby code
|
|
25
|
+
class GenericConversion < Conversion
|
|
26
|
+
# @return [String] The Ruby code to evaluate which should return the
|
|
27
|
+
# converted value
|
|
28
|
+
attr_accessor :code_to_eval
|
|
29
|
+
|
|
30
|
+
# @param code_to_eval [String] The Ruby code to evaluate which should
|
|
31
|
+
# return the converted value
|
|
32
|
+
# @param converted_type [Symbol] The converted data type. Must be one of
|
|
33
|
+
# {BinaryAccessor::DATA_TYPES}
|
|
34
|
+
# @param converted_bit_size [Integer] The size in bits of the converted
|
|
35
|
+
# value
|
|
36
|
+
# @param converted_array_size [Integer] The size in bits of the converted array
|
|
37
|
+
# value (full size of all items if array)
|
|
38
|
+
def initialize(code_to_eval, converted_type = nil, converted_bit_size = nil, converted_array_size = nil)
|
|
39
|
+
super()
|
|
40
|
+
@code_to_eval = code_to_eval
|
|
41
|
+
if ConfigParser.handle_nil(converted_type)
|
|
42
|
+
converted_type = converted_type.to_s.upcase.intern
|
|
43
|
+
raise "Invalid type #{converted_type}" unless BinaryAccessor::DATA_TYPES.include?(converted_type)
|
|
44
|
+
|
|
45
|
+
@converted_type = converted_type
|
|
46
|
+
end
|
|
47
|
+
@converted_bit_size = Integer(converted_bit_size) if ConfigParser.handle_nil(converted_bit_size)
|
|
48
|
+
@converted_array_size = Integer(converted_array_size) if ConfigParser.handle_nil(converted_array_size)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# (see OpenC3::Conversion#call)
|
|
52
|
+
def call(value, packet, buffer)
|
|
53
|
+
myself = packet # For backwards compatibility
|
|
54
|
+
if true or myself # Remove unused variable warning for myself
|
|
55
|
+
return eval(@code_to_eval)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# @return [String] The conversion class followed by the code to evaluate
|
|
60
|
+
def to_s
|
|
61
|
+
"#{@code_to_eval}"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# @param (see Conversion#to_config)
|
|
65
|
+
# @return [String] Config fragment for this conversion
|
|
66
|
+
def to_config(read_or_write)
|
|
67
|
+
config = " GENERIC_#{read_or_write}_CONVERSION_START"
|
|
68
|
+
config << " #{@converted_type}" if @converted_type
|
|
69
|
+
config << " #{@converted_bit_size}" if @converted_bit_size
|
|
70
|
+
config << " #{@converted_array_size}" if @converted_array_size
|
|
71
|
+
config << "\n"
|
|
72
|
+
config << @code_to_eval
|
|
73
|
+
config << " GENERIC_#{read_or_write}_CONVERSION_END\n"
|
|
74
|
+
config
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def as_json(*a)
|
|
78
|
+
result = super(*a)
|
|
79
|
+
result['params'] = [@code_to_eval, @converted_type, @converted_bit_size, @converted_array_size]
|
|
80
|
+
result
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# encoding: ascii-8bit
|
|
2
|
+
|
|
3
|
+
# Copyright 2022 Ball Aerospace & Technologies Corp.
|
|
4
|
+
# All Rights Reserved.
|
|
5
|
+
#
|
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
|
7
|
+
# under the terms of the GNU Affero General Public License
|
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
|
10
|
+
#
|
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU Affero General Public License for more details.
|
|
15
|
+
|
|
16
|
+
# Modified by OpenC3, Inc.
|
|
17
|
+
# All changes Copyright 2022, OpenC3, Inc.
|
|
18
|
+
# All Rights Reserved
|
|
19
|
+
|
|
20
|
+
require 'openc3/conversions/conversion'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
# Converts the packet received time object into a formatted string.
|
|
24
|
+
class PacketTimeFormattedConversion < Conversion
|
|
25
|
+
# Initializes converted_type to :STRING and converted_bit_size to 0
|
|
26
|
+
def initialize
|
|
27
|
+
super()
|
|
28
|
+
@converted_type = :STRING
|
|
29
|
+
@converted_bit_size = 0
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# @param (see Conversion#call)
|
|
33
|
+
# @return [String] Formatted packet time
|
|
34
|
+
def call(value, packet, buffer)
|
|
35
|
+
packet_time = packet.packet_time
|
|
36
|
+
if packet_time
|
|
37
|
+
return packet_time.formatted
|
|
38
|
+
else
|
|
39
|
+
return 'No Packet Time'
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end # class PacketTimeFormattedConversion
|
|
43
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# encoding: ascii-8bit
|
|
2
|
+
|
|
3
|
+
# Copyright 2022 Ball Aerospace & Technologies Corp.
|
|
4
|
+
# All Rights Reserved.
|
|
5
|
+
#
|
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
|
7
|
+
# under the terms of the GNU Affero General Public License
|
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
|
10
|
+
#
|
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU Affero General Public License for more details.
|
|
15
|
+
|
|
16
|
+
# Modified by OpenC3, Inc.
|
|
17
|
+
# All changes Copyright 2022, OpenC3, Inc.
|
|
18
|
+
# All Rights Reserved
|
|
19
|
+
|
|
20
|
+
require 'openc3/conversions/conversion'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
# Converts the packet received time into floating point seconds.
|
|
24
|
+
class PacketTimeSecondsConversion < Conversion
|
|
25
|
+
# Initializes converted_type to :FLOAT and converted_bit_size to 64
|
|
26
|
+
def initialize
|
|
27
|
+
super()
|
|
28
|
+
@converted_type = :FLOAT
|
|
29
|
+
@converted_bit_size = 64
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# @param (see Conversion#call)
|
|
33
|
+
# @return [Float] Packet received time in seconds
|
|
34
|
+
def call(value, packet, buffer)
|
|
35
|
+
packet_time = packet.packet_time
|
|
36
|
+
if packet_time
|
|
37
|
+
return packet_time.to_f
|
|
38
|
+
else
|
|
39
|
+
return 0.0
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end # class PacketTimeSecondsConversion
|
|
43
|
+
end
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# encoding: ascii-8bit
|
|
2
|
+
|
|
3
|
+
# Copyright 2022 Ball Aerospace & Technologies Corp.
|
|
4
|
+
# All Rights Reserved.
|
|
5
|
+
#
|
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
|
7
|
+
# under the terms of the GNU Affero General Public License
|
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
|
10
|
+
#
|
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU Affero General Public License for more details.
|
|
15
|
+
|
|
16
|
+
# Modified by OpenC3, Inc.
|
|
17
|
+
# All changes Copyright 2022, OpenC3, Inc.
|
|
18
|
+
# All Rights Reserved
|
|
19
|
+
|
|
20
|
+
require 'openc3/conversions/conversion'
|
|
21
|
+
require 'openc3/ext/polynomial_conversion' if RUBY_ENGINE == 'ruby' and !ENV['OPENC3_NO_EXT']
|
|
22
|
+
|
|
23
|
+
module OpenC3
|
|
24
|
+
# Performs a polynomial conversion on the value
|
|
25
|
+
class PolynomialConversion < Conversion
|
|
26
|
+
# @return [Array<Float>] The polynomial coefficients
|
|
27
|
+
attr_accessor :coeffs
|
|
28
|
+
|
|
29
|
+
# Initializes the conversion with the given polynomial coefficients. Sets
|
|
30
|
+
# the converted_type to :FLOAT and the converted_bit_size to 64.
|
|
31
|
+
#
|
|
32
|
+
# @param coeffs [Array<Float>] The polynomial coefficients
|
|
33
|
+
def initialize(*coeffs)
|
|
34
|
+
super()
|
|
35
|
+
@coeffs = coeffs.map { |coeff| coeff.to_f }
|
|
36
|
+
@converted_type = :FLOAT
|
|
37
|
+
@converted_bit_size = 64
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
if RUBY_ENGINE != 'ruby' or ENV['OPENC3_NO_EXT']
|
|
41
|
+
# @param (see Conversion#call)
|
|
42
|
+
# @return [Float] The value with the polynomial applied
|
|
43
|
+
def call(value, myself, buffer)
|
|
44
|
+
value = value.to_f
|
|
45
|
+
|
|
46
|
+
# Handle C0
|
|
47
|
+
result = @coeffs[0]
|
|
48
|
+
|
|
49
|
+
# Handle Coefficients raised to a power
|
|
50
|
+
raised_to_power = 1.0
|
|
51
|
+
@coeffs[1..-1].each do |coeff|
|
|
52
|
+
raised_to_power *= value
|
|
53
|
+
result += (coeff * raised_to_power)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
return result
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# @return [String] Class followed by the list of coefficients
|
|
61
|
+
def to_s
|
|
62
|
+
result = ""
|
|
63
|
+
@coeffs.length.times do |index|
|
|
64
|
+
if index == 0
|
|
65
|
+
result << "#{@coeffs[index]}"
|
|
66
|
+
elsif index == 1
|
|
67
|
+
result << " + #{@coeffs[index]}x"
|
|
68
|
+
else
|
|
69
|
+
result << " + #{@coeffs[index]}x^#{index}"
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
result
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# @param (see Conversion#to_config)
|
|
76
|
+
# @return [String] Config fragment for this conversion
|
|
77
|
+
def to_config(read_or_write)
|
|
78
|
+
" POLY_#{read_or_write}_CONVERSION #{@coeffs.join(' ')}\n"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def as_json(*a)
|
|
82
|
+
result = super(*a)
|
|
83
|
+
result['params'] = @coeffs
|
|
84
|
+
result
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# encoding: ascii-8bit
|
|
2
|
+
|
|
3
|
+
# Copyright 2022 Ball Aerospace & Technologies Corp.
|
|
4
|
+
# All Rights Reserved.
|
|
5
|
+
#
|
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
|
7
|
+
# under the terms of the GNU Affero General Public License
|
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
|
10
|
+
#
|
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU Affero General Public License for more details.
|
|
15
|
+
|
|
16
|
+
# Modified by OpenC3, Inc.
|
|
17
|
+
# All changes Copyright 2022, OpenC3, Inc.
|
|
18
|
+
# All Rights Reserved
|
|
19
|
+
|
|
20
|
+
require 'openc3/conversions/conversion'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
# Retrieves the result from an item processor
|
|
24
|
+
class ProcessorConversion < Conversion
|
|
25
|
+
# @param processor_name [String] The name of the associated processor
|
|
26
|
+
# @param result_name [String] The name of the associated result in the processor
|
|
27
|
+
# @param converted_type [String or nil] The datatype of the result of the processor
|
|
28
|
+
# @param converted_bit_size [Integer or nil] The bit size of the result of the processor
|
|
29
|
+
# @param converted_array_size [Integer or nil] The total array bit size of the result of the processor
|
|
30
|
+
def initialize(processor_name, result_name, converted_type = nil, converted_bit_size = nil, converted_array_size = nil)
|
|
31
|
+
super()
|
|
32
|
+
@processor_name = processor_name.to_s.upcase
|
|
33
|
+
@result_name = result_name.to_s.upcase.intern
|
|
34
|
+
if ConfigParser.handle_nil(converted_type)
|
|
35
|
+
@converted_type = converted_type.to_s.upcase.intern
|
|
36
|
+
raise ArgumentError, "Unknown converted type: #{converted_type}" if !BinaryAccessor::DATA_TYPES.include?(@converted_type)
|
|
37
|
+
end
|
|
38
|
+
@converted_bit_size = Integer(converted_bit_size) if ConfigParser.handle_nil(converted_bit_size)
|
|
39
|
+
@converted_array_size = Integer(converted_array_size) if ConfigParser.handle_nil(converted_array_size)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# @param (see Conversion#call)
|
|
43
|
+
# @return [Varies] The result of the associated processor
|
|
44
|
+
def call(value, packet, buffer)
|
|
45
|
+
packet.processors[@processor_name].results[@result_name] || 0 # Never return nil
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# @return [String] The type of processor
|
|
49
|
+
def to_s
|
|
50
|
+
"ProcessorConversion #{@processor_name} #{@result_name}"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# @param (see Conversion#to_config)
|
|
54
|
+
# @return [String] Config fragment for this conversion
|
|
55
|
+
def to_config(read_or_write)
|
|
56
|
+
config = " #{read_or_write}_CONVERSION #{self.class.name.class_name_to_filename} #{@processor_name} #{@result_name}"
|
|
57
|
+
config << " #{@converted_type}" if @converted_type
|
|
58
|
+
config << " #{@converted_bit_size}" if @converted_bit_size
|
|
59
|
+
config << " #{@converted_array_size}" if @converted_array_size
|
|
60
|
+
config << "\n"
|
|
61
|
+
config
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def as_json(*a)
|
|
65
|
+
result = super(*a)
|
|
66
|
+
result['params'] = [@processor_name, @result_name, @converted_type, @converted_bit_size, @converted_array_size]
|
|
67
|
+
result
|
|
68
|
+
end
|
|
69
|
+
end # class ProcessorConversion
|
|
70
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# encoding: ascii-8bit
|
|
2
|
+
|
|
3
|
+
# Copyright 2022 Ball Aerospace & Technologies Corp.
|
|
4
|
+
# All Rights Reserved.
|
|
5
|
+
#
|
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
|
7
|
+
# under the terms of the GNU Affero General Public License
|
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
|
10
|
+
#
|
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU Affero General Public License for more details.
|
|
15
|
+
|
|
16
|
+
# Modified by OpenC3, Inc.
|
|
17
|
+
# All changes Copyright 2022, OpenC3, Inc.
|
|
18
|
+
# All Rights Reserved
|
|
19
|
+
|
|
20
|
+
require 'openc3/conversions/conversion'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
# Converts the packet received count as a derived telemetry item
|
|
24
|
+
class ReceivedCountConversion < Conversion
|
|
25
|
+
# Initializes converted_type to :UINT and converted_bit_size to 32
|
|
26
|
+
def initialize
|
|
27
|
+
super()
|
|
28
|
+
@converted_type = :UINT
|
|
29
|
+
@converted_bit_size = 32
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# @param (see Conversion#call)
|
|
33
|
+
# @return [Integer] packet.received_count
|
|
34
|
+
def call(value, packet, buffer)
|
|
35
|
+
packet.received_count
|
|
36
|
+
end
|
|
37
|
+
end # class ReceivedCountConversion
|
|
38
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# encoding: ascii-8bit
|
|
2
|
+
|
|
3
|
+
# Copyright 2022 Ball Aerospace & Technologies Corp.
|
|
4
|
+
# All Rights Reserved.
|
|
5
|
+
#
|
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
|
7
|
+
# under the terms of the GNU Affero General Public License
|
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
|
10
|
+
#
|
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU Affero General Public License for more details.
|
|
15
|
+
|
|
16
|
+
# Modified by OpenC3, Inc.
|
|
17
|
+
# All changes Copyright 2022, OpenC3, Inc.
|
|
18
|
+
# All Rights Reserved
|
|
19
|
+
|
|
20
|
+
require 'openc3/conversions/conversion'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
# Converts the packet received time object into a formatted string.
|
|
24
|
+
class ReceivedTimeFormattedConversion < Conversion
|
|
25
|
+
# Initializes converted_type to :STRING and converted_bit_size to 0
|
|
26
|
+
def initialize
|
|
27
|
+
super()
|
|
28
|
+
@converted_type = :STRING
|
|
29
|
+
@converted_bit_size = 0
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# @param (see Conversion#call)
|
|
33
|
+
# @return [String] Formatted packet time
|
|
34
|
+
def call(value, packet, buffer)
|
|
35
|
+
if packet.received_time
|
|
36
|
+
return packet.received_time.formatted
|
|
37
|
+
else
|
|
38
|
+
return 'No Packet Received Time'
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end # class ReceivedTimeFormattedConversion
|
|
42
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# encoding: ascii-8bit
|
|
2
|
+
|
|
3
|
+
# Copyright 2022 Ball Aerospace & Technologies Corp.
|
|
4
|
+
# All Rights Reserved.
|
|
5
|
+
#
|
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
|
7
|
+
# under the terms of the GNU Affero General Public License
|
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
|
10
|
+
#
|
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU Affero General Public License for more details.
|
|
15
|
+
|
|
16
|
+
# Modified by OpenC3, Inc.
|
|
17
|
+
# All changes Copyright 2022, OpenC3, Inc.
|
|
18
|
+
# All Rights Reserved
|
|
19
|
+
|
|
20
|
+
require 'openc3/conversions/conversion'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
# Converts the packet received time into floating point seconds.
|
|
24
|
+
class ReceivedTimeSecondsConversion < Conversion
|
|
25
|
+
# Initializes converted_type to :FLOAT and converted_bit_size to 64
|
|
26
|
+
def initialize
|
|
27
|
+
super()
|
|
28
|
+
@converted_type = :FLOAT
|
|
29
|
+
@converted_bit_size = 64
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# @param (see Conversion#call)
|
|
33
|
+
# @return [Float] Packet received time in seconds
|
|
34
|
+
def call(value, packet, buffer)
|
|
35
|
+
if packet.received_time
|
|
36
|
+
return packet.received_time.to_f
|
|
37
|
+
else
|
|
38
|
+
return 0.0
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end # class ReceivedTimeSecondsConversion
|
|
42
|
+
end
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# encoding: ascii-8bit
|
|
2
|
+
|
|
3
|
+
# Copyright 2022 Ball Aerospace & Technologies Corp.
|
|
4
|
+
# All Rights Reserved.
|
|
5
|
+
#
|
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
|
7
|
+
# under the terms of the GNU Affero General Public License
|
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
|
10
|
+
#
|
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU Affero General Public License for more details.
|
|
15
|
+
|
|
16
|
+
# Modified by OpenC3, Inc.
|
|
17
|
+
# All changes Copyright 2022, OpenC3, Inc.
|
|
18
|
+
# All Rights Reserved
|
|
19
|
+
|
|
20
|
+
require 'openc3/conversions/conversion'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
# Segmented polynomial conversions consist of polynomial conversions that are
|
|
24
|
+
# applied for a range of values.
|
|
25
|
+
class SegmentedPolynomialConversion < Conversion
|
|
26
|
+
# @return [Array<Segment>] Segments which make up this conversion
|
|
27
|
+
attr_reader :segments
|
|
28
|
+
|
|
29
|
+
# A polynomial conversion segment which applies the conversion from the
|
|
30
|
+
# lower bound (inclusive) until another segment's lower bound is
|
|
31
|
+
# encountered.
|
|
32
|
+
class Segment
|
|
33
|
+
# @return [Integer] The value at which point this polynomial conversion
|
|
34
|
+
# should apply. All values >= to this value will be converted using the
|
|
35
|
+
# given coefficients.
|
|
36
|
+
attr_reader :lower_bound
|
|
37
|
+
|
|
38
|
+
# @return [Array<Integer>] The polynomial coefficients
|
|
39
|
+
attr_reader :coeffs
|
|
40
|
+
|
|
41
|
+
# Creates a polynomial conversion segment. Multiple Segments are used to
|
|
42
|
+
# implemnt a {SegmentedPolynomialConversion}.
|
|
43
|
+
#
|
|
44
|
+
# @param lower_bound [Integer] The value at which point this polynomial conversion
|
|
45
|
+
# should apply. All values >= to this value will be converted using the
|
|
46
|
+
# given coefficients.
|
|
47
|
+
# @param coeffs [Array<Integer>] The polynomial coefficients
|
|
48
|
+
def initialize(lower_bound, coeffs)
|
|
49
|
+
@lower_bound = lower_bound
|
|
50
|
+
@coeffs = coeffs
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Implement the comparison operator to compared based on the lower_bound
|
|
54
|
+
# but sort in reverse order so the segment with the largest lower_bound
|
|
55
|
+
# comes first. This makes the calculation code in call easier.
|
|
56
|
+
#
|
|
57
|
+
# @param other_segment [Segment] The segment to compare
|
|
58
|
+
# @return [Integer] 1 if self.lower_bound > other_segment.lower_bound, 0
|
|
59
|
+
# if they are equal, -1 if self.lower_bound < other_segment.lower_bound
|
|
60
|
+
def <=>(other_segment)
|
|
61
|
+
return other_segment.lower_bound <=> @lower_bound
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Implement equality operator primarily for ease of testing
|
|
65
|
+
#
|
|
66
|
+
# @param segment [Segment] Other segment
|
|
67
|
+
def ==(other_segment)
|
|
68
|
+
@lower_bound == other_segment.lower_bound &&
|
|
69
|
+
@coeffs == other_segment.coeffs
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Perform the polynomial conversion
|
|
73
|
+
#
|
|
74
|
+
# @param value [Numeric] The value to convert
|
|
75
|
+
# @return [Float] The converted value
|
|
76
|
+
def calculate(value)
|
|
77
|
+
converted = 0.0
|
|
78
|
+
@coeffs.length.times do |index|
|
|
79
|
+
converted += @coeffs[index].to_f * (value**index)
|
|
80
|
+
end
|
|
81
|
+
return converted
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Initialize the converted_type to :FLOAT and converted_bit_size to 64.
|
|
86
|
+
#
|
|
87
|
+
# @param segments [Array] Array of segments typically generated by as_json
|
|
88
|
+
# Format similar to the following: [[15, [3, 2]], [10, [1, 2]]]
|
|
89
|
+
# Where each entry is an array with the first value as the lower_bound
|
|
90
|
+
# and the other entry is an array of the coefficients for that segment.
|
|
91
|
+
def initialize(segments = [])
|
|
92
|
+
super()
|
|
93
|
+
@segments = []
|
|
94
|
+
segments.each { |lower_bound, coeffs| add_segment(lower_bound, *coeffs) }
|
|
95
|
+
@converted_type = :FLOAT
|
|
96
|
+
@converted_bit_size = 64
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Add a segment to the segmented polynomial. The lower bound is inclusive, but
|
|
100
|
+
# is ignored for the segment with the lowest lower_bound.
|
|
101
|
+
#
|
|
102
|
+
# @param lower_bound [Integer] The value at which point this polynomial conversion
|
|
103
|
+
# should apply. All values >= to this value will be converted using the
|
|
104
|
+
# given coefficients.
|
|
105
|
+
# @param coeffs [Array<Integer>] The polynomial coefficients
|
|
106
|
+
def add_segment(lower_bound, *coeffs)
|
|
107
|
+
@segments << Segment.new(lower_bound, coeffs)
|
|
108
|
+
@segments.sort!
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# @param (see Conversion#call)
|
|
112
|
+
# @return [Float] The value with the polynomial applied
|
|
113
|
+
def call(value, packet, buffer)
|
|
114
|
+
# Try to find correct segment
|
|
115
|
+
@segments.each do |segment|
|
|
116
|
+
return segment.calculate(value) if value >= segment.lower_bound
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Default to using segment with smallest lower_bound
|
|
120
|
+
segment = @segments[-1]
|
|
121
|
+
if segment
|
|
122
|
+
return @segments[-1].calculate(value)
|
|
123
|
+
else
|
|
124
|
+
return nil
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# @return [String] The name of the class followed by a description of all
|
|
129
|
+
# the polynomial segments.
|
|
130
|
+
def to_s
|
|
131
|
+
result = ''
|
|
132
|
+
count = 0
|
|
133
|
+
@segments.each do |segment|
|
|
134
|
+
result << "\n" if count > 0
|
|
135
|
+
result << "Lower Bound: #{segment.lower_bound} Polynomial: "
|
|
136
|
+
segment.coeffs.length.times do |index|
|
|
137
|
+
if index == 0
|
|
138
|
+
result << "#{segment.coeffs[index]}"
|
|
139
|
+
elsif index == 1
|
|
140
|
+
result << " + #{segment.coeffs[index]}x"
|
|
141
|
+
else
|
|
142
|
+
result << " + #{segment.coeffs[index]}x^#{index}"
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
count += 1
|
|
146
|
+
end
|
|
147
|
+
result
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# @param (see Conversion#to_config)
|
|
151
|
+
# @return [String] Config fragment for this conversion
|
|
152
|
+
def to_config(read_or_write)
|
|
153
|
+
config = ''
|
|
154
|
+
@segments.each do |segment|
|
|
155
|
+
config <<
|
|
156
|
+
" SEG_POLY_#{read_or_write}_CONVERSION #{segment.lower_bound} #{segment.coeffs.join(' ')}\n"
|
|
157
|
+
end
|
|
158
|
+
config
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def as_json(*a)
|
|
162
|
+
params = []
|
|
163
|
+
@segments.each do |segment|
|
|
164
|
+
params << [segment.lower_bound, segment.coeffs]
|
|
165
|
+
end
|
|
166
|
+
result = super(*a)
|
|
167
|
+
result['params'] = [params]
|
|
168
|
+
result
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# encoding: ascii-8bit
|
|
2
|
+
|
|
3
|
+
# Copyright 2022 Ball Aerospace & Technologies Corp.
|
|
4
|
+
# All Rights Reserved.
|
|
5
|
+
#
|
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
|
7
|
+
# under the terms of the GNU Affero General Public License
|
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
|
10
|
+
#
|
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU Affero General Public License for more details.
|
|
15
|
+
|
|
16
|
+
# Modified by OpenC3, Inc.
|
|
17
|
+
# All changes Copyright 2022, OpenC3, Inc.
|
|
18
|
+
# All Rights Reserved
|
|
19
|
+
|
|
20
|
+
require 'openc3/conversions/conversion'
|
|
21
|
+
|
|
22
|
+
module OpenC3
|
|
23
|
+
# Converts a unix format time: Epoch Jan 1 1970, seconds and microseconds
|
|
24
|
+
class UnixTimeConversion < Conversion
|
|
25
|
+
# Initializes the time item to grab from the packet
|
|
26
|
+
#
|
|
27
|
+
# @param seconds_item_name [String] The telemetry item in the packet which
|
|
28
|
+
# represents the number of seconds since the UNIX time epoch
|
|
29
|
+
# @param microseconds_item_name [String] The telemetry item in the packet
|
|
30
|
+
# which represents microseconds
|
|
31
|
+
def initialize(seconds_item_name, microseconds_item_name = nil)
|
|
32
|
+
super()
|
|
33
|
+
@seconds_item_name = seconds_item_name
|
|
34
|
+
@microseconds_item_name = microseconds_item_name
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# @param (see Conversion#call)
|
|
38
|
+
# @return [Float] Packet time in seconds since UNIX epoch
|
|
39
|
+
def call(value, packet, buffer)
|
|
40
|
+
if @microseconds_item_name
|
|
41
|
+
return Time.at(packet.read(@seconds_item_name, :RAW, buffer), packet.read(@microseconds_item_name, :RAW, buffer)).sys
|
|
42
|
+
else
|
|
43
|
+
return Time.at(packet.read(@seconds_item_name, :RAW, buffer), 0).sys
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# @return [String] The name of the class followed by the time conversion
|
|
48
|
+
def to_s
|
|
49
|
+
if @microseconds_item_name
|
|
50
|
+
return "Time.at(packet.read('#{@seconds_item_name}', :RAW, buffer), packet.read('#{@microseconds_item_name}', :RAW, buffer)).sys"
|
|
51
|
+
else
|
|
52
|
+
return "Time.at(packet.read('#{@seconds_item_name}', :RAW, buffer), 0).sys"
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# @param (see Conversion#to_config)
|
|
57
|
+
# @return [String] Config fragment for this conversion
|
|
58
|
+
def to_config(read_or_write)
|
|
59
|
+
" #{read_or_write}_CONVERSION #{self.class.name.class_name_to_filename} #{@seconds_item_name} #{@microseconds_item_name}\n"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def as_json(*a)
|
|
63
|
+
result = super(*a)
|
|
64
|
+
result['params'] = [@seconds_item_name, @microseconds_item_name]
|
|
65
|
+
result
|
|
66
|
+
end
|
|
67
|
+
end # class UnixTimeConversion
|
|
68
|
+
end
|