protected void processReceivedData(string incomingLine)
        {
            switch (interpreterState)
            {
                case InterpreterState.Idle:
                    // Here we are waiting for a string to indicate the start of return data
                    if (incomingLine == "!")
                        return;
                    else if (incomingLine.Contains("STATUS"))
                    {
                        // Check for correct length
                        if (incomingLine.Length != 7) return;
                        // Try to get focuser number
                        char s = incomingLine[6];
                        int currentFocNum = 0;
                        if (!int.TryParse(s.ToString(), out currentFocNum)) return;
                        // validate the focuser number
                        if (currentFocNum == 1)
                            responseType = InterpreterResponseType.STATUS1;
                        else if (currentFocNum == 2)
                            responseType = InterpreterResponseType.STATUS2;
                        else
                            return;
                        interpreterState = InterpreterState.WaitingForEnd;
                        responseData.Clear();
                    }
                    else if (incomingLine.Contains("CONFIG"))
                    {
                        // Check for correct length
                        if (incomingLine.Length != 7) return;
                        // Try to get focuser number
                        char s = incomingLine[6];
                        int currentFocNum = 0;
                        if (!int.TryParse(s.ToString(), out currentFocNum)) return;
                        // validate the focuser number and set the response type
                        if (currentFocNum == 1)
                        {
                            responseType = InterpreterResponseType.CONFIG1;
                            interpreterState = InterpreterState.WaitingForEnd;
                        }
                        else if (currentFocNum == 2)
                        {
                            responseType = InterpreterResponseType.CONFIG2;
                            interpreterState = InterpreterState.WaitingForEnd;
                        }
                        else
                            return;
                        interpreterState = InterpreterState.WaitingForEnd;
                        responseData.Clear();
                    }
                    else if (incomingLine.Contains("HUB INFO"))
                    {
                        responseType = InterpreterResponseType.HUBINFO;
                        interpreterState = InterpreterState.WaitingForEnd;
                        responseData.Clear();
                    }
                    else if (incomingLine == "M")
                    {
                    CheckForAnotherMoveAck:
                        if (pendingMoveAcks.Count > 0)
                        {
                            FocuserManualResetEvent mre = pendingMoveAcks.Dequeue();
                            if (mre != null)
                            {
                                if (mre.TimeoutOccurred)
                                {
                                    mre = null;
                                    goto CheckForAnotherMoveAck;
                                }
                                else
                                {
                                    mre.Set();
                                    mre = null;
                                }
                            }
                        }
                    }
                    else if (incomingLine == "SET")
                    {
                    CheckForAnotherSetAck:
                        if (pendingSetAcks.Count > 0)
                        {
                            FocuserManualResetEvent mre = pendingSetAcks.Dequeue();
                            if (mre != null)
                            {
                                if (mre.TimeoutOccurred)                // If a timeout occurred on a prior cmd request we are to assume
                                {                                       // that response was never received and thus we should remove it
                                    mre = null;                         // and trigger the next ResetEvent in the list
                                    goto CheckForAnotherSetAck;
                                }
                                else
                                {
                                    mre.Set();
                                    mre = null;
                                }
                            }
                        }
                    }
                    else if (incomingLine == "HALTED")
                    {
                    CheckForAnotherHaltAck:
                        if (pendingHaltAcks.Count > 0)
                        {
                            FocuserManualResetEvent mre = pendingHaltAcks.Dequeue();
                            if (mre != null)
                            {
                                if (mre.TimeoutOccurred)                // If a timeout occurred on a prior cmd request we are to assume
                                {                                       // that response was never received and thus we should remove it
                                    mre = null;                         // and trigger the next ResetEvent in the list
                                    goto CheckForAnotherHaltAck;
                                }
                                else
                                {
                                    mre.Set();
                                    mre = null;
                                }
                            }
                        }
                    }
                    else if (incomingLine == "H")
                    {
                    CheckForAnotherHomeAck:
                        if (pendingHomeAcks.Count > 0)
                        {
                            FocuserManualResetEvent mre = pendingHomeAcks.Dequeue();
                            if (mre != null)
                            {
                                if (mre.TimeoutOccurred)                // If a timeout occurred on a prior cmd request we are to assume
                                {                                       // that response was never received and thus we should remove it
                                    mre = null;                         // and trigger the next ResetEvent in the list
                                    goto CheckForAnotherHomeAck;
                                }
                                else
                                {
                                    mre.Set();
                                    mre = null;
                                }
                            }
                        }
                    }
                    else if (incomingLine.Contains("ER="))
                    {
                        EventLogger.LogMessage("Firmware error code received: " + incomingLine, System.Diagnostics.TraceLevel.Error);
                        try
                        {
                            FirmwareErrorOccurred(this, new FocuserDataReceivedEventArgs(new List<string>() { incomingLine }));
                        }
                        catch
                        {
                        }
                    }
                    break;

                case InterpreterState.WaitingForEnd:
                    if (incomingLine == "END")
                    {
                        switch (responseType)
                        {
                            case InterpreterResponseType.NONE:
                                break;
                            case InterpreterResponseType.CONFIG1:
                                disconnectWatchdog = 0;
                                Config1Received(this, new FocuserDataReceivedEventArgs(responseData));
                                break;
                            case InterpreterResponseType.CONFIG2:
                                disconnectWatchdog = 0;
                                Config2Received(this, new FocuserDataReceivedEventArgs(responseData));
                                break;
                            case InterpreterResponseType.STATUS1:
                                disconnectWatchdog = 0;
                                Status1Received(this, new FocuserDataReceivedEventArgs(responseData));
                                break;
                            case InterpreterResponseType.STATUS2:
                                disconnectWatchdog = 0;
                                Status2Received(this, new FocuserDataReceivedEventArgs(responseData));
                                break;
                            case InterpreterResponseType.HUBINFO:
                                disconnectWatchdog = 0;
                                HubInfoReceived(this, new FocuserDataReceivedEventArgs(responseData));
                                break;
                        }
                        interpreterState = InterpreterState.Idle;
                    }
                    else
                    {
                        // Add the data to the response
                        responseData.Add(incomingLine);
                        // Make sure we didn't miss the end.
                        if (responseData.Count > MAX_RESPONSE_LINE_COUNT)
                            interpreterState = InterpreterState.Idle;
                    }
                    break;

            }
        }
        protected void processReceivedData(string incomingLine)
        {
            switch (interpreterState)
            {
                case InterpreterState.Idle:
                    // Here we are waiting for a string to indicate the start of return data
                    if (incomingLine == "!")
                        return;
                    else if (incomingLine.Contains("STATUS - FOC"))
                    {
                        responseType = InterpreterResponseType.FOC_STATUS;
                        interpreterState = InterpreterState.WaitingForEnd;
                        responseData.Clear();
                    }
                    else if (incomingLine.Contains("STATUS - ROT"))
                    {
                        responseType = InterpreterResponseType.ROT_STATUS;
                        interpreterState = InterpreterState.WaitingForEnd;
                        responseData.Clear();
                    }
                    else if (incomingLine.Contains("CONFIG - FOC"))
                    {
                        responseType = InterpreterResponseType.FOC_CONFIG;
                        interpreterState = InterpreterState.WaitingForEnd;
                        responseData.Clear();
                    }
                    else if (incomingLine.Contains("CONFIG - ROT"))
                    {
                        responseType = InterpreterResponseType.ROT_CONFIG;
                        interpreterState = InterpreterState.WaitingForEnd;
                        responseData.Clear();
                    }
                    else if (incomingLine.Contains("HUB INFO"))
                    {
                        responseType = InterpreterResponseType.HUBINFO;
                        interpreterState = InterpreterState.WaitingForEnd;
                        responseData.Clear();
                    }
                    else if (incomingLine == "M")
                    {
                    CheckForAnotherMoveAck:
                        if (pendingMoveAcks.Count > 0)
                        {
                            FocuserManualResetEvent mre = pendingMoveAcks.Dequeue();
                            if (mre != null)
                            {
                                if (mre.TimeoutOccurred)
                                {
                                    mre = null;
                                    goto CheckForAnotherMoveAck;
                                }
                                else
                                {
                                    mre.Set();
                                    mre = null;
                                }
                            }
                        }
                    }
                    else if (incomingLine == "SET")
                    {
                    CheckForAnotherSetAck:
                        if (pendingSetAcks.Count > 0)
                        {
                            FocuserManualResetEvent mre = pendingSetAcks.Dequeue();
                            if (mre != null)
                            {
                                if (mre.TimeoutOccurred)                // If a timeout occurred on a prior cmd request we are to assume
                                {                                       // that response was never received and thus we should remove it
                                    mre = null;                         // and trigger the next ResetEvent in the list
                                    goto CheckForAnotherSetAck;
                                }
                                else
                                {
                                    mre.Set();
                                    mre = null;
                                }
                            }
                        }
                    }
                    else if (incomingLine == "HALTED")
                    {
                    CheckForAnotherHaltAck:
                        if (pendingHaltAcks.Count > 0)
                        {
                            FocuserManualResetEvent mre = pendingHaltAcks.Dequeue();
                            if (mre != null)
                            {
                                if (mre.TimeoutOccurred)                // If a timeout occurred on a prior cmd request we are to assume
                                {                                       // that response was never received and thus we should remove it
                                    mre = null;                         // and trigger the next ResetEvent in the list
                                    goto CheckForAnotherHaltAck;
                                }
                                else
                                {
                                    mre.Set();
                                    mre = null;
                                }
                            }
                        }
                    }
                    else if (incomingLine == "H")
                    {
                    CheckForAnotherHomeAck:
                        if (pendingHomeAcks.Count > 0)
                        {
                            FocuserManualResetEvent mre = pendingHomeAcks.Dequeue();
                            if (mre != null)
                            {
                                if (mre.TimeoutOccurred)                // If a timeout occurred on a prior cmd request we are to assume
                                {                                       // that response was never received and thus we should remove it
                                    mre = null;                         // and trigger the next ResetEvent in the list
                                    goto CheckForAnotherHomeAck;
                                }
                                else
                                {
                                    mre.Set();
                                    mre = null;
                                }
                            }
                        }
                    }
                    else if (incomingLine.Contains("ER="))
                    {
                        EventLogger.LogMessage("Firmware error code received: " + incomingLine, System.Diagnostics.TraceLevel.Error);
                        try
                        {
                            FirmwareErrorOccurred(this, new FocuserDataReceivedEventArgs(new List<string>() { incomingLine }));
                        }
                        catch
                        {
                        }
                    }
                    break;

                case InterpreterState.WaitingForEnd:
                    if (incomingLine == "END")
                    {
                        switch (responseType)
                        {
                            case InterpreterResponseType.NONE:
                                break;
                            case InterpreterResponseType.FOC_CONFIG:
                                disconnectWatchdog = 0;
                                FocConfigReceived(this, new FocuserDataReceivedEventArgs(responseData));
                                break;
                            case InterpreterResponseType.ROT_CONFIG:
                                disconnectWatchdog = 0;
                                RotConfigReceived(this, new FocuserDataReceivedEventArgs(responseData));
                                break;
                            case InterpreterResponseType.FOC_STATUS:
                                disconnectWatchdog = 0;
                                FocStatusReceived(this, new FocuserDataReceivedEventArgs(responseData));
                                break;
                            case InterpreterResponseType.ROT_STATUS:
                                disconnectWatchdog = 0;
                                RotStatusReceived(this, new FocuserDataReceivedEventArgs(responseData));
                                break;
                            case InterpreterResponseType.HUBINFO:
                                disconnectWatchdog = 0;
                                HubInfoReceived(this, new FocuserDataReceivedEventArgs(responseData));
                                break;
                        }
                        interpreterState = InterpreterState.Idle;
                    }
                    else
                    {
                        // Add the data to the response
                        responseData.Add(incomingLine);
                        // Make sure we didn't miss the end.
                        if (responseData.Count > MAX_RESPONSE_LINE_COUNT)
                            interpreterState = InterpreterState.Idle;
                    }
                    break;

            }
        }