git-svn-id: svn://db.shs.com.ru/pip@755 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2019-02-15 14:45:34 +00:00
parent e1d1853235
commit 0af7eabf56
10 changed files with 140 additions and 63 deletions

View File

@@ -833,14 +833,14 @@ void PIConsole::addVariable(const PIString & name, const PISystemTime * ptr, int
* */ * */
void PIConsole::addVariable(const PIString & name, const PIDiagnostics * ptr, int col, FormatFlags format) { void PIConsole::addVariable(const PIString & name, const PIDiagnostics * ptr, int col, FormatFlags format) {
addString(name + " diagnostics", col, format | PIConsole::Bold); addString(name + " diagnostics", col, format | PIConsole::Bold);
addVariable("Received count", ptr->receiveCount_ptr(), col, format); // addVariable("Received count", ptr->receiveCount_ptr(), col, format);
addVariable("Invalid count", ptr->wrongCount_ptr(), col, format); // addVariable("Invalid count", ptr->wrongCount_ptr(), col, format);
addVariable("Sended count", ptr->sendCount_ptr(), col, format); // addVariable("Sended count", ptr->sendCount_ptr(), col, format);
addVariable("Immediate Frequency, Hz", ptr->immediateFrequency_ptr(), col, format); // addVariable("Immediate Frequency, Hz", ptr->immediateFrequency_ptr(), col, format);
addVariable("Integral Frequency, Hz", ptr->integralFrequency_ptr(), col, format); // addVariable("Integral Frequency, Hz", ptr->integralFrequency_ptr(), col, format);
addVariable("Receive speed", ptr->receiveSpeed_ptr(), col, format); // addVariable("Receive speed", ptr->receiveSpeed_ptr(), col, format);
addVariable("Send speed", ptr->sendSpeed_ptr(), col, format); // addVariable("Send speed", ptr->sendSpeed_ptr(), col, format);
addVariable("Quality", ptr->quality_ptr(), col, format); // addVariable("Quality", ptr->quality_ptr(), col, format);
} }
void PIConsole::addVariable(const PIString & name, const PISystemMonitor * ptr, int col, FormatFlags format) { void PIConsole::addVariable(const PIString & name, const PISystemMonitor * ptr, int col, FormatFlags format) {
addString("monitor " + name, col, format | PIConsole::Bold); addString("monitor " + name, col, format | PIConsole::Bold);

View File

@@ -65,6 +65,7 @@ void piUSleep(int usecs) {
#ifdef WINDOWS #ifdef WINDOWS
//printf("Sleep %d\n", usecs / 1000); //printf("Sleep %d\n", usecs / 1000);
if (usecs > 0) Sleep(usecs / 1000); if (usecs > 0) Sleep(usecs / 1000);
//printf("Sleep end");
#else #else
# ifdef FREERTOS # ifdef FREERTOS
vTaskDelay(usecs / 1000 / portTICK_PERIOD_MS); vTaskDelay(usecs / 1000 / portTICK_PERIOD_MS);

View File

@@ -26,11 +26,14 @@ PIBaseTransfer::PIBaseTransfer(): crc(standardCRC_16()), diag(false) {
setPacketSize(4096); setPacketSize(4096);
#endif #endif
randomize(); randomize();
piCout << "PIBaseTransfer" << &diag;
} }
PIBaseTransfer::~PIBaseTransfer() { PIBaseTransfer::~PIBaseTransfer() {
piCout << "~PIBaseTransfer" << &diag;
diag.stop(); diag.stop();
piCout << "~PIBaseTransfer done";
break_ = true; break_ = true;
} }

View File

@@ -60,40 +60,56 @@ PIDiagnostics::State::State() {
PIDiagnostics::PIDiagnostics(bool start_): PITimer(/*PITimer::Pool*/) { PIDiagnostics::PIDiagnostics(bool start_): PITimer(/*PITimer::Pool*/) {
disconn_ = 0.; disconn_ = 0.;
setInterval(100); piCout << "PIDiagnostics construct";
setInterval(500);
reset(); reset();
setDisconnectTimeout(3.); setDisconnectTimeout(3.);
changeDisconnectTimeout(3.); changeDisconnectTimeout(3.);
if (start_) start(100); if (start_) PITimer::start(500);
piCout << "PIDiagnostics construct done";
}
PIDiagnostics::~PIDiagnostics() {
piCout << "~PIDiagnostics start...";
PITimer::stop();
piCout << "~PIDiagnostics done!";
} }
PIDiagnostics::State PIDiagnostics::state() const { PIDiagnostics::State PIDiagnostics::state() const {
constLock(); mutex_state.lock();
State ret = cur_state; State ret = cur_state;
constUnlock(); mutex_state.unlock();
return ret;
}
PIDiagnostics::Quality PIDiagnostics::quality() const {
PIDiagnostics::Quality ret;
mutex_state.lock();
ret = cur_state.quality;
mutex_state.unlock();
return ret; return ret;
} }
PIString PIDiagnostics::receiveSpeed() const { PIString PIDiagnostics::receiveSpeed() const {
constLock(); mutex_state.lock();
PIString ret = cur_state.receive_speed; PIString ret = cur_state.receive_speed;
constUnlock(); mutex_state.unlock();
return ret; return ret;
} }
PIString PIDiagnostics::sendSpeed() const { PIString PIDiagnostics::sendSpeed() const {
constLock(); mutex_state.lock();
PIString ret = cur_state.send_speed; PIString ret = cur_state.send_speed;
constUnlock(); mutex_state.unlock();
return ret; return ret;
} }
void PIDiagnostics::reset() { void PIDiagnostics::reset() {
lock(); mutex_state.lock();
cur_state = State(); cur_state = State();
if (disconn_ != 0.) { if (disconn_ != 0.) {
int hist_size = history_rec.size(); int hist_size = history_rec.size();
@@ -102,12 +118,12 @@ void PIDiagnostics::reset() {
history_rec.resize(hist_size); history_rec.resize(hist_size);
history_send.resize(hist_size); history_send.resize(hist_size);
} }
unlock(); mutex_state.unlock();
} }
void PIDiagnostics::received(int size, bool correct) { void PIDiagnostics::received(int size, bool correct) {
lock(); mutex_state.lock();
Entry & e(history_rec.front()); Entry & e(history_rec.front());
if (correct) { if (correct) {
e.cnt_ok++; e.cnt_ok++;
@@ -121,24 +137,25 @@ void PIDiagnostics::received(int size, bool correct) {
cur_state.received_bytes_wrong += size; cur_state.received_bytes_wrong += size;
} }
e.empty = false; e.empty = false;
unlock(); mutex_state.unlock();
} }
void PIDiagnostics::sended(int size) { void PIDiagnostics::sended(int size) {
lock(); mutex_state.lock();
Entry & e(history_send.front()); Entry & e(history_send.front());
e.cnt_ok++; e.cnt_ok++;
e.bytes_ok += size; e.bytes_ok += size;
cur_state.sended_packets++; cur_state.sended_packets++;
cur_state.sended_bytes += size; cur_state.sended_bytes += size;
e.empty = false; e.empty = false;
unlock(); mutex_state.unlock();
} }
void PIDiagnostics::tick(void * , int ) { void PIDiagnostics::tick(void * , int ) {
lock(); mutex_state.lock();
//piCoutObj << "lock";
int tcnt_recv = 0; int tcnt_recv = 0;
int tcnt_send = 0; int tcnt_send = 0;
Entry send = calcHistory(history_send, tcnt_send); Entry send = calcHistory(history_send, tcnt_send);
@@ -161,7 +178,7 @@ void PIDiagnostics::tick(void * , int ) {
cur_state.sended_packets_per_sec = ullong(float(send.cnt_ok) / its); cur_state.sended_packets_per_sec = ullong(float(send.cnt_ok) / its);
cur_state.sended_bytes_per_sec = ullong(double(send.bytes_ok) / its); cur_state.sended_bytes_per_sec = ullong(double(send.bytes_ok) / its);
} }
// piCoutObj << "tick" << recv.cnt_ok << send.cnt_ok; //piCoutObj << "tick" << recv.cnt_ok << send.cnt_ok;
// speedRecv = PIString::readableSize(ullong(double(history_rec.front().bytes_ok) / hz)) + "/s"; // speedRecv = PIString::readableSize(ullong(double(history_rec.front().bytes_ok) / hz)) + "/s";
// speedSend = PIString::readableSize(ullong(double(history_send.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.receive_speed = PIString::readableSize(cur_state.received_bytes_per_sec) + "/s";
@@ -192,7 +209,8 @@ void PIDiagnostics::tick(void * , int ) {
qualityChanged(diag, cur_state.quality); qualityChanged(diag, cur_state.quality);
cur_state.quality = diag; cur_state.quality = diag;
} }
unlock(); mutex_state.unlock();
//piCoutObj << "unlock";
} }
@@ -219,7 +237,8 @@ void PIDiagnostics::propertyChanged(const PIString &) {
void PIDiagnostics::changeDisconnectTimeout(float disct) { void PIDiagnostics::changeDisconnectTimeout(float disct) {
lock(); //PITimer::stop();
mutex_state.lock();
disconn_ = piMaxf(disct, interval() / 1000.f); disconn_ = piMaxf(disct, interval() / 1000.f);
if (interval() > 0) { if (interval() > 0) {
int hist_size = piClampi(int(disconn_ * 1000.f / float(interval())), 1, 65536); int hist_size = piClampi(int(disconn_ * 1000.f / float(interval())), 1, 65536);
@@ -231,15 +250,16 @@ void PIDiagnostics::changeDisconnectTimeout(float disct) {
history_send.resize(1); history_send.resize(1);
} }
//piCoutObj << hist_size << disconn_ << interval(); //piCoutObj << hist_size << disconn_ << interval();
unlock(); mutex_state.unlock();
//PITimer::start();
} }
void PIDiagnostics::constLock() const { //void PIDiagnostics::constLock() const {
const_cast<PIDiagnostics*>(this)->lock(); // const_cast<PIDiagnostics*>(this)->lock();
} //}
void PIDiagnostics::constUnlock() const { //void PIDiagnostics::constUnlock() const {
const_cast<PIDiagnostics*>(this)->unlock(); // const_cast<PIDiagnostics*>(this)->unlock();
} //}

View File

@@ -36,7 +36,7 @@ public:
//! Constructs an empty diagnostics and if "start_" start it //! Constructs an empty diagnostics and if "start_" start it
PIDiagnostics(bool start_ = true); PIDiagnostics(bool start_ = true);
virtual ~PIDiagnostics() {;} virtual ~PIDiagnostics();
//! Connection quality //! Connection quality
enum Quality { enum Quality {
@@ -77,6 +77,7 @@ public:
//! Returns period of full disconnect in seconds and period of averaging frequency //! Returns period of full disconnect in seconds and period of averaging frequency
void setDisconnectTimeout(float s) {setProperty("disconnectTimeout", s);} void setDisconnectTimeout(float s) {setProperty("disconnectTimeout", s);}
/*
//! Returns immediate receive frequency, packets/s //! Returns immediate receive frequency, packets/s
float immediateFrequency() const {return cur_state.immediate_freq;} float immediateFrequency() const {return cur_state.immediate_freq;}
@@ -112,9 +113,10 @@ public:
//! Returns overall sended packets count //! Returns overall sended packets count
ullong sendCount() const {return cur_state.sended_packets;} ullong sendCount() const {return cur_state.sended_packets;}
*/
//! Returns connection quality //! Returns connection quality
PIDiagnostics::Quality quality() const {return cur_state.quality;} PIDiagnostics::Quality quality() const;
//! Returns receive speed in format "n {B|kB|MB|GB|TB}/s" //! Returns receive speed in format "n {B|kB|MB|GB|TB}/s"
PIString receiveSpeed() const; PIString receiveSpeed() const;
@@ -122,7 +124,7 @@ public:
//! Returns send speed in format "n {B|kB|MB|GB|TB}/s" //! Returns send speed in format "n {B|kB|MB|GB|TB}/s"
PIString sendSpeed() const; PIString sendSpeed() const;
/* DEPRECATED
//! Returns immediate receive frequency pointer, packets/s. Useful for output to PIConsole //! Returns immediate receive frequency pointer, packets/s. Useful for output to PIConsole
const float * immediateFrequency_ptr() const {return &cur_state.immediate_freq;} const float * immediateFrequency_ptr() const {return &cur_state.immediate_freq;}
@@ -166,9 +168,9 @@ public:
const PIString * receiveSpeed_ptr() const {return &cur_state.receive_speed;} 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 //! 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;} const PIString * sendSpeed_ptr() const {return &cur_state.send_speed;}*/
EVENT_HANDLER0(void, start) {start(100.); changeDisconnectTimeout(disconn_);} EVENT_HANDLER0(void, start) {PITimer::start(100.); changeDisconnectTimeout(disconn_);}
EVENT_HANDLER1(void, start, double, msecs) {if (msecs > 0.) {PITimer::start(msecs); 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, stop) {PITimer::stop();}
EVENT_HANDLER0(void, reset); EVENT_HANDLER0(void, reset);
@@ -220,12 +222,13 @@ private:
Entry calcHistory(PIQueue<Entry> & hist, int & cnt); Entry calcHistory(PIQueue<Entry> & hist, int & cnt);
void propertyChanged(const PIString &); void propertyChanged(const PIString &);
void changeDisconnectTimeout(float disct); void changeDisconnectTimeout(float disct);
void constLock() const; // void constLock() const;
void constUnlock() const; // void constUnlock() const;
PIQueue<Entry> history_rec, history_send; PIQueue<Entry> history_rec, history_send;
float disconn_; float disconn_;
State cur_state; State cur_state;
mutable PIMutex mutex_state;
}; };

View File

@@ -168,6 +168,7 @@ PIThread::PIThread(void * data, ThreadFunc func, bool startNow, int timer_delay)
terminating = running_ = lockRun = false; terminating = running_ = lockRun = false;
priority_ = piNormal; priority_ = piNormal;
delay_ = timer_delay; delay_ = timer_delay;
piCout << "PIThread" << this;
if (startNow) start(timer_delay); if (startNow) start(timer_delay);
} }
@@ -180,6 +181,7 @@ PIThread::PIThread(bool startNow, int timer_delay): PIObject() {
terminating = running_ = lockRun = false; terminating = running_ = lockRun = false;
priority_ = piNormal; priority_ = piNormal;
delay_ = timer_delay; delay_ = timer_delay;
piCout << "PIThread" << this;
if (startNow) start(timer_delay); if (startNow) start(timer_delay);
} }
@@ -202,6 +204,8 @@ PIThread::~PIThread() {
pthread_cancel(PRIVATE->thread); pthread_cancel(PRIVATE->thread);
# endif # endif
# else # else
piCout << "terminate by ~PIThread" << this;
while(1) msleep(10);
TerminateThread(PRIVATE->thread, 0); TerminateThread(PRIVATE->thread, 0);
CloseHandle(PRIVATE->thread); CloseHandle(PRIVATE->thread);
# endif # endif
@@ -321,6 +325,10 @@ void PIThread::terminate() {
//pthread_join(PRIVATE->thread, &ret); //pthread_join(PRIVATE->thread, &ret);
# endif # endif
#else #else
piCout << "terminate by terminate";
while (1) {
msleep(10);
}
TerminateThread(PRIVATE->thread, 0); TerminateThread(PRIVATE->thread, 0);
CloseHandle(PRIVATE->thread); CloseHandle(PRIVATE->thread);
#endif #endif
@@ -438,12 +446,12 @@ void PIThread::__thread_func__(void * t) {
while (!ct.terminating) { while (!ct.terminating) {
ct.maybeCallQueuedEvents(); ct.maybeCallQueuedEvents();
if (ct.lockRun) ct.mutex_.lock(); if (ct.lockRun) ct.mutex_.lock();
//piCout << "thread" << ct.name() << "..."; // piCout << "thread" << ct.name() << "..." << ct.lockRun;
ct.run(); ct.run();
//piCout << "thread" << ct.name() << "done";
//printf("thread %p tick\n", &ct); //printf("thread %p tick\n", &ct);
if (ct.ret_func != 0) ct.ret_func(ct.data_); if (ct.ret_func != 0) ct.ret_func(ct.data_);
if (ct.lockRun) ct.mutex_.unlock(); if (ct.lockRun) ct.mutex_.unlock();
// piCout << "thread" << ct.name() << "done";
if (ct.delay_ > 0) { if (ct.delay_ > 0) {
ct.tmr_.reset(); ct.tmr_.reset();
double sl(0.); double sl(0.);
@@ -472,6 +480,7 @@ void PIThread::__thread_func__(void * t) {
//piCout << "pthread_exit" << (ct.__privateinitializer__.p)->thread; //piCout << "pthread_exit" << (ct.__privateinitializer__.p)->thread;
UNREGISTER_THREAD(&ct); UNREGISTER_THREAD(&ct);
PIINTROSPECTION_UNREGISTER_THREAD(ct.tid()); PIINTROSPECTION_UNREGISTER_THREAD(ct.tid());
piCout << "pthread_exit" << &ct;
#ifndef WINDOWS #ifndef WINDOWS
pthread_detach((ct.__privateinitializer__.p)->thread); pthread_detach((ct.__privateinitializer__.p)->thread);
(ct.__privateinitializer__.p)->thread = 0; (ct.__privateinitializer__.p)->thread = 0;

View File

@@ -18,6 +18,7 @@
*/ */
#include "pitimer.h" #include "pitimer.h"
#include <stdio.h>
#ifdef PIP_TIMER_RT #ifdef PIP_TIMER_RT
# include <csignal> # include <csignal>
#endif #endif
@@ -98,14 +99,15 @@ void _PITimerBase::startDeferred(double interval_ms, double delay_ms) {
bool _PITimerBase::stop(bool wait) { bool _PITimerBase::stop(bool wait) {
piCout << "_PITimerBase::stop" << isRunning();
if (!isRunning()) return true; if (!isRunning()) return true;
piCout << "_PITimerBase::stopTimer";
running_ = !stopTimer(wait); running_ = !stopTimer(wait);
return !running_; return !running_;
} }
class _PITimerImp_Thread: public _PITimerBase { class _PITimerImp_Thread: public _PITimerBase {
public: public:
_PITimerImp_Thread(); _PITimerImp_Thread();
@@ -145,7 +147,7 @@ private:
class _PITimerImp_Pool: public _PITimerImp_Thread { class _PITimerImp_Pool: public _PITimerImp_Thread {
public: public:
_PITimerImp_Pool(); _PITimerImp_Pool();
virtual ~_PITimerImp_Pool() {stop(true);} virtual ~_PITimerImp_Pool() {}
private: private:
class Pool: public PIThread { class Pool: public PIThread {
public: public:
@@ -170,12 +172,14 @@ _PITimerImp_Thread::_PITimerImp_Thread() {
wait_dt = 100; wait_dt = 100;
wait_dd = 200; wait_dd = 200;
wait_tick = 10; wait_tick = 10;
//piCout << "new _PITimerImp_Thread"; piCout << "new _PITimerImp_Thread" << &thread_ << this;
} }
_PITimerImp_Thread::~_PITimerImp_Thread() { _PITimerImp_Thread::~_PITimerImp_Thread() {
stop(true); piCout << "~_PITimerImp_Thread ..." << &thread_ << this;
thread_.stop(true);
piCout << "~_PITimerImp_Thread done" << &thread_ << this;
} }
@@ -205,6 +209,7 @@ bool _PITimerImp_Thread::startTimer(double interval_ms) {
bool _PITimerImp_Thread::stopTimer(bool wait) { bool _PITimerImp_Thread::stopTimer(bool wait) {
piCout << "stop timer..." << &thread_ << this;
#ifndef FREERTOS #ifndef FREERTOS
thread_.stop(true); thread_.stop(true);
#else #else
@@ -214,12 +219,19 @@ bool _PITimerImp_Thread::stopTimer(bool wait) {
if (thread_.isRunning()) if (thread_.isRunning())
thread_.terminate(); thread_.terminate();
#endif #endif
piCout << "stop timer done!" << this << st_wait;
return true; return true;
} }
bool _PITimerImp_Thread::threadFunc() { bool _PITimerImp_Thread::threadFunc() {
if (!running_) return false; //piCout << "threadFunc";
//printf("threadFunc\n");
if (!running_) {
//piCout << "threadFunc 1";
//printf("threadFunc 1");
return false;
}
if (deferred_) { if (deferred_) {
PISystemTime dwt; PISystemTime dwt;
int wth(wait_dt); int wth(wait_dt);
@@ -230,41 +242,69 @@ bool _PITimerImp_Thread::threadFunc() {
dwt = st_time - PISystemTime::current(true); dwt = st_time - PISystemTime::current(true);
if (wth > 0) { if (wth > 0) {
if (dwt.toMilliseconds() > wth + 1.) { if (dwt.toMilliseconds() > wth + 1.) {
piMSleep(wth); //printf("wait 2\n");
//piCout << "wait 2" << this << dwt;
msleep(wth);
//printf("threadFunc 2\n");
//piCout << "threadFunc 2";
return false; return false;
} else { } else {
//piCout << "wait 3" << this << dwt;
//printf("wait 3\n");
dwt.sleep(); dwt.sleep();
deferred_ = false; deferred_ = false;
st_time = PISystemTime::current(true); st_time = PISystemTime::current(true);
} }
} else { } else {
if (dwt.toMilliseconds() > 0.1) if (dwt.toMilliseconds() > 0.1) {
//piCout << "threadFunc 3";
//printf("threadFunc 3\n");
return false; return false;
} }
} }
}
st_wait = st_time - PISystemTime::current(true); st_wait = st_time - PISystemTime::current(true);
//piCout << "wait" << this << st_wait; //piCout << "wait" << this << st_wait;
if (st_wait.abs() > st_odt || st_wait.seconds <= -5) { if (st_wait.abs() > st_odt || st_wait.seconds <= -5) {
adjustTimes(); adjustTimes();
//piCout << "threadFunc 4";
//printf("threadFunc 4\n");
return true; return true;
} }
if (wait_tick > 0) { if (wait_tick > 0) {
if (st_wait.toMilliseconds() > wait_tick + 1.) { if (st_wait.toMilliseconds() > wait_tick + 1.) {
piMSleep(wait_tick); //piCout << "wait 5" << this << wait_tick;
//printf("wait 5 %d\n", wait_tick);
//fflush(stdout);
msleep(wait_tick);
//piCout << "threadFunc 5";
//printf("threadFunc 5\n");
//fflush(stdout);
return false; return false;
} else { } else {
//piCout << "wait 6" << this << st_wait;
//printf("wait 6 %f\n" , st_wait.toMicroseconds());
st_wait.sleep(); st_wait.sleep();
} }
} else { } else {
if (st_wait.toMilliseconds() > 0.1) if (st_wait.toMilliseconds() > 0.1) {
//piCout << "threadFunc 6";
//printf("threadFunc 6\n");
return false; return false;
} }
}
st_time += st_inc; st_time += st_inc;
if (!parent->isPIObject()) { if (!parent->isPIObject()) {
piCout << "Achtung! PITimer \"parent\" is not PIObject!"; piCout << "Achtung! PITimer \"parent\" is not PIObject!";
//piCout << "threadFunc 7";
printf("threadFunc 7\n");
return false; return false;
} }
//piCout << "timer tick";
//printf("timer tick\n");
tfunc(parent); tfunc(parent);
//piCout << "threadFunc 8";
//printf("threadFunc 8\n");
return true; return true;
} }
@@ -522,7 +562,7 @@ void PITimer::init() {
void PITimer::destroy() { void PITimer::destroy() {
//piCout << "destroy" << this << imp; //piCout << "destroy" << this << imp;
if (imp == 0) return; if (imp == 0) return;
//imp->stop(true); ///BUG: WTF FreeRTOS segfault on this! imp->stop(true); ///BUG: WTF FreeRTOS segfault on this!
delete imp; delete imp;
imp = 0; imp = 0;
} }

View File

@@ -35,7 +35,7 @@ class PIP_EXPORT _PITimerBase {
friend class PITimer; friend class PITimer;
public: public:
_PITimerBase(); _PITimerBase();
virtual ~_PITimerBase() {stop(true);} virtual ~_PITimerBase() {}
double interval() const {return interval_;} double interval() const {return interval_;}
void setInterval(double i); void setInterval(double i);

View File

@@ -158,15 +158,16 @@ public:
} }
void updatePeerDiag(TileSimple * tl, const PIDiagnostics & diag) { void updatePeerDiag(TileSimple * tl, const PIDiagnostics & diag) {
tl->content.clear(); tl->content.clear();
PIDiagnostics::State ds = diag.state();
tl->content << TileSimple::Row(diag.name() + " diagnostics", CellFormat(PIScreenTypes::Default, PIScreenTypes::Default, PIScreenTypes::Bold)); tl->content << TileSimple::Row(diag.name() + " diagnostics", CellFormat(PIScreenTypes::Default, PIScreenTypes::Default, PIScreenTypes::Bold));
tl->content << TileSimple::Row("Received count: " + PIString::fromNumber(diag.receiveCount()), CellFormat()); tl->content << TileSimple::Row("Received count: " + PIString::fromNumber(ds.received_packets), CellFormat());
tl->content << TileSimple::Row("Invalid count: " + PIString::fromNumber(diag.wrongCount()), CellFormat()); tl->content << TileSimple::Row("Invalid count: " + PIString::fromNumber(ds.received_packets_wrong), CellFormat());
tl->content << TileSimple::Row("Sended count: " + PIString::fromNumber(diag.sendCount()), CellFormat()); tl->content << TileSimple::Row("Sended count: " + PIString::fromNumber(ds.sended_packets), CellFormat());
tl->content << TileSimple::Row("Immediate Frequency, Hz: " + PIString::fromNumber(diag.immediateFrequency()), CellFormat()); tl->content << TileSimple::Row("Immediate Frequency, Hz: " + PIString::fromNumber(ds.immediate_freq), CellFormat());
tl->content << TileSimple::Row("Integral Frequency, Hz: " + PIString::fromNumber(diag.integralFrequency()), CellFormat()); tl->content << TileSimple::Row("Integral Frequency, Hz: " + PIString::fromNumber(ds.integral_freq), CellFormat());
tl->content << TileSimple::Row("Receive speed: " + diag.receiveSpeed(), CellFormat()); tl->content << TileSimple::Row("Receive speed: " + ds.receive_speed, CellFormat());
tl->content << TileSimple::Row("Send speed: " + diag.sendSpeed(), CellFormat()); tl->content << TileSimple::Row("Send speed: " + ds.send_speed, CellFormat());
tl->content << TileSimple::Row("Quality: " + PIString::fromNumber((int)diag.quality()), CellFormat()); tl->content << TileSimple::Row("Quality: " + PIString::fromNumber((int)ds.quality), CellFormat());
} }
void updatePeerInfo() { void updatePeerInfo() {
bool pm = daemon_.lockedPeers(); bool pm = daemon_.lockedPeers();

View File

@@ -106,9 +106,9 @@ private:
<< ft.diagnostic().sendSpeed() << ft.diagnostic().sendSpeed()
<< "(" << PIString::readableSize(ft.bytesFileCur()) << "/" << PIString::readableSize(ft.bytesFileAll()) << ", " << "(" << PIString::readableSize(ft.bytesFileCur()) << "/" << PIString::readableSize(ft.bytesFileAll()) << ", "
<< PIString::readableSize(ft.bytesCur()) << "/" << PIString::readableSize(ft.bytesAll()) << ")" << PIString::readableSize(ft.bytesCur()) << "/" << PIString::readableSize(ft.bytesAll()) << ")"
<< "ETA" << (ft.diagnostic().receiveBytesPerSec() > 0 ? << "ETA" << (ft.diagnostic().state().received_bytes_per_sec > 0 ?
PIString::fromNumber(PISystemTime::fromSeconds((ft.bytesAll() - ft.bytesCur()) / PIString::fromNumber(PISystemTime::fromSeconds((ft.bytesAll() - ft.bytesCur()) /
ft.diagnostic().receiveBytesPerSec()).toSeconds()) ft.diagnostic().state().received_bytes_per_sec).toSeconds())
: PIString("unknown")) : PIString("unknown"))
#ifndef WINDOWS #ifndef WINDOWS
<< Flush << Flush