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 ISI_PAM extends MultiPathConvolution {
	public ISI_PAM(Dimension dim, Image img, String problemName){
		super(dim,img,problemName);
	}
	protected void initPreconstructor_Variables(){
		initPreconstructorInMPLevel();

		shotNoisePresented=0;
		amInteferenceSummationPoints=1;
		
		modelDescription[0]="Program 9. Model: PAM. ISI and no shot noise. Graph: BER(Height).";
		modelDescription[2]="       Horizontal axis:  ceiling height, meters.";
		modelDescription[3]="       Vertical axis:    log(BER)/log(10).";
		
        dmnRangeF=20.0;
        dmnRangeFDown=18.0;
        dmnRangeX=10.0;
        dmnStartX=7.0;
        grPoints=50;
        drawGrid=true;
        drawLengenOnCurve=false;
        gridStepY=1.0;
        grStartF=100;
        
		functionCOUNT=3;
        /*
        functionTitle[6]="OOK   Rb=0.05 Mhz";
        functionTitle[7]="PAM-2 Rb=0.05 Mhz";
        functionTitle[8]="PAM-3 Rb=0.05 Mhz";

        functionTitle[3]="OOK   Rb=50 Mhz";
        functionTitle[4]="PAM-2 Rb=50 Mhz";
        functionTitle[5]="PAM-3 Rb=50 Mhz";
        */
		
        functionTitle[0]="OOK   Rb=100 Mhz";
        functionTitle[1]="PAM-2 Rb=100 Mhz";
        functionTitle[2]="PAM-3 Rb=100 Mhz";
        
        functionColor=new Color[]{
    			new Color(150,0,0),
    			new Color(0,40,0),
    			new Color(150,0,150),
    			
    			new Color(200,0,0),
    			new Color(0,100,0),
    			new Color(200,0,200),
    			
    			new Color(255,0,0),
    			new Color(0,200,0),
    			new Color(255,0,255)
    			
    	};
	}

	//-----------------------------------------------
    // User Input Prompts
    //- - - - - - - - - - - - - - - - - - - - - - - - 
    protected int setParsToStrings(){
         int i=0;
        
         String decription="";
         for(int j=0; j<subModelTitle.length; j++){
        	 decription += ", "+j+" - " + subModelTitle[j];
         }
         
         //strParsCrr[i][0]=String.valueOf(subModel);   strParsCrr[i][1]="Sub Model: "+decription; strParsCrr[i++][2]="int"; 
         strParsCrr[i][0]=String.valueOf(shotNoisePresented);   strParsCrr[i][1]="shotNoisePresented, 0 or 1"; strParsCrr[i++][2]="int"; 
         strParsCrr[i][0]=String.valueOf(SNR);  strParsCrr[i][1]="SNR, dB"; strParsCrr[i++][2]="double"; 
         strParsCrr[i][0]=String.valueOf(amSAR);  strParsCrr[i][1]="SAR, Signal to Ambient Light Ratio"; strParsCrr[i++][2]="double"; 
         strParsCrr[i][0]=String.valueOf(amInterferencePeriodTi);  strParsCrr[i][1]="Ti, Ambient Light Interference Period, sec"; strParsCrr[i++][2]="double"; 
		 strParsCrr[i][0]=String.valueOf(amInteferenceSummationPoints);   strParsCrr[i][1]="NTi, Ambient Light Interf. Sum. Points Numb., 1 for no Interference."; strParsCrr[i++][2]="int";
         
         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(Rb);   strParsCrr[i][1]="Bit Rate, Rb"; strParsCrr[i++][2]="double";
         //strParsCrr[i][0]=String.valueOf(ceilingHeight);   strParsCrr[i][1]="Room Height, meters"; strParsCrr[i++][2]="double";

         strParsCrr[i][0]=String.valueOf(L);   strParsCrr[i][1]="Maximum symbol length, L"; strParsCrr[i++][2]="int"; 
         //strParsCrr[i][0]=String.valueOf(Amax);   strParsCrr[i][1]="Non-zero levels in chip amplitude, A"; strParsCrr[i++][2]="int";
         
         return i;
    }
    public String setParsFromStrings(){
         int i=0;
         try{
        	 //subModel =Integer.parseInt(strParsCrr[i][0]);  i++;
        	 shotNoisePresented =Integer.parseInt(strParsCrr[i][0]);  i++;
        	 SNR =Double.parseDouble(strParsCrr[i][0]);  i++;
        	 amSAR =Double.parseDouble(strParsCrr[i][0]);  i++;
        	 amInterferencePeriodTi = Double.parseDouble(strParsCrr[i][0]);  i++;
        	 amInteferenceSummationPoints = Integer.parseInt(strParsCrr[i][0]);  i++;
        	 
        	 dmnRangeX =Double.parseDouble(strParsCrr[i][0]);  i++;
        	 dmnRangeF =Double.parseDouble(strParsCrr[i][0]);  i++;
        	 dmnStartF =Double.parseDouble(strParsCrr[i][0]);  i++;
        	 //Rb =Double.parseDouble(strParsCrr[i][0]);  i++;
        	 //ceilingHeight =Double.parseDouble(strParsCrr[i][0]);  i++;
        	 L =Integer.parseInt(strParsCrr[i][0]);  i++;
        	 //Amax =Integer.parseInt(strParsCrr[i][0]);  i++;
         }catch(Exception e){
            return "Exception when (re)setting parameters.\n" + e;    
         }
         return "";
    }
    //- - - - - - - - - - - - - - - - - - - - - - - - 
    // User Input Prompts
	//================================================================

	
	
	//Accuracy is restricted by 1e-16.
	protected double BERonSNR(double ceilingHeight, double Rb, int AmaxPar){
		Amax=AmaxPar;
		this.ceilingHeight=ceilingHeight;
		this.Rb=Rb;
		
		//Apparently these three simulate user input:
		//initParsToStringsFromVars();
		//resetParametersControlsOnGUI();
		spawnParametersAfterUserApplied();
		
		//simulateThresholding();
		if(1.0e-16>BAmb)return -16.0; //Blind return. Assumed accuracy limit in Java.
		return Math.log(BAmb)/Math.log(10);
	}
	
	protected double functionSwitch(int fIx, double x){
	    switch(fIx){
	    //case 6: return BERonSNR(x, 0.05E6,  1);
	    //case 7: return BERonSNR(x, 0.05E6,  2);
	    //case 8: return BERonSNR(x, 0.05E6,  3);
	    //case 3: return BERonSNR(x, 50.0E6, 1);
	    //case 4: return BERonSNR(x, 50.0E6, 2);
	    //case 5: return BERonSNR(x, 50.0E6, 3);
	    case 0: return BERonSNR(x, 100.0E6,1);
	    case 1: return BERonSNR(x, 100.0E6,2);
	    case 2: return BERonSNR(x, 100.0E6,3);
	    }
	    return 0;
    }
	protected double functionSwitchX(int fIx, double t) {return 0;}
}


Copyright (C) 2009 Konstantin Kirillov