//============================================================================
        /// <summary>
        /// Finds the sub-value of a TTypedValue corresponding to this specifier
        /// </summary>
        /// <param name="aValue"></param>
        /// <returns></returns>
        //============================================================================
        public TDDMLValue FindValue(TTypedValue aValue)
        {
            TDDMLValue result;

            if ((SubSpecifier == null) || (aValue == null))
            {
                result = (TDDMLValue)aValue;
            }
            else
            {
                if (SubSpecifier.bIsField)
                {
                    result = (TDDMLValue)(SubSpecifier.FindValue(aValue.member(SubSpecifier.sName)));
                }
                else
                {
                    if (SubSpecifier.bIsElement)
                    {
                        result = (SubSpecifier.FindValue(aValue.item((uint)SubSpecifier.iArrayIndex)));
                    }
                    else
                    {
                        result = null;
                    }
                }
            }
            return(result);
        }
        //============================================================================
        /// <summary>
        ///
        /// </summary>
        /// <param name="baseValue"></param>
        /// <param name="Agg"></param>
        /// <param name="decplaces"></param>
        //============================================================================
        public TOutputScalar(TTypedValue baseValue, TGenericReporter.AggregType Agg, int decplaces)
        {
            // None                  Sum                    Mean                Max                 Min
            COLUMNTYPES = new TTypedValue.TBaseType[12, 5]  {
                { TTypedValue.TBaseType.ITYPE_EMPTY, TTypedValue.TBaseType.ITYPE_EMPTY, TTypedValue.TBaseType.ITYPE_EMPTY, TTypedValue.TBaseType.ITYPE_EMPTY, TTypedValue.TBaseType.ITYPE_EMPTY },
                { TTypedValue.TBaseType.ITYPE_INT1, TTypedValue.TBaseType.ITYPE_INT4, TTypedValue.TBaseType.ITYPE_DOUBLE, TTypedValue.TBaseType.ITYPE_INT1, TTypedValue.TBaseType.ITYPE_INT1 },
                { TTypedValue.TBaseType.ITYPE_INT2, TTypedValue.TBaseType.ITYPE_INT4, TTypedValue.TBaseType.ITYPE_DOUBLE, TTypedValue.TBaseType.ITYPE_INT2, TTypedValue.TBaseType.ITYPE_INT2 },
                { TTypedValue.TBaseType.ITYPE_INT4, TTypedValue.TBaseType.ITYPE_INT4, TTypedValue.TBaseType.ITYPE_DOUBLE, TTypedValue.TBaseType.ITYPE_INT4, TTypedValue.TBaseType.ITYPE_INT4 },
                { TTypedValue.TBaseType.ITYPE_INT8, TTypedValue.TBaseType.ITYPE_INT8, TTypedValue.TBaseType.ITYPE_DOUBLE, TTypedValue.TBaseType.ITYPE_INT8, TTypedValue.TBaseType.ITYPE_INT8 },
                { TTypedValue.TBaseType.ITYPE_SINGLE, TTypedValue.TBaseType.ITYPE_SINGLE, TTypedValue.TBaseType.ITYPE_SINGLE, TTypedValue.TBaseType.ITYPE_SINGLE, TTypedValue.TBaseType.ITYPE_SINGLE },
                { TTypedValue.TBaseType.ITYPE_DOUBLE, TTypedValue.TBaseType.ITYPE_DOUBLE, TTypedValue.TBaseType.ITYPE_DOUBLE, TTypedValue.TBaseType.ITYPE_DOUBLE, TTypedValue.TBaseType.ITYPE_DOUBLE },
                { TTypedValue.TBaseType.ITYPE_CHAR, TTypedValue.TBaseType.ITYPE_CHAR, TTypedValue.TBaseType.ITYPE_CHAR, TTypedValue.TBaseType.ITYPE_CHAR, TTypedValue.TBaseType.ITYPE_CHAR },                               //char
                { TTypedValue.TBaseType.ITYPE_BOOL, TTypedValue.TBaseType.ITYPE_INT4, TTypedValue.TBaseType.ITYPE_DOUBLE, TTypedValue.TBaseType.ITYPE_BOOL, TTypedValue.TBaseType.ITYPE_BOOL },                             //boolean
                { TTypedValue.TBaseType.ITYPE_CHAR, TTypedValue.TBaseType.ITYPE_CHAR, TTypedValue.TBaseType.ITYPE_CHAR, TTypedValue.TBaseType.ITYPE_CHAR, TTypedValue.TBaseType.ITYPE_CHAR },                               //wchar
                { TTypedValue.TBaseType.ITYPE_STR, TTypedValue.TBaseType.ITYPE_STR, TTypedValue.TBaseType.ITYPE_STR, TTypedValue.TBaseType.ITYPE_STR, TTypedValue.TBaseType.ITYPE_STR },                                    //string
                { TTypedValue.TBaseType.ITYPE_STR, TTypedValue.TBaseType.ITYPE_STR, TTypedValue.TBaseType.ITYPE_STR, TTypedValue.TBaseType.ITYPE_STR, TTypedValue.TBaseType.ITYPE_STR }
            };                                                                                                                                                                                                              //wstring


            if (!baseValue.isScalar())
            {
                throw (new ApplicationException("Cannot create non-scalar output columns"));
            }

            baseType = COLUMNTYPES[(int)baseValue.baseType(), (int)Agg]; //Note that the type of the output can depend on the aggregation
            Units    = baseValue.units();
            Aggreg   = Agg;
            decPl    = decplaces;
            Clear(); //init values
        }
