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); } )); } }
protected virtual void Initialize() { // Initialize the port and subscribe to the service motorsOn = false; drivePort = DssEnvironment.ServiceForwarder <drive.DriveOperations>(new Uri(ServiceInfo.Service)); drive.DriveOperations driveNotificationPort = new drive.DriveOperations(); drivePort.Subscribe(driveNotificationPort); // Set up notifications Arbiter.Activate(DssEnvironment.TaskQueue, Arbiter.Receive <drive.Update>(true, driveNotificationPort, NotifyDriveUpdate)); }
protected virtual void Initialize() { // Initialize the port and subscribe to the service to know when the motors are enabled motorsOn = false; drivePort = DssEnvironment.ServiceForwarder <drive.DriveOperations>(new Uri(ServiceInfo.Service)); drive.DriveOperations driveNotificationPort = new drive.DriveOperations(); RSUtils.ReceiveSync(taskQueue, drivePort.Subscribe(driveNotificationPort), Params.DefaultRecieveTimeout); // Set up notifications Arbiter.Activate(DssEnvironment.TaskQueue, Arbiter.Receive <drive.Update>(true, driveNotificationPort, NotifyDriveUpdate)); }
void ConnectToScribbler(DateTime dt) { Uri driveUri = null; // Look for any active generic drive contract service running Arbiter.Activate(DssEnvironment.TaskQueue, Arbiter.Choice(DssEnvironment.DirectoryQuery(drive.Contract.Identifier), delegate(ServiceInfoType success) { driveUri = new Uri(success.Service); Console.WriteLine("================\n" + driveUri); // Initialize the port and subscribe to the service motorsOn = false; drivePort = DssEnvironment.ServiceForwarder <drive.DriveOperations>(driveUri); drive.DriveOperations driveNotificationPort = new drive.DriveOperations(); drivePort.Subscribe(driveNotificationPort); // Set up notifications Arbiter.Activate(DssEnvironment.TaskQueue, Arbiter.Receive <drive.Update>(true, driveNotificationPort, NotifyDriveUpdate) ); autolock.Set(); }, delegate(W3C.Soap.Fault failure) { // Request failed. Sleep for 1 sec and look for 30 times. if (++attemptCount >= 30) { DssEnvironment.LogError("Unable to find Drive Service, aborting - Press <Enter>"); Console.ReadLine(); DssEnvironment.Shutdown(); } else { // Post a timer message that expires in 30 seconds TimeSpan timeout = new TimeSpan(0, 0, 30); DssEnvironment.TaskQueue.EnqueueTimer(timeout, _timerPort); } } )); }
protected virtual void Initialize() { // Initialize the port and subscribe to the service to know when the motors are enabled motorsOn = false; drivePort = DssEnvironment.ServiceForwarder<drive.DriveOperations>(new Uri(ServiceInfo.Service)); drive.DriveOperations driveNotificationPort = new drive.DriveOperations(); RSUtils.ReceiveSync(taskQueue, drivePort.Subscribe(driveNotificationPort), Params.DefaultRecieveTimeout); // Set up notifications Arbiter.Activate(DssEnvironment.TaskQueue, Arbiter.Receive<drive.Update>(true, driveNotificationPort, NotifyDriveUpdate)); }
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); } ); } }