Пример #1
0
void Processor::run() {
	scheduler.init ();
	scheduler.updateProcQueue(globalCnt);
	curProc = scheduler.getNextProc();
	printState();
	while(scheduler.hasProc()) {
		execIO();
		if (curProc != 0) {
		  curProc->exec();
		 } else {
		    cycle = procTimeslice - 1;
		  }
		globalCnt++;
		cycle++;
		scheduler.updateProcQueue(globalCnt);
		if ( cycle == procTimeslice) {
		    if (curProc != 0) {
			if(!curProc->isEnd()) {
			    if (!curProc->isIO)
				scheduler.distribProc(curProc);
			} else {
			    scheduler.decreaseProc();
			  }
		      }
			Proc* p = curProc;
			curProc = scheduler.getNextProc();
			cycle = 0;
			if (curProc || p) {
				if (scheduler.hasProc())
					printState ();
			}
		}
	}
}
Пример #2
0
void setup_renderComponent(ILCLIENT_T *handle,
                           char *renderComponentName,
                           COMPONENT_T **renderComponent)
{
    int err;

    err = ilclient_create_component(handle,
                                    renderComponent,
                                    renderComponentName,
                                    ILCLIENT_DISABLE_ALL_PORTS |
                                        ILCLIENT_ENABLE_INPUT_BUFFERS);
    if (err == -1)
    {
        fprintf(stderr, "RenderComponent create failed\n");
        exit(1);
    }
    printState(ilclient_get_handle(*renderComponent));

    err = ilclient_change_component_state(*renderComponent,
                                          OMX_StateIdle);
    if (err < 0)
    {
        fprintf(stderr, "Couldn't change state to Idle\n");
        exit(1);
    }
    printState(ilclient_get_handle(*renderComponent));
}
Пример #3
0
void setup_fxComponent(ILCLIENT_T *handle,
                       char *fxComponentName,
                       COMPONENT_T **fxComponent)
{
    int err;

    err = ilclient_create_component(handle,
                                    fxComponent,
                                    fxComponentName,
                                    ILCLIENT_DISABLE_ALL_PORTS |
                                        ILCLIENT_ENABLE_INPUT_BUFFERS |
                                        ILCLIENT_ENABLE_OUTPUT_BUFFERS);
    if (err == -1)
    {
        fprintf(stderr, "fxComponent create failed\n");
        exit(1);
    }
    printState(ilclient_get_handle(*fxComponent));

    err = ilclient_change_component_state(*fxComponent,
                                          OMX_StateIdle);
    if (err < 0)
    {
        fprintf(stderr, "Couldn't change state to Idle\n");
        exit(1);
    }
    printState(ilclient_get_handle(*fxComponent));

    // must be before we enable buffers
    setup_deinterlace(*fxComponent);
}
void hillClimbing() {
    int iterations = 0;
    int optimum = (nqueens-1)*nqueens/2;
    
    int current_state[nqueens], i;
    for (i=0; i<nqueens; i++) {
        current_state[i] = queens_buffer[i];
    }
    
    while ((iterations < MAXITER) && (evaluateBuffer() != optimum)) {
        int best_move_evaluation = evaluateBuffer(); // Value to be maximized. Initialize with the current evaluation.
        nsuccessors = 0;
        
        // Loops through all possible moves
        int i, j;
        for (i=0; i<nqueens; i++) {
            for (j=0; j<nqueens; j++) {
                moveQueen(i,j);
                int successor_evaluation = evaluateBuffer();
                if (successor_evaluation > best_move_evaluation) {
                    saveToSuccessors(0);
                    nsuccessors = 1;
                    best_move_evaluation = successor_evaluation;
                }
                else if (successor_evaluation == best_move_evaluation) {
                    saveToSuccessors(nsuccessors);
                    nsuccessors++;
                }
                
                // Undo last move
                setBuffer(current_state);
            }
        }
        
        // Select randomly the best successor
        if (nsuccessors != 0) {
            int random_successor = rand() % nsuccessors;
            setBuffer(successors[random_successor]);
        }
        
        // Update current state
        for (i=0; i<nqueens; i++) {
            current_state[i] = queens_buffer[i];
        }
        
        iterations++;
    }
    if (evaluateBuffer() == optimum) {
        printf ("Solved puzzle.\n");
        printf ("Solution:");
        printState();
        solutions_found++;
    }
    else {
        printf("Puzzle not solved (maximum number of iterations). Final state:\n");
        printState();
    }
}
Пример #5
0
static bool simulator_view(WINDOW *out, WINDOW *state, struct program *program,
                           enum STATE *current_state)
{
        int input;
        static int timeout = 0;

