Browse Source

Distinguish hub port and enable channel hiding

Neal Wilson 7 years ago
parent
commit
dcb72ed41d
1 changed files with 49 additions and 7 deletions
  1. 49
    7
      src/phidget22.w

+ 49
- 7
src/phidget22.w View File

148
 PhidgetPointerIntOut getChannel;
148
 PhidgetPointerIntOut getChannel;
149
 PhidgetPointerIntOut getChannelClass;
149
 PhidgetPointerIntOut getChannelClass;
150
 PhidgetPointerIntOut getChannelSubclass;
150
 PhidgetPointerIntOut getChannelSubclass;
151
+PhidgetPointerIntOut getHubPort;
151
 PhidgetPointer closeManager;
152
 PhidgetPointer closeManager;
152
 PhidgetPointer deleteManager;
153
 PhidgetPointer deleteManager;
153
 
154
 
163
    (getChannel = (PhidgetPointerIntOut) driver.resolve("Phidget_getChannel")) == 0 ||
164
    (getChannel = (PhidgetPointerIntOut) driver.resolve("Phidget_getChannel")) == 0 ||
164
    (getChannelClass = (PhidgetPointerIntOut) driver.resolve("Phidget_getChannelClass")) == 0 ||
165
    (getChannelClass = (PhidgetPointerIntOut) driver.resolve("Phidget_getChannelClass")) == 0 ||
165
    (getChannelSubclass = (PhidgetPointerIntOut) driver.resolve("Phidget_getChannelSubclass")) == 0 ||
166
    (getChannelSubclass = (PhidgetPointerIntOut) driver.resolve("Phidget_getChannelSubclass")) == 0 ||
167
+   (getHubPort = (PhidgetPointerIntOut) driver.resolve("Phidget_getHubPort")) == 0 ||
166
    (closeManager = (PhidgetPointer) driver.resolve("PhidgetManager_close")) == 0 ||
168
    (closeManager = (PhidgetPointer) driver.resolve("PhidgetManager_close")) == 0 ||
167
    (deleteManager = (PhidgetPointer) driver.resolve("PhidgetManager_delete")) == 0)
169
    (deleteManager = (PhidgetPointer) driver.resolve("PhidgetManager_delete")) == 0)
168
 {
170
 {
231
 	int channel;
233
 	int channel;
232
 	int channelClass;
234
 	int channelClass;
233
 	int channelSubclass;
235
 	int channelSubclass;
236
+	int hubPort;
234
 	
237
 	
235
 	getDeviceName(device, &deviceName);
238
 	getDeviceName(device, &deviceName);
236
 	getDeviceSerialNumber(device, &deviceSerialNumber);
239
 	getDeviceSerialNumber(device, &deviceSerialNumber);
237
 	getChannel(device, &channel);
240
 	getChannel(device, &channel);
238
 	getChannelClass(device, &channelClass);
241
 	getChannelClass(device, &channelClass);
239
 	getChannelSubclass(device, &channelSubclass);
242
 	getChannelSubclass(device, &channelSubclass);
243
+	getHubPort(device, &hubPort);
240
 	
244
 	
241
 	QMap<QString,QVariant> itemData;
245
 	QMap<QString,QVariant> itemData;
242
 	
246
 	
246
 		itemData.insert("channel", QString("%1").arg(channel));
250
 		itemData.insert("channel", QString("%1").arg(channel));
247
 		itemData.insert("class", QString("%1").arg(channelClass));
251
 		itemData.insert("class", QString("%1").arg(channelClass));
248
 		itemData.insert("subclass", QString("%1").arg(channelSubclass));
252
 		itemData.insert("subclass", QString("%1").arg(channelSubclass));
253
+		itemData.insert("hubport", QString("%1").arg(hubPort));
249
 		addItem(QString("%1: %2").arg(deviceName).arg(channel), QVariant(itemData));
254
 		addItem(QString("%1: %2").arg(deviceName).arg(channel), QVariant(itemData));
250
 	}
255
 	}
