"yield return allows [the programmer] to iterate through objects returned by a method call." (Sara Morgan)
Then moving on in services, I am reminded (and feel it important to report) that in MRDS, the events that occur around the sensors are pushed through the system, rather than servers having to poll sensors for state changes. This is an awesome feature in MRDS, since polling takes up considerable computation. I learned that from the first channel 9 video on MRDS.
Subscriptions are the means by which services are made aware of events. There are two parties involved in a subscription: the publisher and the subscriber. We need to remember that only certain operations create events (Delete, drop, insert, replace, update and insert), whereas Get and Query do not.
To configure a publisher:
- Add the SubscriptionManager service (Using Microsoft.DSS.Services.SubscriptionManager;//some use an alias like submgr). This service maintains the list of subscribers and forwards the notifications to that list.
- Create a port that acts as a partner service between the two services.
- Create a subscribe message that supports the SubscribeRequestType and SubscribeResponseType.*
- Add the message to the list of supported PortSet operations
- A service needs to be created for the subscribe operation
- Make sure that when the state is changed that the notifications are sent to the subscribers.
Then the subscriber needs to be configured:
- Reference the proxy assembly file for the publisher service (this requires building the subscriber). Click add reference and add the ___.proxy.dll file. Proxy files are the means by which services communicate.
- Make sure that your code will always reference the correct assembly by changing the 'Copy Local' and 'Specific Version' properties to false.
- Add a namespace {alias} declaration to the subscribers implementation class.
- Now add the a partner declaration, similar to the one in the publisher.
- Add code that invokes the Subscribe operation.
I cannot stress the significance of the service tutorials enough. They really will help when you get to understanding this stuff.
*I have significant evidence now to confirm that messages are in fact classes declared in the {service_name}Types.cs file, then added to the list of avalable operations in the PortSet operations. I know I'm slow... that's why the blog exists.
The next chapter is the VPL. This excites me because the VPL can be used to create an environment and then edited in code. It is probably in this chapter that I will get some autonomy in some kind of robot. That's what I'm hoping for. I'm also hoping to get the Lego Mindstorms NXT at the end of the month, because I have to play around with this stuff more.


0 incoming messages (comments):
Post a Comment