Angel \”Java\” Lopez on Blog

April 20, 2008

Distributed Scribble with Microsoft Robotics Developer Studio and DSS

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.

The project

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:

protected override void Start() { base.Start(); // Add service specific initialization here. WinFormsServicePort.Post(new RunForm(CreateForm)); } private Form CreateForm() { return new CanvasForm(_mainPort, linePort, TaskQueue); }

Each line the user draw in the window is posted to service component, to be distributed to any interested subscriber:

[ServiceHandler(ServiceHandlerBehavior.Exclusive)] public IEnumerator<ITask> PostLineHandler(PostLine postLine) { SendNotification<PostLine>(_submgrPort, postLine); yield break; }

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:

[ServiceHandler(ServiceHandlerBehavior.Exclusive)] public IEnumerator<ITask> NewLineHandler(NewLine newLine) { linePort.Post(newLine.Body); newLine.ResponsePort.Post(DefaultUpdateResponseType.Instance); yield break; }

The service component has no state. I use a class to transport the information of new lines to draw and distribute:

[DataContract()] public class DssScribbleState { } [DataContract()] public class DssScribbleLine { [DataMember()] public int fromX; [DataMember()] public int fromY; [DataMember()] public int toX; [DataMember()] public int toY; public DssScribbleLine() { } public DssScribbleLine(int fromX, int fromY, int toX, int toY) { this.fromX = fromX; this.fromY = fromY; this.toX = toX; this.toY = toY; } }

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.

Notes

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.

Conclusions

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
http://www.ajlopez.com/en

7 Comments »

  1. hi for all
    http://www.skilline.com

    Comment by ffa — April 20, 2008 @ 7:26 pm

  2. Hi
    http://www.skilline.com

    Comment by ffa — April 20, 2008 @ 7:39 pm

  3. Looks great! May be usefull for remote teaching/seminar with an touchscreen board, since it will use less bandwidth as images takes more.

    Comment by yadab das — April 23, 2008 @ 6:56 pm

  4. [...] Sehmi referenció en un post suyo a un trabajo mío sobre una killer application que escribí: un scribble distribuido :-) Pero luego también escribió sobre este [...]

    Pingback by Que lindo el guaguau: BigDog de Boston Dynamics - Angel "Java" Lopez — April 24, 2008 @ 1:51 pm

  5. Interesting. Nice one and very useful.

    Comment by Philippine Website Developers — May 1, 2008 @ 2:44 pm

  6. [...] Distributed Scribble with Microsoft Robotics Developer Studio and DSS [...]

    Pingback by Presentando Microsoft Robotics Developer Studio - Angel "Java" Lopez — May 21, 2008 @ 4:05 am

  7. That is a good tip especially to those fresh to the blogosphere.
    Simple but very accurate info… Appreciate your sharing this one.

    A must read article!

    Comment by %anchor_text% — July 1, 2013 @ 2:44 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Shocking Blue Green Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 65 other followers

%d bloggers like this: