package com.nsc.webench.calculators;

import java.io.File;
import java.lang.reflect.Constructor;
import java.net.InetAddress;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;

import org.apache.log4j.Logger;

import com.nsc.webench.components.BasicDevice;
import com.nsc.webench.dataobjects.TemplateDeviceFamily;
import com.nsc.webench.dataobjects.TemplateStaticCalculation;
import com.nsc.webench.pojo.CircuitData;
import com.nsc.webench.pojo.ComponentData;
import com.nsc.webench.pojo.DesignInfo;
import com.nsc.webench.pojo.WebenchDesign;
import com.nsc.webench.power.ccmodels.Design;
import com.nsc.webench.power.circuitcalculators.DesignFactory;
import com.nsc.webench.power.circuitcalculators.DesignFactoryClassLoader;
import com.nsc.webench.power.designer.Customer;
import com.nsc.webench.services.CircuitAssemblyService;
import com.nsc.webench.services.DataObjectService;
import com.nsc.webench.testscripts.DesignIntegrityTest;
import com.nsc.webench.ws.WBConstants;

public class CalculatorFactory {

	private static Logger logger = Logger.getLogger(CalculatorFactory.class.getName());

	// Dynamic Calculations
	private BaseCalculator calculator;
	
	// Static Calculations
    private WebenchDesign webenchDesign;
	
	/*
	 * Constructor
	 */
	
