source: trunk/Cosy/testse.cc@ 10107

Last change on this file since 10107 was 8376, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 1.8 KB
Line 
1#include <iostream>
2
3#include "network.h"
4#include "shaftencoder.h"
5
6using namespace std;
7
8TROOT root("Cosy", "Magic Control System");
9
10int main(int argc, char **argv)
11{
12// TApplication* app = new TApplication("App", &argc, argv);
13// MLog *l = new MLog("log/cosy.log", kTRUE);
14// MLog &lout = *l;
15// gLog.EnableOutputDevice(MLog::eStdout);
16
17 cout << endl;
18 cout << "Usage: testse [nodeid [[speed]" << endl;
19 cout << endl;
20 const int baud = argc>2 ? atoi(argv[2]) : 500;
21 cout << "Creating Network (" << baud << "bps)..." << endl;
22 Network net("/dev/dpm_00", baud);
23
24 const int nodeid = argc>1 ? atoi(argv[1]) : 16;
25
26 cout << "Creating SE #" << nodeid << "..." << endl;
27 ShaftEncoder se(nodeid, "SE/Zd1");
28
29 cout << "Adding SE..." << endl;
30 net.SetNode(&se);
31
32 // Don't call this function twice!
33 cout << "Start Network..." << endl;
34 net.Start();
35
36 if (se.IsZombieNode())
37 {
38 cout << " /-------------------------------------\\" << endl;
39 cout << " >>>>> Initialization of ShaftEncoder failed <<<<<" << endl;
40 cout << " \\-------------------------------------/" << endl;
41 }
42 else
43 {
44#ifndef TESTPDO
45 while (1)
46 {
47 se.RequestSDO(0x6004);
48 se.WaitForSdo(0x6004);
49 if (se.IsZombieNode())
50 {
51 cout << " /------------------------------\\" << endl;
52 cout << " >>>>> Reading of ShaftEncoder failed <<<<<" << endl;
53 cout << " \\------------------------------/" << endl;
54 break;
55 }
56 usleep(100000);
57 }
58#else
59 for (int i=0; i<50; i++)
60 {
61 cout << se.GetPos() << endl;
62 usleep(100000);
63 }
64#endif
65 }
66
67 cout << "Stop Network..." << endl;
68 net.Stop();
69
70 cout << "The End." << endl;
71}
Note: See TracBrowser for help on using the repository browser.