Esempio n. 1
0
        //============================================================================
        /// <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
        }
Esempio n. 2
0
        //=========================================================================
        /// <summary>
        /// Find the element of an array to write to. Resize the array if required.
        /// </summary>
        /// <param name="initName">Name of the init.</param>
        /// <param name="idx">Array item index.</param>
        /// <param name="baseType">The base type of the item.</param>
        /// <param name="elemValue">The typed value of the array item.</param>
        /// <returns>The array item.</returns>
        //=========================================================================
        private void findElementWrite(string initName, int idx, TTypedValue.TBaseType baseType, ref TInitValue elemValue)
        {
            TInitValue aValue = null;

            if (idx < 1)
            {
                throw (new ArrayIndexException("Attempt to write out of range of array value " + initName));
            }

            findValue(initName, out aValue);                                       // Try to locate the named value

            if (aValue == null)                                                    // First time this array has been
            {                                                                      //   referred to - create it
                aValue = new TInitValue(initName, baseType, idx);
                addValue(aValue);
            }

            if (!aValue.isArray())
            {
                throw (new TypeMisMatchException("Attempt to write array to non-array value " + initName));
            }

            if (idx > aValue.count())
            {
                aValue.setElementCount((uint)idx);
            }

            elemValue = (TInitValue)aValue.item((uint)idx);
        }
Esempio n. 3
0
        /// <summary>
        /// Initalises TParameterDefinition from another instance
        /// </summary>
        /// <param name="Source"></param>
        public TParameterDefinition(TParameterDefinition Source)
        {
            FItems = new TParameterDefinition[0];
            int Idx;

            FName = Source.sFullName;
            FNamePart = Source.sPartName;
            FType = Source.paramType;
            FCount = Source.iCount;

            if (FCount > 0)
            {
                Array.Resize(ref FItems, FCount);
                for (Idx = 0; Idx <= FCount - 1; Idx++)
                    FItems[Idx] = new TParameterDefinition(Source.item(Idx));
            }
            else
                FItems = null;

            FParamCount = Source.iParamCount;
            FDefined = Source.FDefined;
        }
Esempio n. 4
0
        /// <summary>
        /// Each element of a "definition string" array may take one of two forms:       
        /// * val:val        Integer subrange (e.g. "1:8")                              
        /// * text[;text]*   List of text indices                                       
        ///                                                                             
        /// For example, if the original string from which sDefnStrings was constructed  
        /// was "KQ-1:4-leaf;stem", then the resulting tree of definitions would be:     
        /// KQ                                                                         
        ///  |                                                                         
        ///  +-+-------------+-------------+-------------+                             
        ///    |             |             |             |                             
        ///    1             2             3             4                             
        ///    +-+-----+     +-+-----+     +-+-----+     +-+-----+                     
        ///      |     |       |     |       |     |       |     |                     
        ///      leaf  stem    leaf  stem    leaf  stem    leaf  stem                  
        /// </summary>
        /// <param name="sDefnStrings"></param>
        /// <param name="aType"></param>
        /// <param name="iOffset"></param>
        public TParameterDefinition(string[] sDefnStrings, TTypedValue.TBaseType aType, int iOffset = 0)
        {
            FItems = new TParameterDefinition[0];
            string[] sSubDefnStrings = new string[0];
            string sIndexStr;
            int iPosn;
            int Idx;

            FName = sDefnStrings[0];
            for (Idx = 1; Idx <= iOffset; Idx++)
                FName = FName + "-" + sDefnStrings[Idx];
            if (iOffset < (sDefnStrings.Length - 1))
                FName = FName + "-";
            FName = FName.ToLower();

            FNamePart = sDefnStrings[iOffset].ToLower();
            FType = aType;
            FDefined = false;

            if (iOffset < (sDefnStrings.Length - 1))
            {
                Array.Resize(ref sSubDefnStrings, sDefnStrings.Length);
                for (Idx = 0; Idx <= (sSubDefnStrings.Length - 1); Idx++)
                    sSubDefnStrings[Idx] = sDefnStrings[Idx];
                sIndexStr = sDefnStrings[iOffset + 1];

                iPosn = sIndexStr.IndexOf(':');
                if (iPosn >= 0)                                                        // Integer subrange
                {
                    int start = Convert.ToInt32(sIndexStr.Substring(0, iPosn));
                    int endpos = Convert.ToInt32(sIndexStr.Substring(iPosn + 1, sIndexStr.Length - iPosn - 1));
                    for (Idx = start; Idx <= endpos; Idx++)
                    {
                        sSubDefnStrings[iOffset + 1] = Convert.ToString(Idx);
                        Array.Resize(ref FItems, FItems.Length + 1);
                        FItems[FItems.Length - 1] = new TParameterDefinition(sSubDefnStrings, aType, iOffset + 1);
                    }
                }
                else                                                                       // Single index or semi-colon-separated  }
                {                                                                      //   list of indices                     }
                    while (sIndexStr != "")
                    {
                        iPosn = sIndexStr.IndexOf(";");
                        if (iPosn >= 0)
                        {
                            sSubDefnStrings[iOffset + 1] = sIndexStr.Substring(0, iPosn);
                            sIndexStr = sIndexStr.Substring(iPosn + 1, sIndexStr.Length - iPosn - 1);
                        }
                        else
                        {
                            sSubDefnStrings[iOffset + 1] = sIndexStr;
                            sIndexStr = "";
                        }

                        Array.Resize(ref FItems, FItems.Length + 1);
                        FItems[FItems.Length - 1] = new TParameterDefinition(sSubDefnStrings, aType, iOffset + 1);
                    }
                }
            }

            FCount = FItems.Length;
            if (bIsScalar())
                FParamCount = 1;
            else
                FParamCount = FCount * item(0).iParamCount;
        }