skuleguy

Hi,

I have a question about passing value (like a variable) to a partner service:

Ok, here's the situation:

I have 2 services A and B.

Service A supports subscription and Service B listens to service A.

So when I run Service B, it'll automatically wakes up service A.

Now I need to pass a value (like a variable) from B to A so that A can initialize a few arrays in its Start() method.

I dont really know at which point in B's code does A get woken up.

Is what i described even possible to do

Thanks,



Re: Microsoft Robotics - Decentralized Software Services (DSS) How to send a value to a partner service before it even gets initialized

skuleguy

Just another question,

Is it possible to pop up a Winform at the beginning of the service, and put the service to a HALT so the users could specify necessary parameters for the service and stuff

Thanks,





Re: Microsoft Robotics - Decentralized Software Services (DSS) How to send a value to a partner service before it even gets initialized

Paul C Roberts

Hi,

So, in answer to your first question, the easiest, and best, way to pass information to a service before it starts is by using the InitialStatePartner mechanism. This allows you to initialise a services state from an XML file. When the Start() method is called on the service, the service state will be either null (there was no InitialStatePartner) or will be initialized to the contents of the XML file - Service Tutorial 3 demonstrates the basics of how to set up an InitialStatePartner.

If you use a manifest to start your services, then that manifest can specify the xml file to use. More importantly, if you use the Dss Manifest Editor, you can fill in the values in the initial state without having to edit xml by hand.

To answer your second question, a service can delay its own startup process after fashion. By the time Start() is called, the service is already considered running by the DSS Node (Start is called at the end of a two-phase startup process), however, the service doesn't start handling incoming messages until it either calls base.Start() or explicitly activate handlers on the main port. The service also doesn't appear in the Directory until base.Start() is called.

Hope this Helps

Paul





Re: Microsoft Robotics - Decentralized Software Services (DSS) How to send a value to a partner service before it even gets initialized

skuleguy

Hi,

Can you tell me where I can find the sample XML code to initialize a service

In the docs, you guys only mentioned "ServiceTutorial3.xml" in IntialStatePartner but that file isn't available.

I would like to have B to pop up a winform (with a button on it), then the user Click "OK", only then Service A (what B subscribe to is woken up). So far I havent been able to do so.

Thanks





Re: Microsoft Robotics - Decentralized Software Services (DSS) How to send a value to a partner service before it even gets initialized

Rob Sim -- Braintech

The XML file is just the serialization of the service state representation. Here are two ways to get a copy:
1. Run your service and navigate to it using a web browser via the service directory. Assuming you're not applying any xslt to the xml you'll see the xml file you need- copy/paste into wordpad, etc.
2. Declare an initial state partner in your code as described in the service tutorials and call SaveState(_state) at or near the end of your Start() method. This will dump the state to the xml file you declared.

If you wanted to get sophisticated, you could have service A provide service B's initial state via HTTP, and when you instantiate B you set the initiail state partner to the URL where A serves the state.

I'm not sure how well it would work to create the winform before B starts (e.g. in B's constructor). However, you could instantiate a winform from B's Start() method and hold off on adding B's service handlers to the interleave until the form closes.

R





Re: Microsoft Robotics - Decentralized Software Services (DSS) How to send a value to a partner service before it even gets initialized

Dave Lee

Hello skuleguy, here is one way to create a custom configuration file:

On your state declaration, add InitialStatePartner like this:

Code Snippet

[InitialStatePartner(Optional=true, ServiceUri="samples\config\MyServiceB.xml")]

private ServiceBState _state = new ServiceBState();

In your Start method, call a function to initialize state:

Code Snippet

///

/// Service Start

///

protected override void Start()

{

InitializeState();

base.Start();

}

private void InitializeState()

{

if (_state == null)

{

_state = new ServiceBState();

_state.JointL1DesiredAngleFromGUI = new float[2];

_state.JointL3DesiredAngleFromGUI = new float[2];

SaveState(state);

}

}

Any time you call SaveState, your state will be saved to either the default location identified in the initialstatepartner, or in the configuration file named in your manifest.

To set up a config file in your manifest, use the manifest editor:

Code Snippet

vpl -m ServiceB.manifest.xml






Re: Microsoft Robotics - Decentralized Software Services (DSS) How to send a value to a partner service before it even gets initialized

skuleguy

Hi Dave Lee,

I thought my problem was pretty much solved given the above guideline. I still have a bigger problem.

When I Deploy the service above (with initialstatepartnering, saveState() and stuff), the "MyServiceB.xml" file never show up.

I was supposed to run another C# application that gather some info from the user, then modify the MyServiceB.xml, then run ServiceB using that newly customized ServiceB.

I thought that was pretty straight forward, please show me the way in.