251
 }
256
 }
301
 		void changeSelectedChannel(int index);
306
 		void changeSelectedChannel(int index);
302
 		void updateSerialNumber(const QString &value);
307
 		void updateSerialNumber(const QString &value);
303
 		void updateChannel(const QString &value);
308
 		void updateChannel(const QString &value);
309
+		void updateHubPort(const QString &value);
304
 		void updateColumnName(const QString &value);
310
 		void updateColumnName(const QString &value);
305
 		void updateChannelType(int value);
311
 		void updateChannelType(int value);
306
 		void updateTCType(int value);
312
 		void updateTCType(int value);
307
 		void updateRTDType(int value);
313
 		void updateRTDType(int value);
308
 		void updateRTDWiring(int value);
314
 		void updateRTDWiring(int value);
315
+		void updateHidden(int value);
309
 	private:
316
 	private:
310
 		PhidgetChannelSelector *channelSelector;
317
 		PhidgetChannelSelector *channelSelector;
311
 		QLineEdit *serialNumber;
318
 		QLineEdit *serialNumber;
312
 		QLineEdit *channel;
319
 		QLineEdit *channel;
320
+		QLineEdit *hubPort;
313
 		QComboBox *subtype;
321
 		QComboBox *subtype;
314
 		QStackedLayout *subtypeLayout;
322
 		QStackedLayout *subtypeLayout;
315
 		QComboBox *tctype;
323
 		QComboBox *tctype;
326
 	channelSelector(new PhidgetChannelSelector),
334
 	channelSelector(new PhidgetChannelSelector),
327
 	serialNumber(new QLineEdit),
335
 	serialNumber(new QLineEdit),
328
 	channel(new QLineEdit),
336
 	channel(new QLineEdit),
337
+	hubPort(new QLineEdit),
329
 	subtype(new QComboBox),
338
 	subtype(new QComboBox),
330
 	subtypeLayout(new QStackedLayout),
339
 	subtypeLayout(new QStackedLayout),
331
 	tctype(new QComboBox),
340
 	tctype(new QComboBox),
340
 	subtype->addItem(tr("Thermocouple"), QVariant(33));
349
 	subtype->addItem(tr("Thermocouple"), QVariant(33));
341
 	layout->addRow(tr("Channels:"), channelSelector);
350
 	layout->addRow(tr("Channels:"), channelSelector);
342
 	layout->addRow(tr("Column Name:"), columnName);
351
 	layout->addRow(tr("Column Name:"), columnName);
352
+	QCheckBox *hidden = new QCheckBox(tr("Hide channel"));
353
+	layout->addRow(hidden);
343
 	layout->addRow(tr("Serial Number:"), serialNumber);
354
 	layout->addRow(tr("Serial Number:"), serialNumber);
355
+	layout->addRow(tr("Hub Port:"), hubPort);
344
 	layout->addRow(tr("Channel Number:"), channel);
356
 	layout->addRow(tr("Channel Number:"), channel);
345
 	layout->addRow(tr("Channel Type:"), subtype);
357
 	layout->addRow(tr("Channel Type:"), subtype);
346
 	serialNumber->setEnabled(false);
358
 	serialNumber->setEnabled(false);
409
 		    rtdwiring->setCurrentIndex(rtdwiring->
421
 		    rtdwiring->setCurrentIndex(rtdwiring->
410
 			    findData(QVariant(node.attribute("value").toInt())));
422
 			    findData(QVariant(node.attribute("value").toInt())));
411
 	    }
423
 	    }
424
+	    else if(node.attribute("name") == "hubport")
425
+	    {
426
+		    hubPort->setText(node.attribute("value"));
427
+	    }
428
+	    else if(node.attribute("name") == "hidden")
429
+	    {
430
+		    hidden->setCheckState(node.attribute("value") == "true" ? Qt::Checked : Qt::Unchecked);
431
+	    }
412
     }
