• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ print_state函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中print_state函数的典型用法代码示例。如果您正苦于以下问题:C++ print_state函数的具体用法?C++ print_state怎么用?C++ print_state使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了print_state函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: repair

void repair(int argc, char *argv[]) {
    if (argc != 2) {
        printf("Please enter a filename.\n");
        return;
    }
    char capture_filename[128];
    char japanese_filename[128];
    char temp_filename[128];
    sprintf(capture_filename, "%s_capture.dat", argv[1]);
    sprintf(japanese_filename, "%s_japanese.dat", argv[1]);
    sprintf(temp_filename, "%s_temp.dat", argv[1]);


    solution sol_;
    solution *sol = &sol_;
    char *buffer = file_to_buffer(capture_filename);
    buffer = load_solution(sol, buffer, 1);
    print_state(sol->base_state);
    calculate_leaves(sol);

    solution solj_;
    solution *solj = &solj_;
    buffer = file_to_buffer(japanese_filename);
    buffer = load_solution(solj, buffer, 1);
    print_state(solj->base_state);
    solj->leaf_nodes = sol->leaf_nodes;

    FILE *f = fopen(temp_filename, "wb");
    save_solution(solj, f);
    fclose(f);
    printf("Done!\n");
}
开发者ID:frostburn,项目名称:tinytsumego,代码行数:32,代码来源:solver.c


示例2: cat_eat

void
cat_eat(unsigned int bowlnumber, int eat_time)
{

  /* check the argument */
  if ((bowlnumber == 0) || ((int)bowlnumber > num_bowls)) {
    panic("cat_eat: invalid bowl number %d\n",bowlnumber);
  }

  /* check and update the simulation state to indicate that
   * the cat is now eating at the specified bowl */
  P(mutex);   // start critical section

  /* first check whether allowing this cat to eat will
   * violate any simulation requirements */
  if (bowls[bowlnumber-1] == 'c') {
    /* there is already a cat eating at the specified bowl */
    panic("cat_eat: attempt to make two cats eat from bowl %d!\n",bowlnumber);
  }
  if (eating_mice_count > 0) {
    /* there is already a mouse eating at some bowl */
    panic("cat_eat: attempt to make a cat eat while mice are eating!\n");
  }
  KASSERT(bowls[bowlnumber-1]=='-');
  KASSERT(eating_mice_count == 0);

  /* now update the state to indicate that the cat is eating */
  eating_cats_count += 1;
  bowls[bowlnumber-1] = 'c';

  /* print a summary of the current state */
  kprintf("cat_eat   (bowl %3d) start:  ",bowlnumber);
  print_state();
  kprintf("\n");

  V(mutex);  // end critical section

  /* simulate eating by introducing a delay
   * note that eating is not part of the critical section */
  clocksleep(eat_time);

  /* update the simulation state to indicate that
   * the cat is finished eating */
  P(mutex);  // start critical section

  KASSERT(eating_cats_count > 0);
  KASSERT(bowls[bowlnumber-1]=='c');
  eating_cats_count -= 1;
  bowls[bowlnumber-1]='-';

  /* print a summary of the current state */
  kprintf("cat_eat   (bowl %3d) finish: ",bowlnumber);
  print_state();
  kprintf("\n");
  
  V(mutex);  // end critical section

  return;
}
开发者ID:y3046308,项目名称:os-group-project,代码行数:59,代码来源:bowls.c


示例3: mouse_eat

