openc3 5.0.6
Sign up to get free protection for your applications and to get access to all the features.
- 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,272 @@
|
|
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/packets/packet_item'
|
21
|
+
|
22
|
+
module OpenC3
|
23
|
+
# Parses a packet item definition and creates a new PacketItem
|
24
|
+
class PacketItemParser
|
25
|
+
# This number is a little arbitrary but there are definitely issues at
|
26
|
+
# 1 million and you really shouldn't be doing anything this big anyway
|
27
|
+
BIG_ARRAY_SIZE = 100_000
|
28
|
+
|
29
|
+
# @param parser [ConfigParser] Configuration parser
|
30
|
+
# @param packet [Packet] The packet the item should be added to
|
31
|
+
# @param cmd_or_tlm [String] Whether this is a command or telemetry packet
|
32
|
+
# @param warnings [Array<String>] Array of warning strings from PacketConfig
|
33
|
+
def self.parse(parser, packet, cmd_or_tlm, warnings)
|
34
|
+
parser = PacketItemParser.new(parser, warnings)
|
35
|
+
parser.verify_parameters(cmd_or_tlm)
|
36
|
+
parser.create_packet_item(packet, cmd_or_tlm)
|
37
|
+
end
|
38
|
+
|
39
|
+
# @param parser [ConfigParser] Configuration parser
|
40
|
+
# @param warnings [Array<String>] Array of warning strings from PacketConfig
|
41
|
+
def initialize(parser, warnings)
|
42
|
+
@parser = parser
|
43
|
+
@warnings = warnings
|
44
|
+
@usage = get_usage()
|
45
|
+
end
|
46
|
+
|
47
|
+
def verify_parameters(cmd_or_tlm)
|
48
|
+
if @parser.keyword.include?('ITEM') && cmd_or_tlm == PacketConfig::COMMAND
|
49
|
+
raise @parser.error("ITEM types are only valid with TELEMETRY", @usage)
|
50
|
+
elsif @parser.keyword.include?('PARAMETER') && cmd_or_tlm == PacketConfig::TELEMETRY
|
51
|
+
raise @parser.error("PARAMETER types are only valid with COMMAND", @usage)
|
52
|
+
end
|
53
|
+
|
54
|
+
# The usage is formatted with brackets <XXX> around each option so
|
55
|
+
# count the number of open brackets to determine the number of options
|
56
|
+
max_options = @usage.count("<")
|
57
|
+
# The last two options (description and endianness) are optional
|
58
|
+
@parser.verify_num_parameters(max_options - 2, max_options, @usage)
|
59
|
+
@parser.verify_parameter_naming(1) # Item name is the 1st parameter
|
60
|
+
end
|
61
|
+
|
62
|
+
def create_packet_item(packet, cmd_or_tlm)
|
63
|
+
item_name = @parser.parameters[0].upcase
|
64
|
+
if packet.items[item_name]
|
65
|
+
msg = "#{packet.target_name} #{packet.packet_name} #{item_name} redefined."
|
66
|
+
Logger.instance.warn msg
|
67
|
+
@warnings << msg
|
68
|
+
end
|
69
|
+
item = PacketItem.new(item_name,
|
70
|
+
get_bit_offset(),
|
71
|
+
get_bit_size(),
|
72
|
+
get_data_type(),
|
73
|
+
get_endianness(packet),
|
74
|
+
get_array_size(),
|
75
|
+
:ERROR) # overflow
|
76
|
+
if cmd_or_tlm == PacketConfig::COMMAND
|
77
|
+
item.range = get_range()
|
78
|
+
item.default = get_default()
|
79
|
+
end
|
80
|
+
item.id_value = get_id_value()
|
81
|
+
item.description = get_description()
|
82
|
+
if append?
|
83
|
+
item = packet.append(item)
|
84
|
+
else
|
85
|
+
item = packet.define(item)
|
86
|
+
end
|
87
|
+
item
|
88
|
+
rescue => err
|
89
|
+
raise @parser.error(err, @usage)
|
90
|
+
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
def append?
|
95
|
+
@parser.keyword.include?("APPEND")
|
96
|
+
end
|
97
|
+
|
98
|
+
def get_data_type
|
99
|
+
index = append? ? 2 : 3
|
100
|
+
@parser.parameters[index].upcase.to_sym
|
101
|
+
end
|
102
|
+
|
103
|
+
def get_bit_offset
|
104
|
+
return 0 if append?
|
105
|
+
|
106
|
+
Integer(@parser.parameters[1])
|
107
|
+
rescue => err # In case Integer fails
|
108
|
+
raise @parser.error(err, @usage)
|
109
|
+
end
|
110
|
+
|
111
|
+
def get_bit_size
|
112
|
+
index = append? ? 1 : 2
|
113
|
+
Integer(@parser.parameters[index])
|
114
|
+
rescue => err
|
115
|
+
raise @parser.error(err, @usage)
|
116
|
+
end
|
117
|
+
|
118
|
+
def get_array_size
|
119
|
+
return nil unless @parser.keyword.include?('ARRAY')
|
120
|
+
|
121
|
+
index = append? ? 3 : 4
|
122
|
+
array_bit_size = Integer(@parser.parameters[index])
|
123
|
+
items = array_bit_size / get_bit_size()
|
124
|
+
if items >= BIG_ARRAY_SIZE
|
125
|
+
warning = "Performance Issue!\n"\
|
126
|
+
"In #{@parser.filename}:#{@parser.line_number} your definition of:\n"\
|
127
|
+
"#{@parser.line}\n"\
|
128
|
+
"creates an array with #{items} elements. Consider creating a BLOCK if this is binary data."
|
129
|
+
Logger.warn(warning)
|
130
|
+
@warnings << warning
|
131
|
+
end
|
132
|
+
array_bit_size
|
133
|
+
rescue => err
|
134
|
+
raise @parser.error(err, @usage)
|
135
|
+
end
|
136
|
+
|
137
|
+
def get_endianness(packet)
|
138
|
+
params = @parser.parameters
|
139
|
+
max_options = @usage.count("<")
|
140
|
+
if params[max_options - 1]
|
141
|
+
endianness = params[max_options - 1].to_s.upcase.intern
|
142
|
+
if endianness != :BIG_ENDIAN and endianness != :LITTLE_ENDIAN
|
143
|
+
raise @parser.error("Invalid endianness #{endianness}. Must be BIG_ENDIAN or LITTLE_ENDIAN.", @usage)
|
144
|
+
end
|
145
|
+
else
|
146
|
+
endianness = packet.default_endianness
|
147
|
+
end
|
148
|
+
endianness
|
149
|
+
end
|
150
|
+
|
151
|
+
def get_range
|
152
|
+
return nil if @parser.keyword.include?('ARRAY')
|
153
|
+
|
154
|
+
data_type = get_data_type()
|
155
|
+
return nil if data_type == :STRING or data_type == :BLOCK
|
156
|
+
|
157
|
+
index = append? ? 3 : 4
|
158
|
+
min = ConfigParser.handle_defined_constants(
|
159
|
+
@parser.parameters[index].convert_to_value, get_data_type(), get_bit_size()
|
160
|
+
)
|
161
|
+
max = ConfigParser.handle_defined_constants(
|
162
|
+
@parser.parameters[index + 1].convert_to_value, get_data_type(), get_bit_size()
|
163
|
+
)
|
164
|
+
min..max
|
165
|
+
end
|
166
|
+
|
167
|
+
def get_default
|
168
|
+
return [] if @parser.keyword.include?('ARRAY')
|
169
|
+
|
170
|
+
index = append? ? 3 : 4
|
171
|
+
data_type = get_data_type()
|
172
|
+
if data_type == :STRING or data_type == :BLOCK
|
173
|
+
# If the default value is 0x<data> (no quotes), it is treated as
|
174
|
+
# binary data. Otherwise, the default value is considered to be a string.
|
175
|
+
if @parser.parameters[index].upcase.start_with?("0X") and
|
176
|
+
!@parser.line.include?("\"#{@parser.parameters[index]}\"") and
|
177
|
+
!@parser.line.include?("\'#{@parser.parameters[index]}\'")
|
178
|
+
return @parser.parameters[index].hex_to_byte_string
|
179
|
+
else
|
180
|
+
return @parser.parameters[index]
|
181
|
+
end
|
182
|
+
else
|
183
|
+
return ConfigParser.handle_defined_constants(
|
184
|
+
@parser.parameters[index + 2].convert_to_value, get_data_type(), get_bit_size()
|
185
|
+
)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def get_id_value
|
190
|
+
return nil unless @parser.keyword.include?('ID_')
|
191
|
+
|
192
|
+
data_type = get_data_type
|
193
|
+
if @parser.keyword.include?('ITEM')
|
194
|
+
index = append? ? 3 : 4
|
195
|
+
else # PARAMETER
|
196
|
+
index = append? ? 5 : 6
|
197
|
+
# STRING and BLOCK PARAMETERS don't have min and max values
|
198
|
+
index -= 2 if data_type == :STRING || data_type == :BLOCK
|
199
|
+
end
|
200
|
+
if data_type == :DERIVED
|
201
|
+
raise @parser.error("DERIVED data type not allowed for Identifier")
|
202
|
+
end
|
203
|
+
|
204
|
+
@parser.parameters[index]
|
205
|
+
end
|
206
|
+
|
207
|
+
def get_description
|
208
|
+
max_options = @usage.count("<")
|
209
|
+
@parser.parameters[max_options - 2] if @parser.parameters[max_options - 2]
|
210
|
+
end
|
211
|
+
|
212
|
+
# There are many different usages of the ITEM and PARAMETER keywords so
|
213
|
+
# parse the keyword and parameters to generate the correct usage information.
|
214
|
+
def get_usage
|
215
|
+
usage = "#{@parser.keyword} <ITEM NAME> "
|
216
|
+
usage << "<BIT OFFSET> " unless @parser.keyword.include?("APPEND")
|
217
|
+
usage << bit_size_usage()
|
218
|
+
usage << type_usage()
|
219
|
+
usage << "<TOTAL ARRAY BIT SIZE> " if @parser.keyword.include?("ARRAY")
|
220
|
+
usage << id_usage()
|
221
|
+
usage << "<DESCRIPTION (Optional)> <ENDIANNESS (Optional)>"
|
222
|
+
usage
|
223
|
+
end
|
224
|
+
|
225
|
+
def bit_size_usage
|
226
|
+
if @parser.keyword.include?("ARRAY")
|
227
|
+
"<ARRAY ITEM BIT SIZE> "
|
228
|
+
else
|
229
|
+
"<BIT SIZE> "
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
def type_usage
|
234
|
+
keyword = @parser.keyword
|
235
|
+
# Item type usage is simple so just return it
|
236
|
+
return "<TYPE: INT/UINT/FLOAT/STRING/BLOCK/DERIVED> " if keyword.include?("ITEM")
|
237
|
+
|
238
|
+
# Build up the parameter type usage based on the keyword
|
239
|
+
usage = "<TYPE: "
|
240
|
+
# ARRAY types don't have min or max or default values
|
241
|
+
if keyword.include?("ARRAY")
|
242
|
+
usage << "INT/UINT/FLOAT/STRING/BLOCK> "
|
243
|
+
else
|
244
|
+
begin
|
245
|
+
data_type = get_data_type()
|
246
|
+
rescue
|
247
|
+
# If the data type could not be determined set something
|
248
|
+
data_type == :INT
|
249
|
+
end
|
250
|
+
# STRING and BLOCK types do not have min or max values
|
251
|
+
if data_type == :STRING || data_type == :BLOCK
|
252
|
+
usage << "STRING/BLOCK> "
|
253
|
+
else
|
254
|
+
usage << "INT/UINT/FLOAT> <MIN VALUE> <MAX VALUE> "
|
255
|
+
end
|
256
|
+
# ID Values do not have default values
|
257
|
+
usage << "<DEFAULT_VALUE> " unless keyword.include?("ID")
|
258
|
+
end
|
259
|
+
usage
|
260
|
+
end
|
261
|
+
|
262
|
+
def id_usage
|
263
|
+
return '' unless @parser.keyword.include?("ID")
|
264
|
+
|
265
|
+
if @parser.keyword.include?("PARAMETER")
|
266
|
+
"<DEFAULT AND ID VALUE> "
|
267
|
+
else
|
268
|
+
"<ID VALUE> "
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
@@ -0,0 +1,134 @@
|
|
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/packets/packet'
|
21
|
+
|
22
|
+
module OpenC3
|
23
|
+
class PacketParser
|
24
|
+
# @param parser [ConfigParser] Configuration parser
|
25
|
+
# @param target_name [String] The name of the target to create the packet
|
26
|
+
# under. If the target name is 'SYSTEM' the keyword parameter will be
|
27
|
+
# used instead of this parameter.
|
28
|
+
# @param commands [Hash] Hash of the currently defined commands
|
29
|
+
# @param warnings [Array<String>] Any warning strings generated while
|
30
|
+
# parsing this command will be appened to this array
|
31
|
+
def self.parse_command(parser, target_name, commands, warnings)
|
32
|
+
parser = PacketParser.new(parser)
|
33
|
+
parser.verify_parameters()
|
34
|
+
parser.create_command(target_name, commands, warnings)
|
35
|
+
end
|
36
|
+
|
37
|
+
# @param parser [ConfigParser] Configuration parser
|
38
|
+
# @param target_name [String] The name of the target to create the packet
|
39
|
+
# under. If the target name is 'SYSTEM' the keyword parameter will be
|
40
|
+
# used instead of this parameter.
|
41
|
+
# @param telemetry [Hash] Hash of the currently defined telemetry packets
|
42
|
+
# @param latest_data [Hash<String=>Hash<String=>Array(Packet)>>] Hash of hashes keyed
|
43
|
+
# first by the target name and then by the item name. This results in an
|
44
|
+
# array of packets containing that target and item. This structure is
|
45
|
+
# used to perform lookups when the packet and item are known but the
|
46
|
+
# packet is not.
|
47
|
+
# @param warnings [Array<String>] Any warning strings generated while
|
48
|
+
# parsing this command will be appened to this array
|
49
|
+
def self.parse_telemetry(parser, target_name, telemetry, latest_data, warnings)
|
50
|
+
parser = PacketParser.new(parser)
|
51
|
+
parser.verify_parameters()
|
52
|
+
parser.create_telemetry(target_name, telemetry, latest_data, warnings)
|
53
|
+
end
|
54
|
+
|
55
|
+
# @param packet [Packet] Packet to check all default and range items for
|
56
|
+
# appropriate data types. Only applicable to COMMAND packets.
|
57
|
+
def self.check_item_data_types(packet)
|
58
|
+
packet.sorted_items.each do |item|
|
59
|
+
item.check_default_and_range_data_types()
|
60
|
+
end
|
61
|
+
rescue
|
62
|
+
# Add the target name and packet name to the error message so the user
|
63
|
+
# can debug where the error occurred
|
64
|
+
raise $!, "#{packet.target_name} #{packet.packet_name} #{$!}", $!.backtrace
|
65
|
+
end
|
66
|
+
|
67
|
+
# @param parser [ConfigParser] Configuration parser
|
68
|
+
def initialize(parser)
|
69
|
+
@parser = parser
|
70
|
+
end
|
71
|
+
|
72
|
+
def verify_parameters
|
73
|
+
@usage = "#{@parser.keyword} <TARGET NAME> <PACKET NAME> <ENDIANNESS: BIG_ENDIAN/LITTLE_ENDIAN> <DESCRIPTION (Optional)>"
|
74
|
+
@parser.verify_num_parameters(3, 4, @usage)
|
75
|
+
@parser.verify_parameter_naming(2) # Packet name is the 2nd parameter
|
76
|
+
end
|
77
|
+
|
78
|
+
def create_command(target_name, commands, warnings)
|
79
|
+
packet = create_packet(target_name)
|
80
|
+
PacketParser.finish_create_command(packet, commands, warnings)
|
81
|
+
end
|
82
|
+
|
83
|
+
def create_telemetry(target_name, telemetry, latest_data, warnings)
|
84
|
+
packet = create_packet(target_name)
|
85
|
+
PacketParser.finish_create_telemetry(packet, telemetry, latest_data, warnings)
|
86
|
+
end
|
87
|
+
|
88
|
+
# private
|
89
|
+
|
90
|
+
def create_packet(target_name)
|
91
|
+
params = @parser.parameters
|
92
|
+
target_name = params[0].to_s.upcase if target_name == 'SYSTEM'
|
93
|
+
packet_name = params[1].to_s.upcase
|
94
|
+
endianness = params[2].to_s.upcase.to_sym
|
95
|
+
description = params[3].to_s
|
96
|
+
if endianness != :BIG_ENDIAN and endianness != :LITTLE_ENDIAN
|
97
|
+
raise @parser.error("Invalid endianness #{params[2]}. Must be BIG_ENDIAN or LITTLE_ENDIAN.", @usage)
|
98
|
+
end
|
99
|
+
|
100
|
+
Packet.new(target_name, packet_name, endianness, description)
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.check_for_duplicate(type, list, packet)
|
104
|
+
msg = nil
|
105
|
+
if list[packet.target_name]
|
106
|
+
if list[packet.target_name][packet.packet_name]
|
107
|
+
msg = "#{type} Packet #{packet.target_name} #{packet.packet_name} redefined."
|
108
|
+
Logger.instance.warn msg
|
109
|
+
end
|
110
|
+
end
|
111
|
+
msg
|
112
|
+
end
|
113
|
+
|
114
|
+
def self.finish_create_command(packet, commands, warnings)
|
115
|
+
warning = PacketParser.check_for_duplicate('Command', commands, packet)
|
116
|
+
warnings << warning if warning
|
117
|
+
packet.define_reserved_items()
|
118
|
+
commands[packet.target_name] ||= {}
|
119
|
+
packet
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.finish_create_telemetry(packet, telemetry, latest_data, warnings)
|
123
|
+
warning = PacketParser.check_for_duplicate('Telemetry', telemetry, packet)
|
124
|
+
warnings << warning if warning
|
125
|
+
packet.define_reserved_items()
|
126
|
+
|
127
|
+
unless telemetry[packet.target_name]
|
128
|
+
telemetry[packet.target_name] = {}
|
129
|
+
latest_data[packet.target_name] = {}
|
130
|
+
end
|
131
|
+
packet
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,73 @@
|
|
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/processors'
|
21
|
+
|
22
|
+
module OpenC3
|
23
|
+
class ProcessorParser
|
24
|
+
# @param parser [ConfigParser] Configuration parser
|
25
|
+
# @param packet [Packet] The current packet
|
26
|
+
# @param cmd_or_tlm [String] Whether this is a command or telemetry packet
|
27
|
+
def self.parse(parser, packet, cmd_or_tlm)
|
28
|
+
@parser = ProcessorParser.new(parser)
|
29
|
+
@parser.verify_parameters(cmd_or_tlm)
|
30
|
+
@parser.create_processor(packet)
|
31
|
+
end
|
32
|
+
|
33
|
+
# @param parser [ConfigParser] Configuration parser
|
34
|
+
def initialize(parser)
|
35
|
+
@parser = parser
|
36
|
+
end
|
37
|
+
|
38
|
+
# @param cmd_or_tlm [String] Whether this is a command or telemetry packet
|
39
|
+
def verify_parameters(cmd_or_tlm)
|
40
|
+
if cmd_or_tlm == PacketConfig::COMMAND
|
41
|
+
raise @parser.error("PROCESSOR only applies to telemetry packets")
|
42
|
+
end
|
43
|
+
|
44
|
+
@usage = "PROCESSOR <PROCESSOR NAME> <PROCESSOR CLASS FILENAME> <PROCESSOR SPECIFIC OPTIONS>"
|
45
|
+
@parser.verify_num_parameters(2, nil, @usage)
|
46
|
+
end
|
47
|
+
|
48
|
+
# @param packet [Packet] The packet the processor should be added to
|
49
|
+
def create_processor(packet)
|
50
|
+
# require should be performed in target.txt
|
51
|
+
klass = @parser.parameters[1].filename_to_class_name.to_class
|
52
|
+
raise @parser.error("#{@parser.parameters[1].filename_to_class_name} class not found. Did you require the file in target.txt?", @usage) unless klass
|
53
|
+
|
54
|
+
if @parser.parameters[2]
|
55
|
+
processor = klass.new(*@parser.parameters[2..(@parser.parameters.length - 1)])
|
56
|
+
else
|
57
|
+
processor = klass.new
|
58
|
+
end
|
59
|
+
raise ArgumentError, "processor must be a OpenC3::Processor but is a #{processor.class}" unless OpenC3::Processor === processor
|
60
|
+
|
61
|
+
processor.name = get_processor_name()
|
62
|
+
packet.processors[processor.name] = processor
|
63
|
+
rescue Exception => err
|
64
|
+
raise @parser.error(err, @usage)
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def get_processor_name
|
70
|
+
@parser.parameters[0].to_s.upcase
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,127 @@
|
|
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/packets/packet_item'
|
21
|
+
|
22
|
+
module OpenC3
|
23
|
+
class StateParser
|
24
|
+
# @param parser [ConfigParser] Configuration parser
|
25
|
+
# @param packet [Packet] The current packet
|
26
|
+
# @param cmd_or_tlm [String] Whether this is a command or telemetry packet
|
27
|
+
# @param item [PacketItem] The packet item to create states on
|
28
|
+
# @param warnings [Array<String>] Array of string warnings which will be
|
29
|
+
# appended with any warnings found when parsing the limits
|
30
|
+
def self.parse(parser, packet, cmd_or_tlm, item, warnings)
|
31
|
+
raise parser.error("Items with LIMITS can't define STATE") if item.limits.values
|
32
|
+
raise parser.error("Items with UNITS can't define STATE") if item.units
|
33
|
+
|
34
|
+
@parser = StateParser.new(parser)
|
35
|
+
@parser.verify_parameters(cmd_or_tlm)
|
36
|
+
@parser.create_state(packet, cmd_or_tlm, item, warnings)
|
37
|
+
end
|
38
|
+
|
39
|
+
# @param parser [ConfigParser] Configuration parser
|
40
|
+
def initialize(parser)
|
41
|
+
@parser = parser
|
42
|
+
end
|
43
|
+
|
44
|
+
# @param cmd_or_tlm [String] Whether this is a command or telemetry packet
|
45
|
+
def verify_parameters(cmd_or_tlm)
|
46
|
+
@usage = "STATE <STATE NAME> <STATE VALUE> "
|
47
|
+
if cmd_or_tlm == PacketConfig::COMMAND
|
48
|
+
@usage << "<HAZARDOUS (Optional)> <Hazardous Description (Optional)>"
|
49
|
+
@parser.verify_num_parameters(2, 4, @usage)
|
50
|
+
else
|
51
|
+
@usage << "<COLOR: GREEN/YELLOW/RED (Optional)>"
|
52
|
+
@parser.verify_num_parameters(2, 3, @usage)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# @param packet [Packet] The current packet
|
57
|
+
# @param cmd_or_tlm [String] Whether this is a command or telemetry packet
|
58
|
+
# @param item [PacketItem] The packet item to create states on
|
59
|
+
# @param warnings [Array<String>] Array of string warnings which will be
|
60
|
+
# appended with any warnings found when parsing the limits
|
61
|
+
def create_state(packet, cmd_or_tlm, item, warnings)
|
62
|
+
item.states ||= {}
|
63
|
+
|
64
|
+
state_name = get_state_name()
|
65
|
+
check_for_duplicate_states(item, warnings)
|
66
|
+
item.states[state_name] = get_state_value(item.data_type)
|
67
|
+
parse_additional_parameters(packet, cmd_or_tlm, item)
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def get_state_name
|
73
|
+
@parser.parameters[0].upcase
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_state_value(data_type)
|
77
|
+
if data_type == :STRING || data_type == :BLOCK
|
78
|
+
@parser.parameters[1]
|
79
|
+
else
|
80
|
+
@parser.parameters[1].convert_to_value
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def check_for_duplicate_states(item, warnings)
|
85
|
+
if item.states[get_state_name()]
|
86
|
+
msg = "Duplicate state defined on line #{@parser.line_number}: #{@parser.line}"
|
87
|
+
Logger.instance.warn(msg)
|
88
|
+
warnings << msg
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def parse_additional_parameters(packet, cmd_or_tlm, item)
|
93
|
+
return unless @parser.parameters.length > 2
|
94
|
+
|
95
|
+
if cmd_or_tlm == PacketConfig::COMMAND
|
96
|
+
get_hazardous(item)
|
97
|
+
else
|
98
|
+
get_state_colors(item)
|
99
|
+
packet.update_limits_items_cache(item)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def get_hazardous(item)
|
104
|
+
if @parser.parameters[2].upcase == 'HAZARDOUS'
|
105
|
+
item.hazardous ||= {}
|
106
|
+
if @parser.parameters[3]
|
107
|
+
item.hazardous[get_state_name()] = @parser.parameters[3]
|
108
|
+
else
|
109
|
+
item.hazardous[get_state_name()] = ""
|
110
|
+
end
|
111
|
+
else
|
112
|
+
raise @parser.error("HAZARDOUS expected as third parameter for this line.", @usage)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def get_state_colors(item)
|
117
|
+
color = @parser.parameters[2].upcase.to_sym
|
118
|
+
unless PacketItem::STATE_COLORS.include? color
|
119
|
+
raise @parser.error("Invalid state color #{color}. Must be one of #{PacketItem::STATE_COLORS.join(' ')}.", @usage)
|
120
|
+
end
|
121
|
+
|
122
|
+
item.limits.enabled = true
|
123
|
+
item.state_colors ||= {}
|
124
|
+
item.state_colors[get_state_name()] = color
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|