//For dyanmic types all the type stuff looks the same, so just reuse the sinter_Variable version of this function to do the
        //work and make them dynamic types on the way out.
        public new static void string2Type(String thisTypeString, ref sinter_IOType thisType, ref int[] sizes)
        {
            sinter_Variable.string2Type(thisTypeString, ref thisType, ref sizes);

            switch (thisType)
            {
            case sinter_IOType.si_DOUBLE:
                thisType = sinter_IOType.si_DY_DOUBLE;
                break;

            case sinter_IOType.si_INTEGER:
                thisType = sinter_IOType.si_DY_INTEGER;
                break;

            case sinter_IOType.si_STRING:
                thisType = sinter_IOType.si_DY_STRING;
                break;

            case sinter_IOType.si_DOUBLE_VEC:
                thisType = sinter_IOType.si_DY_DOUBLE_VEC;
                break;

            case sinter_IOType.si_INTEGER_VEC:
                thisType = sinter_IOType.si_DY_INTEGER_VEC;
                break;

            case sinter_IOType.si_STRING_VEC:
                thisType = sinter_IOType.si_DY_STRING_VEC;
                break;

            default:
                throw new ArgumentException(string.Format("Unknown type {0} passed to sinter_DynmaicScalar.string2type", thisType));
            }
        }
Beispiel #2
0
        //Sizes is an array to support possible multidimensional arrays...
        //Also, dynamic type names are the same as their non-dynamic counterpart
        public static string type2typeString(sinter_IOType thisType, int[] sizes)
        {
            if (thisType == sinter_IOType.si_INTEGER || thisType == sinter_IOType.si_DY_INTEGER)
            {
                return("int");
            }
            else if (thisType == sinter_IOType.si_DOUBLE || thisType == sinter_IOType.si_DY_DOUBLE)
            {
                return("double");
            }
            else if (thisType == sinter_IOType.si_STRING || thisType == sinter_IOType.si_DY_STRING)
            {
                return("string");
            }
            else if (thisType == sinter_IOType.si_INTEGER_VEC || thisType == sinter_IOType.si_DY_INTEGER_VEC)
            {
                return("int[" + Convert.ToString(sizes[0]) + "]");
            }
            else if (thisType == sinter_IOType.si_DOUBLE_VEC || thisType == sinter_IOType.si_DY_DOUBLE_VEC)
            {
                return("double[" + Convert.ToString(sizes[0]) + "]");
            }
            else if (thisType == sinter_IOType.si_STRING_VEC || thisType == sinter_IOType.si_DY_STRING_VEC)
            {
                return("string[" + Convert.ToString(sizes[0]) + "]");
            }

            return("unknown");
        }
Beispiel #3
0
        public void init(string thisName, sinter_IOMode iomode, sinter_IOType thisType, string desc, string[] addStrings, int nn)
        {
            base.init(thisName, iomode, thisType, desc, addStrings);

            makeVector(nn);

            determineIsSetting();
        }
Beispiel #4
0
        //----------------------------------
        //Constuctor
        //----------------------------------

        public sinter_Variable()
            : base()
        {
            // the constructor method
            // set some typlical defaults
            o_error        = sinter_IOError.si_OKAY;
            o_mode         = sinter_IOMode.si_IN;
            o_type         = sinter_IOType.si_DOUBLE;
            o_units        = null;
            o_defaultUnits = null;
        }
Beispiel #5
0
        public virtual void init(string thisName, sinter_IOMode iomode, sinter_IOType thisType, string desc, string[] addStrings)
        {
            o_name           = thisName;
            o_mode           = iomode;
            o_type           = thisType;
            o_description    = desc;
            o_addressStrings = addStrings;
            o_table          = null;
            o_tableName      = null;
            o_tableCol       = 0;
            o_tableRow       = 0;

            makeValue();
            determineIsSetting();
        }
Beispiel #6
0
        /**
         * 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_Sim sim, sinter.sinter_Variable.sinter_IOType type, string[] addStrings)
        {
            o_addressStrings = addStrings;
            IList <string> splitPath = sim.parsePath(o_addressStrings[0]);

            o_name        = getVariableName(sim, addStrings[0]);
            o_mode        = sinter_IOMode.si_IN; //Default to input
            o_type        = type;
            o_description = null;
            o_table       = null;
            o_tableName   = null;
            o_tableCol    = 0;
            o_tableRow    = 0;

            makeValue();
            recvFromSim(sim);
            setDefaultToValue();
        }
 public virtual void init(string thisName, sinter_IOMode iomode, sinter_IOType thisType, string desc, int TimeSeriesLen, string[] addStrings)
 {
     o_TimeSeriesLength = TimeSeriesLen;
     base.init(thisName, iomode, thisType, desc, addStrings);
 }
 public override void init(sinter_Sim sim, sinter_IOType type, string[] addStrings)
 {
     throw new NotImplementedException("Dynamic Scalar does not implement init with no time series");
 }
Beispiel #9
0
        public static void string2Type(String thisTypeString, ref sinter_IOType thisType, ref int[] sizes)
        {
            string[] fields = null;
            string[] sz     = null;

            //Checks if it's a table the bounds will be in brackets
            fields = thisTypeString.Split('[');
            for (int i = 0; i <= fields.Length - 1; i++)
            {
                fields[i] = fields[i].Trim();
            }
            if (fields.Length == 2)
            {
                if (fields[1][fields[1].Length - 1] == ']')                   //Last character in fields[1]
                {
                    fields[1] = fields[1].Substring(0, fields[1].Length - 1); //Drop Last char (Bracket)
                }
            }
            if (fields.Length == 2)
            {
                sz = fields[1].Split(',');
                for (int i = 0; i <= sz.Length - 1; i++)
                {
                    sz[i] = sz[i].Trim();
                }
                sizes = new int[sz.Length];
                for (int ii = 0; ii < sz.Length; ++ii)
                {
                    sizes[ii] = Convert.ToInt32(sz[ii]);
                }
            }

            thisType = sinter_IOType.si_UNKNOWN;

            //End table bounds parsing stuff
            switch (fields[0])
            {
            case "int":
                if (sizes == null || sizes.Length == 0)
                {
                    thisType = sinter_IOType.si_INTEGER;
                }
                else if (sizes.Length == 1)
                {
                    thisType = sinter_IOType.si_INTEGER_VEC;
                }
                break;

            case "double":
                if (sizes == null || sizes.Length == 0)
                {
                    thisType = sinter_IOType.si_DOUBLE;
                }
                else if (sizes.Length == 1)
                {
                    thisType = sinter_IOType.si_DOUBLE_VEC;
                }
                break;

            case "string":
                if (sizes == null || sizes.Length == 0)
                {
                    thisType = sinter_IOType.si_STRING;
                }
                else if (sizes.Length == 1)
                {
                    thisType = sinter_IOType.si_STRING_VEC;
                }
                break;

            case "table":
                thisType = sinter_IOType.si_TABLE;
                break;

            default:
                thisType = sinter_IOType.si_UNKNOWN;
                break;
            }
        }
Beispiel #10
0
 public override void init(string thisName, sinter_IOMode iomode, sinter_IOType thisType, string desc, string[] addStrings)
 {
     init(thisName, iomode, thisType, desc, addStrings, 1);  //Init a unit length vector (0 is bad)  Will be increased later
 }