示例#1
0
	void printParam()
	{
		std::cout << "class CShip" << std::endl;
		printSpeed();
		printCoord();
		printGeneralParam();
		std::cout << "; port_registry = " << m_port_registry << "; num_pass = "******"\n \n" <<std::endl;
	}
示例#2
0
void Finger::printDetails(void)
{
    MYSERIAL.print("Finger ");
    MYSERIAL.print(fingerIndex);
    MYSERIAL.print("  ");
    printSpeed();
    printPos();
    printDir();
    printReached(true);		// print new line after

}
示例#3
0
文件: fast.c 项目: zuloo/fast
int main(void)
{
    setlocale(LC_ALL, "en_US.UTF-8");
    int x,y,height,width;
    char *data = inputString(stdin, 1024);

    freopen("/dev/tty", "rw", stdin);

    // enabling ncurses mode
    WINDOW *win = initscr();
    keypad(win, TRUE);
    noecho();
    cbreak();
    curs_set(0);

    // create colorpair for pivot character
    start_color();
    use_default_colors();
    init_pair(1,COLOR_RED,-1);

    // get terminal size
    getmaxyx(win,height,width);
    y=height/2;
    x=width/2;

    // print info
    mvaddstr(1,1,INFO);
    mvaddstr(height-2,1,USAGE);

    // print pivot markers
    attron(COLOR_PAIR(1));
    mvaddstr(y-1,x,MARKTOP);
    mvaddstr(y+1,x,MARKBOT);
    attroff(COLOR_PAIR(1));

    refresh();

    int speed = 350;
    printSpeed(speed);

    fastread(data,x,y,speed);

    free(data);
    endwin();
    return 0;
}
示例#4
0
  uint32_t lookupPacketSamplingRate(SFLAdaptor *adaptor, HSPSFlowSettings *settings)
  {
    // This falls back on the default "sampling=<n>" setting if the speed is unknown or zero
    uint32_t sampling_n = settings->samplingRate;
    char *method = "global_default";
    if(adaptor) {
      HSPAdaptorNIO *adaptorNIO = (HSPAdaptorNIO *)adaptor->userData;
      
      if(adaptorNIO->up == NO) {
	sampling_n = 0;
	method = "interface_down";
      }
      else {
	char speedStr[51];
	if(adaptor->ifSpeed) {
	  if(printSpeed(adaptor->ifSpeed, speedStr, 50)
	     && lookupApplicationSettings(settings, NULL, speedStr, &sampling_n, NULL)) {
	    method = speedStr;
	  }
	  else {
	    // calcuate default sampling rate based on link speed.  This ensures
	    // that a network switch comes up with manageable defaults even if
	    // the config file is empty...
	    sampling_n = adaptor->ifSpeed / HSP_SPEED_SAMPLING_RATIO;
	    if(sampling_n < HSP_SPEED_SAMPLING_MIN) {
	      sampling_n = HSP_SPEED_SAMPLING_MIN;
	    }
	    method = "speed_default";
	  }
	}
      }

      if(debug) {
	myLog(LOG_INFO, "%s (speed=%"PRIu64") using %s sampling rate = %u",
	      adaptor->deviceName,
	      adaptor->ifSpeed,
	      method,
	      sampling_n);
      }
    }
    return sampling_n;
  }
示例#5
0
/**
 * Main loop.
 */
