public IEnumerator<ITask> ConnectToBiclopsService()
        {
            _biclopsConnected = false;

            loadRemoteServiceDirectoryPorts();

            ds.DirectoryPort remoteDir;
            int k;

            List<biclops.BiclopsOperations> PortList = new List<biclops.BiclopsOperations>();

            while (_biclopsConnected == false)
            {
                for (k = 0; k < _remoteHosts.Count; k++)
                {
                    remoteDir = ServiceForwarder<ds.DirectoryPort>(_remoteHosts[k] + "/directory");
                    ServiceInfoType ServiceInfo = new ServiceInfoType(biclops.Contract.Identifier);
                    ds.QueryRequestType ReqBody;
                    ds.Query Query;

                    ReqBody = new ds.QueryRequestType(ServiceInfo);
                    Query = new ds.Query(ReqBody);

                    // Post query
                    remoteDir.Post(Query);
                    yield return Arbiter.Choice(Query.ResponsePort,
                        delegate(ds.QueryResponseType success)
                        {
                            if (success.RecordList != null)
                            {
                                Console.Write("Received {0} biclops service responses from directory\n", success.RecordList.Length);
                                foreach (ServiceInfoType si in success.RecordList)
                                {
                                    _biclopsPort = base.ServiceForwarder<biclops.BiclopsOperations>(si.Service);
                                    _biclopsConnected = true;
                                    break;
                                }
                            }
                        },
                        delegate(Fault f)
                        {
                            LogError(LogGroups.Console, f.ToString());
                        }
                    );
                    if (_biclopsConnected)
                        break;
                    else
                    {
                        Console.WriteLine("BiclopsRightCameraJointConfiguration: cannot to connect to the Biclops Service\nStart one now if it has not been started and add the host/port to the hosts.txt");
                        Thread.Sleep(2000);
                    }
                }

            }

            yield break;
        }
Exemplo n.º 2
0
        public IEnumerator <ITask> OnHandOff(HandOff handOff)
        {
            Fault fault = null;

            ServiceInfoType[] services = null;

            dir.QueryRequestType request = new dir.QueryRequestType(
                new ServiceInfoType(Contract.Identifier)
                );
            dir.Query query = new dir.Query(request);
            query.TimeSpan = new TimeSpan(0, 0, 2);
            DirectoryPort.Post(query);

            yield return(Arbiter.Choice(
                             query.ResponsePort,
                             delegate(dir.QueryResponseType success)
            {
                services = success.RecordList;
            },
                             delegate(Fault f)
            {
                fault = f;
            }
                             ));

            if (fault != null)
            {
                handOff.ResponsePort.Post(fault);
                yield break;
            }

            foreach (ServiceInfoType service in services)
            {
                FlexDialogOperations fwd   = ServiceForwarder <FlexDialogOperations>(service.Service);
                FlexDialogState      state = null;

                Get get = new Get();
                get.TimeSpan = new TimeSpan(0, 0, 2);
                fwd.Post(get);

                yield return(Arbiter.Choice(
                                 get.ResponsePort,
                                 delegate(FlexDialogState success)
                {
                    state = success;
                },
                                 delegate(Fault f)
                {
                    fault = f;
                }
                                 ));

                if (state != null && state.Title == handOff.Body.Title)
                {
                    handOff.Body.Service = service.HttpServiceAlias.ToString();
                    DoSendNotification(handOff);
                    handOff.ResponsePort.Post(handOff.Body);
                    yield break;
                }
            }

            handOff.ResponsePort.Post(
                Fault.FromCodeSubcodeReason(
                    FaultCodes.Receiver,
                    DsspFaultCodes.UnknownEntry,
                    "Unable to find dialog with title: " + handOff.Body.Title
                    )
                );
        }