Beispiel #3
0
        public void unpack(TTypedValue src)
        {
            ApsimType Data = (ApsimType)Property.Get;

            Data.unpack(src);
            Property.SetObject(Data);
        }
Beispiel #4
0
 //=====================================================================
 /// <summary>
 /// Store the forms controls into the list of TTypedValues.
 /// </summary>
 //=====================================================================
 private void StoreControls()
 {
     for (int i = 0; i < typedvals.Count; i++)
     {
         TTypedValue sdmlinit = typedvals[i];
         if (sdmlinit.Name == "rules")
         {
             sdmlinit.setElementCount((uint)richTextBox1.Lines.Length);
             for (uint line = 0; line < richTextBox1.Lines.Length; line++)
             {
                 sdmlinit.item(line + 1).setValue(richTextBox1.Lines[line]);
             }
         }
         if (sdmlinit.Name == "logfile")
         {
             if (checkBox1.Checked)
             {
                 sdmlinit.setValue(textBox1.Text);
             }
             else
             {
                 sdmlinit.setValue("");
             }
         }
         if (sdmlinit.Name == "log_set")
         {
         }
     }
 }
Beispiel #5
0
        //==========================================================================
        /// <summary>
        ///
        /// </summary>
        /// <param name="propertyID"></param>
        /// <param name="aValue"></param>
        /// <returns></returns>
        //==========================================================================
        public override bool writeProperty(int propertyID, TTypedValue aValue)
        {
            bool result = true;

            switch (propertyID)
            {
            case prpFILE:
            {
                if (FFirstTime)
                {
                    initProperty(prpFILE, aValue);
                }
            } break;

            case prpSUMMARYFILE:
            {
                if (FFirstTime)
                {
                    FSummaryStream = null;
                    initProperty(prpSUMMARYFILE, aValue);
                }
            } break;

            default: result = false; break;
            }

            if (!result)
            {
                result = base.writeProperty(propertyID, aValue);
            }
            return(result);
        }
Beispiel #6
0
 //=========================================================================
 /// <summary>
 /// Assign a driver value.
 /// </summary>
 /// <param name="driverID"></param>
 /// <param name="providerID">Component that provided the value.</param>
 /// <param name="aValue">Returned value.</param>
 //=========================================================================
 public override void assignDriver(int driverID, uint providerID, TTypedValue aValue)
 {
     if (driverID == drvCOMPCLASS)   //if this driver was a comp.type
     {
         if (compInfoList.Count == 1)
         {
             foreach (KeyValuePair <String, List <TComp> > pair in compInfoList)
             {
                 List <TComp> comps = pair.Value;
                 for (int i = 0; i < comps.Count; i++)
                 {
                     TComp comp = comps[i];
                     if (comp.compID == providerID)
                     {
                         comp.CompClass = aValue.asString();                 //store the class type
                         comps[i]       = comp;
                     }
                 }
             }
         }
         else
         {
             throw new Exception("More requests using compInfoList<> than expected in assignDriver()");
         }
     }
     else
     {
         if (!Comp.assignDriver(driverID, providerID, aValue))
         {
             base.assignDriver(driverID, providerID, aValue);
         }
     }
 }
