git-svn-id: svn://db.shs.com.ru/libs@146 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
#include <QSqlError>
|
#include <QSqlError>
|
||||||
#include <QSqlRecord>
|
#include <QSqlRecord>
|
||||||
|
#include <QCheckBox>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
|
||||||
@@ -24,6 +25,15 @@ ConnectionEdit::ConnectionEdit(QWidget * parent): QDialog(parent) {
|
|||||||
ui->comboMode->addItem(PI2QString(e.name + " (" + PIString::fromNumber(e.value) + ")"), QVariant::fromValue<int>(e.value));
|
ui->comboMode->addItem(PI2QString(e.name + " (" + PIString::fromNumber(e.value) + ")"), QVariant::fromValue<int>(e.value));
|
||||||
}
|
}
|
||||||
ui->comboMode->setCurrentIndex(ui->comboMode->count() - 1);
|
ui->comboMode->setCurrentIndex(ui->comboMode->count() - 1);
|
||||||
|
ei = PICodeInfo::enumsInfo->value("PIIODevice::DeviceOption");
|
||||||
|
if (ei) {
|
||||||
|
piForeachC (PICodeInfo::EnumeratorInfo & e, ei->members) {
|
||||||
|
QCheckBox * cb = new QCheckBox();
|
||||||
|
cb->setText(PI2QString(e.name + " (" + PIString::fromNumber(e.value) + ")"));
|
||||||
|
cb->setProperty("__value", e.value);
|
||||||
|
ui->layoutOptions->addWidget(cb);
|
||||||
|
}
|
||||||
|
}
|
||||||
ei = PICodeInfo::enumsInfo->value("PIPacketExtractor::SplitMode");
|
ei = PICodeInfo::enumsInfo->value("PIPacketExtractor::SplitMode");
|
||||||
if (ei) {
|
if (ei) {
|
||||||
piForeachC (PICodeInfo::EnumeratorInfo & e, ei->members)
|
piForeachC (PICodeInfo::EnumeratorInfo & e, ei->members)
|
||||||
@@ -171,6 +181,7 @@ void ConnectionEdit::selectionChanged() {
|
|||||||
ui->lineDevice->setText(di->name());
|
ui->lineDevice->setText(di->name());
|
||||||
ui->linePath->setEditText(di->path());
|
ui->linePath->setEditText(di->path());
|
||||||
ui->spinDeviceDT->setValue(di->disconnectTimeout());
|
ui->spinDeviceDT->setValue(di->disconnectTimeout());
|
||||||
|
setOptions(di->options());
|
||||||
}
|
}
|
||||||
if (type == __CV_Filter) {
|
if (type == __CV_Filter) {
|
||||||
ui->tabWidget->setCurrentIndex(1);
|
ui->tabWidget->setCurrentIndex(1);
|
||||||
@@ -219,6 +230,7 @@ void ConnectionEdit::applyDevice(DeviceItem * b) {
|
|||||||
}
|
}
|
||||||
b->setName(n);
|
b->setName(n);
|
||||||
b->setMode(PIIODevice::DeviceMode(ui->comboMode->itemData(ui->comboMode->currentIndex()).toInt()));
|
b->setMode(PIIODevice::DeviceMode(ui->comboMode->itemData(ui->comboMode->currentIndex()).toInt()));
|
||||||
|
b->setOptions(PIIODevice::DeviceOptions(getOptions()));
|
||||||
b->setPath(ui->linePath->currentText());
|
b->setPath(ui->linePath->currentText());
|
||||||
b->setDisconnectTimeout(ui->spinDeviceDT->value());
|
b->setDisconnectTimeout(ui->spinDeviceDT->value());
|
||||||
recreateConnection();
|
recreateConnection();
|
||||||
@@ -233,6 +245,29 @@ void ConnectionEdit::applySender(SenderItem * b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ConnectionEdit::getOptions() const {
|
||||||
|
int ret(0);
|
||||||
|
for (int i = 0; i < ui->layoutOptions->count(); ++i) {
|
||||||
|
QCheckBox * cb = qobject_cast<QCheckBox*>(ui->layoutOptions->itemAt(i)->widget());
|
||||||
|
if (!cb) continue;
|
||||||
|
if (cb->isChecked())
|
||||||
|
ret |= cb->property("__value").toInt();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ConnectionEdit::setOptions(int o) {
|
||||||
|
for (int i = 0; i < ui->layoutOptions->count(); ++i) {
|
||||||
|
QCheckBox * cb = qobject_cast<QCheckBox*>(ui->layoutOptions->itemAt(i)->widget());
|
||||||
|
if (!cb) continue;
|
||||||
|
int cbf = cb->property("__value").toInt();
|
||||||
|
//qDebug() << cbf;
|
||||||
|
cb->setChecked((o & cbf) == cbf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ConnectionEdit::recreateConnection() {
|
void ConnectionEdit::recreateConnection() {
|
||||||
//qDebug() << "recreate";
|
//qDebug() << "recreate";
|
||||||
if (loading) return;
|
if (loading) return;
|
||||||
@@ -247,6 +282,7 @@ void ConnectionEdit::recreateConnection() {
|
|||||||
//qDebug() << di->path();
|
//qDebug() << di->path();
|
||||||
PIIODevice * dev = conn->addDevice(Q2PIString(di->path()), di->mode());
|
PIIODevice * dev = conn->addDevice(Q2PIString(di->path()), di->mode());
|
||||||
if (!dev) continue;
|
if (!dev) continue;
|
||||||
|
dev->setOptions(di->options());
|
||||||
conn->setDeviceName(dev, Q2PIString(di->name()));
|
conn->setDeviceName(dev, Q2PIString(di->name()));
|
||||||
PIDiagnostics * diag = conn->diagnostic(dev);
|
PIDiagnostics * diag = conn->diagnostic(dev);
|
||||||
if (diag) diag->setDisconnectTimeout(di->disconnectTimeout());
|
if (diag) diag->setDisconnectTimeout(di->disconnectTimeout());
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ private:
|
|||||||
void applyFilter(FilterItem * b);
|
void applyFilter(FilterItem * b);
|
||||||
void applyDevice(DeviceItem * b);
|
void applyDevice(DeviceItem * b);
|
||||||
void applySender(SenderItem * b);
|
void applySender(SenderItem * b);
|
||||||
|
int getOptions() const;
|
||||||
|
void setOptions(int o);
|
||||||
|
|
||||||
Ui::ConnectionEdit * ui;
|
Ui::ConnectionEdit * ui;
|
||||||
PIConnection * conn;
|
PIConnection * conn;
|
||||||
|
|||||||
@@ -63,6 +63,9 @@
|
|||||||
<property name="fieldGrowthPolicy">
|
<property name="fieldGrowthPolicy">
|
||||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="labelAlignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="labelFilter_4">
|
<widget class="QLabel" name="labelFilter_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -99,7 +102,7 @@
|
|||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QComboBox" name="comboMode"/>
|
<widget class="QComboBox" name="comboMode"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="labelFilter_13">
|
<widget class="QLabel" name="labelFilter_13">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Disconnect
|
<string>Disconnect
|
||||||
@@ -110,7 +113,7 @@ timeout:</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="spinDeviceDT">
|
<widget class="QDoubleSpinBox" name="spinDeviceDT">
|
||||||
<property name="suffix">
|
<property name="suffix">
|
||||||
<string> ms</string>
|
<string> ms</string>
|
||||||
@@ -173,6 +176,23 @@ timeout:</string>
|
|||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="labelFilter_14">
|
||||||
|
<property name="text">
|
||||||
|
<string>Options:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<layout class="QVBoxLayout" name="layoutOptions">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
@@ -16,11 +16,13 @@ public:
|
|||||||
void setName(const QString & n) {addProperty(BlockItem::Property("name", "", n)); rename();}
|
void setName(const QString & n) {addProperty(BlockItem::Property("name", "", n)); rename();}
|
||||||
void setPath(const QString & p) {addProperty(BlockItem::Property("device", "", p)); rename();}
|
void setPath(const QString & p) {addProperty(BlockItem::Property("device", "", p)); rename();}
|
||||||
void setMode(PIIODevice::DeviceMode m) {addProperty(BlockItem::Property("mode", "", int(m))); rename();}
|
void setMode(PIIODevice::DeviceMode m) {addProperty(BlockItem::Property("mode", "", int(m))); rename();}
|
||||||
|
void setOptions(PIIODevice::DeviceOptions o) {addProperty(BlockItem::Property("options", "", int(o))); rename();}
|
||||||
void setDisconnectTimeout(double v) {addProperty(BlockItem::Property("disconnectTimeout", "", v)); rename();}
|
void setDisconnectTimeout(double v) {addProperty(BlockItem::Property("disconnectTimeout", "", v)); rename();}
|
||||||
|
|
||||||
QString name() const {return propertyByName("name").value.toString();}
|
QString name() const {return propertyByName("name").value.toString();}
|
||||||
QString path() const {return propertyByName("device").value.toString();}
|
QString path() const {return propertyByName("device").value.toString();}
|
||||||
PIIODevice::DeviceMode mode() const {return PIIODevice::DeviceMode(propertyByName("mode").value.toInt());}
|
PIIODevice::DeviceMode mode() const {return PIIODevice::DeviceMode(propertyByName("mode").value.toInt());}
|
||||||
|
PIIODevice::DeviceOptions options() const {return PIIODevice::DeviceOptions(propertyByName("options").value.toInt());}
|
||||||
double disconnectTimeout() const {return PIIODevice::DeviceMode(propertyByName("disconnectTimeout").value.toDouble());}
|
double disconnectTimeout() const {return PIIODevice::DeviceMode(propertyByName("disconnectTimeout").value.toDouble());}
|
||||||
|
|
||||||
void rename();
|
void rename();
|
||||||
|
|||||||
Reference in New Issue
Block a user