/// <summary> /// In text setup files the IO Variables in a table need to be generated, as they don't exist independently in the /// file. In a JSON file they do exist independently, so this function is unnecessary. /// </summary> public void fixupTable(sinter_SetupFile setupFile) { //First make sure the variable array is the right size int nn = rowStringCount; int mm = colStringCount; o_value = new sinter_Variable[nn, mm]; for (int addressIndex = 0; addressIndex <= (addressStrings.Length - 1); addressIndex++) { for (int i = 0; i <= rowStringCount - 1; i++) { for (int j = 0; j <= colStringCount - 1; j++) { string aString = addressStrings[addressIndex].Replace("%r", getRowString(i)); aString = aString.Replace("%c", getColString(j)); //Now create and init vars sinter_Variable thisVar = new sinter_Variable(); //We don't have a real name, so just use table[i,j] String thisName = String.Format("{0}[{1},{2}]", o_name, i, j); String desc = String.Format("{0}[{1},{2}] (Table Description : {3} )", name, getRowLabel(i), getColLabel(j), description); String[] aStrings = new String[1] { aString }; thisVar.init(thisName, mode, sinter_Variable.sinter_IOType.si_DOUBLE, desc, aStrings); thisVar.tableRow = i; thisVar.tableCol = j; thisVar.tableName = name; thisVar.table = this; setVariable(i, j, thisVar); setupFile.addVariable(thisVar); } } } }
/** * createSinter parses part of the setup file passed in (as a string) to discover the * extension of the simulation file provided. * From that extension it creates the correct class for running that type of simulation. **/ public static ISimulation createSinter(string setupFileString) { sinter_SetupFile thisSetupFile = sinter_SetupFile.determineFileTypeAndParse(setupFileString); string extension = System.IO.Path.GetExtension(thisSetupFile.aspenFilename); sinter_Sim thisAspen = null; if (extension == ".bkp" || extension == ".apw") { thisAspen = new sinter_SimAspen(); thisAspen.setupFile = thisSetupFile; } else if (extension == ".acmf") { thisAspen = new sinter_SimACM(); thisAspen.setupFile = thisSetupFile; } else if (extension == ".xlsm" || extension == ".xls" || extension == ".xlsx") { thisAspen = new sinter_SimExcel(); thisAspen.setupFile = thisSetupFile; } else if (extension != null && extension.ToLower() == ".gencrypt") { thisAspen = new sinter.PSE.sinter_simGPROMS(); thisAspen.setupFile = thisSetupFile; } else if (extension != null && extension.ToLower() == ".gPJ") { throw new System.IO.IOException(String.Format( "gPJ is not an allowed extension for sinter simulation run. SimSinter requires a .gENCRYPT file. filename: {1}.", setupFileString)); } else { throw new System.IO.IOException(String.Format( "Unknown Aspen File extension {0} on filename: {1}. Expecting either .bkp or .apw for Aspen+, .acmf for ACM, .xlsm .xls .xlsx for Excel, or .gencrypt for GPROMS", extension, setupFileString)); } if (thisAspen == null) { throw new System.IO.IOException("Failed to create sinter object, reason unknown."); } if (thisAspen is sinter_InteractiveSim) { sinter_InteractiveSim sSim = (sinter_InteractiveSim)thisAspen; sSim.makeIOTree(); } return(thisAspen); }