void
mouse_eat(unsigned int bowlnumber, int eat_time, unsigned int mouse_num)
{
  /* check the bowl number */
  KASSERT(bowlnumber > 0);
  KASSERT((int)bowlnumber <= NumBowls);

  /* check and updated the simulation state to indicate that
   * the mouse is now eating at the specified bowl. */
  P(mutex);  // start critical section

  /* first check whether allowing this mouse to eat will
   * violate any simulation requirements */
  if (bowls[bowlnumber-1].animal == 'm') {
    /* there is already a mouse eating at the specified bowl */
    panic("mouse_eat: attempt to make mouse %d eat from bowl %d while mouse %d is there!\n",
           mouse_num, bowlnumber, bowls[bowlnumber-1].which);
  }
  if (eating_cats_count > 0) {
    /* there is already a cat eating at some bowl */
    panic("mouse_eat: attempt to make mouse %d eat while cats are eating!\n", mouse_num);
  }
  KASSERT(bowls[bowlnumber-1].animal=='-');
  KASSERT(bowls[bowlnumber-1].which==INVALID_ANIMAL_NUM);
  KASSERT(eating_cats_count == 0);

  /* now update the state to indicate that the mouse is eating */
  eating_mice_count += 1;
  bowls[bowlnumber-1].animal = 'm';
  bowls[bowlnumber-1].which = mouse_num;
  print_state();

  DEBUG(DB_SYNCPROB,"mouse %d starts to eat at bowl %d [%d:%d]\n",
	mouse_num,bowlnumber,eating_cats_count,eating_mice_count);
  V(mutex);  // end critical section

  /* simulate eating by introducing a delay
   * note that eating is not part of the critical section */
  clocksleep(eat_time);

  /* update the simulation state to indicate that
   * the mouse is finished eating */
  P(mutex); // start critical section

  KASSERT(eating_mice_count > 0);
  eating_mice_count -= 1;
  KASSERT(bowls[bowlnumber-1].animal=='m');
  KASSERT(bowls[bowlnumber-1].which==mouse_num);
  bowls[bowlnumber-1].animal='-';
  bowls[bowlnumber-1].which=INVALID_ANIMAL_NUM;
  print_state();

  DEBUG(DB_SYNCPROB,"mouse %d finishes eating at bowl %d [%d:%d]\n",
	mouse_num,bowlnumber,eating_cats_count,eating_mice_count);
  V(mutex);  // end critical section
  return;
}
开发者ID:AdamChit,项目名称:cs350,代码行数:57,代码来源:catmouse.c


示例4: test_spiral_8

bool test_spiral_8()
{
    /* State:
     *
     * |LSB       MSB|
     * 1 1 1 1 1 1 1 1
     * 1 0 0 0 0 0 0 1
     * 1 1 1 1 1 1 0 1
     * 1 0 0 0 0 1 0 1
     * 1 0 1 1 0 1 0 1
     * 1 0 1 0 0 1 0 1
     * 1 0 1 1 1 1 0 1
     * 1 0 0 0 0 0 0 1
     * 1 1 1 1 1 1 1 1
     */
    
    /* Easier to put into hex
     *LSB                                       MSB
     * 1111 1111 1000 0001 1111 1101 1000 0101
     * 1011 0101 1010 0101 1011 1101 1000 0001
     * 1111 1111
     */

    uint32_t * state;

    const uint32_t expected_state[] = {
        0xa1bf81ff,
        0x81bda5ad,
        0xff
    };

    read_pbm("tests/pbm/spiral_8_start.pbm", &state, &state_width, &state_height, NULL);

    ints_per_state = ((state_width * state_height) / 32) + ((state_width * state_height)%32) > 0 ? 1 : 0;
    state_size = ints_per_state * 4;

    if (state_width != 8 && state_height != 9)
    {
        printf("width: %u, expected_width: %u\n", state_width, 8);
        printf("height: %u, expected_height: %u\n", state_height, 9);

        return false;
    }
    else if (!states_equal(state, expected_state))
    {
        puts("state read:");
        print_state(state);

        puts("state expected:");
        print_state(expected_state);

        return false;
    }

    return true;
}
开发者ID:samwhitlock,项目名称:ice,代码行数:56,代码来源:test_read_pbm.c


示例5: finished_one_jump_all_ode

