예제 #1
0
        public void ProcessResponse(char[] response)
        {
            // check that the first two chars are 'M' and 'S'
            if (response[0] != Command[0] || response[1] != Command[1])
            {
                throw new SweepProtocolErrorException("Expected answer to MS command, received different header", response);
            }

            // validate the checksum
            if (!SweepProtocolHelpers.StatusChecksumValid(response))
            {
                throw new SweepProtocolErrorException("Checksum is not valid", response);
            }

            // check if the echoed motor speed code matches what we sent
            var echoedSpeedcode = (SweepMotorSpeed)SweepProtocolHelpers.AsciiBytesToInt(response, 2, 2);

            if (echoedSpeedcode != this.TargetSpeed)
            {
                throw new SweepProtocolErrorException("Echoed speed code missmatched", response);
            }

            // analyze the status
            this.Status = (AdjustMotorSpeedResult)SweepProtocolHelpers.AsciiBytesToInt(response, 5, 2);
        }
예제 #2
0
        public void ProcessResponse(char[] response)
        {
            // check that the first two chars are 'M' and 'Z'
            if (response[0] != Command[0] || response[1] != Command[1])
            {
                throw new SweepProtocolErrorException("Expected answer to DS command, received different header", response);
            }

            // validated the checksum
            if (!SweepProtocolHelpers.StatusChecksumValid(response))
            {
                throw new SweepProtocolErrorException("Checksum is not valid", response);
            }

            // decode the status
            var r = new string(response, 2, 2);

            this.Success = (r == "00");
        }