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

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