char finished_one_jump_all_ode(struct_all_ode *s, double t1) {
    int i;
    char ok;
    ok = s->time_second < t1;
    if (ok) {
        //    printf("simulating from t0=%.5e to t1=%.5e\n", s->time_second, t1);
    }
    while (s->time_second < t1) {
        s->status = gsl_odeiv_evolve_apply(s->e, s->c, s->s,
                &s->sys,
                &s->time_second, t1,
                &s->h, s->x);
        if (s->h > s->hmax) s->h = s->hmax;
        if (s->status == GSL_FAILURE) {
            s->x[s->NX - 1] = 0;
            if (s->mode == MODE_FLY_TO_SOL) {
                if (s->print_values_fly_to_sol) {
                    printf("passing from fly to sol at time t=%.5e\n", s->time_second);
                    print_state(s->x, NULL);
                    print_energies(s, s->x);

                }
                compute_fly_to_sol_percussion(s);
                if (s->print_values_fly_to_sol) {
                    printf("passed from fly to sol at time t=%.5e\n", s->time_second);
                    print_state(s->x, NULL);
                    print_energies(s, s->x);

                }
                s->mode = MODE_SOL;
            }
            if (s->mode == MODE_SOL_TO_FLY) {
                if (s->print_values_sol_to_fly) {
                    printf("passing from sol to fly at time t=%.5e\n", s->time_second);
                    print_state(s->x, NULL);
                    print_energies(s, s->x);

                }
                s->x[INDX_VX] = -sin(s->x[INDX_TH]) * s->x[INDX_VR];
                s->x[INDX_VZ] = cos(s->x[INDX_TH]) * s->x[INDX_VR];
                s->x[INDX_VR] = 0;
                s->x[INDX_R] = s->r0;
                if (s->print_values_sol_to_fly) {
                    printf("passed from sol to fly at time t=%.5e\n", s->time_second);
                    print_state(s->x, NULL);
                    print_energies(s, s->x);

                }
                return 1;
            }
        }
    }
    return 0;

}
开发者ID:jraynal,项目名称:bearded-dubstep,代码行数:55,代码来源:all_ode.c


示例6: main

int main (void) {
        state_t vec1, vec2, vec3;
        binding_t b;
        int i;
       
        srand(time(NULL));
        fprintf(stdout, "--- Debut\n");
       
        /* Creation du vecteur */
        vec1 = create_state();
        vec2 = create_state();
        vec3 = create_state();
       
        /* Remplissage */
        for (i=0; i<15; i++) {
                b.id = i;
                b.place = (int) rand() % 40;
                add_binding(&vec1, b);
                add_binding(&vec3, b);
        }
       
        /* Remplissage */
        for (i=0; i<15; i++) {
                b.id = i;
                b.place = (int) rand() % 40;
                add_binding(&vec2, b);
        }
       
        print_state(vec1);
        print_state(vec2);

        /* Suppression */
        for (i=0; i<10; i++) {
                int r = (int) rand() % 15;
                fprintf(stdout,"Suppression du %d\n",r);
                erase_binding(&vec1, find_binding(vec1,r));
                erase_binding(&vec3, find_binding(vec3,r));
        }

        /* Suppression */
        for (i=0; i<10; i++) {
                int r = (int) rand() % 15;
                fprintf(stdout,"Suppression du %d\n",r);
                erase_binding(&vec2, find_binding(vec2,r));
        }

        print_state(vec1);
        print_state(vec2);
       
        /* Comparaison */
        if (compare_states(&vec1, &vec2)) { fprintf(stdout, "VEC1 = VEC2\n"); } else { fprintf(stdout, "VEC1 != VEC2\n"); }
        if (compare_states(&vec1, &vec3)) { fprintf(stdout, "VEC1 = VEC3\n"); } else { fprintf(stdout, "VEC1 != VEC3\n"); }

        return 1;
}
开发者ID:SavithaSwaroop,项目名称:Evinrude-CAMI-PNML,代码行数:55,代码来源:state_test.c


示例7: main

int main()
{
    state prev = to_state("00000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000");
    std::size_t steps = 25;

    print_state(prev);
    for (std::size_t i = 0; i < steps; ++i) {
        state curr = next_state(prev);
        print_state(curr);
        prev.swap(curr);
    }
    return 0;
}
开发者ID:chrisieh,项目名称:dailyprogrammer,代码行数:13,代码来源:main.cpp


示例8: Sample_Task