int main(void) {
    int32_t lastSpeedCalc = 0;
    int32_t lastDebug = 0;
    int32_t lastDebug2 = 0;
    
    // initalize all modules
    initAll();
    
    // enable interrupts (i.e timers start from here)
    sei();
    
    // The LOOP
    while(1) {
        // read serial port
        readCommand();          // communication.c
        
        // apply speed calculation and run odometer
        if (uptime() >= lastSpeedCalc + SPEED_CALC_PERIOD) {
            lastSpeedCalc += SPEED_CALC_PERIOD;
            calculateSpeeds();  // motors.c
            if (pidOn) {
                runPID();       // motors.c
            }
            //if (debug1) printSpeed(CPUCHAR);
            runOdometer();      // odometer.c
            navigator();
        }
        
        // read sensors and apply position correction
        positionCorrection();   // odometer.c
        
        // print debug loop 2
        if (uptime() >= (lastDebug2 + 20)) {
            lastDebug2 = uptime();
            if (debug6) printf("%d, %d\r\n", p_LsensVal, p_RsensVal);
        }
        
        // print debug
        if ((debugPeriod) && uptime() >= (lastDebug + debugPeriod)) {
            lastDebug += debugPeriod;
            //if (debug1) printf(">21%02x\r", speed0 >> 4);
            //if (debug1) printf(">21%04x\r>22%04x\r", readADC(0), readADC(1));
            //if (debug2) printf("%ld\t%ld\r\n", timer, timer20);
            //if (debug2) printf_P(PSTR("%d\t%d\r\n"), p_L, p_R);
            if (debug3) printf_P(PSTR("%d, %d / %d, %d / %d, %d / %u, %u\r\n"),
                p_Ltrans, p_Lrel, p_Rtrans, p_Rrel, p_Lerr, p_Rerr, posCorrLeftFailed, posCorrRightFailed);
            //if (debug4) printf_P(PSTR("%ld\t%ld\r\n"), ticks0, ticks1);
            //if (debug5) printSpeed(CPUCHAR);
            //if (debug5) printf_P(PSTR("%d\t%d\r\n"), speed0, speed1);
            //if (debug6) printf_P(PSTR("%d\t%d\r\n"), accel0, accel1);
            if (debug7) printf_P(PSTR("%u\t%u\r\n"), power0, power1);
            // debug for GUI
            printTicks(CPUCHAR);
            printSpeed(CPUCHAR);
            printAccel(CPUCHAR);
            printAbsDist(CPUCHAR);
            printRelDist(CPUCHAR);
            printSensors(CPUCHAR);
        }
    }
    
    while(1);
}
示例#6
0
文件: fast.c 项目: zuloo/fast
// fast read looper
void fastread(char *data, int x, int y, int speed)
{
    bool run = false;
    bool pause = false;
    bool last = false;
    int ch;
    char *curr = data;
    int length = 0;
    int pivot = 0;
    int maxlen = strlen(data)-1;
    while(true)
    {
        // reset line
        mvprintw(y,0," ");
        clrtoeol();
        
        char *next = curr;
        next = strpbrk(next,DELIM);

        // did we hit the end of the string?
        if(!next || (int)(next-data)>=maxlen){
            run = false;
            last = true;
        }

        // length of the chararray (not neccessarely charachter count in utf8)
        length = (int)(next-curr);

        // calulate character count
        int charlength = 0;
        for(int i=0; i<length; i+=byteInChar((unsigned char)*(curr+i)))
            ++charlength;

        // which letter to highlight
        pivot = pivotLetter(charlength);
        int pos = pivot;
        // print characters before pivot letter, if any
        if(pivot > 0)
        {
            char pre[pivot*4+1];
            int offset=0;
            for(int i=0; i<pivot; i++)
            {
                pre[i+offset]=*(curr+i+offset);
                // if wide character copy the rest and alter offset
                int charsize = byteInChar((unsigned char)pre[i+offset]);
                for(int j=1; j<charsize; j++)
                {
                    ++offset;
                    pre[i+offset]=*(curr+i+offset);
                }
            }
            // apply offset
            pivot+=offset;

            pre[pivot] = '\0';
            mvprintw(y,x-pos,"%s",pre);
        }

        // print pivot letter
        char mid[5];
        int offset=0;
        mid[0]=*(curr+pivot);
        // if wide character copy the rest and alter offset
        int charsize = byteInChar((unsigned char)mid[0]);
        for(int i=1; i<charsize; i++)
        {
            ++offset;
            mid[i]=*(curr+pivot+offset);
        }
        // apply offset
        pivot+=offset;

        mid[1+offset] = '\0';
        attron(COLOR_PAIR(1));
        mvprintw(y,x,"%s",mid);
        attroff(COLOR_PAIR(1));

        // print characters after pivot letter, if any
        if(length>pivot+1)
        {
            char end[length-pivot];
            strncpy(end, curr+pivot+1, length-pivot-1);
            end[length-pivot-1] = '\0';
            mvprintw(y,x+1,"%s",end);
        }
        if(*next == '-')
            mvprintw(y,x+length-pivot,"-");
    
        refresh();

        if(pause)
        {
            // pause was set -> stop run, reset pause flag
            pause = false;
            run = false;
        }

        do
        {
            // nonblocking keyboard input if running, blocking otherwise
            if(run && !last)
                timeout(0);
            ch = getch();

            switch(ch)
            {
                case ' ':
                    // toggle pause
                    if(run)
                        run = false;
                    else if(!last)
                        run = true;
                    break;
                case 'q':
                    // quit
                    return;
                    break;
                case 'k':
                    // less speed
                    speed+=50;
                    printSpeed(speed);
                    break;
                case 'j':
                    // more speed
                    speed-=50;
                    if(speed < 50)
                        speed = 50;
                    printSpeed(speed);
                    break;
                case 'h':
                    // previous word, pause
                    run = true;
                    pause = true;
                    last = false;
                    next = backwards(data, next-2, DELIM);
                    do
                        next = backwards(data, --next, DELIM);
                    while(strchr(DELIM,*(--next)) && (int)(next-data)>0);
                    break;
                case 'l':
                    // next word, pause
                    run = true;
                    pause = true;
                    break;
                case 'g':
                    // back to start
                    next = data;
                    --next;
                    last = false;
                    pause = true;
                    run = true;
                    break;
                default:
                    break;
            }
            int delay = 0;
            if(charlength>8)
                delay = 200;
            else if(charlength>12)
                delay = 400;
            else if(charlength>16)
                delay = 600;

            if(run)
                usleep(1000*1000*60/speed+delay);
        }
        while(last || !run);

        // skip multiple whitespaces until a word begins
        while(next && (int)(next-data)<maxlen && strchr(DELIM,*(++next)))
            next = strpbrk(next,DELIM);
        // if we hit the end go back until last word begins
        if((int)(next-data)>=maxlen)
        {
            --next;
            do
                next = backwards(data, next, DELIM);
            while(strchr(DELIM,*(--next)) && (int)(next-data)>0);
            next = backwards(data, next, DELIM);
            ++next;
        }
        curr = next;
    }
}
示例#7
0
void Finger::printSpeed(void)
{
    printSpeed(0);
}