コード例 #1
0
 void ExceptionHandler(Exception e)
 {
     _internalPort.Post(e);
 }
コード例 #2
0
ファイル: SickLRF.cs プロジェクト: yangyuanling/TrackRoamer
        IEnumerator <ITask> PowerOn(LinkPowerOn powerOn)
        {
            bool failed = false;

            Tracer.Trace("SickLRF::PowerOn()");

            _state.Description = powerOn.Description;
            _state.LinkState   = "Power On: " + powerOn.Description;
            LogInfo(_state.LinkState);

            //
            // the device has powered on. Set the BaudRate to the highest supported.
            //

            yield return(Arbiter.Choice(
                             _link.SetDataRate(9600),
                             delegate(SuccessResult success)
            {
                _state.LinkState = "Baud Rate set to " + 9600;
                LogInfo(_state.LinkState);
            },
                             delegate(Exception failure)
            {
                _internalPort.Post(failure);
                failed = true;
            }
                             ));

            if (failed)
            {
                yield break;
            }

            Tracer.Trace("SickLRF::Opening the port");

            /*
             * //
             * // wait for confirm to indicate that the LRF has received the new baud rate and is
             * // expecting the serial rate to change imminently.
             * //
             *
             * yield return Arbiter.Choice(
             *  Arbiter.Receive<LinkConfirm>(false,_internalPort,
             *      delegate(LinkConfirm confirm)
             *      {
             *          // the confirm indicates that the LRF has recieved the new baud rate
             *      }),
             *  Arbiter.Receive<DateTime>(false, TimeoutPort(1000),
             *      delegate(DateTime time)
             *      {
             *          _internalPort.Post(new TimeoutException("Timeout waiting for Confirm while setting data rate"));
             *          failed = true;
             *      })
             * );
             *
             * if (failed)
             * {
             *  yield break;
             * }
             *
             * //
             * // Set the serial rate to the rate requested above.
             * //
             *
             * yield return Arbiter.Choice(
             *  _link.SetRate(),
             *  delegate(SuccessResult success)
             *  {
             *      _state.LinkState = "Changed Rate to: " + _link.BaudRate;
             *      LogInfo(_state.LinkState);
             *  },
             *  delegate(Exception failure)
             *  {
             *      _internalPort.Post(failure);
             *      failed = true;
             *  }
             * );
             *
             * if (failed)
             * {
             *  yield break;
             * }
             *
             * //
             * // start continuous measurements.
             * //
             *
             * yield return Arbiter.Choice(
             *  _link.SetContinuous(),
             *  delegate(SuccessResult success)
             *  {
             *      _state.LinkState = "Starting Continuous Measurement";
             *      LogInfo(_state.LinkState);
             *  },
             *  delegate(Exception failure)
             *  {
             *      _internalPort.Post(failure);
             *      failed = true;
             *  }
             * );
             *
             * if (failed)
             * {
             *  yield break;
             * }
             *
             * //
             * // wait for confirm message that signals that the LRF is now in continuous measurement mode.
             * //
             *
             * yield return Arbiter.Choice(
             *  Arbiter.Receive<LinkConfirm>(false, _internalPort,
             *      delegate(LinkConfirm confirm)
             *      {
             *          // received Confirm
             *      }),
             *  Arbiter.Receive<DateTime>(false, TimeoutPort(1000),
             *      delegate(DateTime time)
             *      {
             *          _internalPort.Post(new TimeoutException("Timeout waiting for Confirm after setting continuous measurement mode"));
             *      })
             * );
             *
             * yield break;
             * */
        }
コード例 #3
0
        void ExceptionHandler(Exception e)
        {
            Tracer.Trace("CommLink::ExceptionHandler() exc=" + e);

            _internalPort.Post(e);
        }