Class: OpenC3::StateParser
- Defined in:
- lib/openc3/packets/parsers/state_parser.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_state(packet, cmd_or_tlm, item, warnings) ⇒ Object
-
#initialize(parser) ⇒ StateParser
constructor
A new instance of StateParser.
- #verify_parameters(cmd_or_tlm) ⇒ Object
Constructor Details
#initialize(parser) ⇒ StateParser
Returns a new instance of StateParser.
43 44 45 |
# File 'lib/openc3/packets/parsers/state_parser.rb', line 43 def initialize(parser) @parser = parser end |
Class Method Details
.parse(parser, packet, cmd_or_tlm, item, warnings) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/openc3/packets/parsers/state_parser.rb', line 33 def self.parse(parser, packet, cmd_or_tlm, item, warnings) raise parser.error("Items with LIMITS can't define STATE") if item.limits.values raise parser.error("Items with UNITS can't define STATE") if item.units parser = StateParser.new(parser) parser.verify_parameters(cmd_or_tlm) parser.create_state(packet, cmd_or_tlm, item, warnings) end |
Instance Method Details
#create_state(packet, cmd_or_tlm, item, warnings) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/openc3/packets/parsers/state_parser.rb', line 64 def create_state(packet, cmd_or_tlm, item, warnings) item.states ||= {} state_name = get_state_name() check_for_duplicate_states(item, warnings) item.states[state_name] = get_state_value(item.data_type) parse_additional_parameters(packet, cmd_or_tlm, item) end |
#verify_parameters(cmd_or_tlm) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/openc3/packets/parsers/state_parser.rb', line 48 def verify_parameters(cmd_or_tlm) @usage = "STATE <STATE NAME> <STATE VALUE> " if cmd_or_tlm == PacketConfig::COMMAND @usage << "<HAZARDOUS / DISABLE_MESSAGES (Optional)> <Hazardous Description (Optional)>" @parser.verify_num_parameters(2, 4, @usage) else @usage << "<COLOR: GREEN/YELLOW/RED (Optional)>" @parser.verify_num_parameters(2, 3, @usage) end end |