Beispiel #7
0
        //============================================================================
        /// <summary>
        /// Gets the typed value as an XML description.
        /// </summary>
        /// <param name="value">The typed value to describe as xml.</param>
        /// <param name="startIndent">Formatting indentation start.</param>
        /// <param name="tab">Number of spaces in each tab</param>
        /// <returns>The string with the XML result.</returns>
        //============================================================================
        public override String getText(TTypedValue value, int startIndent, int tab)
        {
            int    nextIndent;
            String sIndent;

            if (startIndent > -1)
            {
                nextIndent = startIndent + tab;
                sIndent    = new String(' ', startIndent);
            }
            else
            {
                nextIndent = -1;
                sIndent    = "";
            }

            StringBuilder sbuf = new StringBuilder(sIndent);

            sbuf.Append("<type name=\"");
            sbuf.Append(value.Name);
            sbuf.Append("\"");
            sbuf.Append(sIndent);
            sbuf.Append(writeFieldInfo(value, nextIndent, tab));
            sbuf.Append(sIndent);
            sbuf.Append("</type>");

            return(sbuf.ToString());
        }
Beispiel #8
0
        //============================================================================
        /// <summary>
        /// Uses the copy constructor to make a clone of a typedvalue's structure.
        /// It is then added as a member to an array or record.
        /// this virtual function is expected to be overriden so that new members are
        /// of the child classes' type.
        /// </summary>
        /// <param name="bluePrintValue">Use this TTYpedValue as the blue print.</param>
        //============================================================================
        public override void newMember(TTypedValue bluePrintValue)
        {
            TInitValue newElement;

            newElement = new TInitValue(bluePrintValue); //calls copy constructor
            addMember(newElement);                       //add the copy
        }
Beispiel #9
0
        //=========================================================================
        /// <summary>
        /// Find the init property item in the array.
        /// </summary>
        /// <param name="initName">Name of the init array.</param>
        /// <param name="idx">Array item index.</param>
        /// <returns>The typed value found at the index.</returns>
        //=========================================================================
        private TTypedValue findElementRead(string initName, int idx)
        {
            TTypedValue aValue = null;
            TTypedValue result;

            readValue(initName, ref aValue);

            if (aValue == null)
            {
                result = null;
            }
            else
            {
                if (!aValue.isArray())
                {
                    throw (new TypeMisMatchException("Attempt to read array from non-array value " + initName));
                }
                if ((idx < 1) || (idx > aValue.count()))
                {
                    throw (new ArrayIndexException("Attempt to read out of range of array value " + initName));
                }
                result = aValue.item((uint)idx);
            }
            return(result);
        }
Beispiel #10
0
        //============================================================================
        /// <summary>
        /// Adds a scalar to an array or record.
        /// </summary>
        /// <param name="sName">Name of the scalar.</param>
        /// <param name="aType">The basic type for this scalar.</param>
        /// <returns>A ref to the newly created scalar.</returns>
        //============================================================================
        public override TTypedValue addScalar(String sName, TBaseType aType)
        {
            TInitValue newScalar;

            TTypedValue result = null;

            if (FIsArray || FIsRecord)
            {
                newScalar = new TInitValue(sName, aType);

                if (isArray())
                {
                    // Arrays pass their default value and valid range down to their elements
                    if (newScalar.getDefault() != null)
                    {
                        newScalar.getDefault().copyFrom(FDefault);
                    }
                    if (newScalar.getMin() != null)
                    {
                        newScalar.getMin().copyFrom(FMin);
                    }
                    if (newScalar.getMax() != null)
                    {
                        newScalar.getMax().copyFrom(FMax);
                    }
                }

                addMember(newScalar);
                result = newScalar;
            }
            return(result);
        }
