コード例 #1
0
ファイル: prefs.cpp プロジェクト: kkoerner/VegModel
void Preferences::changeOTransition(state from,state to,float min,float max,float value){
  cout<<from<<";"<<to<<": "<<getOTransition(from,to)<<"--> change "<<value;
  if (from==SEEDL&&to>SEEDL){//sum of all estab must be less than one
    if (to==JUV) {set_p1(get_p1()+value);}
    else if (to==VEG) {set_p2(get_p2()+value);}
    else {set_p3(get_p3()+value);}
  }
  else if(from==JUV&&to>JUV){
    if (to==VEG) {set_gr1(get_gr1()+value);}
    else  {set_gr2(get_gr2()+value);}
  }
  else{
     float new_val=o_transitions[from][to]+value;
     if  (new_val<=min||new_val>=max) return;
     o_transitions[from][to]=new_val;
     cout<<">"<<new_val<<endl;
  }
    }
コード例 #2
0
ファイル: prefs.cpp プロジェクト: kkoerner/VegModel
/**
  Function sets single object transition rates.
  The value is reduced if establishment or growth of a state would exceed 1.
  \date 24.04.08
  \date 10.10.08
  changed, such as unvalid values are ignored, not recalculated
  \param from the stage of origin
  \param to the stage to go to
  \param value the new value
*/
void  Preferences::setOTransition(state from,state to,float value){
  cout<<from<<";"<<to<<": "<<getOTransition(from,to)<<"-->"<<value;
  if (from==SEEDL&&to>SEEDL){//sum of all estab must be less than one
    float diff=getOTransition(from,to)-value;
    if (to==JUV) {set_p1(get_p1()+diff);}
    else if (to==VEG) {set_p2(get_p2()+diff);}
    else {set_p3(get_p3()+diff);}
  }
  else if(from==JUV&&to>JUV){
    float diff=getOTransition(from,to)-value;
    if (to==VEG) {set_gr1(get_gr1()+value);}
    else  {set_gr2(get_gr2()+value);}
  }
  else{
     o_transitions[from][to]=std::max((float)0.0,value);
     cout<<">"<<value<<endl;
  }
}
コード例 #3
0
ファイル: pins.c プロジェクト: 2e4L/reaver-wps
/* Generate the p1 and p2 pin arrays */
void generate_pins()
{
        int i = 0, index = 0;

	/* If the first half of the pin was not specified, generate a list of possible pins */
	if(!get_static_p1())
	{
		/* 
		 * Look for P1 keys marked as priority. These are pins that have been 
		 * reported to be commonly used on some APs and should be tried first. 
		 */
		for(index=0, i=0; i<P1_SIZE; i++)
		{
			if(k1[i].priority == 1)
			{
				set_p1(index, k1[i].key);
				index++;
			}
		}
        
		/* Randomize the rest of the P1 keys */
		for(i=0; index < P1_SIZE; i++)
        	{
	                if(!k1[i].priority)
	                {
	                        set_p1(index, k1[i].key);
	                        index++;
			}
		}
        }
	else
	{
		/* If the first half of the pin was specified by the user, only use that */
		for(index=0; index<P1_SIZE; index++)
		{
			set_p1(index, get_static_p1());
		}
	}

	/* If the second half of the pin was not specified, generate a list of possible pins */
	if(!get_static_p2())
	{
		/* 
		 * Look for P2 keys statically marked as priority. These are pins that have been 
		 * reported to be commonly used on some APs and should be tried first. 
		 */
		for(index=0, i=0; i<P2_SIZE; i++)
		{
			if(k2[i].priority == 1)
			{
				set_p2(index, k2[i].key);
				index++;
			}
		}

		/* Randomize the rest of the P2 keys */
        	for(i=0; index < P2_SIZE; i++)
        	{
                	if(!k2[i].priority)
                	{
                	        set_p2(index, k2[i].key);
                	        index++;
			}
                }
        }
	else
	{
		/* If the second half of the pin was specified by the user, only use that */
		for(index=0; index<P2_SIZE; index++)
		{
			set_p2(index, get_static_p2());
		}
	}

        return;
}