Source Code
Infrared Signal Coding Schemes
home top contents previous up next

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Image;


final public class GuardedTrainCases extends GuardedTrain {
	
	public GuardedTrainCases(Dimension dim, Image img, String problemName){
		super(dim,img,problemName);
    }


	protected void initPreconstructor_Variables(){
	    modelDescription=new String[]{
	    		"Program 8. Model:   Guarded Train (GT)",
	    		"All functions are calculated by varying GT-parameters.",
                " ",
                "By default, all functions are normilized with",
                "R/Roo - 1, where Roo - correlation at t->oo."
	    };
	    initProblemPreconstructorPars_PartI();
	    
	    modelDescription_Color=new Color(150,150,150);
	    
		modelDescription_TopLeftCornerX=100;
		modelDescription_TopLeftCornerY=100;
		modelDescription_FontSize=15;

		dmnStartF=0.0;
		dmnRangeF=10.0;
		dmnRangeFDown=5;
		dmnStartX=0.01;
		dmnRangeX=2.0;
		
		functionCOUNT=5;
    	functionColor=new Color[]{
    			new Color(255,0,0),
    			new Color(0,0,255),
    			new Color(50,200,50),
    			new Color(150,0,150),
    			new Color(200,200,0)
    	};
        functionTitle=new String[]{
        	"OOK",
        	"DH-PIM alpha=2",
        	"DAPPM",
        	"Arbitrary GT",
        	"PAM Draft"
        };
        
    	//Position of data user input boxes area:
        con(" dhlim="+DH_LIM);
	}

	//do1
    //Java does not make them. No reason is understood. 
    //Fix this here, but keep researching this problem:
    protected void initProblemPreconstructorPars_PartI(){
    

    //===========================================================
	// Pure GT
	//------------------------------------------------------------
	GT_b=3;
    GT_g=1;
    GT_s=3;
    GT_A=3;
    GT_p=1.0;
    GT_q=1/2.0;
    
    GT_LIM=40;
	GTparameters=new double[100];

    
    //===========================================================
	// DH-PIM alpha=2
	//------------------------------------------------------------
	DH_LIM=40;
	DH_b=2;
    DH_g=1;
    DH_s=3;
    DH_A=1;
    DH_p=1.0;
    DH_q=1/2.0;
	DHparameters=new double[100];
    

    //===========================================================
	// OOK
	//------------------------------------------------------------
    OOK_LIM=10;
	OOKparameters=new double[100];

    
    //===========================================================
	// PAM
	//------------------------------------------------------------
    PAM_LIM=10;
    PAM_B=8;
	PAMparameters=new double[100];

    //===========================================================
    //  DAPPM
    //-----------------------------------------------------------

    DAPPM_L=4;
    DAPPM_A=2;
    DAPPM_LIM=40;
	DAPPMparameters=new double[100];
    
  } //Fix end.
  
	
	//-----------------------------------------------
    // User Input-Output Prompts
    //- - - - - - - - - - - - - - - - - - - - - - - - 
   	
