Beispiel #1
0
//! get parameter 
var* sci_bert::get(int param)
{
 var* p_var_ivec = new var_ivec;	// create var_ivec;	
 ivec &iv = (dynamic_cast<var_ivec *>(p_var_ivec))->v; // alias to vector	

 var* p_var_bvec = new var_bvec;	// create var_vec;	
 bvec &bv = (dynamic_cast<var_bvec *>(p_var_bvec))->v; // alias to bvect	

	switch (param)
	{
	case SCI_SIZE:
    case SCI_LENGTH:
		iv.set_length(1);
  		iv[0] = get_length();
		return(p_var_ivec);
	
	case SCI_STATE:
		bv = get_state();
		return(p_var_bvec);
	
	case SCI_SYMBOL_SIZE:
		iv.set_length(1);
 		iv[0] = get_symbol_size();
		return(p_var_ivec);
	
	case SCI_THRESHOLD:
 		iv = get_threshold();
		return(p_var_ivec);
	
	case SCI_BER_CNT:		
		iv = get_ber_cnt();
		return(p_var_ivec);
	
	case SCI_BIT_CNT:		
		iv = get_bit_cnt();
		return(p_var_ivec);
	
	case SCI_METRICS:
		iv.set_length(1);
		iv[0] = get_metrics();
		return(p_var_ivec);
	
	case SCI_FSM:		
		iv.set_length(1);
		iv[0] = get_fsm();
		return(p_var_ivec);
	
	case SCI_OUTPUT:
		iv.set_length(1);
		iv[0] = get_output();
		return(p_var_ivec);

	default:
		throw sci_exception ("sci_bert::get - unknown param", param);			
	}	     
};
Beispiel #2
0
void _cmps_ctor()
{
	fsm_t* machine = get_fsm();

	//CONSTRUCTING
	//example:
	//cmp_cmdexecutor_ctor();

	//CONNECTING
	PRINTING_CONNECT_COMPONENTS;

	//example:
	//CMP_CONNECT(get_cmp_recorder()->send, get_cmp_groupcounter()->receier);

}
Beispiel #3
0
void program(struct arg_int  *time)
{
    int sec = 0;

    /*Firing the FSM so lanch the program*/
    get_fsm()->fire(EVENT_SETUP, NULL); /* TODO: if you have a config file use the path instead of null */
    get_fsm()->fire(EVENT_START, NULL);

    //If time argument is given the program terminates itself automatically
    if(time->count){
      INFOPRINT("The program is going to be terminated %d sec later", *(time->ival));
    }

    while(running){
      thread_sleep(1000);
      if(time->count && *(time->ival) < ++sec){
        break;
      }
    }

    get_fsm()->fire(EVENT_STOP, NULL);
    get_fsm()->fire(EVENT_SHUTDOWN, NULL);

}
Beispiel #4
0
fsm_states_t _fsm_halt_trans(int32_t event, void *arg)
{
	CMP_DEF_THIS(fsm_t, get_fsm());

	switch(event)
	{
	  case EVENT_SETUP:
	    _cmps_ctor();
	    _sys_setup((char_t*) arg);
	    return STATE_HALT;
	  case EVENT_START:
        _sys_start();
        return STATE_RUN;
	  case EVENT_SHUTDOWN:
        _sys_shutdown();
        _cmps_dtor();
        return STATE_HALT;
	  default:
	    WARNINGPRINT("The event (%s) you required doesn't have transition in the current state (%s)", this->event_str, this->state_str);
	    break;
	}

	return this->current;
}
Beispiel #5
0
void _cmps_ntrt_ctor()
{
	fsm_t* machine = get_fsm();

	cmp_sniffer_ctor();
	cmp_evaluator_ctor();
	cmp_recorder_ctor();
	cmp_accumulator_ctor();
	cmp_groupcounter_ctor();
	cmp_cmdexecutor_ctor();

	//Bind:
	PRINTING_CONNECT_COMPONENTS;

	CMP_CONNECT(get_cmp_sniffer()->send, get_cmp_evaluator()->sniff_receiver);
	CMP_CONNECT(get_cmp_evaluator()->send, get_cmp_accumulator()->record_receiver);
	CMP_CONNECT(get_cmp_accumulator()->send_record, get_cmp_evaluator()->record_receiver);

	CMP_CONNECT(get_cmp_recorder()->features_requester, get_cmp_accumulator()->features_requester);

	CMP_CONNECT(get_cmp_sniffer()->send2groupcounter, get_cmp_groupcounter()->sniff_receiver);
	CMP_CONNECT(get_cmp_recorder()->groupcounter_requester, get_cmp_groupcounter()->record_requester);

}