gclib 2.0.9
Communications API for Galil controllers and PLCs
 
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1
4#include "Galil.h"
5#include <iostream>
6#include <iomanip>
7#include <Windows.h> //Sleep
8using namespace std;
9
10int run(int argc, char *argv[])
11{
12 try
13 {
14 cout << Galil::libraryVersion() << '\n';
15
16 for (string s : Galil::addresses())
17 cout << s << '\n';
18
19 //Galil g("GALILPCI1");
20 Galil g("192.168.0.100");
21
22 try
23 {
24 g.command("xx"); //will throw string
25 }
26 catch (string s)
27 {
28 cout << s << endl;
29 }
30
31 cout << g.connection() << '\n';
32 cout << "MGTIME: [" << g.command("MG TIME") << "]\n"; //brackets to visually check trimming
33 //g.command("UI 0");
34 //cout << "Interrupt: " << g.interrupt() << '\n'; //30000 Bug 2047 - UDP interrupt payload byte count incorrect
35 g.programDownload("WT 600\rMG \"Message from DMC code\", TIME\rEN");
36 cout << '\n' << g.programUpload() << '\n' << '\n';
37 g.command("XQ");
38
39 Sleep(1000);
40 cout << g.message(700);
41
42
44 down.push_back(3.1415);
45 down.push_back(2.7183);
46 down.push_back(1.6180);
47 down.push_back(42);
48 g.arrayDownload(down, "mynums");
49 g.arrayUploadFile(); //uses the default arrays.csv
50 g.command("DA *[]");
51 g.arrayDownloadFile(); //uses the default arrays.csv
52 vector<double> up = g.arrayUpload("mynums");
53 for (auto d : up) cout << d << " ";
54 cout << '\n';
55
56 // g.firmwareDownloadFile("\\\\rd3\\applications2\\firmware\\hex2\\4000.dmc\\dmc-4000-r12b-bck.hex");
57 // cout << g.connection() << '\n';
58 // g.firmwareDownloadFile("\\\\rd3\\applications2\\firmware\\hex2\\4000.dmc\\dmc-4000-r12b.hex");
59 // cout << g.connection() << '\n';
60
61 g.write("MG TIME \r");
62 cout << g.read();
63 cout << "\n\n";
64
65 //Data record
66
67
68 vector<string> sources = g.sources();
69 vector<char> r = g.record("QR");
70 for (auto s : sources)
71 {
72 cout << left << setw(10)
73 << g.sourceValue(r, s)
74 << setw(10) << s
75
76 << g.source("Description", s)
77 << ", " << g.source("Units", s)
78 << ", S" << g.source("Scale", s)
79 << " O" << g.source("Offset", s)
80 << '\n';
81 }
82 cout << "\n\n";
83
84 //modify source properties
85 /*g.setSource("Units", "TIME", "seconds");
86 g.setSource("Description", "TIME", "Seconds counter");
87 g.setSource("Scale", "TIME", "1024");
88
89 cout << "TIME" << ""
90 << ", " << g.source("Description", "TIME")
91 << ":" << g.sourceValue(g.record(), "TIME")
92 << " " << g.source("Units", "TIME")
93 << " S:" << g.source("Scale", "TIME")
94 << " O:" << g.source("Offset", "TIME")
95 << '\n';*/
96
97
98 return 0;
99 }
100 catch (string s)
101 {
102 cout << s;
103 return 1;
104 }
105
106}
107
108
109int main(int argc, char *argv[])
110{
111 int rc = run(argc, argv);
112#ifdef _DEBUG
113 cout << "\n\nPress enter to exit...\n";
114 getchar();
115#endif
116 return rc;
117}
Definition Galil.h:26
int main(int argc, char *argv[])
Main function for Commands Example.
GReturn vector(GCon g, char *file)
Puts controller into Vector Mode and accepts a file defining vector points.
Definition vector.cpp:36