Pārlūkot izejas kodu

DATAQ SDK integration

Neal Wilson 11 gadus atpakaļ
vecāks
revīzija
5ae5f756c1
2 mainītis faili ar 55 papildinājumiem un 3 dzēšanām
  1. 47
    0
      config/Windows/productionroaster.xml
  2. 8
    3
      src/typica.w

+ 47
- 0
config/Windows/productionroaster.xml Parādīt failu

@@ -66,6 +66,7 @@
66 66
 		var channels = new Array();
67 67
 		var annotationButtons = new Array();
68 68
 		var nidevices = new Array();
69
+		var dataqsdkdevices = new Array();
69 70
 		var temperatureDisplays = new Array();
70 71
 		var columnNames = new Array();
71 72
 		var modbusdevices = new Array();
@@ -223,6 +224,47 @@
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 268
 				else if(driverReference.driver == "modbusrtu")
227 269
 				{
228 270
 					var device = new ModbusRTUDevice(configModel, driverIndex);
@@ -462,8 +504,13 @@
462 504
 			{
463 505
 				modbusdevices[i].deleteLater();
464 506
 			}
507
+			for(var i = 0; i < dataqsdkdevices.length; i++)
508
+			{
509
+				dataqsdkdevices[i].deleteLater();
510
+			}
465 511
 			delete nidevices;
466 512
 			delete modbusdevices;
513
+			delete dataqsdkdevices;
467 514
             window.saveSizeAndPosition("window");
468 515
             vsplit.saveState("script/mainSplitter");
469 516
             isplit.saveState("script/instrumentSplitter");

+ 8
- 3
src/typica.w Parādīt failu

@@ -6659,6 +6659,10 @@ the range $\lbrack L_1, U_1 \rbrack$.
6659 6659
 Some use cases require a closed range but others require that this constraint
6660 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 6666
 @<Class declarations@>=
6663 6667
 class LinearCalibrator : public QObject@/
6664 6668
 {@/
@@ -6689,6 +6693,7 @@ class LinearCalibrator : public QObject@/
6689 6693
 		Measurement newMeasurement(Measurement measure);
6690 6694
 	@t\4@>@[signals:@]@;
6691 6695
 		void measurement(Measurement measure);
6696
+		void newData(Measurement measure);
6692 6697
 	private:@/
6693 6698
 		double Lo1;
6694 6699
 		double Lo2;
@@ -6706,7 +6711,7 @@ constructed |LinearCalibrator| which should quickly be changed.
6706 6711
 LinearCalibrator::LinearCalibrator(QObject *parent) :
6707 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 6717
 @ The functional portion of the class is in the |newMeasurement()| slot. This
@@ -11707,7 +11712,7 @@ setOrganizationDomain("wilsonscoffee.com");
11707 11712
 setApplicationName(PROGRAM_NAME);
11708 11713
 
11709 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 11716
 details, see the Qt Linguist manual.
11712 11717
 
11713 11718
 @<Load translation objects@>=
@@ -11723,7 +11728,7 @@ if(app.load(QString("%1_%2").arg("Typica").arg(QLocale::system().name())))
11723 11728
 }
11724 11729
 
11725 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 11732
 the one that already exists.
11728 11733
 
11729 11734
 @<Set up the scripting engine@>=

Notiek ielāde…
Atcelt
Saglabāt