/// <summary> /// The Values content /// </summary> public string GetText(int depth) { string tab = ""; for (int i = 0; i < depth; i++) { tab += " "; } string retVal = tab += "Values:\n"; if (getResolution_formula_1() != null) { ResolutionFormula resForm = getResolution_formula_1() as ResolutionFormula; retVal += resForm.GetText(depth + 1); } if (getSpecial_or_reserved_value() != null) { SpecialOrReservedValue value = getSpecial_or_reserved_value() as SpecialOrReservedValue; retVal += value.GetText(depth + 1); } if (getSpecial_or_reserved_values() != null) { SpecialOrReservedValues values = getSpecial_or_reserved_values() as SpecialOrReservedValues; retVal += values.GetText(depth + 1); } return(retVal); }
public override resolution_formula createresolution_formula() { resolution_formula retVal = new ResolutionFormula(); _defaultValueSetter.SetDefaultValue(retVal); return(retVal); }
/// <summary> /// Appends the corresponding type to the name space /// </summary> /// <param name="nameSpace">The namespace in which the type must be added</param> /// <param name="name">the name of the type</param> /// <param name="type">the type to convert</param> private DataDictionary.Types.Type AppendType(DataDictionary.Types.NameSpace nameSpace, string name, ErtmsSolutions.CodecNT.Type type) { DataDictionary.Types.Type retVal = null; if (EFSType(type) == null) { if (type.value is UiValue) { UiValue uiValue = type.value as UiValue; List <DataDictionary.Constants.EnumValue> values = getSpecialValues(uiValue.special_or_reserved_values); Decimal maxValue = twoPow(type.length) - 1; if (IsEnumeration(values, maxValue)) { DataDictionary.Types.Enum enumeration = (DataDictionary.Types.Enum)DataDictionary.Generated.acceptor.getFactory().createEnum(); enumeration.Name = type.id; enumeration.Default = values[0].Name; foreach (DataDictionary.Constants.EnumValue value in values) { enumeration.appendValues(value); } nameSpace.appendEnumerations(enumeration); retVal = enumeration; } else { DataDictionary.Types.Range range = (DataDictionary.Types.Range)DataDictionary.Generated.acceptor.getFactory().createRange(); range.Name = type.id; double factor = 1.0; System.Globalization.CultureInfo info = System.Globalization.CultureInfo.InvariantCulture; ResolutionFormula resolutionFormula = uiValue.resolution_formula; if (resolutionFormula != null && resolutionFormula.Value != null) { factor = double.Parse(resolutionFormula.Value, info); // In that case the precision is integer range.setPrecision(DataDictionary.Generated.acceptor.PrecisionEnum.aIntegerPrecision); range.MinValue = "0"; range.MaxValue = "" + maxValue; range.Default = "0"; } else { if (Math.Round(factor) == factor) { // Integer precision range.setPrecision(DataDictionary.Generated.acceptor.PrecisionEnum.aIntegerPrecision); range.MinValue = "0"; range.MaxValue = "" + maxValue * new Decimal(factor); range.Default = "0"; } else { // Double precision range.setPrecision(DataDictionary.Generated.acceptor.PrecisionEnum.aDoublePrecision); range.MinValue = "0.0"; range.MaxValue = (maxValue * new Decimal(factor)).ToString(info); range.Default = "0.0"; } } foreach (DataDictionary.Constants.EnumValue value in values) { range.appendSpecialValues(value); } nameSpace.appendRanges(range); retVal = range; } } else if (type.value is CharValue) { CharValue charValue = type.value as CharValue; // Nothing to do : translated into string } else if (type.value is BcdValue) { BcdValue bcdValue = type.value as BcdValue; DataDictionary.Types.Range range = (DataDictionary.Types.Range)DataDictionary.Generated.acceptor.getFactory().createRange(); range.Name = type.id; range.MinValue = "0"; range.MaxValue = "" + (twoPow(type.length) - 1); range.Default = "0"; nameSpace.appendRanges(range); retVal = range; } if (retVal != null) { retVal.Comment = type.short_description; if (type.description != null) { retVal.Comment = retVal.Comment + "\n" + type.description; } } } return(retVal); }