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.
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.
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.
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.
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.
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.
- Become a Robot Master
- Build your first App in C#.Net
- Send messages from your C#.Net App to your Lego robot
- Convert a SNAP app into C#
- Build a user interface for multiple robots
- Create a C#.Net version of the Barrier Control App
- Build a responsive user interface for various screen sizes
- Create a data class
- Learn to use an item manager
- Automatically generated grids and forms