|
@@ -148,6 +148,7 @@ PhidgetPointerIntOut getDeviceSerialNumber;
|
148
|
148
|
PhidgetPointerIntOut getChannel;
|
149
|
149
|
PhidgetPointerIntOut getChannelClass;
|
150
|
150
|
PhidgetPointerIntOut getChannelSubclass;
|
|
151
|
+PhidgetPointerIntOut getHubPort;
|
151
|
152
|
PhidgetPointer closeManager;
|
152
|
153
|
PhidgetPointer deleteManager;
|
153
|
154
|
|
|
@@ -163,6 +164,7 @@ if((createManager = (PhidgetPointer) driver.resolve("PhidgetManager_create")) ==
|
163
|
164
|
(getChannel = (PhidgetPointerIntOut) driver.resolve("Phidget_getChannel")) == 0 ||
|
164
|
165
|
(getChannelClass = (PhidgetPointerIntOut) driver.resolve("Phidget_getChannelClass")) == 0 ||
|
165
|
166
|
(getChannelSubclass = (PhidgetPointerIntOut) driver.resolve("Phidget_getChannelSubclass")) == 0 ||
|
|
167
|
+ (getHubPort = (PhidgetPointerIntOut) driver.resolve("Phidget_getHubPort")) == 0 ||
|
166
|
168
|
(closeManager = (PhidgetPointer) driver.resolve("PhidgetManager_close")) == 0 ||
|
167
|
169
|
(deleteManager = (PhidgetPointer) driver.resolve("PhidgetManager_delete")) == 0)
|
168
|
170
|
{
|
|
@@ -231,12 +233,14 @@ void PhidgetChannelSelector::addChannel(void *device)
|
231
|
233
|
int channel;
|
232
|
234
|
int channelClass;
|
233
|
235
|
int channelSubclass;
|
|
236
|
+ int hubPort;
|
234
|
237
|
|
235
|
238
|
getDeviceName(device, &deviceName);
|
236
|
239
|
getDeviceSerialNumber(device, &deviceSerialNumber);
|
237
|
240
|
getChannel(device, &channel);
|
238
|
241
|
getChannelClass(device, &channelClass);
|
239
|
242
|
getChannelSubclass(device, &channelSubclass);
|
|
243
|
+ getHubPort(device, &hubPort);
|
240
|
244
|
|
241
|
245
|
QMap<QString,QVariant> itemData;
|
242
|
246
|
|
|
@@ -246,6 +250,7 @@ void PhidgetChannelSelector::addChannel(void *device)
|
246
|
250
|
itemData.insert("channel", QString("%1").arg(channel));
|
247
|
251
|
itemData.insert("class", QString("%1").arg(channelClass));
|
248
|
252
|
itemData.insert("subclass", QString("%1").arg(channelSubclass));
|
|
253
|
+ itemData.insert("hubport", QString("%1").arg(hubPort));
|
249
|
254
|
addItem(QString("%1: %2").arg(deviceName).arg(channel), QVariant(itemData));
|
250
|
255
|
}
|
251
|
256
|
}
|
|
@@ -301,15 +306,18 @@ class PhidgetChannelConfWidget : public BasicDeviceConfigurationWidget
|
301
|
306
|
void changeSelectedChannel(int index);
|
302
|
307
|
void updateSerialNumber(const QString &value);
|
303
|
308
|
void updateChannel(const QString &value);
|
|
309
|
+ void updateHubPort(const QString &value);
|
304
|
310
|
void updateColumnName(const QString &value);
|
305
|
311
|
void updateChannelType(int value);
|
306
|
312
|
void updateTCType(int value);
|
307
|
313
|
void updateRTDType(int value);
|
308
|
314
|
void updateRTDWiring(int value);
|
|
315
|
+ void updateHidden(int value);
|
309
|
316
|
private:
|
310
|
317
|
PhidgetChannelSelector *channelSelector;
|
311
|
318
|
QLineEdit *serialNumber;
|
312
|
319
|
QLineEdit *channel;
|
|
320
|
+ QLineEdit *hubPort;
|
313
|
321
|
QComboBox *subtype;
|
314
|
322
|
QStackedLayout *subtypeLayout;
|
315
|
323
|
QComboBox *tctype;
|
|
@@ -326,6 +334,7 @@ PhidgetChannelConfWidget::PhidgetChannelConfWidget(DeviceTreeModel *model,
|
326
|
334
|
channelSelector(new PhidgetChannelSelector),
|
327
|
335
|
serialNumber(new QLineEdit),
|
328
|
336
|
channel(new QLineEdit),
|
|
337
|
+ hubPort(new QLineEdit),
|
329
|
338
|
subtype(new QComboBox),
|
330
|
339
|
subtypeLayout(new QStackedLayout),
|
331
|
340
|
tctype(new QComboBox),
|
|
@@ -340,7 +349,10 @@ PhidgetChannelConfWidget::PhidgetChannelConfWidget(DeviceTreeModel *model,
|
340
|
349
|
subtype->addItem(tr("Thermocouple"), QVariant(33));
|
341
|
350
|
layout->addRow(tr("Channels:"), channelSelector);
|
342
|
351
|
layout->addRow(tr("Column Name:"), columnName);
|
|
352
|
+ QCheckBox *hidden = new QCheckBox(tr("Hide channel"));
|
|
353
|
+ layout->addRow(hidden);
|
343
|
354
|
layout->addRow(tr("Serial Number:"), serialNumber);
|
|
355
|
+ layout->addRow(tr("Hub Port:"), hubPort);
|
344
|
356
|
layout->addRow(tr("Channel Number:"), channel);
|
345
|
357
|
layout->addRow(tr("Channel Type:"), subtype);
|
346
|
358
|
serialNumber->setEnabled(false);
|
|
@@ -409,6 +421,14 @@ PhidgetChannelConfWidget::PhidgetChannelConfWidget(DeviceTreeModel *model,
|
409
|
421
|
rtdwiring->setCurrentIndex(rtdwiring->
|
410
|
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
|
433
|
outerLayout->addLayout(subtypeLayout);
|
414
|
434
|
setLayout(outerLayout);
|
|
@@ -430,6 +450,10 @@ PhidgetChannelConfWidget::PhidgetChannelConfWidget(DeviceTreeModel *model,
|
430
|
450
|
this, SLOT(updateRTDType(int)));
|
431
|
451
|
connect(rtdwiring, SIGNAL(currentIndexChanged(int)),
|
432
|
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
|
459
|
@ The combo box provides a convenient way to populate required configuration
|
|
@@ -443,6 +467,7 @@ void PhidgetChannelConfWidget::changeSelectedChannel(int index)
|
443
|
467
|
channel->setText(data.value("channel").toString());
|
444
|
468
|
subtype->setCurrentIndex(subtype->
|
445
|
469
|
findData(QVariant(data.value("subclass").toString().toInt())));
|
|
470
|
+ hubPort->setText(data.value("hubport").toString());
|
446
|
471
|
}
|
447
|
472
|
|
448
|
473
|
@ Channel configuration settings are persisted as they are updated.
|
|
@@ -483,6 +508,16 @@ void PhidgetChannelConfWidget::updateRTDWiring(int value)
|
483
|
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
|
521
|
@ The hardware communnications code provides a single class that reads the
|
487
|
522
|
saved configuration data, creates |Channel| objects for the logging view to
|
488
|
523
|
connect various things to, and pushes data out on those channels. Internally,
|
|
@@ -500,6 +535,7 @@ struct PhidgetChannelData
|
500
|
535
|
int serialNumber;
|
501
|
536
|
int channelNumber;
|
502
|
537
|
int channelType;
|
|
538
|
+ int hubPort;
|
503
|
539
|
int tcType;
|
504
|
540
|
int rtdType;
|
505
|
541
|
int wiring;
|
|
@@ -531,6 +567,7 @@ class Phidget22 : public QObject
|
531
|
567
|
PhidgetPointer p_createTemperatureSensor;
|
532
|
568
|
PhidgetPointerIntIn p_setSerialNumber;
|
533
|
569
|
PhidgetPointerIntIn p_setChannelNumber;
|
|
570
|
+ PhidgetPointerIntIn p_setHubPort;
|
534
|
571
|
PhidgetPointerIntIn p_setTCType;
|
535
|
572
|
PhidgetPointerIntIn p_setRTDType;
|
536
|
573
|
PhidgetPointerIntIn p_setRTDWiring;
|
|
@@ -565,6 +602,7 @@ Phidget22::Phidget22(const QModelIndex &index) : QObject(NULL)
|
565
|
602
|
c->indicatorLabel =
|
566
|
603
|
model->data(channelIndex, Qt::DisplayRole).toString();
|
567
|
604
|
c->device = NULL;
|
|
605
|
+ c->hubPort = -1;
|
568
|
606
|
for(int j = 0; j < channelConfigData.size(); j++)
|
569
|
607
|
{
|
570
|
608
|
QDomElement node = channelConfigData.at(j).toElement();
|
|
@@ -600,6 +638,10 @@ Phidget22::Phidget22(const QModelIndex &index) : QObject(NULL)
|
600
|
638
|
{
|
601
|
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
|
646
|
channelConfiguration.append(c);
|
605
|
647
|
}
|
|
@@ -623,15 +665,10 @@ Channel* Phidget22::getChannel(int channel)
|
623
|
665
|
@ A little more glue allows the host environment to properly set up UI
|
624
|
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
|
668
|
@<Phidget implementation@>=
|
631
|
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
|
674
|
QString Phidget22::channelColumnName(int channel)
|
|
@@ -670,7 +707,8 @@ void Phidget22::start()
|
670
|
707
|
(p_setNewDataCallback = (PhidgetPointerVCPointer)driver.resolve("PhidgetTemperatureSensor_setOnTemperatureChangeHandler")) == 0 ||
|
671
|
708
|
(p_open = (PhidgetPointerIntIn)driver.resolve("Phidget_openWaitForAttachment")) == 0 ||
|
672
|
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
|
713
|
QMessageBox::critical(NULL, tr("Typica: Link error"),
|
676
|
714
|
tr("Failed to link a required symbol in phidget22."));
|
|
@@ -694,6 +732,10 @@ void Phidget22::start()
|
694
|
732
|
default:
|
695
|
733
|
break;
|
696
|
734
|
}
|
|
735
|
+ if(c->hubPort >= 0)
|
|
736
|
+ {
|
|
737
|
+ p_setHubPort(c->device, c->hubPort);
|
|
738
|
+ }
|
697
|
739
|
p_setNewDataCallback(c->device, Phidget22ValueCallback, c->channel);
|
698
|
740
|
p_open(c->device, 5000);
|
699
|
741
|
}
|