        set_state(current_state);

        while (1) {
                wtimeout(state, timeout);
                input = wgetch(status);

                if (program->simulator.memory[program->simulator.PC].isBreakpoint) {
                        popup_window("Breakpoint hit!", 0, true);
                        program->simulator.isPaused = true;
                        program->simulator.memory[program->simulator.PC]
                                .isBreakpoint = false;
                }

                if (QUIT == input) {
                        return false;
                } else if (GOBACK == input) {
                        *current_state = MAIN;
                        program->simulator.isPaused = true;
                        return true;
                } else if (PAUSE == input) {
                        program->simulator.isPaused = !program->simulator.isPaused;
                } else if (START == input || RUN == input) {
                        program->simulator.isPaused = program->simulator.isHalted;
                } else if (RESTART == input) {
                        memPopulated = -1;
                        init_machine(program);
                        wclear(out);
                        wrefresh(out);
                } else if (STEP_NEXT == input) {
                        executeNext(&(program->simulator), output);
                        program->simulator.isPaused = true;
                        printState(&(program->simulator), state);
                } else if (CONTINUE == input) {
                        memPopulated = -1;
                        init_machine(program);
                } else if (CONTINUE_RUN == input) {
                        memPopulated = -1;
                        init_machine(program);
                        program->simulator.isPaused = false;
                }

                if (!program->simulator.isPaused && !program->simulator.isHalted) {
                        executeNext(&(program->simulator), out);
                        timeout = 0;
                } else {
                        set_state(current_state);
                        printState(&(program->simulator), state);
                        timeout = -1;
                        generateContext(context, program, 0, program->simulator.PC);
                }
        }
}
Пример #6
0
void test_reshape_algorithm() {

	int num1 = tidfa_num;
	
	reshape();
	
	int num2 = tidfa_num;
	
	printf("%d new states are needed!\n", num2 - num1);

	int p = 0;
	int i = 0;
	bool http_accept = false;
	for (; i < strlen(indata); i++) {
		p = tidfa_newtr[p][indata[i]];
		if (new_tidfa_accept[p] != -1) {
			http_accept = true;
			break;
		}
	}
	if (http_accept) i++;
	printf("Tidfa accept state = %d\n", p);
	printf("Character consump = %d\n", i);
	
	tsNode *t = tidfaState[getfa(p)];
	while(t != NULL) {
		if (t->tidfa_q == p) break;
		t = t->next;
	}

	matches = t->matches;
	run_string(indata + i, t->x);

	printState(t->x);
	printf("matches=%d\n", matches);
	
	printf("----------------run all character all once---------------\n");
	state st;
	matches = 0;
	st.flow_data_length = strlen(indata);
	st.flow_data = (const u_char*)indata;
  	while (st.fdpos < st.flow_data_length && st.q != NULL)
		CALL_MEMBER_FN(st, st.q)();
	printState(st);
	printf("matches=%d\n", matches);

	printf("---------------run_fs function---------\n");
	matches = 0;
	state st1;
	for (int j = 0; j < strlen(indata); j++)
		run_fs(indata[j], st1);
	printState(st1);
	
	printf("matches=%d\n", matches);
	
	return ;
}
void simulatedAnnealing() {
    clock_t clock_start;
    int optimum = (nqueens-1)*nqueens/2;
    int iterations = 0;
    double current_temperature = INITIAL_TEMPERATURE;
    
    // Starts the clock counter
    clock_start = clock();
    while (evaluateBuffer() != optimum && current_temperature > 0.005) {
        // Save current state
        int current_evaluation = evaluateBuffer();
        int current_state[nqueens], i;
        for (i=0; i<nqueens; i++) {
            current_state[i] = queens_buffer[i];
        }
        setBuffer(current_state);
        
        // Make a random move
        int random_queen = rand() % nqueens;
        int random_column = rand() % nqueens;
        moveQueen(random_queen, random_column);
        int successor_evaluation = evaluateBuffer();
        
        int delta = successor_evaluation - current_evaluation;
        // If the chosen successor is better than the current state
        if (delta > 0) {
            // do nothing
        }
        else {
            double probability_of_change = exp(delta/current_temperature);
            double random_number = (rand() % 100) / (double)100;
            if (random_number < probability_of_change) {
                // do nothing
            }
            else { // Else, revert state to the original one
                setBuffer(current_state);
            }
        }
        
        // Update temperature
        current_temperature = timeToTemperature(clock_start);
        iterations++;
    }
    if (evaluateBuffer() == optimum) {
        printf ("Solved puzzle.\n");
        printf ("Solution:");
        printState();
        solutions_found++;
    }
    else {
        printf("Not solved in this iteration. Final state:");
        printState();
    }
}
Пример #8
0
void test_subroutine_dfa_algorithm() {
	int num1 = tidfa_num;
	get_subroutine_dfa();
	int num2 = tidfa_num;
	printf("%d new states are needed!\n", num2 - num1);
	
	
		int p = 0;
	int i = 0;
	bool http_accept = false;
	state midst;
	int mid_matches = 0;
	
	for (; i < strlen(indata); i++) {
		char c = indata[i];
		if (tran_edge[p][c] != NULL) {
			mid_matches += tran_edge[p][c]->matches;
			set_result(tran_edge[p][c]->st, midst);
		}
		
		p = tidfa_newtr[p][c];
		
		if (new_tidfa_accept[p] != -1) {
			http_accept = true;
			break;
		}
	}
	if (http_accept) i++;
	printf("Tidfa accept state = %d\n", p);
	printf("Character consump = %d\n", i);
	
	tsNode *t = tidfaState[getfa(p)];
	while(t != NULL) {
		if (t->tidfa_q == p) break;
		t = t->next;
	}
	set_result(midst, t->x);
	matches = t->matches + mid_matches;
	run_string(indata + i, t->x);

	printState(t->x);
	printf("matches=%d\n", matches);
	
	printf("----------------run all character all once---------------\n");
	state st;
	matches = 0;
	st.flow_data_length = strlen(indata);
	st.flow_data = (const u_char*)indata;
  	while (st.fdpos < st.flow_data_length && st.q != NULL)
		CALL_MEMBER_FN(st, st.q)();
	printState(st);
	printf("matches=%d\n", matches);
	
}
Пример #9
0
/* **********************************
@ Implemented by Daniel Santos & Hung Q Nguyen
@ Note:
* ***********************************/
void Universe::Universe::run() {
  while (window_.isOpen() && elapsedTime_ < uni_total_times) {
    sf::Event event;
    while (window_.pollEvent(event)) {
      switch (event.type) {
        case sf::Event::Closed:
          window_.close();
          break;
        case sf::Event::KeyPressed:
          shipMove(event.key);
          break;
        default:
          break;
      }
    }
    window_.clear();
    // Update and draw
    checkClickOnSprite();
    updateDialog(selectedPlanet_);
    updateUniverse();
    window_.draw(dialogBox_);
    window_.draw(dialogText_);
    window_.draw(textTime_);
    drawStars();
    window_.draw(*ship_);
    window_.display();

    // Update current
    updateTime(step_time);
  }
  printState();
}
/* A very silly random search 'algorithm' */
void randomSearch() {
    int queen, iter = 0;
    int optimum = (nqueens-1)*nqueens/2;

    while (evaluateBuffer() != optimum) {
        printf("iteration %d: evaluation=%d\n", iter++, evaluateBuffer());
        if (iter == MAXITER) break;  /* give up */
        /* generate a (new) random state: for each queen do ...*/
        for (queen=0; queen < nqueens; queen++) {
            int pos, newpos;
            /* position (=column) of queen */
            pos = columnOfQueen(queen);
            /* change in random new location */
            newpos = pos;
            while (newpos == pos) {
                newpos = random() % nqueens;
            }
            moveQueen(queen, newpos);
        }
    }
    if (iter < MAXITER) {
        printf ("Solved puzzle. ");
    }
    printf ("Final state is");
    printState();
}
Пример #11
0
void handleInputLine() {
  led(ledToggle); 
  ledToggle = ledToggle ? 0 : 1;

  char *value = strchr(inputBuffer, '=');
  if (value) {
    *value = 0; // Zero terminate the key.
    value++;    
    int val = atoi(value);

    for (int i=0;i<P_RW_COUNT;i++) {
      if (!strcmp_P(inputBuffer, getParameterNamePGM(i))) {
	  parameters[i] = val;
	  mprintf(PSTR("Ok: Set p%d = %d\n"), i, val);	
      }
    }
	    
  } else if (*inputBuffer) {
    mprintf(PSTR("Fail '%s'\n"), inputBuffer);
  } else {
    mprintf(PSTR("Status:\n"));	
  }
  
  printState();
}
Пример #12
0
/*!

 */
