remove debug picout from cloud
This commit is contained in:
@@ -28,10 +28,14 @@ PICloudServer::PICloudServer(const PIString & path, PIIODevice::DeviceMode mode)
|
||||
is_deleted = false;
|
||||
eth.setReopenEnabled(false);
|
||||
CONNECT1(void, PIByteArray, &streampacker, packetReceiveEvent, this, _readed);
|
||||
CONNECTL(ð, connected, [this](){opened_ = true; piCoutObj << "connected" << ð tcp.sendStart();});
|
||||
CONNECTL(ð, connected, [this](){
|
||||
opened_ = true;
|
||||
//piCoutObj << "connected" << ð
|
||||
tcp.sendStart();
|
||||
});
|
||||
CONNECTL(ð, disconnected, [this](bool){
|
||||
if (is_deleted) return;
|
||||
piCoutObj << "disconnected" << ð
|
||||
//piCoutObj << "disconnected" << ð
|
||||
for (auto c : clients_) {
|
||||
delete c;
|
||||
}
|
||||
@@ -46,13 +50,13 @@ PICloudServer::PICloudServer(const PIString & path, PIIODevice::DeviceMode mode)
|
||||
|
||||
|
||||
PICloudServer::~PICloudServer() {
|
||||
piCoutObj << "~PICloudServer ..." << this;
|
||||
//piCoutObj << "~PICloudServer ..." << this;
|
||||
is_deleted = true;
|
||||
stop();
|
||||
close();
|
||||
piCout << "wait";
|
||||
//piCout << "wait";
|
||||
waitThreadedReadFinished();
|
||||
piCoutObj << "~PICloudServer done" << this;
|
||||
//piCoutObj << "~PICloudServer done" << this;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +73,7 @@ PIVector<PICloudServer::Client *> PICloudServer::clients() const {
|
||||
|
||||
|
||||
bool PICloudServer::openDevice() {
|
||||
piCout << "PICloudServer open device" << path();
|
||||
//piCout << "PICloudServer open device" << path();
|
||||
bool op = eth.connect(PIEthernet::Address::resolve(path()), false);
|
||||
if (op) {
|
||||
eth.startThreadedRead();
|
||||
@@ -84,7 +88,7 @@ bool PICloudServer::openDevice() {
|
||||
|
||||
|
||||
bool PICloudServer::closeDevice() {
|
||||
piCoutObj << "closeDevice" << this;
|
||||
//piCoutObj << "closeDevice" << this;
|
||||
eth.stopAndWait();
|
||||
ping_timer.stop(false);
|
||||
eth.close();
|
||||
@@ -135,10 +139,10 @@ PICloudServer::Client::Client(PICloudServer * srv, uint id) : server(srv), clien
|
||||
|
||||
|
||||
PICloudServer::Client::~Client() {
|
||||
piCoutObj << "~PICloudServer::Client..." << this;
|
||||
//piCoutObj << "~PICloudServer::Client..." << this;
|
||||
close();
|
||||
stopAndWait();
|
||||
piCoutObj << "~PICloudServer::Client done" << this;
|
||||
//piCoutObj << "~PICloudServer::Client done" << this;
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +152,7 @@ bool PICloudServer::Client::openDevice() {
|
||||
|
||||
|
||||
bool PICloudServer::Client::closeDevice() {
|
||||
piCoutObj << "closeDevice" << this;
|
||||
//piCoutObj << "closeDevice" << this;
|
||||
if (is_connected) {
|
||||
server->clientDisconnect(client_id);
|
||||
is_connected = false;
|
||||
@@ -191,10 +195,14 @@ void PICloudServer::Client::interrupt() {
|
||||
void PICloudServer::Client::pushBuffer(const PIByteArray & ba) {
|
||||
if (!is_connected) return;
|
||||
mutex_buff.lock();
|
||||
if (buff.size_s() > threadedReadBufferSize()) {
|
||||
piCoutObj << "Error: buffer overflow, drop" << ba.size() << "bytes";
|
||||
mutex_buff.unlock();
|
||||
return;
|
||||
}
|
||||
buff.append(ba);
|
||||
cond_buff.notifyOne();
|
||||
mutex_buff.unlock();
|
||||
while (buff.size_s() > threadedReadBufferSize()) piMSleep(100); // FIXME: sleep here is bad
|
||||
}
|
||||
|
||||
|
||||
@@ -212,7 +220,7 @@ void PICloudServer::_readed(PIByteArray & ba) {
|
||||
tcp.sendDisconnected(id);
|
||||
} else {
|
||||
Client * c = new Client(this, id);
|
||||
piCoutObj << "new Client" << id << c;
|
||||
//piCoutObj << "new Client" << id << c;
|
||||
CONNECT1(void, PIObject *, c, deleted, this, clientDeleted);
|
||||
clients_mutex.lock();
|
||||
clients_ << c;
|
||||
@@ -223,7 +231,7 @@ void PICloudServer::_readed(PIByteArray & ba) {
|
||||
} break;
|
||||
case PICloud::TCP::Disconnect: {
|
||||
uint id = tcp.parseDisconnect(ba);
|
||||
piCoutObj << "remove Client" << id;
|
||||
//piCoutObj << "remove Client" << id;
|
||||
clients_mutex.lock();
|
||||
Client * oc = index_clients.value(id, nullptr);
|
||||
clients_mutex.unlock();
|
||||
@@ -238,7 +246,7 @@ void PICloudServer::_readed(PIByteArray & ba) {
|
||||
clients_mutex.lock();
|
||||
Client * oc = index_clients.value(d.first, nullptr);
|
||||
clients_mutex.unlock();
|
||||
piCoutObj << "data for" << d.first << d.second.size();
|
||||
//piCoutObj << "data for" << d.first << d.second.size();
|
||||
if (oc && !d.second.isEmpty()) oc->pushBuffer(d.second);
|
||||
} break;
|
||||
default: break;
|
||||
@@ -249,7 +257,7 @@ void PICloudServer::_readed(PIByteArray & ba) {
|
||||
|
||||
void PICloudServer::clientDeleted(PIObject * o) {
|
||||
PICloudServer::Client * c = (PICloudServer::Client*)o;
|
||||
piCoutObj << "clientDeleted" << c;
|
||||
//piCoutObj << "clientDeleted" << c;
|
||||
clients_mutex.lock();
|
||||
clients_.removeOne(c);
|
||||
auto it = index_clients.makeIterator();
|
||||
|
||||
Reference in New Issue
Block a user