source: libs/libSamgar/examples/SamgarSend.cpp @ 445

Revision 445, 1.4 KB checked in by lmalek, 10 years ago (diff)

Samgar edition by WRUT. Based on Qt. Initial import.

Line 
1#include <Samgar.h>
2#include <iostream>
3using namespace std;
4
5int main() {
6
7  int ccc =0;
8  Network yarp; // setup the network, always needed
9  // Create a module, with a given name,category and subcategory all of
10  // which must only contain a-z 0-9
11  Samgar::SamgarModule IntSender("Sender","Distance",
12                                 "Sonar",Samgar::ModeRun);
13  // The last option must be run or interrupt both of which have
14  // different effects on the module.  Run will create a module which
15  // runs continuously until a stop command is sent from the GUI or
16  // other module.  Interrupt will only enable the module to run
17  // whilst there is new data on the port, so if no infomation is sent
18  // it is then impossible to run the module.
19  IntSender.AddPortS("Out");
20//  IntSender.AddPortS("OutExample");
21  // these two commands start two ports that are children of the module
22  while( 1 )
23  {
24      if (IntSender.getCurrentState() == Samgar::StateRunning)
25      {
26          yarp::os::Time::delay(1.1);
27          // this function sends int data on the specified port
28          IntSender.SendIntData("Out",ccc++);
29          std::cout << "Data send!" <<std::endl;
30      }
31      // in a run module the data given in this function is unimportant
32      // but still needs to be called for the module to work properly
33      IntSender.SucceedFail(true,888);
34  }
35  return 0;
36}
Note: See TracBrowser for help on using the repository browser.