bool
TextPrinter::handleShow( const int,
                         const rcsc::rcg::ShowInfoT & show )
{
    if ( ! M_init_written )
    {
        M_init_written = true;
        M_os << "(Init)" << "\n";
    }

    M_os << "(Info ";
    printState( M_os, show.time_ );

    // ball
    M_os << " (ball "
         << show.ball_.x_ << ' ' << show.ball_.y_ << ' '
         << show.ball_.vx_ << ' ' << show.ball_.vy_ << ')';

    // players
    for ( int i = 0; i < rcsc::MAX_PLAYER*2; ++i )
    {
        rcsc::rcg::player_t p;
        rcsc::rcg::Serializer::convert( show.player_[i], p );

        printPlayer( M_os,
                     show.player_[i].side(),
                     show.player_[i].unum_,
                     M_command_count[i],
                     p );
        M_command_count[i].update( show.player_[i] );
    }

    M_os << ")\n";
    return true;
}
Пример #13
0
/**
 *	@brief		search 3x4 -> 3x3
 *	@param[in]	ac_InitState		state on start
 *	@param[out]	ac_MidState			state on first search end
 *	@param[in]	ac_MoveLog			space moved log
 */
void	search3x4(char* ac_InitState, char* ac_MidState, char* ac_MoveLog)
{
    char	ac_MoveState[FIELD_SIZE];

    printState((char(*)[FIELD_WIDTH])ac_InitState);

    moveState(ac_MoveState, ac_InitState, ac_MoveLog);

    printf("moved :\n");
    printState((char(*)[FIELD_WIDTH])ac_MoveState);

    convertState(ac_MidState, ac_MoveState);

    printf("converted :\n");
    printState((char(*)[FIELD_WIDTH])ac_MidState);
}
Пример #14
0
//============================================================================
// Print some debug info
//============================================================================
void TbKalmanTrack::print() const {
  std::cout << "This is a kalman fitted tracks with chi2/ndof=" << chi2() << "/"
            << ndof() << std::endl;
  // compute forward/backward chi2
  LHCb::ChiSquare forwardchi2, backwardchi2;
  double chi2X(0), chi2Y(0);
  std::cout << "These are the nodes, with some residuals: " << std::endl;
  for (const LHCb::TbKalmanNode * node : m_nodes) {
    std::cout << node->index() << " " << node->z() << " ";
    //<< node->hasInfoUpstream( LHCb::TbKalmanNode::Forward) << " "
    //<< node->hasInfoUpstream( LHCb::TbKalmanNode::Backward) << " " ;
    printState(node->state(), std::cout);
    //std::cout << node->filterStatus( LHCb::TbKalmanNode::Forward) << " "
    //<< node->filterStatus( LHCb::TbKalmanNode::Backward) << " " ;
    const TbKalmanPixelMeasurement* pixelhit =
        dynamic_cast<const TbKalmanPixelMeasurement*>(node);
    if (pixelhit) {
      std::cout << "residual x = " << pixelhit->residualX() << " +/- "
                << std::sqrt(pixelhit->residualCovX()) << " "
                << "residual y = " << pixelhit->residualY() << " +/- "
                << std::sqrt(pixelhit->residualCovY()) << " ";
      chi2X += pixelhit->residualX() * pixelhit->residualX() / pixelhit->covX();
      chi2Y += pixelhit->residualY() * pixelhit->residualY() / pixelhit->covY();
    }
    std::cout << std::endl;
    forwardchi2 += node->deltaChi2(LHCb::TbKalmanNode::Forward);
    backwardchi2 += node->deltaChi2(LHCb::TbKalmanNode::Backward);
  }
  std::cout << "Forward/backward chi2: " << forwardchi2.chi2() << "/"
            << backwardchi2.chi2() << std::endl;
  std::cout << "X/Y chi2: " << chi2X << "/" << chi2Y << std::endl;
}
Пример #15
0
				void operator()(libmaus2::rank::DNARankMEM const & smem, uint64_t const z) const
				{
					std::ostringstream ostr;
					ostr << prefix << "\t" << z << "\t" << smem;
					setState(tid,ostr.str());
					printState();
				}
