private void connectButton_Click(object sender, EventArgs e)
        {
            if (logbook == null)
            {
                disconnectLogbook = false;
                logbook = new Logbook(logbookPort);

                logbook.CommandResult += new CommandResultEventHandler(logbook_CommandResult);
                logbook.CommandFailed += new CommandFailedEventHandler(logbook_CommandFailed);
                logbook.CommandTimeout += new CommandTimeoutEventHandler(logbook_CommandTimeout);
                logbook.CommandQueueFull += new CommandQueueFullEventHandler(logbook_CommandQueueFull);
                logbook.Disconnected += new EventHandler(logbook_Disconnected);

                log.Append("connectButton_Click", String.Format("Connecting Logbook on {0}", logbookPort));
                try
                {
                    logbook.Activate();
                }
                catch (LogbookConnectionException ex)
                {
                    log.LogException(ex);
                }
            }
            else
            {
                if (!logbook.IsActive)
                {
                    log.Append("connectButton_Click", String.Format("Reactivating Logbook on {0}", logbookPort));
                    logbook.Activate();
                }
            }
        }
 public CommandFailedEventArgs(Logbook.Command command, byte[] data)
 {
     this.command = command;
     this.response = new byte[data.Length];
     Array.Copy(data, response, data.Length);
     this.reason = "";
 }
Esempio n. 3
0
        private void LogbookThread()
        {
            logbook = new Logbook(logbookPort);

             logbook.CommandResult += new CommandResultEventHandler(logbook_CommandResult);
             logbook.CommandTimeout += new CommandTimeoutEventHandler(logbook_CommandTimeout);
             logbook.CommandFailed += new CommandFailedEventHandler(logbook_CommandFailed);
             logbook.Disconnected += new EventHandler(logbook_Disconnected);
        }
        public ConnectLogbookForm(Logbook logbook)
        {
            InitializeComponent();
             updateLabel = new LabelTextDelegate(DoUpdateLabel);

             this.logbook = logbook;

             logbook_CommandResultHandler = new CommandResultEventHandler(logbook_CommandResult);
             logbook_CommandFailedHandler = new CommandFailedEventHandler(logbook_CommandFailed);
             logbook_CommandTimeoutHandler = new CommandTimeoutEventHandler(logbook_CommandTimeout);
             logbook_DisconnectedHandler = new EventHandler(logbook_Disconnected);
             activateTimerCallback += new TimerCallback(activateTimerPing);

             logbook.CommandResult += logbook_CommandResultHandler;
             logbook.CommandFailed += logbook_CommandFailedHandler;
             logbook.CommandTimeout += logbook_CommandTimeoutHandler;
             logbook.Disconnected += logbook_DisconnectedHandler;

             if (logbook.IsActive)
             {
            UpdateLabel(statusLabel, "Connected");
             }
        }
 //Constructor.
 public CommandQueueFullEventArgs(Logbook.Command command)
 {
     failedCommand = command;
 }
 public CommandFailedEventArgs(Logbook.Command command)
 {
     this.command = command;
     this.response = new byte[0];
     this.reason = "";
 }
        //Constructor.
        public CommandTimeoutEventArgs(Logbook.Command command, byte[] responseSoFar)
        {
            failedCommand = command;

            failedResponse = new byte[responseSoFar.Length];
            failedResponse = responseSoFar;
        }
 //Constructor.
 public CommandResultEventArgs(byte[] resultGot, Logbook.Command newCommand)
 {
     result = new byte[resultGot.Length];
     result = resultGot;
     command = newCommand;
 }
Esempio n. 9
0
        private void logbook_sendCommand(Logbook.Command command)
        {
            try
             {
            if (logbook.IsActive)
            {
               log.Append("logbook_sendCommand", String.Format("Sending {0}", command.name));
               if (logbookConnectionError)
               {
                  log.Append("logbook_sendCommand", "Logbook connection error - reconnecting");
                  logbook.reconnect();
                  logbookConnectionError = false;

               }
               logbook.sendCommand(command);
            }
             }
             catch (Exception ex)
             {
            logbookConnectionError = true;
            log.LogException(ex);
             }
        }
        private void DesktopLogbookTest_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (logbook != null)
            {
                if (logbook.IsActive)
                {
                    log.Append("DesktopLogbookTest_FormClosing", "Deactivating Logbook");
                    logbook.Deactivate();
                    logbook = null;
                }

            }
        }
Esempio n. 11
0
 private void LogbookThread()
 {
     logbook = new Logbook(logbookPort);
 }