Пример #1
0
        /// <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);
                    }
                }
            }
        }
Пример #2
0
        public static sinter_Variable makeNewVariable(sinter_Sim sim, string path)
        {
            sinter_Variable retVar = null;

            sinter.sinter_Variable.sinter_IOType vartype = sim.guessTypeFromSim(path);
            if (vartype == sinter.sinter_Variable.sinter_IOType.si_DOUBLE ||
                vartype == sinter.sinter_Variable.sinter_IOType.si_INTEGER ||
                vartype == sinter.sinter_Variable.sinter_IOType.si_STRING)
            {
                sinter_Variable previewVar    = new sinter_Variable();
                string[]        addressString = new string[1] {
                    path
                };
                previewVar.init(sim, vartype, addressString);
                previewVar.initializeUnits(sim);
                previewVar.initializeDescription(sim);
                retVar = previewVar;
            }
            else if (vartype == sinter.sinter_Variable.sinter_IOType.si_DOUBLE_VEC ||
                     vartype == sinter.sinter_Variable.sinter_IOType.si_INTEGER_VEC ||
                     vartype == sinter.sinter_Variable.sinter_IOType.si_STRING_VEC)
            {
                sinter_Vector previewVar    = new sinter_Vector();
                string[]      addressString = new string[1] {
                    path
                };
                previewVar.init(sim, vartype, addressString);
                previewVar.initializeUnits(sim);
                previewVar.initializeDescription(sim);
                retVar = previewVar;
            }
            return(retVar);
        }
Пример #3
0
        /* Get a list of all availible settings for this simulation as sinter_Variables */
        public virtual IList <sinter_Variable> getSettings()
        {
            List <sinter_Variable> settings = new List <sinter_Variable>();

            foreach (KeyValuePair <string, Tuple <set_setting, get_setting, sinter_Variable.sinter_IOType> > entry in o_availibleSettings)
            {
                sinter_Variable thisSetting   = sinter_Factory.createVariable(entry.Value.Item3);
                string[]        addressString = { "setting(" + entry.Key + ")" };
                thisSetting.init(entry.Key, sinter_Variable.sinter_IOMode.si_IN, entry.Value.Item3, "Simulation specific setting: " + entry.Key, addressString);
                thisSetting.Value  = entry.Value.Item2();
                thisSetting.dfault = thisSetting.Value;
                settings.Add(thisSetting);
            }
            return(settings);
        }
Пример #4
0
 private void addIO(sinter_Variable.sinter_IOMode iomode, sinter_Variable.sinter_IOType type, string name, string desc, string[] addStrings, int[] bounds)
 {
     if (type == sinter_Variable.sinter_IOType.si_TABLE)
     {
         sinter_Table thisTable = new sinter_Table();
         if (bounds == null || bounds.Length < 2)
         {
             thisTable.init(name, iomode, desc, addStrings, 0, 0);
         }
         else
         {
             thisTable.init(name, iomode, desc, addStrings, bounds[0], bounds[1]);
         }
         addTable(thisTable);
     }
     else if (type == sinter_Variable.sinter_IOType.si_DOUBLE_VEC ||
              type == sinter_Variable.sinter_IOType.si_INTEGER_VEC ||
              type == sinter_Variable.sinter_IOType.si_STRING_VEC)
     {
         sinter_Vector o = new sinter_Vector();
         if (bounds == null || bounds.Length < 1)
         {
             o.init(name, iomode, type, desc, addStrings, 0);
         }
         else
         {
             o.init(name, iomode, type, desc, addStrings, bounds[0]);
         }
         addVariable(o);
     }
     else
     {
         sinter_Variable o = new sinter_Variable();
         o.init(name, iomode, type, desc, addStrings);
         if (o.isSetting)
         {
             addSetting(o);
         }
         else
         {
             addVariable(o);
         }
     }
 }