int
renderImage(OPENMAX_JPEG_DECODER * decoder) {
    int ret;

    printf("Rendering image\n");
    printState(decoder->imageDecoder->handle);

    // setup render buffer
    decoder->ppRenderInputBufferHeader[0]->nFilledLen =
	decoder->pOutputBufferHeader->nFilledLen;
    decoder->ppRenderInputBufferHeader[0]->nFlags = OMX_BUFFERFLAG_EOS;

    printf("Render buffer has %d\n",
	   decoder->ppRenderInputBufferHeader[0]->nFilledLen);
    ret = OMX_EmptyThisBuffer(decoder->imageRender->handle,
			     decoder->ppRenderInputBufferHeader[0]);
    if (ret != OMX_ErrorNone) {
	perror("Emptying render input buffer");
	fprintf(stderr, "Error code %s\n", err2str(ret));
	return OMXJPEG_ERROR_MEMORY;
    } else {
	printf("Called to empty render input buffer\n");
    }

    return OMXJPEG_OK;
}
Пример #17
0
void
V3SVrfIPDR::generalization2(V3SIPDRTimedCube& generalizedCube) {
   if(heavy_debug){
      cerr << "UNSAT, generalizing... Frame before gen:" << generalizedCube.first << " Cube before gen:";
      printState(generalizedCube.second->getState());
   }

   removeFromProof2(generalizedCube);
   generalizeProof(generalizedCube);
   forwardProof(generalizedCube);

   if(heavy_debug){
      cerr << "After generalize... Frame after gen:" << generalizedCube.first << " Cube after gen:";
      printState(generalizedCube.second->getState());
   }
}
Пример #18
0
/* returns >= 0 if match should continue, -1 on failure */
static int addToLogFile( const Game *game, const State *state,
			 const double value[ MAX_PLAYERS ],
			 const uint8_t player0Seat,
			 char *seatName[ MAX_PLAYERS ], FILE *logFile )
{
  int c, r;
  uint8_t p;
  char line[ MAX_LINE_LEN ];

  /* prepare the message */
  c = printState( game, state, MAX_LINE_LEN, line );
  if( c < 0 ) {
    /* message is too long */

    fprintf( stderr, "ERROR: log state message too long\n" );
    return -1;
  }

  /* add the values */
  for( p = 0; p < game->numPlayers; ++p ) {

    r = snprintf( &line[ c ], MAX_LINE_LEN - c,
		  p ? "|%.6f" : ":%.6f", value[ p ] );
    if( r < 0 ) {

      fprintf( stderr, "ERROR: log message too long\n" );
      return -1;
    }
    c += r;

    /* remove trailing zeros after decimal-point */
    while( line[ c - 1 ] == '0' ) { --c; }
    if( line[ c - 1 ] == '.' ) { --c; }
    line[ c ] = 0;
  }

  /* add the player names */
  for( p = 0; p < game->numPlayers; ++p ) {

    r = snprintf( &line[ c ], MAX_LINE_LEN - c,
		  p ? "|%s" : ":%s",
		  seatName[ playerToSeat( game, player0Seat, p ) ] );
    if( r < 0 ) {

      fprintf( stderr, "ERROR: log message too long\n" );
      return -1;
    }
    c += r;
  }

  /* print the line to log and flush */
  if( fprintf( logFile, "%s\n", line ) < 0 ) {

    fprintf( stderr, "ERROR: logging failed for game %s\n", line );
    return -1;
  }
  fflush( logFile );

  return 0;
}
Пример #19
0
void DynamicBinding::print( QTextStream &out, QString key )
{
    QString initial = "set %1_initial \"vstr %1_state_%2;vstr %1_select;vstr %1_action\";";
    initial = initial.arg( _name ).arg( _initialIndex );

    QString select = "set %1_select \"set action vstr %1_action;set back vstr %1_back;set next vstr %1_next; ut_echo Selected %1 adjustment\";";
    select = select.arg( _name );

    QString binding = "bind %2 \"vstr %1_select\";";
    binding = binding.arg( _name ).arg( key );

    out << "// Begin " << _description << endl;
    out << endl;
    for( int i = 0; i < _stateList.size(); i++ )
    {
        printState( out, i );
        out << endl;
    }
    out << initial << endl;
    out << select << endl;
    out << endl;
    out << binding << endl;
    out << endl;
    out << "// Finish " << _description << endl;
}
Пример #20
0
void printStateNode(stateNode &p) {
	printf("\n----------------------------------\n");
	printf("tidfa_q = %d\n", p.tidfa_q);
	printf("matches = %d\n", p.matches);
	printState(p.st);
	printf("----------------------------------\n");
}
int DAUDIO_Start(void* id, int isSource) {
    AlsaPcmInfo* info = (AlsaPcmInfo*) id;
    int ret;
    snd_pcm_state_t state;

    TRACE0("> DAUDIO_Start\n");
    // set to blocking mode
    snd_pcm_nonblock(info->handle, 0);
    // set start mode so that it always starts as soon as data is there
    setStartThreshold(info, TRUE /* use threshold */);
    state = snd_pcm_state(info->handle);
    if (state == SND_PCM_STATE_PAUSED) {
        // in case it was stopped previously
        TRACE0("  Un-pausing...\n");
        ret = snd_pcm_pause(info->handle, FALSE);
        if (ret != 0) {
            ERROR2("  NOTE: error in snd_pcm_pause:%d: %s\n", ret, snd_strerror(ret));
        }
    }
    if (state == SND_PCM_STATE_SUSPENDED) {
        TRACE0("  Resuming...\n");
        ret = snd_pcm_resume(info->handle);
        if (ret < 0) {
            if ((ret != -EAGAIN) && (ret != -ENOSYS)) {
                ERROR2("  ERROR: error in snd_pcm_resume:%d: %s\n", ret, snd_strerror(ret));
            }
        }
    }
    if (state == SND_PCM_STATE_SETUP) {
        TRACE0("need to call prepare again...\n");
        // prepare device
        ret = snd_pcm_prepare(info->handle);
        if (ret < 0) {
            ERROR1("ERROR: snd_pcm_prepare: %s\n", snd_strerror(ret));
        }
    }
    // in case there is still data in the buffers
    ret = snd_pcm_start(info->handle);
    if (ret != 0) {
        if (ret != -EPIPE) {
            ERROR2("  NOTE: error in snd_pcm_start: %d: %s\n", ret, snd_strerror(ret));
        }
    }
    // set to non-blocking mode
    ret = snd_pcm_nonblock(info->handle, 1);
    if (ret != 0) {
        ERROR1("  ERROR in snd_pcm_nonblock: %s\n", snd_strerror(ret));
    }
    state = snd_pcm_state(info->handle);
#ifdef USE_TRACE
    printState(state);
#endif
    ret = (state == SND_PCM_STATE_PREPARED)
        || (state == SND_PCM_STATE_RUNNING)
        || (state == SND_PCM_STATE_XRUN)
        || (state == SND_PCM_STATE_SUSPENDED);
    TRACE1("< DAUDIO_Start %s\n", ret?"success":"error");
    return ret?TRUE:FALSE;
}
Пример #22
0
int main(int argc, char *argv[])
{
    for(;;) {
		loop();
		printState();
	}
    return 0;
}
Пример #23
0
void printNode (Node n, int size) {
    printf("\nNew State!\n");
    printf("\n");
    printf("State:");
    printState(n, size*size);
    printf("\n");
    printf("Depth: %d\n",n->depth);
    printf("Cost: %d\n", n->cost);
}
Пример #24
0
void printStateList(statepVec *v)
{
  unsigned int i;
  for(i = 0; i < v->len; i++) {
    printf("\t");
    printState(v->vec[i]);
    fflush(stdout);
  }
}
Пример #25
0
//-----------------------------------------------------------------------------
//! @brief   TODO enter a description
//! @remark
//-----------------------------------------------------------------------------
void InputState::mergeInputState(const InputState& input)
{
#ifdef _DEBUG
    static bool test = false;
    if (test)
    {
        printState();
    }
#endif
    for (auto standardInputAction : input.m_inputState)
    {
        //Does this action exist in the current input state?
        InputStateMap::iterator it = std::find_if(m_inputState.begin(), m_inputState.end(), [standardInputAction](const StandardInputAction& inputAction) { return inputAction.getAction().getType() == standardInputAction.getAction().getType(); });
        if (it != m_inputState.end())
        {
            float currentValue = it->getValue();
            float inputValue = standardInputAction.getValue();
            //Different signs, take the difference, need to figure out which one is bigger or negative
            currentValue = currentValue + inputValue;
            currentValue = math::clamp(currentValue, 0.0f, 1.0f);
#ifdef _DEBUG
            if (test)
            {
                MSG_TRACE_CHANNEL("Input State", "During merging %s value will change to %f", InputSystem::m_actionNames[standardInputAction.getAction()], currentValue);
            }
#endif

            it->setValue(currentValue);
        }
        else
        {
            //Value is not found in the current input set so we should add it to it.
            m_inputState.push_back(standardInputAction);
        }
    }

#ifdef _DEBUG
    if (test)
    {
        printState();
        input.printState();
    }
#endif
}
Пример #26
0
void patch(stPtrRefVec *lst, statep s)
{
  unsigned int i;
  if(debug)printf("patching %d ptr to:\t", lst->len);
  if(debug)printState(s);
  for(i = 0; i < lst->len; i++) {
    if(debug)printf("patching <%p>...\n", &(lst->vec[i]));
    *(lst->vec[i]) = s;
  }
}
Пример #27
0
void print_info(struct gameState state)
{
	printSupply(&state);
	printHand(state.whoseTurn, &state);
	printDeck(state.whoseTurn, &state);
	printDiscard(state.whoseTurn, &state);
	printPlayed(state.whoseTurn, &state);
	printState(&state);
	printScores(&state);
}
Пример #28
0
    void moveSingle(SimpleStack<size_t> & from, SimpleStack<size_t> & to) {
        assert(!from.isEmpty());
        assert(from.peek() < to.peek());

        to.Push(from.Pop());

        if(print_states) {
            printState();
        }
    }
