Revision 447,
1.6 KB
checked in by lmalek, 10 years ago
(diff) |
tree structure reorganization
|
Line | |
---|
1 | #include <Samgar.h>
|
---|
2 | using namespace std;
|
---|
3 |
|
---|
4 | int main()
|
---|
5 | {
|
---|
6 | Network yarp;
|
---|
7 | int myint;
|
---|
8 | myint = 0;
|
---|
9 | Samgar::SamgarModule IntReciver("Reciver","EmergencyStop","Wheels",Samgar::ModeInterupt);
|
---|
10 | IntReciver.AddPortS("In");
|
---|
11 | // IntReciver.AddPortS("InExample");
|
---|
12 |
|
---|
13 | while( 1 )
|
---|
14 | {
|
---|
15 | if (IntReciver.getCurrentState() == Samgar::StateRunning)
|
---|
16 | {
|
---|
17 | // in this module we accept int data from the specified port. When we call a port for data a true or false returns specifying whether it is new or old data,
|
---|
18 | // and the data reference we pass gets changed if true
|
---|
19 | if(IntReciver.GetIntData("In",&myint)==true)
|
---|
20 | {
|
---|
21 | printf("got data %d \n",myint);
|
---|
22 | // in this module we also update the GUI log with this command.
|
---|
23 | if(myint % 5 == 0)
|
---|
24 | {
|
---|
25 | IntReciver.SendToLog("this has come from a port",3);
|
---|
26 | }
|
---|
27 | }
|
---|
28 | else
|
---|
29 | {
|
---|
30 | // this will never be printed proving the module sleeps after each new input
|
---|
31 | //printf("got no data \n");
|
---|
32 | }
|
---|
33 | }
|
---|
34 | // in an interrupt module this function call has added
|
---|
35 | // significance, the primary being the true or false whether it
|
---|
36 | // has accomplished its task, and secondly a variable which could
|
---|
37 | // be how well it has acheived the task. This data is sent on to
|
---|
38 | // the GUI so the success rate of the modules can be deduced
|
---|
39 | IntReciver.SucceedFail(true,myint);
|
---|
40 | }
|
---|
41 | return 0;
|
---|
42 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.