/// <summary> /// SpeechRecognizerState HTTP query handler /// </summary> /// <param name="query"></param> /// <returns></returns> private IEnumerator <ITask> SpeechRecognizerStateHttpQueryHandler(HttpQuery query) { // Send SpeechRecognizerStateQuery message to own service SpeechRecognizerStateQuery srStateQuery = new SpeechRecognizerStateQuery(); _mainPort.Post(srStateQuery); DsspResponsePort <sr.SpeechRecognizerState> srStateResponse = srStateQuery.ResponsePort; yield return((Choice)srStateResponse); Fault srStateFault = (Fault)srStateResponse; if (srStateFault != null) { LogError(srStateFault); query.ResponsePort.Post(new HttpResponseType( HttpStatusCode.InternalServerError, srStateFault )); yield break; } // Return SpeechRecognizerStateQuery result query.ResponsePort.Post(new HttpResponseType( HttpStatusCode.OK, (sr.SpeechRecognizerState)srStateResponse )); yield break; }
private DsspResponsePort <vector.CallbackResponseType> setLoud() { var responsePort = new DsspResponsePort <vector.CallbackResponseType>(); Activate(Arbiter.Choice(_scribblerPort.SetLoud(_state.GetBool(3)), delegate(DefaultUpdateResponseType success) { responsePort.Post(vector.CallbackResponseType.Instance); }, delegate(Fault failure) { responsePort.Post(failure); })); return(responsePort); }
/// <summary> /// Creates an instance of the service associated with this contract /// </summary> /// <param name="contructorServicePort">Contractor Service that will create the instance</param> /// <param name="partners">Optional list of service partners for new service instance</param> /// <returns>Result PortSet for retrieving service creation response</returns> public static DsspResponsePort<CreateResponse> CreateService(constructor.ConstructorPort contructorServicePort, params PartnerType[] partners) { DsspResponsePort<CreateResponse> result = new DsspResponsePort<CreateResponse>(); ServiceInfoType si = new ServiceInfoType(Contract.Identifier, null); if (partners != null) { si.PartnerList = new List<PartnerType>(partners); } Microsoft.Dss.Services.Constructor.Create create = new Microsoft.Dss.Services.Constructor.Create(si, result); contructorServicePort.Post(create); return result; }
/// <summary> /// Events HTTP query handler /// </summary> /// <param name="query"></param> /// <param name="parameters"></param> /// <returns></returns> private IEnumerator <ITask> EventsHttpQueryHandler(HttpQuery query, NameValueCollection parameters) { // Parse timestamp (TryParse sets the timestamp to zero if parsing fails) long timestamp; long.TryParse(parameters["timestamp"], out timestamp); // Send EventsQuery message to own service EventsQueryRequestType eventsQueryRequest = new EventsQueryRequestType(); eventsQueryRequest.NewerThanTimestamp = timestamp; EventsQuery eventsQuery = new EventsQuery(); eventsQuery.Body = eventsQueryRequest; _mainPort.Post(eventsQuery); DsspResponsePort <EventsQueryResponse> eventsResponse = eventsQuery.ResponsePort; yield return((Choice)eventsResponse); Fault eventsFault = (Fault)eventsResponse; if (eventsFault != null) { LogError(eventsFault); query.ResponsePort.Post(new HttpResponseType( HttpStatusCode.InternalServerError, eventsFault )); yield break; } // Return EventsQuery result query.ResponsePort.Post(new HttpResponseType( HttpStatusCode.OK, (EventsQueryResponse)eventsResponse )); yield break; }
private DsspResponsePort <vector.CallbackResponseType> playTone() { var responsePort = new DsspResponsePort <vector.CallbackResponseType>(); brick.PlayToneBody play = new brick.PlayToneBody() { Frequency1 = (int)Math.Round(_state.Values[0]), Frequency2 = (int)Math.Round(_state.Values[1]), Duration = (int)Math.Round(_state.Values[2]) }; if (play.Frequency1 < 0 || play.Frequency2 < 0 || play.Duration < 0) { responsePort.Post(RSUtils.FaultOfException(new ArgumentOutOfRangeException())); } else { Activate(Arbiter.Choice(_scribblerPort.PlayTone(play), delegate(DefaultUpdateResponseType success) { responsePort.Post(vector.CallbackResponseType.Instance); }, delegate(Fault failure) { responsePort.Post(failure); })); } return(responsePort); }
public Subscribe(SubscribeRequestType body, DsspResponsePort <SubscribeResponseType> responsePort) : base(body, responsePort) { }
public SetAllElements(SetAllRequestType body, DsspResponsePort <DefaultUpdateResponseType> responsePort) : base(body, responsePort) { }
public SetByKey(SetByKeyRequestType body, DsspResponsePort <DefaultUpdateResponseType> responsePort) : base(body, responsePort) { }
public GetAllElements(GetAllElementsRequestType body, DsspResponsePort <GetAllElementsResponseType> responsePort) : base(body, responsePort) { }
public GetByKey(GetByKeyRequestType body, DsspResponsePort <GetElementResponseType> responsePort) : base(body, responsePort) { }
public SetLoud(SetLoudBody body, DsspResponsePort <DefaultUpdateResponseType> respPort) : base(body, respPort) { }
private DsspResponsePort<vector.CallbackResponseType> setLoud() { var responsePort = new DsspResponsePort<vector.CallbackResponseType>(); Activate(Arbiter.Choice(_scribblerPort.SetLoud(_state.GetBool(3)), delegate(DefaultUpdateResponseType success) { responsePort.Post(vector.CallbackResponseType.Instance); }, delegate(Fault failure) { responsePort.Post(failure); })); return responsePort; }
private DsspResponsePort<vector.CallbackResponseType> playTone() { var responsePort = new DsspResponsePort<vector.CallbackResponseType>(); brick.PlayToneBody play = new brick.PlayToneBody() { Frequency1 = (int)Math.Round(_state.Values[0]), Frequency2 = (int)Math.Round(_state.Values[1]), Duration = _state.Values[2] }; if (play.Frequency1 < 0 || play.Frequency2 < 0 || play.Duration < 0) responsePort.Post(RSUtils.FaultOfException(new ArgumentOutOfRangeException())); else Activate(Arbiter.Choice(_scribblerPort.PlayTone(play), delegate(DefaultUpdateResponseType success) { responsePort.Post(vector.CallbackResponseType.Instance); }, delegate(Fault failure) { responsePort.Post(failure); })); return responsePort; }
/// <summary> /// SpeechRecognizerGui Get Operation /// </summary> public Get(GetRequestType body, DsspResponsePort <SpeechRecognizerGuiState> responsePort) : base(body, responsePort) { }
IEnumerator <ITask> AddArticulatedArm() { Vector3 position = new Vector3(0, 0, 0); // Create an instance of our custom arm entity. // Source code for this entity can be found under // Samples\Simulation\Entities\Entities.cs KukaLBR3Entity entity = new KukaLBR3Entity(position); // Name the entity entity.State.Name = "LBR3Arm"; // Insert entity in simulation. SimulationEngine.GlobalInstancePort.Insert(entity); // create simulated arm service DsspResponsePort <CreateResponse> resultPort = CreateService( Microsoft.Robotics.Services.Simulation.LBR3Arm.Proxy.Contract.Identifier, Microsoft.Robotics.Simulation.Partners.CreateEntityPartner("http://localhost/" + entity.State.Name)); // asynchronously handle service creation result. yield return(Arbiter.Choice(resultPort, delegate(CreateResponse rsp) { _armServicePort = ServiceForwarder <arm.ArticulatedArmOperations>(rsp.Service); }, delegate(Fault fault) { LogError(fault); })); if (_armServicePort == null) { yield break; } // we re-issue the get until we get a response with a fully initialized state do { yield return(Arbiter.Receive(false, TimeoutPort(1000), delegate(DateTime signal) { })); yield return(Arbiter.Choice( _armServicePort.Get(new GetRequestType()), delegate(arm.ArticulatedArmState state) { _cachedArmState = state; }, delegate(Fault f) { LogError(f); })); // exit on error if (_cachedArmState == null) { yield break; } } while (_cachedArmState.Joints == null); // Start a timer that will move the arm in a loop // Comment out the line below if you want to control // the arm through SimpleDashboard // Spawn<DateTime>(DateTime.Now, MoveArm); }
public Replace(VectorState body, DsspResponsePort <DefaultReplaceResponseType> responsePort) : base(body, responsePort) { }
public SetAll(SetAllRequestType body, DsspResponsePort <DefaultReplaceResponseType> responsePort) : base(body, responsePort) { }
/// <summary> /// Creates an instance of the LEGO NXT Communications service. /// </summary> /// <returns>Result PortSet for retrieving service creation response</returns> private DsspResponsePort<CreateResponse> CreateNxtCommunicationService() { DsspResponsePort<CreateResponse> createResponsePort = new DsspResponsePort<CreateResponse>(); ServiceInfoType si = new ServiceInfoType(comm.Contract.Identifier, null); Microsoft.Dss.Services.Constructor.Create create = new Microsoft.Dss.Services.Constructor.Create(si, createResponsePort); base.ConstructorPort.Post(create); return createResponsePort; }