Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
ConsoleExample.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include <iostream>
14 #include <windows.h>
15 #include "OphirPyroWrapper.h"
16 #include <vector>
17 
18 int main()
19 {
20  OphirPyroWrapper pyro;
21 
22  char* sn = pyro.ScanUSB();
23  if (sn != 0)
24  std::cout << "sn: " << sn << std::endl;
25  else
26  std::cout << "sn: NULL" << std::endl;
27 
28  int handle = pyro.OpenDevice(sn);
29  std::cout << "handle: " << handle << std::endl;
30 
31  char* wl = pyro.GetWavelengths(handle);
32  std::cout << "wl: " << wl << std::endl;
33  char* gr = pyro.GetRanges(handle);
34  std::cout << "gr: " << gr << std::endl;
35 
36  bool start = pyro.StartStream(handle);
37  std::cout << "start: " << start << std::endl;
38 
39  std::vector<double> data;
40  std::vector<double> timestamp;
41  std::vector<int> status;
42  Sleep(100);
43  unsigned int gd = pyro.GetData(handle, &data, &timestamp, &status);
44  std::cout << "gd: " << gd << std::endl;
45  std::cout << "length: " << data.size() << std::endl;
46  for(int i = 0; i<gd; i++)
47  {
48  std::cout << "data " << i << ": " << data[i] << " ts: " << timestamp[i] << " status: " << status[i] << std::endl;
49  }
50 
51  Sleep(100);
52  gd = pyro.GetData(handle, &data, &timestamp, &status);
53  std::cout << "gd: " << gd << std::endl;
54  std::cout << "length: " << data.size() << std::endl;
55  for(int i = 0; i<gd; i++)
56  {
57  std::cout << "data " << i << ": " << data[i] << " ts: " << timestamp[i] << " status: " << status[i] << std::endl;
58  }
59 
60 
61  Sleep(100);
62  gd = pyro.GetData(handle, &data, &timestamp, &status);
63  std::cout << "gd: " << gd << std::endl;
64  std::cout << "length: " << data.size() << std::endl;
65  for(int i = 0; i<gd; i++)
66  {
67  std::cout << "data " << i << ": " << data[i] << " ts: " << timestamp[i] << " status: " << status[i] << std::endl;
68  }
69 
70  Sleep(1000);
71  gd = pyro.GetData(handle, &data, &timestamp, &status);
72  std::cout << "gd: " << gd << std::endl;
73  std::cout << "length: " << data.size() << std::endl;
74  for(int i = 0; i<gd; i++)
75  {
76  std::cout << "data " << i << ": " << data[i] << " ts: " << timestamp[i] << " status: " << status[i] << std::endl;
77  }
78 
79  bool stop = pyro.StopStream(handle);
80  std::cout << "stop: " << stop << std::endl;
81  bool closed = pyro.CloseDevice(handle);
82  std::cout << "closed: " << closed << std::endl;
83 }
int main()