Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
gui Namespace Reference

Classes

class  domid_comparator
 
class  hit_rate_comparator
 
class  last_view_comparator
 
class  match_comparator
 
class  name_comparator
 
class  run_number_comparator
 

Functions

bool is_problematic (mon_channel const &channel)
 
bool matches (mon_channel const &ch, std::string const &pattern)
 
bool matches (mon_channel const &ch, boost::regex const &regex)
 
void print_table_head (WINDOW *win, int offset)
 
void print_chan (WINDOW *win, ChList::const_iterator const &it, std::vector< char > &buffer, int line_size, int offset, bool highlight)
 
void print_timestamp (WINDOW *win, UTCTime const &tstamp, std::vector< char > &buffer, int line_size, int offset, bool validity)
 

Function Documentation

◆ is_problematic()

bool gui::is_problematic ( mon_channel const & channel)

Definition at line 540 of file gui.cpp.

541{
542 return
543 ! channel.syncd()
544 || channel.mean() > default_hit_counter_threshold
545 || boost::chrono::duration_cast<boost::chrono::seconds>(channel.last_view())
546 > boost::chrono::seconds(2);
547}
static const int default_hit_counter_threshold
Definition gui.cpp:15

◆ matches() [1/2]

bool gui::matches ( mon_channel const & ch,
std::string const & pattern )

Definition at line 736 of file gui.cpp.

737{
738 return
739 pattern.size() != 0
740 && (
741 ch.name().find(pattern) != std::string::npos
742 || ch.mac_address().find(pattern) != std::string::npos
743 || boost::lexical_cast<std::string>(ch.domid()).find(pattern) != std::string::npos
744 );
745}

◆ matches() [2/2]

bool gui::matches ( mon_channel const & ch,
boost::regex const & regex )

Definition at line 762 of file gui.cpp.

763{
764 return
765 boost::regex_match(ch.name(), regex)
766 || boost::regex_match(ch.mac_address(), regex)
767 || boost::regex_match(boost::lexical_cast<std::string>(ch.domid()), regex);
768}

◆ print_table_head()

void gui::print_table_head ( WINDOW * win,
int offset )

Definition at line 959 of file gui.cpp.

960{
961 static const char head[] =
962 "DOMID MAC ADDRESS Name Run # Hit rate (min, max, avg) Last viewed S Delta time";
963
964 if (static_cast<int>(strlen(head)) > offset) {
965 int const max_in_string = strlen(head) - offset;
966 int const nchars = std::min(COLS - 4, max_in_string);
967 wprintw(win, "%.*s", nchars, head + offset);
968 }
969}

◆ print_chan()

void gui::print_chan ( WINDOW * win,
ChList::const_iterator const & it,
std::vector< char > & buffer,
int line_size,
int offset,
bool highlight )

Definition at line 971 of file gui.cpp.

978 {
979 assert(offset <= line_size);
980
981 int const last_view = boost::chrono::duration_cast<boost::chrono::seconds>(
982 it->last_view()
983 ).count();
984
985 int const size = snprintf(
986 &buffer.front(),
987 line_size,
988 "%-9d %-17s %-8s %-6u %7.2f, %7.2f, %7.2f kHz %4d sec ago %s %ld ms",
989 it->domid(),
990 it->mac_address().c_str(),
991 it->name().c_str(),
992 it->run_number(),
993 it->min() / 100.,
994 it->max() / 100.,
995 it->mean() / 100.,
996 last_view,
997 it->syncd() ? "*" : " ",
998 it->avg_delta_time());
999
1000 if (offset < std::min(line_size, size)) {
1001 if (highlight) {
1002 wattron(win, A_REVERSE);
1003 } else {
1004 wattroff(win, A_REVERSE);
1005 }
1006
1007 if (!it->syncd()) {
1008 wattron(win, NOSYNC);
1009 }
1010
1011 if (it->mean() > default_hit_counter_threshold) {
1012 wattron(win, HIRATE);
1013 }
1014
1015 if (last_view > 2) {
1016 wattron(win, NODATA);
1017 }
1018
1019 wprintw(win, "%s", &buffer[offset]);
1020
1021 if (size > line_size) {
1022 wprintw(win, "$");
1023 }
1024 }
1025
1026 wattrset(win, GROUND);
1027}

◆ print_timestamp()

void gui::print_timestamp ( WINDOW * win,
UTCTime const & tstamp,
std::vector< char > & buffer,
int line_size,
int offset,
bool validity )

Definition at line 1029 of file gui.cpp.

1036{
1037 assert(offset <= line_size);
1038
1039 std::ostringstream oss;
1040
1041 oss << UTCTime_h(tstamp, validity);
1042
1043 int const size = snprintf(
1044 &buffer.front(),
1045 line_size,
1046 "Sec: %d, Tic: %-8d - %s",
1047 tstamp.sec(),
1048 tstamp.tics(),
1049 oss.str().c_str());
1050
1051 if (offset < std::min(line_size, size)) {
1052 wprintw(win, "%s", &buffer[offset]);
1053
1054 if (size > line_size) {
1055 wprintw(win, "$");
1056 }
1057 }
1058}