Saturday, June 7, 2008

State Management

This is a separate blog because I feel that internal state posting (and other state handling operations) may have significant relavance to AI programmers such as myself. Again, this is a summary for academic purposes and is taken from Sara Morgan's great book "Programming Microsoft Robotics Studio." Buy it.

To post the state internally, the steps are as follows:
1. Declare the necessary state variables for internal storage.
2. Create an additional Port. It is a generic called Port, Sara uses a {string} example.
3. Create a message which is derived from the Update generic class. (b)This will require a new operation type and service handler (for the operation)
4. Add the operation to the operations list in the PortSet declaration
5. Create an exclusive message handler for the new message. (Would have to add code to poll the HTTP port for requests)
6. In order to actually post the data, the CCR Arbiter class needs to be utilized

Unfortunately Sara does not go into too much detail in describing the actual process of doing it yourself, yet. Code fragments are given, but only 3 (out of the 6 stages) and the placement is not clearly defined. As an assumption, I would say that since this is a state declaration, step one and two goes into {service_name}.cs. Since messages need to be managed, step 3 goes into {service_name}Types.cs, the same going for steps four and five since it deals with the portset operations. Finally step 6 I would guess goes in {service_name}.cs since it is associated with step 2, by means of posting data to the port. I did not attempt it as I have no idea how to poll the HTTP port just yet.

I would recommend revising the service tutorials. In fact, I will be going there now. It appears in the 2008 version the tutorials are quite separate. There are two files in the "Microsoft Robotics Dev Studio 2008\documentation" folder: MsrsUserGuide.chm and VseHelp.chm. The VSE is for simulation and the user guide contains the service tutorials under Decentralized Software Services --> DSS Service Tutorials. Just a note: I think it's wrong to call it DSS Service, since 'Service' is included in the acronym. Just a thought.

The service tutorials are way better than when I did them. Go Microsoft! But I cannot find what I am looking for (because it isn't there), so I will continue in slight ignorance and hope that a useful example will come my way when we get into it properly. I assume the most important thing here is to make note of what needs to happen. I think I should carefully indicate my concerns at this point:
1. State variables? What state variables? An example would be much needed for the whole thing if step one is vague.
2. Here code is given, and I can work out where that goes. But in terms of flow I am quite lost by this point.
3. Message? Is this an HTTP or DSSP message? That would mean it goes in {service_name}Types.cs. I hope I'm right, because I assume that this message is the operation that is being spoken of in step four. The message must be a class (due to the fact that it derives), but how am I supposed to know what gets added, considering I even doubt it's position? I am right, it must be similar to the Get class in {service_name}Types.cs, but after declaring :Update I have no idea what values to assume for TBody and TResponse. I compared to Get, but all I learned is that TBody and TRequest are "new() Update operation(s)." I assume that is where step three (b) comes in, but how am I supposed to do that?
4. Easy, that has been covered everywhere and is very clear in the service tutorials.
5. Polling, as I said, the HTTP port is something I still require to learn. Message handlers are covered in the service tutorials, if I am not mistaken.
6. Covered in the book, but placement will be difficult.

That said, I have thought it through and await an answer in the Next we consider state persistence using files.

Notes:
CCR is required in order to avoid threading conflicts when handling inbound requests.

0 incoming messages (comments):