/** %jp{サンプルタスク} */
void Sample_Task(VP_INT exinf)
{
	int num;
	
	num = (int)exinf;
	
	/* %jp{いわゆる哲学者の食事の問題} */
	for ( ; ; )
	{
		/* %jp{適当な時間考える} */
		print_state(num, "thinking");
		rand_wait();
		
		/* %jp{左右のフォークを取るまでループ} */
		for ( ; ; )
		{
			/* %jp{左から順に取る} */
			wai_sem(LEFT(num));
			if ( pol_sem(RIGHT(num)) == E_OK )
			{
				break;	/* %jp{両方取れた} */
			}
			sig_sem(LEFT(num));	/* %jp{取れなければ離す} */
			
			/* %jp{適当な時間待つ} */
			print_state(num, "hungry");
			rand_wait();

			/* %jp{右から順に取る} */
			wai_sem(RIGHT(num));
			if ( pol_sem(LEFT(num)) == E_OK )
			{
				break;	/* %jp{両方取れた} */
			}
			sig_sem(RIGHT(num));	/* %jp{取れなければ離す} */

			/* %jp{適当な時間待つ} */
			print_state(num, "hungry");
			rand_wait();
		}
		
		/* %jp{適当な時間、食べる} */
		print_state(num, "eating");
		rand_wait();
		
		/* %jp{フォークを置く} */
		sig_sem(LEFT(num));
		sig_sem(RIGHT(num));
	}
}
开发者ID:ryuz,项目名称:hos-v4a,代码行数:51,代码来源:sample.c


示例9: main

int main(int argc, char** argv)
{
    srand(time(NULL));

    initialize_state();

    initialize_timer();

    print_state(stdout, 1.0f);
    printf("Score: %d\n", game_state.score);

    char input;

    double dTime = 0;
    while (1)
    {
        dTime += get_elapsed_time();
        if (dTime > 1)
        {
            printf("Tick.\n");
            dTime -= 1;
        }
    }

    while (input = getchar())
    {
        switch (input)
        {
        case 'D':
            if (move_down()) return 0;
            break;
        case 'G':
            if (gravity_tick()) return 0;
            break;
        case 'L':
            move_left();
            break;
        case 'R':
            move_right();
            break;
        case 'U':
            rotate();
            break;
        }
        print_state(stdout, 1.0f);
        printf("Score: %d\n", game_state.score);
    }

    return 0;
}
开发者ID:m-ender,项目名称:ppcg-tetris-tournament,代码行数:50,代码来源:controller.c


示例10: computer_vs_computer

/**
 * Computer vs computer
 *
 * The computer plays itself
 * @param string for filename
 * @param agent_color
 * @return 1 if black wins, else return 0
 */
int computer_vs_computer( char *file, char agent_color )
{
    char board[ SIZE ][ SIZE ];

    /* set up board */
    setup_board(file,board);

    /* create a new state */
    struct State * state = new_state( board, 'B' );
    struct State * temp_state;

    /* start game */
    print_state( state );
    temp_state = computer_player_first( state );
    Free( state, sizeof( struct State ) );
    state = temp_state;

    /* second move */
    printf( "\n" );
    print_state( state );
    temp_state = computer_player_second( state );
    Free( state, sizeof( struct State ) );
    state = temp_state;

    /* regular game */
    for( ;; )
    {
        printf( "\n" );
        print_state( state );

        //printf( "\n>> Mem usage before: %lu\n", memory_usage() );
        temp_state = computer_player( state );
        Free( state, sizeof( struct State ) );
        state = temp_state;
        //printf( "\n>> Mem usage after: %lu\n", memory_usage() );

        if( terminal_test( state ) == 1 )
        {
            printf( "\n" );
            print_state( state );
            printf( "\nNo moves left!... \n" );
            printf( "\n%c wins!!!\n", opposite_player( state->player ) );
            Free( state, sizeof( struct State ) );
            break;
        }
    }

    return opposite_player( state->player ) == 'B';
}
开发者ID:jibbs00,项目名称:cmpt355project2-eric-julian-michael,代码行数:57,代码来源:game.c


示例11: main

