Esempio n. 1
0
        /// <summary>
        /// Binds together the instances of communication objects and starts
        /// whatever process are necessary
        /// </summary>
        /// <param name="inQueue">The input queue wrapper</param>
        /// <param name="outQueue">The output queue wrapper</param>
        public void Initialize(FecsBecsInputWrapper inQueue,
                               BecsFecsOutputWrapper outQueue)
        {
            AppSettingsReader appSettings = new AppSettingsReader();

            _unitId = (string)appSettings.GetValue("UnitID", typeof(string));

            Parameterization.SourceId = _unitId;
            _inAdapter  = new InputQueueBecsAdapter(inQueue);
            _outAdapter = new OutputQueueBecsAdapter(outQueue);
            _channelMgr = new BecsChannelManager(_outAdapter, _inAdapter);
            _inAdapter.ChannelManager       = _channelMgr;
            Parameterization.ChannelManager = _channelMgr;
            _mediaCtx = new BecsMediaContext();
            Parameterization.MediaContext = _mediaCtx;
            _msgRouter = new SimpleMessageRouter();
            Parameterization.MessageRouter = _msgRouter;
            Receiver.GetInstance().MessagesAvailable +=
                new Receiver.MessagesAvailableHandler(_msgRouter.OnMessagesAvailable);
            _dispatcher = new BecsMsgDispatcher();
            _msgRouter.MessageReceived   += new MessageReceivedHandler(_dispatcher.OnMessageReceived);
            _msgRouter.ResponsesReceived += new ResponsesReceivedHandler(_dispatcher.OnResponsesReceived);

            _msgConfig = new CSMessageConfiguration();
            _sender    = new MessageSender(_msgConfig);

            RegisterMessageHandlers();

            int period = (int)appSettings.GetValue("SendPeriod", typeof(int));

            _sender.Start(period);
        }
 public BecsChannel(OutputQueueBecsAdapter outAdapter,
                    InputQueueBecsAdapter inAdapter)
 {
     _outAdapter = outAdapter;
     _inAdapter  = inAdapter;
 }
 /// <summary>
 /// Constructor receiving the adapters for the input and iutput queues
 /// </summary>
 /// <param name="outQueue">The adapter for the output queue</param>
 /// <param name="inQueue">The adapter for the input queue</param>
 public BecsChannelManager(OutputQueueBecsAdapter outQueue,
                           InputQueueBecsAdapter inQueue)
 {
     _outQueue = outQueue;
     _inQueue  = inQueue;
 }