-
Notifications
You must be signed in to change notification settings - Fork 0
/
ams4100_hClass.m
1661 lines (1638 loc) · 72.3 KB
/
ams4100_hClass.m
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
classdef ams4100_hClass < matlab.mixin.SetGet
%AMS4100_HCLASS Handle class for A-M systems Model 4100
%
% This class interfaces with A-M Systems Model 4100 stimulus isolator
%
% Each property can be written to or read from and it will send data
% to the instrument if connected.
%
% Rev 1.x First released Revision
% Rev 2.x Added PIN number, and included PIN in SendReceiveString
% .2 Changed train and event num to max 99999 Added MatlabRev
% Rev 3.x Add open and close relay commands
% Rev 4.x Ethernet Communication with tcpclient instead of JAVA
%
% Rev 4.x.NML - This is where Max started modifying code
%% Properties
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
properties (Dependent)
Active % Active status
Mode % mode type EXAMPLE: handle.mode =3; or handle.mode = mode.intVolt;
TrainType % Train type EXAMPLE: handle.TrainType =1; or handle.TrainType = tType.simple;
TrainDelay % Train Delay in us Valid values are: 0 to 9,360,000,000 EXAMPLE: handle.TrainDelay =5000; (5ms)
TrainDur % Train Duration in us Valid values are: 0 to 9,360,000,000 EXAMPLE: handle.TrainDur=5000; (5ms)
TrainPeriod % Train Period in us Valid values are: 0 to 9,360,000,000 EXAMPLE: handle.TrainPeriod =5000; (5ms)
TrainQuantity % Train Quantity Valid values are: 0 to 100 EXAMPLE: handle.TrainQuantity =11;
TrainLevel % Train Level in uV Valid values are: 0 to 200,000,000 EXAMPLE: handle.TainLevel =5000; (5mV)
TrainFrequency % Train Frequency in HZ Valid values are: 1,000,000/2 to 1,000,000/9,360,000,000 Hz EXAMPLE: handle.TrainFrequency =67; (Hz)
OffsetOrHold % Set train level as offset or hold EXAMPLE: handle.OffsetOrHold =1; or handle.OffsetOrHold = offsetOrHold.hold;
EventType % The type of event for the current LibID . EXAMPLE: handle.EventType =1; or handle.EventType = eType.biphasic;
EventDelay % Event Delay for the current LibID in us Valid values are: 0 to 9,360,000,000 EXAMPLE: handle.EventDelay =5000; (5ms)
EventDur1 % Event Duration1 for the current LibID in us Valid values are: 0 to 9,360,000,000 EXAMPLE: handle.EventDuration1 =5000; (5ms)
EventDur2 % Event Duration2 for the current LibID in us Valid values are: 0 to 9,360,000,000 EXAMPLE: handle.EventDuration2 =5000; (5ms)
EventDur3 % Event Duration3 for the current LibID in us Valid values are: 0 to 9,360,000,000 EXAMPLE: handle.EventDur3 =5000; (5ms)
EventPeriod % Event Period for the current LibID in us Valid values are: 0 to 9,360,000,000 EXAMPLE: handle.EventPeriod =5000; (5ms)
EventQuantity % Event Quantity for the current LibID Valid values are: 0 to 100 EXAMPLE: handle.EventQuantity = 12;
EventFrequency % Event Frequency for the current LibID in HZ Valid values are: 1,000,000/2 to 1,000,000/9,360,000,000 Hz EXAMPLE: handle.EventFrequency =67; (Hz)
EventAmp1 % Event Amplitude1 for the current LibID in uV Valid values are: 0 to 200,000,000 EXAMPLE: handle.EventAmp1 =5000; (5mV)
EventAmp2 % Event Amplitude2 for the current LibID in uV Valid values are: 0 to 200,000,000 EXAMPLE: handle.EventAmp2 =5000; (5mV)
EventList % List the LibID location for mixed event types
IsoOutput % Sets the ISOout to zero when off or normal when on timing contiues on or off
Auto % Variable Auto complete EXAMPLE: handle.Auto =1; or handle.Auto =auto.fixed;
Trigger % Trigger type EXAMPLE: handle.Trigger =1; or handle.Trigger =trigger.rising;
Monitor % BNC Monitor mode scale EXAMPLE: handle.Monitor =1; or handle.Monitor = monitor.scale1VperV;
Sync1 % BNC Sync1 source EXAMPLE: handle.Sync1 =1; or handle.Sync1 =sync.eventPeriod;
Sync2 % BNC Sync2 source EXAMPLE: handle.Sync2 =1; or handle.Sync2 =sync.eventPeriod;
PeriodOrFreq % Frequecy input style EXAMPLE: handle.PeriodOrFreq =1; or handle.PeriodOrFreq = periodOrFreq.frequency;
UniformNumber
% EventID % loads the event data if it exists in the event list when in train type mixed.
LibID % loads the library into current event and updates event list for that new library position.
HighVflag
HighIflag
Generating
Running
EnableButtonIn
PIN % communication PIN number
DoComms % If true then communication with the instrument will occur, if false then no commuication
% Libraries % All the Event Data saved in the libraries [LibID Type Delay Dur1 Dur2 Per Quant Freq Int Amp1 Amp2 Sym]
end
properties (Access=private)
priv_PIN=1001;
priv_Active='';
priv_Output='intVolt';
priv_Trigger='rising';
priv_Auto='none';
priv_Monitor='scale1VperV';
priv_Sync1='trainDuration';
priv_Sync2='eventDuration1';
priv_PeriodOrFreq='period';
priv_TrainType='uniform';
priv_TrainDelay=0;
priv_TrainDur=0;
priv_TrainPeriod=0;
priv_TrainQuantity=0;
priv_TrainLevel=0;
priv_TrainFrequency=0;
priv_OffsetOrHold='offset';
% priv_EventID=1;
priv_LibID=1;
priv_EventType='monophasic';
priv_EventDelay=0;
priv_EventDur1=0;
priv_EventDur3=0;
priv_EventPeriod=0;
priv_EventQuantity=0;
priv_EventFrequency=0;
priv_EventDur2=0;
priv_EventAmp1=0;
priv_EventAmp2=0;
priv_EventList=1:20;
priv_IsoOutput=0; % 0 is on
priv_UniformNumber=1;
priv_HighVflag=0;
priv_HighIflag=0;
priv_Generating=0;
priv_Running=0;
priv_EnableButtonIn=0;
PortEthernet=0; % 1 for ethernet
PortSerial=0; % 1 for serial
etherfctr=100; %how much faster the ethernet should be compared to USB
CONST;
priv_DoComms = true;
% [LibID Type Delay Dur1 Dur2 Dur3 Quant Per Freq Amp1 Amp2 Sym] Note
% priv_Libraries=[(1:20)' zeros(20,1,'uint8') zeros(20,4,'uint64') zeros(20,1,'uint8') zeros(20,4,'uint64') zeros(20,1,'uint8')];
end
properties (SetAccess=protected)
PortSuccess=0;
Revision='';
Network='';
SerialNumber='';
values;
MCUrev=0;
MatlabRev='4.0.NML';
Logger
end
properties
loading=0; % a variable that is set to 1 if the entire library data set is being loaded. turns off start and stop
Port; %
PortInfo; %
ActiveComms=0; % a flag that goes high during active communication to the instrument
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Public Methods
methods
%% costructor
function obj = ams4100_hClass(amsPort,amsPIN,startCOMS)
% ams4100 - Constructor for the class
%
% obj = AMS4100(amsPort) creates a handle to an
% instance of the AMS4100 Class. The instance is set to be
% associated with the Instrument that is paired with the com port
% defined in the input amsPort.
%
% SYNOPSIS: obj =AMS4100(amsPort)
%
% INPUT: amsPort - string value defining the numeric value of the
% desired Com Port or IP address
% amsPIN - a pin number up to 5 digits set on the instrument to allow setting values
% startCOMS - if false then there will be no communication with instrument
%
% mode: obj - handle to the instance of the
% AMS4100 Class
%
% EXAMPLE: handle = AMS4100('COM7');
%
[obj.values, obj.CONST]=ComConstants; % load default rev constants
switch nargin
case 2
obj.Port=amsPort;
obj.PIN=amsPIN;
obj.DoComms=true;
case 1
obj.Port=amsPort;
obj.PIN=1001;
obj.DoComms=true;
case 0
%[obj.PortSuccess, obj.PortInfo]=testams(obj,amsPort);
% comports=cellstr(serialportlist);
% obj.Port=cell2mat(comports(1));
obj.Port='COMNONE';
obj.PIN=1001;
obj.DoComms=false;
otherwise
obj.Port=amsPort;
obj.PIN=amsPIN;
obj.DoComms=startCOMS;
end
if iscell(obj.Port)
obj.Port=cell2mat(obj.Port);
end
if length(obj.Port)<3
obj.Port='COMnone';
end
try
if strcmpi(obj.Port(1:3),'COM') % IF COM PORT
fprintf('setting up port %s with pin %i\r' ,obj.Port, obj.PIN);
obj.PortEthernet=0;
if ~strcmp(obj.Port,'COMNONE')
obj.PortInfo=serialport(obj.Port,115200); % port and baud rate
pause(1); % and give it a bit of time to set up
obj.PortInfo.Timeout=10; %wait up to 10 seconds for a reply
obj.PortInfo.DataBits=8;
obj.PortInfo.StopBits=1;
obj.PortInfo.Parity='odd';
configureTerminator(obj.PortInfo,42,'CR'); % termintor for readline,writeline
flush(obj.PortInfo);
writeline(obj.PortInfo,'get rev');
pause(0.1); % wait for transmission]
count=obj.PortInfo.NumBytesAvailable;
if( count>10)
obj.PortSerial=1;
else
obj.PortSerial=0;
end
else
count=0;
obj.PortSerial=0;
obj.PortInfo=[];
end
else % ELSE IT IS TELNET
disp('setting up TCP client');
t=tcpclient(obj.Port,23,"Timeout",20,"ConnectTimeout",30);
if exist('t','var')
obj.PortInfo=t;
pause(0.5); % wait for wakeup and get ready to clear buffer
clear t;
read(obj.PortInfo); % empties buffer
write(obj.PortInfo,uint8(sprintf('get rev \r')))
pause(0.1); % wait for transmission]
count=obj.PortInfo.BytesAvailable;
if( count>10)
obj.PortEthernet=1;
else
obj.PortEthernet=0;
end
else
count=0;
obj.PortEthernet=0;
obj.PortInfo=[];
end
end
%****************************************
if count > 12
obj.PortSuccess=1;
outStr=readReply(obj);
lines=strfind(outStr,'~');
if length(lines)>1
outStr=outStr(lines(1)+1:lines(2)-1);
end
obj.Revision=outStr;
obj.MCUrev=getMCUrev(obj); % gets a the single digit number after the 'M'
obj.Network=SendReceiveString(obj,'g n');
obj.SerialNumber=SendReceiveString(obj,'g m 1 6');
obj.Logger = mlog.Logger(sprintf('AMS4100_%s',obj.SerialNumber));
UpdateEventList(obj);
else
obj.PortSuccess=0;
disp('No data connection was obtained')
end
catch ME
if obj.PortEthernet
% no need for ethernet close
else
% no need for serialport close
end
obj.PortEthernet=0;
obj.PortSerial=0;
obj.PortSuccess=0;
warning('No Instrument communication')
error(ME.identifier, 'Connection Error: %s', ME.message)
end
end
%% destructor
function delete(obj)
if obj.PortEthernet
% destroying the object should clear the ethernet port
try %#ok<TRYNC>
delete(obj.PortInfo);
end
else
% destroying the object should clear the serialport
end
try %#ok<TRYNC>
delete(obj.Logger);
end
end
%% Get/Set Properties
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.DoComms(obj)
% The DoComm property
%
% Valid values are:
% False= no communication with instrument
% True = communication with instrumet
%
out=obj.priv_DoComms;
end
function set.DoComms(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >1 || min(value)<0
error('DoComms must be between 0 and 1');
else
obj.priv_DoComms=value;
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.PIN(obj)
% The PIN property
%
% Valid values are:
% 0 to 9999
%
out=obj.priv_PIN;
end
function set.PIN(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >9999 || min(value)<1
error('DoComms must be between 1 and 9999');
else
obj.priv_PIN=value;
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.Mode(obj)
% The mode property sets the mode type
%
% Valid values are from ComConstants.m:
% EXAMPLE: handle.mode =3;
% EXAMPLE: handle.mode = handle.values.mode.intVolt;
%
obj.priv_Output=obj.GetInfo(obj.CONST.menu.general,obj.CONST.general.mode,obj.priv_Output);
out=obj.priv_Output;
obj.Logger.info(sprintf('get::Mode=%s',out));
end
function set.Mode(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >6 || min(value)<0
error('Mode must be between 0 and 6');
else
Stop(obj);
obj.priv_Output=obj.getfieldstr(obj.values.mode, value);
obj.PortSuccess=obj.SetInfo(obj.CONST.menu.general,obj.CONST.general.mode,value);
obj.Logger.info(sprintf('set::Mode=%d',value));
Run(obj);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.IsoOutput(obj)
% The IsoOutput property
%
% Valid values are from ComConstants.m:
% EXAMPLE: handle.Trigger =1;
% EXAMPLE: handle.Trigger =handle.values.trigger.rising;
%
obj.priv_IsoOutput=obj.GetInfo(obj.CONST.menu.general,obj.CONST.general.isoOutput,obj.priv_IsoOutput);
out=obj.priv_IsoOutput;
obj.Logger.info(sprintf('get::IsoOutput=%s',out));
end
function set.IsoOutput(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >1 || min(value)<0
error('Trigger must be 0 or 1');
else
% Stop(obj);
obj.priv_IsoOutput=obj.getfieldstr(obj.values.isoOutput,value);
% sprintf('s m %d %d %d',uint8(obj.CONST.menu.general),uint8(obj.CONST.general.trigger),uint64(trigger(value)))
obj.PortSuccess=obj.SetInfo(obj.CONST.menu.general,obj.CONST.general.isoOutput ,value);
obj.Logger.info(sprintf('set::IsoOutput=%d',value));
% Run(obj);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.Active(obj)
% The Active property gets the mode status
% function obj=set.Active(obj,value)
% if strcmp(value,'run') || strcmp(value,'stop')
% if obj.PortSuccess == 1 && obj.DoComms
% if strcmp(value,'run')
% strOut=obj.SendReceiveString('s a run');
% obj.PortSuccess =strcmp(strOut,'*');
% else
% strOut=obj.SendReceiveString('s a stop');
% obj.PortSuccess =strcmp(strOut,'*');
% end
% value=obj.SendReceiveString('g a');
% obj.priv_Active=value;
% else
% if obj.DoComms warning('No Instrument communication ams4100 values will change, but the instrument settings are not changed'); end
% end
% else
% error('The value must be "run" or "stop"');
% end
% end
obj.priv_Active=obj.SendReceiveString('g a');
out=obj.priv_Active;
obj.Logger.info(sprintf('get::Active=%s',out));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.Trigger(obj)
% The Trigger property
%
% Valid values are from ComConstants.m:
% EXAMPLE: handle.Trigger =1;
% EXAMPLE: handle.Trigger =handle.values.trigger.rising;
%
obj.priv_Trigger=obj.GetInfo(obj.CONST.menu.general,obj.CONST.general.trigger,obj.priv_Trigger);
out=obj.priv_Trigger;
obj.Logger.info(sprintf('get::Trigger=%s',out));
end
function set.Trigger(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >1 || min(value)<0
error('Trigger must be 0 or 1');
else
Stop(obj);
obj.priv_Trigger=obj.getfieldstr(obj.values.trigger,value);
% sprintf('s m %d %d %d',uint8(obj.CONST.menu.general),uint8(obj.CONST.general.trigger),uint64(trigger(value)))
obj.PortSuccess=obj.SetInfo(obj.CONST.menu.general,obj.CONST.general.trigger ,value);
obj.Logger.info(sprintf('set::Trigger=%d',value));
Run(obj);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.Auto(obj)
% The Auto property
%
% Valid values are from ComConstants.m:
% EXAMPLE: handle.Auto =1;
% EXAMPLE: handle.Auto =handle.values.auto.fixed;
%
obj.priv_Auto=obj.GetInfo(obj.CONST.menu.general,obj.CONST.general.auto,obj.priv_Auto);
out=obj.priv_Auto;
obj.Logger.info(sprintf('get::Auto=%s',out));
end
function set.Auto(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >2 || min(value)<0
error('Auto must be between 0 and 2');
else
Stop(obj);
obj.priv_Auto=obj.getfieldstr( obj.values.auto , value );
obj.PortSuccess=obj.SetInfo( obj.CONST.menu.general,obj.CONST.general.auto , value );
obj.Logger.info(sprintf('set::Auto=%d',value));
Run(obj);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.Monitor(obj)
% The Monitor property
%
% Valid values are from ComConstants.m:
% EXAMPLE: handle.Monitor =1;
% EXAMPLE: handle.Monitor = handle.values.monitor.scale1VperV;
%
obj.priv_Monitor=obj.GetInfo(obj.CONST.menu.general,obj.CONST.general.monitor,obj.priv_Monitor);
out=obj.priv_Monitor;
obj.Logger.info(sprintf('get::Monitor=%s',out));
end
function set.Monitor(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >7 || min(value)<0
error('Monitor must be from 0 to 5');
else
Stop(obj);
obj.priv_Monitor=obj.getfieldstr( obj.values.monitor , value );
obj.PortSuccess=obj.SetInfo(obj.CONST.menu.general,obj.CONST.general.monitor ,value);
obj.Logger.info(sprintf('set::Monitor=%d',value));
Run(obj);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.Sync1(obj)
% The Sync1 property
%
% Valid values are from ComConstants.m:
% EXAMPLE: handle.Sync1 =1;
% EXAMPLE: handle.Sync1 =handle.values.sync.eventPeriod;
%
obj.priv_Sync1=obj.GetInfo(obj.CONST.menu.config,obj.CONST.config.sync1,obj.priv_Sync1);
out=obj.priv_Sync1;
obj.Logger.info(sprintf('get::Sync1=%s',out));
end
function set.Sync1(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >8 || min(value)<0
error('Sync1 must be from 0 to 8');
else
Stop(obj);
obj.priv_Sync1=obj.getfieldstr( obj.values.sync , value );
obj.PortSuccess=obj.SetInfo(obj.CONST.menu.config, obj.CONST.config.sync1, value);
obj.Logger.info(sprintf('set::Sync1=%d',value));
Run(obj);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.Sync2(obj)
% The Sync2 property
%
% Valid values are from ComConstants.m:
% EXAMPLE: handle.Sync2 =1;
% EXAMPLE: handle.Sync2 =handle.values.sync.eventPeriod;
%
obj.priv_Sync2=obj.GetInfo(obj.CONST.menu.config,obj.CONST.config.sync2,obj.priv_Sync2);
out=obj.priv_Sync2;
obj.Logger.info(sprintf('get::Sync2=%s',out));
end
function set.Sync2(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >3 || min(value)<0
error('Sync2 must be from 0 to 3');
else
Stop(obj);
obj.priv_Sync2=obj.getfieldstr( obj.values.sync , value );
obj.PortSuccess=obj.SetInfo(obj.CONST.menu.config, obj.CONST.config.sync2, value);
obj.Logger.info(sprintf('set::Sync2=%d',value));
Run(obj);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.PeriodOrFreq(obj)
% The PeriodOrFreq property
%
% Valid values are from ComConstants.m:
% EXAMPLE: handle.PeriodOrFreq =1;
% EXAMPLE: handle.PeriodOrFreq = handle.values.periodOrFreq.frequency;
%
obj.priv_PeriodOrFreq=obj.GetInfo(obj.CONST.menu.config,obj.CONST.config.periodOrFreq,obj.priv_PeriodOrFreq);
out=obj.priv_PeriodOrFreq;
obj.Logger.info(sprintf('get::PeriodOrFreq=%s',out));
end
function set.PeriodOrFreq(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >1 || min(value)<0
error('PeriodOrFreq must be 0 or 1');
else
Stop(obj);
obj.priv_PeriodOrFreq=obj.getfieldstr( obj.values.periodOrFreq, value);
obj.PortSuccess=obj.SetInfo(obj.CONST.menu.config,obj.CONST.config.periodOrFreq,value);
obj.Logger.info(sprintf('set::PeriodOrFreq=%d',value));
Run(obj);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.TrainType(obj)
% The TrainType property
%
% Valid values are from ComConstants.m:
% EXAMPLE: handle.TrainType =2;
% EXAMPLE: handle.TrainType = handle.values.train.type.uniform;
%
obj.priv_TrainType=obj.GetInfo(obj.CONST.menu.train,obj.CONST.train.type,obj.priv_TrainType);
out=obj.priv_TrainType;
obj.Logger.info(sprintf('get::TrainType=%s',out));
end
function set.TrainType(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >1 || min(value)<0
error('TrainType must be from 0 to 2');
else
Stop(obj);
obj.priv_TrainType=obj.getfieldstr( obj.values.train.type , value );
obj.PortSuccess=obj.SetInfo(obj.CONST.menu.train,obj.CONST.train.type, value );
obj.Logger.info(sprintf('set::TrainType=%d',value));
Run(obj);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.TrainDelay(obj)
% The TrainDelay property
%
% Valid values are:
% 0 to 9,360,000,000 us
% EXAMPLE: handle.TrainDelay =5000 (5ms);
%
obj.priv_TrainDelay=obj.GetInfo(obj.CONST.menu.train,obj.CONST.train.delay,obj.priv_TrainDelay);
out=obj.priv_TrainDelay;
obj.Logger.info(sprintf('get::TrainDelay=%s',out));
end
function set.TrainDelay(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >9360000000 || min(value)<0 || not(isnumeric(value)) || not( rem(value,1)==0)
error('TrainDelay must be an integer from 0 to 9360000000');
else
Stop(obj);
obj.priv_TrainDelay=value;
obj.PortSuccess=obj.SetInfo(obj.CONST.menu.train, obj.CONST.train.delay, value);
obj.Logger.info(sprintf('set::TrainDelay=%d',value));
Run(obj);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.UniformNumber(obj)
% The UniformNumber property
obj.priv_UniformNumber= obj.GetInfo(obj.CONST.menu.uniformevent , ...
obj.CONST.uniformevent.number, ...
obj.priv_UniformNumber);
out=obj.priv_UniformNumber;
obj.Logger.info(sprintf('get::UniformNumber=%s',out));
end
function set.UniformNumber(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >20 || min(value)<1 || not(isnumeric(value)) || not( rem(value,1)==0)
error('UniformNumber must be an integer from 1 to 20');
else
Stop(obj);
obj.priv_UniformNumber=value;
obj.PortSuccess=obj.SetInfo(obj.CONST.menu.uniformevent , ...
obj.CONST.uniformevent.number, ...
value);
%AMS_UpdateEventTable();
%AMS_UpdateEvents();
obj.Logger.info(sprintf('set::UniformNumber=%d',value));
Run(obj);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.HighVflag(obj)
% The HighVflag property
tmp=SendReceiveString(obj,'g c');
bitPos=4;
obj.priv_HighVflag=bitand(bitshift(double(tmp(1)),-bitPos),1);
out=obj.priv_HighVflag;
obj.Logger.info(sprintf('get::HighVflag=%s',out));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.HighIflag(obj)
% The HighIflag property
tmp=SendReceiveString(obj,'g c');
bitPos=3;
obj.priv_HighIflag=bitand(bitshift(double(tmp(1)),-bitPos),1);
out=obj.priv_HighIflag;
obj.Logger.info(sprintf('get::HighIflag=%s',out));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.Generating(obj)
% The HighVflag property
tmp=SendReceiveString(obj,'g c');
bitPos=2;
obj.priv_Generating=bitand(bitshift(double(tmp(1)),-bitPos),1);
out=obj.priv_Generating;
obj.Logger.info(sprintf('get::Generating=%s',out));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.Running(obj)
% The HighVflag property
tmp=SendReceiveString(obj,'g c');
bitPos=1;
obj.priv_Running=bitand(bitshift(double(tmp(1)),-bitPos),1);
out=obj.priv_Running;
obj.Logger.info(sprintf('get::Running=%s',out));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.EnableButtonIn(obj)
% The HighVflag property
tmp=SendReceiveString(obj,'g c');
bitPos=0;
obj.priv_EnableButtonIn=bitand(bitshift(double(tmp(1)),-bitPos),1);
out=obj.priv_EnableButtonIn;
obj.Logger.info(sprintf('get::EnableButtonIn=%s',out));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.TrainDur(obj)
%TrainDur- train duration in us
% The TrainDurproperty
%
% Valid values are:
% 2 to 9,360,000,000 us
% EXAMPLE: handle.TrainDur=5000 (5ms);
%
obj.priv_TrainDur=obj.GetInfo(obj.CONST.menu.train,obj.CONST.train.duration,obj.priv_TrainDur);
out=obj.priv_TrainDur;
obj.Logger.info(sprintf('get::TrainDur=%s',out));
end
function set.TrainDur(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >9360000000 || min(value)<2 || not(isnumeric(value)) || not( rem(value,1)==0)
error('TrainDur must be an integer from 2 to 9360000000');
else
Stop(obj);
obj.priv_TrainDur=value;
obj.PortSuccess=obj.SetInfo(obj.CONST.menu.train, obj.CONST.train.duration, value);
obj.Logger.info(sprintf('set::TrainDur=%d',value));
Run(obj);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.TrainPeriod(obj)
% The TrainPeriod property
%
% Valid values are:
% 2 to 9,360,000,000 us
% EXAMPLE: handle.TrainPeriod =5000 (5ms);
%
obj.priv_TrainPeriod=obj.GetInfo(obj.CONST.menu.train,obj.CONST.train.period,obj.priv_TrainPeriod);
out=obj.priv_TrainPeriod;
obj.Logger.info(sprintf('get::TrainPeriod=%s',out));
end
function set.TrainPeriod(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >9360000000 || min(value)<2 || not(isnumeric(value)) || not( rem(value,1)==0)
error('TrainPeriod must be an integer from 2 to 9360000000');
else
Stop(obj);
obj.priv_TrainPeriod=value;
freq=round(1000000/value);
obj.priv_TrainFrequency=freq;
obj.PortSuccess=obj.SetInfo(obj.CONST.menu.train, obj.CONST.train.period, value);
obj.Logger.info(sprintf('set::TrainPeriod=%d',value));
Run(obj);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.TrainQuantity(obj)
% The TrainQuantity property
%
% Valid values are:
% 1 to 100
% EXAMPLE: handle.TrainQuantity =22 ;
%
obj.priv_TrainQuantity=obj.GetInfo(obj.CONST.menu.train,obj.CONST.train.quantity,obj.priv_TrainQuantity);
out=obj.priv_TrainQuantity;
obj.Logger.info(sprintf('get::TrainQuantity=%s',out));
end
function set.TrainQuantity(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >100 || min(value)<1 || not(isnumeric(value)) || not( rem(value,1)==0)
error('TrainQuantity must be an integer from 1 to 100');
else
Stop(obj);
obj.priv_TrainQuantity=value;
obj.PortSuccess=obj.SetInfo(obj.CONST.menu.train, obj.CONST.train.quantity, value);
obj.Logger.info(sprintf('set::TrainQuantity=%d',value));
Run(obj);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.TrainLevel(obj)
% The TainLevel property
%
% Valid values are:
% 0 to 200000000
% EXAMPLE: handle.TainLevel =10000; (this is 10mV)
%
obj.priv_TrainLevel=obj.GetInfo(obj.CONST.menu.train,obj.CONST.train.level,obj.priv_TrainLevel);
out=obj.priv_TrainLevel;
obj.Logger.info(sprintf('get::TrainLevel=%s',out));
end
function set.TrainLevel(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >200000000 || min(value)< -200000000 || not(isnumeric(value)) || not( rem(value,1)==0)
error('TainLevel must be an integer from 0 to 200000000');
else
Stop(obj);
obj.priv_TrainLevel=value;
obj.PortSuccess=obj.SetInfo(obj.CONST.menu.train, obj.CONST.train.level, value);
obj.Logger.info(sprintf('set::TrainLevel=%d',value));
Run(obj);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.TrainFrequency(obj)
% The TrainFrequency property
%
% Valid values are:
% 1,000,000/2 to 1,000,000/9,360,000,000 Hz
% EXAMPLE: handle.TrainPeriod =67; (Hz)
%
out=obj.priv_TrainFrequency;
obj.Logger.info(sprintf('get::TrainFrequency=%s',out));
end
function set.TrainFrequency(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if isnumeric(value)
period=round(1000000/value);
if max(period) >9360000000 || min(period)<0
error('TrainFrequency must be floats from 1.0684e-04 to 500,000');
else
Stop(obj);
obj.priv_TrainFrequency=value;
obj.priv_TrainPeriod=period;
obj.PortSuccess=obj.SetInfo(obj.CONST.menu.train, obj.CONST.train.period, period);
obj.Logger.info(sprintf('set::TrainFrequency=%d',value));
Run(obj);
end
else
error('Values must be numeric');
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.OffsetOrHold(obj)
% The OffsetOrHold property
%
% Valid values are from ComConstants.m:
% EXAMPLE: handle.OffsetOrHold =1;
% EXAMPLE: handle.OffsetOrHold = handle.values.offsetOrHold.hold;
%
obj.priv_OffsetOrHold=obj.GetInfo(obj.CONST.menu.train,obj.CONST.train.offsetOrHold,obj.priv_OffsetOrHold);
out=obj.priv_OffsetOrHold;
obj.Logger.info(sprintf('get::OffsetOrHold=%s',out));
end
function set.OffsetOrHold(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >2 || min(value)<0
error('OffsetOrHold must be from 0 to 2');
else
Stop(obj);
obj.priv_OffsetOrHold=obj.getfieldstr( obj.values.offsetOrHold, value);
obj.PortSuccess=obj.SetInfo(obj.CONST.menu.train, obj.CONST.train.offsetOrHold, value);
obj.Logger.info(sprintf('set::OffsetOrHold=%d',value));
Run(obj);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function out = get.EventID(obj)
% % The EventID property
% %
% % If EventID changes it will update the event fields (in event.m) using
% % the function AMS_UpdateEvents. This is only active for mixed train
% % types
% % Valid values are:
% % 1 to 20
% % EXAMPLE: handle.EventID =1 ;
% %
% out=obj.priv_EventID;
% end
% function obj=set.EventID(obj,value)
% if size(value,2) ~= 1 || size(value,1)~= 1
% error('Must be a 1 by 1 byte array.');
% else
% if max(value) >20 || min(value)<1 || not(isnumeric(value)) || not( rem(value,1)==0)
% error('EventID must be an integer from 1 to 20');
% else
% obj.priv_EventID=value;
% %obj.PortSuccess=obj.SetInfo(obj.CONST.menu.event, event.eventID, value);
% %AMS_UpdateEvents();
% end
% end
% end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.LibID(obj)
% The LibID property
%
% If LibID can only change in train type uniform, or mixed. In mixed
% when LibID changes that library will be loaded into Event 1. In mixed
% when LibID changes that library will be loaded into the current
% Event, and the Event List will change that library Position.
% Valid values are:
% 1 to 20
% EXAMPLE: handle.LibID =1 ;
%
out=obj.priv_LibID;
obj.Logger.info(sprintf('get::LibID=%s',out));
end
function set.LibID(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >20 || min(value)<1 || not(isnumeric(value)) || not( rem(value,1)==0)
error('LibID must be an integer from 1 to 20');
else
obj.priv_LibID=value;
obj.Logger.info(sprintf('set::LibID=%d',value));
%obj.PortSuccess=obj.SetInfo(obj.CONST.menu.event, event.libID, value);
%AMS_UpdateEventTable();
%AMS_UpdateEvents();
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.EventType(obj)
% The EventType property
%
% Valid values are from ComConstants.m:
% EXAMPLE: handle.EventType =1;
% EXAMPLE: handle.EventType = handle.values.event.type.biphasic;
%
obj.priv_EventType=obj.GetInfo(obj.CONST.menu.event+obj.LibID-1,obj.CONST.event.type,obj.priv_EventType);
out=obj.priv_EventType;
obj.Logger.info(sprintf('get::EventType=%s',out));
end
function set.EventType(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >3 || min(value)<0
error('EventType must be from 0 to 3');
else
Stop(obj);
obj.priv_EventType=obj.getfieldstr( obj.values.event.type , value );
obj.PortSuccess=obj.SetInfo(obj.CONST.menu.event+obj.LibID-1, obj.CONST.event.type, value);
obj.Logger.info(sprintf('set::EventType=%d',value));
Run(obj);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.EventDelay(obj)
% The EventDelay property
%
% Valid values are:
% 0 to 9,360,000,000 us
% EXAMPLE: handle.EventDelay =5000 (5ms);
%
obj.priv_EventDelay=obj.GetInfo(obj.CONST.menu.event+obj.LibID-1,obj.CONST.event.delay,obj.priv_EventDelay);
out=obj.priv_EventDelay;
obj.Logger.info(sprintf('get::EventDelay=%s',out));
end
function set.EventDelay(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >9360000000 || min(value)<0 || not(isnumeric(value)) || not( rem(value,1)==0)
error('EventDelay must be an integer from 0 to 9360000000');
else
Stop(obj);
obj.priv_EventDelay=value;
obj.PortSuccess=obj.SetInfo(obj.CONST.menu.event+obj.LibID-1,obj.CONST.event.delay, value);
obj.Logger.info(sprintf('set::EventDelay=%d',value));
Run(obj);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.EventDur1(obj)
% The EventDuration1 property
%
% Valid values are:
% 1 to 9,360,000,000 us
% EXAMPLE: handle.EventDuration1 =5000 (5ms);
%
obj.priv_EventDur1=obj.GetInfo(obj.CONST.menu.event+obj.LibID-1,obj.CONST.event.dur1,obj.priv_EventDur1);
out=obj.priv_EventDur1;
obj.Logger.info(sprintf('get::EventDur1=%s',out));
end
function set.EventDur1(obj,value)
if size(value,2) ~= 1 || size(value,1)~= 1
error('Must be a 1 by 1 byte array.');
else
if max(value) >9360000000 || min(value)<1 || not(isnumeric(value)) || not( rem(value,1)==0)
error('EventDuration1 must be an integer from 1 to 9360000000');
else
Stop(obj);
obj.priv_EventDur1=value;
obj.PortSuccess=obj.SetInfo(obj.CONST.menu.event+obj.LibID-1,obj.CONST.event.dur1, value);
obj.Logger.info(sprintf('set::EventDur1=%d',value));
Run(obj);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = get.EventDur2(obj)
% The EventDuration2 property
%
% Valid values are: