# mainClient.cpp Source File

# mainClient.cpp

Go to the documentation of this file.

    00001
    00013 #include <iostream>
    00014 #include "slsDetectorUsers.h"
    00015 #include "detectorData.h"
    00016
    00017
    00019 int dataCallback(detectorData *pData, int iframe, void *pArg)
    00020 {
    00021   std::cout  << "dataCallback: " << pData->npoints  << " "  << pData->npy  << "Frame number: " << iframe << std::endl;
    00022 }
    00023
    00024
    00026 int main(int argc,  char *argv[]) {
    00027   int id=0;
    00028   int status;
    00030   if (argc>=3)
    00031     id=atoi(argv[2]);
    00032
    00033
    00034
    00036   slsDetectorUsers *pDetector = new  slsDetectorUsers (id);
    00037
    00038
    00040   if (argc>=2)
    00041     pDetector->readConfigurationFile(argv[1]);
    00042
    00044    pDetector->setOnline(1);
    00045
    00047    if (argc>=3)
    00048            pDetector->retrieveDetectorSetup( argv[2]);
    00049    else{
    00051     int minX, minY=0, sizeX, sizeY=1;
    00052     pDetector->getDetectorSize(minX, minY, sizeX,  sizeY);
    00053     std::cout  << "X: Start=" << minX << ", Size= "  << sizeX  << std::endl;
    00054     std::cout  << "Y: Start=" << minY << ", Size= "  << sizeY  << std::endl;
    00055     pDetector->setDetectorSize(0,0,7680,1);
    00056     std::cout  <<  pDetector->getDetectorDeveloper()  << std::endl;
    00057
    00059     pDetector->registerDataCallback(&dataCallback, NULL);
    00060
    00062     status = pDetector->getDetectorStatus();
    00063     if (status  !=  0){
    00064       std::cout << "Detector not ready: " << slsDetectorUsers::runStatusType(status) << std::endl;
    00065       return 1;
    00066     }
    00067
    00069     std::cout  << "settings: "  << slsDetectorUsers::getDetectorSettings(pDetector->setSettings()) << std::endl;
    00070     pDetector->setSettings(slsDetectorUsers::getDetectorSettings("veryhighgain"));
    00071     std::cout  << "settings: "  << slsDetectorUsers::getDetectorSettings(pDetector->setSettings()) << std::endl;
    00072
    00074      pDetector->setExposureTime(10000000);
    00075
    00077      pDetector->setExposurePeriod(100000000);
    00078
    00080      pDetector->setNumberOfFrames(30);
    00081 }
    00083      pDetector->startMeasurement();
    00084
    00085      while (1) {
    00086        usleep(100000);
    00087         status = pDetector->getDetectorStatus();
    00088         if (status  == 0 || status == 1|| status == 3)
    00089           break;
    00090      }
    00091
    00092      char *temp[] = {"receiver", NULL};
    00094         std::cout << "answer to a get command:" << pDetector->getCommand(1,temp,0) << std::endl;
    00095
    00096      delete pDetector;
    00097
    00098      return 0;
    00099 }
    00100