Exemple #1
0
        /// <summary>Determines if the returned status code indicates that the last operation was executed successfully (then it returns), otherwise a PTControllerException is raised.</summary>
        private void ValidateResult(Byte result, bool async)
        {
            result = Utility.GetUnsignedByteValue(result);

            const byte asyncMin = (byte)PTResult.PanLimitHit;
            const byte asyncMax = (byte)PTResult.TiltSpeedTriggerHit;

            if (async)
            {
                while (result >= asyncMin && result <= asyncMax)
                {
                    if (result == (byte)PTResult.CableDisconnectDetected)
                    {
                        throw new PTControllerException("Asynchronous Cable Disconnection detected");
                    }

                    result = _c.GetByte();
                    result = Utility.GetUnsignedByteValue(result);
                }
            }

            if (result != (byte)PTResult.Ok)
            {
                const byte errorMin = (byte)PTResult.IllegalCommandArgument;
                const byte errorMax = (byte)PTResult.FirmwareVersionTooLow;

                if (result >= errorMin && result <= errorMax)
                {
                    PTResult ptResult = (PTResult)result;
                    throw new PTControllerException(ptResult);
                }
                else if (result == (Byte)PTCommand.Halt)
                {
                    // NOOP
                }
                else
                {
                    // There are a few anomalous results I haven't been able to reliably reproduce
                    // there was one in the 80s, and another around 250

                    throw new PTControllerException("Non-OK but Unknown Result: " + result);
                }
            }
        }
Exemple #2
0
 public PTControllerException(PTResult result) : base("Controller Error: " + result.ToString())
 {
     Result = result;
 }
Exemple #3
0
 public PTControllerException(String message) : base(message)
 {
     Result = PTResult.Ok;
 }