-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathControlLight.cpp
More file actions
1435 lines (1228 loc) · 53.5 KB
/
ControlLight.cpp
File metadata and controls
1435 lines (1228 loc) · 53.5 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
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ControlLight.cpp : Defines the entry point for the application.
//
//#include "std.h"
#include "ControlAPI.h"
#include "std.h"
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <thread>
#include <cstdio>
#include <bitset>
#ifdef _WIN32
#include <conio.h>
#else
#include <sys/select.h>
#include <termios.h>
#include <unistd.h>
#endif
using namespace std;
#ifdef _WIN32
bool ConsoleKeyPressed() {
if (_kbhit()) {
_getch();
return true;
}
return false;
}
#else
bool ConsoleKeyPressed() {
termios oldTerminalSettings;
if (tcgetattr(STDIN_FILENO, &oldTerminalSettings) != 0) {
return false;
}
termios newTerminalSettings = oldTerminalSettings;
newTerminalSettings.c_lflag &= ~(ICANON | ECHO);
if (tcsetattr(STDIN_FILENO, TCSANOW, &newTerminalSettings) != 0) {
return false;
}
fd_set readFileDescriptors;
FD_ZERO(&readFileDescriptors);
FD_SET(STDIN_FILENO, &readFileDescriptors);
timeval timeout = { 0, 0 };
int selected = select(STDIN_FILENO + 1, &readFileDescriptors, nullptr, nullptr, &timeout);
if (selected > 0) {
char key;
(void)read(STDIN_FILENO, &key, 1);
}
tcsetattr(STDIN_FILENO, TCSANOW, &oldTerminalSettings);
return selected > 0;
}
#endif
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#define new DEBUG_NEW
#endif
#ifdef WIN32
#define ConfigFileName "..\\..\\..\\ControlHardwareConfig.json"
#else
#define ConfigFileName "./ControlHardwareConfig.json"
#endif
#if !defined(BUILDING_DLL) && defined(USING_DLL)
//if you use Namespace CLA, you need to put CLA:: in front of all DLL function names; you can then remove the CLA_ prefix from all functions
#ifdef THROW_EXCEPTIONS
#ifdef API_CLASS
ControlLight_API CLA;
bool LoadControlHardwareInterface() {
bool ControlHardwareInterfaceLoadedSuccessfully = false;
try {
bool success = true;
try { CLA.LoadFromJSONFile(ConfigFileName); }
catch (...) {
success = false;
}
CLA.Initialize();
bool ready = true;
try { CLA.IsReady(); }
catch (...) { ready = false; }
if (ready) {
if (!success) {
ControlMessageBox("Warning: Loading of hardware configuration file worked only partially.");
}
ControlHardwareInterfaceLoadedSuccessfully = true;
//AddErrorMessage("Hardware configuration file loaded");
}
else {
if (success) {
AddErrorMessage("Warning: Hardware configuration file did not contain a sequencer with ID=0.");
}
}
}
catch (const CLA_Exception& e) {
ControlMessageBox(e.what());
}
catch (...) {
ControlMessageBox("Error loading hardware configuration file 1");
}
if (!ControlHardwareInterfaceLoadedSuccessfully) {
try {
CLA.Cleanup();
CLA.Create(/*InitializeAfx*/ false, /*InitializeAfxSocket*/ false);
}
catch (...) {
ControlMessageBox("Error during cleanup");
}
}
return ControlHardwareInterfaceLoadedSuccessfully;
}
int main() {
cout << "Class wrapped API, using exceptions" << endl;
//try { //happens in class constructor
// CLA.Create(/*InitializeAfx*/ true, /*InitializeAfxSocket*/ true);
//}
//catch (...) {
// AddErrorMessage("Initialization failed");
// return 1; // Initialization failed
//}
if (!CLA.IsCreated()) {
AddErrorMessage("Initialization failed");
return 1; // Initialization failed
}
try {
if (!LoadControlHardwareInterface()) {
AddErrorMessage("Error loading hardware configuration file 2");
CLA.AddDeviceSequencer(0, "OpticsFoundrySequencerV1", "192.168.1.90", 7, true, 0, 100000000, 2000000, false, true, true, true);
CLA.AddDeviceAnalogOut16bit(0, 24, 4, true, -10, 10);
CLA.AddDeviceAnalogOut16bit(0, 552, 4, true, -10, 10);
CLA.AddDeviceDigitalOut(0, 1, 16);
CLA.AddDeviceDigitalOut(0, 2, 16);
CLA.AddDeviceAD9854(0, 232, 2, 300000000, 1, 1);
CLA.AddDeviceAD9858(0, 652, 1200000000, 1);
CLA.AddDeviceAD9959(0, 21, 1000000000, 1);
CLA.Initialize();
}
}
catch (...) {
ControlMessageBox("Error loading hardware configuration file 3");
try {
CLA.Cleanup();
}
catch (...) {
ControlMessageBox("Error during cleanup");
}
//CLA.Cleanup(); //happens in class destructor
return -1;
}
CLA.SwitchDebugMode(true, "DebugSequencer");
try { CLA.IsReady(); }
catch (...) {
AddErrorMessage("Not all sequencers connected");
CLA.Cleanup();
return -1;
}
//test
uint8_t* buffer = nullptr;
for (int i = 0; i < 10; i++) {
cout << "Iteration " << i << ": ";
try {
Time starttime = Clock::now();
CLA.StartAssemblingSequence();
//start data acquisition. This is an example for a command for which we didn't yet provide a convenience function in the DLL.
//In this somewhat convoluted manner one can achieve anything without API interface changes
/*
uint8_t ChannelNumber = 0;
uint32.t NumberOfDataPoints = 1000;
double DelayBetweenDataPoints.in.ms.in.ms = 0.02;
CLA.SetValueSerialDevice(0, 0, 0, (uint8_t*)&ChannelNumber, 8);
CLA.SetValueSerialDevice(0, 0, 1, (uint8_t*)&NumberOfDataPoints, 32);
CLA.SetValueSerialDevice(0, 0, 2, (uint8_t*)&DelayBetweenDataPoints.in.ms.in.ms, 64);
CLA.SetValueSerialDevice(0, 0, 3, (uint8_t*)&ChannelNumber, 8); //starts the acquisition
*/
//this is the same command using a convenience function
CLA.SequencerStartAnalogInAcquisition(0, 0, 1000, 0.02);
for (int j = 1; j < 100; j++) {
CLA.SetVoltage(0, 24, 10.0 * j / 100.0);
uint16_t data = 0xffff;
CLA.SetValue(0, 1, 0, (uint8_t*)&data, 16);
CLA.Wait_ms(0.1);
data = 0;
CLA.SetValue(0, 1, 0, (uint8_t*)&data, 16);
CLA.Wait_ms(0.1);
double Frequency = 1000.0 * j / 100.0;
CLA.SetValue(0, 232, 0, (uint8_t*)&Frequency, 64);
}
CLA.Wait_ms(10);
CLA.ExecuteSequence();
bool running = false;
unsigned long long DataPointsWritten = 0;
CLA.GetSequenceExecutionStatus(running, DataPointsWritten);
unsigned long buffer_length = 0;
unsigned long EndTimeOfCycle = 0;
CLA.WaitTillEndOfSequenceThenGetInputData(buffer, buffer_length, EndTimeOfCycle, 10);
Duration duration = Clock::now() - starttime;
cout << "Duration: " << milliSeconds(duration) << " ms Buffer length : " << buffer_length << endl;
}
catch (const CLA_Exception& e) {
ControlMessageBox(e.what());
}
catch (...) {
AddErrorMessage("Error during sequence execution");
}
}
try {
CLA.Cleanup();
}
catch (...) {
AddErrorMessage("Error during cleanup");
}
return 0;
}
#else
bool LoadControlHardwareInterface() {
bool ControlHardwareInterfaceLoadedSuccessfully = false;
try {
bool success = true;
try { CLA_LoadFromJSONFile(ConfigFileName); }
catch (...) {
success = false;
}
CLA_Initialize();
bool ready = true;
try { CLA_IsReady(); }
catch (...) { ready = false; }
if (ready) {
if (!success) {
ControlMessageBox("Warning: Loading of hardware configuration file worked only partially.");
}
ControlHardwareInterfaceLoadedSuccessfully = true;
//AddErrorMessage("Hardware configuration file loaded");
}
else {
if (success) {
AddErrorMessage("Warning: Hardware configuration file did not contain a sequencer with ID=0.");
}
}
}
catch (const CLA_Exception& e) {
ControlMessageBox(e.what());
}
catch (...) {
ControlMessageBox("Error loading hardware configuration file 1");
}
if (!ControlHardwareInterfaceLoadedSuccessfully) {
try {
CLA_Cleanup();
CLA_Create(/*InitializeAfx*/ false, /*InitializeAfxSocket*/ false);
}
catch (...) {
ControlMessageBox("Error during cleanup");
}
}
return ControlHardwareInterfaceLoadedSuccessfully;
}
int main() {
cout << "Bare function API, using exceptions" << endl;
try {
CLA_Create(/*InitializeAfx*/ true, /*InitializeAfxSocket*/ true);
}
catch (...) {
AddErrorMessage("Initialization failed");
return 1; // Initialization failed
}
try {
if (!LoadControlHardwareInterface()) {
AddErrorMessage("Error loading hardware configuration file 2");
CLA_AddDeviceSequencer(0, "OpticsFoundrySequencerV1", "192.168.1.90", 7, true, 0, 100000000, 2000000, false, true, true, true);
CLA_AddDeviceAnalogOut16bit(0, 24, 4, true, -10, 10);
CLA_AddDeviceAnalogOut16bit(0, 552, 4, true, -10, 10);
CLA_AddDeviceDigitalOut(0, 1, 16);
CLA_AddDeviceDigitalOut(0, 2, 16);
CLA_AddDeviceAD9854(0, 232, 2, 300000000, 1, 1);
CLA_AddDeviceAD9858(0, 652, 1200000000, 1);
CLA.AddDeviceAD9959(0, 21, 1000000000, 1);
CLA_Initialize();
}
}
catch (...) {
ControlMessageBox("Error loading hardware configuration file 3");
try {
CLA_Cleanup();
}
catch (...) {
ControlMessageBox("Error during cleanup");
}
CLA_Cleanup();
return -1;
}
CLA_SwitchDebugMode(true, "DebugSequencer");
try { CLA_IsReady(); }
catch (...) {
AddErrorMessage("Not all sequencers connected");
CLA_Cleanup();
return -1;
}
//test
uint8_t* buffer = nullptr;
for (int i = 0; i < 10; i++) {
cout << "Iteration " << i << ": ";
try {
Time starttime = Clock::now();
CLA_StartAssemblingSequence();
//start data acquisition. This is an example for a command for which we didn't yet provide a convenience function in the DLL.
//In this somewhat convoluted manner one can achieve anything without API interface changes
/*
uint8_t ChannelNumber = 0;
uint32_t NumberOfDataPoints = 1000;
double DelayBetweenDataPoints_in_ms_in_ms = 0.02;
CLA_SetValueSerialDevice(0, 0, 0, (uint8_t*)&ChannelNumber, 8);
CLA_SetValueSerialDevice(0, 0, 1, (uint8_t*)&NumberOfDataPoints, 32);
CLA_SetValueSerialDevice(0, 0, 2, (uint8_t*)&DelayBetweenDataPoints_in_ms_in_ms, 64);
CLA_SetValueSerialDevice(0, 0, 3, (uint8_t*)&ChannelNumber, 8); //starts the acquisition
*/
//this is the same command using a convenience function
CLA_SequencerStartAnalogInAcquisition(0, 0, 1000, 0.02);
for (int j = 1; j < 100; j++) {
CLA_SetVoltage(0, 24, 10.0 * j / 100.0);
uint16_t data = 0xffff;
CLA_SetValue(0, 1, 0, (uint8_t*)&data, 16);
CLA_Wait_ms(0.1);
data = 0;
CLA_SetValue(0, 1, 0, (uint8_t*)&data, 16);
CLA_Wait_ms(0.1);
double Frequency = 1000.0 * j / 100.0;
CLA_SetValue(0, 232, 0, (uint8_t*)&Frequency, 64);
}
CLA_Wait_ms(10);
CLA_ExecuteSequence();
bool running = false;
unsigned long long DataPointsWritten = 0;
CLA_GetSequenceExecutionStatus(running, DataPointsWritten);
unsigned long buffer_length = 0;
unsigned long EndTimeOfCycle = 0;
CLA_WaitTillEndOfSequenceThenGetInputData(buffer, buffer_length, EndTimeOfCycle, 10);
Duration duration = Clock::now() - starttime;
cout << "Duration: " << milliSeconds(duration) << " ms Buffer length : " << buffer_length << endl;
}
catch (const CLA_Exception& e) {
ControlMessageBox(e.what());
}
catch (...) {
AddErrorMessage("Error during sequence execution");
}
}
try {
CLA_Cleanup();
}
catch (...) {
AddErrorMessage("Error during cleanup");
}
return 0;
}
#endif //API_CLASS
#else //THROW_EXCEPTIONS
#ifdef API_CLASS
ControlLight_API CLA;
bool LoadControlHardwareInterface() {
bool ControlHardwareInterfaceLoadedSuccessfully = false;
try {
bool success = CLA.LoadFromJSONFile(ConfigFileName);
CLA.Initialize();
if (CLA.IsReady()) {
if (!success) {
ControlMessageBox("Warning: Loading of hardware configuration file worked only partially.");
}
ControlHardwareInterfaceLoadedSuccessfully = true;
//AddErrorMessage("Hardware configuration file loaded");
}
else {
if (success) {
AddErrorMessage("Warning: Hardware configuration file did not contain a sequencer with ID=0.");
}
}
}
catch (...) {
AddErrorMessage("Error loading hardware configuration file 1");
}
if (!ControlHardwareInterfaceLoadedSuccessfully) {
CLA.Cleanup();
CLA.Create(/*InitializeAfx*/ false, /*InitializeAfxSocket*/ false);
}
return ControlHardwareInterfaceLoadedSuccessfully;
}
int main() {
cout << "Class wrapped API, using bool error return value" << endl;
if (!CLA.IsCreated()) {
ControlMessageBox("Error while initializing CLA class");
return 1; // Initialization failed
}
if (!LoadControlHardwareInterface()) {
AddErrorMessage("Error loading hardware configuration file 2");
CLA.AddDeviceSequencer(0, "OpticsFoundrySequencerV1", "192.168.1.90", 7, true, 0, 100000000, 2000000, false, true, true, true);
CLA.AddDeviceAnalogOut16bit(0, 24, 4, true, -10, 10);
CLA.AddDeviceAnalogOut16bit(0, 552, 4, true, -10, 10);
CLA.AddDeviceDigitalOut(0, 1, 16);
CLA.AddDeviceDigitalOut(0, 2, 16);
CLA.AddDeviceAD9854(0, 232, 2, 300000000, 1, 1);
CLA.AddDeviceAD9858(0, 652, 1200000000, 1);
CLA.AddDeviceAD9959(0, 21, 1000000000, 1);
CLA.Initialize();
}
CLA.SwitchDebugMode(true, "DebugSequencer");
if (!CLA.IsReady()) {
AddErrorMessage("Not all sequencers connected");
CLA.Cleanup();
return -1;
}
//test
uint8_t* buffer = nullptr;
for (int i = 0; i < 10; i++) {
Time starttime = Clock::now();
cout << "Iteration " << i << ": ";
CLA.StartAssemblingSequence();
//start data acquisition. This is an example for a command for which we didn't yet provide a convenience function in the DLL.
//In this somewhat convoluted manner one can achieve anything without API interface changes
/*
uint8_t ChannelNumber = 0;
uint32_t NumberOfDataPoints = 1000;
double DelayBetweenDataPoints_in_ms_in_ms = 0.02;
CLA.SetValueSerialDevice(0, 0, 0, (uint8_t*)&ChannelNumber, 8);
CLA.SetValueSerialDevice(0, 0, 1, (uint8_t*)&NumberOfDataPoints, 32);
CLA.SetValueSerialDevice(0, 0, 2, (uint8_t*)&DelayBetweenDataPoints_in_ms_in_ms, 64);
CLA.SetValueSerialDevice(0, 0, 3, (uint8_t*)&ChannelNumber, 8); //starts the acquisition
*/
//this is the same command using a convenience function
CLA.SequencerStartAnalogInAcquisition(0, 0, 1000, 0.02);
for (int j = 1; j < 100; j++) {
CLA.SetVoltage(0, 24, 10.0 * j / 100.0);
uint16_t data = 0xffff;
CLA.SetValue(0, 1, 0, (uint8_t*)&data, 16);
CLA.Wait_ms(0.1);
data = 0;
CLA.SetValue(0, 1, 0, (uint8_t*)&data, 16);
CLA.Wait_ms(0.1);
double Frequency = 1000.0 * j / 100.0;
CLA.SetValue(0, 232, 0, (uint8_t*)&Frequency, 64);
}
CLA.Wait_ms(10);
CLA.ExecuteSequence();
bool running = false;
unsigned long long DataPointsWritten = 0;
CLA.GetSequenceExecutionStatus(running, DataPointsWritten);
unsigned long buffer_length = 0;
unsigned long EndTimeOfCycle = 0;
CLA.WaitTillEndOfSequenceThenGetInputData(buffer, buffer_length, EndTimeOfCycle, 10);
Duration duration = Clock::now() - starttime;
cout << "Duration: " << milliSeconds(duration) << " ms Buffer length : " << buffer_length << endl;
}
//CLA.Cleanup();//this happens in CLA desctuctor
return 0;
}
#else //API_CLASS
bool LoadControlHardwareInterface() {
bool ControlHardwareInterfaceLoadedSuccessfully = false;
try {
bool success = CLA_LoadFromJSONFile(ConfigFileName);
CLA_Initialize();
if (CLA_IsReady()) {
if (!success) {
ControlMessageBox("Warning: Loading of hardware configuration file worked only partially.");
}
ControlHardwareInterfaceLoadedSuccessfully = true;
//AddErrorMessage("Hardware configuration file loaded");
}
else {
if (success) {
AddErrorMessage("Warning: Hardware configuration file did not contain a sequencer with ID=0.");
}
}
}
catch (...) {
AddErrorMessage("Error loading hardware configuration file 1");
}
if (!ControlHardwareInterfaceLoadedSuccessfully) {
CLA_Cleanup();
CLA_Create(/*InitializeAfx*/ false, /*InitializeAfxSocket*/ false);
}
return ControlHardwareInterfaceLoadedSuccessfully;
}
void RampVoltage(unsigned int Sequencer, unsigned int Address, double StartVoltage, double TargetVoltage, double Duration_in_ms, double StepSize_in_ms) {
unsigned long NumberOfSteps = (unsigned long)(Duration_in_ms / StepSize_in_ms);
double StepSize = (TargetVoltage - StartVoltage) / (double)NumberOfSteps;
double Voltage = StartVoltage;
for (unsigned long i = 0; i < NumberOfSteps; i++) {
CLA_SetVoltage(Sequencer, Address, Voltage);
CLA_Wait_ms(StepSize_in_ms);
Voltage += StepSize;
}
CLA_SetVoltage(Sequencer, Address, TargetVoltage);
}
bool InitializeSystem() {
cout << "Bare function API, using bool error return value" << endl;
bool DemoSmartSequencer = false;
if (!CLA_Create(/*InitializeAfx*/ true, /*InitializeAfxSocket*/ true)) {
return false; // Initialization failed
}
if (!LoadControlHardwareInterface()) {
AddErrorMessage("Error loading hardware configuration file 2");
CLA_AddDeviceSequencer(0, "OpticsFoundrySequencerV1", "192.168.1.90", 7, true, 0, 100000000, 2000000, false, true, true, true);
CLA_AddDeviceAnalogOut16bit(0, 24, 4, true, -10, 10);
CLA_AddDeviceAnalogOut16bit(0, 552, 4, true, -10, 10);
CLA_AddDeviceDigitalOut(0, 1, 16);
CLA_AddDeviceDigitalOut(0, 2, 16);
CLA_AddDeviceAD9854(0, 232, 2, 300000000, 1, 1);
CLA_AddDeviceAD9858(0, 652, 1200000000, 1);
CLA_AddDeviceAD9959(0, 21, 1000000000, 1, false);
CLA_Initialize();
}
//CLA_UseEdgeTriggeredLatches(0, true); //ToDo: check that edge triggered latches work
//CLA_SwitchDebugMode(true, "DebugSequencer"); //If on, FPGA sends debug info over USB COM port, which slows it down
if (!CLA_IsReady()) {
AddErrorMessage("Not all sequencers connected");
CLA_Cleanup();
return false;
}
return true;
}
typedef enum
{
E_TestAnalogInput,
E_TestDigitalInput,
E_TestTimeTagger,
E_TestNothing
} E_TestInputType;
constexpr E_TestInputType InputTestType = E_TestAnalogInput;
void DemoSequence(unsigned long CycleNumber) {
//instert the addresses of your IO cards here
constexpr uint8_t SequencerNr = 0;
constexpr uint8_t DigOut_0_addr = 1;
constexpr uint8_t DigOut_1_addr = 2;
constexpr uint8_t AD9959_0_addr = 3;
constexpr uint8_t AD9959_1_addr = 4;
constexpr uint8_t AnaOut_0_addr = 5;
//select which card you want to test
constexpr uint8_t DigOutAddr = DigOut_0_addr;
constexpr uint8_t AnaOutAddr = AnaOut_0_addr;
constexpr uint8_t AD9959Addr = AD9959_0_addr;
CLA_StartAssemblingSequence(); //starts sequence and stores timetag. If DemoSequence is called from DemoFPGASequencerCyclicSequencing, the sequence waits after that timetag till the clock cycle counter in the FPGA reaches the target
CLA_SequencerWriteSystemTimeToInputMemory(SequencerNr); //a second time tag. When cycling sequences, this allows to determine the time the FPGA waited for a trigger. This time should always be reasonably large (a few 10ms at least) to accomodate timing fluctuations of the PC and the ethernet connection.
CLA_SequencerWriteInputMemory(SequencerNr, CycleNumber); //write current cycle number to the input memory. This is used to verify if data of the correct cycle was retrieved.
CLA_SequencerWriteInputMemory(SequencerNr, 6); //a narker, just to see we can write to the input memory. Can e.g. be used to clearly, human readably, mark different sections of the input memory data stream. This is mostly good for debugging.
CLA_SequencerWriteInputMemory(SequencerNr, 7); //a narker, just to see we can write to the input memory
CLA_SequencerSwitchDebugLED(SequencerNr, 1);
CLA_SequencerAddMarker(SequencerNr, 1);//for debug: displays marker (here "1") on ZYNQ USB port output (use Termite or similar to see it)
//CLA_SetDigitalOutput(SequencerNr, /*Addr*/ DigOutAddr, /* BitNr */ 0, true);
CLA_Wait_ms(1);
//Thesse loops allow you to quickly check if a digital output board works. Output number N should blink N+1 times. Outputs of unaddressed cards should not change.
for (int BitNr = 0; BitNr < 16; BitNr++) {
for (int n = 0; n < BitNr + 1; n++) {
CLA_SetDigitalOutput(SequencerNr, /*Addr*/ DigOutAddr, BitNr, true);
//CLA_SetSequencerDigitalOut(SequencerNr, 0);
//CLA_SwitchSequencerBuzzer(SequencerNr, false);
CLA_SequencerSwitchDebugLED(SequencerNr, 0);
CLA_Wait_ms(0.1);
CLA_SetDigitalOutput(SequencerNr, /*Addr*/ DigOutAddr, BitNr, false);
//CLA_SetSequencerDigitalOut(SequencerNr, 128);
//CLA_SwitchSequencerBuzzer(SequencerNr, true);
CLA_SequencerSwitchDebugLED(SequencerNr, 1);
CLA_Wait_ms(0.1);
}
}
CLA_SetSequencerDigitalOut(SequencerNr, 0);
//Test input board:
//for (uint8_t n = 0; n<12; n++) {
// CLA_SelectRackSlot(SequencerNr, /*RackNr*/ 0, n);
// CLA_Wait_ms(100);
//}
//At each moment only one rack slot is allowed to act as input and send data to the FPGA.
//This is achieved by a rack slot arbiter on the backplane.
//This tests the reliability of the arbiter by blinking the rack slot selection LED, available on e.g. the serial IO board.
for (int j = 1; j < 5; j++) {
CLA_SelectRackSlot(SequencerNr, /*RackNr*/ 0, 5);
CLA_Wait_ms(50);
uint8_t r = 16*(rand()/RAND_MAX);
if (r == 5) r = 4;
CLA_SelectRackSlot(SequencerNr, /*RackNr*/ 0, r);
CLA_Wait_ms(50);
}
CLA_SelectRackSlot(SequencerNr, /*RackNr*/ 0, 5);
if (InputTestType == E_TestAnalogInput) {
//Test analog in with convenience function
//@param analog_in_type Analog in board type. 0: AQuRA MCP3208 analog in board; 1: MCP3208 12-bit ADC on SerialPortBoard; 2: ADS1256 24-bit ADC
CLA_SequencerStartAnalogInAcquisition(SequencerNr, /*AnalogInType*/ 2, /*SPI_CS*/ 0, /*AnalogInChannelNr*/ 0, /*NumberOfDataPoints*/ 100, /*SamplingPeriod_in_ms*/ 1);
CLA_Wait_ms(100);
}
//Test analogIn, pedestrian way
//start data acquisition. This is an example for a command for which we didn't yet provide a convenience function in the DLL.
//In this somewhat convoluted manner one can achieve anything without API interface changes
/*
uint8_t ChannelNumber = 0;
uint32_t NumberOfDataPoints = 1000;
double DelayBetweenDataPoints_in_ms_in_ms = 0.02;
CLA_SetValueSerialDevice(0, 0, 0, (uint8_t*)&AnalogInType, 8);
CLA_SetValueSerialDevice(0, 0, 1, (uint8_t*)&SPI_CS, 8);
CLA_SetValueSerialDevice(0, 0, 2, (uint8_t*)&ChannelNumber, 8);
CLA_SetValueSerialDevice(0, 0, 3, (uint8_t*)&NumberOfDataPoints, 32);
CLA_SetValueSerialDevice(0, 0, 4, (uint8_t*)&DelayBetweenDataPoints_in_ms_in_ms, 64);
CLA_SetValueSerialDevice(0, 0, 5, (uint8_t*)&ChannelNumber, 8); //starts the acquisition
*/
if (InputTestType == E_TestDigitalInput) {
//Test repeated digital in. Connect a time varying digital signal to the digital input board, available e.g. on the serial IO board.
//The digital port is sampled regularly and the result + time stamp stored in the input memory
//input_buf_mem_data[7:0] <= core_dig_in_sync;
//input_buf_mem_data[28:8] <= INPUT_REPEAT_nr;
//input_buf_mem_data[31:29] <= 3'b010; (magic number to be more sure that this input memory entry came from digital input)
/// @param RepeatedOutInCommand the command to execute for each data point. 0: stop; 1: repeated SPI transfer; 2: repeated digital in; 3: digital in event tagger
CLA_SequencerRepeatedOutIn(SequencerNr, /*NumberOfDataPoints*/ 200, /*SamplingPeriod_in_ms*/ 1, /* RepeatedOutInCommand*/ 2);
CLA_Wait_ms(100);
}
if (InputTestType == E_TestTimeTagger) {
//Test event time tagger. Connect a time varying digital signal to the digital input board, avaiable e.g. on the serial IO board.
/// @param RepeatedOutInCommand the command to execute for each data point. 0: stop; 1: repeated SPI transfer; 2: repeated digital in; 3: digital in event tagger
/// for 3: if dig in changes, safes dig in on input memory bit 0:7, bit 8: counter overflow, bit 9: 4-entry fifo overflow, bit 10:31: clock cycle counter; runs till stopped by setting RepeatedOutInCommand to 0 with new SequencerRepeatedOutIn command.
//Output data format (32-bit words):
//bit 0 to 7: 8-bit input port patterm
//bit 8: 1 means timer overflow; this enables one to calculate the timestamp beyond the 22 bit length of the timer counter
//bit 9: 1 means 8-entry fifo overflow, i.e. events have been lost because BRAM wasn't fast enough to store them
//bit 10 to 31: timer, counting 1 up every 10ns, overflowing every 2^22 * 10ns = 41.94304 ms
CLA_SequencerRepeatedOutIn(SequencerNr, /*NumberOfDataPoints*/ 1000, /*SamplingPeriod_in_ms*/ 1, /* RepeatedOutInCommand*/ 3);
CLA_Wait_ms(10);
CLA_SequencerRepeatedOutIn(SequencerNr, /*NumberOfDataPoints*/ 1, /*SamplingPeriod_in_ms*/ 1, /* RepeatedOutInCommand*/ 0);
}
//Test AD9959 DDS
CLA_Reset(SequencerNr, AD9959Addr);
//Usually, an IOUpdate pulse is sent out automatically after each SPI command
//However, to program phases, we first need to send out all commands programming all channels and then finish with one IO update pulse that updates everything
CLA_SetIOUpdateEnabled(SequencerNr, AD9959Addr, false);
CLA_SetFrequencyOfChannel(SequencerNr, AD9959Addr, 0, 0.1);//in MHz
CLA_SetPowerOfChannel(SequencerNr, AD9959Addr, 0, 100); // in %
CLA_SetPhaseOfChannel(SequencerNr, AD9959Addr, 0, 0);
CLA_SetFrequencyOfChannel(SequencerNr, AD9959Addr, 1, 0.1);//in MHz
CLA_SetPowerOfChannel(SequencerNr, AD9959Addr, 1, 100); // in %
CLA_SetPhaseOfChannel(SequencerNr, AD9959Addr, 1, 90);
CLA_SetFrequencyOfChannel(SequencerNr, AD9959Addr, 2, 0.1);//in MHz
CLA_SetPowerOfChannel(SequencerNr, AD9959Addr, 2, 100); // in %
CLA_SetPhaseOfChannel(SequencerNr, AD9959Addr, 2, 180);
CLA_SetFrequencyOfChannel(SequencerNr, AD9959Addr, 3, 0.1);//in MHz
CLA_SetPowerOfChannel(SequencerNr, AD9959Addr, 3, 100); // in %
//We reanable automatic IO Update. The next SPI command will be written and then an IO Update will be sent that activates all newly programmed parameter values
CLA_SetIOUpdateEnabled(SequencerNr, AD9959Addr, true);
CLA_SetPhaseOfChannel(SequencerNr, AD9959Addr, 3, 270);
for (int j = 1; j < 100; j=j+10) {
CLA_SetVoltage(SequencerNr, AnaOutAddr, 10.0 * j / 100.0);
uint16_t data = 0xffff;
CLA_SetValue(SequencerNr, DigOutAddr, 0, (uint8_t*)&data, 16);
CLA_Wait_ms(0.002);
data = 0;
CLA_SetValue(SequencerNr, DigOutAddr, 0, (uint8_t*)&data, 16);
CLA_Wait_ms(0.002);
//double Frequency = 1000.0 * j / 100.0;
CLA_SetFrequencyOfChannel(SequencerNr, AD9959Addr, 1, 10.0 * j/100.0);//in MHz
//CLA_SetValue(SequencerNr, AD9959Addr, 0, (uint8_t*)&Frequency, 64);
//CLA_Wait_ms(10);
}
CLA_SetFrequencyOfChannel(SequencerNr, AD9959Addr, 1, 0.1);//in MHz
CLA_Wait_ms(10);
//A very simple ramp procedure. ToDo: program ramp management system
RampVoltage(SequencerNr, /*Address*/ AnaOutAddr, /*StartVoltage*/ -10, /* TargetVoltage*/ 10, /*Duration_in_ms*/ 100, /*StepSize_in_ms*/ 0.1);
CLA_SequencerSwitchDebugLED(SequencerNr, 0);
CLA_SetDigitalOutput(SequencerNr, /*Addr*/ DigOutAddr, /* BitNr */ 0, false);
CLA_Wait_ms(10);
CLA_SequencerWriteSystemTimeToInputMemory(SequencerNr); //store FPGA counter as a timestamp so that one can easily determine the exact sequence duration
//CLA_SelectRackSlot(SequencerNr, /*RackNr*/ 0, 0);
}
void DemoSequenceShort(unsigned long CycleNumber) {
//A short test sequence for debugging
constexpr uint8_t SequencerNr = 0;
constexpr uint8_t DigOut_0_addr = 1;
constexpr uint8_t DigOut_1_addr = 2;
constexpr uint8_t AD9959_0_addr = 3;
constexpr uint8_t AD9959_1_addr = 4;
constexpr uint8_t AnaOut_0_addr = 5;
constexpr uint8_t DigOutAddr = DigOut_0_addr;
constexpr uint8_t AnaOutAddr = AnaOut_0_addr;
constexpr uint8_t AD9959Addr = AD9959_0_addr;
CLA_StartAssemblingSequence();
CLA_SequencerWriteSystemTimeToInputMemory(SequencerNr);
CLA_SequencerWriteInputMemory(SequencerNr, CycleNumber);
CLA_SequencerWriteInputMemory(SequencerNr, 6); //a narker, just to see we can write to the input memory
CLA_SequencerWriteInputMemory(SequencerNr, 7); //a narker, just to see we can write to the input memory
//Test AD9959 DDS
CLA_Reset(SequencerNr, AD9959Addr);
//Usually, an IOUpdate pulse is sent out automatically after each SPI command
//However, to program phases, we first need to send out all commands programming all channels and then finish with one IO update pulse that updates everything
CLA_SequencerWriteInputMemory(SequencerNr, 5); //a narker, just to see we can write to the input memory
CLA_SetIOUpdateEnabled(SequencerNr, AD9959Addr, false);
CLA_SequencerWriteInputMemory(SequencerNr, 6); //a narker, just to see we can write to the input memory
CLA_SetFrequencyOfChannel(SequencerNr, AD9959Addr, 0, 0.1);//in MHz
CLA_SequencerWriteInputMemory(SequencerNr, 7); //a narker, just to see we can write to the input memory
CLA_SetPowerOfChannel(SequencerNr, AD9959Addr, 0, 100); // in %
CLA_SequencerWriteInputMemory(SequencerNr, 8); //a narker, just to see we can write to the input memory
CLA_SetPhaseOfChannel(SequencerNr, AD9959Addr, 0, 0);
CLA_SequencerWriteInputMemory(SequencerNr, 9); //a narker, just to see we can write to the input memory
CLA_SetFrequencyOfChannel(SequencerNr, AD9959Addr, 1, 0.1);//in MHz
CLA_SetPowerOfChannel(SequencerNr, AD9959Addr, 1, 100); // in %
CLA_SetPhaseOfChannel(SequencerNr, AD9959Addr, 1, 90);
CLA_SetFrequencyOfChannel(SequencerNr, AD9959Addr, 2, 0.1);//in MHz
CLA_SetPowerOfChannel(SequencerNr, AD9959Addr, 2, 100); // in %
CLA_SetPhaseOfChannel(SequencerNr, AD9959Addr, 2, 180);
CLA_SetFrequencyOfChannel(SequencerNr, AD9959Addr, 3, 0.1);//in MHz
CLA_SetPowerOfChannel(SequencerNr, AD9959Addr, 3, 100); // in %
//We reanable automatic IO Update. The next SPI command will be written and then an IO Update will be sent that activates all newly programmed parameter values
CLA_SetIOUpdateEnabled(SequencerNr, AD9959Addr, true);
CLA_SetPhaseOfChannel(SequencerNr, AD9959Addr, 3, 270);
CLA_Wait_ms(10);
CLA_SequencerWriteSystemTimeToInputMemory(SequencerNr);
//CLA_SelectRackSlot(SequencerNr, /*RackNr*/ 0, 0);
}
void SaveInputDataToFile(const std::string& filename,
const uint32_t* buffer,
unsigned long buffer_length)
{
FILE* file = std::fopen(filename.c_str(), "w");
if (!file) {
cerr << "Couldn't open file for writing" << endl;
return;
}
for (unsigned long i = 0; i < buffer_length; ++i) {
if (InputTestType == E_TestDigitalInput) {
//To test repeated digital input reading
uint8_t low_byte = buffer[i];
std::string bin = std::bitset<8>(low_byte).to_string();
std::fprintf(file, "%lu %u %s\n", i, buffer[i], bin.c_str());
}
if (InputTestType == E_TestTimeTagger) {
//To test digital input as event time tagger
uint8_t low_byte = buffer[i];
uint8_t second_byte = buffer[i] >> 8;
std::string bin = std::bitset<8>(low_byte).to_string();
std::string bin2 = std::bitset<8>(second_byte).to_string();
std::fprintf(file, "%lu %lu %s %s\n", i, buffer[i] >> 10, bin2.c_str(), bin.c_str());
}
if (InputTestType == E_TestAnalogInput) {
//To test analog input
uint8_t help = buffer[i] & 0xff;
std::string bin0 = std::bitset<8>(help).to_string();
help = (buffer[i] >> 8) & 0xff;
std::string bin1 = std::bitset<8>(help).to_string();
help = (buffer[i] >> 16) & 0xff;
std::string bin2 = std::bitset<8>(help).to_string();
help = (buffer[i] >> 24) & 0xff;
std::string bin3 = std::bitset<8>(help).to_string();
std::fprintf(file, "%s %s %s %s %lu %lu %lu %li \n", bin3.c_str(), bin2.c_str(), bin1.c_str(), bin0.c_str(), i, buffer[i] >> 24, buffer[i] & 0xFFF, (int32_t)(buffer[i] << 8));
}
}
std::fclose(file);
}
void DemoSequenceAnalyseData(unsigned long CycleNumber, uint32_t* buffer, const unsigned long& buffer_length, const unsigned long& EndTimeOfCycle, double PeriodicTriggerPeriod_in_ms) {
static unsigned long long PreviousFPGASystemTime = 0;
static unsigned int NumberOfTimesFailedRun = 0;
static Time starttime = Clock::now();
static Time last_starttime = Clock::now();
bool CycleSuccessful = true;
//FPGA soft trigger SystemTime is in first 8 bytes thanks to CLA automatically putting WriteSystemTimeToInputMemory before cyclic trigger
//Bytes 8 to 15 contain the FPGA SystemTime directly after the cyclic trigger, thanks to the
//CA.Command("WriteSystemTimeToInputMemory();"); command in the sequence.
//We use it to check if the time between two triggers is correct, i.e. if the total cycle duration is correct.
unsigned long long FPGASystemTimeStart = ((unsigned long long*)buffer)[0]; // in units of the clock period, i.e. usually 10ns
unsigned long FPGASystemTimeLow = buffer[2];
unsigned long FPGASystemTimeHigh = buffer[3];
unsigned long long FPGASystemTime = ((unsigned long long*)buffer)[1]; // in units of the clock period, i.e. usually 10ns
//unsigned long long FPGASystemTimeAtSequenceEnd = ((unsigned long long*)Buffer)[BufferLength/2-2]; // in units of the clock period, i.e. usually 10ns
unsigned long CycleNrFromBuffer = buffer[4];
double WaitForTriggerTime = 0.00001 * (FPGASystemTime - FPGASystemTimeStart);
//We check if the MOT loading time was ok.
//For that, PeriodicTriggerPeriod_in_ms must contain the duration of the previous sequence plus the desired MOT loading time.
//The only variable part of the sequence is the blue MOT duration.
//We measure this blue MOT's duration by determining the time between the start of the last sequence and the start of this sequence.
//The blue MOT duration is ElapsedFPGASystemTime - the duration of the last sequence.
//We don't calculate the blue MOT duration explicitly, but check if ElapsedFPGASystemTime is within the expected range.
unsigned long long ElapsedFPGASystemTime = FPGASystemTime - PreviousFPGASystemTime;
unsigned long long SoftToHardTriggerDelay = FPGASystemTime - FPGASystemTimeStart;
double CyclePeriodError = ElapsedFPGASystemTime - (PeriodicTriggerPeriod_in_ms * 100000);
std::string ErrorMessages = "";
if (ElapsedFPGASystemTime > PeriodicTriggerPeriod_in_ms * 100000 + 10) {
ErrorMessages += " Overtime by " + std::format("{}", CyclePeriodError/100000) + " ms.";
CycleSuccessful = false;
}
else if (ElapsedFPGASystemTime < PeriodicTriggerPeriod_in_ms * 100000 - 10) {
ErrorMessages += " Undertime by " + std::format("{}", CyclePeriodError / 100000) + " ms.";
CycleSuccessful = false;
}
if (CycleNumber != CycleNrFromBuffer) {
ErrorMessages += " Cycle number slip (expected " + std::format("{}", CycleNumber) + ", got " + std::format("{}", CycleNrFromBuffer) + ").";
CycleSuccessful = false;
}
PreviousFPGASystemTime = FPGASystemTime;
last_starttime = starttime;
starttime = Clock::now();
Duration duration = last_starttime - starttime;
std::string out_buf = std::format("{:4} {:4} {:4} {:4.0f} {:4.0f} {:4.0f} {:10} {:03X} {:08X} f{:03} rc{} {}",
CycleNrFromBuffer,
buffer_length,
SoftToHardTriggerDelay,
CyclePeriodError,
milliSeconds(duration),
WaitForTriggerTime,
ElapsedFPGASystemTime,
FPGASystemTimeHigh,
FPGASystemTimeLow,
NumberOfTimesFailedRun,
(CycleSuccessful) ? 1 : 0,
EndTimeOfCycle);
std::string status = out_buf + ErrorMessages;
cout << status << endl;
if (buffer != NULL) {
//process input data
std::string filename = std::format("C:\\data\\input{:04}.dat", CycleNumber);
SaveInputDataToFile(filename, buffer, buffer_length);
//freeing buffer is done in CAL and shouldn't be done here.
}
else {
cerr << "no input data received" << endl;
CycleSuccessful = false;
}
if (!CycleSuccessful) NumberOfTimesFailedRun++;
}
void DemoFPGASequencerSingleRun() {
if (!InitializeSystem()) {
return;
}
uint8_t* buffer = nullptr;
constexpr unsigned long NrCycles = 10;
for (unsigned long CycleNr = 0; CycleNr < NrCycles; CycleNr++) {
Time starttime = Clock::now();
cout << "Iteration " << CycleNr << ": ";
DemoSequence(CycleNr);
CLA_ExecuteSequence();
bool running = false;
unsigned long long DataPointsWritten = 0;
CLA_GetSequenceExecutionStatus(running, DataPointsWritten);
unsigned long buffer_length = 0;
unsigned long EndTimeOfCycle = 0;
CLA_WaitTillEndOfSequenceThenGetInputData(buffer, buffer_length, EndTimeOfCycle, 10);
DemoSequenceAnalyseData(CycleNr, (uint32_t*)buffer, buffer_length/4, EndTimeOfCycle, 0);
//Duration duration = Clock::now() - starttime;
//cout << "Duration: " << milliSeconds(duration) << " ms Buffer length : " << buffer_length << endl;
}
CLA_Cleanup();
}
void DemoFPGASequencerCyclicSequencing() {
if (!InitializeSystem()) {
return;
}
uint8_t* buffer = nullptr;
//assemble sequence
DemoSequence(0);
double SequenceDuration_in_ms;
CLA_GetTime_ms(SequenceDuration_in_ms);
double WaitTimeAfterSequence_in_ms = 300;
double PeriodicTriggerPeriod_in_ms = (SequenceDuration_in_ms + WaitTimeAfterSequence_in_ms);
double PeriodicTriggerAllowedWaitTime_in_ms = PeriodicTriggerPeriod_in_ms + 2000;
cout << "Cycling with " << PeriodicTriggerPeriod_in_ms << " ms period of which " << SequenceDuration_in_ms << " ms sequence duration." << endl;
//Tell sequencer that we'll use cyclic sequencing. This updates trigger settings.
CLA_SetPeriodicTrigger_ms(PeriodicTriggerPeriod_in_ms, PeriodicTriggerAllowedWaitTime_in_ms);
//to speed up TCP/IP transmission of data from PC to sequencer, transmit only changes of sequence, if possible.
CLA_TransmitOnlyDifferenceBetweenCommandSequenceIfPossible(true);
cout << "Press any key to stop cyclic sequencing." << endl;
unsigned long CycleNr = 0;
while (!ConsoleKeyPressed()) {
Time starttime = Clock::now();
cout << "Iteration " << CycleNr << ": ";
//We create sequence from scratch to update trigger settings and cycle number dependent sequence entries.
DemoSequence(CycleNr);
//CLA_ExecuteSequence("c:\\data\\DebugDemoFPGASequencerCyclicSequence.txt"); //Use this version to create debug file
CLA_ExecuteSequence(); //use this version to run without creating debug file
bool running = false;
unsigned long long DataPointsWritten = 0;
CLA_GetSequenceExecutionStatus(running, DataPointsWritten);