	public CalculatorFactory (WebenchDesign webenchDesign) {
		
		this.setWebenchDesign(webenchDesign);
		
		// Retrive design info
		DesignInfo myDesign = webenchDesign.getMyDesign();
		
		// Retrieve device
		String device 	= myDesign.getDevice();
		String topology = myDesign.getTopology();
		String flow		= myDesign.getFlow();
			
		if( webenchDesign.getMyDesign().getCC_detect().equals("HW")){
			this.calculator = new PowerCalculator(webenchDesign);
		}
		// Set calculator
		else if (("amplifiers").equals(flow)) {
			this.calculator = new FilterArchitectCalculator(webenchDesign);
		}
		else if (("opamps").equals(flow)) {
			if (topology.equalsIgnoreCase("Non-inverting")) {
				this.calculator = new AmplifierDesignerCalculator(webenchDesign);
			}
			else if (topology.equalsIgnoreCase("Inverting")) {
				this.calculator = new AmplifierDesignerCalculatorInverting(webenchDesign); 
			}
		}
		
		else if (device.equals("TPS27081A")) {
			this.calculator = new TPS27081A_Calculator(webenchDesign);
		}
		
		else if (device.equals("TLV62065")) {
			this.calculator = new TLV62065_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS51200")) {
			this.calculator = new TPS51200_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS27082L")) {
			this.calculator = new TPS27082L_Calculator(webenchDesign);
		}
		else if (device.equals("TPS62401/1")|| device.equals("TPS62403/1")) {
			this.calculator = new TPS62401_1_Calculator(webenchDesign);
		}
		else if (device.equals("TPS62402/1")|| device.equals("TPS62402-Q1/1")) {
			this.calculator = new TPS62402_1_Calculator(webenchDesign);
		}
		else if (device.equals("TPS62404/1")|| device.equals("TPS62404-Q1/1")) {
			this.calculator = new TPS62404_1_Calculator(webenchDesign);
		}
		else if (device.equals("TPS62405-Q1/1")) {
			this.calculator = new TPS62405_Q1_1_Calculator(webenchDesign);
		}
		else if (device.equals("TPS62421/1")) {
			this.calculator = new TPS62421_1_Calculator(webenchDesign);
		}
		else if(device.equals("TPS61021") || device.equals("TPS61021A"))
		{
			this.calculator = new SteppedStartupDecorator(new TPS61021_Calculator(webenchDesign));
		}
		else if(device.equals("TLV62130"))
		{
			this.calculator = new SteppedStartupDecorator(new TLV62130_Calculator(webenchDesign));
		}
		else if (device.equals("TPS61030") || device.equals("TPS61031") || device.equals("TPS61032"))  {
			this.calculator = new SteppedStartupDecorator(new TPS61030_Calculator(webenchDesign));
		}
		else if (device.equals("TPS53647")) {
			this.calculator = new TPS53647_Calculator(webenchDesign);
		}
		else if (device.equals("TPS65261/1")||device.equals("TPS65261/2")||device.equals("TPS65261/3")||device.equals("TPS65261-1/1")||device.equals("TPS65261-1/2")||device.equals("TPS65261-1/3")) {
			this.calculator = new TPS65261_Calculator(webenchDesign);
		}
		else if (device.equals("TPS65262/1")||device.equals("TPS65262/2")||device.equals("TPS65262/3")||device.equals("TPS65262-1/1")||device.equals("TPS65262-1/2")||device.equals("TPS65262-1/3")) {
			this.calculator = new TPS65262_Calculator(webenchDesign);
		}
		else if (device.equals("TPS65265/1")||device.equals("TPS65265/2")||device.equals("TPS65265/3")) {
			this.calculator = new TPS65265_Calculator(webenchDesign);
		}
		else if (device.equals("TPS65400/1")||device.equals("TPS65400/2")||device.equals("TPS65400/3")||device.equals("TPS65400-Q1/1")||device.equals("TPS65400-Q1/2")||device.equals("TPS65400-Q1/3")||device.equals("TPS65400-Q1/4")) {
			this.calculator = new TPS65400_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS54331") || device.equals("TPS54331-Q1") || device.equals("TPS54531") || device.equals("TPS54231")||device.equals("TPS54332")) {
			this.calculator = new TPS54331_Calculator(webenchDesign);
		} 
		else if (device.equals("TPS54335") || device.equals("TPS54335A")) {
			this.calculator = new TPS54335_Calculator(webenchDesign);
		} 
		else if (device.equals("TPS54336") || device.equals("TPS54336A")) {
			this.calculator = new TPS54336_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54334")) {
			this.calculator = new TPS54334_Calculator(webenchDesign);
		}
		else if (device.equals("TPS51216") || device.equals("TPS51716") || device.equals("TPS51916")) {
			this.calculator = new TPS51216_Calculator(webenchDesign);
		}
		else if (device.equals("TPS5410")) {
			this.calculator = new TPS5410_Calculator(webenchDesign);
		}
		else if (device.equals("TPS5410-Q1")) {
			this.calculator = new TPS5410_Q1_Calculator(webenchDesign);
		}
		else if (device.equals("TPS5430")) {
			this.calculator = new TPS5430_Calculator(webenchDesign);
		}
		else if (device.equals("TPS5431")) {
			this.calculator = new TPS5430_Calculator(webenchDesign);
		}
		else if (device.equals("TPS5430-Q1")) {
			this.calculator = new TPS5430_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS54A20")) {
			this.calculator = new TPS54A20_Calculator(webenchDesign);
		}
		else if (device.equals("TPS62770")) {
			this.calculator = new TPS62770_Calculator(webenchDesign);
		}
		else if (device.equals("LM2574HV")) {
			this.calculator = new LM2574HV_Calculator(webenchDesign);
		}
		else if (device.equals("LM2574")) {
			this.calculator = new LM2574_Calculator(webenchDesign);
		}
			
		else if (device.equals("TPS82740A")) {
			this.calculator = new TPS82740A_Calculator(webenchDesign);
		}
		else if (device.equals("TPS62134D")) {
			this.calculator = new SteppedStartupDecorator(new TPS62134D_Calculator(webenchDesign));
		}
		else if (device.equals("TPS62745") ) {
			this.calculator = new SteppedStartupDecorator(new TPS62745_Calculator(webenchDesign));
		}
	
		else if (device.equals("TPS62097")|| device.equals("TPS6209718") || device.equals("TPS6209733") ) {
			this.calculator = new SteppedStartupDecorator(new TPS62097_Calculator(webenchDesign));
		}
		
		else if (device.equals("TPS62130") || device.equals("TPS62130A") || device.equals("TPS62130A-Q1") ) {
			this.calculator = new SteppedStartupDecorator(new TPS62130_Calculator(webenchDesign));
		}
		
		else if(device.equals("TPS627451")) {
			this.calculator = new SteppedStartupDecorator(new TPS627451_Calculator(webenchDesign));
		}
		else if (device.equals("TPS61235") || device.equals("TPS61235P")) {
			this.calculator = new SteppedStartupDecorator(new TPS61235_Calculator(webenchDesign));
		}
		else if (device.equals("TPS61236") || device.equals("TPS61236P") ) {
			this.calculator = new SteppedStartupDecorator(new TPS61236_Calculator(webenchDesign));
		}
		else if (device.equals("TPS62172-Q1")) {
			this.calculator = new TPS62172_Q1_Calculator(webenchDesign);
		}
		else if (device.equals("TPS62170-Q1")) {
			this.calculator = new TPS62170_Q1_Calculator(webenchDesign);			
		}
		else if (device.equals("TPS62171-Q1")) {
			this.calculator = new TPS62171_Q1_Calculator(webenchDesign);			
		}
		else if (device.equals("TPS62175") || device.equals("TPS62177")) {
			this.calculator = new SteppedStartupDecorator(new TPS62175_Calculator(webenchDesign));
		}
		else if (device.equals("TPS62180")||device.equals("TPS62184")) {
			this.calculator = new TPS62180_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS62480")) {
			this.calculator = new TPS62480_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS82130")) {
			this.calculator = new TPS82130_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS62182")) {
			this.calculator = new TPS62180_Calculator(webenchDesign);
		}
		else if (device.equals("TPS5420")) {
			this.calculator = new TPS5420_Calculator(webenchDesign);
		}
		else if (device.equals("TPS5432")) {
			this.calculator = new TPS5432_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54233")) {
			this.calculator = new TPS54233_Calculator(webenchDesign);
		}
		else if (device.equals("TPS82740B")) {
			this.calculator = new TPS82740B_Calculator(webenchDesign);
		}
		else if (device.equals("TPS61040")|| device.equals("TPS61041")) {
			this.calculator = new TPS61040_Calculator(webenchDesign);
		}
		else if (device.equals("TPS61070")|| device.equals("TPS61071")) {
			this.calculator = new TPS61070_Calculator(webenchDesign);
		}
		else if (device.equals("TPS61071-Q1")) {
			this.calculator = new TPS61070_Calculator(webenchDesign);
		}
		else if (device.equals("TPS61072")) {
			this.calculator = new TPS61072_Calculator(webenchDesign);
		}
		else if (device.equals("TPS61073")) {
			this.calculator = new TPS61070_Calculator(webenchDesign);
		}
		else if (device.equals("TPS61045")) {
			this.calculator = new TPS61045_Calculator(webenchDesign);	
		}
		else if (device.equals("TPS61046")) {
			this.calculator = new TPS61046_Calculator(webenchDesign);
			
		} else if (device.equals("TPS61220")) {
			this.calculator = new TPS61220_Calculator(webenchDesign);
			
		} else if (device.equals("TPS61093")) {
			this.calculator = new TPS61093_Calculator(webenchDesign);
		
		} else if (device.equals("TPS61098")) {
			this.calculator = new TPS61098_Calculator(webenchDesign);
		
		} else if (device.equals("TPS610981"))  {
			this.calculator = new TPS610981_Calculator(webenchDesign);
		
		} else if ( device.equals("TPS610985")) {
			this.calculator = new TPS610985_Calculator(webenchDesign);
		
		} else if ( device.equals("TPS610986")) {
			this.calculator = new TPS610986_Calculator(webenchDesign);
		
		}		else if (device.equals("TPS610982")) {
			this.calculator = new TPS610982_Calculator(webenchDesign);
		
		} else if (device.equals("TPS61093-Q1")) {
			this.calculator = new TPS61093_Calculator(webenchDesign);
		
		} else if (device.equals("TPS61240")) {
			this.calculator = new TPS61240_Calculator(webenchDesign);
		}
		else if (device.equals("TPS61240-Q1")) {
			this.calculator = new TPS61240_Calculator(webenchDesign);
		}
		else if (device.equals("TPS61241")) {
			this.calculator = new TPS61241_Calculator(webenchDesign);
		}
		else if (device.equals("TPS61253")) {
				this.calculator = new TPS61253_Calculator(webenchDesign);
		}
		else if (device.equals("TPS652510/1") || device.equals("TPS652510/2") || device.equals("TPS652510/3")) {
			this.calculator = new TPS652510_Calculator(webenchDesign);
		}
		else if (device.equals("TPS61251")) {
			this.calculator = new TPS61251_Calculator(webenchDesign);
		}
		else if (device.equals("TPS61254")) {
			this.calculator = new TPS61254_Calculator(webenchDesign);
		}
		
		
		else if (device.equals("TPS61256")||device.equals("TPS61256B")) {
			this.calculator = new TPS61256_Calculator(webenchDesign);
		}	
		
		else if (device.equals("TPS61258")) {
			this.calculator = new TPS61258_Calculator(webenchDesign);
		}	
		
		else if (device.equals("TPS61259")) {
			this.calculator = new TPS61259_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS612592")) {
			this.calculator = new TPS612592_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS25940A")) {
			this.calculator = new TPS25940A_Calculator(webenchDesign);
			
		}
		else if (device.equals("LMZ36002")) {
			this.calculator = new LMZ36002_Calculator(webenchDesign);
			
		}
				
		else if (device.equals("LMZ34202")) {
			this.calculator = new LMZ34202_Calculator(webenchDesign);
			
		}
				
		else if (device.equals("TPS25944A")) {
			this.calculator = new TPS25944A_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS25942L")) {
				this.calculator = new TPS25942L_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS25944L")) {
			this.calculator = new TPS25944L_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS54618")||device.equals("TPS54618-Q1")) {
			this.calculator = new TPS54618_Calculator(webenchDesign);
			
		}
		else if (device.equals("TPS54719")) {
			this.calculator = new TPS54719_Calculator(webenchDesign);
			
		}
		else if (device.equals("TPS25942A")) {
			this.calculator = new TPS25942A_Calculator(webenchDesign);
			
		}
		else if (device.equals("TPS25940L")) {
			this.calculator = new TPS25940L_Calculator(webenchDesign);
			
		}
		else if (device.equals("TPS62743")) {
			this.calculator = new SteppedStartupDecorator(new TPS62743_Calculator(webenchDesign));
			
		}
		else if (device.equals("TPS5420-Q1")) {
			this.calculator = new TPS5420_Q1_Calculator(webenchDesign);
		}
		else if (device.equals("TPS5450")) {
			this.calculator = new TPS5450_Calculator(webenchDesign);
		}
		else if (device.equals("TPS5450-Q1")) {
			this.calculator = new TPS5450_Q1_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54623")) {
			this.calculator = new TPS54623_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54340")) {
			this.calculator = new TPS54340_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54340-Q1")) {
			this.calculator = new TPS54340_Q1_Calculator(webenchDesign);
		}
		else if (device.equals("TPS43060")) {
			this.calculator = new TPS43060_Calculator(webenchDesign);
		}
		else if (device.equals("TPS43061")) {
			this.calculator = new TPS43060_Calculator(webenchDesign);
		}
		else if (device.equals("TPS62086")) {
			this.calculator = new TPS62086_Calculator(webenchDesign);
		}
		else if (device.equals("TPS62087")) {
			this.calculator = new TPS62087_Calculator(webenchDesign);
		}
		else if (device.equals("TPS40305")) {
			this.calculator = new TPS40305_Calculator(webenchDesign);
		}
		else if (device.equals("TPS40303")) {
			this.calculator = new TPS40303_Calculator(webenchDesign);
		}
		else if (device.equals("TPS40425")||device.equals("TPS40425/1")||device.equals("TPS40425/2") ) {
			this.calculator = new TPS40425_Calculator(webenchDesign);
		}
		else if (device.equals("TPS40428")||device.equals("TPS40428/1")||device.equals("TPS40428/2") ) {
			this.calculator = new TPS40428_Calculator(webenchDesign);
		}
		else if (device.equals("TPS56C215")) {
			this.calculator = new TPS56C215_Calculator(webenchDesign);
		}
		else if (device.equals("TPS82085")) {
			this.calculator = new TPS82085_Calculator(webenchDesign);
		}
		else if (device.equals("TPS40304")) {
			this.calculator = new TPS40304_Calculator(webenchDesign);
		}
		else if (device.equals("TPS40170")) {
			this.calculator = new TPS40170_Calculator(webenchDesign);
		}
		else if (device.equals("TPS40170-Q1")) {
			this.calculator = new TPS40170_Q1_Calculator(webenchDesign);
		}
		else if (device.equals("TPS40210")) {
			this.calculator = new TPS40210_Calculator(webenchDesign);
		}
		else if (device.equals("TPS40210-Q1")) {
			this.calculator = new TPS40210_Q1_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54062")) {
			this.calculator = new TPS54062_Calculator(webenchDesign);
		}
		else if (device.equals("TPS62134A")) {
			this.calculator = new SteppedStartupDecorator( new TPS62134A_Calculator(webenchDesign));
		}
		else if (device.equals("TPS62134B")) {
			this.calculator = new SteppedStartupDecorator(new TPS62134B_Calculator(webenchDesign));
		}
		else if (device.equals("TPS62134C")) {
			this.calculator = new SteppedStartupDecorator( new TPS62134C_Calculator(webenchDesign));
		}
		else if (device.equals("TPS54061")) {
			this.calculator = new TPS54061_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54061-Q1")) {
			this.calculator = new TPS54061_Q1_Calculator(webenchDesign);
		}
		else if (device.equals("TPS56921")) {
				this.calculator = new TPS56921_Calculator(webenchDesign);
		}
		else if (device.equals("TPS560200")) {
			this.calculator = new TPS560200_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54040")|| device.equals("TPS57040-Q1")||device.equals("TPS5401")) {
				this.calculator = new TPS54040_Calculator(webenchDesign);
				
		} 
		 else if (device.equals("TPS54040A")) {
				this.calculator = new TPS54040_Calculator(webenchDesign);
				
		} 
		 else if (device.equals("TPS54040-Q1")) {
				this.calculator = new TPS54040_Calculator(webenchDesign);
				
		} 
		 else if (device.equals("TPS54060")||device.equals("TPS57060-Q1")) {
				this.calculator = new TPS54040_Calculator(webenchDesign);				
		} 
				 
		 else if (device.equals("TPS54060A")) {
				this.calculator = new TPS54040_Calculator(webenchDesign);
				
		} 
		 else if (device.equals("TPS54060-Q1")) {
				this.calculator = new TPS54040_Calculator(webenchDesign);
				
		} 
		 else if (device.equals("TPS54140")||device.equals("TPS57140-Q1")) {
				this.calculator = new TPS54140_Calculator(webenchDesign);
				
		} else if (device.equals("TPS54140A")) {
			this.calculator = new TPS54140_Calculator(webenchDesign);
			
		}
		 else if (device.equals("TPS54140-Q1")) {
				this.calculator = new TPS54140_Calculator(webenchDesign);
				
		}
		 else if (device.equals("TPS54160") || device.equals("TPS57160-Q1")) {
				this.calculator = new TPS54140_Calculator(webenchDesign);
				
			}
		 else if (device.equals("TPS57112-Q1")) {
				this.calculator = new TPS57112_Q1_Calculator(webenchDesign);
				
			}
		 else if (device.equals("TPS57114-Q1")) {
				this.calculator = new TPS57114_Q1_Calculator(webenchDesign);
				
			}
		 else if (device.equals("TPS54160A")) {
				this.calculator = new TPS54140_Calculator(webenchDesign);
				
			}
		 else if (device.equals("TPS54160-Q1")) {
				this.calculator = new TPS54140_Calculator(webenchDesign);
				
			}
		 else if (device.equals("TPS62120")) {
				this.calculator = new TPS62120_Calculator(webenchDesign);
				
			}
			else if (device.equals("TPS61089")) {
				this.calculator = new TPS61089_Calculator(webenchDesign);
				
			}
		 else if (device.equals("TPS62122")) {
				this.calculator = new TPS62120_Calculator(webenchDesign);
				
		} else if (device.startsWith("TPS2294")){
			 this.calculator = new LoadSwitchCalculator(webenchDesign);
		} else if (device.startsWith("TPS2291")) {
			this.calculator = new LoadSwitchCalculator(webenchDesign);
		}  else if(device.startsWith("TPS2295")){
			this.calculator = new TPS2295X_Calculator(webenchDesign);
		} else if(device.startsWith("TPS2296")){
			this.calculator = new TPS2296X_Calculator(webenchDesign);
		} else if (device.equals("LM46002") || device.equals("LM46002-Q1")) {  //6th gen SIMPLE SWITCHER
			this.calculator = new LM46002_Calculator(webenchDesign);
		 
		} else if (device.startsWith("LM43603") || device.equals("LM43603-Q1")) {  //6th gen SIMPLE SWITCHER
			this.calculator = new LM43603_Calculator(webenchDesign);			
			
		} else if (device.startsWith("LM43602") || device.equals("LM43602-Q1")) {  //6th gen SIMPLE SWITCHER
			this.calculator = new LM43602_Calculator(webenchDesign);			
		
		} else if (device.equals("LM43600") || device.equals("LM43600-Q1")) {	//6th gen SIMPLE SWITCHER
			this.calculator = new LM43600_Calculator(webenchDesign);
			
		} else if (device.equals("LM43601") || device.equals("LM43601-Q1")) {	//6th gen SIMPLE SWITCHER
			this.calculator = new LM43601_Calculator(webenchDesign);
			
		} 
		else if (device.equals("LM46000") || device.equals("LM46001") ) {	//6th gen SIMPLE SWITCHER
		this.calculator = new LM46000_Calculator(webenchDesign);
		} 
		 
		else if (device.startsWith("LM267")) {
			this.calculator = new LM267X_Calculator(webenchDesign);
			
		} else if ((device.startsWith("LM27342")) || (device.startsWith("LM27341")) || (device.equals("LMR12015")) || (device.equals("LMR12020"))) {
			this.calculator = new LM27342_Calculator(webenchDesign);
			
		} else if (device.equals("LM2750")) {
			this.calculator = new LM2750_Calculator(webenchDesign);
			
		} else if (device.equals("LM2770")) {
			this.calculator = new LM2770_Calculator(webenchDesign);
			
		} else if (device.equals("LM2788")) {
			this.calculator = new LM2788_Calculator(webenchDesign);
			
		} else if (device.equals("LM3557")) {
			this.calculator = new LM3557_Calculator(webenchDesign);
			
		} else if (device.equals("LM2700")) {
			this.calculator = new LM2700_Calculator(webenchDesign);
			
		}else if (device.startsWith("LM367")) {
			this.calculator = new LM367X_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM258") && "boost".equalsIgnoreCase(topology)) {
			this.calculator = new LM258X_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM258") && "flyback".equalsIgnoreCase(topology)) {
			this.calculator = new LM258XF_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM2854")) {
			this.calculator = new LM2854_Calculator(webenchDesign);
			
		} /*else if ((device.startsWith("LM3478") || device.startsWith("LM3488")) && "boost".equalsIgnoreCase(topology)) {
			this.calculator = new LM34XX_Calculator(webenchDesign);
			
		}*/ else if (device.startsWith("LM3404")) {
			this.calculator = new LM3404_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM3402")) {
			this.calculator = new LM3404_Calculator(webenchDesign);

		} else if (device.startsWith("LM2734") || device.startsWith("LM2736")|| device.startsWith("LMR12010")) {
			this.calculator = new LM2734_Calculator(webenchDesign);			

		} else if (device.startsWith("LM2738")) {
			this.calculator = new LM2738_Calculator(webenchDesign);

		} else if (device.startsWith("LM2852")) {
			this.calculator = new LM2852_Calculator(webenchDesign);		
			
		} else if (device.equals("LM53602A-Q1")||device.equals("LM536023-Q1")||device.equals("LM536025-Q1")) {
			this.calculator = new LM53602A_Q1_Calculator(webenchDesign);
		
		} else if (device.equals("LM53601A-Q1")||device.equals("LM536013-Q1")) {
			this.calculator = new LM53601A_Q1_Calculator(webenchDesign);	
		
		} else if (device.equals("LM536015-Q1")) {
			this.calculator = new LM536015_Q1_Calculator(webenchDesign);	
		
		} else if (device.equals("LM53600A-Q1")||device.equals("LM536003-Q1")){
			this.calculator = new LM53600A_Q1_Calculator(webenchDesign);		
		
		}else if (device.equals("LM536005-Q1")) {
			this.calculator = new LM536005_Q1_Calculator(webenchDesign);	
		
		}else if (device.startsWith("LM536033-Q1")) {
			this.calculator = new LM536033_Q1_Calculator(webenchDesign);		
			
		} else if (device.startsWith("LM53603A-Q1")) {
			this.calculator = new LM53603A_Q1_Calculator(webenchDesign);	
			
		}else if (device.startsWith("LM536035-Q1")) {
			this.calculator = new LM536035_Q1_Calculator(webenchDesign);		
			
		} else if (device.equals("LM53635A-Q1")|| device.equals("LM536353-Q1")|| device.equals("LM53635M-Q1")) {
			this.calculator = new LM53635A_Q1_Calculator(webenchDesign);	
			
		}	else if (device.equals("LM53625A-Q1")|| device.equals("LM53625M-Q1")|| device.equals("LM536255-Q1")|| device.equals("LM53625L-Q1") || device.equals("LM53625N-Q1")|| device.equals("LM536253-Q1")) {
			this.calculator = new LM53625A_Q1_Calculator(webenchDesign);	
		
		} else if (device.equals("LM536355-Q1") || device.equals("LM53635N-Q1") || device.equals("LM53635L-Q1")) {
			this.calculator = new LM536355_Q1_Calculator(webenchDesign);	
		
		}else if ( (device.startsWith("LM557") || device.startsWith("LM2557")) && "Inverting_Buck_Boost".equalsIgnoreCase(topology)) {
			this.calculator = new LM557X_IBB_Calculator(webenchDesign);	
			
		} else if ( (device.startsWith("LM557") || device.startsWith("LM2557")) && "Buck".equalsIgnoreCase(topology)) {
			this.calculator = new LM557X_Calculator(webenchDesign);
					
		} else if (device.startsWith("LM2854")) {
			this.calculator = new LM2854_Calculator(webenchDesign);
			
		} 
		else if (device.equals("LM5121-Q1")&& "Boost".equalsIgnoreCase(topology)) {
			this.calculator = new LM5121_Q1_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM2854")) {
			this.calculator = new LM2854_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM315")) {
			this.calculator = new LM315X_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM2735")) {
			this.calculator = new LM2735_Calculator(webenchDesign);			
			
		} else if (device.startsWith("LM259")) {
			this.calculator = new LM259x_Calculator(webenchDesign);			
			
		} else if (device.startsWith("LM2731X")) {
			this.calculator = new LM2731X_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM5010")) {
			this.calculator = new LMx5010_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM25010")) {
			this.calculator = new LMx5010_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM5007")) {
			this.calculator = new LMx5007_8_9_Calculator(webenchDesign);
			
		}
		else if (device.startsWith("LM5160")) {
			this.calculator = new LM5160_Calculator(webenchDesign);
			
		}
		else if (device.equals("LM5161") || device.equals("LM5161-Q1") ){
			this.calculator = new LM5161_Calculator(webenchDesign);
			
		}
		else if (device.equals("LM5165")  || device.equals("LM5165-Q1") || device.equals("LM5165X") || device.equals("LM5165Y") || device.equals("LM5165X-Q1") || device.equals("LM5165Y-Q1") ) {
			this.calculator = new LM5165X_Calculator(webenchDesign);
			
		}
		else if (device.startsWith("LM5175")) {
			this.calculator = new LM5175_Calculator(webenchDesign);
			
		}
		else if (device.startsWith("LM5008")) {
			this.calculator = new LMx5007_8_9_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM5009")) {
			this.calculator = new LMx5007_8_9_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM25007")) {
			this.calculator = new LMx5007_8_9_Calculator(webenchDesign);
		
		} else if (device.equals("LM34910")) {
			this.calculator = new LM34910_Calculator(webenchDesign);	
		
		}else if (device.equals("LM34910C")) {
			this.calculator = new LM34910C_Calculator(webenchDesign);
		
		} else if (device.equals("LM34917A")) {
			this.calculator = new LM34917A_Calculator(webenchDesign);
				
		} else if (device.startsWith("LM3491") && !device.startsWith("LM34919") && !device.equals("LM34914") && !device.equals("LM34910")) {
			this.calculator = new LM349xx_Calculator(webenchDesign);
		
		} else if (device.startsWith("LM3421")) {
			this.calculator = new LM3421_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM3423")) {
			this.calculator = new LM3423_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM3424")) {
			this.calculator = new LM3424_Calculator(webenchDesign);
			
		} else if (device.equals("LM3429")) {
			this.calculator = new LM3429_Q1_Calculator(webenchDesign);			
		
		} else if (device.equals("LM3429-Q1")) {
			this.calculator = new LM3429_Q1_Calculator(webenchDesign);
				
		} else if (device.equals("TPS54116-Q1")) {
			this.calculator = new TPS54116_Q1_Calculator(webenchDesign);
				
		} else if (device.startsWith("LM310") || device.startsWith("LMR242")) {
			this.calculator = new LM310X_Calculator(webenchDesign);
			
//		} else if (device.startsWith("LM5005")) {
//			this.calculator = new LMx5005_Calculator(webenchDesign);	
			
		} else if (device.startsWith("LM5005")) {
			this.calculator = new LM557X_Calculator(webenchDesign);
			
//		} else if (device.startsWith("LM25005")) {
//			this.calculator = new LMx5005_Calculator(webenchDesign);
	
		} else if (device.startsWith("LM25005")) {
			this.calculator = new LM557X_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM1770")) {
			this.calculator = new LM1770_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM2696")) {
			this.calculator = new LM2696_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM5000")) {
			this.calculator = new LM5000_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM2853")) {
			this.calculator = new LM2852_Calculator(webenchDesign);
				
		} 
		else if (device.equals("TPS54202")|| device.equals("TPS54202H")|| device.equals("TPS54302")) {
			this.calculator = new TPS54202_Calculator(webenchDesign);
				
		} 
		else if (device.startsWith("LMR10530")) {		//added 9-17-12, Kevin.
			this.calculator = new LMR10530Y_Calculator(webenchDesign);
		
		} else if (device.startsWith("LM2833")) {		//added 9-17-12, Kevin.
			this.calculator = new LMR10530Y_Calculator(webenchDesign);
		
		} else if (device.startsWith("LM283") || device.startsWith("LMR105")) {
			this.calculator = new LM283x_Calculator(webenchDesign);

		} else if (device.startsWith("LM3485")) {
			this.calculator = new LM3485_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM2267") || device.startsWith("LM22680")) {
			this.calculator = new LM2267X_Calculator(webenchDesign);
		
		} else if (device.startsWith("LM5015")) {
			this.calculator = new LM5015_Calculator(webenchDesign);
			
//		} else if (device.startsWith("LM3668")) {
//			this.calculator = new LM3668_Calculator(webenchDesign);
		
//		} else if (device.startsWith("LM3410")) {
//			this.calculator = new LM3410_Calculator(webenchDesign);	
		
		} else if (device.startsWith("LM3406")) {
			this.calculator = new LM3406_Calculator(webenchDesign);

		} else if (device.startsWith("LM3406HV")) {
			this.calculator = new LM3406HV_Calculator(webenchDesign);

		} else if (device.startsWith("LM3401")) {
			this.calculator = new LM3401_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM3405A")) {
			this.calculator = new LM3405A_Calculator(webenchDesign);

		} else if (device.startsWith("LM2743")) {
			this.calculator = new LM2743_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM2743-Q1")) {
			this.calculator = new LM2743_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM201")) {
			this.calculator = new LM20XXX_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM202")) {
			this.calculator = new LM20XXX_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM203")) {
			this.calculator = new LM20XXX_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM3409")) {
			this.calculator = new LM3409HV_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM3410")) {
			this.calculator = new LM3410_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM3431")) {
			this.calculator = new LM3431_Calculator(webenchDesign);

		} else if (device.startsWith("LM5088") && "Buck".equalsIgnoreCase(topology)){
			this.calculator = new LM5088_Calculator(webenchDesign);			

		} else if (device.startsWith("LM25088")&& "Buck".equalsIgnoreCase(topology)) {
			this.calculator = new LM5088_Calculator(webenchDesign);	
			
		} else if (device.startsWith("LM5088") && "Inverting_Buck_Boost".equalsIgnoreCase(topology)) {
			this.calculator = new LM5088IBB_Calculator(webenchDesign);
			
		} else if (device.startsWith("LMZ34002") && "Inverting_Buck_Boost".equalsIgnoreCase(topology)) {
			this.calculator = new LM5088IBB_Calculator(webenchDesign);			
			
/*		} else if (device.startsWith("LM25088") && "Inverting_Buck_Boost".equalsIgnoreCase(topology)) {
			this.calculator = new LM5088IBB_Calculator(webenchDesign);
			*/
			
		} 		 
		 else if (device.startsWith("LMZ10504")) {
			this.calculator = new LMZ10504_Calculator(webenchDesign);
			
		}
		 else if (device.startsWith("LMZ31503")) 
		 {
				this.calculator = new LMZ31503_Calculator(webenchDesign);
				
		 }
		 else if (device.equals("LMZ31506")) {
			this.calculator = new LMZ31506_Calculator(webenchDesign);	
			
		}
		else if (device.equals("LMZ31506H")) {
			this.calculator = new LMZ31506H_Calculator(webenchDesign);	
			
		}else if (device.startsWith("LMZ35003")) {
			this.calculator = new LMZ35003_Calculator(webenchDesign);
			
		}
		else if (device.startsWith("LMZ30604")) {
			this.calculator = new LMZ30604_Calculator(webenchDesign);
			
		}else if (device.startsWith("LM284")|| device.startsWith("LMR1420")) {
			this.calculator = new LM284x_Calculator(webenchDesign);
			
		}/*else if (device.equals("LMZ13610")) {
			this.calculator = new LMZ13610_Calculator(webenchDesign);
		
		}*/else if (device.startsWith("LMZ1420")) {
			this.calculator = new LMZ14203_Calculator(webenchDesign);
		
		} else if (device.equals("LMZ12001") || device.equals("LMZ12002")  || device.equals("LMZ12003")) {
			this.calculator = new LMZ12003_Calculator(webenchDesign); 
		
		} 
		else if (device.startsWith("LMR14050S") || device.startsWith("LMR14020S") || device.startsWith("LMR14030S")) {
			this.calculator = new LMR14050S_Calculator(webenchDesign);
		
		}		
		else if(device.equals("LMR14003X")|| device.equals("LMR14003Y"))
		{
		 this.calculator = new LMR14003X_Calculator(webenchDesign);			
		}
		
		else if(device.equals("LMR14006X")|| device.equals("LMR14006Y"))
		{
		 this.calculator = new LMR14006X_Calculator(webenchDesign);			
		}
		
		else if(device.equals("LMR16006X")|| device.equals("LMR16006Y"))
		{
		 this.calculator = new LMR16006X_Calculator(webenchDesign);			
		}	
		else if(device.equals("LMR16010P")|| device.equals("LMR16020P"))
		{
		 this.calculator = new LMR16020P_Calculator(webenchDesign);			
		}
		else if(device.equals("LMR16030S"))
		{
		 this.calculator = new LMR16030S_Calculator(webenchDesign);			
		}
		else if(device.equals("LMR16030P"))
		{
		 this.calculator = new LMR16030P_Calculator(webenchDesign);			
		}
		else if(device.equals("LMR23625C")|| device.equals("LMR23610A"))
		{
		 this.calculator = new LMR23625C_Calculator(webenchDesign);			
		}
		else if(device.equals("LMR23625CF"))
		{
		 this.calculator = new LMR23625CF_Calculator(webenchDesign);			
		}
		else if(device.equals("LMR23630A")|| device.equals("LMR23630AF"))
		{
		 this.calculator = new LMR23630A_Calculator(webenchDesign);			
		}
		else if (device.startsWith("LM3433")) {
			this.calculator = new LM3433_Calculator(webenchDesign);
			
		} 
		else if (device.startsWith("LMZ30606")) {
			this.calculator = new LMZ30606_Calculator(webenchDesign);			
		}
		else if (device.startsWith("LMZ30602")) {
			this.calculator = new LMZ30602_Calculator(webenchDesign);			
		}
		else if ( (device.equals("LM5001") || device.equals("LM5001-Q1")) &&  ( "boost".equalsIgnoreCase(topology) ||  "flyback".equalsIgnoreCase(topology) || "sepic".equalsIgnoreCase(topology) ) ) {

			this.calculator = new LM5001_Calculator(webenchDesign);	//jazmine 8/27/2014
					
		} else if (device.startsWith("LM3481") || device.startsWith("LM3017")) {
			this.calculator = new LM3481_Calculator(webenchDesign);	
			
		} else if ((device.startsWith("LM3478") || device.startsWith("LM3488")) && "boost".equalsIgnoreCase(topology)) {
			this.calculator = new LM5001_Calculator(webenchDesign);	
			
		} else if ((device.startsWith("LM3478") || device.startsWith("LM3488")) && "sepic".equalsIgnoreCase(topology)) {
			this.calculator = new LM34XX_Calculator(webenchDesign);	
			
		} else if (device.equals("LM5118")||device.equals("LM5118-Q1")) {
			this.calculator = new LM5118_Calculator(webenchDesign);	
			
		} else if (device.startsWith("LM25118")) {
			this.calculator = new LM25118_Calculator(webenchDesign);	
			
		}else if (device.startsWith("LM5085")) {
			this.calculator = new LM5085_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM25085")) {
			this.calculator = new LM5085_Calculator(webenchDesign);	
			
		} else if (device.startsWith("LM25085A")) {
			this.calculator = new LM5085_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM3407")) {
			this.calculator = new LM3407_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM5002")) {
			this.calculator = new LM5001_Calculator(webenchDesign);	
		
 		} else if (device.startsWith("LM5116")) {
			this.calculator = new LM5116_Calculator(webenchDesign);	
 		
 		} else if (device.startsWith("LM25116")) {
			this.calculator = new LM5116_Calculator(webenchDesign);	
		
 		} else if (device.startsWith("LM34930")) {
			this.calculator = new LM34930_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM34919")) {
			this.calculator = new LM34919_Calculator(webenchDesign);
		
		}else if (device.equals("LM34914")) {
			this.calculator = new LM34914_Calculator(webenchDesign);	
		
		}else if (device.equals("LM34910")) {
			this.calculator = new LM34910_Calculator(webenchDesign);	
		
		} else if (device.startsWith("LM3434")) {
			this.calculator = new LM3433_Calculator(webenchDesign);
		
		} else if (device.startsWith("LM5020-1")) {
			this.calculator = new LM5020_1_Calculator(webenchDesign);
		
		} else if (device.startsWith("LM5020-2")) {
			this.calculator = new LM5020_1_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM5022")&& "Boost".equalsIgnoreCase(topology)) {
			this.calculator = new LM5022_Calculator(webenchDesign);	
			
		} else if (device.equals("LM5122")&& "Boost".equalsIgnoreCase(topology)) {
			this.calculator = new LM5122_Calculator(webenchDesign);	
				
		} else if (device.equals("LM5122-Q1")&& "Boost".equalsIgnoreCase(topology)) {
			this.calculator = new LM5122_Q1_Calculator(webenchDesign);
			
		} else if (device.equals("LM5121")&& "Boost".equalsIgnoreCase(topology)) {
			this.calculator = new LM5121_Calculator(webenchDesign);	
				
		/*} else if (device.equals("LM5121-Q1")&& "Boost".equalsIgnoreCase(topology)) {
			this.calculator = new LM5121_Q1_Calculator(webenchDesign);*/
			
		}else if (device.startsWith("LM5022") && "SEPIC".equalsIgnoreCase(topology)) {
			this.calculator = new LM5022S_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM27402") || device.startsWith("LM27403")) {
			this.calculator = new LM27402_Calculator(webenchDesign);	
		
		} else if (device.startsWith("LM21305") ) {
			this.calculator = new LM21305_Calculator(webenchDesign);	
		
		} else if (device.startsWith("LM10500") ) {
			this.calculator = new LM10500_Calculator(webenchDesign);	
		
		} else if (device.startsWith("LMZ10503")) {
			this.calculator = new LMZ10504_Calculator(webenchDesign);
			
		} else if (device.startsWith("LMZ31530")) {
			this.calculator = new LMZ31530_Calculator(webenchDesign);	//jaz
			
		} else if (device.startsWith("LMZ31520")) {
			this.calculator = new LMZ31530_Calculator(webenchDesign);	//jaz
		
		} else if (device.startsWith("LM3414")) {
			this.calculator = new LM3414_Calculator(webenchDesign);
		
		}/*else if (device.startsWith("LM21215")) {
			this.calculator = new LM21215_Calculator(webenchDesign);
		
		}*/else if (device.startsWith("LMZ10505")) {
			this.calculator = new LMZ10504_Calculator(webenchDesign);
		
		} else if (device.startsWith("LM2743")) {
			this.calculator = new LM2743_Calculator(webenchDesign);
		
		} else if (device.startsWith("LM2743-Q1")) {
			this.calculator = new LM2743_Calculator(webenchDesign);			
			
		} else if (device.startsWith("LMZ31710")) {
			this.calculator = new LMZ31710_Calculator(webenchDesign);	//added by PJ			
			
		} else if (device.startsWith("LMZ31704")) {
			this.calculator = new LMZ31710_Calculator(webenchDesign);	//added by PJ			
			
		} else if (device.startsWith("LMZ31707")) {
			this.calculator = new LMZ31710_Calculator(webenchDesign);	//added by PJ			
			
		} else if (device.startsWith("LM27402")) {
			this.calculator = new LM27402_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM3464")) {
			this.calculator = new LM3464_Calculator(webenchDesign);
		
		} else if (device.startsWith("LM21215")) {
			this.calculator = new LM21k_Calculator(webenchDesign);
		
		} else if (device.startsWith("LM21212")) {
			this.calculator = new LM21k_Calculator(webenchDesign);
		
		} else if (device.startsWith("LM21212-2")) {
			this.calculator = new LM21k_Calculator(webenchDesign);
		
		} else if (device.startsWith("LM21215A-1")) {
			this.calculator = new LM21k_Calculator(webenchDesign);
		
		}
		else if (device.equals("TPS54218")){
			this.calculator = new TPS54218_Calculator(webenchDesign);			
		}
		else if (device.equals("TPS54318")){
			this.calculator = new TPS54318_Calculator(webenchDesign);
			
		}else if (device.equals("TPS54320")){
			this.calculator = new TPS54320_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM5117") || device.startsWith("LM25117") || device.startsWith("TPS5432")) {
			this.calculator = new LM5117_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM5119") || device.startsWith("LM25119")) {
			this.calculator = new LM5119_Calculator(webenchDesign);
			
		} else if (device.equals("LM5140-Q1")){
			this.calculator = new LM5140_Q1_Calculator(webenchDesign);
			
		} else if (device.equals("LM5141-Q1")){
			this.calculator = new LM5141_Q1_Calculator(webenchDesign);
			
		}else if (device.startsWith("LM3492") ) {
			this.calculator = new LM3492_Calculator(webenchDesign);	
		
		} else if (device.startsWith("LMZ23605")||device.startsWith("LM2875")||device.startsWith("LM2874")||device.startsWith("LMZ23603")||device.startsWith("LMZ22003")||device.startsWith("LMZ22005")) {
			this.calculator = new LMZ23605_Calculator(webenchDesign);
		
		} else if (device.startsWith("LMZ22010")) {
			this.calculator = new LMZ22010_Calculator(webenchDesign);
			
		} else if (device.startsWith("LMZ22008")) {
			this.calculator = new LMZ22010_Calculator(webenchDesign);
				
		} else if (device.startsWith("LMZ23610")) {
			this.calculator = new LMZ22010_Calculator(webenchDesign);
				
		} else if (device.equals("LMZ23608")) {
			this.calculator = new LMZ22010_Calculator(webenchDesign);
			
		} else if (device.equals("LMZ13606H") || device.equals("LMZ13608H") || device.equals("LMZ23606H") || device.equals("LMZ23608H"))  {
			this.calculator = new LMZ23608H_Calculator(webenchDesign);
				
		} else if (device.startsWith("LMZ12010")) {
			this.calculator = new LMZ22010_Calculator(webenchDesign);
			
		} else if (device.startsWith("LMZ12008")) {
			this.calculator = new LMZ22010_Calculator(webenchDesign);
			
		} else if (device.equals("LMZ13608")) {
			this.calculator = new LMZ22010_Calculator(webenchDesign);
			
		} else if (device.startsWith("LMZ13610")) {
			this.calculator = new LMZ22010_Calculator(webenchDesign);
			
		} else if (device.equals("TPS54260")) {
			this.calculator = new TPS54260_Calculator(webenchDesign);
		
		} else if (device.equals("TPS54260-Q1")) {
			this.calculator = new TPS54260_Q1_Calculator(webenchDesign);
			
		} else if (device.equals("TPS54260-Q1")) {
			this.calculator = new TPS54260_Q1_Calculator(webenchDesign);	
			
		} else if (device.equals("TPS54260-Q1")) {
				this.calculator = new TPS54260_Q1_Calculator(webenchDesign);
		
		} else if (device.equals("TPS54341")) {
			this.calculator = new TPS54341_Calculator(webenchDesign);
		
		} else if (device.equals("TPS54360") || device.equals("TPS54360-Q1") ){
			this.calculator = new TPS54360_Calculator(webenchDesign);

		} else if (device.equals("TPS54361")){
			this.calculator = new TPS54361_Calculator(webenchDesign);
			
		} else if (device.equals("TPS54361-Q1")){
			this.calculator = new TPS54361_Q1_Calculator(webenchDesign);

		} else if (device.equals("TPS54622")){
			this.calculator = new TPS54622_Calculator(webenchDesign);

		} else if (device.equals("TPS54620")){
			this.calculator = new TPS54620_Calculator(webenchDesign);

		} else if (device.equals("TPS56121") )  {
			this.calculator = new TPS56121_Calculator(webenchDesign);

		} else if (device.equals("TPS56221") )  {
			this.calculator = new TPS56221_Calculator(webenchDesign);

		} else if (device.equals("TPS61085")) {
			this.calculator = new TPS61085_Calculator(webenchDesign);

		} else if (device.equals("TPS61086")) {
			this.calculator = new TPS61086_Calculator(webenchDesign);

		}
		else if (device.equals("TPS61085-Q1")) {
			this.calculator = new TPS61085_Calculator(webenchDesign);

		}
		else if (device.equals("TPS61087")) {
			this.calculator = new TPS61087_Calculator(webenchDesign);

		}else if (device.equals("TPS61087-Q1")) {
			this.calculator = new TPS61087_Calculator(webenchDesign);

		}else if (device.equals("TPS61088")) {
			this.calculator = new TPS61088_Calculator(webenchDesign);

		}else if (device.startsWith("LM2864")) {
			this.calculator = new LM2864_Calculator(webenchDesign);

		} else if (device.startsWith("LMZ10501")) {
			this.calculator = new LMZ1050X_Calculator(webenchDesign);

		} else if (device.startsWith("LMZ10500")) {
			this.calculator = new LMZ1050X_Calculator(webenchDesign);

		} else if (device.startsWith("LM0505")) {
			this.calculator = new LM0505_Calculator(webenchDesign);

		} else if (device.equals("LM2731X") || device.equals("LM2733X")) {
			this.calculator = new LM2731X_Calculator(webenchDesign);
			
		} else if (device.equals("LMR62014X")) {
			this.calculator = new LMR62014X_Calculator(webenchDesign);
			
		} else if (device.equals("LMR64010X")) {
			this.calculator = new LMR64010X_Calculator(webenchDesign);
			
		}else if (device.startsWith("TPS720")) {
			this.calculator = new TPS720XX_Calculator(webenchDesign);
			
		} else if (device.startsWith("TPS74X01")) {
			this.calculator = new TPS74X01_Calculator(webenchDesign);
			
		} else if ((device.equals("TPS74701")) || (device.equals("TPS74801")) || (device.equals("TPS74901"))) {
			this.calculator = new TPS74X01_Calculator(webenchDesign);
			
		} else if ((device.equals("TPS74201")) || (device.equals("TPS74301")) || (device.equals("TPS74401"))){			
			this.calculator = new TPS74XXX_Calculator(webenchDesign);
			
		} else if (device.equals("LMR62421X")) {
			this.calculator = new LM2735_Calculator(webenchDesign);	

		} else if (device.equals("LM5067")) {
			this.calculator = new LM5067_Calculator(webenchDesign);	

		} else if (device.startsWith("LM5069")) {
			this.calculator = new LM5069_Calculator(webenchDesign);	
			
		} else if (device.equals("LM25069")) {
			this.calculator = new LM25069_Calculator(webenchDesign);
			
		} else if (device.equals("LM25061")) {
			this.calculator = new LM25061_Calculator(webenchDesign);
			
		} else if (device.equals("TPS2420")) {
			this.calculator = new TPS2420_Calculator(webenchDesign);
			
		} else if (device.startsWith("TPS2592")) {
			this.calculator = new TPS2592XX_Calculator(webenchDesign);
			
		} else if (device.equals("TPS2490") ||device.equals("TPS2491") ) {
			this.calculator = new TPS249X_Calculator(webenchDesign);
			
		} else if (device.equals("TPS92550")) {
			this.calculator = new TPS92550_Calculator(webenchDesign);
			
		}
		else if (device.equals("TPS92550")) {
			this.calculator = new TPS92550_Calculator(webenchDesign);
			
		}else if (device.equals("TPS92512HV")||device.equals("TPS92513HV")||device.equals("TPS92512") ) {
			this.calculator = new TPS92512HV_Calculator(webenchDesign);
			
		}else if (device.equals("TPS92513")) {
			this.calculator = new TPS92512HV_Calculator(webenchDesign);
			
		}else if (device.equals("TPS92691-Q1")) {
			this.calculator = new TPS92691_Q1_Calculator(webenchDesign);
			
		}else if (device.startsWith("LM2600")) {
			this.calculator = new LM26001_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM26420X/1")) {
			this.calculator = new LM26420X_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM26420X/2")) {
			this.calculator = new LM26420X_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM26420Y/1")) {
			this.calculator = new LM26420X_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM26420Y/2")) {
			this.calculator = new LM26420X_Calculator(webenchDesign);
		
		} else if (device.startsWith("LM26420X-Q0/1")) {
			this.calculator = new LM26420X_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM26420X-Q0/2")) {
			this.calculator = new LM26420X_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM26420X-Q1/1")) {
			this.calculator = new LM26420X_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM26420X-Q1/2")) {
			this.calculator = new LM26420X_Calculator(webenchDesign);
			
		} else if (device.startsWith("LM27313")) {
			this.calculator = new LM27313_Calculator(webenchDesign);
			
		} else if (device.startsWith("LMR70503")) {
			this.calculator = new LMR70503_Calculator(webenchDesign);
			
		} else if (device.startsWith("LMZ21700")) {
			this.calculator = new LMZ2170X_Calculator(webenchDesign);

		} else if (device.startsWith("LMZ21701")) {
			this.calculator = new LMZ2170X_Calculator(webenchDesign);

		} else if (device.startsWith("LP5907")) {
			this.calculator = new LP5907_Calculator(webenchDesign);
		
		} else if (device.startsWith("LP2951")) {
			this.calculator = new LP2951_Calculator(webenchDesign);
			
		}  else if (device.equalsIgnoreCase("LP2998")||device.equalsIgnoreCase("LP2998-Q1") ||device.startsWith("LP2996A")||device.startsWith("LP2996-N")) {
			this.calculator = new LP2998_Calculator(webenchDesign);
			
		}else if (device.equals("TPS53513")) {
			this.calculator = new TPS53513_Calculator(webenchDesign);
			
		}
		else if (device.equals("TPS54418")) {
			this.calculator = new TPS54418_Calculator(webenchDesign);
			
		}else if (device.equals("TPS53915")) {
			this.calculator = new TPS53915_Calculator(webenchDesign);
			
		}else if (device.equals("TPS549A20")) {
			this.calculator = new TPS549A20_Calculator(webenchDesign);
			
		}else if (device.equals("TPS544C20") || device.equals("TPS544B20")) {
			this.calculator = new TPS544C20_Calculator(webenchDesign);

		} else if (device.equals("TPS544B25")) {
			this.calculator = new VoutTransitionSim(new TPS544B25_Calculator(webenchDesign));
			
		} else if (device.equals("TPS544C25")) {
			this.calculator = new VoutTransitionSim(new TPS544C25_Calculator(webenchDesign));
			
		} else if (device.equals("TPS546C20A") || device.equals("TPS546C23")) {
			this.calculator = new VoutTransitionSim(new TPS546C20A_Calculator(webenchDesign));
			
		}
		else if (device.startsWith("LM501")&& (topology.equalsIgnoreCase("Flybuck"))) {
			this.calculator = new LM501xFlybuck_Calculator(webenchDesign);
		}
		
		else if (device.startsWith("LM2501")&& (topology.equalsIgnoreCase("Flybuck"))) {
			this.calculator = new LM501xFlybuck_Calculator(webenchDesign);
		}
		
		else if (device.startsWith("TLV716")) {
			this.calculator = new TLV716XXXXP_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS56428")){
			this.calculator = new TPS56428_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54020")){
			this.calculator = new TPS54020_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54540")){
			this.calculator = new TPS54540_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54541")){  	
			this.calculator = new TPS54541_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54540-Q1")){
			this.calculator = new TPS54540_Q1_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54561") || device.equals("TPS54561-Q1")){
			this.calculator = new TPS54561_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54560")){
			this.calculator = new TPS54560_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54560-Q1")){
			this.calculator = new TPS54560_Q1_Calculator(webenchDesign);
		}
		else if (device.startsWith("LP2985")){
			this.calculator = new LP2985_Calculator(webenchDesign);
		}
		else if (device.startsWith("LP2989")){
			this.calculator = new LP2989_Calculator(webenchDesign);
		}
		else if (device.equals("TPS53317")){
			this.calculator = new TPS53317_Calculator(webenchDesign);
		}
		else if (device.equals("TPS53317A")){
			this.calculator = new TPS53317A_Calculator(webenchDesign);
		}
		else if (device.equals("TPS53355")){
			this.calculator = new TPS53355_Calculator(webenchDesign);
		}
		else if (device.equals("TPS53353")){
			this.calculator = new TPS53353_Calculator(webenchDesign);
		}
		else if (device.equals("TPS55340-Q1")){
			this.calculator = new TPS55340_Q1_Calculator(webenchDesign);
		}
		else if (device.equals("TPS55330")){
			this.calculator = new TPS55330_Calculator(webenchDesign);
		}
		else if (device.equals("TPS55010")){
			this.calculator = new TPS55010_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS55340")){
			this.calculator = new TPS55340_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS53318")){
			this.calculator = new TPS53318_Calculator(webenchDesign);
		}
		else if (device.equals("TPS53315")){
			this.calculator = new TPS53315_Calculator(webenchDesign);
		}
		else if (device.equals("TPS53319")){
			this.calculator = new TPS53319_Calculator(webenchDesign);
		}
		else if (device.startsWith("LP3869")){
			this.calculator = new LP3869X_Calculator(webenchDesign);
		}
		else if (device.equals("TPS562200")){
			this.calculator = new TPS562200_Calculator(webenchDesign);
		}
		else if (device.equals("TPS562209") || device.equals("PMP9725")){
			this.calculator = new TPS562209_Calculator(webenchDesign);
		}
		else if (device.equals("TPS563200")){
			this.calculator = new TPS563200_Calculator(webenchDesign);
		}
		else if (device.equals("TPS563209")){
			this.calculator = new TPS563209_Calculator(webenchDesign);
		}
		else if (device.equals("TPS563210")){
			this.calculator = new TPS563210_Calculator(webenchDesign);
		}
		else if (device.equals("TPS563219")){
			this.calculator = new TPS563210_Calculator(webenchDesign);
		}
		else if (device.equals("TPS56520")){
			this.calculator = new TPS56520_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54240")){
			this.calculator = new TPS54240_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54240-Q1")){
			this.calculator = new TPS54240_Q1_Calculator(webenchDesign);
		}
		else if (device.equals("TPS56720")){
			this.calculator = new TPS56720_Calculator(webenchDesign);
		} 
		else if (device.equals("TPS56920")) {
			this.calculator = new TPS56920_Calculator(webenchDesign);
		}
		else if (device.equals("TPS56C20")){
			this.calculator = new TPS56C20_Calculator(webenchDesign);
		}
		else if (device.equals("TPS61170") || device.equals("TPS61170-Q1") ){
			this.calculator = new TPS61170_Calculator(webenchDesign);
		}
		else if (device.equals("TPS61175")|| device.equals("TPS61175-Q1")){
			this.calculator = new TPS61175_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS61230") || device.equals("TPS61232") ){
			this.calculator = new TPS61230_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS63050")){
			this.calculator = new TPS63050_Calculator(webenchDesign);
		}
		else if (device.equals("TPS63051")){
			this.calculator = new TPS63051_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS63024")){
			this.calculator = new TPS63024_Calculator(webenchDesign);
		}
		else if (device.equals("TPS630242")){
			this.calculator = new TPS630242_Calculator(webenchDesign);
		}
		else if (device.equals("TPS630241")){
			this.calculator = new TPS630241_Calculator(webenchDesign);
		}
		else if (device.equals("TPS62090")|| device.equals("TPS62090-Q1")){
			this.calculator = new SteppedStartupDecorator(new TPS62090_Calculator(webenchDesign));
		}
		
		else if (device.equals("TPS62095")|| device.equals("TLV62095")){
			this.calculator = new SteppedStartupDecorator(new TPS62095_Calculator(webenchDesign));
		}
		
		else if (device.equals("TPS54360")){
			this.calculator = new TPS54360_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54226")|| device.equals("TPS54228") || device.equals("TPS54227")||device.equals("TPS54229")||device.equals("TPS54229E")){
			this.calculator = new TPS54226_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54478")){
			this.calculator = new TPS54478_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54678")){
			this.calculator = new TPS54678_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54821")) {
			this.calculator = new TPS54821_Calculator(webenchDesign);
		}
		else if (device.equals("TPS548D22")) {
			this.calculator = new TPS548D22_Calculator(webenchDesign);
		}
		else if (device.equals("TPS549D22")) {
			this.calculator = new TPS549D22_Calculator(webenchDesign);
		}
		else if (device.equals("TPS548D21")) {
			this.calculator = new TPS548D21_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS62080A")){
			this.calculator = new TPS62080A_Calculator(webenchDesign);
		}
		else if (device.equals("TPS62081")){
			this.calculator = new TPS62081_Calculator(webenchDesign);
		}
		else if (device.equals("TPS62082")){
			this.calculator = new TPS62082_Calculator(webenchDesign);
		}
		else if (device.equals("TPS62125")){
			this.calculator = new TPS62125_Calculator(webenchDesign);
		}		
		else if (device.equals("TPS62085")){
			this.calculator = new TPS62085_Calculator(webenchDesign);
		}
		
		else if (device.equals("TLV62085")){
			this.calculator = new TLV62085_Calculator(webenchDesign);
		}
		
		else if (device.equals("TLV62084A")){
			this.calculator = new TLV62084A_Calculator(webenchDesign);
		}
		
		else if (device.equals("TPS7A1601") || device.equals("TPS7A1633") || device.equals("TPS7A1650")){
			this.calculator = new TPS7A16XX_Calculator(webenchDesign);
		}
		else if (device.equals("TPS7A7100") || device.equals("TPS7A7200") || device.equals("TPS7A7300"))  {
			this.calculator = new TPS7A7X00_Calculator(webenchDesign);
		}
		else if (device.equals("TPS54388-Q1"))  {
			this.calculator = new TPS54388_Q1_Calculator(webenchDesign);
		}
		else if (device.equals("UCC28700"))  {
			this.calculator = new UCC28700_Calculator(webenchDesign);
		}
		
		else if (device.equals("UCC28704"))  {
			this.calculator = new UCC28704_Calculator(webenchDesign);
		}
		else if (device.equals("UCC28710"))  {
			this.calculator = new UCC28710_Calculator(webenchDesign);
		}
		else {
			if ( this.calculator == null){
				logger.warn("Device " + device + " not supported by CalculatorFactory.  Using GenericDeviceCalculator.");
				this.calculator = new GenericDeviceCalculator(webenchDesign);	
			}
			
		}		
		logger.warn("Device " + device + " is supported by " + calculator.getClass().getName()); // why is this a warning? shouldn't it be info()? -dharik
		/*
		 * Static calculations & Initial Conditions
		 */
		
		
		if (calculator != null) {
			
			
			// Dynamical reloading of class file is now active on cronv2 stage
			String hostName = "HOST NAME NOT SET";    	
			try {
			    InetAddress addr = InetAddress.getLocalHost();	
				hostName = addr.getHostName();
			} catch (Exception e) {
				e.printStackTrace();
			}
			// if it is not a generic calculator try loading the latest class from the disk && hostname is cronv6 or local			
			if ( !calculator.getClass().getCanonicalName().contains("GenericDeviceCalculator") && 
					(hostName.contains( WBConstants.hostname_conv6) || hostName.toUpperCase().contains("TA")))
			{
				try 
				{
					BaseCalculator simCalculatorInstance = null;
					Class simulationCalculatorClass = this.calculator.getClass();                 
				     String classCanonicalName = simulationCalculatorClass.getCanonicalName();
				     // appspace/app/web/webench/build/Webench5_WS/src/com/nsc/webench/power/circuitcalculators
					 simulationCalculatorClass = getReloadedClass(classCanonicalName);	             
					 if ( simulationCalculatorClass != null){
						 // now create the instance
						 	Class [] objClass = {WebenchDesign.class};
					 		Object[] params = {webenchDesign};
					    	Constructor cons = simulationCalculatorClass.getConstructor(objClass);
					    	if (cons != null) {
					    			simCalculatorInstance = (BaseCalculator)cons.newInstance(params);	         	    		
					    	}
				     }
					 if ( simCalculatorInstance != null){
						 this.calculator = simCalculatorInstance;	 
					 }					 
				} catch (Exception e) {
					//System.out.println ("Simulation Calculator-Exception when searching for Circuit Calculator Class for Device=" +  
								//webenchDesign.getMyDesign().getDesignName());
					//e.printStackTrace();
				}
	             
			}
						
			// CalculatorFactory
			calculator.setCalculatorFactory(this);
			
			// FSW_SYNC
			if (calculator.getSwitchingFrequency() == null) {
				CircuitData circuit = CircuitAssemblyService.getAssembledElectricalSimCircuit(webenchDesign);
				Double switchingFrequency = CircuitAssemblyService.getSwitchingFrequency(circuit, this);
				calculator.setSwitchingFrequency(switchingFrequency);
			}
				
			// Basic values
			HashMap<String, TemplateStaticCalculation> templateStaticCalculationMap = this.getBasicTemplateStaticCalculationMap();
			calculator.setTemplateStaticCalculationMap(templateStaticCalculationMap);
		
			// Precalculated values
			templateStaticCalculationMap = this.getPrecalculatedTemplateStaticCalculationMap(templateStaticCalculationMap);
			calculator.setTemplateStaticCalculationMap(templateStaticCalculationMap);
					
		}		
		
	}
	
