Sha256: b093d470bae59d0431e4a54e68991a3bc898cc914b2d816ab80511c5c0e9418a

Contents?: true

Size: 1.5 KB

Versions: 5

Compression:

Stored size: 1.5 KB

Contents

# encoding: ascii-8bit

# Copyright 2022 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 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 program may also be used under the terms of a commercial or
# enterprise edition license of COSMOS if purchased from the
# copyright holder

require 'cosmos'
require 'cosmos/bridge/bridge_config'
require 'cosmos/bridge/bridge_interface_thread'
require 'cosmos/bridge/bridge_router_thread'

module Cosmos
  class Bridge
    def initialize(filename)
      @config = BridgeConfig.new(filename)
      @threads = []

      # Start Interface Threads
      @config.interfaces.each do |interface_name, interface|
        @threads << BridgeInterfaceThread.new(interface)
        @threads[-1].start
      end

      # Start Router Threads
      @config.routers.each do |router_name, router|
        @threads << BridgeRouterThread.new(router)
        @threads[-1].start
      end

      at_exit() do
        shutdown()
      end
    end

    def shutdown
      @threads.each do |thread|
        thread.stop
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cosmos-5.0.5 lib/cosmos/bridge/bridge.rb
cosmos-5.0.4 lib/cosmos/bridge/bridge.rb
cosmos-5.0.3 lib/cosmos/bridge/bridge.rb
cosmos-5.0.2 lib/cosmos/bridge/bridge.rb
cosmos-5.0.2.pre.beta2 lib/cosmos/bridge/bridge.rb