onoff.cc

 1 const char *help = "\
 2 progname: onoff.cc\n\
 3 code2html: This program switch ON/OFF a Sony pan/til/zoom camera using a VISCA serial interface.\n\
 4 version: Torch3 vision2.0, 2003-2005\n\
 5 (c) Sebastien Marcel (marcel@idiap.ch)\n";
 6 
 7 #include "SonyEviD31.h"
 8 #include "SonyEviD100P.h"
 9 
10 using namespace Torch;
11 
12 int main(int argc, char **argv)
13 {
14 	print("SonyEviD100P on /dev/ttyS%s\n", argv[1]);
15 
16 	SonyEviD100P camera("/dev/ttyS", argv[1][0]);
17 
18 	if(camera.connect() == false) return 0;
19 	      
20 	int powerStatus;
21 	bool isOn;
22 	bool isOff;
23 	
24 	print("Trying to get the power status of the camera.\n");
25 	powerStatus = camera.getPowerStatus();
26 
27 	switch(powerStatus)
28 	{
29 	case -1: print("Error couldn't get the power status.\n");
30 		 break;
31 	case 0: print("The camera is OFF.\n");
32 		isOn = camera.setPowerOn();
33 		if(isOn == true) 
34 		{
35 			print("Camera should be on now !\n");
36 
37 			camera.goHome();
38 		}
39 		 break;
40 	case 1: print("The camera is ON.\n");
41 		isOff = camera.setPowerOff();
42 		if(isOff == true) print("Camera should be off now !\n");
43 		 break;
44 	default: print("Unexpected value.\n");
45 	}
46 
47 	
48 	
49 	return 1;
50 }