Пример #29
0
const bool
V3SVrfIPDR::checkReachability2(const uint32_t& frame, const V3NetVec& cubeState, const bool& extend, const bool& notImportant) {
   if(heavy_debug && !notImportant){
      cerr << "\n!!!!!!checkReachability2 frame : " << frame << " cube : ";
      printState(cubeState);
      cerr << endl;
   }
   assert (frame > 0); assert (frame < getPDRFrame());
   const uint32_t& d = frame - 1;


   _pdrSvr[d]->assumeRelease();
   // Assume cube'
   addCubeToSolver2(d, cubeState, 0);

   /*V3SSvrMiniSat * gg= (V3SSvrMiniSat *)_pdrSvr[d];
   for (unsigned i = 0; i < 40; ++i){
      cerr << i << " : " << gg->getVerifyData( i ,0 ) << endl;
   }*/
    for (uint32_t i = 0; i < cubeState.size(); ++i)
     _pdrSvr[d]->assumeProperty(_pdrSvr[d]->getFormula(_handler->_latchMap->at(_decompDepth)[cubeState[i].id], 0), cubeState[i].cp);
    if (extend) {
     // Assume ~cube
     addCubeToSolver(d, cubeState, 0);
     V3SvrDataVec blockCube; blockCube.clear(); blockCube.reserve(cubeState.size()); size_t fId;
     for (uint32_t i = 0; i < cubeState.size(); ++i) {
        fId = _pdrSvr[d]->getFormula(_vrfNtk->getLatch(cubeState[i].id), 0);
        blockCube.push_back(cubeState[i].cp ? fId : _pdrSvr[d]->getNegFormula(fId));
     }
     _pdrSvrData = _pdrSvr[d]->setImplyUnion(blockCube);
     assert (_pdrSvrData); _pdrSvr[d]->assumeProperty(_pdrSvrData);
     // Check Reachability by SAT Calling
     if (profileON()) _solveStat->start();
     _pdrSvr[d]->simplify();
     const bool result = _pdrSvr[d]->assump_solve();
     if (profileON()) _solveStat->end();
     _pdrSvr[d]->assertProperty(_pdrSvr[d]->getNegFormula(_pdrSvrData));  // Invalidate ~cube in future solving
     if(heavy_debug && !notImportant) cerr << "result: " << result << endl << endl;
     return result;
    }
    else {
     if (profileON()) _solveStat->start();
     /*V3SSvrMiniSat * GG = (V3SSvrMiniSat *)_pdrSvr[d];
     for (unsigned i = 0, s = GG->_assump.size(); i < s; ++i){
        cout << var(GG->_assump[i]) << ":" << sign(GG->_assump[i]) << endl;
     }*/
     _pdrSvr[d]->simplify();
     const bool result = _pdrSvr[d]->assump_solve();
     if (profileON()) _solveStat->end();
     if(heavy_debug && !notImportant) cerr << "result: " << result << endl << endl;
     return result;
    }

}
Пример #30
0
/**
 * @brief Sends all pending data to dev console
 */