Beispiel #11
0
        public override void unpack(TTypedValue src)
        {
            DDMLValue.setValue(src);
            setPropertyValue(); //store the Value property
            T Data = Value;

            Property.SetObject(Data);
        }
Beispiel #12
0
        /// <summary>
        /// Write the parameter set
        /// </summary>
        /// <param name="subSet">The parameter subset</param>
        /// <param name="strings">List of strings</param>
        /// <param name="elem">XML element name</param>
        /// <param name="indent">The XML indentation</param>
        private void WriteParamSet(ParameterSet subSet, List <string> strings, string elem, int indent)
        {
            string lineStr;
            int    idx;

            if (!subSet.NodeIsRoot())
            {
                strings.Add(string.Empty);
            }

            lineStr = new string(' ', indent) + "<" + elem + " name=\"" + subSet.EnglishName + "\"";
            if (subSet.NodeIsRoot())
            {
                lineStr += " version=\"" + subSet.Version + "\">";
            }
            else
            {
                if (subSet.LocaleCount() > 0)
                {
                    lineStr += " locales=\"" + subSet.GetLocale(0);
                    for (idx = 1; idx <= subSet.LocaleCount() - 1; idx++)
                    {
                        lineStr += ";" + subSet.GetLocale(idx);
                    }
                    lineStr += "\"";
                }
                lineStr += ">";
            }
            strings.Add(lineStr);

            if (subSet.TranslationCount() > 0)
            {
                for (idx = 0; idx <= subSet.TranslationCount() - 1; idx++)
                {
                    lineStr = new string(' ', indent + 2) + "<translate lang=\"" +
                              subSet.GetTranslation(idx).Lang + "\">" +
                              TTypedValue.EscapeText(subSet.GetTranslation(idx).Text) + "</translate>";
                    strings.Add(lineStr);
                }
            }

            for (idx = 0; idx <= subSet.DefinitionCount() - 1; idx++)
            {
                this.WriteParameters(subSet, subSet.GetDefinition(idx), strings, indent + 2);
            }
            for (idx = 0; idx <= subSet.ChildCount() - 1; idx++)
            {
                this.WriteParamSet(subSet.GetChild(idx), strings, "set", indent + 2);
            }

            lineStr = new string(' ', indent) + "</" + elem + ">";
            if (!subSet.NodeIsRoot() && (subSet.ChildCount() > 0))
            {
                lineStr += "<!-- " + subSet.EnglishName + " -->";
            }

            strings.Add(lineStr);
        }
Beispiel #13
0
 //============================================================================
 /// <summary>
 /// Creates a one dimensional array of arbitrary items.
 /// </summary>
 /// <param name="sArrayName">Name of this array.</param>
 /// <param name="baseValue">Use as the base type of the array elements.</param>
 /// <param name="iNoElements">Create it with this number of elements.</param>
 //============================================================================
 public TInitValue(String sArrayName, TTypedValue baseValue, int iNoElements)
     : base(sArrayName, baseValue, iNoElements)
 {
     //FMax = null;
     //FMin = null;
     FDefault = null;
     newMember(baseValue);
     setElementCount((uint)iNoElements);
 }
Beispiel #14
0
 //=======================================================================
 /// <summary>
 /// Construct a TCompProperty using a TTypedValue object. It will be
 /// non readable, non writeable, and not an init property. It's name will
 /// be ""
 /// </summary>
 /// <param name="typedValue">Typed Value to use as the blueprint</param>
 //=======================================================================
 public TCompProperty(TTypedValue typedValue)
 {
     bRead      = false;
     bWrite     = false;
     bInit      = false;
     InitValue  = new TInitValue(typedValue);
     Name       = "";
     sDescr     = "";
     sFullDescr = "";
 }
