예제 #1
0
        /// <summary>
        /// Gets the columm value - applying special procedure for certain <c>PropertyEntryColumn</c>
        /// </summary>
        /// <param name="column">The column.</param>
        /// <param name="input">The input.</param>
        /// <returns></returns>
        public Object getColumn(PropertyEntryColumn column, Object input)
        {
            if (imbSciStringExtensions.isNullOrEmptyString(input))
            {
                input = "";
            }
            switch (column)
            {
            case PropertyEntryColumn.entry_importance:

                if (input is IValueWithImportanceInfo)
                {
                    IValueWithImportanceInfo input_IValueWithImportanceInfo = (IValueWithImportanceInfo)input;
                    if (input_IValueWithImportanceInfo.isValueInAlarmRange)
                    {
                        return(dataPointImportance.alarm);
                    }
                }

                return(this[PropertyEntryColumn.entry_importance]);

                break;

            case PropertyEntryColumn.entry_value:

                if (input is IValueWithToString)
                {
                    IValueWithToString input_IValueWithToString = (IValueWithToString)input;
                    return(input_IValueWithToString.GetFormatedValue());
                }

                return(input.toStringSafe());

                break;

            case PropertyEntryColumn.entry_valueAndUnit:
                if (input is IValueWithToString)
                {
                    IValueWithToString input_IValueWithToString = (IValueWithToString)input;
                    return(input_IValueWithToString.GetFormatedValueAndUnit());
                }

                return(imbSciStringExtensions.add(input.toStringSafe(), this[PropertyEntryColumn.entry_unit].ToString(), " "));

                break;

            default:
                return(this[column]);

                break;
            }

            return("");
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PropertyEntry"/> class.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="value">The value.</param>
        /// <param name="name">Initial value for Display Name</param>
        /// <param name="description">Initial description - overide of description found in <c>value</c> object</param>
        /// <param name="relevance">The relevance - override of info found in <c>value</c></param>
        /// <seealso cref="imbSCI.Core.interfaces.IValueWithRoleInfo"/>
        /// <seealso cref="imbSCI.Core.interfaces.IValueWithUnitInfo"/>
        /// <seealso cref="imbSCI.Core.interfaces.IValueWithImportanceInfo"/>
        /// <seealso cref="IObjectWithNameAndDescription"/>
        public PropertyEntry(Object key, Object value, String name = "", String description = "", dataPointImportance relevance = dataPointImportance.normal)
        {
            // this.setFromEnumType(typeof(PropertyEntryColumn));

            this[PropertyEntryColumn.entry_key] = key;

            Object input = value;

            this[PropertyEntryColumn.entry_name]        = name;
            this[PropertyEntryColumn.entry_description] = description;
            this[PropertyEntryColumn.entry_importance]  = relevance.ToString();

            this[PropertyEntryColumn.entry_value] = value;

            if (value is IValueWithUnitInfo)
            {
                IValueWithUnitInfo value_IValueWithUnitInfo = (IValueWithUnitInfo)value;
                this[PropertyEntryColumn.entry_unit]     = value_IValueWithUnitInfo.unit_sufix;
                this[PropertyEntryColumn.entry_unitname] = value_IValueWithUnitInfo.unit_name;
            }

            if (input is IValueWithRoleInfo)
            {
                IValueWithRoleInfo input_IValueWithRoleInfo = (IValueWithRoleInfo)input;
                this[PropertyEntryColumn.role_letter] = input_IValueWithRoleInfo.role_letter;
                this[PropertyEntryColumn.role_name]   = input_IValueWithRoleInfo.role_name;
                this[PropertyEntryColumn.role_symbol] = input_IValueWithRoleInfo.role_symbol;
            }

            if (input is IObjectWithNameAndDescription)
            {
                IObjectWithNameAndDescription input_IObjectWithNameAndDescription = (IObjectWithNameAndDescription)input;

                this[PropertyEntryColumn.entry_name]        = input_IObjectWithNameAndDescription.name;
                this[PropertyEntryColumn.entry_description] = input_IObjectWithNameAndDescription.description;
            }

            if (input is IValueWithImportanceInfo)
            {
                IValueWithImportanceInfo input_IValueWithImportanceInfo = (IValueWithImportanceInfo)input;
                this[PropertyEntryColumn.entry_importance] = input_IValueWithImportanceInfo.relevance.ToString();
            }

            if (imbSciStringExtensions.isNullOrEmptyString(this[PropertyEntryColumn.entry_name]))
            {
                this[PropertyEntryColumn.entry_name] = key.ToString().imbTitleCamelOperation(true);
            }

            if (imbSciStringExtensions.isNullOrEmptyString(this[PropertyEntryColumn.entry_description]))
            {
                //this[PropertyEntryColumn.entry_description] = this.  this.getStringLine(",", PropertyEntryColumn.role_name, PropertyEntryColumn.entry_unitname, PropertyEntryColumn.role_letter);
            }
        }
예제 #3
0
        /// <summary>
        /// Sets the item.
        /// </summary>
        /// <param name="pi">The pi.</param>
        protected void setItem(PropertyInfo pi)
        {
            basicDisplayItem displayInfo = new basicDisplayItem(pi);

            bdis.Add(pi, displayInfo);

            if (displayGroup == null)
            {
                displayGroup = displayGroups["Main"];
            }

            if (displayInfo.attributes.ContainsKey(imbAttributeName.measure_displayGroup))
            {
                displayGroup = displayGroups[displayInfo.attributes.getMessage(imbAttributeName.measure_displayGroup, "Main")];

                if (displayGroup.description.isNullOrEmptyString())
                {
                    displayGroup.description = displayInfo.attributes.getMessage(imbAttributeName.measure_displayGroupDescripton, ".");
                }
            }
            else
            {
                //pi.getAttributeValueOrDefault<DescriptionAttribute>(displayGroup, pi)
            }

            Int32 priority = displayInfo.attributes.getMessage <Int32>(imbAttributeName.viewPriority, 100);

            calcGroupId = displayInfo.attributes.getMessage <Int32>(imbAttributeName.measure_calcGroup, calcGroupId);

            Object tmp = pi.PropertyType.getInstance();

            if (tmp is IObjectWithNameAndDescription)
            {
                IObjectWithNameAndDescription tmp_IObjectWithName = (IObjectWithNameAndDescription)tmp;
                tmp_IObjectWithName.name        = displayInfo.displayName;
                tmp_IObjectWithName.description = displayInfo.description;
            }

            if (tmp is IValueWithImportanceInfo)
            {
                IValueWithImportanceInfo tmp_IValueWithImportanceInfo = (IValueWithImportanceInfo)tmp;
                tmp_IValueWithImportanceInfo.relevance = displayInfo.attributes.getMessage <dataPointImportance>(imbAttributeName.measure_important, dataPointImportance.normal);
            }

            if (tmp is IMeasure)
            {
                IMeasure im = (IMeasure)tmp;

                im.isAlarmTurnedOn = displayInfo.attributes.ContainsKey(imbAttributeName.measure_setAlarm);
                im.valueRange.setValueRange(displayInfo.attributes.getMessage <aceRangeConfig>(imbAttributeName.measure_setRange));
                im.alarmCriteria.setCriteria(displayInfo.attributes.getMessage <aceCriterionConfig>(imbAttributeName.measure_setAlarm));

                im.metaModelName   = displayInfo.attributes.getMessage(imbAttributeName.measure_metaModelName, im.name);
                im.metaModelPrefix = displayInfo.attributes.getMessage(imbAttributeName.measure_metaModelPrefix, "MN");

                im.doUnitOptimization = displayInfo.attributes.getMessage <Boolean>(imbAttributeName.measure_optimizeUnit, false);

                Tuple <Enum, String, String, String, String> tup = displayInfo.attributes.getMessageObj(imbAttributeName.measure_setRole) as Tuple <Enum, String, String, String, String>;
                if (tup != null)
                {
                    //im.setCustomRoleEntry(bDI.attributes.getMessageObj(imbAttributeName.measure_setRole) as Tuple<Enum, String, String, String, String>)
                    im.info.unit = im.getUnitEntry(displayInfo.attributes.getMessage <measureSystemUnitEntry>(imbAttributeName.measure_setUnit));
                    im.info.role = im.getRoleEntry(displayInfo.attributes.getMessage <measureSystemUnitEntry>(imbAttributeName.measure_setRole));
                }

                //displayGroup.AddAtEnd(im);

                //calcGroups[calcGroupId].AddAtEnd(im);
            }

            //Add(pi.Name, tmp);
        }