示例#1
0
 public IEnumerator <ITask> ReplaceHandler(pxContactSensor.Replace replace)
 {
     _state = replace.Body;
     replace.ResponsePort.Post(dssp.DefaultReplaceResponseType.Instance);
     _subMgrPort.Post(new submgr.Submit(_state, dssp.DsspActions.ReplaceRequest));
     yield break;
 }
示例#2
0
        public IEnumerator <ITask> ReplaceHandler(bumper.Replace replace)
        {
            if (_subscribed)
            {
                throw new InvalidOperationException("Already subscribed");
            }
            else if (ValidState(replace.Body))
            {
                _bumperConfigState.ContactSensorArrayState = replace.Body;
                SaveState(_bumperConfigState);

                Port <bool> subscribeDonePort = new Port <bool>();
                SpawnIterator <Port <bool> >(subscribeDonePort, SubscribeToNXT);
                yield return(Arbiter.Receive <bool>(false, subscribeDonePort,
                                                    delegate(bool success)
                {
                    if (success)
                    {
                        replace.ResponsePort.Post(DefaultReplaceResponseType.Instance);
                    }
                    else
                    {
                        replace.ResponsePort.Post(
                            Fault.FromCodeSubcodeReason(FaultCodes.Receiver,
                                                        DsspFaultCodes.OperationFailed,
                                                        "LegoNxtBumper service subscription to LEGO NXT Brick failed")
                            );
                    }
                }));
            }
            else
            {
                throw new InvalidOperationException("Invalid State");
            }

            yield break;
        }
示例#3
0
 public virtual IEnumerator <ITask> ReplaceHandler(bumper.Replace replace)
 {
     _state = replace.Body;
     replace.ResponsePort.Post(DefaultReplaceResponseType.Instance);
     yield break;
 }
 public virtual IEnumerator <ITask> ReplaceHandler(contactsensor.Replace replace)
 {
     replace.ResponsePort.Post(Fault.FromException(new InvalidOperationException("The LEGO NXT touch sensor is updated from hardware.")));
     yield break;
 }
 /// <summary>
 /// Handles Replace notifications from the Bumper partner - updating state of the whole set of sensors
 /// </summary>
 /// <remarks>Posts a <typeparamref name="BumpersArrayUpdate"/> to itself.</remarks>
 /// <param name="replace">notification</param>
 void BumperReplaceNotification(bumper.Replace replace)
 {
     LogInfo("DriveBehaviorServiceBase: BumperReplaceNotification()");
     _mainPort.Post(new BumpersArrayUpdate(replace.Body));
 }
示例#6
0
 /// <summary>
 /// Handles Replace notifications from the Bumper partner
 /// </summary>
 /// <remarks>Posts a <typeparamref name="BumpersUpdate"/> to itself.</remarks>
 /// <param name="replace">notification</param>
 void BumperReplaceNotification(bumper.Replace replace)
 {
     _mainPort.Post(new BumpersUpdate(replace.Body));
 }
示例#7
0
 /// <summary>
 /// Handles Replace notifications from the Bumper partner
 /// </summary>
 /// <remarks>Posts a <typeparamref name="BumpersUpdate"/> to itself.</remarks>
 /// <param name="replace">notification</param>
 void BumperReplaceNotification(bumper.Replace replace)
 {
     LogInfo("Explorer: BumperReplaceNotification()");
     _mainPort.Post(new BumpersUpdate(replace.Body));
 }
 public virtual IEnumerator <ITask> GenericReplaceHandler(bumper.Replace replace)
 {
     throw new InvalidOperationException("The LEGO NXT Contact Sensor Array is configured by the LEGO NXT Brick service.");
 }