	private static  HashMap<String, Class> reloadedClassMap = new HashMap<String, Class>();
	public static synchronized void clearReloadedClassMap()
	{
		CalculatorFactory.reloadedClassMap = new HashMap<String, Class>();
		
	}
	private synchronized Class getReloadedClass(String classCanonicalName)
	{
		Class cls = reloadedClassMap.get(classCanonicalName);
		if ( cls == null){
			  try {	
				  	 System.out.println("***************** Loading class " + classCanonicalName);
					 ClassLoader parentClassLoader = this.getClass().getClassLoader();
					 DesignFactoryClassLoader designFactoryClassLoader = new DesignFactoryClassLoader(parentClassLoader);
					 designFactoryClassLoader.classCanonicalName = classCanonicalName;
					 Class reloadedCls = designFactoryClassLoader.loadClass(classCanonicalName);
					 reloadedClassMap.put(classCanonicalName, reloadedCls);
					 if ( reloadedCls != null)
						 cls = reloadedCls;	                       
					
				 } catch (Exception e) {
				     // TODO Auto-generated catch block
					 //System.out.println("***************** FAILED to load the class dynamically");
				    // e.printStackTrace();
				     cls = null;;
				 }	 
		}
		return cls;
	}
	
	public WebenchDesign getWebenchDesign() {
		return webenchDesign;
	}

