65
65
66
66
function daq = createDAQ(obj )
67
67
% Create a Heka DAQ controller if on Windows or a simulation controller on Mac.
68
+
68
69
import Symphony .Core .* ;
69
70
70
- import Heka .* ;
71
-
72
- if ~isempty(which(' HekaDAQInputStream' ))
71
+ try
73
72
import Heka .* ;
74
73
75
74
% Register the unit converters
93
92
94
93
daq = HekaDAQController(hekaID , 0 );
95
94
daq .InitHardware();
96
- else
95
+ catch ME
96
+ daq = [];
97
+ disp([' Could not load the Heka driver: ' ME .message ]);
98
+ end
99
+
100
+ if isempty(daq )
97
101
import Symphony .SimulationDAQController .* ;
98
102
99
- disp(' Could not load the Heka driver, using the simulation controller instead.' );
100
-
101
- Converters .Register(' V' , ' V' , @(m ) m );
103
+ disp(' Using the simulation controller instead.' );
102
104
daq = SimulationDAQController();
103
105
daq .BeginSetup();
104
106
105
107
daq.SimulationRunner = Simulation(@(output ,step ) loopbackSimulation(obj , output , step , outStream , inStream ));
106
108
end
107
109
108
110
daq.Clock = daq ;
111
+
112
+ % Make sure the unit conversions we need are available.
113
+ if ~Converters .Test(' V' , ' V' )
114
+ Converters .Register(' V' , ' V' , @(m ) m );
115
+ end
116
+ if ~Converters .Test(' mV' , ' V' )
117
+ Converters .Register(' mV' , ' V' , @(m ) m * 1e-3 );
118
+ end
119
+ if ~Converters .Test(' V' , ' mV' )
120
+ Converters .Register(' V' , ' mV' , @(m ) m * 1e3 );
121
+ end
122
+ if ~Converters .Test(' A' , ' A' )
123
+ Converters .Register(' A' , ' A' , @(m ) m );
124
+ end
125
+ if ~Converters .Test(' pA' , ' A' )
126
+ Converters .Register(' pA' , ' A' , @(m ) m * 1e- 12 );
127
+ end
128
+ if ~Converters .Test(' A' , ' pA' )
129
+ Converters .Register(' A' , ' pA' , @(m ) m * 1e12);
130
+ end
109
131
end
110
132
111
133
@@ -193,15 +215,15 @@ function addStreams(obj, device, outStreamName, inStreamName)
193
215
end
194
216
195
217
196
- function addDevice(obj , deviceName , outStreamName , inStreamName )
218
+ function addDevice(obj , deviceName , outStreamName , inStreamName , units )
197
219
import Symphony .Core .* ;
198
220
import Symphony .ExternalDevices .* ;
199
221
200
222
if isa(obj .controller .DAQController , ' Heka.HekaDAQController' ) && strncmp(outStreamName , ' DIGITAL_OUT' , 11 )
201
223
% The digital out channels for the Heka ITC share a single device.
202
224
if isempty(obj .hekaDigitalOutDevice )
203
- obj.hekaDigitalOutDevice = UnitConvertingExternalDevice(' Heka Digital Out' , ' HEKA Instruments' , obj .controller , Measurement(0 , ' V ' ));
204
- obj.hekaDigitalOutDevice.MeasurementConversionTarget = ' V ' ;
225
+ obj.hekaDigitalOutDevice = UnitConvertingExternalDevice(' Heka Digital Out' , ' HEKA Instruments' , obj .controller , Measurement(0 , units ));
226
+ obj.hekaDigitalOutDevice.MeasurementConversionTarget = units ;
205
227
obj.hekaDigitalOutDevice.Clock = obj .controller .DAQController ;
206
228
207
229
stream = obj .streamWithName(' DIGITAL_OUT.1' , true );
@@ -212,8 +234,8 @@ function addDevice(obj, deviceName, outStreamName, inStreamName)
212
234
obj.hekaDigitalOutNames{end + 1 } = deviceName ;
213
235
obj .hekaDigitalOutChannels(end + 1 ) = str2double(outStreamName(end ));
214
236
else
215
- dev = UnitConvertingExternalDevice(deviceName , ' unknown' , obj .controller , Measurement(0 , ' V ' ));
216
- dev.MeasurementConversionTarget = ' V ' ;
237
+ dev = UnitConvertingExternalDevice(deviceName , ' unknown' , obj .controller , Measurement(0 , units ));
238
+ dev.MeasurementConversionTarget = units ;
217
239
dev.Clock = obj .controller .DAQController ;
218
240
219
241
obj .addStreams(dev , outStreamName , inStreamName );
0 commit comments