Client examples

Simple python example to start image taking.

from PyTango import *
import sys
import time

try :
    t1 = DeviceProxy( "exp/gc655c/cam1")
    status = t1.command_inout("StartAcquisition")


except :
    print "Failed to start acquisition !"
    print sys.exc_info()[0]

Simple python example to stop image taking.

from PyTango import *
import sys
import time

try :
    t1 = DeviceProxy( "test/gc655c/cam1")
    t1.command_inout("StopAcquisition")


except :
    print "Failed to stop data acquisition !"
    print sys.exc_info()[0]

Simple cpp example to start and stop acquisition.

/* 
 * example of a client using the TANGO C++ api.
 */
#include <tango.h>
using namespace Tango;

main(unsigned int argc, char **argv)
{
  unsigned long temp;
  long  out;
  int nb_read;

  //
  // create a connection to a TANGO attribute
  //

  DeviceProxy *camera = new DeviceProxy("test/gc1280m/cam1");

  camera->command_inout("StartAcquisition");
  AttributeProxy *attribute1 = new AttributeProxy( "test/gc1280m/cam1/WriteFramesToBinaryFile");
  DeviceAttribute write_value1;
  out = 1;
  write_value1 << out;
  attribute1->write(write_value1);
//  usleep(300000);
  sleep(10);
  camera->command_inout("StopAcquisition");
}

Simple cpp example to change Exposure time.

/* 
 * example of a client using the TANGO C++ api.
 */
#include <iostream>
#include <tango.h>
using namespace Tango;

main(unsigned int argc, char **argv)
{

        long exposure_time;

        //
        // create a connection to a TANGO attribute
        //
        DeviceProxy *camera = new DeviceProxy("test/gc1280m/cam1");

        camera->command_inout("InitCamera");

    std::cout << "Introduce new exposure time (us):" << endl;

    std::cin >> exposure_time;
        AttributeProxy *attribute = new AttributeProxy( "test/gc1280m/cam1/Exposure");
    DeviceAttribute write_value;
        write_value << exposure_time;
        attribute->write(write_value);


        camera->command_inout("CleanupCamera");
}

Simple example how to read the date of the acquisition (in sec) from binary files.

/* 
 * example of a client using the TANGO C++ api.
 */
using namespace std;

int main () {
  FILE * pFile;
  int result; 
  char fecha[25];
  
  pFile = fopen ( "test_00001.bin" , "rb" );
  if (pFile==NULL) {fputs ("File error",stderr); exit (1);}
  result = fread (fecha,sizeof(char),25,pFile);
  cout << "Time : " << fecha << endl;

  fclose(pFile);

  return 0;
}