IEnumerator <ITask> OnConnectMotorHandler(OnConnectMotor onConnectMotor)
        {
            if (onConnectMotor.DriveControl == _driveControl)
            {
                drive.EnableDriveRequest request = new drive.EnableDriveRequest(false);
                if (_drivePort != null)
                {
                    yield return(Arbiter.Choice(
                                     _drivePort.EnableDrive(request),
                                     delegate(DefaultUpdateResponseType response) { },
                                     delegate(Fault f)
                    {
                        LogError(f);
                    }
                                     ));

                    if (_motorShutdown != null)
                    {
                        PerformShutdown(ref _motorShutdown);
                    }
                }

                _drivePort     = ServiceForwarder <drive.DriveOperations>(onConnectMotor.Service);
                _motorShutdown = new Port <Shutdown>();

                drive.ReliableSubscribe subscribe = new drive.ReliableSubscribe(
                    new ReliableSubscribeRequestType(10)
                    );
                subscribe.NotificationPort         = _driveNotify;
                subscribe.NotificationShutdownPort = _motorShutdown;

                _drivePort.Post(subscribe);

                yield return(Arbiter.Choice(
                                 subscribe.ResponsePort,
                                 delegate(SubscribeResponseType response)
                {
                    LogInfo("Subscribed to " + onConnectMotor.Service);
                },
                                 delegate(Fault fault)
                {
                    _motorShutdown = null;
                    LogError(fault);
                }
                                 ));

                request = new drive.EnableDriveRequest(true);

                yield return(Arbiter.Choice(
                                 _drivePort.EnableDrive(request),
                                 delegate(DefaultUpdateResponseType response) { },
                                 delegate(Fault f)
                {
                    LogError(f);
                }
                                 ));
            }
        }
Exemple #2
0
        public virtual IEnumerator <ITask> ReliableSubscribeHandler(drive.ReliableSubscribe subscribe)
        {
            yield return(Arbiter.Choice(
                             SubscribeHelper(_subMgrPort, subscribe.Body, subscribe.ResponsePort),
                             delegate(SuccessResult success)
            {
                SendNotification <drive.Update>(_subMgrPort, subscribe.Body.Subscriber, _state);
            }, null));

            yield break;
        }
 public IEnumerator <ITask> ReliableSubscribeHandler(diffdrive.ReliableSubscribe subscribe)
 {
     Activate(Arbiter.Choice(
                  SubscribeHelper(_subMgrPort, subscribe.Body, subscribe.ResponsePort),
                  delegate(SuccessResult success)
     {
         _subMgrPort.Post(new submgr.Submit(
                              subscribe.Body.Subscriber, DsspActions.UpdateRequest, _state, null));
     },
                  delegate(Exception ex) { LogError(ex); }
                  ));
     yield break;
 }
 public IEnumerator <ITask> ReliableSubscribeHandler(drive.ReliableSubscribe subscribe)
 {
     yield return(Arbiter.Choice(
                      SubscribeHelper(_subMgrPort, subscribe.Body, subscribe.ResponsePort),
                      delegate(SuccessResult success)
     {
         Update update = new Update(_state);
         SendNotificationToTarget <Update>(subscribe.Body.Subscriber, _subMgrPort, update);
     },
                      delegate(Exception ex)
     {
         LogError(ex);
         throw ex;
     }
                      ));
 }
        IEnumerator<ITask> OnConnectMotorHandler(OnConnectMotor onConnectMotor)
        {
            if (onConnectMotor.DriveControl == _driveControl)
            {
                drive.EnableDriveRequest request = new drive.EnableDriveRequest();

                if (_drivePort != null)
                {
                    yield return Arbiter.Choice(
                        _drivePort.EnableDrive(request),
                        delegate(DefaultUpdateResponseType response)                         
                        {
                            
                        },
                        delegate(Fault f)
                        {
                            LogError(f);
                        }
                    );

                    if (_motorShutdown != null)
                    {
                        yield return PerformShutdown(ref _motorShutdown);
                    }
                }

                _drivePort = ServiceForwarder<drive.DriveOperations>(onConnectMotor.Service);
                _motorShutdown = new Port<Shutdown>();

                request.Enable = true;

                yield return Arbiter.Choice(
                    _drivePort.EnableDrive(request),
                    delegate(DefaultUpdateResponseType response) { },
                    delegate(Fault f)
                    {
                        LogError(f);
                    }
                );

                drive.ReliableSubscribe subscribe = new drive.ReliableSubscribe(
                    new ReliableSubscribeRequestType(10)
                );
                subscribe.NotificationPort = _driveNotify;
                subscribe.NotificationShutdownPort = _motorShutdown;

                _drivePort.Post(subscribe);

                yield return Arbiter.Choice(
                    subscribe.ResponsePort,
                    delegate(SubscribeResponseType response)
                    {
                        LogInfo("Subscribed to " + onConnectMotor.Service);
                    },
                    delegate(Fault fault)
                    {
                        _motorShutdown = null;
                        LogError(fault);
                    }
                );
            }
        }