void Interface::draw() { ofFill(); ofBackground(0, 0, 0); ofSetColor(255); float w = ofGetWidth(); float h = ofGetHeight(); // draw settings area // draw path selector area drawPathInspector(0, 0, w*0.5, h*0.5); // draw map 50% 0, 100%, 60% drawMap(w*0.5+pad, 0+pad, (w*0.5)-(2*pad), (h*0.5)-(2*pad)); // draw detail inspection view / path editor drawPointInspector(0, h*0.5, w*0.5, h*0.45); // draw output view //ofSetColor(60); //ofRect(w*0.5, h*0.5, w*0.5, h*0.45); drawOutput(w*0.5, h*0.5, w*0.5, h*0.45); // draw simulator control / timeline //ofSetColor(40); //ofRect(0, h*0.95, w, h*0.05); drawTimeline(0, h*0.95, w, h*0.05); /*for (int i=0; i<data->paths.size(); i++) { drawPath(&data->paths[i]); } if (selectedPoint) { drawInterpolation(&selectedPoint->bikes, 20., 800., 700., 400.); }*/ ofSetColor(20, 20, 255); if(selectedPath){ ofDrawBitmapString("Selected path: " + ofToString(selectedPath->i), 20, 20); ofDrawBitmapString(" Sum max: " + ofToString(selectedPath->sum_max), 20, 40); } if(selectedPoint){ ofDrawBitmapString("Selected point: " + ofToString(selectedPoint->i), 20, 80); } if(selectedChannel){ ofDrawBitmapString("Selected channel: " + ofToString(selectedChannel->i), 20, 140); } ofSetColor(255,20,20); ofDrawBitmapString("FPS: " + ofToString(ofGetFrameRate()), 20, 180); }
void drawGUI(void) { //make main border with title box(stdscr,0,0); move(0,1); wprintw(stdscr,"ASIM Tester %s",SDM_VERSION); w_menu = subwin(stdscr,MENU_HEIGHT,MENU_WIDTH,1,1); w_out = subwin(stdscr,LINES-2,COLS-2-MENU_WIDTH,1,MENU_WIDTH+1); w_in = subwin(stdscr,LINES-2-MENU_HEIGHT,MENU_WIDTH,MENU_HEIGHT+1,1); drawInput(); drawOutput(); drawMenu(); wrefresh(stdscr); }
void displayRaw(void) { char buf[BUFSIZE]; short length; int i; int error_code; char error_str[80]; length = sensor.RawRead((unsigned char*)buf); if (cur_line >= LINES-4) { cur_line = 1; drawOutput(); } error_code = errno; wmove(w_out,cur_line,1); if(length < 0) { wprintw(w_out,"ASIM read error: %s",strerror_r(error_code,error_str,80)); } else { wprintw(w_out,"%d bytes",length); if(isprint(buf[0])) { wprintw(w_out," (%c)",buf[0]); } wprintw(w_out,"%s",":\t"); for(i=0;i<length;i++) wprintw(w_out,"%.2hhx ",buf[i]); } cur_line++; wrefresh(w_out); }
void displayRead(void) { char buf[BUFSIZE]; unsigned short length; int i; char msg_type; int error_code; char error_str[80]; msg_type = sensor.Read(length,(unsigned char*)buf, sizeof(buf)); if (cur_line >= LINES-4) { cur_line = 1; drawOutput(); } error_code = errno; switch(msg_type) { case ASIM_STATUS: wmove(w_out,cur_line,1); if (buf[0]&0x80) //first bit is set for an error { wprintw(w_out,"ASIM status ERROR: %hhd",buf[0]); if(buf[0]&0x40) //illegal command bit { cur_line++; wmove(w_out,cur_line,1); wprintw(w_out,"Illegal or unrecognized command"); } if(buf[0]&0x20) //self test failure bit { cur_line++; wmove(w_out,cur_line,1); wprintw(w_out,"Self Test failed"); } } else { wprintw(w_out,"ASIM status OK: %hhd",buf[0]); } if(buf[0]&0x10) //mode bit { cur_line++; wmove(w_out,cur_line,1); wprintw(w_out,"ASIM mode: operational"); } else { cur_line++; wmove(w_out,cur_line,1); wprintw(w_out,"ASIM mode: idle"); } cur_line++; break; case ASIM_XTEDS: //clear output screen for the xTEDS cur_line = 1; drawOutput(); //display xTEDS wmove(w_out,cur_line,1); wprintw(w_out,"ASIM xTEDS (%d):",length); cur_line++; wmove(w_out,cur_line,1); cur_line++; for(i=0;i<length;++i) { if(isprint(buf[i])) { wprintw(w_out,"%c",buf[i]); } else { if(iscntrl(buf[i])) { if(buf[i] == '\n') { wmove(w_out,cur_line,1); cur_line++; } if(buf[i] == '\t') { wprintw(w_out," "); } } else { wmove(w_out,1,13); wprintw(w_out,"ERROR: contains non-prinatble character 0x%hhx",buf[i]); wmove(w_out,cur_line,1); cur_line++; } } } cur_line++; break; case ASIM_DATA: wmove(w_out,cur_line,1); wprintw(w_out,"ASIM data message (%d bytes): (%hhd,%hhd)",length,buf[0],buf[1]); cur_line++; wmove(w_out,cur_line,1); for(i=0;i<length-1;++i) { wprintw(w_out,"%hhx ",buf[1+i]); } cur_line++; break; case ASIM_VERSION: wmove(w_out,cur_line,1); wprintw(w_out,"ASIM version %hhd",buf[0]); cur_line++; break; case ASIM_ERROR: wmove(w_out,cur_line,1); wprintw(w_out,"ASIM read error: %s",strerror_r(error_code,error_str,80)); cur_line++; break; case ASIM_TIMEOUT: wmove(w_out,cur_line,1); wprintw(w_out,"ASIM read error: %s",strerror_r(error_code,error_str,80)); cur_line++; break; default: wmove(w_out,cur_line,1); wprintw(w_out,"Unexpected ASIM message"); cur_line++; wmove(w_out,cur_line,1); wprintw(w_out,"%hhx %hd ",msg_type,length); for(i=0;i<length;++i) { wprintw(w_out,"%hhx ",buf[i]); } cur_line++; break; } wrefresh(w_out); }