Browse Source

DATAQ SDK integration

Neal Wilson 11 years ago
parent
commit
5ae5f756c1
2 changed files with 55 additions and 3 deletions
  1. 47
    0
      config/Windows/productionroaster.xml
  2. 8
    3
      src/typica.w

+ 47
- 0
config/Windows/productionroaster.xml View File

66
 		var channels = new Array();
66
 		var channels = new Array();
67
 		var annotationButtons = new Array();
67
 		var annotationButtons = new Array();
68
 		var nidevices = new Array();
68
 		var nidevices = new Array();
69
+		var dataqsdkdevices = new Array();
69
 		var temperatureDisplays = new Array();
70
 		var temperatureDisplays = new Array();
70
 		var columnNames = new Array();
71
 		var columnNames = new Array();
71
 		var modbusdevices = new Array();
72
 		var modbusdevices = new Array();
223
 						}
224
 						}
224
 					}
225
 					}
225
 				}
226
 				}
227
+				else if(driverReference.driver == "dataqsdk")
228
+				{
229
+					var device = new DataqSdkDevice(driverReference.autoSelect ? driverReference.deviceNumber : driverReference.port);
230
+					var sampleRate = 6;
231
+					if(configModel.hasChildren(driverIndex)
232
+					{
233
+						for(var j = 0; j < configModel.rowCount(driverIndex); j++)
234
+						{
235
+							var channelIndex = configModel.index(j, 0, driverIndex);
236
+							var channelReference = configModel.referenceElement(configModel.data(channelIndex, 32));
237
+							var unit;
238
+							if(channelReference.type == "Temperature") {
239
+								unit = Units.Fahrenheit;
240
+							}
241
+							else {
242
+								unit = Units.Unitless;
243
+							}
244
+							var channel = device.newChannel(unit);
245
+							var calibrator = new LinearCalibrator;
246
+							calibrator.measuredLower = channelReference.calibrationMeasuredLower;
247
+							calibrator.measuredUpper = channelReference.calibrationMeasuredUpper;
248
+							calibrator.mappedLower = channelReference.calibrationMappedLower;
249
+							calibrator.mappedUpper = channelReference.calibrationMappedUpper;
250
+							calibrator.sensitivity = channelReference.calibrationSensitivity;
251
+							calibrator.closedRange = channelReference.calibrationClosedInterval;
252
+							// device.setSmoothingEnabled(j) = channelReference.smoothing;
253
+							channel.newData.connect(calibrator.newMeasurement)
254
+							channels.push(calibrator);
255
+							columnNames.push(channelReference.column);
256
+							var indicator = new TemperatureDisplay;
257
+							temperatureDisplays.push(indicator);
258
+							var decorator = new WidgetDecorator(indicator, configModel.data(channelIndex, 0), 2);
259
+							calibrator.newData.connect(indicator.setValue);
260
+							indicatorPanel.addWidget(decorator);
261
+						}
262
+						sampleRate /= configModel.rowCount(driverIndex);
263
+					}
264
+					device.setSampleRate(sampleRate);
265
+					device.start();
266
+					dataqsdkdevices.push(device);
267
+				}
226
 				else if(driverReference.driver == "modbusrtu")
268
 				else if(driverReference.driver == "modbusrtu")
227
 				{
269
 				{
228
 					var device = new ModbusRTUDevice(configModel, driverIndex);
270
 					var device = new ModbusRTUDevice(configModel, driverIndex);
462
 			{
504
 			{
463
 				modbusdevices[i].deleteLater();
505
 				modbusdevices[i].deleteLater();
464
 			}
506
 			}
507
+			for(var i = 0; i < dataqsdkdevices.length; i++)
508
+			{
509
+				dataqsdkdevices[i].deleteLater();
510
+			}
465
 			delete nidevices;
511
 			delete nidevices;
466
 			delete modbusdevices;
512
 			delete modbusdevices;
513
+			delete dataqsdkdevices;
467
             window.saveSizeAndPosition("window");
514
             window.saveSizeAndPosition("window");
468
             vsplit.saveState("script/mainSplitter");
515
             vsplit.saveState("script/mainSplitter");
469
             isplit.saveState("script/instrumentSplitter");
516
             isplit.saveState("script/instrumentSplitter");

+ 8
- 3
src/typica.w View File

6659
 Some use cases require a closed range but others require that this constraint
6659
 Some use cases require a closed range but others require that this constraint
6660
 is loosened to allow extrapolation. Both are provided by this class.
6660
 is loosened to allow extrapolation. Both are provided by this class.
6661
 
6661
 
6662
+Starting in \pn{} 1.6 this class has both the |measurement| and the
6663
+|newData| signals. This allows a |LinearCalibrator| to be treated like a
6664
+|Channel| when used with a |DataqSdkDevice|.
6665
+
6662
 @<Class declarations@>=
6666
 @<Class declarations@>=
6663
 class LinearCalibrator : public QObject@/
6667
 class LinearCalibrator : public QObject@/
6664
 {@/
6668
 {@/
6689
 		Measurement newMeasurement(Measurement measure);
6693
 		Measurement newMeasurement(Measurement measure);
6690
 	@t\4@>@[signals:@]@;
6694
 	@t\4@>@[signals:@]@;
6691
 		void measurement(Measurement measure);
6695
 		void measurement(Measurement measure);
6696
+		void newData(Measurement measure);
6692
 	private:@/
6697
 	private:@/
6693
 		double Lo1;
6698
 		double Lo1;
6694
 		double Lo2;
6699
 		double Lo2;
6706
 LinearCalibrator::LinearCalibrator(QObject *parent) :
6711
 LinearCalibrator::LinearCalibrator(QObject *parent) :
6707
 	QObject(parent), Lo1(0), Lo2(0), Up1(1), Up2(1), sensitivitySetting(0.0), clamp(false)@/
6712
 	QObject(parent), Lo1(0), Lo2(0), Up1(1), Up2(1), sensitivitySetting(0.0), clamp(false)@/
6708
 {
6713
 {
6709
-	/* Nothing needs to be done here. */
6714
+	connect(this, SIGNAL(measurement(Measurement)), this, SIGNAL(newData(Measurement)));
6710
 }
6715
 }
6711
 
6716
 
6712
 @ The functional portion of the class is in the |newMeasurement()| slot. This
6717
 @ The functional portion of the class is in the |newMeasurement()| slot. This
11707
 setApplicationName(PROGRAM_NAME);
11712
 setApplicationName(PROGRAM_NAME);
11708
 
11713
 
11709
 @ Much of the user visible text in \pn{} is wrapped in a call to |tr()|. Such
11714
 @ Much of the user visible text in \pn{} is wrapped in a call to |tr()|. Such
11710
-text can be replaced with translated text based on the user's locale. For more
11715
+text can be replaced with translated text based on the user'@q'@>s locale. For more
11711
 details, see the Qt Linguist manual.
11716
 details, see the Qt Linguist manual.
11712
 
11717
 
11713
 @<Load translation objects@>=
11718
 @<Load translation objects@>=
11723
 }
11728
 }
11724
 
11729
 
11725
 @ We also want to be able to access the application instance from within the
11730
 @ We also want to be able to access the application instance from within the
11726
-scripting engine. We don't need to be able to create new instances, just access
11731
+scripting engine. We don'@q'@>t need to be able to create new instances, just access
11727
 the one that already exists.
11732
 the one that already exists.
11728
 
11733
 
11729
 @<Set up the scripting engine@>=
11734
 @<Set up the scripting engine@>=

Loading…
Cancel
Save