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,442 @@
|
|
|
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 'nokogiri'
|
|
21
|
+
require 'openc3/packets/parsers/xtce_parser'
|
|
22
|
+
|
|
23
|
+
module OpenC3
|
|
24
|
+
class XtceConverter
|
|
25
|
+
attr_accessor :current_target_name
|
|
26
|
+
|
|
27
|
+
# Output a previously parsed definition file into the XTCE format
|
|
28
|
+
#
|
|
29
|
+
# @param commands [Hash<String=>Packet>] Hash of all the command packets
|
|
30
|
+
# keyed by the packet name.
|
|
31
|
+
# @param telemetry [Hash<String=>Packet>] Hash of all the telemetry packets
|
|
32
|
+
# keyed by the packet name.
|
|
33
|
+
# that were created while parsing the configuration
|
|
34
|
+
# @param output_dir [String] The name of the output directory to generate
|
|
35
|
+
# the XTCE files. A file is generated for each target.
|
|
36
|
+
def self.convert(commands, telemetry, output_dir)
|
|
37
|
+
XtceConverter.new(commands, telemetry, output_dir)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def initialize(commands, telemetry, output_dir)
|
|
43
|
+
FileUtils.mkdir_p(output_dir)
|
|
44
|
+
|
|
45
|
+
# Build target list
|
|
46
|
+
targets = []
|
|
47
|
+
telemetry.each { |target_name, packets| targets << target_name }
|
|
48
|
+
commands.each { |target_name, packets| targets << target_name }
|
|
49
|
+
targets.uniq!
|
|
50
|
+
|
|
51
|
+
targets.each do |target_name|
|
|
52
|
+
next if target_name == 'UNKNOWN'
|
|
53
|
+
|
|
54
|
+
# Reverse order of packets for the target so things are expected (reverse) order for xtce
|
|
55
|
+
XtceParser.reverse_packet_order(target_name, commands)
|
|
56
|
+
XtceParser.reverse_packet_order(target_name, telemetry)
|
|
57
|
+
|
|
58
|
+
FileUtils.mkdir_p(File.join(output_dir, target_name, 'cmd_tlm'))
|
|
59
|
+
filename = File.join(output_dir, target_name, 'cmd_tlm', target_name.downcase + '.xtce')
|
|
60
|
+
begin
|
|
61
|
+
File.delete(filename)
|
|
62
|
+
rescue
|
|
63
|
+
# Doesn't exist
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Create the xtce file for this target
|
|
67
|
+
builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
|
|
68
|
+
xml['xtce'].SpaceSystem("xmlns:xtce" => "http://www.omg.org/space/xtce",
|
|
69
|
+
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
|
|
70
|
+
"name" => target_name,
|
|
71
|
+
"xsi:schemaLocation" => "http://www.omg.org/space/xtce http://www.omg.org/spec/XTCE/20061101/06-11-06.xsd") do
|
|
72
|
+
create_telemetry(xml, telemetry, target_name)
|
|
73
|
+
create_commands(xml, commands, target_name)
|
|
74
|
+
end # SpaceSystem
|
|
75
|
+
end # builder
|
|
76
|
+
File.open(filename, 'w') do |file|
|
|
77
|
+
file.puts builder.to_xml
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def create_telemetry(xml, telemetry, target_name)
|
|
83
|
+
# Gather and make unique all the packet items
|
|
84
|
+
unique_items = telemetry[target_name] ? get_unique(telemetry[target_name]) : {}
|
|
85
|
+
|
|
86
|
+
xml['xtce'].TelemetryMetaData do
|
|
87
|
+
xml['xtce'].ParameterTypeSet do
|
|
88
|
+
unique_items.each do |item_name, item|
|
|
89
|
+
to_xtce_type(item, 'Parameter', xml)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
xml['xtce'].ParameterSet do
|
|
94
|
+
unique_items.each do |item_name, item|
|
|
95
|
+
to_xtce_item(item, 'Parameter', xml)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
if telemetry[target_name]
|
|
100
|
+
xml['xtce'].ContainerSet do
|
|
101
|
+
telemetry[target_name].each do |packet_name, packet|
|
|
102
|
+
attrs = { :name => (packet_name + '_Base'), :abstract => "true" }
|
|
103
|
+
xml['xtce'].SequenceContainer(attrs) do
|
|
104
|
+
process_entry_list(xml, packet, :TELEMETRY)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
attrs = { :name => packet_name }
|
|
108
|
+
attrs['shortDescription'] = packet.description if packet.description
|
|
109
|
+
xml['xtce'].SequenceContainer(attrs) do
|
|
110
|
+
xml['xtce'].EntryList
|
|
111
|
+
xml['xtce'].BaseContainer(:containerRef => (packet_name + '_Base')) do
|
|
112
|
+
if packet.id_items && packet.id_items.length > 0
|
|
113
|
+
xml['xtce'].RestrictionCriteria do
|
|
114
|
+
xml['xtce'].ComparisonList do
|
|
115
|
+
packet.id_items.each do |item|
|
|
116
|
+
xml['xtce'].Comparison(:parameterRef => item.name, :value => item.id_value)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end # SequenceContainer
|
|
123
|
+
end # telemetry.each
|
|
124
|
+
end # ContainerSet
|
|
125
|
+
end # if telemetry[target_name]
|
|
126
|
+
end # TelemetryMetaData
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def create_commands(xml, commands, target_name)
|
|
130
|
+
return unless commands[target_name]
|
|
131
|
+
|
|
132
|
+
xml['xtce'].CommandMetaData do
|
|
133
|
+
xml['xtce'].ArgumentTypeSet do
|
|
134
|
+
get_unique(commands[target_name]).each do |arg_name, arg|
|
|
135
|
+
to_xtce_type(arg, 'Argument', xml)
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
xml['xtce'].MetaCommandSet do
|
|
139
|
+
commands[target_name].each do |packet_name, packet|
|
|
140
|
+
attrs = { :name => packet_name + "_Base", :abstract => "true" }
|
|
141
|
+
xml['xtce'].MetaCommand(attrs) do
|
|
142
|
+
xml['xtce'].ArgumentList do
|
|
143
|
+
packet.sorted_items.each do |item|
|
|
144
|
+
next if item.data_type == :DERIVED
|
|
145
|
+
|
|
146
|
+
to_xtce_item(item, 'Argument', xml)
|
|
147
|
+
end
|
|
148
|
+
end # ArgumentList
|
|
149
|
+
xml['xtce'].CommandContainer(:name => "#{target_name}_#{packet_name}_CommandContainer") do
|
|
150
|
+
process_entry_list(xml, packet, :COMMAND)
|
|
151
|
+
end
|
|
152
|
+
end # Abstract MetaCommand
|
|
153
|
+
|
|
154
|
+
attrs = { :name => packet_name }
|
|
155
|
+
attrs['shortDescription'] = packet.description if packet.description
|
|
156
|
+
xml['xtce'].MetaCommand(attrs) do
|
|
157
|
+
xml['xtce'].BaseMetaCommand(:metaCommandRef => packet_name + "_Base") do
|
|
158
|
+
if packet.id_items && packet.id_items.length > 0
|
|
159
|
+
xml['xtce'].ArgumentAssignmentList do
|
|
160
|
+
packet.id_items.each do |item|
|
|
161
|
+
xml['xtce'].ArgumentAssignment(:argumentName => item.name, :argumentValue => item.id_value)
|
|
162
|
+
end
|
|
163
|
+
end # ArgumentAssignmentList
|
|
164
|
+
end
|
|
165
|
+
end # BaseMetaCommand
|
|
166
|
+
end # Actual MetaCommand
|
|
167
|
+
end # commands.each
|
|
168
|
+
end # MetaCommandSet
|
|
169
|
+
end # CommandMetaData
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def get_unique(items)
|
|
173
|
+
unique = {}
|
|
174
|
+
items.each do |packet_name, packet|
|
|
175
|
+
packet.sorted_items.each do |item|
|
|
176
|
+
next if item.data_type == :DERIVED
|
|
177
|
+
|
|
178
|
+
unique[item.name] ||= []
|
|
179
|
+
unique[item.name] << item
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
unique.each do |item_name, unique_items|
|
|
183
|
+
if unique_items.length <= 1
|
|
184
|
+
unique[item_name] = unique_items[0]
|
|
185
|
+
next
|
|
186
|
+
end
|
|
187
|
+
# TODO: need to make sure all the items in the array are exactly the same
|
|
188
|
+
unique[item_name] = unique_items[0]
|
|
189
|
+
end
|
|
190
|
+
unique
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# This method is almost the same for commands and telemetry except for the
|
|
194
|
+
# XML element name: [Array]ArgumentRefEntry vs [Array]ParameterRefEntry,
|
|
195
|
+
# and XML reference: argumentRef vs parameterRef.
|
|
196
|
+
# Thus we build the name and use send to dynamically dispatch.
|
|
197
|
+
def process_entry_list(xml, packet, cmd_vs_tlm)
|
|
198
|
+
if cmd_vs_tlm == :COMMAND
|
|
199
|
+
type = "Argument"
|
|
200
|
+
else # :TELEMETRY
|
|
201
|
+
type = "Parameter"
|
|
202
|
+
end
|
|
203
|
+
xml['xtce'].EntryList do
|
|
204
|
+
packed = packet.packed?
|
|
205
|
+
packet.sorted_items.each do |item|
|
|
206
|
+
next if item.data_type == :DERIVED
|
|
207
|
+
|
|
208
|
+
# TODO: Handle nonunique item names
|
|
209
|
+
if item.array_size
|
|
210
|
+
# Requiring parameterRef for argument arrays appears to be a defect in the schema
|
|
211
|
+
xml['xtce'].public_send("Array#{type}RefEntry".intern, :parameterRef => item.name) do
|
|
212
|
+
set_fixed_value(xml, item) if !packed
|
|
213
|
+
xml['xtce'].DimensionList do
|
|
214
|
+
xml['xtce'].Dimension do
|
|
215
|
+
xml['xtce'].StartingIndex do
|
|
216
|
+
xml['xtce'].FixedValue(0)
|
|
217
|
+
end
|
|
218
|
+
xml['xtce'].EndingIndex do
|
|
219
|
+
xml['xtce'].FixedValue((item.array_size / item.bit_size) - 1)
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
else
|
|
225
|
+
if packed
|
|
226
|
+
xml['xtce'].public_send("#{type}RefEntry".intern, "#{type.downcase}Ref".intern => item.name)
|
|
227
|
+
else
|
|
228
|
+
xml['xtce'].public_send("#{type}RefEntry".intern, "#{type.downcase}Ref".intern => item.name) do
|
|
229
|
+
set_fixed_value(xml, item)
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
def set_fixed_value(xml, item)
|
|
238
|
+
if item.bit_offset >= 0
|
|
239
|
+
xml['xtce'].LocationInContainerInBits(:referenceLocation => 'containerStart') do
|
|
240
|
+
xml['xtce'].FixedValue(item.bit_offset)
|
|
241
|
+
end
|
|
242
|
+
else
|
|
243
|
+
xml['xtce'].LocationInContainerInBits(:referenceLocation => 'containerEnd') do
|
|
244
|
+
xml['xtce'].FixedValue(-item.bit_offset)
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
def to_xtce_type(item, param_or_arg, xml)
|
|
250
|
+
# TODO: Spline Conversions
|
|
251
|
+
case item.data_type
|
|
252
|
+
when :INT, :UINT
|
|
253
|
+
to_xtce_int(item, param_or_arg, xml)
|
|
254
|
+
when :FLOAT
|
|
255
|
+
to_xtce_float(item, param_or_arg, xml)
|
|
256
|
+
when :STRING
|
|
257
|
+
to_xtce_string(item, param_or_arg, xml, 'String')
|
|
258
|
+
when :BLOCK
|
|
259
|
+
to_xtce_string(item, param_or_arg, xml, 'Binary')
|
|
260
|
+
when :DERIVED
|
|
261
|
+
raise "DERIVED data type not supported in XTCE"
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
# Handle arrays
|
|
265
|
+
if item.array_size
|
|
266
|
+
# The above will have created the type for the array entries. Now we create the type for the actual array.
|
|
267
|
+
attrs = { :name => (item.name + '_ArrayType') }
|
|
268
|
+
attrs[:shortDescription] = item.description if item.description
|
|
269
|
+
attrs[:arrayTypeRef] = (item.name + '_Type')
|
|
270
|
+
attrs[:numberOfDimensions] = '1' # OpenC3 Only supports one-dimensional arrays
|
|
271
|
+
xml['xtce'].public_send('Array' + param_or_arg + 'Type', attrs)
|
|
272
|
+
end
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
def to_xtce_limits(item, xml)
|
|
276
|
+
return unless item.limits && item.limits.values
|
|
277
|
+
|
|
278
|
+
item.limits.values.each do |limits_set, limits_values|
|
|
279
|
+
if limits_set == :DEFAULT
|
|
280
|
+
xml['xtce'].DefaultAlarm do
|
|
281
|
+
xml['xtce'].StaticAlarmRanges do
|
|
282
|
+
xml['xtce'].WarningRange(:minInclusive => limits_values[1], :maxInclusive => limits_values[2])
|
|
283
|
+
xml['xtce'].CriticalRange(:minInclusive => limits_values[0], :maxInclusive => limits_values[3])
|
|
284
|
+
end
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
def to_xtce_int(item, param_or_arg, xml)
|
|
291
|
+
attrs = { :name => (item.name + '_Type') }
|
|
292
|
+
attrs[:initialValue] = item.default if item.default and !item.array_size
|
|
293
|
+
attrs[:shortDescription] = item.description if item.description
|
|
294
|
+
if item.states and item.default and item.states.key(item.default)
|
|
295
|
+
attrs[:initialValue] = item.states.key(item.default) and !item.array_size
|
|
296
|
+
end
|
|
297
|
+
if item.data_type == :INT
|
|
298
|
+
signed = 'true'
|
|
299
|
+
encoding = 'twosCompliment'
|
|
300
|
+
else
|
|
301
|
+
signed = 'false'
|
|
302
|
+
encoding = 'unsigned'
|
|
303
|
+
end
|
|
304
|
+
if item.states
|
|
305
|
+
xml['xtce'].public_send('Enumerated' + param_or_arg + 'Type', attrs) do
|
|
306
|
+
to_xtce_endianness(item, xml)
|
|
307
|
+
to_xtce_units(item, xml)
|
|
308
|
+
xml['xtce'].IntegerDataEncoding(:sizeInBits => item.bit_size, :encoding => encoding)
|
|
309
|
+
xml['xtce'].EnumerationList do
|
|
310
|
+
item.states.each do |state_name, state_value|
|
|
311
|
+
# Skip the special OpenC3 'ANY' enumerated state
|
|
312
|
+
next if state_value == 'ANY'
|
|
313
|
+
|
|
314
|
+
xml['xtce'].Enumeration(:value => state_value, :label => state_name)
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
else
|
|
319
|
+
if (item.read_conversion and item.read_conversion.class == PolynomialConversion) or (item.write_conversion and item.write_conversion.class == PolynomialConversion)
|
|
320
|
+
type_string = 'Float' + param_or_arg + 'Type'
|
|
321
|
+
else
|
|
322
|
+
type_string = 'Integer' + param_or_arg + 'Type'
|
|
323
|
+
attrs[:signed] = signed
|
|
324
|
+
end
|
|
325
|
+
xml['xtce'].public_send(type_string, attrs) do
|
|
326
|
+
to_xtce_endianness(item, xml)
|
|
327
|
+
to_xtce_units(item, xml)
|
|
328
|
+
if (item.read_conversion and item.read_conversion.class == PolynomialConversion) or (item.write_conversion and item.write_conversion.class == PolynomialConversion)
|
|
329
|
+
xml['xtce'].IntegerDataEncoding(:sizeInBits => item.bit_size, :encoding => encoding) do
|
|
330
|
+
to_xtce_conversion(item, xml)
|
|
331
|
+
end
|
|
332
|
+
else
|
|
333
|
+
xml['xtce'].IntegerDataEncoding(:sizeInBits => item.bit_size, :encoding => encoding)
|
|
334
|
+
end
|
|
335
|
+
to_xtce_limits(item, xml)
|
|
336
|
+
if item.range
|
|
337
|
+
xml['xtce'].ValidRange(:minInclusive => item.range.first, :maxInclusive => item.range.last)
|
|
338
|
+
end
|
|
339
|
+
end # Type
|
|
340
|
+
end # if item.states
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
def to_xtce_float(item, param_or_arg, xml)
|
|
344
|
+
attrs = { :name => (item.name + '_Type'), :sizeInBits => item.bit_size }
|
|
345
|
+
attrs[:initialValue] = item.default if item.default and !item.array_size
|
|
346
|
+
attrs[:shortDescription] = item.description if item.description
|
|
347
|
+
xml['xtce'].public_send('Float' + param_or_arg + 'Type', attrs) do
|
|
348
|
+
to_xtce_endianness(item, xml)
|
|
349
|
+
to_xtce_units(item, xml)
|
|
350
|
+
if (item.read_conversion and item.read_conversion.class == PolynomialConversion) or (item.write_conversion and item.write_conversion.class == PolynomialConversion)
|
|
351
|
+
xml['xtce'].FloatDataEncoding(:sizeInBits => item.bit_size, :encoding => 'IEEE754_1985') do
|
|
352
|
+
to_xtce_conversion(item, xml)
|
|
353
|
+
end
|
|
354
|
+
else
|
|
355
|
+
xml['xtce'].FloatDataEncoding(:sizeInBits => item.bit_size, :encoding => 'IEEE754_1985')
|
|
356
|
+
end
|
|
357
|
+
to_xtce_limits(item, xml)
|
|
358
|
+
if item.range
|
|
359
|
+
xml['xtce'].ValidRange(:minInclusive => item.range.first, :maxInclusive => item.range.last)
|
|
360
|
+
end
|
|
361
|
+
end
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
def to_xtce_string(item, param_or_arg, xml, string_or_binary)
|
|
365
|
+
# TODO: OpenC3 Variably sized strings are not supported in XTCE
|
|
366
|
+
attrs = { :name => (item.name + '_Type') }
|
|
367
|
+
attrs[:characterWidth] = 8 if string_or_binary == 'String'
|
|
368
|
+
if item.default && !item.array_size
|
|
369
|
+
unless item.default.is_printable?
|
|
370
|
+
attrs[:initialValue] = '0x' + item.default.simple_formatted
|
|
371
|
+
else
|
|
372
|
+
attrs[:initialValue] = item.default.inspect
|
|
373
|
+
end
|
|
374
|
+
end
|
|
375
|
+
attrs[:shortDescription] = item.description if item.description
|
|
376
|
+
xml['xtce'].public_send(string_or_binary + param_or_arg + 'Type', attrs) do
|
|
377
|
+
# Don't call to_xtce_endianness for Strings or Blocks
|
|
378
|
+
to_xtce_units(item, xml)
|
|
379
|
+
if string_or_binary == 'String'
|
|
380
|
+
xml['xtce'].StringDataEncoding(:encoding => 'UTF-8') do
|
|
381
|
+
xml['xtce'].SizeInBits do
|
|
382
|
+
xml['xtce'].Fixed do
|
|
383
|
+
xml['xtce'].FixedValue(item.bit_size.to_s)
|
|
384
|
+
end
|
|
385
|
+
end
|
|
386
|
+
end
|
|
387
|
+
else
|
|
388
|
+
xml['xtce'].BinaryDataEncoding do
|
|
389
|
+
xml['xtce'].SizeInBits do
|
|
390
|
+
xml['xtce'].FixedValue(item.bit_size.to_s)
|
|
391
|
+
end
|
|
392
|
+
end
|
|
393
|
+
end
|
|
394
|
+
end
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
def to_xtce_item(item, param_or_arg, xml)
|
|
398
|
+
if item.array_size
|
|
399
|
+
xml['xtce'].public_send(param_or_arg, :name => item.name, "#{param_or_arg.downcase}TypeRef" => item.name + '_ArrayType')
|
|
400
|
+
else
|
|
401
|
+
xml['xtce'].public_send(param_or_arg, :name => item.name, "#{param_or_arg.downcase}TypeRef" => item.name + '_Type')
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
def to_xtce_units(item, xml)
|
|
406
|
+
if item.units
|
|
407
|
+
xml['xtce'].UnitSet do
|
|
408
|
+
xml['xtce'].Unit(item.units, :description => item.units_full)
|
|
409
|
+
end
|
|
410
|
+
else
|
|
411
|
+
xml['xtce'].UnitSet
|
|
412
|
+
end
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
def to_xtce_endianness(item, xml)
|
|
416
|
+
if item.endianness == :LITTLE_ENDIAN and item.bit_size > 8
|
|
417
|
+
xml['xtce'].ByteOrderList do
|
|
418
|
+
(((item.bit_size - 1) / 8) + 1).times do |byte_significance|
|
|
419
|
+
xml['xtce'].Byte(:byteSignificance => byte_significance)
|
|
420
|
+
end
|
|
421
|
+
end
|
|
422
|
+
end
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
def to_xtce_conversion(item, xml)
|
|
426
|
+
if item.read_conversion
|
|
427
|
+
conversion = item.read_conversion
|
|
428
|
+
else
|
|
429
|
+
conversion = item.write_conversion
|
|
430
|
+
end
|
|
431
|
+
if conversion && conversion.class == PolynomialConversion
|
|
432
|
+
xml['xtce'].DefaultCalibrator do
|
|
433
|
+
xml['xtce'].PolynomialCalibrator do
|
|
434
|
+
conversion.coeffs.each_with_index do |coeff, index|
|
|
435
|
+
xml['xtce'].Term(:coefficient => coeff, :exponent => index)
|
|
436
|
+
end
|
|
437
|
+
end
|
|
438
|
+
end
|
|
439
|
+
end
|
|
440
|
+
end
|
|
441
|
+
end
|
|
442
|
+
end
|