	public void setWebenchDesign(WebenchDesign webenchDesign) {
		this.webenchDesign = webenchDesign;
	}
	
	/*
	 * Getters and Setters
	 */
	
	public BaseCalculator getCalculator() {
		return calculator;
	}

	public void setCalculator(BaseCalculator calculator) {
		this.calculator = calculator;
	}

	/*
	 * Custom Methods
	 */
	
	public Double getBOMComponentValue(String componentName, String attribute) {
				
		if (this.calculator == null) {
			return null;
		}
		
		return calculator.getBOMComponentValue(componentName, attribute);
	}
	
	/*
	 * Calculations
	 */
	
	public String getCalculationValue(String calculationName) {
		return this.getCalculationValue(calculationName, null);
	}
	
	public String getCalculationValue(String calculationName, ComponentData component) {
		
		String calculationValue = null;
		
		if (this.calculator == null) {
			return null;
		}
		
		HashMap<String, TemplateStaticCalculation> templateStaticCalculationMap = calculator.getTemplateStaticCalculationMap();
		
		if ((component == null) && (templateStaticCalculationMap != null)) {
		
			// Look in the static calculations
			TemplateStaticCalculation templateStaticCalculation = templateStaticCalculationMap.get(calculationName);
			if (templateStaticCalculation != null) {
			
				calculationValue = templateStaticCalculation.getCalculationValue();
			
				if (calculationValue.startsWith("@@")) {
					String[] elements = calculationValue.split("@@");
					String componentName = elements[1];
					String attribute = elements[2];
					calculationValue = this.getBOMComponentValue(componentName, attribute).toString();
					return calculationValue;
				} else if (templateStaticCalculation.getCalculated().equals("Y")) {
					calculationValue = this.getCalculationValue(calculationValue, component);
					return calculationValue;
				}
			
			}
			
		}
	
		// If not found, get calculation from data structures
//		logger.info("+getCaluclationValue(): " + calculationName );
		if ( component!= null){
//			logger.info(component.getComponentName());
		}
		Double numericValue = null;
		try{
			numericValue = calculator.getNumericCalculationValue(calculationName, component);
		}
		catch(Exception valExp)
		{
			valExp.printStackTrace();
		}
		
		if (numericValue != null) {
			calculationValue = numericValue.toString();
					
		} else {
			String textValue = calculator.getTextCalculationValue(calculationName, component);
			if (textValue != null) {
				calculationValue = textValue;
			}
		}

		// Log messages
		if (calculationValue != null) {
			// logger.info("Calculation (" + calculationName + "): " + calculationValue + " SIMTYPE: " + webenchDesign.getMyDesign().getSimType());
			DesignIntegrityTest.log( "Calculation " + calculationName + " is " + calculationValue );
		} else {
			logger.warn("Calculation (" + calculationName + "): " + calculationValue + " SIMTYPE: " + webenchDesign.getMyDesign().getSimType());
			DesignIntegrityTest.log( "Calculation " + calculationName + " is null" );
		}	
				
		return calculationValue;
		
	}

