-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControlAPI.cpp
More file actions
1610 lines (1420 loc) · 59.9 KB
/
ControlAPI.cpp
File metadata and controls
1610 lines (1420 loc) · 59.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
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
// ControlAPI.cpp: implementation of the API.
//
//////////////////////////////////////////////////////////////////////
#include "ControlAPI.h"
#include <QMessageBox>
#include <QDebug>
#include <QString>
#include <QDateTime>
//#include <QCoreApplication>
#define EnableDebug
#ifdef EnableDebug
#define EnableTimingDebug
#endif
#ifndef EnableDebug
//#define SlowDLLAccessToImproveStability
#endif
#ifdef SlowDLLAccessToImproveStability
#include <QThread>
#endif
#ifdef EnableDebug
#define WriteDebug(msg) \
if (DebugTextStream) { \
(*DebugTextStream) << msg; \
DebugTextStream->flush(); \
}
#else
#ifdef SlowDLLAccessToImproveStability
//QThread::usleep(10);//usleep(50); too slow -> use nsecsElapsed, despite being busy wait
#define WriteDebug(msg) \
{ \
QElapsedTimer t; \
t.start();\
while (t.nsecsElapsed() < 5000); \
}
#else
#define WriteDebug(msg)
#endif
#endif
#ifdef EnableTimingDebug
QTime LastTimeStamp;
void CControlAPI::WriteTimeStamp() {
QTime Now = QTime::currentTime();
int ellapsedTime = LastTimeStamp.msecsTo(Now);
LastTimeStamp= Now;
QString buf = QString::number(ellapsedTime) ;
WriteDebug(buf);
}
#define MacroWriteTimestamp WriteTimeStamp();
#define MacroWriteTimestampDot WriteDebug(".");
#else
void CControlAPI::WriteTimeStamp() {
}
#define MacroWriteTimestamp
#define MacroWriteTimestampDot
#endif
extern void Sleep_ms_and_call_CA_OnIdle(int delay_in_milli_seconds);
void ErrorNotYetImplemented() {
QMessageBox msgBox;
msgBox.setText("ControlAPI.cpp: function not yet implemented");
msgBox.exec();
}
CControlAPI::CControlAPI()
{
ConnectedToLowLevelSoftware = false;
telnet = NULL;
DebugFileDirectory="";
DebugFile= nullptr;
DebugTextStream = nullptr;
#ifdef USE_CA_DLL
Set_CA_DLL_CallsToNull();
#endif
}
bool CControlAPI::isConnected(bool no_error_message) const {
#ifdef USE_CA_DLL
return true;
#else
if (!telnet) return false;
else return telnet->isConnected(no_error_message);
#endif
}
unsigned int CControlAPI::GetNumberReconnects() const {
#ifdef USE_CA_DLL
return 0;
#else
if (!telnet) return 0;
else return telnet->NumberReconnects;
#endif
}
bool CControlAPI::UsingDLL() const {
#ifdef USE_CA_DLL
return true;
#else
return false;
#endif
}
#ifdef USE_CA_DLL
void CControlAPI::Set_CA_DLL_CallsToNull() {
CA_DLL_Handle = NULL;
CA_DLL_GetInstance = NULL;
CA_DLL_Create = NULL;
CA_DLL_Configure = NULL;
CA_DLL_Command = NULL;
CA_DLL_DidCommandErrorOccur = NULL;
CA_DLL_GetLastError = NULL;
CA_DLL_StoreSequenceInMemory = NULL;
CA_DLL_SwitchToDirectOutputMode = NULL;
CA_DLL_OnIdle = NULL;
CA_DLL_SwitchDebugMode = NULL;
CA_DLL_Trigger = NULL;
CA_DLL_StartSequence = NULL;
CA_DLL_IsSequenceRunning = NULL;
CA_DLL_GetLastCommandLineNumber = NULL;
CA_DLL_WaitTillSequenceEnds = NULL;
CA_DLL_ResetFPGA = NULL;
CA_DLL_ConnectToSequencer = NULL;
CA_DLL_CheckIfSequencerReady = NULL;
CA_DLL_ProgramSequence = NULL;
CA_DLL_ProgramInterlockSequence = NULL;
CA_DLL_ReplaceCommand = NULL;
CA_DLL_ReplaceCommandForNextCycle = NULL;
CA_DLL_ReplaceCommandsForNextCycle = NULL;
CA_DLL_ResetCommandList = NULL;
CA_DLL_AssembleSequenceListFromMemory = NULL;
CA_DLL_StartCycling = NULL;
CA_DLL_StopCycling = NULL;
CA_DLL_IsCycling = NULL;
CA_DLL_DataAvailable = NULL;
CA_DLL_GetNextCycleStartTimeAndNumber = NULL;
CA_DLL_ResetCycleNumber = NULL;
CA_DLL_InterruptSequence = NULL;
CA_DLL_WriteReadSPI = NULL;
CA_DLL_WaitTillEndOfSequenceThenGetInputData = NULL;
CA_DLL_GetCycleData = NULL;
CA_DLL_ClearAnalogInputQueue = NULL;
CA_DLL_HasInterlockTriggered = NULL;
CA_DLL_ResetInterlock = NULL;
CA_DLL_SetExternalTrigger = NULL;
CA_DLL_SetPeriodicTrigger = NULL;
CA_DLL_GetPeriodicTriggerError = NULL;
CA_DLL_SetExternalClock = NULL;
CA_DLL_SetupSerialPort = NULL;
CA_DLL_WriteToSerial = NULL;
CA_DLL_WriteToI2C = NULL;
CA_DLL_WriteToSPI = NULL;
CA_DLL_GetSequenceDuration = NULL;
CA_DLL_GetTimeInMs = NULL;
CA_DLL_Ramp = NULL;
CA_DLL_Wait = NULL;
CA_DLL_WaitTillBusBufferEmpty = NULL;
CA_DLL_WaitTillRampsEnd = NULL;
CA_DLL_StopRamps = NULL;
CA_DLL_DoNothing = NULL;
CA_DLL_StartAnalogInAcquisition = NULL;
CA_DLL_StartXADCAnalogInAcquisition = NULL;
CA_DLL_GoBackInTime = NULL;
CA_DLL_GoToTime = NULL;
CA_DLL_ReturnToCurrentTime = NULL;
CA_DLL_FinishLastGoBackInTime = NULL;
CA_DLL_WriteInputMemory = NULL;
CA_DLL_WriteSystemTimeToInputMemory = NULL;
CA_DLL_SwitchDebugLED = NULL;
CA_DLL_IgnoreTCPIP = NULL;
CA_DLL_AddMarker = NULL;
}
#endif
CControlAPI::~CControlAPI()
{
DisconnectFromLowLevelSoftware();
if (DebugTextStream) {
DebugTextStream->flush();
delete DebugTextStream;
DebugTextStream = nullptr;
}
if (DebugFile) {
DebugFile->close();
delete DebugFile;
DebugFile = nullptr;
}
}
void CControlAPI::MessageBox(QString aMessage) {
QMessageBox msgBox;
msgBox.setText(aMessage);
msgBox.exec();
}
#ifdef USE_CA_DLL
bool CControlAPI::ConnectToLowLevelSoftware(QTelnet * atelnet, const char* ParamFileName, const char* IP, const bool Debug, const QString _DebugFileDirectory, unsigned long port, double timeout_in_seconds) {
CA_DLL_Lib = new QLibrary("Control.dll");
if (!CA_DLL_Lib->load()) {
qDebug() << "Failed to load DLL:" << CA_DLL_Lib->errorString();
return -1;
}
/*ChatGPT, load the following functions:
API_EXPORT HControlAPI ControlAPI_GetInstance();
API_EXPORT bool ControlAPI_Configure(bool displayErrors);
API_EXPORT void ControlAPI_Cleanup();
API_EXPORT long ControlAPI_Command(const char* code);
API_EXPORT bool ControlAPI_DidCommandErrorOccur(long* lineNumber, const char** commandWithError);
API_EXPORT const char* ControlAPI_GetLastError();
API_EXPORT void ControlAPI_StoreSequenceInMemory(bool store);
API_EXPORT void ControlAPI_SwitchToDirectOutputMode();
API_EXPORT void ControlAPI_OnIdle();
API_EXPORT bool ControlAPI_StartSequence(bool showDialog);
API_EXPORT bool ControlAPI_IsSequenceRunning();
API_EXPORT long ControlAPI_GetLastCommandLineNumber();
API_EXPORT bool ControlAPI_WaitTillSequenceEnds(double timeout);
API_EXPORT bool ControlAPI_ResetFPGA();
API_EXPORT bool ControlAPI_ConnectToSequencer(const unsigned char* IP, unsigned long port, double timeout);
API_EXPORT bool ControlAPI_CheckIfSequencerReady(double timeout);
API_EXPORT void ControlAPI_ProgramSequence();
API_EXPORT bool ControlAPI_ProgramInterlockSequence();
API_EXPORT bool ControlAPI_ReplaceCommand(unsigned long cycle_number, unsigned int command_line_nr, const char* new_command);
API_EXPORT void ControlAPI_ReplaceCommandForNextCycle(unsigned int command_line_nr, const char* new_command);
API_EXPORT void ControlAPI_ReplaceCommandsForNextCycle();
API_EXPORT void ControlAPI_ResetCommandList();
API_EXPORT bool ControlAPI_AssembleSequenceListFromMemory();
API_EXPORT bool ControlAPI_StartCycling(long idleTime_ms, long softPreTrigger_ms, bool onlyTransmitDiff, bool showDialog);
API_EXPORT void ControlAPI_StopCycling();
API_EXPORT bool ControlAPI_IsCycling();
API_EXPORT bool ControlAPI_DataAvailable();
API_EXPORT bool ControlAPI_GetNextCycleStartTimeAndNumber(long* timeTillNextCycleStart_ms, long* nextCycleNumber);
API_EXPORT bool ControlAPI_ResetCycleNumber();
API_EXPORT bool ControlAPI_InterruptSequence();
API_EXPORT void ControlAPI_WriteReadSPI(unsigned int chip_select, unsigned int num_bits_out, unsigned long long data_high, unsigned long long data_low, unsigned int num_bits_in);
API_EXPORT bool ControlAPI_WaitTillEndOfSequenceThenGetInputData(unsigned char** buffer, unsigned long* buffer_length, unsigned long* endTimeOfCycle, double timeout);
API_EXPORT bool ControlAPI_GetCycleData(unsigned char** buffer, unsigned long* buffer_length, long* cycleNumber, unsigned long* lastCycleEndTime, unsigned long* lastCycleStartPreTriggerTime, bool* cycleError, const char** errorMessages);
API_EXPORT bool ControlAPI_ClearAnalogInputQueue();
API_EXPORT bool ControlAPI_HasInterlockTriggered();
API_EXPORT bool ControlAPI_ResetInterlock();
API_EXPORT void ControlAPI_SetExternalTrigger(bool externalTrigger0, bool externalTrigger1);
API_EXPORT void ControlAPI_SetPeriodicTrigger(double period_ms, double allowedWait_ms);
API_EXPORT bool ControlAPI_GetPeriodicTriggerError();
API_EXPORT void ControlAPI_SetExternalClock(bool externalClock0, bool externalClock1);
API_EXPORT bool ControlAPI_SetupSerialPort(unsigned char port_number, unsigned long baud_rate);
API_EXPORT bool ControlAPI_WriteToSerial(unsigned int port_nr, const char* command, unsigned long length);
API_EXPORT bool ControlAPI_WriteToI2C(unsigned int port_nr, const char* command, unsigned long length);
API_EXPORT bool ControlAPI_WriteToSPI(unsigned int port_nr, const char* command, unsigned long length);
API_EXPORT double ControlAPI_GetSequenceDuration();
API_EXPORT double ControlAPI_GetTimeInMs();
API_EXPORT void ControlAPI_Ramp(const char* output_name, double start_value, double end_value, double ramp_time_ms, double timestep_ms);
API_EXPORT void ControlAPI_Wait(double time_ms, unsigned long ID);
API_EXPORT void ControlAPI_WaitTillBusBufferEmpty(unsigned long ID);
API_EXPORT void ControlAPI_WaitTillRampsEnd(unsigned long ID);
API_EXPORT void ControlAPI_StopRamps();
API_EXPORT void ControlAPI_DoNothing();
API_EXPORT void ControlAPI_StartAnalogInAcquisition(unsigned char sequencer, unsigned char SPI_port, unsigned char SPI_CS, unsigned int channel_number, unsigned int num_datapoints, double delay_ms);
API_EXPORT void ControlAPI_StartXADCAnalogInAcquisition(unsigned int channel_number, unsigned int num_datapoints, double delay_ms);
API_EXPORT void ControlAPI_GoBackInTime(double timeJump_ms, unsigned int ID);
API_EXPORT void ControlAPI_GoToTime(double time_ms, unsigned int ID);
API_EXPORT void ControlAPI_ReturnToCurrentTime(unsigned int ID);
API_EXPORT void ControlAPI_FinishLastGoBackInTime(unsigned int ID);
API_EXPORT void ControlAPI_WriteInputMemory(unsigned long data, bool write_next_address, unsigned long address);
API_EXPORT void ControlAPI_WriteSystemTimeToInputMemory();
API_EXPORT void ControlAPI_SwitchDebugLED(unsigned int onOff);
API_EXPORT void ControlAPI_IgnoreTCPIP(bool onOff);
API_EXPORT void ControlAPI_AddMarker(unsigned char marker);
*/
CA_DLL_GetInstance = (GetInstanceFunc)CA_DLL_Lib->resolve("ControlAPI_GetInstance");
CA_DLL_Create = (CreateFunc)CA_DLL_Lib->resolve("ControlAPI_Create");
CA_DLL_Configure = (ConfigureFunc)CA_DLL_Lib->resolve("ControlAPI_Configure");
CA_DLL_Cleanup = (CleanupFunc)CA_DLL_Lib->resolve("ControlAPI_Cleanup");
CA_DLL_Command = (CommandFunc)CA_DLL_Lib->resolve("ControlAPI_Command");
CA_DLL_DidCommandErrorOccur = (DidErrorFunc)CA_DLL_Lib->resolve("ControlAPI_DidCommandErrorOccur");
CA_DLL_GetLastError = (GetErrorFunc)CA_DLL_Lib->resolve("ControlAPI_GetLastError");
CA_DLL_StoreSequenceInMemory = (StoreSequenceInMemoryFunc)CA_DLL_Lib->resolve("ControlAPI_StoreSequenceInMemory");
CA_DLL_SwitchToDirectOutputMode = (SwitchToDirectOutputModeFunc)CA_DLL_Lib->resolve("ControlAPI_SwitchToDirectOutputMode");
CA_DLL_OnIdle = (OnIdleFunc)CA_DLL_Lib->resolve("ControlAPI_OnIdle");
CA_DLL_SwitchDebugMode = (SwitchDebugModeFunc)CA_DLL_Lib->resolve("ControlAPI_SwitchDebugMode");
CA_DLL_Trigger = (TriggerFunc)CA_DLL_Lib->resolve("ControlAPI_Trigger");
CA_DLL_StartSequence = (StartSequenceFunc)CA_DLL_Lib->resolve("ControlAPI_StartSequence");
CA_DLL_IsSequenceRunning = (IsSequenceRunningFunc)CA_DLL_Lib->resolve("ControlAPI_IsSequenceRunning");
CA_DLL_GetLastCommandLineNumber = (GetLastCommandLineNumberFunc)CA_DLL_Lib->resolve("ControlAPI_GetLastCommandLineNumber");
CA_DLL_WaitTillSequenceEnds = (WaitTillSequenceEndsFunc)CA_DLL_Lib->resolve("ControlAPI_WaitTillSequenceEnds");
CA_DLL_ResetFPGA = (ResetFPGAFunc)CA_DLL_Lib->resolve("ControlAPI_ResetFPGA");
CA_DLL_ConnectToSequencer = (ConnectToSequencerFunc)CA_DLL_Lib->resolve("ControlAPI_ConnectToSequencer");
CA_DLL_CheckIfSequencerReady = (CheckIfSequencerReadyFunc)CA_DLL_Lib->resolve("ControlAPI_CheckIfSequencerReady");
CA_DLL_ProgramSequence = (ProgramSequenceFunc)CA_DLL_Lib->resolve("ControlAPI_ProgramSequence");
CA_DLL_ProgramInterlockSequence = (ProgramInterlockSequenceFunc)CA_DLL_Lib->resolve("ControlAPI_ProgramInterlockSequence");
CA_DLL_ReplaceCommand = (ReplaceCommandFunc)CA_DLL_Lib->resolve("ControlAPI_ReplaceCommand");
CA_DLL_ReplaceCommandForNextCycle = (ReplaceCommandForNextCycleFunc)CA_DLL_Lib->resolve("ControlAPI_ReplaceCommandForNextCycle");
CA_DLL_ReplaceCommandsForNextCycle = (ReplaceCommandsForNextCycleFunc)CA_DLL_Lib->resolve("ControlAPI_ReplaceCommandsForNextCycle");
CA_DLL_ResetCommandList = (ResetCommandListFunc)CA_DLL_Lib->resolve("ControlAPI_ResetCommandList");
CA_DLL_AssembleSequenceListFromMemory = (AssembleSequenceListFromMemoryFunc)CA_DLL_Lib->resolve("ControlAPI_AssembleSequenceListFromMemory");
CA_DLL_StartCycling = (StartCyclingFunc)CA_DLL_Lib->resolve("ControlAPI_StartCycling");
CA_DLL_StopCycling = (StopCyclingFunc)CA_DLL_Lib->resolve("ControlAPI_StopCycling");
CA_DLL_IsCycling = (IsCyclingFunc)CA_DLL_Lib->resolve("ControlAPI_IsCycling");
CA_DLL_DataAvailable = (DataAvailableFunc)CA_DLL_Lib->resolve("ControlAPI_DataAvailable");
CA_DLL_GetNextCycleStartTimeAndNumber = (GetNextCycleStartTimeAndNumberFunc)CA_DLL_Lib->resolve("ControlAPI_GetNextCycleStartTimeAndNumber");
CA_DLL_ResetCycleNumber = (ResetCycleNumberFunc)CA_DLL_Lib->resolve("ControlAPI_ResetCycleNumber");
CA_DLL_InterruptSequence = (InterruptSequenceFunc)CA_DLL_Lib->resolve("ControlAPI_InterruptSequence");
CA_DLL_WriteReadSPI = (WriteReadSPIFunc)CA_DLL_Lib->resolve("ControlAPI_WriteReadSPI");
CA_DLL_WaitTillEndOfSequenceThenGetInputData = (WaitTillEndOfSequenceThenGetInputDataFunc)CA_DLL_Lib->resolve("ControlAPI_WaitTillEndOfSequenceThenGetInputData");
CA_DLL_GetCycleData = (GetCycleDataFunc)CA_DLL_Lib->resolve("ControlAPI_GetCycleData");
CA_DLL_ClearAnalogInputQueue = (ClearAnalogInputQueueFunc)CA_DLL_Lib->resolve("ControlAPI_ClearAnalogInputQueue");
CA_DLL_HasInterlockTriggered = (HasInterlockTriggeredFunc)CA_DLL_Lib->resolve("ControlAPI_HasInterlockTriggered");
CA_DLL_ResetInterlock = (ResetInterlockFunc)CA_DLL_Lib->resolve("ControlAPI_ResetInterlock");
CA_DLL_SetExternalTrigger = (SetExternalTriggerFunc)CA_DLL_Lib->resolve("ControlAPI_SetExternalTrigger");
CA_DLL_SetPeriodicTrigger = (SetPeriodicTriggerFunc)CA_DLL_Lib->resolve("ControlAPI_SetPeriodicTrigger");
CA_DLL_GetPeriodicTriggerError = (GetPeriodicTriggerErrorFunc)CA_DLL_Lib->resolve("ControlAPI_GetPeriodicTriggerError");
CA_DLL_SetExternalClock = (SetExternalClockFunc)CA_DLL_Lib->resolve("ControlAPI_SetExternalClock");
CA_DLL_SetupSerialPort = (SetupSerialPortFunc)CA_DLL_Lib->resolve("ControlAPI_SetupSerialPort");
CA_DLL_WriteToSerial = (WriteToSerialFunc)CA_DLL_Lib->resolve("ControlAPI_WriteToSerial");
CA_DLL_WriteToI2C = (WriteToI2CFunc)CA_DLL_Lib->resolve("ControlAPI_WriteToI2C");
CA_DLL_WriteToSPI = (WriteToSPIFunc)CA_DLL_Lib->resolve("ControlAPI_WriteToSPI");
CA_DLL_GetSequenceDuration = (GetSequenceDurationFunc)CA_DLL_Lib->resolve("ControlAPI_GetSequenceDuration");
CA_DLL_GetTimeInMs = (GetTimeInMsFunc)CA_DLL_Lib->resolve("ControlAPI_GetTimeInMs");
CA_DLL_Ramp = (RampFunc)CA_DLL_Lib->resolve("ControlAPI_Ramp");
CA_DLL_Wait = (WaitFunc)CA_DLL_Lib->resolve("ControlAPI_Wait");
CA_DLL_WaitTillBusBufferEmpty = (WaitTillBusBufferEmptyFunc)CA_DLL_Lib->resolve("ControlAPI_WaitTillBusBufferEmpty");
CA_DLL_WaitTillRampsEnd = (WaitTillRampsEndFunc)CA_DLL_Lib->resolve("ControlAPI_WaitTillRampsEnd");
CA_DLL_StopRamps = (StopRampsFunc)CA_DLL_Lib->resolve("ControlAPI_StopRamps");
CA_DLL_DoNothing = (DoNothingFunc)CA_DLL_Lib->resolve("ControlAPI_DoNothing");
CA_DLL_StartAnalogInAcquisition = (StartAnalogInAcquisitionFunc)CA_DLL_Lib->resolve("ControlAPI_StartAnalogInAcquisition");
CA_DLL_StartXADCAnalogInAcquisition = (StartXADCAnalogInAcquisitionFunc)CA_DLL_Lib->resolve("ControlAPI_StartXADCAnalogInAcquisition");
CA_DLL_GoBackInTime = (GoBackInTimeFunc)CA_DLL_Lib->resolve("ControlAPI_GoBackInTime");
CA_DLL_GoToTime = (GoToTimeFunc)CA_DLL_Lib->resolve("ControlAPI_GoToTime");
CA_DLL_ReturnToCurrentTime = (ReturnToCurrentTimeFunc)CA_DLL_Lib->resolve("ControlAPI_ReturnToCurrentTime");
CA_DLL_FinishLastGoBackInTime = (FinishLastGoBackInTimeFunc)CA_DLL_Lib->resolve("ControlAPI_FinishLastGoBackInTime");
CA_DLL_WriteInputMemory = (WriteInputMemoryFunc)CA_DLL_Lib->resolve("ControlAPI_WriteInputMemory");
CA_DLL_WriteSystemTimeToInputMemory = (WriteSystemTimeToInputMemoryFunc)CA_DLL_Lib->resolve("ControlAPI_WriteSystemTimeToInputMemory");
CA_DLL_SwitchDebugLED = (SwitchDebugLEDFunc)CA_DLL_Lib->resolve("ControlAPI_SwitchDebugLED");
CA_DLL_IgnoreTCPIP = (IgnoreTCPIPFunc)CA_DLL_Lib->resolve("ControlAPI_IgnoreTCPIP");
CA_DLL_AddMarker = (AddMarkerFunc)CA_DLL_Lib->resolve("ControlAPI_AddMarker");
if (
!CA_DLL_GetInstance ||
!CA_DLL_Create ||
!CA_DLL_Configure ||
!CA_DLL_Command ||
!CA_DLL_DidCommandErrorOccur ||
!CA_DLL_GetLastError ||
!CA_DLL_StoreSequenceInMemory ||
!CA_DLL_SwitchToDirectOutputMode ||
!CA_DLL_OnIdle ||
!CA_DLL_SwitchDebugMode ||
!CA_DLL_Trigger ||
!CA_DLL_StartSequence ||
!CA_DLL_IsSequenceRunning ||
!CA_DLL_GetLastCommandLineNumber ||
!CA_DLL_WaitTillSequenceEnds ||
!CA_DLL_ResetFPGA ||
!CA_DLL_ConnectToSequencer ||
!CA_DLL_CheckIfSequencerReady ||
!CA_DLL_ProgramSequence ||
!CA_DLL_ProgramInterlockSequence ||
!CA_DLL_ReplaceCommand ||
!CA_DLL_ReplaceCommandForNextCycle ||
!CA_DLL_ReplaceCommandsForNextCycle ||
!CA_DLL_ResetCommandList ||
!CA_DLL_AssembleSequenceListFromMemory ||
!CA_DLL_StartCycling ||
!CA_DLL_StopCycling ||
!CA_DLL_IsCycling ||
!CA_DLL_DataAvailable ||
!CA_DLL_GetNextCycleStartTimeAndNumber ||
!CA_DLL_ResetCycleNumber ||
!CA_DLL_InterruptSequence ||
!CA_DLL_WriteReadSPI ||
!CA_DLL_WaitTillEndOfSequenceThenGetInputData ||
!CA_DLL_GetCycleData ||
!CA_DLL_ClearAnalogInputQueue ||
!CA_DLL_HasInterlockTriggered ||
!CA_DLL_ResetInterlock ||
!CA_DLL_SetExternalTrigger ||
!CA_DLL_SetPeriodicTrigger ||
!CA_DLL_GetPeriodicTriggerError ||
!CA_DLL_SetExternalClock ||
!CA_DLL_SetupSerialPort ||
!CA_DLL_WriteToSerial ||
!CA_DLL_WriteToI2C ||
!CA_DLL_WriteToSPI ||
!CA_DLL_GetSequenceDuration ||
!CA_DLL_GetTimeInMs ||
!CA_DLL_Ramp ||
!CA_DLL_Wait ||
!CA_DLL_WaitTillBusBufferEmpty ||
!CA_DLL_WaitTillRampsEnd ||
!CA_DLL_StopRamps ||
!CA_DLL_DoNothing ||
!CA_DLL_StartAnalogInAcquisition ||
!CA_DLL_StartXADCAnalogInAcquisition ||
!CA_DLL_GoBackInTime ||
!CA_DLL_GoToTime ||
!CA_DLL_ReturnToCurrentTime ||
!CA_DLL_FinishLastGoBackInTime ||
!CA_DLL_WriteInputMemory ||
!CA_DLL_WriteSystemTimeToInputMemory ||
!CA_DLL_SwitchDebugLED ||
!CA_DLL_IgnoreTCPIP ||
!CA_DLL_AddMarker
) {
qDebug() << "Failed to resolve one or more ControlAPI symbols.";
DisconnectFromLowLevelSoftware();
return -1;
}
DebugFileDirectory = _DebugFileDirectory;
if (Debug && (DebugFileDirectory != "")) {
if (DebugFile) {
DebugFile->close();
delete DebugFile;
DebugFile = nullptr;
}
DebugFile = new QFile(DebugFileDirectory + "\\ControlAPI_Debug.txt");
if (DebugFile->open(QIODevice::WriteOnly)) {
DebugTextStream = new QTextStream(DebugFile);
(*DebugTextStream) << "Start debugging ControlAPI at " << QDateTime::currentDateTime().toString() << "\n";
(*DebugTextStream) << "IP: " << IP << ", Port: " << port << "\n";
(*DebugTextStream) << "Timeout: " << timeout_in_seconds << " seconds\n";
(*DebugTextStream) << "Using DLL: " << (UsingDLL() ? "Yes" : "No") << "\n";
(*DebugTextStream) << "Connected to low-level software.\n";
#ifdef EnableDebug
(*DebugTextStream) << "Finegrained debugging enabled.\n";
#else
(*DebugTextStream) << "Finegrained debugging disabled. Enable it by defining EnableDebug in ControlAPI.cpp\n";
#endif
DebugTextStream->flush();
} else {
DebugFile->close();
delete DebugFile;
DebugFile = nullptr;
MessageBox("Couldn't open file for writing");
}
}
CA_DLL_Create(ParamFileName, true, true, true);
CA_DLL_Handle = CA_DLL_GetInstance();
ConnectedToLowLevelSoftware = true;
#ifdef EnableTimingDebug
LastTimeStamp = QTime::currentTime();
#endif
return true;
}
void CControlAPI::DisconnectFromLowLevelSoftware() {
if (CA_DLL_Lib) {
Set_CA_DLL_CallsToNull();
CA_DLL_Cleanup();
CA_DLL_Cleanup = NULL;
CA_DLL_Lib->unload();
delete CA_DLL_Lib;
CA_DLL_Lib = NULL;
}
ConnectedToLowLevelSoftware = false;
}
void CControlAPI::ConfigureControlAPI(bool DisplayCommandErrors) {
WriteDebug("CCA")
if (CA_DLL_Configure)
CA_DLL_Configure(DisplayCommandErrors);
WriteDebug("x ")
}
QString CControlAPI::GetError() {
if (CA_DLL_GetLastError) {
WriteDebug("GE")
const char* error = CA_DLL_GetLastError();
WriteDebug("x ")
if (error) {
return QString::fromUtf8(error);
}
}
return QString();
}
void CControlAPI::StoreSequenceInMemory(bool DoStoreSequenceInMemory) {
WriteDebug("SS")
if (CA_DLL_StoreSequenceInMemory)
CA_DLL_StoreSequenceInMemory(DoStoreSequenceInMemory);
WriteDebug("x ")
}
bool CControlAPI::ConnectToSequencer(const char* IP, unsigned long port, double timeout_in_seconds) {
if (CA_DLL_ConnectToSequencer) {
WriteDebug("CTS")
bool ret = CA_DLL_ConnectToSequencer(reinterpret_cast<const unsigned char*>(IP), port, timeout_in_seconds);
WriteDebug("x ")
return ret;
}
return false;
}
bool CControlAPI::CheckIfLowLevelSoftwareReady(double /*timeout_in_seconds*/) {
return ConnectedToLowLevelSoftware;
}
bool CControlAPI::CheckIfSequencerReady(double timeout_in_seconds) {
if (CA_DLL_CheckIfSequencerReady) {
WriteDebug("CISR")
bool ret = CA_DLL_CheckIfSequencerReady(timeout_in_seconds);
WriteDebug("x ")
return ret;
}
return false;
}
long CControlAPI::Command(const char* command) {
if (CA_DLL_Command) {
WriteDebug("C")
long ret = CA_DLL_Command(command);
WriteDebug("x ")
return ret;
}
return -1; // Indicate failure if the function is not available
}
bool CControlAPI::DidCommandErrorOccur(long& ErrorLineNr, QString& CodeWithError, double /*timeout_in_seconds*/) {
if (CA_DLL_DidCommandErrorOccur) {
long lineNr = 0;
const char* errStr = nullptr;
WriteDebug("DCEO")
bool res = CA_DLL_DidCommandErrorOccur(&lineNr, &errStr);
WriteDebug("x ")
ErrorLineNr = lineNr;
CodeWithError = errStr ? QString::fromUtf8(errStr) : QString();
return res;
}
return false;
}
long CControlAPI::GetLastCommandLineNumber() {
if (CA_DLL_GetLastCommandLineNumber) {
WriteDebug("GL")
long ret = CA_DLL_GetLastCommandLineNumber();
WriteDebug("x ")
return ret;
}
return -1;
}
void CControlAPI::ProgramSequence() {
WriteDebug("PS")
if (CA_DLL_ProgramSequence)
CA_DLL_ProgramSequence();
WriteDebug("x ")
}
void CControlAPI::SwitchToDirectOutputMode() {
WriteDebug("STD")
if (CA_DLL_SwitchToDirectOutputMode)
CA_DLL_SwitchToDirectOutputMode();
WriteDebug("x ")
}
void CControlAPI::SwitchDebugMode(bool OnOff, bool DebugTimingOnOff) {
if (CA_DLL_SwitchDebugMode) {
WriteDebug("DM")
CA_DLL_SwitchDebugMode(OnOff, DebugTimingOnOff);
WriteDebug("x ")
}
}
void CControlAPI::OnIdle() {
//if the DLL is used without a timer in the DLL kicking the DLL's OnIdle function, we need to do that
//It's a bit cleaner if we do it from Qt, as we then never can have a conflict between code execution started by the DLL timer
//and code execution started by a DLL call.
//If we use ethernet to connect to the API, it is not needed to kick the API's OnIdle function,
//because it is its own program with its own OnIdle calls anyways.
#ifdef USE_CA_DLL
if (CA_DLL_OnIdle) {
WriteDebug("I")
MacroWriteTimestamp
CA_DLL_OnIdle();
MacroWriteTimestampDot
MacroWriteTimestamp
WriteDebug("x")
}
#endif
}
void CControlAPI::Trigger() {
//immediately trigger the transfer of the next sequence to the FPGA
#ifdef USE_CA_DLL
if (CA_DLL_Trigger) {
WriteDebug("T")
MacroWriteTimestamp
CA_DLL_Trigger();
MacroWriteTimestampDot
MacroWriteTimestamp
WriteDebug("x")
}
#endif
}
bool CControlAPI::ProgramInterlockSequence() {
if (CA_DLL_ProgramInterlockSequence) {
WriteDebug("PIS")
bool ret = CA_DLL_ProgramInterlockSequence();
WriteDebug("x ")
return ret;
}
return false;
}
void CControlAPI::ReplaceCommand(unsigned long cycle_number, unsigned int command_line_nr, const char* new_command) {
if (CA_DLL_ReplaceCommand) {
WriteDebug("RC")
CA_DLL_ReplaceCommand(cycle_number, command_line_nr, new_command);
WriteDebug("x ")
}
}
bool CControlAPI::StartSequence(bool ShowRunProgressDialog, double /*timeout_in_seconds*/) {
if (CA_DLL_StartSequence) {
WriteDebug("SS")
bool ret = CA_DLL_StartSequence(ShowRunProgressDialog);
WriteDebug("x ")
return ret;
}
return false;
}
void CControlAPI::ResetCycleNumber() {
WriteDebug("RCN")
if (CA_DLL_ResetCycleNumber)
CA_DLL_ResetCycleNumber();
WriteDebug("x ")
}
bool CControlAPI::StartCycling(long readout_pre_trigger_in_ms, long soft_pre_trigger_in_ms, bool TransmitOnlyDifferenceBetweenCommandSequenceIfPossible, bool DoWindowsEnterCriticalPriorityMode, bool diplay_progress_dialog) {
if (CA_DLL_StartCycling) {
WriteDebug("StartCycling")
bool ret = CA_DLL_StartCycling(readout_pre_trigger_in_ms, soft_pre_trigger_in_ms, TransmitOnlyDifferenceBetweenCommandSequenceIfPossible, DoWindowsEnterCriticalPriorityMode, diplay_progress_dialog);
WriteDebug("x ")
return ret;
}
return false;
}
void CControlAPI::StopCycling() {
WriteDebug("StopCycling")
if (CA_DLL_StopCycling)
CA_DLL_StopCycling();
WriteDebug("x ")
}
bool CControlAPI::IsCycling(double /*timeout_in_seconds*/) {
if (CA_DLL_IsCycling) {
WriteDebug("IC")
bool ret = CA_DLL_IsCycling();
if (ret) {WriteDebug("1x ")}
else {WriteDebug("0x ")}
return ret;
}
return false;
}
bool CControlAPI::DataAvailable(double timeout_in_seconds) {
if (CA_DLL_DataAvailable) {
long WaitedForData_in_ms = 1;
long Timeout_in_ms = timeout_in_seconds * 1000;
WriteDebug("D1")
bool DataAvailable = CA_DLL_DataAvailable();
MacroWriteTimestampDot
MacroWriteTimestamp
WriteDebug("x ")
while ((!DataAvailable) && (WaitedForData_in_ms < Timeout_in_ms)) {
MacroWriteTimestamp
Sleep_ms_and_call_CA_OnIdle(10);
WaitedForData_in_ms += 10;
WriteDebug("D")
MacroWriteTimestamp
MacroWriteTimestampDot
DataAvailable = CA_DLL_DataAvailable();
MacroWriteTimestamp
WriteDebug("x ")
}
WriteDebug(((DataAvailable) ? "d1 " : "d0 "))
return DataAvailable;
}
return false;
}
bool CControlAPI::GetNextCycleStartTimeAndNumber(long &TimeTillNextCycleStart_in_ms, long &NextCycleNumber, double /*timeout_in_seconds*/) {
if (CA_DLL_GetNextCycleStartTimeAndNumber) {
WriteDebug("GN")
bool ret = CA_DLL_GetNextCycleStartTimeAndNumber(&TimeTillNextCycleStart_in_ms, &NextCycleNumber);
#ifdef EnableDebug
if (ret) {
QString text = QString::number(TimeTillNextCycleStart_in_ms)+ "ms " + QString::number(NextCycleNumber) + "x ";
WriteDebug(text)
}
else {WriteDebug("0x ")}
#endif
return ret;
}
return false;
}
bool CControlAPI::IsSequenceRunning() {
if (CA_DLL_IsSequenceRunning) {
WriteDebug("ISR")
bool ret = CA_DLL_IsSequenceRunning();
WriteDebug("x ")
return ret;
}
return false;
}
bool CControlAPI::WaitTillSequenceEnds(double timeout_in_seconds) {
if (CA_DLL_WaitTillSequenceEnds) {
WriteDebug("WTSE")
bool ret = CA_DLL_WaitTillSequenceEnds(timeout_in_seconds);
WriteDebug("x ")
return ret;
}
return false;
}
bool CControlAPI::InterruptSequence() {
if (CA_DLL_InterruptSequence) {
WriteDebug("IntS")
bool ret = CA_DLL_InterruptSequence();
WriteDebug("x ");
return ret;
}
return false;
}
double CControlAPI::GetTime_in_ms() {
if (CA_DLL_GetTimeInMs) {
WriteDebug("GT")
double ret = CA_DLL_GetTimeInMs();
WriteDebug("x ")
return ret;
}
return -1.0;
}
void CControlAPI::GoBackInTime(double aTimeJump_in_ms, unsigned int ID) {
WriteDebug("GBIT")
if (CA_DLL_GoBackInTime)
CA_DLL_GoBackInTime(aTimeJump_in_ms, ID);
WriteDebug("x ")
}
void CControlAPI::GoToTime(double aTime_in_ms, unsigned int ID) {
WriteDebug("GTT")
if (CA_DLL_GoToTime)
CA_DLL_GoToTime(aTime_in_ms, ID);
WriteDebug("x ")
}
void CControlAPI::ReturnToCurrentTime(unsigned int ID) {
WriteDebug("RTCT")
if (CA_DLL_ReturnToCurrentTime)
CA_DLL_ReturnToCurrentTime(ID);
WriteDebug("x ")
}
void CControlAPI::FinishLastGoBackInTime(unsigned int ID) {
WriteDebug("FLGBIT")
if (CA_DLL_FinishLastGoBackInTime)
CA_DLL_FinishLastGoBackInTime(ID);
WriteDebug("x ")
}
void CControlAPI::StartAnalogInAcquisition(unsigned char sequencer, unsigned char SPI_port, unsigned char SPI_CS, unsigned int channel_number, unsigned int number_of_datapoints, double delay_between_datapoints_in_ms) {
WriteDebug("SAIA")
if (CA_DLL_StartAnalogInAcquisition)
CA_DLL_StartAnalogInAcquisition(sequencer, SPI_port, SPI_CS, channel_number, number_of_datapoints, delay_between_datapoints_in_ms);
WriteDebug("x ")
}
bool CControlAPI::WaitTillEndOfSequenceThenGetInputData(unsigned int*& buffer, unsigned long& buffer_length, double timeout_in_seconds) {
//
//The buffer has been allocated by the DLL. It needs to be deleted by the DLL as well,
//which is done the next time you call WaitTillEndOfSequenceThenGetInputData with the same buffer pointer.
//
if (CA_DLL_WaitTillEndOfSequenceThenGetInputData) {
unsigned char* raw_buffer = nullptr;
unsigned long buffer_length_in_bytes = 0;
unsigned long dummy_end_time = 0;
WriteDebug("WTSEGD")
bool result = CA_DLL_WaitTillEndOfSequenceThenGetInputData(&raw_buffer, &buffer_length_in_bytes, &dummy_end_time, timeout_in_seconds);
WriteDebug("x ")
buffer = reinterpret_cast<unsigned int*>(raw_buffer);
buffer_length = buffer_length_in_bytes/4;
return result;
}
return false;
}
bool CControlAPI::GetCycleData(unsigned int*& buffer, unsigned long& buffer_length, long &CycleNumber, long &LastCycleEndTime, long &LastCycleStartPreTriggerTime, bool &CycleError, QString &ErrorMessages, double /*timeout_in_seconds*/) {
//
//The buffer has been allocated by the DLL. It needs to be deleted by the DLL as well and this will automatically be done
//after a certain number of runs, currently set to 128 in ControlAPI.h of the DLLs source code.
//The buffer is only valid for 128 cycles of the experiment. Afterwards the DLL will free the buffer's memory.
//If the buffer is accessd after the DLL deleted it, the program will stall
//If you intend to use the buffer's data for a long time, then create a copy of it into memory that you allocated.
//
if (CA_DLL_GetCycleData) {
unsigned char* raw_buffer = nullptr;
const char* error_cstr = nullptr;
unsigned long buffer_length_in_bytes;
WriteDebug("GC")
MacroWriteTimestamp
WriteDebug("D")
bool result = CA_DLL_GetCycleData(&raw_buffer, &buffer_length_in_bytes, &CycleNumber,
reinterpret_cast<unsigned long*>(&LastCycleEndTime),
reinterpret_cast<unsigned long*>(&LastCycleStartPreTriggerTime),
&CycleError, &error_cstr);
MacroWriteTimestamp
WriteDebug("x\n")
buffer = reinterpret_cast<unsigned int*>(raw_buffer);
if (error_cstr) ErrorMessages = QString::fromUtf8(error_cstr);
else ErrorMessages.clear();
buffer_length = buffer_length_in_bytes/4;
return result;
}
return false;
}
bool CControlAPI::ClearAnalogInputQueue() {
if (CA_DLL_ClearAnalogInputQueue) {
WriteDebug("CAIQ")
bool ret = CA_DLL_ClearAnalogInputQueue();
WriteDebug("x ")
}
return false;
}
bool CControlAPI::HasInterlockTriggered() {
if (CA_DLL_HasInterlockTriggered) {
WriteDebug("HIT")
bool ret = CA_DLL_HasInterlockTriggered();
WriteDebug("x ")
return ret;
}
return false;
}
bool CControlAPI::ResetInterlock() {
if (CA_DLL_ResetInterlock) {
WriteDebug("RI")
bool ret = CA_DLL_ResetInterlock();
WriteDebug("x ")
return ret;
}
return false;
}
void CControlAPI::SetExternalTrigger(bool ExternalTrigger0, bool ExternalTrigger1) {
WriteDebug("SET")
if (CA_DLL_SetExternalTrigger)
CA_DLL_SetExternalTrigger(ExternalTrigger0, ExternalTrigger1);
WriteDebug("x ")
}
void CControlAPI::SetPeriodicTrigger(double PeriodicTriggerPeriod_in_ms, double PeriodicTriggerAllowedWaitTime_in_ms) {
WriteDebug("SPT")
if (CA_DLL_SetPeriodicTrigger)
CA_DLL_SetPeriodicTrigger(PeriodicTriggerPeriod_in_ms, PeriodicTriggerAllowedWaitTime_in_ms);
WriteDebug("x ")
}
bool CControlAPI::GetPeriodicTriggerError() {
if (CA_DLL_GetPeriodicTriggerError) {
WriteDebug("GPTE")
bool ret = CA_DLL_GetPeriodicTriggerError();
WriteDebug("x ")
return ret;
}
return false;
}
void CControlAPI::SetExternalClock(bool ExternalClock0, bool ExternalClock1) {
WriteDebug("SEC")
if (CA_DLL_SetExternalClock)
CA_DLL_SetExternalClock(ExternalClock0, ExternalClock1);
WriteDebug("x ")
}
bool CControlAPI::ResetFPGA() {
if (CA_DLL_ResetFPGA) {
WriteDebug("RF")
bool ret = CA_DLL_ResetFPGA();
WriteDebug("x ")
return ret;
}
return false;
}
bool CControlAPI::SetupSerialPort(unsigned char port_number, unsigned long baud_rate) {
if (CA_DLL_SetupSerialPort) {
WriteDebug("SSP")
bool ret = CA_DLL_SetupSerialPort(port_number, baud_rate);
WriteDebug("x ")
return ret;
}
return false;
}
void CControlAPI::Ramp(unsigned char* output_name, double start_value, double end_value, double ramp_time_in_ms, double timestep_in_ms) {
WriteDebug("R")
if (CA_DLL_Ramp)
CA_DLL_Ramp(reinterpret_cast<const char*>(output_name), start_value, end_value, ramp_time_in_ms, timestep_in_ms);
WriteDebug("x ")
}
void CControlAPI::Wait(double time_in_ms, unsigned long ID) {
WriteDebug("W")
if (CA_DLL_Wait)
CA_DLL_Wait(time_in_ms, ID);
WriteDebug("x ")
}
void CControlAPI::WaitTillBusBufferEmpty(unsigned long ID) {
WriteDebug("WTBBE")
if (CA_DLL_WaitTillBusBufferEmpty)
CA_DLL_WaitTillBusBufferEmpty(ID);
WriteDebug("x ")
}
void CControlAPI::WaitTillRampsEnd(unsigned long ID) {
WriteDebug("WTRE")
if (CA_DLL_WaitTillRampsEnd)
CA_DLL_WaitTillRampsEnd(ID);
WriteDebug("x ")
}
void CControlAPI::StopRamps() {
WriteDebug("SR")
if (CA_DLL_StopRamps)
CA_DLL_StopRamps();
WriteDebug("x ")
}
bool CControlAPI::WriteToSerial(unsigned int port_nr, unsigned char* command, unsigned long length) {
if (CA_DLL_WriteToSerial) {
WriteDebug("WTS")
bool ret = CA_DLL_WriteToSerial(port_nr, reinterpret_cast<const char*>(command), length);
WriteDebug("x ")
}
return false;
}
bool CControlAPI::WriteToI2C(unsigned int port_nr, unsigned char* command, unsigned long length) {
if (CA_DLL_WriteToI2C) {
WriteDebug("WTI2C")
bool ret = CA_DLL_WriteToI2C(port_nr, reinterpret_cast<const char*>(command), length);
WriteDebug("x ")
return ret;
}
return false;
}
bool CControlAPI::WriteToSPI(unsigned int port_nr, unsigned char* command, unsigned long length) {
if (CA_DLL_WriteToSPI) {
WriteDebug("WTSPI")
bool ret = CA_DLL_WriteToSPI(port_nr, reinterpret_cast<const char*>(command), length);
WriteDebug("x ")
return ret;
}
return false;
}
bool CControlAPI::GetSequenceDuration(double &SequenceDuration_in_ms) {
if (CA_DLL_GetSequenceDuration) {