Ejemplo n.º 1
1
        public void Execute(Protocol protocol)
        {
            log.Debug("TestRequestCommand:Execute");

            try
            {
                protocol.Send(_message);
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
                throw;
            }
        }
Ejemplo n.º 2
1
            /// <summary>
            /// Unistalira handlere
            /// </summary>
            /// <param name="protocol"></param>
            public override void UnInstallHandlers(Protocol protocol)
            {
                log.Debug("ReceiverSate:UnInstallHandlers");

                try
                {
                    protocol.FrameReceived -= FrameReceiveHandler;
                    protocol.EotReceived -= EotReceiveHandler;
                }
                catch (Exception ex)
                {
                    log.Error(ex.ToString());
                    throw;
                }
            }
Ejemplo n.º 3
1
            /// <summary>
            /// Unistalira handler, ova metoda se poziva prilikom tranzicije u novo stanje
            /// </summary>
            /// <param name="protocol"></param>
            public override void UnInstallHandlers(Protocol protocol)
            {
                log.Debug("IdleState:UnInstallHandlers");

                try
                {
                    protocol.AckReceived -= AckReceiveHandler;
                    protocol.EnqReceived -= EnqReceiveHandler;
                    protocol.UnknownReceived -= UnknownReceiveHandler;
                }
                catch (Exception ex)
                {
                    log.Error(ex.ToString());
                    throw;
                }
            }
Ejemplo n.º 4
1
            /// <summary>
            /// U idle modu prvo saljemo ENQ karakter i startamo timer
            /// Ukoliko uredjaj ne odovori timer handler ce se pozvati kad istekne timer
            /// </summary>
            /// <param name="protocol"></param>
            /// <param name="message"></param>
            public override void Send(Protocol protocol, string message)
            {
                log.DebugFormat("IdleState:Send:Message={0}",message);

                try
                {
                    _message = message;
                    _message_sent = true;

                    protocol.SendEnq();
                    protocol.AckTimer.Interval = Timeout.NoResponseTimeOut;
                    _timerHandler = new ElapsedEventHandler(bind<object, ElapsedEventArgs, Protocol>(TimeoutHandler, protocol));
                    protocol.AckTimer.Elapsed += _timerHandler;
                    protocol.AckTimer.Start();
                }
                catch (Exception ex)
                {
                    log.Error(ex.ToString());
                    throw;
                }
            }
Ejemplo n.º 5
1
 public CobasProtocolBulder()
 {
     _protocol = new CobasProtocol();
 }
Ejemplo n.º 6
1
 public CobasProtocolBuilder(Mode mode, CommandDispatcherParams param)
 {
     log.Debug("CobasProtocolBuilder:ctor");
     _command_dispatcher_param = param;
     _protocol = new CobasProtocol();
     _protocol.Mode = mode;
     _protocol.Entity = Entity.Host;
 }
Ejemplo n.º 7
1
            /// <summary>
            /// Handler koji se poziva kad istekne timer
            /// Ovo je 10 sekundni timer starta se ukoliko kao odgovor na ENQ ne dobijemo ACK vec neto drugo
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            /// <param name="protocol"></param>
            private void TimeoutUnknownHandler(object sender, ElapsedEventArgs e, Protocol protocol)
            {
                log.Debug("IdleState:TimeoutUnknownHandler");

                try
                {
                    protocol.AckTimer.Elapsed -= _timerHandler;
                    protocol.SendEot();
                    protocol.ChangeState(Idle);

                    CleanState();
                    protocol._waitHandle.Set();

                    log.Error("IdleState:TimeoutUnknownHandler:Answer is not [ACK]");
                }
                catch (Exception ex)
                {
                    log.Error(ex.ToString());
                    throw;
                }
            }
Ejemplo n.º 8
1
            /// <summary>
            /// Handler koji se poziva kad istekne timer
            /// Ovo je 15 sekundni timer starta se kad posaljemo ENQ
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            /// <param name="protocol"></param>
            private void TimeoutHandler(object sender, ElapsedEventArgs e, Protocol protocol)
            {
                log.Debug("IdleState:TimeoutHandler");

                try
                {
                    protocol.AckTimer.Elapsed -= _timerHandler;
                    protocol.SendEot();

                    CleanState();
                    protocol._waitHandle.Set();
                    log.Error("IdleState:TimeoutHandler:No answer from host");
                }
                catch (Exception ex)
                {
                    log.Error(ex.ToString());
                    throw;
                }
            }
Ejemplo n.º 9
1
        /// <summary>
        /// Kreira protokol i zakaci handlere
        /// </summary>
        /// <param name="args"></param>
        public void Start(string[] args)
        {
            try
            {
                log.Info(StartTrace());
                _protocol = Protocol.Create(new SerialCobasProtocolBuilder(_protocol_mode,
                                                                           new CommandDispatcherParams() { DeviceName = _file_dispatcher_device_name,
                                                                                                           Path = _file_dispatcher_path,
                                                                                                           Extension = _file_dispatcher_extension,
                                                                                                           OutExtension = _file_dispatcher_out_extension},
                                                                           new SerialDispatcherParams()  { PortName = _serial_dispatcher_port_name,
                                                                                                           BaudRate = _serial_dispatcher_baudrate,
                                                                                                           StopBits = _serial_dispatcher_stop_bits,
                                                                                                           DataBits = _serial_dispatcher_data_bits,
                                                                                                           Handshake = _serial_dispatcher_handshake,
                                                                                                           Parity = _serial_dispatcher_parity}));
                _protocol.ResultReportMessage += new Protocol.MessageEvent(ResultReportMessageHandler);
                _protocol.ResultReportBatchMessage += new Protocol.MessageEvent(ResultReportBatchMessageHandler);
                _protocol.InquiryTestRequestMessage += new Protocol.MessageEvent(InquiryTestRequestMessageHandler);

                _protocol.Start();
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
                smtpLog.Error(ex.ToString());
                Debugging.SendAttachment(Debugging.CollectFiles());
            }
        }
Ejemplo n.º 10
1
            /// <summary>
            /// Ukoliko dodje zahtjev za slanjem nove poruke, a mi smo u receiver state-u, onda 
            /// spremamo poruku za slanje poslije
            /// </summary>
            /// <param name="protocol"></param>
            /// <param name="message"></param>
            public override void Send(Protocol protocol, string message)
            {
                log.DebugFormat("ReceiverSate:Send: Message={0}",message);

                _pending_messages.Add(message);
            }