Beispiel #15
0
        //============================================================================
        /// <summary>
        /// Sets the fields of the typed value with the timestep values.
        /// </summary>
        /// <param name="timeValue">Ref to the typed value to be set.</param>
        /// <returns>A ref to the typed value that has been set.</returns>
        //============================================================================
        public TTypedValue getTypedValue(ref TTypedValue timeValue)
        {
            timeValue.member(1).setValue((int)start.getDay());
            timeValue.member(2).setValue((int)start.getSec());
            timeValue.member(3).setValue((double)start.getSecPart());

            timeValue.member(4).setValue((int)finish.getDay());
            timeValue.member(5).setValue((int)finish.getSec());
            timeValue.member(6).setValue((double)finish.getSecPart());

            return(timeValue);
        }
Beispiel #16
0
        //=========================================================================
        /// <summary>
        /// Find the init property and return the typedvalue.
        /// </summary>
        /// <param name="initName">Name of the init property.</param>
        /// <param name="xValue">The typed value found. null if not found.</param>
        /// <returns>True if found.</returns>
        //=========================================================================
        public bool readValue(string initName, ref TTypedValue xValue)
        {
            TInitValue aValue = null;

            bool result = (findValue(initName, out aValue) >= 0);

            if (result)
            {
                xValue = aValue;
            }

            return(result);
        }
Beispiel #17
0
        //============================================================================
        /// <summary>
        /// Used to add a scalar to a record or array
        /// </summary>
        /// <param name="sName">Name of the scalar value.</param>
        /// <param name="aType">Use this type.</param>
        /// <returns>The scalar value added.</returns>
        //============================================================================
        public override TTypedValue addScalar(String sName, TBaseType aType)
        {
            TSDMLValue  newScalar;
            TTypedValue result = null;

            if (FIsArray || FIsRecord)
            {
                newScalar = new TSDMLValue(sName, aType);
                addMember(newScalar);
                result = newScalar;
            }
            return(result);
        }
Beispiel #18
0
        //==========================================================================
        /// <summary>
        ///
        /// </summary>
        /// <param name="driverID"></param>
        /// <param name="providerID"></param>
        /// <param name="aValue"></param>
        //==========================================================================
        public override void assignDriver(int driverID, uint providerID, TTypedValue aValue)
        {
            if (driverID == drvTIME)
            {
                FTimeStep.Set(aValue);
            }
            else
            {
                FReporter.storeVariable(aValue);
            }

            //base.assignDriver(driverID, providerID, aValue);
        }
Beispiel #19
0
        //=========================================================================
        /// <summary>
        /// Read the scalar value in the array at the specified index.
        /// </summary>
        /// <param name="initName">Name of the array init property.</param>
        /// <param name="idx">Item index in the array.</param>
        /// <param name="value">The scalar value found at the index. Returns empty string if not found.</param>
        //=========================================================================
        public void readElement(string initName, int idx, ref string value)
        {
            TTypedValue aValue = null;

            aValue = findElementRead(initName, idx);
            if (aValue != null)
            {
                value = aValue.asStr();
            }
            else
            {
                value = "";
            }
        }
Beispiel #20
0
        //=========================================================================
        /// <summary>
        /// Read the scalar value in the array at the specified index.
        /// </summary>
        /// <param name="initName">Name of the array init property.</param>
        /// <param name="idx">Item index in the array.</param>
        /// <param name="value">The scalar value found at the index. Returns 0 if not found.</param>
        //=========================================================================
        public void readElement(string initName, int idx, ref double value)
        {
            TTypedValue aValue = null;

            aValue = findElementRead(initName, idx);
            if (aValue != null)
            {
                value = aValue.asDouble();
            }
            else
            {
                value = 0.0;
            }
        }
Beispiel #21
0
        //=========================================================================
        /// <summary>
        /// Read the scalar value in the array at the specified index.
        /// </summary>
        /// <param name="initName">Name of the array init property.</param>
        /// <param name="idx">Item index in the array.</param>
        /// <param name="value">The value found at the index. Returns false if not found.</param>
        //=========================================================================
        public void readElement(string initName, int idx, ref bool value)
        {
            TTypedValue aValue = null;

            aValue = findElementRead(initName, idx);
            if (aValue != null)
            {
                value = aValue.asBool();
            }
            else
            {
                value = false;
            }
        }
