コード例 #1
0
        private void ProcessAttributes(AFAttributes attributes, string prefix)
        {
            foreach (AFAttribute attr in attributes)
            {
                if (attr == fDataReference.Attribute)
                {
                    continue;
                }

                string attrName = prefix + "|" + attr.Name;

                if (TransformerCore.IsNumericVal(attr.Type))
                {
                    cmbSourceAttribute.Items.Add(attrName);
                }

                ProcessAttributes(attr.Attributes, attrName);
            }
        }
コード例 #2
0
        private AFValue Calculate(AFValues inputValues)
        {
            MethodEnum method;

            if (!Enum.TryParse(ConvertMethod, out method))
            {
                throw new ArgumentException(Resources.ERR_NoBitSpecified);
            }

            if (inputValues == null || inputValues.Count == 0)
            {
                throw new ArgumentException(Resources.ERR_NoInputValues);
            }

            AFValue    inVal = inputValues[0];
            AFDatabase db    = inVal.Attribute.Database;

            if (db == null)
            {
                throw new ArgumentException("No db found");
            }

            object objVal = inVal.Value;

            if (inVal.IsGood && objVal != null)
            {
                if (TransformerCore.IsNumericVal(objVal))
                {
                    AFValue newVal;

                    switch (method)
                    {
                    default:
                    case MethodEnum.None:
                        newVal = new AFValue(objVal, inVal.Timestamp, inVal.UOM);
                        break;

                    case MethodEnum.Simple:
                        var targetUOMAttrS = AFAttribute.FindAttribute("UOM", Attribute);
                        newVal = Convert(inVal, db, targetUOMAttrS);
                        break;

                    case MethodEnum.Full:
                        var sourceUOMAttr = AFAttribute.FindAttribute("UOM", inVal.Attribute);
                        newVal = Convert(inVal, db, sourceUOMAttr);
                        var targetUOMAttrF = AFAttribute.FindAttribute("UOM", Attribute);
                        newVal = Convert(newVal, db, targetUOMAttrF);
                        break;
                    }

                    return(newVal);
                }
                else
                {
                    throw new ArgumentException(Resources.ERR_SourceAttributeMustBeAnIntegerType);
                }
            }
            else
            {
                return(AFValue.CreateSystemStateValue(Attribute, AFSystemStateCode.BadInput, inVal.Timestamp));
            }
        }