//---------------------------------------
        // 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));
                }
            }
        }
Example #2
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);
         }
     }
 }