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

This commit is contained in:
2016-08-17 15:40:37 +00:00
parent 2a7e45baff
commit f76a27d6cf
12 changed files with 253 additions and 65 deletions

View File

@@ -178,14 +178,14 @@ void Daemon::TileFileProgress::tileEvent(PIScreenTile * t, TileEvent e) {
Daemon::Daemon(): PIPeer(pisd_prefix + PISystemInfo::instance()->hostname + "_" + PIString(rand() % 100)), fm(this) {
setName("Daemon");
timer.setName("__S__Daemon_timer");
dtimer.setName("__S__Daemon_timer");
mode = offset = cur = height = 0;
CONNECTU(&screen, keyPressed, this, keyEvent)
CONNECTU(&timer, tickEvent, this, timerEvent)
CONNECTU(&dtimer, tickEvent, this, timerEvent)
CONNECTU(&fm, tileKey, this, fmKeyEvent)
CONNECTU(&fm, actionRequest, this, fmActionRequest)
timer.addDelimiter(5);
timer.start(200);
dtimer.addDelimiter(5);
dtimer.start(200);
//CONNECTU(&console, keyPressed, this, keyEvent)
//dir.setDir("/home/peri4/Documents");

View File

@@ -54,6 +54,9 @@ public:
bool lockedEth() const {return eth_mutex.isLocked();}
bool lockedPeers() const {return peers_mutex.isLocked();}
bool lockedMBcasts() const {return mc_mutex.isLocked();}
bool lockedSends() const {return send_mutex.isLocked();}
bool lockedMCSends() const {return send_mc_mutex.isLocked();}
private:
enum PacketType {
@@ -138,7 +141,7 @@ private:
void sendDirToRemote(Remote * r);
mutable PIStringList available_daemons;
PITimer timer;
PITimer dtimer;
PIString conn_name;
PIMutex remote_mutex;
PIMap<int, PIString> dnames;

View File

@@ -1,6 +1,6 @@
/*
PIP - Platform Independent Primitives
Remote console viewer
PIp System Daemon
Copyright (C) 2016 Ivan Pelipenko peri4ko@gmail.com
This program is free software: you can redistribute it and/or modify
@@ -73,7 +73,11 @@ public:
mt = tpeer = peerTile();
mt->hide(); mt->name() = "peer info";
center->addTile(mt); mtiles << mt;
mt = tpeerdiag = peerDiagTile();
mt->hide(); mt->name() = "peer diag";
center->addTile(mt); mtiles << mt;
TilePICout * outt = new TilePICout();
outt->size_policy = PIScreenTypes::Expanding;
screen.rootTile()->addTile(outt);
@@ -91,6 +95,7 @@ public:
ret->content << TileList::Row("Connect to another daemon", CellFormat());
ret->content << TileList::Row("Peer info", CellFormat());
ret->content << TileList::Row("Peer reinit", CellFormat());
ret->content << TileList::Row("Peer diagnostics", CellFormat());
ret->content << TileList::Row("Exit", CellFormat());
ret->selection_mode = TileList::NoSelection;
return ret;
@@ -107,6 +112,23 @@ public:
ret->content << TileSimple::Row(" CPU count: " + PIString::fromNumber(PISystemInfo::instance()->processorsCount), CellFormat());
return ret;
}
PIScreenTile * peerDiagTile() {
PIScreenTile * ret = new PIScreenTile();
TileSimple * htl = new TileSimple();
htl->size_policy = PIScreenTypes::Fixed;
ret->direction = PIScreenTypes::Vertical;
htl->content << TileSimple::Row("Peer: " + daemon_.name() + " | " + daemon_.selfInfo().name, CellFormat(PIScreenTypes::Default, PIScreenTypes::Default, PIScreenTypes::Bold));
PIScreenTile * diag = new PIScreenTile();
diag->direction = PIScreenTypes::Horizontal;
peerdiagdata_tl = new TileSimple();
peerdiagservice_tl = new TileSimple();
ret->addTile(htl);
ret->addTile(diag);
diag->addTile(peerdiagdata_tl);
diag->addTile(peerdiagservice_tl);
// updatePeerInfo();
return ret;
}
PIScreenTile * peerTile() {
PIScreenTile* ret = new PIScreenTile();
TileSimple * htl = new TileSimple();
@@ -123,9 +145,21 @@ public:
ret->addTile(peerinfo_tl);
ret->addTile(addrs_tl);
ret->addTile(peermap_tl);
updatePeerInfo();
// updatePeerInfo();
return ret;
}
void updatePeerDiag(TileSimple * tl, const PIDiagnostics & diag) {
tl->content.clear();
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("Invalid count: " + PIString::fromNumber(diag.wrongCount()), CellFormat());
tl->content << TileSimple::Row("Sended count: " + PIString::fromNumber(diag.sendCount()), CellFormat());
tl->content << TileSimple::Row("Immediate Frequency, Hz: " + PIString::fromNumber(diag.immediateFrequency()), CellFormat());
tl->content << TileSimple::Row("Integral Frequency, Hz: " + PIString::fromNumber(diag.integralFrequency()), CellFormat());
tl->content << TileSimple::Row("Receive speed: " + diag.receiveSpeed(), CellFormat());
tl->content << TileSimple::Row("Send speed: " + diag.sendSpeed(), CellFormat());
tl->content << TileSimple::Row("Quality: " + PIString::fromNumber((int)diag.quality()), CellFormat());
}
void updatePeerInfo() {
bool pm = daemon_.lockedPeers();
screen.lock();
@@ -136,6 +170,9 @@ public:
peermap_tl->content.clear();
peers_tl->content << TileList::Row("this | 0 | 0 | " + PIString::fromNumber(daemon_.allPeers().size_s()) +
" [em = " + PIString::fromBool(daemon_.lockedEth()) + ", "
"mm = " + PIString::fromBool(daemon_.lockedMBcasts()) + ", "
"sm = " + PIString::fromBool(daemon_.lockedSends()) + ", "
"ms = " + PIString::fromBool(daemon_.lockedMCSends()) + ", "
"pm = " + PIString::fromBool(pm) + "]", CellFormat());
piForeachC(PIPeer::PeerInfo &p , daemon_.allPeers())
peers_tl->content << TileList::Row(p.name + " | d = " + PIString::fromNumber(p.dist) +
@@ -160,6 +197,8 @@ public:
}
piForeachC(PIString &s , peermap)
peermap_tl->content << TileList::Row(s, CellFormat());
updatePeerDiag(peerdiagdata_tl, daemon_.diagnosticData());
updatePeerDiag(peerdiagservice_tl, daemon_.diagnosticService());
daemon_.unlock();
screen.unlock();
}
@@ -176,14 +215,15 @@ public:
if (t == tmenu) {
if (e.type == TileList::RowPressed) {
piForeach (PIScreenTile * t, mtiles)
t->hide();
t->hide();
switch (e.data.toInt()) {
case 0: tinfo->show(); break;
case 1: tfm->show(); break;
case 2: daemon_.showMainList(); tdaemon->show(); break;
case 3: tpeer->show(); peers_tl->setFocus(); break;
case 4: daemon_.reinit(); tmenu->show(); break;
case 5: PIKbdListener::exiting = true; break;
case 0: tinfo->show(); break;
case 1: tfm->show(); break;
case 2: daemon_.showMainList(); tdaemon->show(); break;
case 3: tpeer->show(); peers_tl->setFocus(); break;
case 4: daemon_.reinit(); tmenu->show(); break;
case 5: tpeerdiag->show(); break;
case 6: PIKbdListener::exiting = true; break;
}
}
return;
@@ -198,13 +238,14 @@ public:
}
EVENT_HANDLER1(void, keyEvent, PIKbdListener::KeyEvent, e) {
if (screen.dialogTile()) return;
if (tpeer->visible || tinfo->visible)
if (tpeer->visible || tinfo->visible || tpeerdiag->visible)
if (e.key == PIKbdListener::Esc) menuRequest();
//piCout << "key" << e.key;
}
PIScreenTile * tmenu, * tinfo, * tfm, * tdaemon, * tpeer;
PIScreenTile * tmenu, * tinfo, * tfm, * tdaemon, * tpeer, * tpeerdiag;
TileList * peers_tl, * addrs_tl, * peermap_tl;
TileSimple * peerinfo_tl;
TileSimple * peerdiagdata_tl, * peerdiagservice_tl;
PIVector<PIScreenTile * > mtiles;
int cur_peer;
};