int main( int argc, char **argv )
{
// VARIABLES FOR INPUT
    char str[ MAX_LINE_LENGTH +1 ] ;
    ssize_t nchars; 
    state_t state; // state_t is defined by the PSVN API. It is the type used for individual states.

// VARIABLES FOR ITERATING THROUGH state's SUCCESSORS
    state_t child;
    ruleid_iterator_t iter; // ruleid_terator_t is the type defined by the PSVN API successor/predecessor iterators.
    int ruleid ; // an iterator returns a number identifying a rule
    int childCount;

// READ A LINE OF INPUT FROM stdin
    printf("Please enter a state followed by ENTER: ");
    if ( fgets(str, sizeof str, stdin) == NULL ) {
	printf("Error: empty input line.\n");
	return 0; 
    }

// CONVERT THE STRING TO A STATE
    nchars = read_state( str, &state );
    if (nchars <= 0) {
	printf("Error: invalid state entered.\n");
	return 0; 
    }

    printf("The state you entered is: ");
    print_state( stdout, &state );
    printf("\n");

// LOOP THOUGH THE CHILDREN ONE BY ONE
    childCount = 0;
    init_fwd_iter( &iter, &state );  // initialize the child iterator 
      while( ( ruleid = next_ruleid( &iter ) ) >= 0 ) {
//    while( -1 >= 0 ) {
	apply_fwd_rule( ruleid, &state, &child );
	++childCount;
    	printf("child %d. ",childCount);
	print_state( stdout, &child );
    	//printf("  %s (cost %d)\n",get_fwd_rule_label(ruleid),get_fwd_rule_cost(ruleid));
    	printf("  %s (cost %d), goal=%d\n",get_fwd_rule_label(ruleid),get_fwd_rule_cost(ruleid),is_goal(&child));
    } // end while... no more children
    if (childCount == 0) {
	printf("Your state has no children.\n");
    }

    return 0;
} // end main
开发者ID:acsalcedo,项目名称:heuristic-search,代码行数:49,代码来源:succ.c


示例12: test_61c

bool test_61c()
{
    /* State:
     *
     * |LSB                         MSB|
     * 1 1 1 0 1 1 1 0 1 0 0 0 1 0 1 1 1
     * 1 0 0 0 1 0 0 0 1 0 0 0 1 0 1 0 0
     * 1 0 0 0 1 1 1 0 1 1 1 0 1 0 1 0 0
     * 1 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 0
     * 1 1 1 0 1 1 1 0 1 1 1 0 1 0 1 1 1
     */
/* This is to make it easier to put into hex
1110 1110 1000 1011 1100 0100 0100 0101
0010 0011 1011 1010 1001 0000 0101 0101
0100 1110 1110 1110 1011 1
 */
    uint32_t * state;

    const uint32_t expected_state[] = {
        0xa223d177,
        0xaa095dc4,
        0x1d7772
    };

    read_pbm("tests/pbm/61c_end.pbm", &state, &state_width, &state_height, NULL);

    ints_per_state = ((state_width * state_height) / 32) + ((state_width * state_height)%32) > 0 ? 1 : 0;
    state_size = ints_per_state * 4;

    if (state_width != 17 && state_height != 5)
    {
        printf("width: %u, expected_width: %u\n", state_width, 17);
        printf("height: %u, expected_height: %u\n", state_height, 5);

        return false;
    }
    else if (!states_equal(state, expected_state))
    {
        puts("state read:");
        print_state(state);

        puts("state expected:");
        print_state(expected_state);

        return false;
    }

    return true;
}
开发者ID:samwhitlock,项目名称:ice,代码行数:49,代码来源:test_read_pbm.c


示例13: print_state

