git-svn-id: svn://db.shs.com.ru/libs@125 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2016-09-26 17:17:54 +00:00
parent a8289c1ee6
commit 125158f243
8 changed files with 56 additions and 20 deletions

View File

@@ -68,6 +68,7 @@ CDCore::CDCore() {
CONNECTU(&datatr, sendRequest, this, dtSendRequest)
CONNECTU(&datatr, receiveFinished, this, dtReceiveFinished)
CONNECTU(&sendt, started, this, sendThread)
CONNECTU(&x_timer, tickEvent, this, xTimerTick)
/*k_[1] = KType(1, "123", "120+3", "comment");
k_[2] = KType(2, "1", "2", "comm");
@@ -77,22 +78,16 @@ CDCore::CDCore() {
k_.section(11)[3] = KType(3, "1", "1", "88");
k_.section(11)[4] = KType(4, "0", "0", "88");
k_.section(11)[6] = KType(6, "0", "0", "88");*/
//piCout << s;
//piCout << s;
}
void CDCore::k_rec(const PIByteArray & data) {
}
void CDCore::x_rec(const PIByteArray & data) {
}
void CDCore::c_rec(const PIByteArray & data) {
CDCore::~CDCore() {
datatr.stop();
x_timer.stop();
sendt.stop();
sendt.waitForFinish(10);
connection.stop();
}
@@ -142,11 +137,29 @@ void CDCore::reinitConnection(const PIString &configuration) {
}
void CDCore::startPing() {
x_timer.start(1);
}
void CDUtils::CDCore::dataReceived(const PIString & from, const PIByteArray & data) {
// piCoutObj << "dataReceived" << from << data.size();
PIIODevice * d = connection.deviceByName("cd");
if (d && d == connection.deviceByFullPath(from)) {
datatr.received(data);
if (data.size() >= sizeof(4)) {
const uint sig = *((const uint*)(data.data()));
if (sig == 0x54424950) datatr.received(data);
else {
CDPacketType pt = (CDPacketType)sig;
switch(pt) {
case CD_Ping:
piCoutObj << "ping";
break;
default: break;
}
}
}
}
}
@@ -209,6 +222,15 @@ void CDCore::sendThread() {
}
void CDCore::xTimerTick() {
PacketHeader ph;
ph.type = CD_Ping;
PIByteArray ba;
ba << ph;
connection.writeByName("cd", ba);
}
void CDCore::dtSendRequest(PIByteArray &data) {
connection.writeByName("cd", data);
// piCoutObj << "send" << data.size() << ret;