Ejemplo 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));
                    }
                }
            }
        }
Ejemplo n.º 2
0
        //---------------------------------------
        // Comunication with Simulation Program
        //---------------------------------------

        public override void sendToSim(sinter_InteractiveSim o_sim)
        {
            if ((mode != sinter_IOMode.si_OUT) && (!isSetting))
            {
                if (o_type == sinter_IOType.si_DY_DOUBLE_VEC)  //Really, only doubles support type conversion
                {
                    double[] t_value = ((double[][])o_TimeSeriesValues)[o_TimeSeriesIndex];
                    t_value = unitsConversion(units, defaultUnits, (double[])t_value);  //Do units conversion if required

                    //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.sendVectorToSim <double>(addressStrings[addressIndex], t_value);
                    }
                }
                else if (o_type == sinter_IOType.si_DY_INTEGER_VEC)
                {
                    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.sendVectorToSim <int>(addressStrings[addressIndex], t_value);
                    }
                }
                else if (o_type == sinter_IOType.si_DY_STRING_VEC)
                {
                    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.sendVectorToSim <string>(addressStrings[addressIndex], t_value);
                    }
                }
                else
                {
                    throw new ArgumentException(string.Format("Invalid sinter_IOType passed to sinter_DynamicVector.sendToSim", o_type));
                }
            }
        }