	private String getTemplateStaticCalculationValue(String calculationName) {
		
		HashMap<String, TemplateStaticCalculation> templateStaticCalculationMap = calculator.getTemplateStaticCalculationMap();
		
		TemplateStaticCalculation templateStaticCalculation = templateStaticCalculationMap.get(calculationName);
		
		if (templateStaticCalculation != null) {
			if (("Y").equals(templateStaticCalculation.getCalculated())) {
				return this.getTemplateStaticCalculationValue(templateStaticCalculation.getCalculationValue());
			} else {
				return templateStaticCalculation.getCalculationValue();
			}
		} else {
			return null;
		}
	}
	
	private HashMap<String, TemplateStaticCalculation> getBasicTemplateStaticCalculationMap() {
		
		HashMap<String, TemplateStaticCalculation> templateStaticCalculationMap = new HashMap<String, TemplateStaticCalculation>();
		
		DesignInfo myDesign = this.getWebenchDesign().getMyDesign();
		
		HashSet<String> deviceFamilySet = new HashSet<String>();
		TemplateDeviceFamily templateDeviceFamily = DataObjectService.getTemplateDeviceFamily(myDesign.getDevice());
		if (templateDeviceFamily != null) {
			deviceFamilySet.add(templateDeviceFamily.getFamily());
		}
		deviceFamilySet.add("zzz");
		
		HashSet<String> flowSet = new HashSet<String>();
		flowSet.add(myDesign.getFlow());
		flowSet.add("zzz");
		
		HashSet<String> topologySet	= new HashSet<String>();
		topologySet.add(myDesign.getTopology());
		topologySet.add("zzz");
		
		HashSet<String> deviceSet	= new HashSet<String>();
		deviceSet.add(myDesign.getDevice());
		deviceSet.add("zzz");
		
		HashSet<String> appTypeSet	= new HashSet<String>();
		appTypeSet.add(myDesign.getAppType());
		appTypeSet.add("zzz");
		
		HashSet<String> flavorSet	= new HashSet<String>();
		flavorSet.add(myDesign.getFlavor());
		flavorSet.add("zzz");
		
		HashSet<String> simTypeSet	= new HashSet<String>();  
		simTypeSet.add(myDesign.getSimType());
		simTypeSet.add("zzz");
		
		ArrayList<TemplateStaticCalculation> templateStaticCalculationList = DataObjectService.getTemplateStaticCalculationList();
		
		for (int i = 0; i < templateStaticCalculationList.size(); i++) {
			
			TemplateStaticCalculation templateStaticCalculation = templateStaticCalculationList.get(i);

			if (deviceFamilySet.contains(templateStaticCalculation.getDeviceFamily()) && flowSet.contains(templateStaticCalculation.getFlow()) && topologySet.contains(templateStaticCalculation.getTopology()) && deviceSet.contains(templateStaticCalculation.getDevice()) && appTypeSet.contains(templateStaticCalculation.getAppType()) && flavorSet.contains(templateStaticCalculation.getFlavor()) && simTypeSet.contains(templateStaticCalculation.getSimType())) {				
				String calculationName 	= templateStaticCalculation.getCalculationName();
				templateStaticCalculationMap.put(calculationName, templateStaticCalculation);
			}
		}
		
		return templateStaticCalculationMap;
		
	}
	
