sglmodel.java
来自「an example to create form base. it inclu」· Java 代码 · 共 484 行
JAVA
484 行
package com.freescale.RAppID.controller.model.sgl;
/**
* Copyright Freescale Semiconductor Inc 2006 All Rights Reserved
*/
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.freescale.RAppID.common.IConstants;
import com.freescale.RAppID.controller.devicemgmt.ISoftwareAttributeConstants;
import com.freescale.RAppID.controller.devicemgmt.SGLController;
import com.freescale.RAppID.controller.model.common.FileSoftwareAttribute;
import com.freescale.RAppID.controller.model.common.FunctionSoftwareAttribute;
import com.freescale.RAppID.controller.model.sectionmap.SectionBean;
import com.freescale.RAppID.controller.projectmgmt.ProjectManager;
import com.freescale.RAppID.util.CommonUtility;
import com.freescale.RAppID.util.RappidLogger;
@XmlRootElement(name = "SGLModel")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder =
{
"pragmaSectionMap", "swAttributes", "sGL_HIGH_PER", "sGL_LOW_PER", "sGL_MODE_SEL", "sGL_SOUND_DUR", "enable_hex"
})
public class SGLModel implements Serializable, Cloneable
{
transient RappidLogger logger = RappidLogger.getLogger(this);
@XmlTransient
private boolean dirty;
@XmlElementWrapper(name = "swAttributes")
private HashMap<String, FileSoftwareAttribute> swAttributes;
/* this Map is used for Pragma support. */
@XmlElementWrapper(name = "pragmaSectionMap")
private HashMap<String, SectionBean> pragmaSectionMap;
private SGL_HIGH_PER sGL_HIGH_PER;
private SGL_LOW_PER sGL_LOW_PER;
private SGL_MODE_SEL sGL_MODE_SEL;
private SGL_SOUND_DUR sGL_SOUND_DUR;
private boolean enable_hex=false;
public boolean isDirty()
{
return dirty;
}
public void setDirty(boolean dirty)
{
this.dirty = dirty;
}
public SGL_HIGH_PER getSGL_HIGH_PER()
{
return sGL_HIGH_PER;
}
public void setSGL_HIGH_PER(SGL_HIGH_PER sgl_high_per)
{
sGL_HIGH_PER = sgl_high_per;
}
public SGL_LOW_PER getSGL_LOW_PER()
{
return sGL_LOW_PER;
}
public void setSGL_LOW_PER(SGL_LOW_PER sgl_low_per)
{
sGL_LOW_PER = sgl_low_per;
}
public SGL_MODE_SEL getSGL_MODE_SEL()
{
return sGL_MODE_SEL;
}
public void setSGL_MODE_SEL(SGL_MODE_SEL sgl_mode_sel)
{
sGL_MODE_SEL = sgl_mode_sel;
}
public SGL_SOUND_DUR getSGL_SOUND_DUR()
{
return sGL_SOUND_DUR;
}
public void setSGL_SOUND_DUR(SGL_SOUND_DUR sgl_sound_dur)
{
sGL_SOUND_DUR = sgl_sound_dur;
}
public HashMap<String, SectionBean> getPragmaSectionMap()
{
return pragmaSectionMap;
}
public void setPragmaSectionMap(HashMap<String, SectionBean> pragmaSectionMap)
{
this.pragmaSectionMap = pragmaSectionMap;
}
public HashMap<String, FileSoftwareAttribute> getSwAttributes()
{
if(swAttributes == null)
{
swAttributes = new HashMap<String, FileSoftwareAttribute>();
}
return swAttributes;
}
public void setSwAttributes(
HashMap<String, FileSoftwareAttribute> swAttributes)
{
this.swAttributes = swAttributes;
}
public Object clone()
{
SGLModel clone = null;
try
{
clone = (SGLModel) super.clone();
clone.dirty = this.dirty;
clone.swAttributes = new HashMap<String, FileSoftwareAttribute>();
Iterator itrAttributes = this.swAttributes.keySet().iterator();
while (itrAttributes.hasNext())
{
String key = itrAttributes.next().toString();
FileSoftwareAttribute objAttribute = (FileSoftwareAttribute) this.swAttributes
.get(key);
clone.swAttributes.put(key, (FileSoftwareAttribute) objAttribute
.clone());
}
clone.pragmaSectionMap = new HashMap<String, SectionBean>();
Iterator itrpragma = this.pragmaSectionMap.keySet().iterator();
while (itrpragma.hasNext())
{
String key = itrpragma.next().toString();
if(pragmaSectionMap.get(key) instanceof SectionBean)
{
SectionBean sectionBean = (SectionBean) ( (SectionBean) ( this.pragmaSectionMap
.get(key) ) ).clone();
clone.pragmaSectionMap.put(key, sectionBean);
}
}
clone.sGL_HIGH_PER = (SGL_HIGH_PER) this.sGL_HIGH_PER.clone();
clone.sGL_LOW_PER = (SGL_LOW_PER) this.sGL_LOW_PER.clone();
clone.sGL_MODE_SEL = (SGL_MODE_SEL) this.sGL_MODE_SEL.clone();
clone.sGL_SOUND_DUR = (SGL_SOUND_DUR) this.sGL_SOUND_DUR.clone();
clone.enable_hex=this.enable_hex;
}
catch (CloneNotSupportedException e)
{
logger.ERROR(e);
}
return clone;
}
public double getSoundDurationCalulationVal()
{
double busClockSpeedVal = ProjectManager.getInstance()
.getsystemclkTimersModel().getSystemClock()
.getFinalClockFrequencyForSet3();
double prescalerVal = this.getSGL_MODE_SEL().getPrescaler();
double result = 1 / ( busClockSpeedVal / ( prescalerVal + 1 ) );
double soundDuration = this.getSGL_SOUND_DUR().getSoundDuration();
double finalResult = result * soundDuration * 1000;
return finalResult;
}
public double getHighPeriodCalulationVal()
{
double busClockSpeedVal = ProjectManager.getInstance()
.getsystemclkTimersModel().getSystemClock()
.getFinalClockFrequencyForSet3();
double prescalerVal = this.getSGL_MODE_SEL().getPrescaler();
double result = 1 / ( busClockSpeedVal / ( prescalerVal + 1 ) );
double highPeriod = this.getSGL_HIGH_PER().getHighPeriod();
double finalResult = result * highPeriod * 1000;
return finalResult;
}
public double getLowPeriodCalulationVal()
{
double busClockSpeedVal = ProjectManager.getInstance()
.getsystemclkTimersModel().getSystemClock()
.getFinalClockFrequencyForSet3();
double prescalerVal = this.getSGL_MODE_SEL().getPrescaler();
double result = 1 / ( busClockSpeedVal / ( prescalerVal + 1 ) );
double lowPeriod = this.getSGL_LOW_PER().getLowPeriod();
double finalResult = result * lowPeriod * 1000;
return finalResult;
}
public boolean isEnable_hex()
{
return enable_hex;
}
public void setEnable_hex(boolean enable_hex)
{
this.enable_hex = enable_hex;
}
public void setSrcFileName(String srcFileName)
{
HashMap<String, FileSoftwareAttribute> swAttrFuncMap = getSwAttributes();
FileSoftwareAttribute fsa_src = swAttrFuncMap
.get(Integer
.toString(ISoftwareAttributeConstants.SGL_INITIALIZATION_SOURCE_FILE));
if(fsa_src != null)
{
fsa_src.setValue(srcFileName);
}
}
/**
* This method returns the source file name of the module
*
* @return
*/
public String getSrcFileName()
{
String srcFileName = "";
HashMap<String, FileSoftwareAttribute> swAttrFuncMap = getSwAttributes();
FileSoftwareAttribute fsa_src = swAttrFuncMap
.get(Integer
.toString(ISoftwareAttributeConstants.SGL_INITIALIZATION_SOURCE_FILE));
if(fsa_src != null)
{
srcFileName = fsa_src.getValue();
}
return srcFileName;
}
public void setHdrFileName(String srcFileName)
{
HashMap<String, FileSoftwareAttribute> swAttrFuncMap = getSwAttributes();
FileSoftwareAttribute fsa_src = (FileSoftwareAttribute) swAttrFuncMap
.get(Integer
.toString(ISoftwareAttributeConstants.SGL_INITIALIZATION_HEADER_FILE));
if(fsa_src != null)
{
fsa_src.setValue(srcFileName);
}
}
/**
* This method returns the source file name of the module
*
* @return
*/
public String getHdrFileName()
{
String srcFileName = "";
HashMap<String, FileSoftwareAttribute> swAttrFuncMap = getSwAttributes();
FileSoftwareAttribute fsa_src = swAttrFuncMap
.get(Integer
.toString(ISoftwareAttributeConstants.SGL_INITIALIZATION_HEADER_FILE));
if(fsa_src != null)
{
srcFileName = fsa_src.getValue();
}
return srcFileName;
}
public void setInitFncName(String srcFileName)
{
HashMap<String, FileSoftwareAttribute> swAttrFuncMap = getSwAttributes();
FileSoftwareAttribute fsa_src = swAttrFuncMap
.get(Integer
.toString(ISoftwareAttributeConstants.SGL_INITIALIZATION_SOURCE_FILE));
FunctionSoftwareAttribute initFunctio = fsa_src.getFunctionMap().get(Integer
.toString(ISoftwareAttributeConstants.SGL_INITIALIZATION_FUNCTION));
if(initFunctio != null)
{
initFunctio.setValue(srcFileName);
}
}
public void setSoundTypeFncName(String srcFileName)
{
HashMap<String, FileSoftwareAttribute> swAttrFuncMap = getSwAttributes();
FileSoftwareAttribute fsa_src = swAttrFuncMap
.get(Integer
.toString(ISoftwareAttributeConstants.SGL_INITIALIZATION_SOURCE_FILE));
FunctionSoftwareAttribute initFunctio = fsa_src.getFunctionMap().get(Integer
.toString(ISoftwareAttributeConstants.SGL_SET_SOUND_TYPE_FUNCTION));
if(initFunctio != null)
{
initFunctio.setValue(srcFileName);
}
}
public void setSoundDurationFncName(String srcFileName)
{
HashMap<String, FileSoftwareAttribute> swAttrFuncMap = getSwAttributes();
FileSoftwareAttribute fsa_src = swAttrFuncMap
.get(Integer
.toString(ISoftwareAttributeConstants.SGL_INITIALIZATION_SOURCE_FILE));
FunctionSoftwareAttribute initFunctio = fsa_src.getFunctionMap().get(Integer
.toString(ISoftwareAttributeConstants.SGL_SET_SOUND_DURATION_FUNCTION));
if(initFunctio != null)
{
initFunctio.setValue(srcFileName);
}
}
public void setSGLModeFncName(String srcFileName)
{
HashMap<String, FileSoftwareAttribute> swAttrFuncMap = getSwAttributes();
FileSoftwareAttribute fsa_src = swAttrFuncMap
.get(Integer
.toString(ISoftwareAttributeConstants.SGL_INITIALIZATION_SOURCE_FILE));
FunctionSoftwareAttribute initFunctio = fsa_src.getFunctionMap().get(Integer
.toString(ISoftwareAttributeConstants.SGL_SET_MODE_FUNCTION));
if(initFunctio != null)
{
initFunctio.setValue(srcFileName);
}
}
/**
* This method returns the source file name of the module
*
* @return
*/
public String getInitFncName()
{
String srcFileName = "";
HashMap<String, FileSoftwareAttribute> swAttrFuncMap = getSwAttributes();
FileSoftwareAttribute fsa_src = swAttrFuncMap
.get(Integer
.toString(ISoftwareAttributeConstants.SGL_INITIALIZATION_SOURCE_FILE));
FunctionSoftwareAttribute initFunctio = fsa_src.getFunctionMap().get(Integer
.toString(ISoftwareAttributeConstants.SGL_INITIALIZATION_FUNCTION));
if(initFunctio != null)
{
srcFileName = initFunctio.getValue();
}
return srcFileName;
}
public String getSGLModeFncName()
{
String srcFileName = "";
HashMap<String, FileSoftwareAttribute> swAttrFuncMap = getSwAttributes();
FileSoftwareAttribute fsa_src = swAttrFuncMap
.get(Integer
.toString(ISoftwareAttributeConstants.SGL_INITIALIZATION_SOURCE_FILE));
FunctionSoftwareAttribute initFunctio = fsa_src.getFunctionMap().get(Integer
.toString(ISoftwareAttributeConstants.SGL_SET_MODE_FUNCTION));
if(initFunctio != null)
{
srcFileName = initFunctio.getValue();
}
return srcFileName;
}
public String getSoundTypeFncName()
{
String srcFileName = "";
HashMap<String, FileSoftwareAttribute> swAttrFuncMap = getSwAttributes();
FileSoftwareAttribute fsa_src = swAttrFuncMap
.get(Integer
.toString(ISoftwareAttributeConstants.SGL_INITIALIZATION_SOURCE_FILE));
FunctionSoftwareAttribute initFunctio = fsa_src.getFunctionMap().get(Integer
.toString(ISoftwareAttributeConstants.SGL_SET_SOUND_TYPE_FUNCTION));
if(initFunctio != null)
{
srcFileName = initFunctio.getValue();
}
return srcFileName;
}
public String getSoundDurationFncName()
{
String srcFileName = "";
HashMap<String, FileSoftwareAttribute> swAttrFuncMap = getSwAttributes();
FileSoftwareAttribute fsa_src = swAttrFuncMap
.get(Integer
.toString(ISoftwareAttributeConstants.SGL_INITIALIZATION_SOURCE_FILE));
FunctionSoftwareAttribute initFunctio = fsa_src.getFunctionMap().get(Integer
.toString(ISoftwareAttributeConstants.SGL_SET_SOUND_DURATION_FUNCTION));
if(initFunctio != null)
{
srcFileName = initFunctio.getValue();
}
return srcFileName;
}
public void setFuncName(int funcType, String funcName)
{
Map<String, FunctionSoftwareAttribute> funcMap = getFuncAttributeMap();
if (funcMap != null)
{
FunctionSoftwareAttribute funcSA = funcMap
.get(Integer.toString(funcType));
if (funcSA == null)
{
funcSA = new FunctionSoftwareAttribute(funcType, funcName);
funcSA.setEnabledForCodeGeneration(true);
}
else
{
funcSA.setValue(funcName);
}
funcMap.put(Integer.toString(funcType), funcSA);
}
}
public String getFuncName(int funcType)
{
String funcName = null;
Map funcMap = getFuncAttributeMap();
if(funcMap != null)
{
FunctionSoftwareAttribute funcSA = (FunctionSoftwareAttribute) funcMap
.get(Integer.toString(funcType));
if(funcSA != null)
{
funcName = funcSA.getValue();
}
}
return funcName;
}
public Map<String, FunctionSoftwareAttribute> getFuncAttributeMap()
{
HashMap<String, FileSoftwareAttribute> swAttrFuncMap = getSwAttributes();
FileSoftwareAttribute fsa_src = (FileSoftwareAttribute)swAttrFuncMap
.get(Integer
.toString(ISoftwareAttributeConstants.SGL_INITIALIZATION_SOURCE_FILE));
return fsa_src.getFunctionMap();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?