Neal Wilson 11 年之前
父節點
當前提交
ad75555a24
共有 4 個檔案被更改,包括 79 行新增34 行删除
  1. 26
    0
      config/Windows/newbatch.xml
  2. 12
    0
      config/Windows/productionroaster.xml
  3. 37
    34
      src/scales.w
  4. 4
    0
      src/typica.w

+ 26
- 0
config/Windows/newbatch.xml 查看文件

@@ -2,6 +2,7 @@
2 2
     <menu name="Batch">
3 3
         <item id="new" shortcut="Ctrl+N">New Batch…</item>
4 4
     </menu>
5
+	<layout type="horizontal">
5 6
     <layout type="vertical">
6 7
         <layout type="horizontal">
7 8
 			<label>Machine:</label>
@@ -53,6 +54,11 @@
53 54
             <button name="Save log as target profile" type="check" id="target" />
54 55
         </layout>
55 56
     </layout>
57
+	<layout type="vertical">
58
+		<layout type="vertical" id="scales" />
59
+		<stretch />
60
+	</layout>
61
+	</layout>
56 62
     <program>
57 63
         <![CDATA[
58 64
 			var unitBox = findChildObject(this, 'unit');
@@ -77,6 +83,26 @@
77 83
             var roasted = findChildObject(this, 'roasted');
78 84
             var roastwt = findChildObject(this, 'roast');
79 85
             roastwt.maximumWidth = 80;
86
+			var scalesLayout = findChildObject(this, 'scales');
87
+			scalesLayout.spacing = 10;
88
+			if(navigationwindow.loggingWindow.scales.length > 0) {
89
+				for(var i = 0; i < navigationwindow.loggingWindow.scales.length; i++) {
90
+					var scale = navigationwindow.loggingWindow.scales[i];
91
+					var label = new QLabel(" ");
92
+					var weighButton = new QPushButton();
93
+					weighButton.text = "Weigh";
94
+					weighButton.clicked.connect(scale.weigh);
95
+					label.updateMeasurement = function(m, u) {
96
+						this.text = Units.convertWeight(m, u, Units.Pound) + " lb";
97
+					};
98
+					scalesLayout.addWidget(label);
99
+					scalesLayout.addWidget(weighButton);
100
+					scale.newMeasurement.connect(function(m, u) {
101
+						label.updateMeasurement(m, u);
102
+					});
103
+					scale.weigh();
104
+				}
105
+			}
80 106
 			model.dataChanged.connect(function() {
81 107
 				green.text = table.columnSum(1, 0);
82 108
 				table.resizeColumnToContents(0);

+ 12
- 0
config/Windows/productionroaster.xml 查看文件

@@ -75,6 +75,7 @@
75 75
 		var rateoffsets = new Array();
76 76
 		var ratezeros = new Array();
77 77
 		var channelType = new Array();
78
+		window.scales = new Array();
78 79
 		var indicatorPanel = findChildObject(this, 'indicators');
79 80
 		var annotationPanel = findChildObject(this, 'controlpanel');
80 81
 		var log = findChildObject(this, 'log');
@@ -488,6 +489,17 @@
488 489
 						}
489 490
 					}
490 491
 				}
492
+				else if(driverReference.driver == "scale")
493
+				{
494
+					var scale = new SerialScale(driverReference.port);
495
+					scale.setDataBits(8);
496
+					scale.setBaudRate(driverReference.baudrate);
497
+					scale.setParity(driverReference.parity);
498
+					scale.setStopBits(driverReference.stopbits);
499
+					scale.setFlowControl(driverReference.flowcontrol);
500
+					scale.open(3);
501
+					window.scales.push(scale);
502
+				}
491 503
 			}
492 504
 		}
493 505
 		for(var i = 1; i < tabControls.length; i++)

+ 37
- 34
src/scales.w 查看文件

@@ -336,10 +336,16 @@ class SerialScaleConfWidget : public BasicDeviceConfigurationWidget
336 336
 		                                  const QModelIndex &index);
337 337
 	private slots:
338 338
 		void updatePort(const QString &newPort);
339
-		void updateBaudRate(const QString &newRate);
340
-		void updateParity(const QString &newParity);
341
-		void updateFlowControl(const QString &newFlow);
342
-		void updateStopBits(const QString &newStopBits);
339
+		void updateBaudRate(const QString &rate);
340
+		void updateParity(int index);
341
+		void updateFlowControl(int index);
342
+		void updateStopBits(int index);
343
+	private:
344
+		PortSelector *port;
345
+		BaudSelector *baud;
346
+		ParitySelector *parity;
347
+		FlowSelector *flow;
348
+		StopSelector *stop;
343 349
 };
344 350
 
345 351
 @ This is very similar to other configuration widgets.
@@ -347,31 +353,28 @@ class SerialScaleConfWidget : public BasicDeviceConfigurationWidget
347 353
 @<SerialScaleConfWidget implementation@>=
348 354
 SerialScaleConfWidget::SerialScaleConfWidget(DeviceTreeModel *model,
349 355
                                              const QModelIndex &index)