Beispiel #22
0
        //============================================================================
        /// <summary>
        /// Gets the value of this XML element and stores it in the matching typed value.
        /// </summary>
        /// <param name="sAttrName">Name of the element.</param>
        /// <param name="aValue">The typed value to be set with the value found.</param>
        //============================================================================
        protected void parseRangeValue(String sAttrName, TTypedValue aValue)
        {
            XmlNode anode;
            String  sAttrValue;

            if (parser != null)
            {
                anode = parser.firstElementChild(parser.rootNode(), sAttrName);
                if (anode != null)
                {
                    sAttrValue = parser.getText(anode);
                    aValue.setValue(sAttrValue);
                }
            }
        }
Beispiel #23
0
 //===========================================================================
 /// <summary>
 /// Initialise all the members of the TInitValue. Recurse into fields.
 /// </summary>
 /// <param name="item">The TInitValue to initialise</param>
 //===========================================================================
 protected void initialiseMembers(TInitValue item)
 {
     if (item.isScalar() && (item.getDefault() != null))
     {
         item.copyFrom(item.getDefault());
     }
     else
     {
         for (uint i = 1; i <= item.count(); i++) //for each member of the item
         {
             TTypedValue child = item.item(i);
             initialiseMembers((TInitValue)child);
         }
     }
 }
Beispiel #24
0
    //=========================================================================
    /// <summary>
    ///
    /// </summary>
    /// <param name="eventID"></param>
    /// <param name="iState"></param>
    /// <param name="publisherID"></param>
    /// <param name="aParams"></param>
    /// <returns></returns>
    //=========================================================================
    public override int processEventState(int eventID, int iState, uint publisherID, TTypedValue aParams)
    {
        int iCondition = 0;

        if (eventID == tickID)
        {
            //execute tick event
        }
        else
        {
            Comp.handleEvent(eventID, aParams, publisherID);
        }
        ////return base.processEventState(eventID, iState, publisherID, aParams);
        return(iCondition);
    }
Beispiel #25
0
        //=========================================================================
        /// <summary>
        /// Write the typed value to the property.
        /// </summary>
        /// <param name="initName">Name of the destination property.</param>
        /// <param name="xValue">The typed value to write.</param>
        //=========================================================================
        public void writeValue(string initName, TTypedValue xValue)
        {
            TInitValue newValue;

            findValue(initName, out newValue);
            if (newValue != null)
            {
                writeData(xValue, newValue);
            }
            else
            {
                newValue      = new TInitValue(xValue);
                newValue.Name = initName;
                addValue(newValue);
                writeData(xValue, newValue);
            }
        }
        //==============================================================================
        /// <summary>
        /// Stores the current value of a requested variable.
        /// </summary>
        /// <param name="aValue"></param>
        //==============================================================================
        public void storeVariable(TTypedValue aValue)
        {
            int        iReqIdx;
            TDDMLValue reqValue;

            iReqIdx = FRequestNames.IndexOf(aValue.Name);
            if (iReqIdx < 0)
            {
                throw (new ApplicationException("storeVariable() - Attempt to store invalid variable: " + aValue.Name));
            }

            reqValue = FRequests[iReqIdx];
            if (reqValue == null)
            {
                reqValue           = new TDDMLValue(aValue); // First time: make a copy of the TTypedValue
                FRequests[iReqIdx] = reqValue;
            }
            reqValue.setValue(aValue);
        }
Beispiel #27
0
    //==============================================================================
    /// <summary>
    /// Build a requestSetvalue message.
    /// </summary>
    /// <param name="iLocalSetPropID">Local identifier for the property.</param>
    /// <param name="Value">Value to which to set the property.</param>
    /// <returns>The new message. If this function fails then the returned message.msgID==0</returns>
    //==============================================================================
    protected TMsgHeader buildRequestSetMsg(int iLocalSetPropID, TTypedValue Value)
    {
        uint            valSize;
        TSetterProperty localProp = null;
        TMsgHeader      newMsg    = new TMsgHeader();

        newMsg.msgID = 0;   //default to fault

        valSize = Value.sizeBytes();
        byte[] valPtr = new byte[valSize];
        Value.getData(ref valPtr);

        //destination is the owning system
        interpreter.setField(Msgs.MSG_REQUESTSET_ID, iLocalSetPropID);      //local reg property ID
        interpreter.setField(Msgs.MSG_REQUESTSET_TYPE, localProp.sDDML);
        interpreter.setField(Msgs.MSG_REQUESTSET_VALUE, valPtr, valSize);
        newMsg = interpreter.createMessage(Msgs.MSG_REQUESTSET, parentID);
        return(newMsg);
    }
