My Project
 All Classes Files Functions Variables Macros
mainClient.cpp
Go to the documentation of this file.
1 
19 #include "slsDetectorUsers.h"
20 #include "detectorData.h"
21 #include <iostream>
22 #include <cstdlib>
23 
32 int dataCallback(detectorData *pData, int iframe, int isubframe, void *pArg)
33 {
34  std::cout << " DataCallback:"
35  << "\n nx : " << pData->npoints
36  << "\n ny : " << pData->npy
37  << "\n Frame number : " << iframe << std::endl;
38 }
39 
40 
49 int main(int argc, char **argv) {
51  int id=0;
52  if (argc>=4)
53  id=atoi(argv[3]);
54 
55 
57  int ret = 1;
58  slsDetectorUsers *pDetector = new slsDetectorUsers (ret, id);
59  if (ret == 1) {
60  std::cout << "Error: Could not instantiate slsDetectorUsers" << std::endl;
61  return EXIT_FAILURE;
62  }
63 
64 
66  if (argc>=2){
67  pDetector->readConfigurationFile(argv[1]);
68  std::cout << "Detector configured" << std::endl;
69  }
70 
72  pDetector->setOnline(1);
73 
75  pDetector->setReceiverOnline(1);
76 
78  pDetector->registerDataCallback(&dataCallback, NULL);
79 
80 
82  int status = pDetector->getDetectorStatus();
83  if (status != 0){
84  std::cout << "Detector not ready: " << slsDetectorUsers::runStatusType(status) << std::endl;
85  return 1;
86  }
87 
89  if (argc>=3){
90  pDetector->retrieveDetectorSetup(argv[2]);
91  std::cout << "Detector measurement set-up done" << std::endl;
92  }
93 
94 
96  pDetector->startMeasurement();
97  std::cout << "measurement finished" << std::endl;
98 
102  delete pDetector;
103 
104  return 0;
105 }
106 
void registerDataCallback(int(*userCallback)(detectorData *d, int f, int s, void *), void *pArg)
register calbback for accessing detector final data, also enables data streaming in client and receiv...
void startMeasurement()
start measurement and acquires
int main(int argc, char **argv)
Definition: mainClient.cpp:49
int setReceiverOnline(int const online=-1)
sets the receivers onlineFlag
int retrieveDetectorSetup(std::string const fname)
Loads the detector setup from file.
int setOnline(int const online=-1)
sets the onlineFlag
The slsDetectorUsers class is a minimal interface class which should be instantiated by the users in ...
int getDetectorStatus()
get run status
int readConfigurationFile(std::string const fname)
Reads the configuration file – will contain all the informations needed for the configuration (e...
static std::string runStatusType(int s)
returns std::string from run status index
int dataCallback(detectorData *pData, int iframe, int isubframe, void *pArg)
Definition: mainClient.cpp:32