@SuppressWarnings("unused")
public Sampleform engineCore(Project project,ArrayList<SampleBean> figList,HashMap<String, SimulationFields[]> simulationArr) throws Exception {
long start = System.currentTimeMillis();
SampleBean samplebean = new SampleBean();
Sampleform sampleform = new Sampleform();
EconomicAnalysis _EconomicAnalysis = new EconomicAnalysis();
Modeling modeling = new Modeling();
sampleform.setLifeTime(project.getProLifeTime());
sampleform.setIteration(project.getProIterNum());
sampleform.setTd((float)project.getProTd());
sampleform.setLifeTime(project.getProLifeTime());
float[][] resultArr = null;
float[] totavaArr = null;
ArrayList<int[][]> breakList = new ArrayList<int[][]>();
float[] iterationArr = new float [sampleform.getIteration()];
String[][] stepAve = new String [2][figList.size()];
String[] stepFigName = new String [figList.size()];
sampleform.setIterationArr(new float [sampleform.getIteration()]);
sampleform.setYeartotRoof((int)sampleform.getTd()*24);
sampleform.setTotRoof((int)(sampleform.getYeartotRoof())*sampleform.getLifeTime());
boolean saTest = false;
saList = new ArrayList<SampleBean>();
sampleform.setFailState("flaring");
for (int k=0;k<sampleform.getIteration();k++) {
sumF = 0;
int[][] brakeArr = new int[3][figList.size()];
for (int i=0;i<brakeArr[0].length;i++) {
brakeArr[1][i] = figList.get(i).getFigUid();
}
resultArr = new float[figList.size()+1][(int)sampleform.getTotRoof()];
totavaArr = new float[sampleform.getLifeTime()];
sampleform.setYearAvailability(0f);
sampleform.setRepearState(true);
for (int i=0;i<figList.size();i++) {
saControl = 1;
sampleform.setStep(0f);
sampleform.setPresent(0f);
sampleform.setMaxMttf(figList.get(i).getFigMaxMttf()*8760f);
sampleform.setMinMttf(figList.get(i).getFigMinMttf()*8760f);
sampleform.setMostMttf(figList.get(i).getFigMostMttf()*8760f);
for (int s=0;s<sampleform.getTotRoof();s++){
//System.out.println(sampleform.getPresent());
if (sampleform.getPresent() <= s) {
this.computeHazardRate(sampleform,figList.get(i));
//System.out.println(sampleform.isGeneralState());
if (sampleform.isGeneralState()) { //정상
sampleform.setRepearState(true);
sampleform.setPresent(sampleform.getPresent()+24);
} else {//고장
brakeArr[0][i] = brakeArr[0][i] + 1;
if (figList.get(i).getFigMoType().equals("se")) {
//System.out.println(figList.get(i).getFigMoName());
sampleform.setRepearState(false);
//System.out.println("b:"+sampleform.getPresent());
sampleform.setPresent(sampleform.getPresent()+figList.get(i).getFigMttr());
//System.out.println("a:"+sampleform.getPresent());
} else if (sampleform.getFailState() == "flaring" && figList.get(i).getFigFlaring().floatValue() > 1) {
sampleform.setRepearState(true);
sampleform.setPresent(s+figList.get(i).getFigFlaring().floatValue());
sampleform.setFailState("mttr");
} else if (sampleform.getFailState() == "mttr" && figList.get(i).getFigFlaring().floatValue() > 1) {
sampleform.setRepearState(false);
sampleform.setImpRepair(figList.get(i).getFigMttr());
sampleform.setImpFailure(figList.get(i).getFigDelivery().floatValue());
sampleform.setPresent(sampleform.getPresent()+sampleform.getImpFailure()+sampleform.getImpRepair());
sampleform.setImpRepair(s+sampleform.getImpRepair());
sampleform.setFailState("flaring");
} else {
if (Integer.parseInt(figList.get(i).getFigFailureState()) == 1) { // 직렬일경우
sampleform.setRepearState(false);
sampleform.setImpRepair(figList.get(i).getFigMttr());
sampleform.setImpFailure(figList.get(i).getFigDelivery().floatValue());
sampleform.setPresent(sampleform.getPresent()+sampleform.getImpFailure()+sampleform.getImpRepair());
sampleform.setImpRepair(s+sampleform.getImpRepair());
} else if (Integer.parseInt(figList.get(i).getFigFailureState())> 1){ // 병렬일 경우
sampleform.setRepearState(true);
}
}
sampleform.setBreakpoint(sampleform.getPresent()); // 고장에서 정상으로 돌아올시점 기록
sumF = 0;
}
}
///////////////////////////////////////////////
if (sampleform.isRepearState()) {
sampleform.setAvailability(100f);
} else {
if (sampleform.getImpRepair()>s) { //delivery
sampleform.setAvailability(100f - (figList.get(i).getFigImpFailure().floatValue()*100f));
} else { //mttr
sampleform.setAvailability(100f - (figList.get(i).getFigImpRepair().floatValue()*100f));
}
}
resultArr[i][s] = sampleform.getAvailability();
sampleform.setStep(sampleform.getAvailability()+sampleform.getStep());
//log.debug(sampleform.getAvailability());
}
//stepFigName[i] = figList.get(i).getFigMoName();
stepAve[0][i] = figList.get(i).getFigMoName();
float val = (1-((sampleform.getTotRoof()-sampleform.getStep())/sampleform.getTotRoof()));
if (k == 0) {
stepAve[1][i] = Float.toString(val);
} else if(k == sampleform.getIteration()-1) {
stepAve[1][i] = Float.toString((val+Float.valueOf(stepAve[1][i]).floatValue())/sampleform.getIteration());
} else {
stepAve[1][i] = Float.toString(val+Float.valueOf(stepAve[1][i]).floatValue());
}
sampleform.setBreakpoint(0);
}
breakList.add(brakeArr);//장비별 고장횟수
//현재 다중 부품이 들어갈경우 하나라도 망가지면 시스템이 정지한다는 가정하에 가용성 계산(직렬)
for (int s=0;s<sampleform.getTotRoof();s++) {
for (int i=0;i<figList.size();i++) {
if (sampleform.getAvailability() > resultArr[i][s] || i == 0) {
sampleform.setAvailability(resultArr[i][s]);
}
}
resultArr[figList.size()][s] = sampleform.getAvailability();
sampleform.setYearAvailability(sampleform.getYearAvailability() + sampleform.getAvailability());
if (((s+1)%sampleform.getYeartotRoof()) == 0) {
int arrNum = (int) ((s+1)/sampleform.getYeartotRoof())-1;
sampleform.setYearAvailability(sampleform.getYearAvailability()/100f);
totavaArr[arrNum] = sampleform.getYearAvailability();
sampleform.setYearAvailability(0f);;
}
sampleform.setAvailability(0f);
}
//전체 가용율 계산
for (int i=0;i<totavaArr.length;i++) {
sampleform.setAvailability(sampleform.getAvailability() + totavaArr[i]);
}
float stdAva = (1-((sampleform.getTotRoof()-sampleform.getAvailability())/sampleform.getTotRoof()));
iterationArr[k] = stdAva;
sampleform.setAvailabilityAll(sampleform.getAvailabilityAll() + stdAva);
}
//sampleform.setStepFigName(stepFigName);
//장비별 망가진 횟수
/*for (int i=0;i<breakList.size();i++) {
//_EconomicAnalysis.
System.out.println(breakList.size());
for (int s=0;s<breakList.get(i)[0].length;s++) {
System.out.println(breakList.get(i)[0][s]);
}
}*/
sampleform.setStepAve(stepAve);
sampleform.setStepFigName(stepFigName);
sampleform.setBrakeArr(breakList);
sampleform.setResultArr(resultArr);//시간당 수치 or 마지막번지에는 eq 가용율
sampleform.setIterationArr(iterationArr);//iteration roof 당 가용율
sampleform.setYeartotRoof(sampleform.getYeartotRoof());//1년기준 총 루프 횟수
sampleform.setTotRoof((int)sampleform.getTotRoof());//Iteration 기준 총 루프 횟수
sampleform.setTotAvailability((sampleform.getAvailabilityAll()/sampleform.getIteration())*100);//총 총가용율
sampleform.setFmcont(figList.size()+1);
long end = System.currentTimeMillis();
log.debug( " testNum : " + testNum + "" );
log.debug( "실행 시간 : " + ( end - start )/1000.0 + "초" );
log.debug(sampleform.getTotRoof());
log.debug("총 총가용율:"+sampleform.getTotAvailability()+"%");
//request.setAttribute("resultparamater", sampleform.getTotavaArr());
//log.debug();
//log.debug();
return sampleform;