I’m playing withthe new CTP release of Microsoft Robotics Developer Studio. It has new features, as deploying and running a Visual Programming Language diagram in many nodes.
To explore some of this new functionality, I’ve write the dream of any software developer: a distributed multiuser scribble program…;-)… Well, it’s a very simple one, but it works, and it can run in many places, exposing and sharing your most inspired mouse drawings. The code can be downloaded from here.
I have the 1.5 version of the MSRS and the new CTP MRDS (new acronym, guys), running in the same machine, without glitches. I’ve started creating a new Simple Dss Service RDS 2008:
The project contains one service component named DssScribble, and one Windows form, that is in charge of the drawing:
At the start of the service component, it creates the form, and connects to it using ports and its dispatcher queue:
Each line the user draw in the window is posted to service component, to be distributed to any interested subscriber:
The lines are received in the NewLineHandler (the way to connect two components is via VPL, we’ll see later). The linePort is the port to communicate with the WinForm instance:
The service component has no state. I use a class to transport the information of new lines to draw and distribute:
Drawing with VPL
The Visual Programming Language is a fascinating tool, with so many features. You can drag and drop service components from the toolbar. When the tool is launched, you can search the DssScrible service component in the left bottom toolbox:
I dropped two instances of DssScribble service component, and renamed them to DssScribble1 and DssScribble2:
I connected the instances, so they listen their notifications. Every line produced in one instance, is transmitted to the other. In this way, what you draw in a window is viewed in the other.
The connection is between the PostLine notification to a NewLine operation:
To launch the application, go to Run -> Start menu. A windows appears, showing the log messages:
Few moments, and the two instances of DssScribble service are created, each one shows a form. You can draw in any form, and the mouse drawn lines are replayed in the other form:
That is my self-portrait: my left eye with a tear, because the emotion of distributed scribbling…. 😉
Running on distributed nodes
VPL IDE has a node designer. At the right, there is a node branch on the Project tree. Each node represents a DSS node hosting DSS service components. I added two nodes, the first containing the instance and diagram of the current application (diagrams are services that can be viewed during the debug phase in your browser, you’ll love that featuer). I dragged and dropped DssScribble2 instance to the second node:
Note the right bottom panel: I set the properties for Windows0 node, in the same localhost machine, but with other ports (Windows node will run at 50000/50001 ports). In other project, I tried to have a remote machine, and the distribution of the application worked without problems. You can define any number of nodes, each in a machine of your office, put on them DssScribble instances, related each other, and play scribbling with your coworkers (after work, please…. 😉
In order to run the application in a distribute way, you must compile it. Use the Build -> Compile as a Service menu option. You must set a directory where to generate the code and solution. Then, VPL tool compile the solution and generate packages to deploy. You can open the generated solution with Visual Studio, if you are curious (the code is a very interesting, a very clever one, implementing, I suppose, an state or stack machine, look at Decrement and Increment methods).
Each node must have a package deployer service, running on another port (the same one for all nodes, default value is 55555). Go to run bin directory of Microsoft Robotics Developer Studio, and run the rundeployer.cmd:
Note: if you want to compile the service again, you must stop the deployer node: this is using the bin directory and the compilation conflicts with the package deployer host.
Now, we are ready to deploy our killer app: execute Run -> Run on distributed nodes. The system warns about to have deployers running:
And the magic begins: each node is contacted, and the application is deployer to them. A DSS node is started in each node, and its corresponding service instances are created. In this example, you will have two new old-DOS windows, running each DSS node. This is my second node window:
Now, each node show its scribbling window, and the fun begins.
I’m not using partners in this example. Instead, I’m put notification of events, in this case, new lines, so other components can receive such notification. You can write other components, other than scribble windows, to receive and process the lines. One idea is to use the coordinates of a new line to control a robot motor, or to persists the lines produced with a new persistence component. To control a robot motor, you should play with VPL, without rewriting the service component code.
Using VPL you can compose new applications from preexisting components. You can create your own activities, too. And using node diagrams (in VPL or using the DSS Manifest Editor) with the packager deployer, we can distribute the application in many physical nodes, in any convenient manner. But you must define each node and component: there is no provisioning of have a grid, so we can clone and distribute a working component. A gridified DSS application can be written, but in my opinion, it should be created with custom code. Idea to explore: write a custom control application that, using package deployer, deploys tasks to nodes in a grid.
All these tools opened my brain. Writing DSS service component is a new way of thinking and programming, something I want to explore for years: how to write objects with one-way message processing, in a distributed and parallel way (AjAgents was motivated by that objective). I envision some system that model Minsky ideas about the human mind.
Well, it’s a new brave world. Dorothy: we are not in Kansas anymore… 😉
Angel “Java” Lopez