Sha256: a836e59f61e38fcf19c392a177d6fd3abb863563fdd20bf156c1e793cf720ffe

Contents?: true

Size: 1.45 KB

Versions: 32

Compression:

Stored size: 1.45 KB

Contents

# encoding: ascii-8bit

# Copyright 2014 Ball Aerospace & Technologies Corp.
# All Rights Reserved.
#
# This program is free software; you can modify and/or redistribute it
# under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 3 with
# attribution addendums as found in the LICENSE.txt

# This file implements an example background task

require 'cosmos/tools/cmd_tlm_server/background_task'

module Cosmos

  # ExampleBackgroundTask class
  #
  # This class is an example background task
  #
  class ExampleBackgroundTask < BackgroundTask

    def initialize
      super()
      @name = 'Example Background Task'
      @sleeper = Sleeper.new
    end

    def call
      sent_count = 0
      @status = "Sleeping for 5 seconds"
      return if @sleeper.sleep(5) # allow interfaces time to start
      loop do
        #Make sure we start up with 3 collects
        if (tlm('INST', 'HEALTH_STATUS', 'COLLECTS') < 3)
          begin
            cmd('INST', 'COLLECT', 'TYPE' => 'NORMAL', 'DURATION' => 1)
            sent_count += 1
            @status = "Sent COLLECT ##{sent_count} at #{Time.now.formatted}"
          rescue
            # Oh well - probably disconnected
          end
        else
          break
        end
        return if @sleeper.sleep(1)
      end
      @status = "Finished at #{Time.now.formatted}"
    end

    def stop
      @sleeper.cancel
    end

  end # class ExampleBackgroundTask

end # module Cosmos

Version data entries

32 entries across 25 versions & 1 rubygems

Version Path
cosmos-3.8.3 demo/lib/example_background_task.rb
cosmos-3.8.2 demo/lib/example_background_task.rb
cosmos-3.8.1 demo/lib/example_background_task.rb
cosmos-3.8.0 demo/lib/example_background_task.rb
cosmos-3.7.1 demo/lib/example_background_task.rb
cosmos-3.7.0 demo/lib/example_background_task.rb
cosmos-3.6.3 demo/lib/example_background_task.rb
cosmos-3.6.2 demo/lib/example_background_task.rb
cosmos-3.6.1 demo/lib/example_background_task.rb
cosmos-3.6.0 demo/lib/example_background_task.rb
cosmos-3.5.3 demo/lib/example_background_task.rb
cosmos-3.5.2 demo/lib/example_background_task.rb
cosmos-3.5.0 demo/lib/example_background_task.rb
cosmos-3.4.2 test/performance/lib/example_background_task.rb
cosmos-3.4.2 demo/lib/example_background_task.rb
cosmos-3.4.1 test/performance/lib/example_background_task.rb
cosmos-3.4.1 demo/lib/example_background_task.rb
cosmos-3.4.0 test/performance/lib/example_background_task.rb
cosmos-3.4.0 demo/lib/example_background_task.rb
cosmos-3.3.3 test/performance/lib/example_background_task.rb