Ejemplo n.º 1
0
        /**
         * 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);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///  InitializeSinter: MUST be called before openSim (working dir and setupFile must be done).
        ///
        /// </summary>
        /// <param name="job"></param>
        /// <param name="workingDir"></param>
        /// <param name="config"></param>
        protected override void InitializeSinter(IJobConsumerContract job, string workingDir, string config)
        {
            applicationName = job.ApplicationName;
            if (job.ApplicationName == "ACM")
            {
                sim           = new sinter_SimACM();
                sim.setupFile = new sinter_JsonSetupFile();
            }
            else if (job.ApplicationName == "AspenPlus")
            {
                sim           = new sinter_SimAspen();
                sim.setupFile = new sinter_JsonSetupFile();
            }

            sim.workingDir = workingDir;
            sim.setupFile.parseFile(config);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///  InitializeSinter: MUST be called before openSim (working dir and setupFile must be done).
        ///
        /// </summary>
        /// <param name="job"></param>
        /// <param name="workingDir"></param>
        /// <param name="config"></param>
        protected override void InitializeSinter(IJobConsumerContract job, string workingDir, string config)
        {
            applicationName = job.ApplicationName;
            if (job.ApplicationName == "ACM")
            {
                sim           = new sinter_SimACM();
                sim.setupFile = new sinter_JsonSetupFile();
            }
            else if (job.ApplicationName == "AspenPlus")
            {
                sim           = new sinter_SimAspen();
                sim.setupFile = new sinter_JsonSetupFile();
            }
            else
            {
                throw new Exception(String.Format("Unsupported Application Type: {0}", job.ApplicationName));
            }

            sim.workingDir = workingDir;
            sim.setupFile.parseFile(config);
        }