Exemplo n.º 1
0
 public void Run()
 {
     try
     {
         SiDriverState currentState = StartupBootstrap();
         while (IsAlive(currentState))
         {
             GecoSiLogger.StateChanged(currentState.GetType().Name);
             currentState = currentState.Receive(messageQueue, writer, siHandler);
         }
         if (currentState.IsError())
         {
             siHandler.NotifyError(CommStatus.FatalError, currentState.Status());
         }
     }
     catch (ThreadInterruptedException e)
     {
         // normal way out
     }
     catch (Exception e)
     {
         e.PrintStackTrace();
         GecoSiLogger.Error(" #run# " + e);
     }
     finally
     {
         Stop();
     }
 }
Exemplo n.º 2
0
 protected SiDriverState RetrieveDataMessages(SiMessageQueue queue, ICommWriter writer, SiHandler siHandler,
                                              SiMessage[] readoutCommands, int nbPunchesIndex, String timeoutMessage)
 {
     try
     {
         GecoSiLogger.StateChanged(GetType().Name);
         SiMessage readoutCommand = readoutCommands[0];
         writer.Write(readoutCommand);
         SiMessage firstDataBlock = PollAnswer(queue, readoutCommand.CommandByte());
         int       nbDataBlocks   = (nbPunchesIndex == -1)
             ? readoutCommands.Length
             : ExtractNumberOfDataBlocks(firstDataBlock, nbPunchesIndex);
         var dataMessages = new SiMessage[nbDataBlocks];
         dataMessages[0] = firstDataBlock;
         for (int i = 1; i < nbDataBlocks; i++)
         {
             readoutCommand = readoutCommands[i];
             writer.Write(readoutCommand);
             dataMessages[i] = PollAnswer(queue, readoutCommand.CommandByte());
         }
         siHandler.Notify(CreateDataFrame(dataMessages));
         return(ACK_READ.Send(writer, siHandler));
     }
     catch (TimeoutException e)
     {
         return(ErrorFallback(siHandler, timeoutMessage));
     }
     catch (InvalidMessage e)
     {
         return(ErrorFallback(siHandler, "Invalid message: " + e.ReceivedMessage()));
     }
 }