git-svn-id: svn://db.shs.com.ru/libs@231 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -121,7 +121,7 @@ void CDCore::k_parse(PIIODevice * d) {
|
||||
void CDCore::k_update(PIIODevice * d) {
|
||||
CDSection uk = k_;
|
||||
k_parse(d);
|
||||
bool kn = false;
|
||||
bool kn = true;
|
||||
if (!uk.isEmpty())
|
||||
if (!uk.isSameStructure(k_)) {
|
||||
piCout << "ask for save names";
|
||||
@@ -131,6 +131,7 @@ void CDCore::k_update(PIIODevice * d) {
|
||||
//piCout << k_.count() << uk.count();
|
||||
k_ = uk;
|
||||
k_.makePath();
|
||||
k_.calculate();
|
||||
K_ChangedGlobal();
|
||||
}
|
||||
|
||||
@@ -188,6 +189,13 @@ void CDUtils::CDCore::dataReceived(const PIString & from, const PIByteArray & da
|
||||
}
|
||||
|
||||
|
||||
CDCore * CDCore::instance() {
|
||||
/*static CDCore * ret = new CDCore();
|
||||
return ret;*/
|
||||
return __Core_Initializer__::__instance__;
|
||||
}
|
||||
|
||||
|
||||
void CDCore::K_Send() {
|
||||
piCoutObj << "K_Send";
|
||||
PIByteArray ba;
|
||||
|
||||
@@ -28,7 +28,7 @@ class CDCore: public PIObject
|
||||
friend class CDSection;
|
||||
friend class KInterface;
|
||||
public:
|
||||
static CDCore * instance() {return __Core_Initializer__::__instance__;}
|
||||
static CDCore * instance();
|
||||
|
||||
EVENT(K_Sended)
|
||||
EVENT(K_SendFail)
|
||||
|
||||
@@ -5,10 +5,12 @@
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
KInterface K;
|
||||
|
||||
|
||||
KInterface::KInterface() {
|
||||
core = CDCore::instance();
|
||||
//piCoutObj << core;
|
||||
//piCoutObj << (void*)this << core;
|
||||
k_file = PIStringAscii("k.dat");
|
||||
k_file_size = 0;
|
||||
CONNECTU(core, K_Sended, this, sended);
|
||||
@@ -35,11 +37,13 @@ CDType & KInterface::operator [](const PIString & name_) {
|
||||
|
||||
|
||||
CDType & KInterface::operator [](int v) {
|
||||
//piCout << (void*)this << "[]" << core;
|
||||
return core->k_[v];
|
||||
}
|
||||
|
||||
|
||||
const CDType KInterface::operator [](int v) const {
|
||||
//piCout << (void*)this << "[]" << core;
|
||||
return core->k_[v];
|
||||
}
|
||||
|
||||
|
||||
@@ -65,8 +65,8 @@ private:
|
||||
};
|
||||
|
||||
|
||||
static KInterface K;
|
||||
|
||||
}
|
||||
|
||||
extern CDUtils::KInterface K;
|
||||
|
||||
#endif // CDUTILS_K_H
|
||||
|
||||
@@ -167,7 +167,7 @@ CDSection CDParser::parse(PIIODevice * d, int cdsection_type) {
|
||||
comment.cutLeft(en.size_s() + 2).trim();
|
||||
ck.setEnumValues(sections.value(en).enumValues());
|
||||
ck.setComment(comment);
|
||||
piCout << "enum" << en << ck.enumValues();
|
||||
//piCout << "enum" << en << ck.enumValues();
|
||||
}
|
||||
}
|
||||
cs[cev] = ck;
|
||||
|
||||
@@ -301,31 +301,29 @@ void CDSection::write(PIIODevice * d, const PIString & prefix) {
|
||||
if (k.isEmpty() && s.isEmpty()) return;
|
||||
// piCout << "[CDSection] write start";
|
||||
PIString l;
|
||||
if (!k.isEmpty()) {
|
||||
if (prefix.isEmpty()) l = "[k]";
|
||||
else l = "[" + prefix + ".k]";
|
||||
l += "\n";
|
||||
if (prefix.isEmpty()) l = "[k]";
|
||||
else l = "[" + prefix + ".k]";
|
||||
l += "\n";
|
||||
d->write(l.toUTF8());
|
||||
l = "name = " + name + " \n";
|
||||
d->write(l.toUTF8());
|
||||
l = "alias = " + alias + " \n";
|
||||
d->write(l.toUTF8());
|
||||
PIMap<int, CDType>::iterator i;
|
||||
for (i = k.begin(); i != k.end(); ++i) {
|
||||
CDType & ck(i.value());
|
||||
l.clear(); l << ck.index() << ".f = " << ck.formula() << " #s " << ck.comment() << " \n";
|
||||
d->write(l.toUTF8());
|
||||
l = "name = " + name + " \n";
|
||||
l.clear(); l << ck.index() << ".v = " << ck.value() << " #" << ck.type() << " " << ck.name() << " \n";
|
||||
d->write(l.toUTF8());
|
||||
l = "alias = " + alias + " \n";
|
||||
d->write(l.toUTF8());
|
||||
PIMap<int, CDType>::iterator i;
|
||||
for (i = k.begin(); i != k.end(); ++i) {
|
||||
CDType & ck(i.value());
|
||||
l.clear(); l << ck.index() << ".f = " << ck.formula() << " #s " << ck.comment() << " \n";
|
||||
if (!ck.enumValues().enum_list.isEmpty()) {
|
||||
l.clear(); l << ck.index() << ".ev = {";
|
||||
//PIVector<CDType::Enumerator> el = ck.enumValues();
|
||||
piForeachC (PIVariantTypes::Enumerator & e, ck.enumValues().enum_list)
|
||||
l << e.value << " - " << e.name << ", ";
|
||||
l.cutRight(2);
|
||||
l << "} \n";
|
||||
d->write(l.toUTF8());
|
||||
l.clear(); l << ck.index() << ".v = " << ck.value() << " #" << ck.type() << " " << ck.name() << " \n";
|
||||
d->write(l.toUTF8());
|
||||
if (!ck.enumValues().enum_list.isEmpty()) {
|
||||
l.clear(); l << ck.index() << ".ev = {";
|
||||
//PIVector<CDType::Enumerator> el = ck.enumValues();
|
||||
piForeachC (PIVariantTypes::Enumerator & e, ck.enumValues().enum_list)
|
||||
l << e.value << " - " << e.name << ", ";
|
||||
l.cutRight(2);
|
||||
l << "} \n";
|
||||
d->write(l.toUTF8());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!s.isEmpty()) {
|
||||
|
||||
@@ -27,8 +27,9 @@ message(STATUS "Building ${PROJECT_NAME}")
|
||||
if (NOT DEFINED ENV{QNX_HOST})
|
||||
if (KX_PULT)
|
||||
find_package(Qt4 REQUIRED)
|
||||
find_package(QAD REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
include_directories(${QT_INCLUDES})
|
||||
include_directories(${QT_INCLUDES} ${QAD_INCLUDES})
|
||||
set(CPPS "kx_pult.cpp" "kx_pult.h" "kx_pult.ui" "main_kx_pult.cpp")
|
||||
set(MOCS "kx_pult.h")
|
||||
file(GLOB UIS "*.ui")
|
||||
|
||||
@@ -181,6 +181,7 @@ void ConnectionEdit::selectionChanged() {
|
||||
ui->lineDevice->setText(di->name());
|
||||
ui->linePath->setEditText(di->path());
|
||||
ui->spinDeviceDT->setValue(di->disconnectTimeout());
|
||||
ui->spinDeviceBS->setValue(di->bufferSize());
|
||||
setOptions(di->options());
|
||||
}
|
||||
if (type == __CV_Filter) {
|
||||
@@ -198,6 +199,7 @@ void ConnectionEdit::selectionChanged() {
|
||||
ui->spinTimeout->setValue(fi->timeout());
|
||||
ui->spinSize->setValue(fi->packetSize());
|
||||
ui->spinFilterDT->setValue(fi->disconnectTimeout());
|
||||
ui->spinFilterBS->setValue(fi->bufferSize());
|
||||
}
|
||||
if (type == __CV_Sender) {
|
||||
ui->tabWidget->setCurrentIndex(2);
|
||||
@@ -219,6 +221,7 @@ void ConnectionEdit::applyFilter(FilterItem * b) {
|
||||
b->setTimeout(ui->spinTimeout->value());
|
||||
b->setPacketSize(ui->spinSize->value());
|
||||
b->setDisconnectTimeout(ui->spinFilterDT->value());
|
||||
b->setBufferSize(ui->spinFilterBS->value());
|
||||
recreateConnection();
|
||||
}
|
||||
|
||||
@@ -233,6 +236,7 @@ void ConnectionEdit::applyDevice(DeviceItem * b) {
|
||||
b->setOptions(PIIODevice::DeviceOptions(getOptions()));
|
||||
b->setPath(ui->linePath->currentText());
|
||||
b->setDisconnectTimeout(ui->spinDeviceDT->value());
|
||||
b->setBufferSize(ui->spinDeviceBS->value());
|
||||
recreateConnection();
|
||||
}
|
||||
|
||||
@@ -283,6 +287,7 @@ void ConnectionEdit::recreateConnection() {
|
||||
PIIODevice * dev = conn->addDevice(Q2PIString(di->path()), di->mode());
|
||||
if (!dev) continue;
|
||||
dev->setOptions(di->options());
|
||||
dev->setThreadedReadBufferSize(di->bufferSize());
|
||||
conn->setDeviceName(dev, Q2PIString(di->name()));
|
||||
PIDiagnostics * diag = conn->diagnostic(dev);
|
||||
if (diag) diag->setDisconnectTimeout(di->disconnectTimeout());
|
||||
@@ -317,6 +322,7 @@ void ConnectionEdit::recreateConnection() {
|
||||
if (name_from.isEmpty()) continue;
|
||||
PIPacketExtractor * pe = conn->addFilter(Q2PIString(fi_t->name()),conn->deviceByName(name_from), fi_t->mode());
|
||||
if (!pe) continue;
|
||||
pe->setBufferSize(fi_t->bufferSize());
|
||||
pe->setHeader(PIByteArray::fromString(Q2PIString(fi_t->header())));
|
||||
pe->setFooter(PIByteArray::fromString(Q2PIString(fi_t->footer())));
|
||||
pe->setTimeout(fi_t->timeout());
|
||||
|
||||
@@ -89,43 +89,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelFilter_12">
|
||||
<property name="text">
|
||||
<string>Mode:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboMode"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="labelFilter_13">
|
||||
<property name="text">
|
||||
<string>Disconnect
|
||||
timeout:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QDoubleSpinBox" name="spinDeviceDT">
|
||||
<property name="suffix">
|
||||
<string> ms</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9999.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>3.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="EComboBox" name="linePath">
|
||||
<property name="editable">
|
||||
@@ -176,6 +139,19 @@ timeout:</string>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelFilter_12">
|
||||
<property name="text">
|
||||
<string>Mode:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboMode"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labelFilter_14">
|
||||
<property name="text">
|
||||
@@ -193,6 +169,85 @@ timeout:</string>
|
||||
</property>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_14">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelFilter_13">
|
||||
<property name="text">
|
||||
<string>Disconnect timeout:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="spinDeviceDT">
|
||||
<property name="suffix">
|
||||
<string> ms</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9999.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>3.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelFilter_15">
|
||||
<property name="text">
|
||||
<string>Buffer size:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinDeviceBS">
|
||||
<property name="suffix">
|
||||
<string> b</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>4096</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999999999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>1</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@@ -489,6 +544,45 @@ timeout:</string>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>17</width>
|
||||
<height>17</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelFilter_17">
|
||||
<property name="text">
|
||||
<string>Buffer size:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinFilterBS">
|
||||
<property name="suffix">
|
||||
<string> b</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999999999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>65536</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_7">
|
||||
<property name="orientation">
|
||||
|
||||
@@ -18,12 +18,14 @@ public:
|
||||
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 setBufferSize(int v) {addProperty(BlockItem::Property("bufferSize", "", v)); rename();}
|
||||
|
||||
QString name() const {return propertyByName("name").value.toString();}
|
||||
QString path() const {return propertyByName("device").value.toString();}
|
||||
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());}
|
||||
int bufferSize() const {return propertyByName("bufferSize").value.toInt();}
|
||||
|
||||
void rename();
|
||||
|
||||
@@ -44,7 +46,8 @@ public:
|
||||
void setTimeout(double v) {addProperty(BlockItem::Property("timeout", "", v)); rename();}
|
||||
void setPacketSize(int v) {addProperty(BlockItem::Property("size", "", v)); rename();}
|
||||
void setDisconnectTimeout(double v) {addProperty(BlockItem::Property("disconnectTimeout", "", v)); rename();}
|
||||
|
||||
void setBufferSize(int v) {addProperty(BlockItem::Property("bufferSize", "", v)); rename();}
|
||||
|
||||
QString name() const {return propertyByName("name").value.toString();}
|
||||
PIPacketExtractor::SplitMode mode() const {return PIPacketExtractor::SplitMode(propertyByName("mode").value.toInt());}
|
||||
QString header() const {return propertyByName("header").value.toString();}
|
||||
@@ -52,7 +55,8 @@ public:
|
||||
double timeout() const {return propertyByName("timeout").value.toDouble();}
|
||||
int packetSize() const {return propertyByName("size").value.toInt();}
|
||||
double disconnectTimeout() const {return PIIODevice::DeviceMode(propertyByName("disconnectTimeout").value.toDouble());}
|
||||
|
||||
int bufferSize() const {return propertyByName("bufferSize").value.toInt();}
|
||||
|
||||
void rename();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -73,7 +73,7 @@ int CDKItemModel::columnCount(const QModelIndex &parent) const {
|
||||
}
|
||||
|
||||
|
||||
Qt::ItemFlags CDKItemModel::flags(const QModelIndex &index) const {
|
||||
Qt::ItemFlags CDKItemModel::flags(const QModelIndex & index) const {
|
||||
if (!index.isValid()) return 0;
|
||||
Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
CDKItem * item = getItem(index);
|
||||
@@ -89,13 +89,15 @@ Qt::ItemFlags CDKItemModel::flags(const QModelIndex &index) const {
|
||||
}
|
||||
|
||||
|
||||
bool CDKItemModel::setData(const QModelIndex &index, const QVariant &value, int role) {
|
||||
bool CDKItemModel::setData(const QModelIndex & index, const QVariant &value, int role) {
|
||||
if (role == Qt::CheckStateRole && index.column() == 4) {
|
||||
CDKItem * item = getItem(index);
|
||||
if (item->type_ == CDKItem::ItemCDType) {
|
||||
CDType t = K.section(item->buildPath())[item->index_];
|
||||
if (t.type() == "b") {
|
||||
bool result = item->setData(index.column(), PI2QString(PIString::fromBool(value.toBool())));
|
||||
QModelIndex rin(CDKItemModel::index(index.row(), 3, index.parent()));
|
||||
emit dataChanged(rin, rin);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -103,7 +105,11 @@ bool CDKItemModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||
if (role != Qt::EditRole) return false;
|
||||
CDKItem * item = getItem(index);
|
||||
bool result = item->setData(index.column(), value);
|
||||
if (result) emit dataChanged(index, index);
|
||||
if (result) {
|
||||
QModelIndex rin(CDKItemModel::index(index.row(), 3, index.parent()));
|
||||
emit dataChanged(rin, rin);
|
||||
emit dataChanged(index, index);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -237,6 +243,7 @@ QVariant CDKItem::value(CDType t, int role) const {
|
||||
bool CDKItem::setData(int column, const QVariant &value) {
|
||||
if ((column == 3 || column == 4) && type_ == ItemCDType) {
|
||||
K.section(buildPath())[index_].setValue(Q2PIString(value.toString()));
|
||||
K.calculate();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -49,7 +49,7 @@ signals:
|
||||
void KReceiveFailed();
|
||||
void KReceiveSucceed();
|
||||
void messageStatus(QString msg);
|
||||
void busyStatusChanged(bool bisy);
|
||||
void busyStatusChanged(bool busy);
|
||||
|
||||
void _qcdk_sendFailed(); // PRIVATE
|
||||
void _qcdk_sendSucceed(); // PRIVATE
|
||||
|
||||
Reference in New Issue
Block a user