Compare commits
5 Commits
b6898b96f7
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d955bb846 | |||
| 31bacbedae | |||
| a3e88f792d | |||
| b65bf5e640 | |||
| 0c36565aec |
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.0)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
||||||
project(CD)
|
project(CD)
|
||||||
set(CD_MAJOR 1)
|
set(CD_MAJOR 1)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.0)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
project(cd_core)
|
project(cd_core)
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
file(GLOB CPPS "cdutils_*.cpp")
|
file(GLOB CPPS "cdutils_*.cpp")
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ void CInterface::autoConnect(PIObject * o, const PIString & prefix) {
|
|||||||
// piCout << "func" << it.value().func_name;
|
// piCout << "func" << it.value().func_name;
|
||||||
}
|
}
|
||||||
PIVector<CDType *> cl = C.root().children();
|
PIVector<CDType *> cl = C.root().children();
|
||||||
piForeachC(CDType * c, cl) {
|
for (const auto * c: cl) {
|
||||||
PIString cp = prefix + c->pathString().join("_");
|
PIString cp = prefix + c->pathString().join("_");
|
||||||
if (cp.isEmpty()) continue;
|
if (cp.isEmpty()) continue;
|
||||||
if (!eh_map.contains(cp)) continue;
|
if (!eh_map.contains(cp)) continue;
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ CDCore::CDCore() {
|
|||||||
setName("CDCore");
|
setName("CDCore");
|
||||||
x_timer.setName("_S.CDCore.x_timer");
|
x_timer.setName("_S.CDCore.x_timer");
|
||||||
datatr.setPacketSize(960);
|
datatr.setPacketSize(960);
|
||||||
|
cout_buffer_id = PICout::registerExternalBufferID();
|
||||||
CONNECTU(&connection, dataReceivedEvent, this, dataReceived);
|
CONNECTU(&connection, dataReceivedEvent, this, dataReceived);
|
||||||
CONNECTU(PICout::Notifier::object(), finished, this, piCoutFinished);
|
CONNECTU(PICout::Notifier::object(), finished, this, piCoutFinished);
|
||||||
/*PIString s(app_config);
|
/*PIString s(app_config);
|
||||||
@@ -111,7 +112,7 @@ void CDCore::cd_read(CDSection * cd, PIIODevice * d) {
|
|||||||
initRoot(cd);
|
initRoot(cd);
|
||||||
raiseChangedGlobal(cd->cd_type_);
|
raiseChangedGlobal(cd->cd_type_);
|
||||||
/*PIVector<PIIODevice * > ds = connection.allDevices();
|
/*PIVector<PIIODevice * > ds = connection.allDevices();
|
||||||
piForeach(PIIODevice * d, ds) {
|
for (PIIODevice * d: ds) {
|
||||||
if (d)
|
if (d)
|
||||||
piCoutObj << d->constructFullPath() << d->isOpened();
|
piCoutObj << d->constructFullPath() << d->isOpened();
|
||||||
}*/
|
}*/
|
||||||
@@ -376,7 +377,7 @@ void CDCore::xTimerTick() {
|
|||||||
} else {
|
} else {
|
||||||
ba = makeHeader(CD_XValues, 0);
|
ba = makeHeader(CD_XValues, 0);
|
||||||
ba << x_selected;
|
ba << x_selected;
|
||||||
piForeachC(PIDeque<int> & p, x_selected) {
|
for (const auto & p: x_selected) {
|
||||||
x_[p].writeX(ba);
|
x_[p].writeX(ba);
|
||||||
}
|
}
|
||||||
// piCout << "x app" << x_selected.size();
|
// piCout << "x app" << x_selected.size();
|
||||||
@@ -387,7 +388,7 @@ void CDCore::xTimerTick() {
|
|||||||
|
|
||||||
|
|
||||||
void CDCore::piCoutFinished(int id, PIString * buffer) {
|
void CDCore::piCoutFinished(int id, PIString * buffer) {
|
||||||
if (!buffer || !(id == 1)) return;
|
if ((id != cout_buffer_id) || !buffer) return;
|
||||||
PIString sp = buffer->takeRange('[', ']');
|
PIString sp = buffer->takeRange('[', ']');
|
||||||
PIDeque<int> p = CDCore::stringToPath(sp);
|
PIDeque<int> p = CDCore::stringToPath(sp);
|
||||||
sendMessage(m_[p], Log, *buffer);
|
sendMessage(m_[p], Log, *buffer);
|
||||||
@@ -470,7 +471,7 @@ void CDCore::procReceivedPacket(PIByteArray & ba) {
|
|||||||
ba >> x_selected;
|
ba >> x_selected;
|
||||||
// piCout << "X req" << x_selected.size();
|
// piCout << "X req" << x_selected.size();
|
||||||
x_.setSelectedX(false);
|
x_.setSelectedX(false);
|
||||||
piForeachC(PIDeque<int> & p, x_selected) {
|
for (const auto & p: x_selected) {
|
||||||
x_[p].x_enabled = true;
|
x_[p].x_enabled = true;
|
||||||
}
|
}
|
||||||
x_mutex.unlock();
|
x_mutex.unlock();
|
||||||
@@ -480,7 +481,7 @@ void CDCore::procReceivedPacket(PIByteArray & ba) {
|
|||||||
PIVector<PIDeque<int>> x_vals;
|
PIVector<PIDeque<int>> x_vals;
|
||||||
ba >> x_vals;
|
ba >> x_vals;
|
||||||
x_mutex.lock();
|
x_mutex.lock();
|
||||||
piForeachC(PIDeque<int> & p, x_vals) {
|
for (const auto & p: x_vals) {
|
||||||
x_[p].readX(ba);
|
x_[p].readX(ba);
|
||||||
}
|
}
|
||||||
x_mutex.unlock();
|
x_mutex.unlock();
|
||||||
@@ -557,7 +558,7 @@ PIString CDCore::pathToString(const PIDeque<int> & p) {
|
|||||||
PIDeque<int> CDCore::stringToPath(const PIString & p) {
|
PIDeque<int> CDCore::stringToPath(const PIString & p) {
|
||||||
PIDeque<int> ret;
|
PIDeque<int> ret;
|
||||||
PIStringList sl = p.split(".");
|
PIStringList sl = p.split(".");
|
||||||
piForeachC(PIString & s, sl)
|
for (const auto & s: sl)
|
||||||
ret << s.toInt();
|
ret << s.toInt();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -567,7 +568,7 @@ void CDUtils::CDCore::dataReceived(const PIString & from, const PIByteArray & da
|
|||||||
// piCoutObj << "dataReceived" << from << data.size();
|
// piCoutObj << "dataReceived" << from << data.size();
|
||||||
PIIODevice * d = connection.deviceByName("cd");
|
PIIODevice * d = connection.deviceByName("cd");
|
||||||
if (d && d == connection.deviceByFullPath(from)) {
|
if (d && d == connection.deviceByFullPath(from)) {
|
||||||
if (data.size() >= sizeof(4)) {
|
if (data.size() >= sizeof(int)) {
|
||||||
PIByteArray ba = data;
|
PIByteArray ba = data;
|
||||||
uchar header = ba.take_front();
|
uchar header = ba.take_front();
|
||||||
if (header == header_transfer) {
|
if (header == header_transfer) {
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ class CD_CORE_EXPORT CDCore: public PIObject {
|
|||||||
friend class CDSection;
|
friend class CDSection;
|
||||||
friend class Interface;
|
friend class Interface;
|
||||||
friend class XInterface;
|
friend class XInterface;
|
||||||
|
friend class MInterface;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static CDCore * instance();
|
static CDCore * instance();
|
||||||
@@ -111,6 +112,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
CDCore();
|
CDCore();
|
||||||
~CDCore();
|
~CDCore();
|
||||||
|
|
||||||
EVENT_HANDLER2(void, dataReceived, const PIString &, from, const PIByteArray &, data);
|
EVENT_HANDLER2(void, dataReceived, const PIString &, from, const PIByteArray &, data);
|
||||||
EVENT_HANDLER1(void, dtSendRequest, PIByteArray &, data);
|
EVENT_HANDLER1(void, dtSendRequest, PIByteArray &, data);
|
||||||
EVENT_HANDLER1(void, dtReceiveFinished, bool, ok);
|
EVENT_HANDLER1(void, dtReceiveFinished, bool, ok);
|
||||||
@@ -136,6 +138,7 @@ private:
|
|||||||
PIMutex x_mutex;
|
PIMutex x_mutex;
|
||||||
PIVector<PIDeque<int>> x_selected;
|
PIVector<PIDeque<int>> x_selected;
|
||||||
PIMap<PIString, OHPair> c_handlers;
|
PIMap<PIString, OHPair> c_handlers;
|
||||||
|
int cout_buffer_id = 0;
|
||||||
bool need_rebuild_x, x_pult_side;
|
bool need_rebuild_x, x_pult_side;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,5 +19,5 @@ void MInterface::messageBox(const CDType & m, const PIString & msg) {
|
|||||||
|
|
||||||
PICout MInterface::createPICout(const CDType & m) const {
|
PICout MInterface::createPICout(const CDType & m) const {
|
||||||
PIString * buff = new PIString("[" + CDCore::pathToString(m.path()) + "]");
|
PIString * buff = new PIString("[" + CDCore::pathToString(m.path()) + "]");
|
||||||
return PICout::withExternalBuffer(buff, 1);
|
return PICout::withExternalBufferAndID(buff, core->cout_buffer_id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,24 +3,12 @@
|
|||||||
#include "cdutils_core.h"
|
#include "cdutils_core.h"
|
||||||
#include "piconfig.h"
|
#include "piconfig.h"
|
||||||
#include "pievaluator.h"
|
#include "pievaluator.h"
|
||||||
#include "pifile.h"
|
|
||||||
|
|
||||||
using namespace CDUtils;
|
using namespace CDUtils;
|
||||||
|
|
||||||
|
|
||||||
const int cd_x_history_max_size = 4000;
|
const int cd_x_history_max_size = 4000;
|
||||||
|
|
||||||
CDType::CDType() {
|
|
||||||
index_ = -1;
|
|
||||||
value_d = 0.;
|
|
||||||
value_i = 0;
|
|
||||||
value_b = calculated = x_enabled = false;
|
|
||||||
cd_type_ = cdNull;
|
|
||||||
parent = 0;
|
|
||||||
avg_size = 1;
|
|
||||||
mode_ = rmode_ = X_Current;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CDType::CDType(int i, const PIString & n, const PIString & t, const PIString & v, const PIString & f, const PIString & c, cdT cd_t) {
|
CDType::CDType(int i, const PIString & n, const PIString & t, const PIString & v, const PIString & f, const PIString & c, cdT cd_t) {
|
||||||
index_ = i;
|
index_ = i;
|
||||||
|
|||||||
@@ -34,6 +34,12 @@ class CDItemModel;
|
|||||||
namespace CDUtils {
|
namespace CDUtils {
|
||||||
|
|
||||||
class CDSection;
|
class CDSection;
|
||||||
|
class CDCore;
|
||||||
|
class Interface;
|
||||||
|
class KInterface;
|
||||||
|
class XInterface;
|
||||||
|
class CInterface;
|
||||||
|
class MInterface;
|
||||||
|
|
||||||
enum UpdateMode {
|
enum UpdateMode {
|
||||||
SaveByIndex = 0x01,
|
SaveByIndex = 0x01,
|
||||||
@@ -67,7 +73,7 @@ public:
|
|||||||
X_All_Avg
|
X_All_Avg
|
||||||
};
|
};
|
||||||
|
|
||||||
CDType();
|
CDType() {}
|
||||||
CDType(int i, const PIString & n, const PIString & t, const PIString & v, const PIString & f, const PIString & c, cdT cd_t);
|
CDType(int i, const PIString & n, const PIString & t, const PIString & v, const PIString & f, const PIString & c, cdT cd_t);
|
||||||
|
|
||||||
CDType & operator=(double x);
|
CDType & operator=(double x);
|
||||||
@@ -107,19 +113,20 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
bool calculate(PIEvaluator * e, PIVector<const CDType *> stack = PIVector<const CDType *>());
|
bool calculate(PIEvaluator * e, PIVector<const CDType *> stack = PIVector<const CDType *>());
|
||||||
PIVariantTypes::Enum parseEnumComment(PIString c);
|
PIVariantTypes::Enum parseEnumComment(PIString c);
|
||||||
cdT cd_type_;
|
|
||||||
int index_;
|
cdT cd_type_ = cdNull;
|
||||||
|
int index_ = -1;
|
||||||
PIString name_, type_;
|
PIString name_, type_;
|
||||||
PIString value_s, formula_, comment_, error_;
|
PIString value_s, formula_, comment_, error_;
|
||||||
PIVariantTypes::Enum enum_values;
|
PIVariantTypes::Enum enum_values;
|
||||||
CDSection * parent;
|
CDSection * parent = nullptr;
|
||||||
PIDeque<int> path_;
|
PIDeque<int> path_;
|
||||||
double value_d;
|
double value_d = 0.;
|
||||||
int value_i;
|
int value_i = 0;
|
||||||
bool value_b, calculated, x_enabled;
|
bool value_b = false, calculated = false, x_enabled = false;
|
||||||
PIVector<double> avg_h;
|
PIVector<double> avg_h;
|
||||||
int avg_size;
|
int avg_size = 1;
|
||||||
XMode mode_, rmode_;
|
XMode mode_ = X_Current, rmode_ = X_Current;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -157,10 +164,7 @@ public:
|
|||||||
PIString alias;
|
PIString alias;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CDSection(PIMap<int, CDType> k_, PIMap<int, CDSection> s_) {
|
CDSection(PIMap<int, CDType> k_, PIMap<int, CDSection> s_): cd(k_), s(s_) {}
|
||||||
cd = k_;
|
|
||||||
s = s_;
|
|
||||||
}
|
|
||||||
CDType & getByName(const PIString & name_);
|
CDType & getByName(const PIString & name_);
|
||||||
CDType & getByPath(const PIDeque<int> & path_);
|
CDType & getByPath(const PIDeque<int> & path_);
|
||||||
void write(PIIODevice * d, const PIString & prefix = PIString());
|
void write(PIIODevice * d, const PIString & prefix = PIString());
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ bool QCDCore::bindWidget(QWidget * w) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PIVector<CDType *> ak = K.root().children();
|
PIVector<CDType *> ak = K.root().children();
|
||||||
piForeachC(CDType * k, ak) {
|
for (const auto * k: ak) {
|
||||||
if (!on.endsWith(PI2QString(k->pathString().join("_")))) continue;
|
if (!on.endsWith(PI2QString(k->pathString().join("_")))) continue;
|
||||||
if (bindWidget(w, *k)) return true;
|
if (bindWidget(w, *k)) return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ void CDView::cd_receivedX() {
|
|||||||
X.lock();
|
X.lock();
|
||||||
PIVector<PIDeque<int>> xl = X.enabledList();
|
PIVector<PIDeque<int>> xl = X.enabledList();
|
||||||
// piCout << "X" << xl.size();
|
// piCout << "X" << xl.size();
|
||||||
piForeachC(PIDeque<int> & x, xl) {
|
for (const auto & x: xl) {
|
||||||
CDType & t(X[x]);
|
CDType & t(X[x]);
|
||||||
// piCout << t;
|
// piCout << t;
|
||||||
// piCout << t.path();
|
// piCout << t.path();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ using namespace CDUtils;
|
|||||||
|
|
||||||
QStringList CDUtils::getList(const PIVector<PIDeque<int>> & x_list) {
|
QStringList CDUtils::getList(const PIVector<PIDeque<int>> & x_list) {
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
piForeachC(PIDeque<int> & p, x_list)
|
for (const auto & p: x_list)
|
||||||
ret << PI2QString(CDCore::pathToString(p));
|
ret << PI2QString(CDCore::pathToString(p));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@ QStringList CDUtils::getList(const PIVector<PIDeque<int>> & x_list) {
|
|||||||
|
|
||||||
PIVector<PIDeque<int>> CDUtils::setList(const QStringList & l) {
|
PIVector<PIDeque<int>> CDUtils::setList(const QStringList & l) {
|
||||||
PIVector<PIDeque<int>> ret;
|
PIVector<PIDeque<int>> ret;
|
||||||
foreach(QString s, l)
|
for (const auto & s: l)
|
||||||
ret << CDCore::stringToPath(Q2PIString(s));
|
ret << CDCore::stringToPath(Q2PIString(s));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -294,7 +294,7 @@ void CDGraphics::receivedX() {
|
|||||||
X.lock();
|
X.lock();
|
||||||
PIVector<PIDeque<int>> x_list = X.enabledList();
|
PIVector<PIDeque<int>> x_list = X.enabledList();
|
||||||
PIVector<double> ch;
|
PIVector<double> ch;
|
||||||
piForeachC(PIDeque<int> & p, x_list) {
|
for (const auto & p: x_list) {
|
||||||
CDType & t(X[p]);
|
CDType & t(X[p]);
|
||||||
if (t.xmode_rec() == CDType::X_Current)
|
if (t.xmode_rec() == CDType::X_Current)
|
||||||
ch.resize(1).fill(t.toDouble());
|
ch.resize(1).fill(t.toDouble());
|
||||||
|
|||||||
@@ -130,7 +130,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../../../qad/libs/graphic/qad_graphic.qrc">
|
<iconset resource="../../../qad/libs/graphic/qad_graphic.qrc">
|
||||||
<normaloff>:/icons/border-line.png</normaloff>:/icons/border-line.png</iconset>
|
<normaloff>:/icons/edit-rename.png</normaloff>:/icons/edit-rename.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ void CDPultWindow::apply(bool sessions) {
|
|||||||
X.lock();
|
X.lock();
|
||||||
PIVector<PIDeque<int>> x_list = X.enabledList();
|
PIVector<PIDeque<int>> x_list = X.enabledList();
|
||||||
X.unlock();
|
X.unlock();
|
||||||
piForeachC(PIDeque<int> & p, x_list)
|
for (const auto & p: x_list)
|
||||||
X.enable(X[p]);
|
X.enable(X[p]);
|
||||||
((CDItemModel *)widgetX->view->model())->updateModel();
|
((CDItemModel *)widgetX->view->model())->updateModel();
|
||||||
widgetX->view->expandAll();
|
widgetX->view->expandAll();
|
||||||
|
|||||||
Reference in New Issue
Block a user