BIG deep clean
This commit is contained in:
@@ -1,5 +1,23 @@
|
||||
#include "pibasetransfer.h"
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Base class for reliable send and receive data in fixed packets with error correction, pause and resume
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "pibasetransfer.h"
|
||||
|
||||
const uint PIBaseTransfer::signature = 0x54424950;
|
||||
|
||||
@@ -16,7 +34,6 @@ PIBaseTransfer::PIBaseTransfer(): crc(standardCRC_16()), diag(false) {
|
||||
send_up = 0;
|
||||
timeout_ = 10.;
|
||||
diag.setDisconnectTimeout(timeout_ / 10);
|
||||
//CONNECTU(&diag, qualityChanged, this, diagChanged);
|
||||
diag.setName("PIBaseTransfer");
|
||||
diag.start(50);
|
||||
packets_count = 10;
|
||||
@@ -144,7 +161,6 @@ void PIBaseTransfer::received(PIByteArray data) {
|
||||
// piCoutObj << "Done Packet" << h.id;
|
||||
}
|
||||
if (is_receiving && h.id == 0) {
|
||||
// if (checkSession() == 0 && pt == pt_ReplySuccess) finish_receive(true);
|
||||
if (pt == pt_ReplySuccess) {
|
||||
mutex_session.lock();
|
||||
int cs = checkSession();
|
||||
@@ -183,8 +199,6 @@ void PIBaseTransfer::received(PIByteArray data) {
|
||||
}
|
||||
if (is_receiving) {
|
||||
if (header.session_id != h.session_id) {
|
||||
//sendBreak(h.session_id);
|
||||
//return;
|
||||
piCoutObj << "restart receive";
|
||||
mutex_header.unlock();
|
||||
finish_receive(false, true);
|
||||
@@ -214,7 +228,6 @@ void PIBaseTransfer::received(PIByteArray data) {
|
||||
replies.fill(pt_Unknown);
|
||||
pm_string.resize(replies.size(), '-');
|
||||
diag.reset();
|
||||
// diag.start(100);
|
||||
//piCoutObj << "receiveStarted()";
|
||||
is_receiving = true;
|
||||
break_ = false;
|
||||
@@ -261,7 +274,6 @@ bool PIBaseTransfer::send_process() {
|
||||
packet_header_size = sizeof(PacketHeader) + customHeader().size();
|
||||
break_ = false;
|
||||
diag.reset();
|
||||
// diag.start(100);
|
||||
sendStarted();
|
||||
is_sending = true;
|
||||
int session_size = session.size();
|
||||
@@ -278,14 +290,12 @@ bool PIBaseTransfer::send_process() {
|
||||
send_up = 0;
|
||||
send_tm.reset();
|
||||
mutex_send.unlock();
|
||||
//int ltm = 0;
|
||||
for (int i = 0; i < session_size; i++) {
|
||||
mutex_send.lock();
|
||||
int sq = send_queue;
|
||||
mutex_send.unlock();
|
||||
if (sq >= packets_count || is_pause) {
|
||||
--i;
|
||||
//piMSleep(PIP_MIN_MSLEEP);
|
||||
if (is_pause) {
|
||||
piMSleep(40);
|
||||
//piCout << "send pause";
|
||||
@@ -368,9 +378,7 @@ bool PIBaseTransfer::send_process() {
|
||||
send_queue++;
|
||||
mutex_send.unlock();
|
||||
}
|
||||
// if (chk == -1) return finish_send(false);
|
||||
if (break_) return finish_send(false);
|
||||
//piMSleep(PIP_MIN_MSLEEP);
|
||||
}
|
||||
return finish_send(false);
|
||||
}
|
||||
@@ -410,7 +418,6 @@ void PIBaseTransfer::buildSession(PIVector<Part> parts) {
|
||||
fi.id = parts[i].id;
|
||||
//piCout << fi.id << state_string;
|
||||
bytes_all += parts[i].size;
|
||||
//fi.size = fi.entry.size;
|
||||
fi.start = 0;
|
||||
llong rest = parts[i].size - (packet_size - cur_size);
|
||||
//piCout << i << fi.size << rest << bytes_all;
|
||||
@@ -494,8 +501,7 @@ bool PIBaseTransfer::getStartRequest() {
|
||||
mutex_session.lock();
|
||||
if (replies[0] == pt_ReplySuccess) {
|
||||
state_string = "send permited!";
|
||||
//packets_count = piClampi(10 / tm.elapsed_m(), 2, 100);
|
||||
//piCoutObj << "ping " << tm.elapsed_m() << packets_count;
|
||||
//piCoutObj << "ping " << tm.elapsed_m();
|
||||
mutex_session.unlock();
|
||||
return true;
|
||||
}
|
||||
@@ -528,9 +534,7 @@ void PIBaseTransfer::processData(int id, PIByteArray & data) {
|
||||
while (!data.isEmpty()) {
|
||||
ba.clear();
|
||||
data >> fi;
|
||||
//if (fi.size > 0)
|
||||
data >> ba;
|
||||
//fi.fsize = ba.size();
|
||||
bytes_cur += fi.size;
|
||||
//piCoutObj << "recv" << fi;
|
||||
session[id - 1] << fi;
|
||||
@@ -549,7 +553,6 @@ PIByteArray PIBaseTransfer::build_packet(int id) {
|
||||
PIByteArray ret;
|
||||
PIByteArray ba;
|
||||
//piCoutObj << "session id" << header.session_id;
|
||||
//ret << header;
|
||||
ret.append(customHeader());
|
||||
mutex_session.lock();
|
||||
for (int i = 0; i < session[id].size_s(); i++) {
|
||||
@@ -587,7 +590,6 @@ bool PIBaseTransfer::finish_send(bool ok) {
|
||||
mutex_header.unlock();
|
||||
//piCoutObj << state_string << PIString::readableSize(bytes_all);
|
||||
sendFinished(ok);
|
||||
// diag.stop();
|
||||
bytes_all = bytes_cur = 0;
|
||||
return ok;
|
||||
}
|
||||
@@ -604,7 +606,6 @@ void PIBaseTransfer::finish_receive(bool ok, bool quet) {
|
||||
}
|
||||
//piCoutObj << state_string << PIString::readableSize(bytes_all);
|
||||
receiveFinished(ok);
|
||||
// diag.stop();
|
||||
bytes_all = bytes_cur = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Base class for reliable send and receive data in fixed packets with error correction, pause and resume
|
||||
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Complex I/O point
|
||||
PIP - Platform Independent Primitives
|
||||
Complex I/O point
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "piconnection.h"
|
||||
@@ -152,7 +152,6 @@ bool PIConnection::configure(PIConfig & conf, const PIString & name_) {
|
||||
PIIODevice * dev = addDevice(fn, dm);
|
||||
if (!dev) continue;
|
||||
dev_aliases[n] = fn;
|
||||
//device_names[n] = dev;
|
||||
setDeviceName(dev, n);
|
||||
dev->setName(name_ + ".device." + dev_list[i]);
|
||||
PIConfig::Entry de = ce.getValue("device." + n);
|
||||
@@ -357,7 +356,6 @@ PIIODevice * PIConnection::addDevice(const PIString & full_path, PIIODevice::Dev
|
||||
void PIConnection::setDeviceName(PIIODevice * dev, const PIString & name) {
|
||||
if (!dev) return;
|
||||
device_names[name] = dev;
|
||||
//dev->setProperty();
|
||||
}
|
||||
|
||||
|
||||
@@ -522,7 +520,6 @@ PIPacketExtractor * PIConnection::addFilter(PIPacketExtractor * filter, const PI
|
||||
}
|
||||
if (!e->devices.contains(dev)) {
|
||||
bounded_extractors[dev] << e->extractor;
|
||||
//if (PIString(dev->className()) == "PIPacketExtractor") dev->setThreadSafe(false);
|
||||
e->devices << dev;
|
||||
}
|
||||
return e->extractor;
|
||||
@@ -1124,7 +1121,6 @@ void __DevicePool_threadReadDP(void * ddp) {
|
||||
if (!dev->open()) {piMSleep(dev->reopenTimeout()); return;}
|
||||
PIByteArray ba;
|
||||
ba = dev->read(dev->threadedReadBufferSize());
|
||||
// dd->dev->threadedRead(ba.data(), ba.size());
|
||||
if (ba.isEmpty()) {piMSleep(10); return;}
|
||||
dev->threadedRead(ba.data(), ba.size_s());
|
||||
dev->threadedReadEvent(ba.data(), ba.size_s());
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
* \brief Complex I/O point
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Complex I/O point
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Complex I/O point
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PICONNECTION_H
|
||||
@@ -43,7 +43,6 @@ public:
|
||||
|
||||
~PIConnection();
|
||||
|
||||
|
||||
/*! \brief Configure connection from config file "config" from section "name". Returns if configuration was successful
|
||||
* \details \b Warning: all devices, filters and channels removed before configure! */
|
||||
bool configureFromConfig(const PIString & config, const PIString & name = PIStringAscii("connection"));
|
||||
@@ -84,7 +83,6 @@ public:
|
||||
//! Returns all devices bounded to this connection
|
||||
PIVector<PIIODevice * > boundedDevices() const;
|
||||
|
||||
|
||||
/*! \brief Add filter with name "name" to device with full path "full_path_name" or filter "full_path_name"
|
||||
* \details If there is no filter with name "name", connection create new with split mode "mode" and bound
|
||||
* to it device "full_path_name" or filter "full_path_name". If filter with name "name" already exists,
|
||||
@@ -115,7 +113,6 @@ public:
|
||||
//! Remove all filters from connection
|
||||
void removeAllFilters();
|
||||
|
||||
|
||||
//! Returns all filters of connection
|
||||
PIVector<PIPacketExtractor * > filters() const;
|
||||
|
||||
@@ -128,7 +125,6 @@ public:
|
||||
//! Returns all devices bounded to filter "name"
|
||||
PIVector<PIIODevice * > filterBoundedDevices(const PIString & name) const;
|
||||
|
||||
|
||||
/*! \brief Add to connection channel from "name_from" to "name_to"
|
||||
* \details "name_from" and "name_to" can be full pathes of devices or device names or filter names.
|
||||
* Returns \b false if there if no such device or filter, else create channel and returns \b true */
|
||||
@@ -171,7 +167,6 @@ public:
|
||||
//! Returns all channels of this connection as full pathes or filter names pair array (from, to)
|
||||
PIVector<PIPair<PIString, PIString> > channels() const;
|
||||
|
||||
|
||||
/*! \brief Add to connection sender with name "name" device with full path "full_path"
|
||||
* \details If there is no sender with name "name", connection create new, bound
|
||||
* to it device "full_path_name" and start sender timer with frequency "frequency".
|
||||
@@ -209,7 +204,6 @@ public:
|
||||
//! Remove from connection all senders
|
||||
void removeAllSenders();
|
||||
|
||||
|
||||
//! Start read thread of device with full path "full_path"
|
||||
void startThreadedRead(const PIString & full_path_name);
|
||||
|
||||
@@ -259,7 +253,6 @@ public:
|
||||
//! Returns PIDiagnostics * assosiated with device or filter "dev"
|
||||
PIDiagnostics * diagnostic(const PIIODevice * dev) const {return diags_.value(const_cast<PIIODevice * >(dev), 0);}
|
||||
|
||||
|
||||
//! Write data "data" to device with full path "full_path" and returns result of \a write() function of device
|
||||
int writeByFullPath(const PIString & full_path, const PIByteArray & data);
|
||||
|
||||
@@ -269,7 +262,6 @@ public:
|
||||
//! Write data "data" to device "dev" and returns result of \a write() function of device
|
||||
int write(PIIODevice * dev, const PIByteArray & data);
|
||||
|
||||
|
||||
//! Returns all connections in application
|
||||
static PIVector<PIConnection * > allConnections();
|
||||
|
||||
@@ -407,7 +399,6 @@ private:
|
||||
PIMap<PIIODevice * , PIDiagnostics * > diags_;
|
||||
|
||||
static PIVector<PIConnection * > _connections;
|
||||
|
||||
};
|
||||
|
||||
void __DevicePool_threadReadDP(void * ddp);
|
||||
|
||||
@@ -1,17 +1,36 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Class for send and receive PIByteArray via PIBaseTransfer
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "pidatatransfer.h"
|
||||
|
||||
|
||||
PIByteArray PIDataTransfer::buildPacket(Part fi) {
|
||||
PIByteArray ba;
|
||||
ba.resize(fi.size);
|
||||
memcpy(ba.data(), data_.data(fi.start), fi.size);
|
||||
memcpy(ba.data(), data_.data(fi.start), fi.size);
|
||||
return ba;
|
||||
}
|
||||
|
||||
|
||||
void PIDataTransfer::receivePart(Part fi, PIByteArray ba, PIByteArray pheader) {
|
||||
if (data_.size() < fi.start + fi.size) data_.resize(fi.start + fi.size);
|
||||
memcpy(data_.data(fi.start), ba.data(), ba.size_s());
|
||||
memcpy(data_.data(fi.start), ba.data(), ba.size_s());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Class for send and receive PIByteArray via PIBaseTransfer
|
||||
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "pibasetransfer.h"
|
||||
|
||||
|
||||
class PIP_EXPORT PIDataTransfer: public PIBaseTransfer
|
||||
{
|
||||
PIOBJECT_SUBCLASS(PIDataTransfer, PIBaseTransfer)
|
||||
@@ -39,7 +40,6 @@ private:
|
||||
virtual PIByteArray buildPacket(Part p);
|
||||
virtual void receivePart(PIBaseTransfer::Part fi, PIByteArray ba, PIByteArray pheader);
|
||||
PIByteArray data_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Speed and quality in/out diagnostics
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Speed and quality in/out diagnostics
|
||||
Andrey Bychkov work.a.b@yandex.ru, Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "pidiagnostics.h"
|
||||
@@ -37,8 +37,6 @@
|
||||
* */
|
||||
|
||||
|
||||
|
||||
|
||||
PIDiagnostics::State::State() {
|
||||
immediate_freq = integral_freq = 0.f;
|
||||
received_packets_per_sec = 0ull;
|
||||
@@ -71,7 +69,6 @@ PIDiagnostics::PIDiagnostics(bool start_): PITimer(/*PITimer::Pool*/) {
|
||||
|
||||
PIDiagnostics::~PIDiagnostics() {
|
||||
//piCout << "~PIDiagnostics start...";
|
||||
//PITimer::stop();
|
||||
//piCout << "~PIDiagnostics done!";
|
||||
}
|
||||
|
||||
@@ -179,8 +176,6 @@ void PIDiagnostics::tick(void * , int ) {
|
||||
cur_state.sended_bytes_per_sec = ullong(double(send.bytes_ok) / its);
|
||||
}
|
||||
//piCoutObj << "tick" << recv.cnt_ok << send.cnt_ok;
|
||||
// speedRecv = PIString::readableSize(ullong(double(history_rec.front().bytes_ok) / hz)) + "/s";
|
||||
// speedSend = PIString::readableSize(ullong(double(history_send.front().bytes_ok) / hz)) + "/s";
|
||||
cur_state.receive_speed = PIString::readableSize(cur_state.received_bytes_per_sec) + "/s";
|
||||
cur_state.send_speed = PIString::readableSize(cur_state.sended_bytes_per_sec) + "/s";
|
||||
int arc = recv.cnt_ok + recv.cnt_fail;
|
||||
@@ -237,7 +232,6 @@ void PIDiagnostics::propertyChanged(const PIString &) {
|
||||
|
||||
|
||||
void PIDiagnostics::changeDisconnectTimeout(float disct) {
|
||||
//PITimer::stop();
|
||||
mutex_state.lock();
|
||||
disconn_ = piMaxf(disct, interval() / 1000.f);
|
||||
if (interval() > 0) {
|
||||
@@ -251,15 +245,5 @@ void PIDiagnostics::changeDisconnectTimeout(float disct) {
|
||||
}
|
||||
//piCoutObj << hist_size << disconn_ << interval();
|
||||
mutex_state.unlock();
|
||||
//PITimer::start();
|
||||
}
|
||||
|
||||
|
||||
//void PIDiagnostics::constLock() const {
|
||||
// const_cast<PIDiagnostics*>(this)->lock();
|
||||
//}
|
||||
|
||||
|
||||
//void PIDiagnostics::constUnlock() const {
|
||||
// const_cast<PIDiagnostics*>(this)->unlock();
|
||||
//}
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
* \brief Connection quality diagnostics
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Speed and quality in/out diagnostics
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Speed and quality in/out diagnostics
|
||||
Andrey Bychkov work.a.b@yandex.ru, Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIDIAGNOSTICS_H
|
||||
@@ -77,44 +77,6 @@ public:
|
||||
//! Returns period of full disconnect in seconds and period of averaging frequency
|
||||
void setDisconnectTimeout(float s) {setProperty("disconnectTimeout", s);}
|
||||
|
||||
/*
|
||||
//! Returns immediate receive frequency, packets/s
|
||||
float immediateFrequency() const {return cur_state.immediate_freq;}
|
||||
|
||||
//! Returns integral receive frequency for \a disconnectTimeout() seconds, packets/s
|
||||
float integralFrequency() const {return cur_state.integral_freq;}
|
||||
|
||||
//! Returns correct received packets per second
|
||||
ullong receiveCountPerSec() const {return cur_state.received_packets_per_sec;}
|
||||
|
||||
//! Returns sended packets per second
|
||||
ullong sendCountPerSec() const {return cur_state.sended_packets_per_sec;}
|
||||
|
||||
//! Returns correct received bytes per second
|
||||
ullong receiveBytesPerSec() const {return cur_state.received_bytes_per_sec;}
|
||||
|
||||
//! Returns sended bytes per second
|
||||
ullong sendBytesPerSec() const {return cur_state.sended_bytes_per_sec;}
|
||||
|
||||
//! Returns overall correct received bytes
|
||||
ullong receiveBytes() const {return cur_state.received_bytes;}
|
||||
|
||||
//! Returns overall wrong received bytes
|
||||
ullong wrongBytes() const {return cur_state.received_bytes_wrong;}
|
||||
|
||||
//! Returns overall sended bytes
|
||||
ullong sendBytes() const {return cur_state.sended_bytes;}
|
||||
|
||||
//! Returns overall correct received packets count
|
||||
ullong receiveCount() const {return cur_state.received_packets;}
|
||||
|
||||
//! Returns overall wrong received packets count
|
||||
ullong wrongCount() const {return cur_state.received_packets_wrong;}
|
||||
|
||||
//! Returns overall sended packets count
|
||||
ullong sendCount() const {return cur_state.sended_packets;}
|
||||
*/
|
||||
|
||||
//! Returns connection quality
|
||||
PIDiagnostics::Quality quality() const;
|
||||
|
||||
@@ -124,55 +86,9 @@ public:
|
||||
//! Returns send speed in format "n {B|kB|MB|GB|TB}/s"
|
||||
PIString sendSpeed() const;
|
||||
|
||||
/* DEPRECATED
|
||||
//! Returns immediate receive frequency pointer, packets/s. Useful for output to PIConsole
|
||||
const float * immediateFrequency_ptr() const {return &cur_state.immediate_freq;}
|
||||
|
||||
//! Returns integral receive frequency pointer for period, packets/s. Useful for output to PIConsole
|
||||
const float * integralFrequency_ptr() const {return &cur_state.integral_freq;}
|
||||
|
||||
//! Returns correct received packets per second pointer. Useful for output to PIConsole
|
||||
const ullong * receiveCountPerSec_ptr() const {return &cur_state.received_packets_per_sec;}
|
||||
|
||||
//! Returns sended packets per second pointer. Useful for output to PIConsole
|
||||
const ullong * sendCountPerSec_ptr() const {return &cur_state.sended_packets_per_sec;}
|
||||
|
||||
//! Returns correct received bytes per second pointer. Useful for output to PIConsole
|
||||
const ullong * receiveBytesPerSec_ptr() const {return &cur_state.received_bytes_per_sec;}
|
||||
|
||||
//! Returns sended bytes per second pointer. Useful for output to PIConsole
|
||||
const ullong * sendBytesPerSec_ptr() const {return &cur_state.sended_bytes_per_sec;}
|
||||
|
||||
//! Returns overall correct received bytes pointer. Useful for output to PIConsole
|
||||
const ullong * receiveBytes_ptr() const {return &cur_state.received_bytes;}
|
||||
|
||||
//! Returns overall wrong received bytes pointer. Useful for output to PIConsole
|
||||
const ullong * wrongBytes_ptr() const {return &cur_state.received_bytes_wrong;}
|
||||
|
||||
//! Returns overall sended bytes pointer. Useful for output to PIConsole
|
||||
const ullong * sendBytes_ptr() const {return &cur_state.sended_bytes;}
|
||||
|
||||
//! Returns overall correct received packets count pointer. Useful for output to PIConsole
|
||||
const ullong * receiveCount_ptr() const {return &cur_state.received_packets;}
|
||||
|
||||
//! Returns overall wrong received packets count pointer. Useful for output to PIConsole
|
||||
const ullong * wrongCount_ptr() const {return &cur_state.received_packets_wrong;}
|
||||
|
||||
//! Returns overall sended packets count pointer. Useful for output to PIConsole
|
||||
const ullong * sendCount_ptr() const {return &cur_state.sended_packets;}
|
||||
|
||||
//! Returns connection quality pointer. Useful for output to PIConsole
|
||||
const int * quality_ptr() const {return (int * )&cur_state.quality;}
|
||||
|
||||
//! Returns receive speed pointer in format "n {B|kB|MB|GB|TB}/s". Useful for output to PIConsole
|
||||
const PIString * receiveSpeed_ptr() const {return &cur_state.receive_speed;}
|
||||
|
||||
//! Returns send speed pointer in format "n {B|kB|MB|GB|TB}/s". Useful for output to PIConsole
|
||||
const PIString * sendSpeed_ptr() const {return &cur_state.send_speed;}*/
|
||||
|
||||
EVENT_HANDLER0(void, start) {PITimer::start(100.); changeDisconnectTimeout(disconn_);}
|
||||
EVENT_HANDLER1(void, start, double, msecs) {if (msecs > 0.) {PITimer::start(msecs); changeDisconnectTimeout(disconn_);}}
|
||||
//EVENT_HANDLER0(void, stop) {PITimer::stop();}
|
||||
EVENT_HANDLER0(void, reset);
|
||||
|
||||
EVENT_HANDLER1(void, received, int, size) {received(size, true);}
|
||||
@@ -224,8 +140,6 @@ private:
|
||||
Entry calcHistory(PIQueue<Entry> & hist, int & cnt);
|
||||
void propertyChanged(const PIString &);
|
||||
void changeDisconnectTimeout(float disct);
|
||||
// void constLock() const;
|
||||
// void constUnlock() const;
|
||||
|
||||
PIQueue<Entry> history_rec, history_send;
|
||||
float disconn_;
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Class for send and receive files and directories via PIBaseTransfer
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "pifiletransfer.h"
|
||||
|
||||
const char PIFileTransfer::sign[] = {'P', 'F', 'T'};
|
||||
@@ -11,7 +30,6 @@ PIFileTransfer::PIFileTransfer() {
|
||||
dir = PIDir::current();
|
||||
started_ = scanning = false;
|
||||
bytes_file_all = bytes_file_cur = 0;
|
||||
// CONNECT(void, this, sendStarted, this, send_started);
|
||||
CONNECT(void, this, receiveStarted, this, receive_started);
|
||||
CONNECT1(void, bool, this, sendFinished, this, send_finished);
|
||||
CONNECT1(void, bool, this, receiveFinished, this, receive_finished);
|
||||
@@ -72,7 +90,6 @@ bool PIFileTransfer::sendFiles(const PIVector<PFTFileInfo> &files) {
|
||||
PIStringList names;
|
||||
//piCoutObj << "prepare to send" << files_.size() << "files";
|
||||
for (int i = 0; i < files_.size_s(); i++) {
|
||||
//files_[i].path = dir.relative(files_[i].path);
|
||||
if (names.contains(files_[i].path)) {
|
||||
files_.remove(i);
|
||||
--i;
|
||||
@@ -212,10 +229,6 @@ PIByteArray PIFileTransfer::buildPacket(Part p) {
|
||||
return PIByteArray();
|
||||
}
|
||||
}
|
||||
//if (fi.isDir()) {
|
||||
// piCout << "create dir" << fi.path;
|
||||
// dir.make(fi.path);
|
||||
//}
|
||||
cur_file_string = fi.path;
|
||||
bytes_file_all = fi.size;
|
||||
bytes_file_cur = p.start;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Class for send and receive files and directories via PIBaseTransfer
|
||||
Copyright (C) 2020 Andrey Bychkov work.a.b@yandex.ru
|
||||
Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -103,7 +103,6 @@ private:
|
||||
virtual void receivePart(Part fi, PIByteArray ba, PIByteArray pheader);
|
||||
virtual PIByteArray buildPacket(Part fi);
|
||||
virtual PIByteArray customHeader();
|
||||
// EVENT_HANDLER(void, send_started);
|
||||
EVENT_HANDLER(void, receive_started);
|
||||
EVENT_HANDLER1(void, send_finished, bool, ok);
|
||||
EVENT_HANDLER1(void, receive_finished, bool, ok);
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Module includes
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Module includes
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIIOUTILSMODULE_H
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Packets extractor
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Packets extractor
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -109,13 +109,13 @@ public:
|
||||
//! Returns missed by validating functions bytes count
|
||||
ullong missedBytes() const {return missed;}
|
||||
|
||||
// //! Returns missed by validating functions packets count, = missedBytes() / packetSize
|
||||
ullong missedPackets() const {/*if (packetSize_hf == 0) return missed; return missed / packetSize_hf*/; return missed_packets;}
|
||||
//! Returns missed by validating functions packets count, = missedBytes() / packetSize
|
||||
ullong missedPackets() const {return missed_packets;}
|
||||
|
||||
//! Returns pointer to \a missedBytes() count. Useful for output to PIConsole
|
||||
const ullong * missedBytes_ptr() const {return &missed;}
|
||||
|
||||
// //! Returns pointer to \a missedPackets() count. Useful for output to PIConsole
|
||||
//! Returns pointer to \a missedPackets() count. Useful for output to PIConsole
|
||||
const ullong * missedPackets_ptr() const {return &missed_packets;}
|
||||
|
||||
//! Add data to extractor, raise \a packetReceived() if packet is ready
|
||||
|
||||
Reference in New Issue
Block a user