예제 #1
0
        /// <summary>
        /// Update all values of given COSEM object.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="view"></param>
        public static void UpdateProperties(IGXDLMSBase obj, IGXDLMSView view)
        {
            if (obj == null)
            {
                return;
            }
            GXDLMSObject tmp = view.Target;

            view.Description = tmp.Description;
            //If we want to show what properties are changed.
            if (view.ErrorProvider != null)
            {
                view.ErrorProvider.Clear();
                foreach (int it in tmp.GetDirtyAttributeIndexes())
                {
                    UpdateDirty(view, ((Form)view).Controls, tmp, it, true);
                }
            }
            //Update atribute values.
            for (int it = 1; it != obj.GetAttributeCount() + 1; ++it)
            {
                object value = null;
                bool   dirty = view.Target.GetDirty(it, out value);
                value = view.Target.GetValues()[it - 1];
                bool bFound = UpdateProperty(view, ((Form)view).Controls, it, value);
                if (!bFound)
                {
                    view.OnAccessRightsChange(it, view.Target.GetAccess(it));
                }
                if (!bFound)
                {
                    view.OnValueChanged(it, value, false);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Update selected values of given COSEM object.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="view"></param>
        public static void UpdateProperty(GXDLMSClient client, GXDLMSObject obj, int index, IGXDLMSView view, bool connected, bool user)
        {
            if (obj == null)
            {
                return;
            }
            if ((view as Form).InvokeRequired)
            {
                try
                {
                    (view as Form).BeginInvoke(new UpdatePropertyEventHandler(UpdateProperty), client, obj, index, view, connected, user);
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(view as Form, ex.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                }
                return;
            }
            GXDLMSObject tmp = view.Target;

            view.Description = tmp.Description;
            //If we want to show what properties are changed.
            if (view.ErrorProvider != null)
            {
                view.ErrorProvider.Clear();
                foreach (int it in tmp.GetDirtyAttributeIndexes())
                {
                    UpdateDirty(view, ((Form)view).Controls, tmp, it, true);
                }
            }
            //Update atribute values.
            for (int it = 1; it != (obj as IGXDLMSBase).GetAttributeCount() + 1; ++it)
            {
                if (index == 0 || it == index)
                {
                    object value = null;
                    bool   dirty = view.Target.GetDirty(it, out value);
                    value = view.Target.GetValues()[it - 1];
                    GXValueField item = UpdateProperty(view, ((Form)view).Controls, it, value);
                    if (item == null || item.NotifyChanges)
                    {
                        GXDLMSViewArguments arg = new GXDLMSViewArguments()
                        {
                            Client = client, Index = it, Connected = connected, User = user, Value = value
                        };
                        view.OnValueChanged(arg);
                    }
                    if (it == index)
                    {
                        break;
                    }
                }
            }
        }