Writing new data to a service from another program

Hi guys,

Im new to MSRS but have been writing software for robotics in ASM, BASIC, C,C++,C# in the normal way for many years. to get up to speed on MSRS programming Ive been through the service tutorials and the hosting tutorials but unfortunately I am struggling with writing data to the variables inside a service from another program.

Using the dsshosting example program 2 and service tutorial 5, I can see how to read data from a service using commands like "Get" but I dont know what syntax to use in order to alter the data inside the service. I can retreive a class full of data objects which is good, but I dont know how to set those members to different values.

For example I could easily read the value from the increment tick example in my program, but cannot figure out how to use a function like "SetTickCount" to change what that value is. I have not come across a function in a hosting app that does the write operation. Im assuming that it is some sort of Arbiter task with a pair of delegates? There is no example of this sort of operation in the tutorials.

I would think that once Ive got my head around readand write operations in MSRS, I can get on and program robots in the way I always have done.

Please help, as I'd love to use MSRS, its just that from my point of view the tutorials have little holes in them which are hard to fill in.

[1439 byte] By [c6jones720] at [2008-1-9]
# 1

You can define you own operations within a service that allow you to set the internal state of your service.

Actually, if you look at the handler of the IncrementTick operation you will see that the state in modified (variable TickCount incremented).

Code Snippet

[ServiceHandler(ServiceHandlerBehavior.Exclusive)]

public IEnumerator<ITask> IncrementTickHandler(rst4.IncrementTick incrementTick)

{

_state.TickCount++;

incrementTick.ResponsePort.Post(DefaultUpdateResponseType.Instance);

yield break;

}

Also, note that you can use a custom class as parameter of your operation (like IncrementTickRequest in this case), therefore, you can define whatever type you need to pass to your service state.

Code Snippet

public class IncrementTick : Update<IncrementTickRequest, PortSet<DefaultUpdateResponseType, Fault>>

{

public IncrementTick()

: base(new IncrementTickRequest())

{

}

}

Pd. I would post this kind of question in the DSS forum (not the community forum).

array2001 at 2007-10-3 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Community...
# 2
Thanks for your help but Im not sure if it answers my question.
Please forgive my ignorance but it looks to me like the two code snippets you provided are for operations within the service. This isnt exactly what I mean. What Im trying to do basically is change the value of any old variable inside a service from a hosting program. Im trying to make changes from outside the service.

For example In my hosting program we can use:

Code Snippet

yield return Arbiter.Choice(pServiceTutorial1.Get(),
delegate(st1.ServiceTutorial1State success)
{
// GET Request succeeded
DssEnvironment.LogInfo("Service Tutorial1 state: "

+ success.Member); //<--success.member came out

//of the service

_status = 0;
},
delegate(W3C.Soap.Fault failure)
{
// GET Request failed.
DssEnvironment.LogError("Could not retrieve state.");
}
);


So all that above will give my hosting program the values of all variables in the class named success. - Thats great, but I now want to force new values into the service from my hosting program.

I assumed you could use the same syntax to put something new into the service like:

Code Snippet

yield return Arbiter.Choice(pServiceTutorial1.Replace(),
delegate(st1.ServiceTutorial1State success)
{
success.Member = "this is a test"; // < Im trying to put this into the service

_status = 0;
},
delegate(W3C.Soap.Fault failure)
{
// GET Request failed.
DssEnvironment.LogError("Could not retrieve state.");
}
);


But of course its just giving me a compile time error. I just want to write new values to variables in a service from outside of that service.

c6jones720 at 2007-10-3 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Community...
# 3
You're close:


st1.ServiceTutorial1State= new ServiceTutorialState();
st1.Member = "this is a test";

yield return Arbiter.Choice(pServiceTutorial1.Replace(st1),

delegate(DefaultReplaceResponseType success)

{

},


delegate(W3C.Soap.Fault failure)

{


DssEnvironment.LogError("Could not update state.");


}

);

RobSim--Braintech at 2007-10-3 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Community...
# 4
Argh, sorry for the formatting. These forums don't play nice with firefox...
RobSim--Braintech at 2007-10-3 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Community...
# 5
Thanks for your help. That look pretty much like what I want. As far as Im concerned if you can read data and write data to a service the rest is just like regular coding. - Thanks I'll give that a go.
c6jones720 at 2007-10-3 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Community...

Microsoft Robotics Studio

Site Classified