Thanks a lot,





Re: Microsoft Robotics - Decentralized Software Services (DSS) How to send a value to a partner service before it even gets initialized

Dave Lee

The config file won't be deployed unless it is named in the manifest. See my post above to use the manifest editor.

However, it sounds like it might be better to implement a Replace for your state.

The second service can then gather user input and post the Replace to your service. This should replace the state, and then potentially start the second phase of your service behavior.






Re: Microsoft Robotics - Decentralized Software Services (DSS) How to send a value to a partner service before it even gets initialized

skuleguy

Hi Dave Lee,

Could you please elaborate a bit more on how attach the file using XML
So far I have tried to do it according to the Documentation and George's post, regarding InitialStatePartner:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1476240&SiteID=1

This is the Manifest.XML of my service:
Code Snippet

< xml version="1.0" >
<Manifest
xmlns="http://schemas.microsoft.com/xw/2004/10/manifest.html "
xmlns:dssp="http://schemas.microsoft.com/xw/2004/10/dssp.html"
>
<CreateServiceList>
<ServiceRecordType>
<dssp:Contract>http://schemas.tempuri.org/2007/08/simplejointsimulation3.html</dssp:Contract>
<dssp:PartnerList>
<dssp:Partner>
<dssp:Service>http://localhost/mountpoint/config/SimpleJointSimulation3.xml </dssp:Service>
<dssp:Name>dssp:StateService</dssp:Name>
</dssp:Partner>
</dssp:PartnerList>
</ServiceRecordType>


</CreateServiceList>

</Manifest>



When I run Debug mode in VS2005, the Project seems to load the initial state from (and only from) C:\Microsoft Robotics Studio ( 1.5)\config\SimpleJointSimulation3
.xml

And things work fine there.

Now the deployment is ugly. Sad

I have my "initialstate resource" file everywhere I can, but I keep getting this error:

Rebuilding contract directory cache. This will take a few moments
Contract directory cache refresh complete
*** File Not Found: /mountpoint/config/simplejointsimulation3.xml

Where exactly should I be placing the resource file so that it's ready for deployment

After deployment, if I attempt to change the IntialState Document, it would still load the new one in right

Thanks !!





Re: Microsoft Robotics - Decentralized Software Services (DSS) How to send a value to a partner service before it even gets initialized

skuleguy

Hi all,
I manage to get something working but this makes no sense.

I have tried different stuff for what goes in between these tags:


<dssp: Service>( ) </dssp: Service>


And that includes:

(1)SimpleJointSimulation3.xml
This one keeps telling me crazy error even when i'm in VS2005 Debugger, please take a look at the picture:
http://farm2.static.flickr.com/1163/1208495953_069419bbcb_o.jpg

(2) http://localhost/mountpoint/config/SimpleJointSimulation3.xml
This one got me through VS, loaded fine, but i just need to put the SimpleJointSimulation3.xml in this folder:
C:\Microsoft Robotics Studio (1.5)\config\
I was happy for like 2 seconds, then I realized that when I tried to "dssdeploy" it, it didnt work, I got this error:
Contract directory cache refresh complete
*** File Not Found: /mountpoint/config/simplejointsimulation3.xml


So I came to the last solution:
(3)C:\Microsoft Robotics Studio (1.5)\SimpleJointSimulation3.xml

This one works great to the point of package successfully deployed. I got a "SimpleJointSimulation3.xml" in the newly targeted unzipped location too.
BUT, when the deployed program was run, it didn't load the new "SimpleJointSimulation3.xml" that came with the simulation. It actually loaded
the file "C:\Microsoft Robotics Studio (1.5)\SimpleJointSimulation3.xml". I have verified this is indeed the case.


I have also tried to modify the newly unzipped "SimpleJointSimulation3.manifest.xml" to get it to load the new "SimpleJointSimulation3.xml" (by stop targetting
C:\Microsoft Robotics Studio (1.5)\ ), that didn't work, it gave me an error similar to (1).

Could someone please show me a step-by-step plan of where to store stuff get it it deployed correctly When I make changes to the newly unzipped "InitialState xml", I want the deployed service to load from there.
Btw, I have my project's Code stored in Mydocument/Visual Studio 2005/Projects/. George told me that "when you run things from visual studio ALWAYS set the running directory to be where your MSRS root is", So does that mean that I have to store my project code in C:\Microsoft Robotics Studio 1.5\
And "When you create a DSS deploy package, NEVER run the deployed runtime from an MSRS command shell. DssHost will actually go back to its install directory (c:\microsoft robotics studio 1.5) and look for DLLs. So when you deploy START a new shell, then run DssHost" So I when I have done the Dss deploy, I shouldnt be running it in "C:\Microsoft Robotics Studios\" command prompt right

