Example #1
0
        /// <summary>
        /// Get view for COSEM object.
        /// </summary>
        /// <param name="views">List of available views.</param>
        /// <param name="target">Selected COSEM object.</param>
        /// <returns>Assigned view.</returns>
        public static IGXDLMSView GetView(Dictionary <Type, List <IGXDLMSView> > views, GXDLMSObject target)
        {
            List <IGXDLMSView> v = views[target.GetType()];

            foreach (var it in v)
            {
                GXDLMSViewAttribute[] att = (GXDLMSViewAttribute[])it.GetType().GetCustomAttributes(typeof(GXDLMSViewAttribute), true);
                if (att.Length == 1 && Contains <byte>(att[0].Versions, (byte)target.Version))
                {
                    return(it);
                }
            }
            return(v[0]);
        }
Example #2
0
        /// <summary>
        /// Get view for COSEM object.
        /// </summary>
        /// <param name="views">List of available views.</param>
        /// <param name="target">Selected COSEM object.</param>
        /// <param name="standard">Used standard.</param>
        /// <returns>Assigned view.</returns>
        public static IGXDLMSView GetView(Dictionary <Type, List <IGXDLMSView> > views, GXDLMSObject target, Standard standard)
        {
            List <IGXDLMSView> v = views[target.GetType()];

            foreach (var it in v)
            {
                GXDLMSViewAttribute[] att = (GXDLMSViewAttribute[])it.GetType().GetCustomAttributes(typeof(GXDLMSViewAttribute), true);
                if (att.Length == 1 && Contains <byte>(att[0].Versions, (byte)target.Version) &&
                    Contains <Standard>(att[0].Standards, standard) &&
                    Contains <string>(att[0].LogicalNames, target.LogicalName))
                {
                    return(it);
                }
            }
            foreach (var it in v)
            {
                GXDLMSViewAttribute[] att = (GXDLMSViewAttribute[])it.GetType().GetCustomAttributes(typeof(GXDLMSViewAttribute), true);
                if (att.Length == 1 && Contains <byte>(att[0].Versions, (byte)target.Version) &&
                    Equals <Standard>(att[0].Standards, Standard.DLMS) && Contains <string>(att[0].LogicalNames, target.LogicalName))
                {
                    return(it);
                }
            }
            //Find default UI.
            foreach (var it in v)
            {
                GXDLMSViewAttribute[] att = (GXDLMSViewAttribute[])it.GetType().GetCustomAttributes(typeof(GXDLMSViewAttribute), true);
                if (att.Length == 1 && Contains <byte>(att[0].Versions, (byte)target.Version) &&
                    Equals <Standard>(att[0].Standards, Standard.DLMS) &&
                    Equals <string>(att[0].LogicalNames, null))
                {
                    return(it);
                }
            }
            return(v[0]);
        }