Gurux.DLMS.Objects.GXDLMSObject.ClearDirty C# (CSharp) Méthode

ClearDirty() private méthode

private ClearDirty ( int attributeIndex ) : void
attributeIndex int
Résultat void
        public void ClearDirty(int attributeIndex)
        {
            DirtyAttributes.Remove(attributeIndex);
            if (OnChange != null)
            {
                OnChange(this, false, attributeIndex, null);
            }
        }

Usage Example

        public void Write(GXDLMSObject obj, object target, int index, List<object> UpdatedObjects)
        {
            object value;
            GXReplyData reply = new GXReplyData();
            for (int it = 1; it != (obj as IGXDLMSBase).GetAttributeCount() + 1; ++it)
            {
                reply.Clear();
                if (obj.GetDirty(it, out value))
                {
                    //Read DLMS data type if not known.
                    DataType type = obj.GetDataType(it);
                    if (type == DataType.None)
                    {
                        byte[] data = client.Read(obj, it)[0];
                        ReadDataBlock(data, "Write object type " + obj.ObjectType, reply);
                        type = reply.DataType;
                        if (type == DataType.None)
                        {
                            throw new Exception("Failed to write value. Data type not set.");
                        }
                        obj.SetDataType(it, type);
                    }
                    try
                    {
                        foreach (byte[] tmp in client.Write(obj.Name, value, type, obj.ObjectType, it))
                        {
                            ReadDataBlock(tmp, "Write object", reply);
                        }
                        obj.ClearDirty(it);
                        //Read data once again to make sure it is updated.
                        byte[] data = client.Read(obj, it)[0];
                        ReadDataBlock(data, "Read object " + obj.ObjectType, reply);

                        value = reply.Value;
                        if (value is byte[] && (type = obj.GetUIDataType(it)) != DataType.None)
                        {
                            value = GXDLMSClient.ChangeType((byte[])value, type);
                        }
                        client.UpdateValue(obj, it, value);
                    }
                    catch (GXDLMSException ex)
                    {
                        if (ex.ErrorCode == 3)
                        {
                            throw new Exception("Read/Write Failed.");
                        }
                        else
                        {
                            throw ex;
                        }
                    }
                }
            }
        }
All Usage Examples Of Gurux.DLMS.Objects.GXDLMSObject::ClearDirty