int print_ei_scn(const struct opal_ei_scn *ei) { print_header("Environmental Information"); print_opal_v6_hdr(ei->v6hdr); print_center("Genesis Readings"); print_line("Timestamp", "0x%016lx", ei->g_timestamp); print_ei_env_scn(&(ei->genesis)); print_center(" "); if (ei->status == CORROSION_RATE_NORM) print_line("Corrosion Rate Status", "Normal"); else if (ei->status == CORROSION_RATE_ABOVE) print_line("Corrosion Rate Status", "Above Normal"); else print_line("Corrosion Rate Status", "Unknown"); print_line("User Data Section", "%s", ei->user_data_scn ? "Present" : "Absent"); print_line("Sensor Reading Count", "0x%04x", ei->read_count); int i; for(i = 0; i < ei->read_count; i++) print_ei_env_scn(ei->readings + i); return 0; }
int print_src_scn(const struct opal_src_scn *src, void *cookie) { if (src->v6hdr.id[0] == 'P') print_header("Primary System Reference Code"); else print_header("Secondary System Reference Code"); print_opal_v6_hdr(src->v6hdr); print_line("SRC Format", "0x%x", src->flags); print_line("SRC Version", "0x%x", src->version); print_line("Valid Word Count", "0x%x", src->wordcount); print_line("SRC Length", "%x", src->srclength); print_src_refcode(src); if(src->fru_count) { print_center(" "); print_center("Callout Section"); print_center(" "); /* Hardcode this to look like FSP, not what what they want here... */ print_line("Additional Sections", "Disabled"); print_line("Callout Count", "%d", src->fru_count); int i; for (i = 0; i < src->fru_count; i++) print_fru_scn(src->fru[i]); } print_center(" "); return 0; }
void print_title () { printf("\n\n"); print_center("*** ELIZA ***"); print_center("Original code by Weizenbaum, 1966"); print_center("To stop Eliza, type 'bye'"); printf("\n\n"); printf("HI! I'M ELIZA. WHAT'S YOUR PROBLEM?\n"); }
//----------------------------------------------------------------------------------------------------- void K3NGdisplay::print_center_screen(char * print_string,char * print_string2){ if (display_rows == 2){ print_center(print_string,0); print_center(print_string2,1); } else { print_center(print_string,(display_rows/2)-1); print_center(print_string2,(display_rows/2)); } }
//----------------------------------------------------------------------------------------------------- void K3NGdisplay::print_center_fixed_field_size(char * print_string,int y,int field_size){ char workstring[WORK_STRING_SIZE] = ""; char workstring2[WORK_STRING_SIZE] = ""; int spaces_to_add = field_size - strlen(print_string); if (spaces_to_add > 0){ for (int x = 0;(x < (spaces_to_add/2)) && (strlen(workstring) < (WORK_STRING_SIZE-1));x++){ strcat(workstring," "); } } strncpy(workstring2,print_string,field_size); strcat(workstring,workstring2); if (spaces_to_add > 0){ for (int x = 0;(x < (spaces_to_add/2)) && (strlen(workstring) < (WORK_STRING_SIZE-1));x++){ strcat(workstring," "); } if ((spaces_to_add % 2) != 0){ // odd number means we have another space to add on the end strcat(workstring," "); } } print_center(workstring,y); }
static WINDOW * ui_window_create (int width, int height, int x, int y, const char *title) { WINDOW *w = newwin (height, width, y, x); if (title) { box (w, 0, 0); print_center (w, width/2, 0, title); } wrefresh (w); return w; }
int main(int argc, char **argv) { init_ncurses(); print_center("Welcome to Static Movement Router", 5); sleep(1); endwin(); return 0; }
//----------------------------------------------------------------------------------------------------- void K3NGdisplay::print_center_screen(char * print_string,char * print_string2,char * print_string3,char * print_string4){ if (display_rows == 4){ print_center(print_string,0); print_center(print_string2,1); print_center(print_string3,2); print_center(print_string4,3); } else { print_center(print_string,(display_rows/2)-1); print_center(print_string2,(display_rows/2)); print_center(print_string3,(display_rows/2)+1); print_center(print_string4,(display_rows/2)+3); } }
//----------------------------------------------------------------------------------------------------- void K3NGdisplay::print_center_padded(char * print_string,int y,int padding){ char workstring[WORK_STRING_SIZE] = ""; for (int x = 0;(x < padding) && (strlen(workstring) < (WORK_STRING_SIZE-1));x++){ strcat(workstring," "); } strcat(workstring,print_string); for (int x = 0;(x < padding) && (strlen(workstring) < (WORK_STRING_SIZE-1));x++){ strcat(workstring," "); } print_center(workstring,y); }
void taylortrack::vis::OutputVisualizer::update_main_window() { // Create Box around main window box(this->main_window_, 0, 0); wmove(this->main_window_, 1, 1); if (this->data_set_) { double x_axis_size = diagram_data_.size(); int height, width; getmaxyx(this->main_window_, height, width); // Not the entire window usable width -= 2; height -= 4; // Calculate values per character int vpc = static_cast<int>(ceil(x_axis_size / static_cast<double>(width))); int actual_size = static_cast<int>(x_axis_size / vpc); // Calculate max value double max_value = 0.0f; for (int i = 0; i < actual_size; ++i) { double current_value = 0; for (int j = 0; j < vpc; ++j) { current_value += diagram_data_[i * vpc + j]; } if (current_value > max_value) { max_value = current_value; } } wprintw(this->main_window_, "Debug-Values: %d %d %d %d %f", vpc, actual_size, COLORS, can_change_color(), max_value); if (max_value > 0.0) { // calculate the value of one square in the terminal double delta = max_value / height; // Add the vpc next values together and draw block if value high enough for (int y = 0; y < height; ++y) { for (int x = 0; x < actual_size; ++x) { double current_value = 0; for (int j = 0; j < vpc; ++j) { current_value += diagram_data_[x * vpc + j]; } if (current_value >= (height - y) * delta) { wmove(this->main_window_, 1 + y, 1 + x); if (x % 2 == 0) { waddch(this->main_window_, ' ' | COLOR_PAIR(3)); } else { waddch(this->main_window_, ' ' | COLOR_PAIR(4)); } } } } } else { height = getmaxy(this->main_window_); height -= 2; wmove(this->main_window_, height / 2, 1); print_center(this->main_window_, "Invalid Data!"); } } else { int height; height = getmaxy(this->main_window_); height -= 2; wmove(this->main_window_, height / 2, 1); print_center(this->main_window_, "Waiting for Data..."); } // flush display buffer and write to screen wrefresh(this->main_window_); }
//----------------------------------------------------------------------------------------------------- void K3NGdisplay::print_center_screen(char * print_string,uint8_t text_attribute){ print_center(print_string,(display_rows-1)/2,text_attribute); }
//----------------------------------------------------------------------------------------------------- void K3NGdisplay::print_center_screen(char * print_string){ print_center(print_string,(display_rows-1)/2); }