version 3.21.0

add PISystemTime overload for thread/timer/io classes
This commit is contained in:
2024-07-09 16:32:27 +03:00
parent 9cd05996e7
commit 903b320629
9 changed files with 172 additions and 130 deletions

View File

@@ -38,24 +38,11 @@
PIDiagnostics::State::State() {
immediate_freq = integral_freq = 0.f;
received_packets_per_sec = 0ull;
received_packets = 0ull;
received_packets_wrong = 0ull;
received_bytes_per_sec = 0ull;
received_bytes = 0ull;
received_bytes_wrong = 0ull;
sended_packets_per_sec = 0ull;
sended_packets = 0ull;
sended_bytes_per_sec = 0ull;
sended_bytes = 0ull;
receive_speed = send_speed = PIString::readableSize(0) + "/s";
quality = PIDiagnostics::Unknown;
}
PIDiagnostics::PIDiagnostics(bool start_): PITimer(/*PITimer::Pool*/) {
disconn_ = 0.;
// piCout << "PIDiagnostics construct";
setInterval(100);
reset();
@@ -104,6 +91,20 @@ PIString PIDiagnostics::sendSpeed() const {
}
void PIDiagnostics::start() {
PITimer::start(100.);
changeDisconnectTimeout(disconn_);
}
void PIDiagnostics::start(double msecs) {
if (msecs > 0.) {
PITimer::start(msecs);
changeDisconnectTimeout(disconn_);
}
}
void PIDiagnostics::reset() {
mutex_state.lock();
cur_state = State();

View File

@@ -54,24 +54,23 @@ public:
//! Information about current diagnostics state
struct PIP_EXPORT State {
State();
float immediate_freq;
float integral_freq;
ullong received_packets_per_sec;
ullong received_packets;
ullong received_packets_wrong;
ullong received_bytes_per_sec;
ullong received_bytes;
ullong received_bytes_wrong;
ullong sended_packets_per_sec;
ullong sended_packets;
ullong sended_bytes_per_sec;
ullong sended_bytes;
float immediate_freq = 0.f;
float integral_freq = 0.f;
ullong received_packets_per_sec = 0ull;
ullong received_packets = 0ull;
ullong received_packets_wrong = 0ull;
ullong received_bytes_per_sec = 0ull;
ullong received_bytes = 0ull;
ullong received_bytes_wrong = 0ull;
ullong sended_packets_per_sec = 0ull;
ullong sended_packets = 0ull;
ullong sended_bytes_per_sec = 0ull;
ullong sended_bytes = 0ull;
PIString receive_speed;
PIString send_speed;
PIDiagnostics::Quality quality;
PIDiagnostics::Quality quality = PIDiagnostics::Unknown;
};
//! Returns current state
PIDiagnostics::State state() const;
@@ -81,6 +80,9 @@ public:
//! Returns period of full disconnect in seconds and period of averaging frequency
void setDisconnectTimeout(float s) { setProperty("disconnectTimeout", s); }
//! Returns period of full disconnect and period of averaging frequency
void setDisconnectTimeout(PISystemTime tm) { setProperty("disconnectTimeout", tm.toSeconds()); }
//! Returns connection quality
PIDiagnostics::Quality quality() const;
@@ -91,16 +93,8 @@ public:
PIString sendSpeed() const;
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, start);
EVENT_HANDLER1(void, start, double, msecs);
EVENT_HANDLER0(void, reset);
EVENT_HANDLER1(void, received, int, size) { received(size, true); }
@@ -135,16 +129,11 @@ public:
private:
struct PIP_EXPORT Entry {
Entry() {
bytes_ok = bytes_fail = 0;
cnt_ok = cnt_fail = 0;
empty = true;
}
ullong bytes_ok;
ullong bytes_fail;
uint cnt_ok;
uint cnt_fail;
bool empty;
ullong bytes_ok = 0;
ullong bytes_fail = 0;
uint cnt_ok = 0;
uint cnt_fail = 0;
bool empty = true;
};
friend bool operator==(const PIDiagnostics::Entry & f, const PIDiagnostics::Entry & s);
friend bool operator!=(const PIDiagnostics::Entry & f, const PIDiagnostics::Entry & s);
@@ -156,7 +145,7 @@ private:
void changeDisconnectTimeout(float disct);
PIQueue<Entry> history_rec, history_send;
float disconn_;
float disconn_ = 0.f;
State cur_state;
mutable PIMutex mutex_state;
};