-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgccDppConsole.cpp
More file actions
575 lines (505 loc) · 21.9 KB
/
gccDppConsole.cpp
File metadata and controls
575 lines (505 loc) · 21.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
/** gccDppConsole.cpp */
// gccDppConsole.cpp : Defines the entry point for the console application.
#include <iostream>
#include <signal.h>
//#include <unistd.h>
//#include <stdlib.h>
//#include <errno.h>
using namespace std;
#ifdef _WIN32
#include <windows.h>
#include <conio.h>
#include <tchar.h>
//#pragma comment(lib, "user32.lib")
#define CLEAR_TERM "cls"
#else
#define Sleep(x) usleep((x)*1000)
#define _getch getchar
#define CLEAR_TERM "clear"
#endif
#include "ConsoleHelper.h"
#include "stringex.h"
//#include <unistd.h>
#define SHARE_BUF_SIZE 40000 // byte 2049 * sizeof(unsigned long long) (16392)
TCHAR szName[]=TEXT("GlobalMyFileMappingObject");
TCHAR mtName[]=TEXT("Mutex");
TCHAR evName[]=TEXT("Event");
CConsoleHelper chdpp; // DPP communications functions
bool bRunSpectrumTest = false; // run spectrum test
bool bRunConfigurationTest = false; // run configuration test
bool bHaveStatusResponse = false; // have status response
bool bHaveConfigFromHW = false; // have configuration from hardware
static bool sig_received = false;
/* シグナルハンドラ */
void SignalHandler(int sig) {
if (sig == SIGINT) {
cout << "received SIGINT" << endl;
} else if (sig == SIGTERM) {
cout << "received SIGTERM" << endl;
}
sig_received = true;
}
void InitializeSignalHandler () {
sig_received = false;
if (signal(SIGINT, SignalHandler) == SIG_ERR) {
cout << "can't catch SIGINT" << endl;
}
if (signal(SIGTERM, SignalHandler) == SIG_ERR) {
cout << "can't catch SIGTERM" << endl;
}
}
bool InitializeSharedMemory(HANDLE &hMapFile, unsigned long long* &pBuf, HANDLE &ghMutex, HANDLE &hEvent) {
hMapFile = CreateFileMapping(
INVALID_HANDLE_VALUE, // use paging file
NULL, // default security
PAGE_READWRITE, // read/write access
0, // maximum object size (high-order DWORD)
SHARE_BUF_SIZE, // maximum object size (low-order DWORD)
szName); // name of mapping object
if (hMapFile == NULL) {
_tprintf(TEXT("Could not create file mapping object (%d).\n"),
GetLastError());
return false;
}
pBuf = (unsigned long long*) MapViewOfFile(hMapFile, // handle to map object
FILE_MAP_ALL_ACCESS, // read/write permission
0,
0,
SHARE_BUF_SIZE);
if (pBuf == NULL) {
_tprintf(TEXT("Could not map view of file (%d).\n"),
GetLastError());
CloseHandle(hMapFile);
return false;
}
ghMutex = CreateMutex(NULL, FALSE, mtName);
if (ghMutex == NULL) {
printf("CreateMutex error: %d\n", GetLastError());
return false;
}
hEvent = CreateEvent(NULL, TRUE, FALSE, evName);
if (hEvent == NULL) {
printf("CreateEvent error: %d\n", GetLastError());
return false;
}
return true;
}
// connect to default dpp
// CConsoleHelper::LibUsb_Connect_Default_DPP // LibUsb connect to default DPP
void ConnectToDefaultDPP() {
cout << endl;
cout << "Running DPP LibUsb tests from console..." << endl;
cout << endl;
cout << "\tConnecting to default LibUsb device..." << endl;
if (chdpp.LibUsb_Connect_Default_DPP()) {
cout << "\t\tLibUsb DPP device connected." << endl;
cout << "\t\tLibUsb DPP devices present: " << chdpp.LibUsb_NumDevices << endl;
} else {
cout << "\t\tLibUsb DPP device not connected." << endl;
cout << "\t\tNo LibUsb DPP device present." << endl;
}
}
// Get DPP Status
// CConsoleHelper::LibUsb_isConnected // check if DPP is connected
// CConsoleHelper::LibUsb_SendCommand(XMTPT_SEND_STATUS) // request status
// CConsoleHelper::LibUsb_ReceiveData() // parse the status
// CConsoleHelper::DppStatusString // display status string
void GetDppStatus() {
if (chdpp.LibUsb_isConnected) { // send and receive status
cout << endl;
cout << "\tRequesting Status..." << endl;
if (chdpp.LibUsb_SendCommand(XMTPT_SEND_STATUS)) { // request status
cout << "\t\tStatus sent." << endl;
cout << "\t\tReceiving status..." << endl;
if (chdpp.LibUsb_ReceiveData()) {
cout << "\t\t\tStatus received..." << endl;
cout << chdpp.DppStatusString << endl;
bRunSpectrumTest = true;
bHaveStatusResponse = true;
bRunConfigurationTest = true;
} else {
cout << "\t\tError receiving status." << endl;
}
} else {
cout << "\t\tError sending status." << endl;
}
}
}
// Read Full DPP Configuration From Hardware // request status before sending/receiving configurations
// CONFIG_OPTIONS // holds configuration command options
// CConsoleHelper::CreateConfigOptions // creates configuration options from last status read
// CConsoleHelper::ClearConfigReadFormatFlags(); // clear configuration format flags, for cfg readback
// CConsoleHelper::CfgReadBack = true; // requesting general readback format
// CConsoleHelper::LibUsb_SendCommand_Config // send command with options
// CConsoleHelper::LibUsb_ReceiveData() // parse the configuration
// CConsoleHelper::HwCfgReady // config is ready
void ReadDppConfigurationFromHardware(bool bDisplayCfg) {
CONFIG_OPTIONS CfgOptions;
if (bHaveStatusResponse && bRunConfigurationTest) {
//test configuration functions
// Set options for XMTPT_FULL_READ_CONFIG_PACKET
chdpp.CreateConfigOptions(&CfgOptions, "", chdpp.DP5Stat, false);
cout << endl;
cout << "\tRequesting Full Configuration..." << endl;
chdpp.ClearConfigReadFormatFlags(); // clear all flags, set flags only for specific readback properties
//chdpp.DisplayCfg = false; // DisplayCfg format overrides general readback format
chdpp.CfgReadBack = true; // requesting general readback format
if (chdpp.LibUsb_SendCommand_Config(XMTPT_FULL_READ_CONFIG_PACKET,
CfgOptions)) { // request full configuration
if (chdpp.LibUsb_ReceiveData()) {
if (chdpp.HwCfgReady) { // config is ready
bHaveConfigFromHW = true;
if (bDisplayCfg) {
cout << "\t\t\tConfiguration Length: " << (unsigned int) chdpp.HwCfgDP5.length() << endl;
cout << "\t================================================================" << endl;
cout << chdpp.HwCfgDP5 << endl;
cout << "\t================================================================" << endl;
cout << "\t\t\tScroll up to see configuration settings." << endl;
cout << "\t================================================================" << endl;
} else {
cout << "\t\tFull configuration received." << endl;
}
}
}
}
}
}
// Display Preset Settings
// CConsoleHelper::strPresetCmd // preset mode
// CConsoleHelper::strPresetVal // preset setting
void DisplayPresets() {
if (bHaveConfigFromHW) {
cout << "\t\t\tPreset Mode: " << chdpp.strPresetCmd << endl;
cout << "\t\t\tPreset Settings: " << chdpp.strPresetVal << endl;
}
}
// Display Preset Settings
// CONFIG_OPTIONS // holds configuration command options
// CConsoleHelper::CreateConfigOptions // creates configuration options from last status read
// CConsoleHelper::HwCfgDP5Out // preset setting
// CConsoleHelper::LibUsb_SendCommand_Config // send command with options
void SendPresetAcquisitionTime(string strPRET) {
CONFIG_OPTIONS CfgOptions;
cout << "\tSetting Preset Acquisition Time..." << strPRET << endl;
chdpp.CreateConfigOptions(&CfgOptions, "", chdpp.DP5Stat, false);
CfgOptions.HwCfgDP5Out = strPRET;
// send PresetAcquisitionTime string, bypass any filters, read back the mode and settings
if (chdpp.LibUsb_SendCommand_Config(XMTPT_SEND_CONFIG_PACKET_EX, CfgOptions)) {
ReadDppConfigurationFromHardware(false); // read setting back
DisplayPresets(); // display new presets
} else {
cout << "\t\tPreset Acquisition Time NOT SET" << strPRET << endl;
}
}
void SendListData(HANDLE &hMapFile, unsigned long long* &pBuf, HANDLE &ghMutex, HANDLE &hEvent,
unsigned long long (&list_data)[MAX_LIST_BUFFER_RECORDS], short records) {
// system(CLEAR_TERM);
// for (int i = 0; i < records; i++) {
// cout << list_data[i] << endl;
// }
// mutex lock
WaitForSingleObject(ghMutex, INFINITE);
// write shared memory
CopyMemory(pBuf, list_data, sizeof(unsigned long long) * records);
// mutex unlock
ReleaseMutex(ghMutex);
// set event signal
SetEvent(hEvent);
}
// Acquire Spectrum
// CConsoleHelper::LibUsb_SendCommand(XMTPT_DISABLE_MCA_MCS) //disable for data/status clear
// CConsoleHelper::LibUsb_SendCommand(XMTPT_SEND_CLEAR_SPECTRUM_STATUS) //clear spectrum/status
// CConsoleHelper::LibUsb_SendCommand(XMTPT_ENABLE_MCA_MCS); // enabling MCA for spectrum acquisition
// CConsoleHelper::LibUsb_SendCommand(XMTPT_SEND_SPECTRUM_STATUS)) // request spectrum+status
// CConsoleHelper::LibUsb_ReceiveData() // process spectrum and data
// CConsoleHelper::ConsoleGraph() (low resolution display) // graph data on console with status
// CConsoleHelper::LibUsb_SendCommand(XMTPT_DISABLE_MCA_MCS) // disable mca after acquisition
void AcquireSpectrum(HANDLE &hMapFile, unsigned long long* &pBuf, HANDLE &ghMutex, HANDLE &hEvent, int time) {
bool bDisableMCA = false;
//bRunSpectrumTest = false; // disable test
if (bRunSpectrumTest) {
cout << "\tRunning spectrum test..." << endl;
cout << "\t\tDisabling MCA for spectrum data/status clear." << endl;
chdpp.LibUsb_SendCommand(XMTPT_DISABLE_MCA_MCS);
Sleep(1000);
cout << "\t\tClearing spectrum data/status." << endl;
chdpp.LibUsb_SendCommand(XMTPT_SEND_CLEAR_SPECTRUM_STATUS);
Sleep(1000);
cout << "\t\tEnabling MCA for spectrum data acquisition with status ." << endl;
chdpp.LibUsb_SendCommand(XMTPT_ENABLE_MCA_MCS);
Sleep(1000);
cout << "\t\tClear list mode timer" << endl;
chdpp.LibUsb_SendCommand(XMTPT_CLEAR_LIST_MODE_TIMER);
Sleep(100);
cout << "\t\tClear spectrum" << endl;
chdpp.LibUsb_SendCommand(XMTPT_CLEAR_SPECTRUM_BUFFER_A);
Sleep(100);
system(CLEAR_TERM);
while (true) {
if (sig_received) {
cout << "sig received" << endl;
InitializeSignalHandler();
break;
}
if (chdpp.LibUsb_SendCommand(XMTPT_SEND_LIST_MODE_DATA)) { // request list
if (chdpp.LibUsb_ReceiveData()) {
bDisableMCA = true;
SendListData(hMapFile, pBuf, ghMutex, hEvent, chdpp.DP5Proto.LISTDATA.AMPLITUDE, chdpp.DP5Proto.LISTDATA.AMPLITUDE_RECORDS);
if (chdpp.DP5Proto.LISTDATA.isFIFOFULL)
cout << "FIFOFULL" << endl;
}
} else {
SetEvent(hEvent);
cout << "\t\tProblem acquiring spectrum." << endl;
break;
}
Sleep(time);
}
if (bDisableMCA) {
SetEvent(hEvent);
system("Pause");
cout << "\t\tSpectrum acquisition with status done. Disabling MCA." << endl;
chdpp.LibUsb_SendCommand(XMTPT_DISABLE_MCA_MCS);
Sleep(1000);
}
}
}
// Read Configuration File
// CConsoleHelper::SndCmd.GetDP5CfgStr("PX5_Console_Test.txt");
void ReadConfigFile() {
std::string strCfg;
strCfg = chdpp.SndCmd.AsciiCmdUtil.GetDP5CfgStr("PX5_Console_Test.txt");
cout << "\t\t\tConfiguration Length: " << (unsigned int) strCfg.length() << endl;
cout << "\t================================================================" << endl;
cout << strCfg << endl;
cout << "\t================================================================" << endl;
}
//Following is an example of loading a configuration from file
//then sending the configuration to the DPP device.
// SendConfigFileToDpp("NaI_detector_cfg.txt"); // calls SendCommandString
// AcquireSpectrum();
//
bool SendCommandString(string strCMD) {
CONFIG_OPTIONS CfgOptions;
chdpp.CreateConfigOptions(&CfgOptions, "", chdpp.DP5Stat, false);
CfgOptions.HwCfgDP5Out = strCMD;
// send ASCII command string, bypass any filters, read back the mode and settings
if (chdpp.LibUsb_SendCommand_Config(XMTPT_SEND_CONFIG_PACKET_EX, CfgOptions)) {
// command sent
} else {
cout << "\t\tASCII Command String NOT SENT" << strCMD << endl;
return false;
}
return true;
}
std::string ShortenCfgCmds(std::string strCfgIn) {
std::string strCfg("");
strCfg = strCfgIn;
long lCfgLen = 0; //ASCII Configuration Command String Length
lCfgLen = (long) strCfg.length();
if (lCfgLen > 0) {
strCfg = chdpp.SndCmd.AsciiCmdUtil.ReplaceCmdText(strCfg, "US;", ";");
strCfg = chdpp.SndCmd.AsciiCmdUtil.ReplaceCmdText(strCfg, "OFF;", "OF;");
strCfg = chdpp.SndCmd.AsciiCmdUtil.ReplaceCmdText(strCfg, "RISING;", "RI;");
strCfg = chdpp.SndCmd.AsciiCmdUtil.ReplaceCmdText(strCfg, "FALLING;", "FA;");
}
return strCfg;
}
// run GetDppStatus(); first to get PC5_PRESENT, DppType
// Includes Configuration Oversize Fix 20141224
bool SendConfigFileToDpp(string strFilename) {
std::string strCfg;
long lCfgLen = 0; //ASCII Configuration Command String Length
bool bCommandSent = false;
bool isPC5Present = false;
int DppType = 0;
int idxSplitCfg = 0; //Configuration split position, only if necessary
bool bSplitCfg = false; //Configuration split flag
std::string strSplitCfg(""); //Configuration split string second buffer
bool isDP5_RevDxGains;
unsigned char DPP_ECO;
isPC5Present = chdpp.DP5Stat.m_DP5_Status.PC5_PRESENT;
DppType = chdpp.DP5Stat.m_DP5_Status.DEVICE_ID;
isDP5_RevDxGains = chdpp.DP5Stat.m_DP5_Status.isDP5_RevDxGains;
DPP_ECO = chdpp.DP5Stat.m_DP5_Status.DPP_ECO;
strCfg = chdpp.SndCmd.AsciiCmdUtil.GetDP5CfgStr(strFilename);
strCfg = chdpp.SndCmd.AsciiCmdUtil.RemoveCmdByDeviceType(strCfg, isPC5Present, DppType, isDP5_RevDxGains, DPP_ECO);
lCfgLen = (long) strCfg.length();
if ((lCfgLen > 0) && (lCfgLen <= 512)) { // command length ok
cout << "\t\t\tConfiguration Length: " << lCfgLen << endl;
} else if (lCfgLen > 512) { // configuration too large, needs fix
cout << "\t\t\tConfiguration Length (Will Shorten): " << lCfgLen << endl;
strCfg = ShortenCfgCmds(strCfg);
lCfgLen = (long) strCfg.length();
if (lCfgLen > 512) { // configuration still too large, split config
cout << "\t\t\tConfiguration Length (Will Split): " << lCfgLen << endl;
bSplitCfg = true;
idxSplitCfg = chdpp.SndCmd.AsciiCmdUtil.GetCmdChunk(strCfg);
cout << "\t\t\tConfiguration Split at: " << idxSplitCfg << endl;
strSplitCfg = strCfg.substr(idxSplitCfg);
strCfg = strCfg.substr(0, idxSplitCfg);
}
} else {
cout << "\t\t\tConfiguration Length Error: " << lCfgLen << endl;
return false;
}
bCommandSent = SendCommandString(strCfg);
if (bSplitCfg) {
// Sleep(40); // may need delay here
bCommandSent = SendCommandString(strSplitCfg);
}
return bCommandSent;
}
// Close Connection
// CConsoleHelper::LibUsb_isConnected // LibUsb DPP connection indicator
// CConsoleHelper::LibUsb_Close_Connection() // close connection
void CloseConnection() {
if (chdpp.LibUsb_isConnected) { // send and receive status
cout << endl;
cout << "\tClosing connection to default LibUsb device..." << endl;
chdpp.LibUsb_Close_Connection();
cout << "\t\tDPP device connection closed." << endl;
}
}
// Helper functions for saving spectrum files
void SaveSpectrumConfig() {
string strSpectrumConfig;
chdpp.Dp5CmdList = chdpp.MakeDp5CmdList(); // ascii text command list for adding comments
strSpectrumConfig = chdpp.CreateSpectrumConfig(chdpp.HwCfgDP5); // append configuration comments
chdpp.sfInfo.strSpectrumConfig = strSpectrumConfig;
}
// Saving spectrum file
void SaveSpectrumFile() {
string strSpectrum; // holds final spectrum file
chdpp.sfInfo.strSpectrumStatus = chdpp.DppStatusString; // save last status after acquisition
chdpp.sfInfo.m_iNumChan = chdpp.mcaCH; // number channels in spectrum
chdpp.sfInfo.SerialNumber = chdpp.DP5Stat.m_DP5_Status.SerialNumber; // dpp serial number
chdpp.sfInfo.strDescription = "Amptek Spectrum File"; // description
chdpp.sfInfo.strTag = "TestTag"; // tag
// create spectrum file, save file to string
strSpectrum = chdpp.CreateMCAData(chdpp.DP5Proto.SPECTRUM.DATA, chdpp.sfInfo, chdpp.DP5Stat.m_DP5_Status);
chdpp.SaveSpectrumStringToFile(strSpectrum); // save spectrum file string to file
}
int main(int argc, char *argv[]) {
system(CLEAR_TERM);
ConnectToDefaultDPP();
cout << "Press the Enter key to continue . . .";
_getch();
if (!chdpp.LibUsb_isConnected) { return 1; }
system(CLEAR_TERM);
chdpp.DP5Stat.m_DP5_Status.SerialNumber = 0;
GetDppStatus();
cout << "Press the Enter key to continue . . .";
_getch();
if (chdpp.DP5Stat.m_DP5_Status.SerialNumber == 0) { return 1; }
////// system("cls");
////// SendConfigFileToDpp("PX5_Console_Test.txt"); // calls SendCommandString
////// system("Pause");
system(CLEAR_TERM);
ReadDppConfigurationFromHardware(true);
cout << "Press the Enter key to continue . . .";
_getch();
system(CLEAR_TERM);
DisplayPresets();
cout << "Press the Enter key to continue . . .";
_getch();
// system(CLEAR_TERM);
// SendPresetAcquisitionTime("PRET=20;");
// SaveSpectrumConfig();
// cout << "Press the Enter key to continue . . .";
// _getch();
system(CLEAR_TERM);
SendPresetAcquisitionTime("PRET=OFF;");
cout << "Press the Enter key to continue . . .";
_getch();
InitializeSignalHandler();
HANDLE hMapFile = NULL;
unsigned long long *pBuf = NULL;
HANDLE ghMutex = NULL;
HANDLE hEvent = NULL;
bool isSharedMemoryUsefull = InitializeSharedMemory(hMapFile, pBuf, ghMutex, hEvent);
int time = 100;
while (isSharedMemoryUsefull) {
system(CLEAR_TERM);
cout << "Request status packet: 1" << endl;
// cout << "Request List-mode data: 2" << endl;
// cout << "Text configuration to DP5: 3" << endl;
// cout << "Text configuration Readback from DP5: 4" << endl;
cout << "Clear Spectrum Buffer: 5" << endl;
cout << "Enable MCA/MCS: 6" << endl;
cout << "Disable MCA/MCS: 7" << endl;
cout << "Clear/Sync List-mode timer: 8" << endl;
cout << "Set request List-mode call interval time (milli sec): 9" << " now: " << time << endl;
cout << "Start request List-mode call loop: 10" << endl;
cout << "End: 0" << endl;
int command = 0;
cin >> command;
if (command == 0) {
break;
} else if (command == 1) {
GetDppStatus();
cout << "Press the Enter key to continue . . .";
_getch();
// } else if (command == 2) {
// break;
// } else if (command == 3) {
// break;
// } else if (command == 4) {
// break;
} else if (command == 5) {
cout << "\t\tClear spectrum" << endl;
if (chdpp.LibUsb_SendCommand(XMTPT_CLEAR_SPECTRUM_BUFFER_A)) {
chdpp.LibUsb_ReceiveData();
}
cout << "Press the Enter key to continue . . .";
_getch();
} else if (command == 6) {
cout << "\t\tEnabling MCA for spectrum data acquisition with status ." << endl;
chdpp.LibUsb_SendCommand(XMTPT_ENABLE_MCA_MCS);
cout << "Press the Enter key to continue . . .";
_getch();
} else if (command == 7) {
cout << "\t\tDisabling MCA for spectrum data/status clear." << endl;
chdpp.LibUsb_SendCommand(XMTPT_DISABLE_MCA_MCS);
cout << "Press the Enter key to continue . . .";
_getch();
} else if (command == 8) {
cout << "\t\tClear list mode timer" << endl;
if (chdpp.LibUsb_SendCommand(XMTPT_CLEAR_LIST_MODE_TIMER)) {
chdpp.LibUsb_ReceiveData();
}
cout << "Press the Enter key to continue . . .";
_getch();
} else if (command == 9) {
cin >> time;
cout << "Press the Enter key to continue . . .";
_getch();
} else if (command == 10) {
AcquireSpectrum(hMapFile, pBuf, ghMutex, hEvent, time);
} else {
break;
}
}
if (hEvent != NULL) {
CloseHandle(hEvent);
}
if (ghMutex != NULL) {
CloseHandle(ghMutex);
}
if (pBuf != NULL)
UnmapViewOfFile(pBuf);
if (hMapFile != NULL)
CloseHandle(hMapFile);
SaveSpectrumFile();
cout << "Press the Enter key to continue . . .";
_getch();
system(CLEAR_TERM);
ReadConfigFile();
cout << "Press the Enter key to continue read . . .";
_getch();
system(CLEAR_TERM);
CloseConnection();
cout << "Press the Enter key to continue . . .";
_getch();
return 0;
}