Esempio n. 1
0
        IEnumerator<ITask> OnConnectWebCamHandler(OnConnectWebCam Opt)
        {
            Fault fault = null;
            SubscribeResponseType s;
            String camera = Opt.Service;

            _webCamPort = ServiceForwarder<cam.WebCamOperations>(camera);


            //cam.Subscribe subscribe = new cam.Subscribe();
            //subscribe.NotificationPort = _webCamNotify;


            yield return Arbiter.Choice(
                _webCamPort.Subscribe(_webCamNotify),
                //                subscribe.ResponsePort,
                delegate(SubscribeResponseType success)
                { s = success; },
                delegate(Fault f)
                {
                    fault = f;
                }
            );

            if (fault != null)
            {
                LogError(null, "Failed to subscribe to webcam", fault);
                yield break;
            }
        }       
Esempio n. 2
0
 /// <summary>
 /// See adapter documentation in the Myro 3 developer manual.
 /// http://wiki.roboteducation.org/Myro_3.0_Developer_Manual
 /// </summary>
 public WebcamAdapter(ServiceInfoType serviceInfo)
 {
     ServiceInfo = serviceInfo;
     opPort = DssEnvironment.ServiceForwarder<webcam.WebCamOperations>(new Uri(serviceInfo.Service));
 }
Esempio n. 3
0
        // TT - New handler for connecting to WebCam
        IEnumerator<ITask> OnConnectWebCamHandler(OnConnectWebCam Opt)
        {
            //ServiceInfoType info = null;
            Fault fault = null;
            SubscribeResponseType s;
            String camera = Opt.Service;

            _webCamPort = ServiceForwarder<cam.WebCamOperations>(camera);

            //cam.Subscribe subscribe = new cam.Subscribe();
            //subscribe.NotificationPort = _webCamNotify;

            //_webCamPort.Post(subscribe);

            yield return Arbiter.Choice(
                _webCamPort.Subscribe(_webCamNotify),
//                subscribe.ResponsePort,
                delegate(SubscribeResponseType success)
                { s = success; },
                delegate(Fault f)
                {
                    fault = f;
                }
            );

            if (fault != null)
            {
                LogError(null, "Failed to subscribe to webcam", fault);
                yield break;
            }

            RunForm runForm = new RunForm(CreateWebCamForm);

            WinFormsServicePort.Post(runForm);

            yield return Arbiter.Choice(
                runForm.pResult,
                delegate(SuccessResult success) { },
                delegate(Exception e)
                {
                    fault = Fault.FromException(e);
                }
            );

            if (fault != null)
            {
                LogError(null, "Failed to Create WebCam window", fault);
                yield break;
            }
            // The following code falls over with a null pointer
            // exception inside MainPortInterleave.CombineWith.
            // Since I don't know why, I have added the message
            // to the interleave that is created at startup.
            // This is a bit tacky, but does not seem to do any harm.
            /*
            Interleave x = Arbiter.Interleave(
                    new TeardownReceiverGroup(),
                    new ExclusiveReceiverGroup(
                        Arbiter.ReceiveWithIterator<cam.UpdateFrame>(true, _webCamNotify, CameraUpdateFrameHandler)
                    ),
                    new ConcurrentReceiverGroup()
            );

            base.MainPortInterleave.CombineWith(x);
            */

            // There is a bug in the simulated webcam. It does not
            // automatically send UpdateFrame messages when you
            // subscribe. If this is a simulated camera, then set
            // up a timer to poke the webcam service and make it
            // send a frame.
            if (camera.ToLower().Contains("simul"))
            {
                Activate(
                    Arbiter.Receive(false, TimeoutPort(_state.Options.CameraInterval), CameraTimer)
                );
            }

            yield break;

        }