import java.awt.Color; import java.awt.Dimension; import java.awt.Image; final public class AmbientNoise extends MultiPathConvolution{ public AmbientNoise(Dimension dim, Image img, String problemName){ super(dim,img,problemName); } double unit=100.0E-6; protected void initPreconstructor_Variables(){ initPreconstructorInMPLevel(); modelDescription[0]="Program: 4. Model: Ambient Noise."; functionCOUNT=8; functionTitle[1]=""; //functionTitle[2]="mi. t-unit=a"; functionTitle[3]="mi."; functionTitle[4]="vi. "+100000+" ns"; functionTitle[5]="vi. "+15000+" ns"; functionTitle[6]="vi. "+10+" ns"; functionTitle[7]="vi. "+2+" ns"; dmnRangeF=30.0; dmnRangeX=100.0E-6; dmnRangeFDown=15; grStartF=350; functionColor=new Color[]{ new Color(255,0,0), new Color(200,100,0), new Color(255,0,200), new Color(0,100,200,50), new Color(0,0,255), new Color(255,0,0), new Color(0,100,0), new Color(200,0,200) }; } //----------------------------------------------- // 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 //================================================================ protected double functionSwitch(int fIx, double x){ switch(fIx){ case 0: return hh(x); //case 1: return drawSignal(x,hk)/scaled_chip_length; //case 2: return am_mi(x*a)*.05; case 3: return am_mi(x); //case 4: return am_vi(x*unit, x*unit+scaled_chip_length*a )*.05; case 4: return am_vi(x, 100.0E-6); case 5: return am_vi(x, 15.0E-6); case 6: return am_vi(x, 0.01E-6); case 7: return am_vi(x, 0.002E-6); } return 0; } protected double functionSwitchX(int fIx, double t) {return 0;} } Copyright (C) 2009 Konstantin Kirillov