-
Notifications
You must be signed in to change notification settings - Fork 1
/
PTZ.cpp
65 lines (57 loc) · 1.38 KB
/
PTZ.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
#include "stdafx.h"
#include "Serial.h"
#include "stdio.h"
#include<iostream>
#include<iomanip>
#include<windows.h>
using namespace std;
int main()
{
int message;
int flag = 1;
float pan, tilt;
Pantilt ptz1;
if (ptz1.Open(3, 9600) == FALSE) {
cout << "failed to open the serial port" << endl;
cin >> flag;
return 0;
}
ptz1.Position(0, 0);
ptz1.PosInq();
//cout << "(" << ptz1.pospan << "," << ptz1.postilt << ")" << endl;
//ptz1.Move(4, 1, 1);
//while (1) {
// ptz1.PosInq();
// cout << "(" << ptz1.pospan << "," << ptz1.postilt << ")" << endl;
// Sleep(500);
//}
//
//return 0;
int i = 0;
ptz1.Reset();
ptz1.PosInq();
cout << "(" << ptz1.pospan << "," << ptz1.postilt << ")" << "i=" << i << endl;
while(1){
//cout << "pan="; cin >> pan ;
//cout << "tilt="; cin >> tilt;
message = ptz1.Position(i, 0);
/*if (message > 0) cout << "successfully sent " <<oct<< message << " bytes" << endl;
else {
switch (message) {
case 0: cout << "SendCommand error" << endl; break;
case -1: cout << "pan or tilt input out rang" << endl; break;
case -2: cout << "Convert error" << endl; break;
case -3: cout << "SendCommand byte>16" << endl; break;
}
}*/
ptz1.PosInq();
cout<<"(" << ptz1.pospan << "," << ptz1.postilt <<")"<<"i="<<i<< endl;
////ptz1.Reset();
//cout << "1 to continue:";
//cin >> flag;
Sleep(1000);
i=i+1;
}
return 0;
}