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