Esempio n. 1
0
        //---------------------------------------
        // Comunication with Simulation Program
        //---------------------------------------

        //<Summary>
        //send value to simulation
        //</Summary>
        public override void sendToSim(sinter_InteractiveSim o_sim)
        {
            if ((mode != sinter_IOMode.si_OUT) && (!isSetting))
            {
                //This allows one to pass in simulation settings as a sinter varaible if it has a path of the form: setting(blah) = value
                //So, setting( is a "reserved word" in sinter variable pathes (Maybe a special character would be better?
                for (int addressIndex = 0; addressIndex <= (addressStrings.Length - 1); addressIndex++)
                {
                    if (type == sinter_IOType.si_DOUBLE_VEC)
                    {
                        double[] t_value = unitsConversion(units, defaultUnits, (double[])o_value);  //Do units conversion if required
                        o_sim.sendVectorToSim <double>(addressStrings[addressIndex], (double[])t_value);
                    }
                    else if (type == sinter_IOType.si_DY_INTEGER_VEC)
                    {
                        o_sim.sendVectorToSim <int>(addressStrings[addressIndex], (int[])o_value);
                    }
                    else if (type == sinter_IOType.si_DY_STRING_VEC)
                    {
                        o_sim.sendVectorToSim <string>(addressStrings[addressIndex], (string[])o_value);
                    }
                    else
                    {
                        throw new NotImplementedException(string.Format("Unknown type {0} passed to sinter_Vector.sendToSim", type));
                    }
                }
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        //---------------------------------------
        // Comunication with Simulation Program
        //---------------------------------------

        //<Summary>
        //send value to simulation
        //</Summary>
        public void sendToSim(sinter_InteractiveSim o_sim)
        {
            if (mode != sinter_Variable.sinter_IOMode.si_OUT)
            {
                //This allows one to pass in simulation settings as a sinter varaible if it has a path of the form: setting(blah) = value
                //So, setting( is a "reserved word" in sinter variable pathes (Maybe a special character would be better?
                for (int ii = 0; ii <= rowStringCount - 1; ii++)
                {
                    for (int jj = 0; jj <= colStringCount - 1; jj++)
                    {
                        o_value[ii, jj].sendToSim(o_sim);
                    }
                }
            }
        }
Esempio n. 4
0
 //<Summary>
 //send value to simulation
 //</Summary>
 public virtual void sendToSim(sinter_InteractiveSim o_sim)
 {
     if ((mode != sinter_IOMode.si_OUT) && (!isSetting))
     {
         object t_value = o_value;
         if (o_type == sinter_IOType.si_DOUBLE)  //Really, only doubles support type conversion
         {
             t_value = unitsConversion(units, defaultUnits, Convert.ToDouble(o_value));
         }
         //Now that we have the correct converted value, pass it into each address inside the simulation
         for (int addressIndex = 0; addressIndex <= (addressStrings.Length - 1); addressIndex++)
         {
             o_sim.sendValueToSim(addressStrings[addressIndex], t_value);
         }
     }
 }
        //---------------------------------------
        // Comunication with Simulation Program
        //---------------------------------------

        //<Summary>
        //send value to simulation
        //</Summary>
        public override void sendToSim(sinter_InteractiveSim o_sim)
        {
            if ((mode != sinter_IOMode.si_OUT) && (!isSetting))
            {
                if (o_type == sinter_IOType.si_DY_DOUBLE)  //Really, only doubles support type conversion
                {
                    double t_value = ((double[])o_TimeSeriesValues)[o_TimeSeriesIndex];
                    t_value = unitsConversion(units, defaultUnits, t_value);

                    //Now that we have the correct converted value, pass it into each address inside the simulation
                    for (int addressIndex = 0; addressIndex <= (addressStrings.Length - 1); addressIndex++)
                    {
                        o_sim.sendValueToSim(addressStrings[addressIndex], t_value);
                    }
                }
                else if (o_type == sinter_IOType.si_DY_INTEGER)
                {
                    int t_value = ((int[])o_TimeSeriesValues)[o_TimeSeriesIndex];

                    //Now that we have the correct converted value, pass it into each address inside the simulation
                    for (int addressIndex = 0; addressIndex <= (addressStrings.Length - 1); addressIndex++)
                    {
                        o_sim.sendValueToSim(addressStrings[addressIndex], t_value);
                    }
                }
                else if (o_type == sinter_IOType.si_DY_STRING)
                {
                    string t_value = ((string[])o_TimeSeriesValues)[o_TimeSeriesIndex];

                    //Now that we have the correct converted value, pass it into each address inside the simulation
                    for (int addressIndex = 0; addressIndex <= (addressStrings.Length - 1); addressIndex++)
                    {
                        o_sim.sendValueToSim(addressStrings[addressIndex], t_value);
                    }
                }
                else
                {
                    throw new ArgumentException(string.Format("Invalid sinter_IOType passed to sinter_DynamicScalar.sendToSim", o_type));
                }
            }
        }
 /**
  * This version of init attempts to discover as much as possible about the variable automatically.
  * This is useful for the GUI, when the user selects a variable off the tree we need to try to figure out all about it.
  **/
 public virtual void init(sinter_InteractiveSim sim, sinter.sinter_Variable.sinter_IOType type, int TimeSeriesLen, string[] addStrings)
 {
     o_TimeSeriesLength = TimeSeriesLen;
     base.init(sim, type, addStrings);
 }