Sha256: 35382289496f26e2636bf556ee93b632972091a79d78264d538c158b31d6b0d1

Contents?: true

Size: 1.62 KB

Versions: 5

Compression:

Stored size: 1.62 KB

Contents

# encoding: ascii-8bit

# Copyright 2024 OpenC3, Inc.
# All Rights Reserved.
#
# This program is free software; you can modify and/or redistribute it
# under the terms of the GNU Affero General Public License
# as published by the Free Software Foundation; version 3 with
# attribution addendums as found in the LICENSE.txt
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# This file may also be used under the terms of a commercial license
# if purchased from OpenC3, Inc.

require 'openc3/packets/command_validator'

class InstCmdValidator < OpenC3::CommandValidator
  def pre_check(command)
    # Record the current value of CMD_ACPT_CNT for comparison in post_check
    @cmd_acpt_cnt = tlm("<%= target_name %> HEALTH_STATUS CMD_ACPT_CNT")
    return [true, nil]
  end

  def post_check(command)
    if command.packet_name == 'TIME_OFFSET'
      # Return Failure with a message
      return [false, 'TIME_OFFSET failure description']
    end
    if command.packet_name == 'MEMLOAD'
      # Return Unknown with a message
      return [nil, 'MEMLOAD validation unknown']
    end
    if command.packet_name == 'CLEAR'
      wait_check("<%= target_name %> HEALTH_STATUS CMD_ACPT_CNT == 0", 10)
      # Return Success with a message
      return [true, "CMD_ACPT_CNT cleared"]
    else
      wait_check("<%= target_name %> HEALTH_STATUS CMD_ACPT_CNT > #{@cmd_acpt_cnt}", 10)
      # Return Success without a message
      return [true, nil]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
openc3-cosmos-demo-6.0.2 targets/INST/lib/inst_cmd_validator.rb
openc3-cosmos-demo-6.0.1 targets/INST/lib/inst_cmd_validator.rb
openc3-cosmos-demo-6.0.0 targets/INST/lib/inst_cmd_validator.rb
openc3-cosmos-demo-5.20.0 targets/INST/lib/inst_cmd_validator.rb
openc3-cosmos-demo-5.19.0 targets/INST/lib/inst_cmd_validator.rb