Beispiel #28
0
        //=========================================================================
        /// <summary>
        /// Writes the srcValue to destValue.
        /// </summary>
        /// <param name="srcValue">The source value.</param>
        /// <param name="destValue">The destination item.</param>
        //=========================================================================
        private void writeData(TTypedValue srcValue, TTypedValue destValue)
        {
            uint Idx;

            if (destValue.isScalar())
            {
                if (srcValue != null)
                {
                    destValue.setValue(srcValue);
                }
                else if ((destValue.baseType() >= TTypedValue.TBaseType.ITYPE_INT1) && (destValue.baseType() <= TTypedValue.TBaseType.ITYPE_DOUBLE))
                {
                    destValue.setValue(0);
                }
                else
                {
                    destValue.setValue("");
                }
            }
            else if (destValue.isArray())
            {
                if (srcValue == null)
                {
                    destValue.setElementCount(0);
                }
                else
                {
                    destValue.setElementCount(srcValue.count());
                    for (Idx = 1; Idx <= srcValue.count(); Idx++)
                    {
                        writeData(srcValue.item(Idx), destValue.item(Idx));
                    }
                }
            }
            else // record
            {
                for (Idx = 1; Idx <= destValue.count(); Idx++)
                {
                    writeData(srcValue.member(destValue.item(Idx).Name), destValue.item(Idx));
                }
            }
        }
Beispiel #29
0
        //============================================================================
        /// <summary>
        /// Copy constructor. This constructor makes a copy of the source's structure.
        /// For specialised child classes, this constructor should be overriden.
        /// </summary>
        /// <param name="typedValue">TTypedValue to use as the source.</param>
        //============================================================================
        public TInitValue(TTypedValue typedValue)
            : base(typedValue)
        {
            //FMax = null;
            //FMin = null;
            FDefault = null;
            FDescr   = "";
            //required in this derived class
            initTypeCopy(typedValue);  //calls suitable virtual functions

            TInitValue other = (TInitValue)typedValue;

            if (other != null)
            {
                if (other.FDefault != null)
                {
                    if (FDefault == null)
                    {
                        FDefault = new TDDMLValue("defval", FBaseType);
                    }
                    FDefault.copyFrom(other.FDefault);
                }
                if (other.FMin != null)
                {
                    if (FMin == null)
                    {
                        FMin = new TDDMLValue("minval", FBaseType);
                    }
                    FMin.copyFrom(other.FMin);
                }
                if (other.FMax != null)
                {
                    if (FMax == null)
                    {
                        FMax = new TDDMLValue("maxval", FBaseType);
                    }
                    FMax.copyFrom(other.FMax);
                }
                setDescr(other.getDescr(), 255);
            }
        }
Beispiel #30
0
        //============================================================================
        /// <summary>
        /// Return the string for the scalar ttypedvalue.
        /// Numeric types are returned without any rounding or escaping.
        /// </summary>
        /// <param name="attrInfo">The scalar TTypedValue</param>
        /// <returns>String represenation of the scalar</returns>
        //============================================================================
        protected String scalarString(TTypedValue attrInfo)
        {
            String strVal;

            if ((attrInfo.baseType() >= TTypedValue.TBaseType.ITYPE_SINGLE) && (attrInfo.baseType() <= TTypedValue.TBaseType.ITYPE_DOUBLE))
            {
                strVal = attrInfo.asDouble().ToString(); //full precision
            }
            else
            {
                if ((attrInfo.baseType() >= TTypedValue.TBaseType.ITYPE_INT1) && (attrInfo.baseType() <= TTypedValue.TBaseType.ITYPE_INT8))
                {
                    strVal = attrInfo.asInt().ToString(); //no need to escape this
                }
                else
                {
                    strVal = attrInfo.asEscapedString();
                }
            }
            return(strVal);
        }