Course 10 / Lecture 3:

Receive messages from your robot and handle events

In this lecture you will learn how to subscribe for events coming from a robot sensor, and how to handle them in your C#.Net robot control app. You will also learn how to display robot events on the user interface of your app.

Task #1:

Create a page for displaying sensor values!

The following video shows you how to create a new page (the name of the page: Page_ButtonIndicator) with two OzGPC_Image components. One of them will be a hidden image.

Task #2:

Create an event for receiveing messages!

From the following video you can learn how to create a new EventHandler, and raise it if there is a new message from the lego robot. You also need to override the In method to raise the previously created event.

Task #3:

Subscribe for the message received event!

In the constructor of the Page_ButtonIndicator class you need to subscribe for the OnMessageReceived event. In this lecture we are testing a touch sensor. If we press it, the OnMessageReceived event occurs with on value. If it is not pressed, the off value is coming from the sensor.

Task #4:

Test your system!

It is not enough to subscribe for this event, you also need to subscribe the events of the Touch Sensor. After you have subscribed to it, build and test the app.

Task #5:

Unsubscribe!

The following example demonstrates how to override the Dispose class. It is very important to release the resources used by your application. This Dispose method clean ups all class based object and unsubscribe from different events.

More information


Next


Copyright © 2000- |Ozeki Ltd | info@ozekirobot.com |
Page: 6160 | 79.99.42.43 | Login