    protected int setParsToStrings(){
         int i=0;
         strParsCrr[i][0]=String.valueOf(dmnRangeX);  strParsCrr[i][1]="Argument Range"; strParsCrr[i++][2]="double"; 
         strParsCrr[i][0]=String.valueOf(dmnRangeF);  strParsCrr[i][1]="Function Range"; strParsCrr[i++][2]="double";
         strParsCrr[i][0]=String.valueOf(dmnStartF);  strParsCrr[i][1]="Function Start"; strParsCrr[i++][2]="double";

         strParsCrr[i][0]=String.valueOf(GT_b);   strParsCrr[i][1]="b - Arbitrary GT.  Populated train length"; strParsCrr[i++][2]="int";
         strParsCrr[i][0]=String.valueOf(GT_g);   strParsCrr[i][1]="g - Arbitrary GT.  Guard length"; strParsCrr[i++][2]="int";
         strParsCrr[i][0]=String.valueOf(GT_s);   strParsCrr[i][1]="s - Arbitrary GT.  Maximum empty train length"; strParsCrr[i++][2]="int";
         strParsCrr[i][0]=String.valueOf(GT_A);   strParsCrr[i][1]="A - Arbitrary GT.  Maximum amplitude"; strParsCrr[i++][2]="int";
         strParsCrr[i][0]=String.valueOf(GT_p);   strParsCrr[i][1]="p - Arbitrary GT.  Probability of active chip on first position"; strParsCrr[i++][2]="double";
         strParsCrr[i][0]=String.valueOf(GT_q);   strParsCrr[i][1]="q - Arbitrary GT.  Probability of active chip on next positions"; strParsCrr[i++][2]="double";
       
         strParsCrr[i][0]=String.valueOf(DH_b);   strParsCrr[i][1]="b - DH-PIM alpha=2. Populated train length"; strParsCrr[i++][2]="int";
         strParsCrr[i][0]=String.valueOf(DH_g);   strParsCrr[i][1]="g - DH-PIM alpha=2. Guard length"; strParsCrr[i++][2]="int";
         strParsCrr[i][0]=String.valueOf(DH_s);   strParsCrr[i][1]="s - DH-PIM alpha=2. Maximum empty train length"; strParsCrr[i++][2]="int";
         strParsCrr[i][0]=String.valueOf(DH_A);   strParsCrr[i][1]="A - DH-PIM alpha=2. Maximum amplitude"; strParsCrr[i++][2]="int";
         strParsCrr[i][0]=String.valueOf(DH_p);   strParsCrr[i][1]="p - DH-PIM alpha=2. Probability of active chip on first position"; strParsCrr[i++][2]="double";
         strParsCrr[i][0]=String.valueOf(DH_q);   strParsCrr[i][1]="q - DH-PIM alpha=2. Probability of active chip on next positions"; strParsCrr[i++][2]="double";
       
         strParsCrr[i][0]=String.valueOf(DAPPM_L);   strParsCrr[i][1]="DAPPM L"; strParsCrr[i++][2]="int"; 
         strParsCrr[i][0]=String.valueOf(DAPPM_A);   strParsCrr[i][1]="DAPPM A"; strParsCrr[i++][2]="int";
         strParsCrr[i][0]=String.valueOf(DAPPM_LIM);   strParsCrr[i][1]="DAPPM limit of d -  maximum concerned chip correlation distance"; strParsCrr[i++][2]="int";

         strParsCrr[i][0]=String.valueOf(GT_DivideBy_rInf);   strParsCrr[i][1]="Normalize by dividing R by rInf: 1-normalize, 0-not"; strParsCrr[i++][2]="int";
         strParsCrr[i][0]=String.valueOf(GT_Subtract_rInf);   strParsCrr[i][1]="Normalize by subtracting rInf from R: 1-normalize, 0-not"; strParsCrr[i++][2]="int";

         strParsCrr[i][0]=String.valueOf(PAM_B);   strParsCrr[i][1]="PAM B - Number of symbols in PAM alphabet"; strParsCrr[i++][2]="int";
         
         return i;
    }
    public String setParsFromStrings(){
         int i=0;
         try{
        	 dmnRangeX =Double.parseDouble(strParsCrr[i][0]);  i++;
        	 dmnRangeF =Double.parseDouble(strParsCrr[i][0]);  i++;
        	 dmnStartF =Double.parseDouble(strParsCrr[i][0]);  i++;
        	 GT_b =Integer.parseInt(strParsCrr[i][0]);  i++;
        	 GT_g =Integer.parseInt(strParsCrr[i][0]);  i++;
        	 GT_s =Integer.parseInt(strParsCrr[i][0]);  i++;
        	 GT_A =Integer.parseInt(strParsCrr[i][0]);  i++;
        	 GT_p =Double.parseDouble(strParsCrr[i][0]);  i++;
        	 GT_q =Double.parseDouble(strParsCrr[i][0]);  i++;
        	 
        	 DH_b =Integer.parseInt(strParsCrr[i][0]);  i++;
        	 DH_g =Integer.parseInt(strParsCrr[i][0]);  i++;
        	 DH_s =Integer.parseInt(strParsCrr[i][0]);  i++;
        	 DH_A =Integer.parseInt(strParsCrr[i][0]);  i++;
        	 DH_p =Double.parseDouble(strParsCrr[i][0]);  i++;
        	 DH_q =Double.parseDouble(strParsCrr[i][0]);  i++;
        	 
        	 DAPPM_L =Integer.parseInt(strParsCrr[i][0]);  i++;
        	 DAPPM_A =Integer.parseInt(strParsCrr[i][0]);  i++;
        	 DAPPM_LIM=Integer.parseInt(strParsCrr[i][0]);  i++;

        	 GT_DivideBy_rInf =Integer.parseInt(strParsCrr[i][0]);  i++;
        	 GT_Subtract_rInf=Integer.parseInt(strParsCrr[i][0]);  i++;

        	 PAM_B=Integer.parseInt(strParsCrr[i][0]);  i++;
         }catch(Exception e){
            return "Exception when (re)setting parameters.\n" + e;    
         }
         return "";
    }
    //- - - - - - - - - - - - - - - - - - - - - - - - 
    // User Input Output Prompts
	//-----------------------------------------------

    
    //===========================================================
	// Pure GT
	//------------------------------------------------------------
    
	int GT_b;
    int GT_g;
    int GT_s;
    int GT_A;
    double GT_p;
    double GT_q;
    
    private int GT_LIM;
    double[] rGT;
    double[] mGT;
	double[] GTparameters;