432
     }
413
     outerLayout->addLayout(subtypeLayout);
433
     outerLayout->addLayout(subtypeLayout);
414
 	setLayout(outerLayout);
434
 	setLayout(outerLayout);
430
             this, SLOT(updateRTDType(int)));
450
             this, SLOT(updateRTDType(int)));
431
     connect(rtdwiring, SIGNAL(currentIndexChanged(int)),
451
     connect(rtdwiring, SIGNAL(currentIndexChanged(int)),
432
             this, SLOT(updateRTDWiring(int)));
452
             this, SLOT(updateRTDWiring(int)));
453
+    connect(hubPort, SIGNAL(textChanged(QString)),
454
+            this, SLOT(updateHubPort(QString)));
455
+    connect(hidden, SIGNAL(stateChanged(int)),
456
+            this, SLOT(updateHidden(int)));
433
 }
457
 }
434
 
458
 
435
 @ The combo box provides a convenient way to populate required configuration
459
 @ The combo box provides a convenient way to populate required configuration
443
 	channel->setText(data.value("channel").toString());
467
 	channel->setText(data.value("channel").toString());
444
 	subtype->setCurrentIndex(subtype->
468
 	subtype->setCurrentIndex(subtype->
445
 		findData(QVariant(data.value("subclass").toString().toInt())));
469
 		findData(QVariant(data.value("subclass").toString().toInt())));
470
+	hubPort->setText(data.value("hubport").toString());
446
 }
471
 }
447
 
472
 
448
 @ Channel configuration settings are persisted as they are updated.
473
 @ Channel configuration settings are persisted as they are updated.
483
 	updateAttribute("rtdwiring", rtdwiring->itemData(value).toString());
508
 	updateAttribute("rtdwiring", rtdwiring->itemData(value).toString());
484
 }
509
 }
485
 
510
 
511
+void PhidgetChannelConfWidget::updateHubPort(const QString &value)
512
+{
513
+	updateAttribute("hubport", value);
514
+}
515
+
516
+void PhidgetChannelConfWidget::updateHidden(int value)
517
+{
518
+	updateAttribute("hidden", value == 0 ? "false" : "true");
519
+}
520
+
486
 @ The hardware communnications code provides a single class that reads the
521
 @ The hardware communnications code provides a single class that reads the
487
 saved configuration data, creates |Channel| objects for the logging view to
522
 saved configuration data, creates |Channel| objects for the logging view to
488
 connect various things to, and pushes data out on those channels. Internally,
523
 connect various things to, and pushes data out on those channels. Internally,
500
 	int serialNumber;
535
 	int serialNumber;
501
 	int channelNumber;
536
 	int channelNumber;
502
 	int channelType;
537
 	int channelType;
538
+	int hubPort;
503
 	int tcType;
539
 	int tcType;
504
 	int rtdType;
540
 	int rtdType;
505
 	int wiring;
541
 	int wiring;
531
 		PhidgetPointer p_createTemperatureSensor;
567
 		PhidgetPointer p_createTemperatureSensor;
532
 		PhidgetPointerIntIn p_setSerialNumber;
568
 		PhidgetPointerIntIn p_setSerialNumber;
533
 		PhidgetPointerIntIn p_setChannelNumber;
569
 		PhidgetPointerIntIn p_setChannelNumber;
570
+		PhidgetPointerIntIn p_setHubPort;
534
 		PhidgetPointerIntIn p_setTCType;
571
 		PhidgetPointerIntIn p_setTCType;
535
 		PhidgetPointerIntIn p_setRTDType;
572
 		PhidgetPointerIntIn p_setRTDType;
536
 		PhidgetPointerIntIn p_setRTDWiring;
573
 		PhidgetPointerIntIn p_setRTDWiring;
565
 			c->indicatorLabel =
602
 			c->indicatorLabel =
566
 				model->data(channelIndex, Qt::DisplayRole).toString();