I appreciate your help,

Thanks a lot, guys





Re: Microsoft Robotics - Decentralized Software Services (DSS) How to send a value to a partner service before it even gets initialized

skuleguy

Hi all,

I have been able to move a bit further. Still I could not run the service after the deployment. Something is wrong and/or I'm wrong.

If you don't want to see the process, please skip to *THE PROBLEM*

Ok, I have created my Visual Studio 2005 Project in

C:\Microsoft Robotics Studio (1.5)\samples\SimpleJointSimulation5

This is the Content of my manifest xml :

Code Snippet

< xml version="1.0" >

<Manifest

xmlns="http://schemas.microsoft.com/xw/2004/10/manifest.html"

xmlns:dssp="http://schemas.microsoft.com/xw/2004/10/dssp.html"

>

<CreateServiceList>

<ServiceRecordType>

<dssp:Contract>http://schemas.tempuri.org/2007/08/simplejointsimulation5.html</< FONT>dssp:Contract>

<dssp:PartnerList>

<dssp:Partner>

<dssp:Service>SimpleJointSimulation5.xml</< FONT>dssp:Service>

<dssp:Name>dssp:StateService</< FONT>dssp:Name>

</< FONT>dssp:Partner>

</< FONT>dssp:PartnerList>

</< FONT>ServiceRecordType>

</< FONT>CreateServiceList>

</< FONT>Manifest>

I pressed F5, and it compile correctly, and gives me an initialStatePartner SimpleJointSimulation5.xml in the same folder as the Manifest file. So I'm extremely happy with that.

Now I follow the Guidelines in the MSRS Documentation on DssServiceDeployment. I went to the MSRS Command Prompt and I typed:

dssdeploy /p /m:"samples\SimpleJointSimulation5\SimpleJointSimulation5.manifest.xml" SimpleJointSimulation5.exe

That gives me an exe file as expected.

Still in the MSRS Command prompt, now I Unpack the thing into "%Temp%\SimpleJointSimulation5" using the command:

dssdeploy /u /t:%Temp%\SimpleJointSimulation5 SimpleJointSimulation5.exe

This created the "bin" and "sample" folders in my Temp\SimpleJointSimulation5\.

And in Temp\SimpleJointSimulation5\samples\simplejointsimulation5 , I got 2 files: "SimpleJointSimulation5.xml" and "SimpleJointSimulation5.manifest.xml".

*THE PROBLEM*

Now I closed the MSRS Command Shell and then started a new command shell. I consecutively typed in the following:

cd /d "%TEMP%\SimpleJointSimulation5"


bin\dsshost /p:50000 /m:"samples\SimpleJointSimulation5\SimpleJointSimulation5.manifest.xml"

And now, I got this error.

I have also tried to use this command (I read this in the SUMO readme):

cd /d "%TEMP%\SimpleJointSimulation5"

Dsshost -port:50000 -tcpport:50001 -manifest:"samples\SimpleJointSimulation5\SimpleJointSimulation5.Manifest.xml"


And I got the Same Error

Please take a look at the Screen Capture of the Error: http://farm2.static.flickr.com/1331/1214023347_be533a9c30_o.jpg

Please show me how to do this properly,

Thanks so much






Re: Microsoft Robotics - Decentralized Software Services (DSS) How to send a value to a partner service before it even gets initialized

skuleguy

Hi Dave Lee,

I have tried to start a new Command Prompt, (non-MSRS one), then I have tried to remove, the InitialStatePartner in my manifest, just deploy without it to C:\Test\ (a new folder I created.
I got even a crazier error Sad. Please take a look at the screen capture

http://farm2.static.flickr.com/1198/1216068272_a3891a9b24_o.jpg

Is this something wrong from my coding, or is it from the deployment process. Coz before Deploying, I "F5"-ed in VS2005 and the project and simulation runs correctly.

Please help me out.

Thanks a lot,





Re: Microsoft Robotics - Decentralized Software Services (DSS) How to send a value to a partner service before it even gets initialized

George Chrysanthakopoulos

Ok, all this time we missed one important detail. You building a DssDeploy Package for simulation services. Well, such packages can onlybe installed on top of MSRS install directories, since they need additional dependencies. Plus they expect the user system to have Ageia, XNA, DX9, etc.

So while your original problem is solved (using the manifest to supply a state file to initialize a service) your DssDeploy issues had to do with the fact you are trying to deploy a package with simulation services, on an arbitrary disk location. And that will not work, plus it will violate the license if you add those dlls explicitly.

The resolution is to ask your consumers to have MSRS installed if they want to play around with your package, and have your DssDeploy package unpack in their MSRS install directory.

g