void updateDevConsoleState(Engine *engine) {
	if (!isConsoleReady()) {
		return;
	}
// looks like this is not needed anymore
//	checkIfShouldHalt();
	printPending();

	/**
	 * this should go before the firmware error so that console can detect connection
	 */
	printSensors(&logger, false);

#if EFI_PROD_CODE || defined(__DOXYGEN__)
	// todo: unify with simulator!
	if (hasFirmwareError()) {
		scheduleMsg(&logger, "FATAL error: %s", errorMessageBuffer);
		warningEnabled = false;
		scheduleLogging(&logger);
		return;
	}
#endif

#if (EFI_PROD_CODE && HAL_USE_ADC) || defined(__DOXYGEN__)
	pokeAdcInputs();
#endif

	if (!fullLog) {
		return;
	}

	systime_t nowSeconds = getTimeNowSeconds();
	printInfo(nowSeconds);

#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
	int currentCkpEventCounter = getCrankEventCounter();
	if (prevCkpEventCounter == currentCkpEventCounter && timeOfPreviousReport == nowSeconds) {
		return;
	}
	timeOfPreviousReport = nowSeconds;

	prevCkpEventCounter = currentCkpEventCounter;
#else
	chThdSleepMilliseconds(200);
#endif

	printState();

#if EFI_WAVE_ANALYZER
	printWave(&logger);
#endif

	scheduleLogging(&logger);
}