//============================================================================ /// <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 }
//============================================================================ /// <summary> /// Formats the xml text for the 'field' or 'element' description of the typed /// value stored as a TPropertyInfo or TDriverInfo. /// </summary> /// <param name="attrInfo">The TypedValue attribute.</param> /// <param name="indent">Indentation in chars.</param> /// <param name="tab">Number of spaces in each tab</param> /// <returns>XML text for the field</returns> //============================================================================ protected override String writeFieldInfo(TTypedValue attrInfo, int indent, int tab) { uint i; uint iFirst; int oneIndent; int nextIndent; int startIndent; String CR = ""; //determine how much to indent this description oneIndent = 0; startIndent = 0; if (indent > -1) { oneIndent = tab; startIndent = indent; CR = "\r\n"; } nextIndent = indent; String sIndent = new String(' ', startIndent + oneIndent); StringBuilder xml = new StringBuilder(""); xml.Append(" kind=\"" + attrInfo.typeName() + "\""); if (attrInfo.isArray()) { xml.Append(" array=\"T\""); } if ((attrInfo.units().Length > 0) && (attrInfo.units()[0] != '-')) { xml.Append(" unit=\"" + attrInfo.units() + "\""); } xml.Append(">" + CR); //if a scalar or array of scalars then write the defval|minval|maxval elements if (attrInfo.isScalar() || (attrInfo.isArray() && attrInfo.baseType() == TTypedValue.TBaseType.ITYPE_DEF)) { TInitValue initInfo = new TInitValue(attrInfo); if (initInfo != null) { if (initInfo.getDefault() != null) { xml.Append(sIndent + "<defval>" + initInfo.getDefault().asEscapedString() + "</defval>" + CR); } if (initInfo.getMin() != null) { xml.Append(sIndent + "<minval>" + initInfo.getMin().asEscapedString() + "</minval>" + CR); } if (initInfo.getMax() != null) { xml.Append(sIndent + "<maxval>" + initInfo.getMax().asEscapedString() + "</maxval>" + CR); } } } //now nest into the fields/elements sIndent = new String(' ', startIndent); if (!attrInfo.isScalar()) { // Special handling for non-scalar arrays of length 0, to ensure type definition is output iFirst = (uint)((attrInfo.isArray() && attrInfo.count() == 0) ? 0 : 1); for (i = iFirst; i <= attrInfo.count(); i++) { //for each child field if (attrInfo.isArray() && attrInfo.baseType() == TTypedValue.TBaseType.ITYPE_DEF) { xml.Append(sIndent + "<element"); xml.Append(writeFieldInfo(attrInfo.item(i), nextIndent, oneIndent)); xml.Append(sIndent + "</element>" + CR); } else if (attrInfo.isRecord()) { xml.Append(sIndent + "<field name=\"" + attrInfo.item(i).Name + "\""); xml.Append(writeFieldInfo(attrInfo.item(i), nextIndent, oneIndent)); xml.Append(sIndent + "</field>" + CR); } } } return(xml.ToString()); }
//============================================================================ /// <summary> /// Formats the xml text for the 'field' or 'element' description of the typed /// value stored as a TTypedValue. /// </summary> /// <param name="attrInfo"></param> /// <param name="indent"></param> /// <param name="tab">Number of spaces in each tab</param> /// <returns>Buffer containing the text</returns> /// N.Herrmann Apr 2002 //============================================================================ protected override String writeFieldInfo(TTypedValue attrInfo, int indent, int tab) { String elementType; uint i; int nextIndent; int oneIndent; String CR = ""; TTypedValue firstElement; String sIndent = ""; //determine how much to indent this description oneIndent = 0; nextIndent = -1; if (indent > -1) { CR = Environment.NewLine; oneIndent = tab; nextIndent = indent + oneIndent; sIndent = new String(' ', nextIndent); //begin at this level } StringBuilder xml = new StringBuilder(""); if (attrInfo.baseType() != TBaseType.ITYPE_DEF) { xml.Append(" kind=\"" + attrInfo.typeName() + "\""); } if (attrInfo.isArray()) { xml.Append(" array=\"T\""); } if ((attrInfo.units().Length > 0) && (attrInfo.units()[0] != '-')) { xml.Append(" unit=\"" + attrInfo.units() + "\""); } //now nest into the fields/elements for this DDML type if (!attrInfo.isScalar()) { xml.Append(">" + CR); if (attrInfo.isArray() && (attrInfo.baseType() == TBaseType.ITYPE_DEF)) //an array will only show the first child for DDML { if (attrInfo.count() == 0) { firstElement = attrInfo.item(0); } else { firstElement = attrInfo.item(1); } elementType = "element"; xml.Append(sIndent + "<" + elementType); xml.Append(writeFieldInfo(firstElement, nextIndent, oneIndent)); if (!firstElement.isScalar()) { xml.Append(sIndent + "</" + elementType + ">" + CR); } } else if (attrInfo.isRecord()) { for (i = 1; i <= attrInfo.count(); i++) //for each child field { elementType = "field"; xml.Append(sIndent + "<" + elementType + " name=\"" + attrInfo.item(i).Name + "\""); xml.Append(writeFieldInfo(attrInfo.item(i), nextIndent, oneIndent)); if (!attrInfo.item(i).isScalar()) { xml.Append(sIndent + "</" + elementType + ">" + CR); } } } } else { xml.Append("/>" + CR); } return(xml.ToString()); }
//===================================================================== /// <summary> /// /// </summary> /// <param name="typedValue"></param> public TAFTreeViewColumnTag(TTypedValue typedValue) { _typedValue = typedValue; //_sColumnData = ipsColumnData; _sVariable = _typedValue.Name; _sValue = _typedValue.asString(); _sType = _typedValue.typeName(); if (_sType.ToLower().Equals("defined") || (_typedValue.isRecord() == true)) { _sType = "record"; } if (_typedValue.isArray()) { _sType = "array"; } _sUnit = _typedValue.units(); if (typedValue is TInitValue) { TInitValue initValue = _typedValue as TInitValue; _sDescr = initValue.getDescr(); if (initValue.getDefault() != null) { _sDefault = initValue.getDefault().asString(); } else { _sDefault = ""; } if (initValue.getMin() != null) { _sMin = initValue.getMin().asString(); } else { _sMin = ""; } if (initValue.getMax() != null) { //_sMax = Math.Round( initValue.getMax().asDouble(),3).ToString(); _sMax = initValue.getMax().asString(); //initValue.getMax().typeName() //double dMaxValue = double.MaxValue; //switch (initValue.baseType()) //{ // case TTypedValue.TBaseType.ITYPE_INT1: // { // //FMax.setValue(+VERYLARGE_I1); // //FMin.setValue(-VERYLARGE_I1); // } break; // case TTypedValue.TBaseType.ITYPE_INT2: // { // //FMax.setValue(+VERYLARGE_I2); // //FMin.setValue(-VERYLARGE_I2); // } break; // case TTypedValue.TBaseType.ITYPE_INT4: // { // //FMax.setValue(+VERYLARGE_I4); // //FMin.setValue(-VERYLARGE_I4); // } break; // case TTypedValue.TBaseType.ITYPE_INT8: // { // //FMax.setValue(+VERYLARGE_I8); // //FMin.setValue(-VERYLARGE_I8); // } break; // case TTypedValue.TBaseType.ITYPE_SINGLE: // { // //FMax.setValue(+1.0 * VERYLARGE_S); // //FMin.setValue(-1.0 * VERYLARGE_S); // } break; // case TTypedValue.TBaseType.ITYPE_DOUBLE: // { // dMaxValue = TInitValue.VERYLARGE_D_POS; // //FMin.setValue(VERYLARGE_D_NEG); // } break; //} //if (initValue.getMax().asDouble() == dMaxValue) //{ // Console.WriteLine("equal"); // _sMax = ""; //} } else { _sMax = ""; } } }
//============================================================================ /// <summary> /// Writes the SDML value as XML. /// </summary> /// <param name="attrInfo">The typed value to use.</param> /// <param name="indent">Indent spaces to use. -1 = no indent.</param> /// <param name="tab">Number of spaces in each tab</param> /// <returns>The XML for the SDML value.</returns> //============================================================================ protected override String writeFieldInfo(TTypedValue attrInfo, int indent, int tab) { uint i; int oneIndent; int nextIndent; int startIndent; String CR = ""; //determine how much to indent this description oneIndent = 0; startIndent = 0; if (indent > -1) { oneIndent = tab; startIndent = indent; CR = "\r\n"; } String sIndent = new String(' ', startIndent); //begin at this level nextIndent = indent + oneIndent; StringBuilder xml = new StringBuilder(""); if (attrInfo.baseType() != TTypedValue.TBaseType.ITYPE_DEF) { xml.Append(" kind=\"" + attrInfo.typeName() + "\""); } if (attrInfo.isArray()) { xml.Append(" array=\"T\""); } if ((attrInfo.units().Length > 0) && (attrInfo.units()[0] != '-')) { xml.Append(" unit=\"" + attrInfo.units() + "\""); } xml.Append(">" + CR); if (attrInfo.isScalar()) // Scalars - use a <val> element { xml.Append(sIndent + "<val>" + scalarString(attrInfo) + "</val>" + CR); } else { //now nest into the fields/elements for (i = 1; i <= attrInfo.count(); i++) { if (attrInfo.isArray() && (attrInfo.baseType() != TTypedValue.TBaseType.ITYPE_DEF)) { xml.Append(new String(' ', oneIndent) + "<val>" + scalarString(attrInfo.item(i)) + "</val>" + CR); // Scalar array, indented format } else if (attrInfo.isArray()) // All other arrays { xml.Append(sIndent + "<element" + writeFieldInfo(attrInfo.item(i), nextIndent, oneIndent) + sIndent + "</element>" + CR); } else if (attrInfo.isRecord()) // Records { xml.Append(sIndent + "<field name=\"" + attrInfo.item(i).Name + "\"" + writeFieldInfo(attrInfo.item(i), nextIndent, oneIndent) + sIndent + "</field>" + CR); } } } return(xml.ToString()); }