603
 				model->data(channelIndex, Qt::DisplayRole).toString();
567
 			c->device = NULL;
604
 			c->device = NULL;
605
+			c->hubPort = -1;
568
 			for(int j = 0; j < channelConfigData.size(); j++)
606
 			for(int j = 0; j < channelConfigData.size(); j++)
569
 			{
607
 			{
570
 				QDomElement node = channelConfigData.at(j).toElement();
608
 				QDomElement node = channelConfigData.at(j).toElement();
600
 				{
638
 				{
601
 					c->columnName = node.attribute("value");
639
 					c->columnName = node.attribute("value");
602
 				}
640
 				}
641
+				else if(node.attribute("name") == "hubport")
642
+				{
643
+					c->hubPort = node.attribute("value").toInt();
644
+				}
603
 			}
645
 			}
604
 			channelConfiguration.append(c);
646
 			channelConfiguration.append(c);
605
 		}
647
 		}
623
 @ A little more glue allows the host environment to properly set up UI
665
 @ A little more glue allows the host environment to properly set up UI
624
 elements.
666
 elements.
625
 
667
 
626
-TODO: Provide a configuration control for channel hiding and then change this
627
-to return whatever has been configured rather than assume all channels must be
628
-visible.
629
-
630
 @<Phidget implementation@>=
668
 @<Phidget implementation@>=
631
 bool Phidget22::isChannelHidden(int channel)
669
 bool Phidget22::isChannelHidden(int channel)
632
 {
670
 {
633
-	// return channelConiguration.at(channel)->hidden;
634
-	return false;
671
+	return channelConfiguration.at(channel)->hidden;
635
 }
672
 }
636
 
673
 
637
 QString Phidget22::channelColumnName(int channel)
674
 QString Phidget22::channelColumnName(int channel)
670
 		(p_setNewDataCallback = (PhidgetPointerVCPointer)driver.resolve("PhidgetTemperatureSensor_setOnTemperatureChangeHandler")) == 0 ||
707
 		(p_setNewDataCallback = (PhidgetPointerVCPointer)driver.resolve("PhidgetTemperatureSensor_setOnTemperatureChangeHandler")) == 0 ||
671
 		(p_open = (PhidgetPointerIntIn)driver.resolve("Phidget_openWaitForAttachment")) == 0 ||
708
 		(p_open = (PhidgetPointerIntIn)driver.resolve("Phidget_openWaitForAttachment")) == 0 ||
672
 		(p_close = (PhidgetPointer)driver.resolve("Phidget_close")) == 0 ||
709
 		(p_close = (PhidgetPointer)driver.resolve("Phidget_close")) == 0 ||
673
-		(p_delete = (PhidgetPointer)driver.resolve("PhidgetTemperatureSensor_delete")) == 0)
710
+		(p_delete = (PhidgetPointer)driver.resolve("PhidgetTemperatureSensor_delete")) == 0 ||
711
+		(p_setHubPort = (PhidgetPointerIntIn)driver.resolve("Phidget_setHubPort")) == 0)
674
 	{
712
 	{
675
 		QMessageBox::critical(NULL, tr("Typica: Link error"),
713
 		QMessageBox::critical(NULL, tr("Typica: Link error"),
676
 		                      tr("Failed to link a required symbol in phidget22."));
714
 		                      tr("Failed to link a required symbol in phidget22."));
694
 			default:
732
 			default:
695
 				break;
733
 				break;
696
 		}
734
 		}
735
+		if(c->hubPort >= 0)
736
+		{
737
+			p_setHubPort(c->device, c->hubPort);
738
+		}
697
 		p_setNewDataCallback(c->device, Phidget22ValueCallback, c->channel);
739
 		p_setNewDataCallback(c->device, Phidget22ValueCallback, c->channel);
698
 		p_open(c->device, 5000);
740
 		p_open(c->device, 5000);
699
 	}
741
 	}

Loading…
Cancel
Save