350
-: BasicDeviceConfigurationWidget(model, index)
356
+: BasicDeviceConfigurationWidget(model, index),
357
+  port(new PortSelector), baud(new BaudSelector), parity(new ParitySelector),
358
+  flow(new FlowSelector), stop(new StopSelector)
351 359
 {
352 360
 	QFormLayout *layout = new QFormLayout;
353
-	PortSelector *port = new PortSelector;
354 361
 	layout->addRow(tr("Port:"), port);
355 362
 	connect(port, SIGNAL(currentIndexChanged(QString)),
356 363
 	        this, SLOT(updatePort(QString)));
357 364
 	connect(port, SIGNAL(editTextChanged(QString)),
358 365
 	        this, SLOT(updatePort(QString)));
359
-	BaudSelector *rate = new BaudSelector;
360
-	layout->addRow(tr("Baud:"), rate);
361
-	connect(rate, SIGNAL(currentIndexChanged(QString)),
366
+	layout->addRow(tr("Baud:"), baud);
367
+	connect(baud, SIGNAL(currentIndexChanged(QString)),
362 368
 	        this, SLOT(updateBaudRate(QString)));
363
-	ParitySelector *parity = new ParitySelector;
364 369
 	layout->addRow(tr("Parity:"), parity);
365
-	connect(parity, SIGNAL(currentIndexChanged(QString)),
366
-	        this, SLOT(updateParity(QString)));
367
-	FlowSelector *flow = new FlowSelector;
370
+	connect(parity, SIGNAL(currentIndexChanged(int)),
371
+	        this, SLOT(updateParity(int)));
368 372
 	layout->addRow(tr("Flow Control:"), flow);
369
-	connect(flow, SIGNAL(currentIndexChanged(QString)),
370
-	        this, SLOT(updateFlowControl(QString)));
371
-	StopSelector *stop = new StopSelector;
373
+	connect(flow, SIGNAL(currentIndexChanged(int)),
374
+	        this, SLOT(updateFlowControl(int)));
372 375
 	layout->addRow(tr("Stop Bits:"), stop);
373
-	connect(stop, SIGNAL(currentIndexChanged(QString)),
374
-	        this, SLOT(updateStopBits(QString)));
376
+	connect(stop, SIGNAL(currentIndexChanged(int)),
377
+	        this, SLOT(updateStopBits(int)));
375 378
 	@<Get device configuration data for current node@>@;
376 379
 	for(int i = 0; i < configData.size(); i++)
377 380
 	{
@@ -391,26 +394,26 @@ SerialScaleConfWidget::SerialScaleConfWidget(DeviceTreeModel *model,
391 394
 		}
392 395
 		else if(node.attribute("name") == "baudrate")
393 396
 		{
394
-			rate->setCurrentIndex(rate->findText(node.attribute("value")));
397
+			baud->setCurrentIndex(baud->findText(node.attribute("value")));
395 398
 		}
396 399
 		else if(node.attribute("name") == "parity")
397 400
 		{
398
-			parity->setCurrentIndex(parity->findText(node.attribute("value")));
401
+			parity->setCurrentIndex(parity->findData(node.attribute("value")));
399 402
 		}
400 403
 		else if(node.attribute("name") == "flowcontrol")
401 404
 		{
402
-			flow->setCurrentIndex(flow->findText(node.attribute("value")));
405
+			flow->setCurrentIndex(flow->findData(node.attribute("value")));
403 406
 		}
404 407
 		else if(node.attribute("name") == "stopbits")
405 408
 		{
406
-			stop->setCurrentIndex(stop->findText(node.attribute("value")));
409
+			stop->setCurrentIndex(stop->findData(node.attribute("value")));
407 410
 		}
408 411
 	}
409 412
 	updatePort(port->currentText());
410
-	updateBaudRate(rate->currentText());
411
-	updateParity(parity->currentText());
412
-	updateFlowControl(flow->currentText());
413
-	updateStopBits(stop->currentText());
413
+	updateBaudRate(baud->currentText());
414
+	updateParity(parity->currentIndex());
415
+	updateFlowControl(flow->currentIndex());
416
+	updateStopBits(stop->currentIndex());
414 417
 	setLayout(layout);
415 418
 }
416 419
 
@@ -422,24 +425,24 @@ void SerialScaleConfWidget::updatePort(const QString &newPort)
422 425
 	updateAttribute("port", newPort);
423 426
 }
424 427
 
425
-void SerialScaleConfWidget::updateBaudRate(const QString &newRate)
428
+void SerialScaleConfWidget::updateBaudRate(const QString &rate)
426 429
 {
427
-	updateAttribute("baudrate", newRate);
430
+	updateAttribute("baudrate", rate);
428 431
 }
429 432
 
430
-void SerialScaleConfWidget::updateParity(const QString &newParity)
433
+void SerialScaleConfWidget::updateParity(int index)
431 434
 {
432
-	updateAttribute("parity", newParity);
435
+	updateAttribute("parity", parity->itemData(index).toString());
433 436
 }
434 437
 
435
-void SerialScaleConfWidget::updateFlowControl(const QString &newFlow)
438
+void SerialScaleConfWidget::updateFlowControl(int index)
436 439
 {
437
-	updateAttribute("flowcontrol", newFlow);
440
+	updateAttribute("flowcontrol", flow->itemData(index).toString());
438 441
 }
439 442
 
440
-void SerialScaleConfWidget::updateStopBits(const QString &newStopBits)
443
+void SerialScaleConfWidget::updateStopBits(int index)
441 444
 {
442
-	updateAttribute("stopbits", newStopBits);
445
+	updateAttribute("stopbits", stop->itemData(index).toString());
443 446
 }
444 447
 
445 448
 @ The configuration widget is registered with the configuration system.

+ 4
- 0
src/typica.w 查看文件

@@ -15793,7 +15793,11 @@ PortSelector::PortSelector(QWidget *parent) : QComboBox(parent),
15793 15793
 	QextPortInfo port;
15794 15794
 	foreach(port, ports)
15795 15795
 	{
15796
+#ifdef Q_OS_WIN32
15796 15797
 		addItem(port.portName);
15798
+#else
15799
+		addItem(port.physName);
15800
+#endif
15797 15801
 	}
15798 15802
 	lister->setUpNotifications();
15799 15803
 	connect(lister, SIGNAL(deviceDiscovered(QextPortInfo)),

Loading…
取消
儲存