	private HashMap<String, TemplateStaticCalculation> getPrecalculatedTemplateStaticCalculationMap(HashMap<String, TemplateStaticCalculation> templateStaticCalculationMap) {
	
		Iterator it = templateStaticCalculationMap.values().iterator();
		
		while (it.hasNext()) {
			
			// Retrieve static calculation object
			TemplateStaticCalculation templateStaticCalculation = (TemplateStaticCalculation) it.next();
			
			if (templateStaticCalculation.getCalculated().equals("Y")) {
				
				// Retrieve calculationName
				String calculationName = templateStaticCalculation.getCalculationValue();
				
				// Try to retrieve value from static calculations
				String calculationValue = this.getTemplateStaticCalculationValue(templateStaticCalculation.getCalculationValue());
				
				if (calculationValue != null) {
					
					// If found, update template calculation object
					templateStaticCalculation.setCalculationValue(calculationValue);
					templateStaticCalculation.setCalculated("N");
					
				} else {
					
					// If not found, try to find value from calculation object
					Double numericValue = calculator.getNumericCalculationValue(calculationName);
					
					if (numericValue != null) {
						calculationValue = numericValue.toString();
								
					} else {
						String textValue = calculator.getTextCalculationValue(calculationName);
						if (textValue != null) {
							calculationValue = textValue;
						}
					}
					
					// If found, update template calculation object
					if (calculationValue != null) {
						templateStaticCalculation.setCalculationValue(calculationValue);
						templateStaticCalculation.setCalculated("N");
					}
					
				}
				
			}
			
			templateStaticCalculationMap.put(templateStaticCalculation.getCalculationName(), templateStaticCalculation);
			
		}
		
		return templateStaticCalculationMap;
		
	}
	
}