	protected void prepare_PureGT_Parameters(){
		 con("\n\n\nPure GT");
		 if( rGT== null || rGT.length<GT_LIM) {
		     rGT=new double[GT_LIM];
		     mGT=new double[GT_LIM];
		 }
    	 GTparameters=new double[100];
    	 prepareGTParameters(rGT, 
    			             mGT,
    			             GT_A,
	                         GT_b,
	                         GT_g,
	                         GT_s,
	                         GT_p,
	                         GT_q,
	                         GTparameters	                         
    			             );	
	}
	//------------------------------------------------------------
	// Pure GT
    //===========================================================

    //===========================================================
	// DH-PIM alpha=2
	//------------------------------------------------------------

	int DH_LIM;
	int DH_b;
    int DH_g;
    int DH_s;
    int DH_A;
    double DH_p;
    double DH_q;
    
    double[] rDH;
    double[] mDH;
	double[] DHparameters;

	protected void prepare_DH_Parameters(){
		 con("\n\n\nDH-PIM alpha=2");
		 //int safeLimit=DH_LIM+DH_b-1;
		 if( rDH== null || rGT.length<DH_LIM) {
		     rDH=new double[DH_LIM];
		     mDH=new double[DH_LIM];
	    	 DHparameters=new double[100];
		 }
    	 prepareGTParameters(rDH, 
    			             mDH,
    			             DH_A,
	                         DH_b,
	                         DH_g,
	                         DH_s,
	                         DH_p,
	                         DH_q,
	                         DHparameters	                         
    			             );	
	}
	//------------------------------------------------------------
	// DH-PIM alpha=2
    //===========================================================

	
    //===========================================================
	// OOK
	//------------------------------------------------------------
    private int OOK_LIM;
    double[] rOOK;
    double[] mOOK;
	double[] OOKparameters=new double[100];
	protected void prepare_OOK_Parameters(){
		 con("\n\n\nOOK");
		 if( rOOK== null || rOOK.length<OOK_LIM) {
		     rOOK=new double[OOK_LIM];
		     mOOK=new double[OOK_LIM];
	    	 OOKparameters=new double[100];
		 }
    	 prepareGTParameters(rOOK, 
    			             mOOK,
    			             1,
	                         1,
	                         0,
	                         0,
	                         0.5,
	                         0.0,
	                         OOKparameters	                         
    			             );	
	}
	//------------------------------------------------------------
	// OOK
    //===========================================================

    //===========================================================
	// PAM
	//------------------------------------------------------------
    private int PAM_LIM;
    int PAM_B;
    double[] rPAM;
    double[] mPAM;
	double[] PAMparameters;
	protected void prepare_PAM_Parameters(){
		 con("\n\n\nPAM");
		 if( rPAM== null || rPAM.length<PAM_LIM) {
		     rPAM=new double[PAM_LIM];
		     mPAM=new double[PAM_LIM];
		     PAMparameters=new double[100];
		 }
    	 prepareGTParameters(rPAM, 
    			             mPAM,
    			             PAM_B,
	                         1,
	                         0,
	                         0,
	                         0.5,
	                         0.0,
	                         PAMparameters	                         
    			             );	
	}
	//------------------------------------------------------------
	// PAM
    //===========================================================

   
    
    
    //===========================================================
    //  DAPPM
    //-----------------------------------------------------------

    int DAPPM_L;
    int DAPPM_A;
    protected int DAPPM_LIM;

	double[] rDAPPM;
    double[] mDAPPM;
	double[] DAPPMparameters;

    private void prepareDAPPMParameters(){
		 con("\n\n\nDAPPM");
   	    if( rDAPPM== null || rDAPPM.length<DAPPM_LIM) {
   		    rDAPPM=new double[DAPPM_LIM];
   	  	    mDAPPM=new double[DAPPM_LIM];
	    }
	    DAPPMparameters=new double[100];
	    prepareGTParameters(
	    		         rDAPPM, 
			             mDAPPM,
			             DAPPM_A,
                         1,
                         0,
                         DAPPM_L-1,
                         1,
                         0,
                         DAPPMparameters	                         
			             );	
    }     	
    //-----------------------------------------------------------
    //  DAPPM
    //===========================================================

    protected void spawnParametersAfterUserApplied(){
    //protected void aprepareParameters(){
    	prepare_DH_Parameters();
    	prepare_PureGT_Parameters();
    	prepareDAPPMParameters();
    	prepare_OOK_Parameters();
    	prepare_PAM_Parameters();
    }
	protected double functionSwitch(int fIx, double x){
		    switch(fIx){
		    case 0: return functionGT(x,rOOK,OOKparameters);
		    case 1: return functionGT(x,rDH,DHparameters);
		    case 2: return functionGT(x,rDAPPM,DAPPMparameters);
		    case 3: return functionGT(x,rGT,GTparameters);
		    case 4: return functionGT(x,rPAM,PAMparameters);
		    }
		    return 0;
	}
	protected double functionSwitchX(int fIx, double t) {return 0;}
    
}


Copyright (C) 2009 Konstantin Kirillov