lexeme *st_one_two_sym_lex(lexer_info *linfo, buffer *buf)
{
    lexeme *lex = NULL;

#ifdef LEXER_DEBUG
    print_state("ST_ONE_TWO_SYM_LEX", linfo->c);
#endif

    if (buf->count_sym == 0) {
        add_to_buffer(buf, linfo->c);
        deferred_get_char(linfo);
    } else if (buf->count_sym == 1) {
        /* TODO: make it more pretty */
        char prev_c = get_last_from_buffer(buf);
        clear_buffer(buf);
        switch (prev_c) {
        case '>':
            lex = (prev_c == linfo->c) ?
                make_lex(LEX_APPEND) :
                make_lex(LEX_OUTPUT);
            break;
        case '|':
            lex = (prev_c == linfo->c) ?
                make_lex(LEX_OR) :
                make_lex(LEX_PIPE);
            break;
        case '&':
            lex = (prev_c == linfo->c) ?
                make_lex(LEX_AND) :
                make_lex(LEX_BACKGROUND);
            break;
        default:
            fprintf(stderr, "Lexer: error (type 1) in ST_ONE_TWO_SYM_LEX;");
            print_state("ST_ONE_TWO_SYM_LEX", linfo->c);
            exit(ES_LEXER_INCURABLE_ERROR);
        }
        if (prev_c == linfo->c)
            deferred_get_char(linfo);
        linfo->state = ST_START;
        return lex;
    } else {
        fprintf(stderr, "Lexer: error (type 2) in ST_ONE_TWO_SYM_LEX;");
        print_state("ST_ONE_TWO_SYM_LEX", linfo->c);
        exit(ES_LEXER_INCURABLE_ERROR);
    }

    return lex;
}
开发者ID:Totktonada,项目名称:shell,代码行数:48,代码来源:lexer.c


示例14: print_results

void
print_results (void)
{
  state_number i;

  /* We used to use just .out if SPEC_NAME_PREFIX (-p) was used, but
     that conflicts with Posix.  */
  FILE *out = xfopen (spec_verbose_file, "w");

  reduce_output (out);
  grammar_rules_partial_print (out,
			       _("Rules never reduced"), rule_never_reduced_p);
  conflicts_output (out);

  print_grammar (out);

  /* If the whole state item sets, not only the kernels, are wanted,
     `closure' will be run, which needs memory allocation/deallocation.   */
  if (report_flag & report_itemsets)
    new_closure (nritems);
  /* Storage for print_reductions.  */
  shift_set =  bitset_create (ntokens, BITSET_FIXED);
  look_ahead_set = bitset_create (ntokens, BITSET_FIXED);
  for (i = 0; i < nstates; i++)
    print_state (out, states[i]);
  bitset_free (shift_set);
  bitset_free (look_ahead_set);
  if (report_flag & report_itemsets)
    free_closure ();

  xfclose (out);
}
开发者ID:crow89,项目名称:Alcatel_OT_985_kernel,代码行数:32,代码来源:print.c


示例15: change_state

static void change_state(int *state, int new_state, int depth){
  *state = new_state;
  if(DEBUG == TRUE){
    print_state(*state, depth);
    fflush(stdout);
  }
}
开发者ID:elambert,项目名称:honeycomb,代码行数:7,代码来源:xml.c


示例16: mrs_decrypt_lastblock

static MRS_INLINE void mrs_decrypt_lastblock(mrs_state_t state, unsigned char * out, const unsigned char * in, size_t inlen)
{
    size_t i;
    mrs_word_t * S = state->S;
    uint8_t lastblock[BYTES(MRS_R)];
    mrs_permute(state);
    for(i = 0; i < WORDS(MRS_R); ++i)
    {
        STORE(lastblock + i * BYTES(MRS_W), S[i]);
    }

    /* undo padding */
    memcpy(lastblock, in, inlen);
    /*lastblock[inlen] ^= 0x01;
    lastblock[BYTES(MRS_R) - 1] ^= 0x80;*/

    for (i = 0; i < WORDS(MRS_R); ++i)
    {
        const mrs_word_t c = LOAD(lastblock + i * BYTES(MRS_W));
        STORE(lastblock + i * BYTES(MRS_W), S[i] ^ c);
        S[i] = c;
    }
    memcpy(out, lastblock, inlen);

#if defined(MRS_DEBUG)
    printf("DECRYPTING LASTBLOCK:\n");
    print_bytes(lastblock, BYTES(MRS_R));
    printf("STATE:\n");
    print_state(state->S);
#endif

    burn(lastblock, 0, sizeof lastblock);
}
开发者ID:0x64616E69656C,项目名称:mem-aead,代码行数:33,代码来源:mrs.c


示例17: mrs_finalise

