git-svn-id: svn://db.shs.com.ru/libs@383 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -182,7 +182,14 @@ void CDCore::init(const PIString & configuration, bool pult) {
|
||||
|
||||
|
||||
void CDCore::startX(double freq) {
|
||||
x_timer.start(1000. / piMaxd(freq, 0.01));
|
||||
piCout << "start x" << x_timer.isRunning() << freq;
|
||||
if (!x_timer.isRunning())
|
||||
x_timer.start(1000. / piMaxd(freq, 0.01));
|
||||
}
|
||||
|
||||
|
||||
void CDCore::stopX() {
|
||||
x_timer.stop();
|
||||
}
|
||||
|
||||
|
||||
@@ -314,24 +321,28 @@ void CDCore::sendThread() {
|
||||
|
||||
|
||||
void CDCore::xTimerTick() {
|
||||
x_mutex.lock();
|
||||
//piCout << "x tick" << x_pult_side;
|
||||
PIByteArray ba;
|
||||
x_mutex.lock();
|
||||
if (x_pult_side) {
|
||||
ba = makeHeader(CD_XRequest, 0);
|
||||
if (need_rebuild_x) {
|
||||
x_selected = x_.collectX();
|
||||
//piCout << "collectX" << x_selected.size();
|
||||
need_rebuild_x = false;
|
||||
}
|
||||
ba << x_selected;
|
||||
//piCout << "x pult send" << x_selected.size();
|
||||
} else {
|
||||
ba = makeHeader(CD_XValues, 0);
|
||||
ba << x_selected;
|
||||
piForeachC (PIDeque<int> & p, x_selected) {
|
||||
x_[p].writeX(ba);
|
||||
}
|
||||
//piCout << "x app" << x_selected.size();
|
||||
}
|
||||
x_mutex.unlock();
|
||||
connection.writeByName("cd", ba);
|
||||
sendDirect(ba);
|
||||
}
|
||||
|
||||
|
||||
@@ -393,10 +404,26 @@ void CDCore::procReceivedPacket(PIByteArray & ba) {
|
||||
ba >> p;
|
||||
k_[p.path].setValue(p.value);
|
||||
} break;
|
||||
case CD_XQuery:
|
||||
X_Send();
|
||||
break;
|
||||
case CD_XSend: {
|
||||
piCoutObj << "X received";
|
||||
PIByteArray x;
|
||||
ba >> x;
|
||||
x << uchar(0);
|
||||
PIString s = PIString::fromUTF8((const char *)x.data());
|
||||
PIIOString ios(&s);
|
||||
cd_read(&x_, &ios);
|
||||
X_Received();
|
||||
} break;
|
||||
case CD_XRequest: {
|
||||
if (x_pult_side) break;
|
||||
//break;
|
||||
x_mutex.lock();
|
||||
x_selected.clear();
|
||||
ba >> x_selected;
|
||||
//piCout << "X req" << x_selected.size();
|
||||
x_.setSelectedX(false);
|
||||
piForeachC (PIDeque<int> & p, x_selected) {
|
||||
x_[p].x_enabled = true;
|
||||
@@ -404,12 +431,14 @@ void CDCore::procReceivedPacket(PIByteArray & ba) {
|
||||
x_mutex.unlock();
|
||||
} break;
|
||||
case CD_XValues: {
|
||||
if (!x_pult_side) break;
|
||||
x_mutex.lock();
|
||||
x_selected.clear();
|
||||
ba >> x_selected;
|
||||
piForeachC (PIDeque<int> & p, x_selected) {
|
||||
PIVector<PIDeque<int> > x_vals;
|
||||
ba >> x_vals;
|
||||
piForeachC (PIDeque<int> & p, x_vals) {
|
||||
x_[p].readX(ba);
|
||||
}
|
||||
X_ReceivedX(x_vals); /// WARNING! under mutex
|
||||
x_mutex.unlock();
|
||||
} break;
|
||||
case CD_CQuery:
|
||||
|
||||
Reference in New Issue
Block a user