source: trunk/MagicSoft/Cosy/testse.cc@ 6724

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