void mrs_finalise(mrs_state_t state, size_t hlen, size_t mlen, unsigned char * tag)
{
    mrs_word_t * S = state->S;
    uint8_t lastblock[BYTES(MRS_R)];
    size_t i;

    /* finalise state */
    mrs_permute(state);

    S[0] ^= hlen;
    S[1] ^= mlen;

    mrs_permute(state);

    /* extract tag */
    for (i = 0; i < WORDS(MRS_R); ++i)
    {
        STORE(lastblock + i * BYTES(MRS_W), S[i]);
    }
    memcpy(tag, lastblock, BYTES(MRS_T));

#if defined(MRS_DEBUG)
    printf("FINALISED:\n");
    print_state(state->S);
#endif

    burn(lastblock, 0, BYTES(MRS_R));
}
开发者ID:0x64616E69656C,项目名称:mem-aead,代码行数:28,代码来源:mrs.c


示例18: main

int main (int argc, char **argv)
{
    FILE * gcodeFile;
    char lineBuffer[1024];
    char * lineBufferPointer = &lineBuffer[0];
    GCODE_STATE previous_command; //stores the previous gcode command
    GCODE_STATE current_command; //stores the next gcode command
    init_gcode_state(&previous_command);
    init_gcode_state(&current_command);

    gcodeFile = fopen("test.gcode","r");
    if(gcodeFile == NULL){
        printf("Error: file dosen't exist");
        return -1;
    }

    printf ("GCode interpreter test\n");
    while(fgets(lineBuffer, 1024, gcodeFile) != NULL){
        //reset the line buffer pointer to the start of the line
        lineBufferPointer = &lineBuffer[0]; 
        previous_command = current_command;
        current_command = parse_gcode(lineBufferPointer);
        print_state(current_command);

    }

    fclose(gcodeFile);
    return 0;  // make sure your main returns int
}
开发者ID:Matt-S,项目名称:Delta-Robot,代码行数:29,代码来源:test.c


示例19: serve_client

int serve_client(const int client) {
    state s_;
    state *s = &s_;
    int action = -1;
    if (read(client, (void*) &action, sizeof(int)) != sizeof(int)) {
        return READ_ERROR;
    }
    if (action == ACTION_LIST_SOLUTIONS) {
        WRITE(client, &num_solutions, sizeof(int));
        for (int i = 0; i < num_solutions; i++) {
            WRITE(client, sols[i]->base_state, SIZE_OF_STATE);
            int num_layers = (int)(sols[i]->num_layers);
            WRITE(client, &num_layers, sizeof(int));
            int name_len = strlen(solution_names[i]);
            WRITE(client, &name_len, sizeof(int));
            WRITE(client,solution_names[i], name_len * sizeof(char));
        }
        return SOLUTION_FOUND;
    }
    else if (action == ACTION_QUERY_STATE) {
        if (read(client, (void*) s, SIZE_OF_STATE) != SIZE_OF_STATE) {
            return READ_ERROR;
        }
        #ifdef DEBUG
            print_state(s);
            repr_state(s);
        #endif
        return query_state(client, s);
    }
    return ERROR_INVALID_ACTION;
}
开发者ID:frostburn,项目名称:tinytsumego,代码行数:31,代码来源:query.c


示例20: main

int main() {
  int rc = 0, cycle = 0;
  IAvoid_reset(&output);
  input.obstacle_detected = 0;
  input.latence1 = 2;
  input.latence2 = 3;
  input.latence3 = 4;
  input.latence4 = 5;
    
  while (1) {
    IAvoid(&input,&output);
    print_state(output);
    usleep(1000000);
    cycle++;
    if (cycle == 3) {
      input.obstacle_detected = 1;
    }

    if (output.stop && !output.up) {
      rc = 0;
    }

    if (output.up == 1) {
      rc = cycle;
      printf("rc %d\n",rc);
      input.obstacle_detected = 0;
    }
    
  }

  return 0;
}
开发者ID:insadrone,项目名称:InsaQuadDrone,代码行数:32,代码来源:main.c



注:本文中的print_state函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ print_statistics函数代码示例发布时间:2022-05-30
下一篇:
C++ print_stat函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap