Example #1
0
        void IGXDLMSBase.Load(GXXmlReader reader)
        {
            List <GXDLMSObjectDefinition> list = new List <GXDLMSObjectDefinition>();

            if (reader.IsStartElement("RegisterAssignment", true))
            {
                while (reader.IsStartElement("Item", true))
                {
                    GXDLMSObjectDefinition it = new GXDLMSObjectDefinition();
                    it.ObjectType  = (ObjectType)reader.ReadElementContentAsInt("ObjectType");
                    it.LogicalName = reader.ReadElementContentAsString("LN");
                    list.Add(it);
                }
                reader.ReadEndElement("RegisterAssignment");
            }
            RegisterAssignment = list.ToArray();
            MaskList.Clear();
            if (reader.IsStartElement("MaskList", true))
            {
                while (reader.IsStartElement("Item", true))
                {
                    byte[] mask = GXDLMSTranslator.HexToBytes(reader.ReadElementContentAsString("Mask"));
                    byte[] i    = GXDLMSTranslator.HexToBytes(reader.ReadElementContentAsString("Index"));
                    MaskList.Add(new KeyValuePair <byte[], byte[]>(mask, i));
                }
                reader.ReadEndElement("MaskList");
            }
            ActiveMask = GXDLMSTranslator.HexToBytes(reader.ReadElementContentAsString("ActiveMask"));
        }
Example #2
0
 void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         if (e.Value is string)
         {
             LogicalName = e.Value.ToString();
         }
         else
         {
             LogicalName = GXDLMSClient.ChangeType((byte[])e.Value, DataType.OctetString).ToString();
         }
     }
     else if (e.Index == 2)
     {
         List <GXDLMSObjectDefinition> items = new List <GXDLMSObjectDefinition>();
         if (e.Value != null)
         {
             foreach (Object[] it in (Object[])e.Value)
             {
                 GXDLMSObjectDefinition item = new GXDLMSObjectDefinition();
                 item.ObjectType  = (ObjectType)Convert.ToInt32(it[0]);
                 item.LogicalName = GXDLMSObject.ToLogicalName((byte[])it[1]);
                 items.Add(item);
             }
         }
         RegisterAssignment = items.ToArray();
     }
     else if (e.Index == 3)
     {
         MaskList.Clear();
         if (e.Value != null)
         {
             foreach (Object[] it in (Object[])e.Value)
             {
                 List <byte> index_list = new List <byte>();
                 foreach (byte b in (Object[])it[1])
                 {
                     index_list.Add(b);
                 }
                 MaskList.Add(new KeyValuePair <byte[], byte[]>((byte[])it[0], index_list.ToArray()));
             }
         }
     }
     else if (e.Index == 4)
     {
         if (e.Value == null)
         {
             ActiveMask = null;
         }
         else
         {
             ActiveMask = (byte[])e.Value;
         }
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }
 void IGXDLMSBase.SetValue(GXDLMSSettings settings, int index, object value)
 {
     if (index == 1)
     {
         if (value is string)
         {
             LogicalName = value.ToString();
         }
         else
         {
             LogicalName = GXDLMSClient.ChangeType((byte[])value, DataType.OctetString).ToString();
         }
     }
     else if (index == 2)
     {
         List <GXDLMSObjectDefinition> items = new List <GXDLMSObjectDefinition>();
         if (value != null)
         {
             foreach (Object[] it in (Object[])value)
             {
                 GXDLMSObjectDefinition item = new GXDLMSObjectDefinition();
                 item.ClassId     = (ObjectType)Convert.ToInt32(it[0]);
                 item.LogicalName = GXDLMSObject.ToLogicalName((byte[])it[1]);
                 items.Add(item);
             }
         }
         RegisterAssignment = items.ToArray();
     }
     else if (index == 3)
     {
         MaskList.Clear();
         if (value != null)
         {
             foreach (Object[] it in (Object[])value)
             {
                 List <byte> index_list = new List <byte>();
                 foreach (byte b in (Object[])it[1])
                 {
                     index_list.Add(b);
                 }
                 MaskList.Add(new KeyValuePair <byte[], byte[]>((byte[])it[0], index_list.ToArray()));
             }
         }
     }
     else if (index == 4)
     {
         if (value == null)
         {
             ActiveMask = null;
         }
         else
         {
             ActiveMask = (byte[])value;
         }
     }
     else
     {
         throw new ArgumentException("SetValue failed. Invalid attribute index.");
     }
 }
Example #4
0
 public void FillMaskList()
 {
     try
     {
         MaskList.Clear();
         string lType = Database.Tables[CurrentTable.TableId].Columns[CurrentColumn.ColumnId].Type;
         if (lType.Equals("int"))
         {
             MaskList.Add("Hash");
             MaskList.Add("Random Value");
             MaskList.Add("RangedValue");
             MaskList.Add("Offset");
             MaskList.Add("Shuffle");
         }
         else if (lType.Equals("varchar") || lType.Equals("nvarchar") || lType.Equals("varchar2") || lType.Equals("text"))
         {
             MaskList.Add("Random String Part");
             // MaskList.Add("Replace String Part");
             MaskList.Add("Substitution");
         }
         else if (lType.Equals("date") || lType.Equals("datetime") || lType.Equals("datetime2"))
         {
             MaskList.Add("Hash date");
         }
         else if (lType.Equals("bit"))
         {
             MaskList.Add("Random Value");
         }
         else if (lType.Equals("float") || lType.Equals("double"))
         {
             MaskList.Add("Hash");
         }
     }
     catch
     {
     }
 }
Example #5
0
 void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         LogicalName = GXCommon.ToLogicalName(e.Value);
     }
     else if (e.Index == 2)
     {
         List <GXDLMSObjectDefinition> items = new List <GXDLMSObjectDefinition>();
         if (e.Value != null)
         {
             foreach (object tmp in (IEnumerable <object>)e.Value)
             {
                 List <object> it;
                 if (tmp is List <object> )
                 {
                     it = (List <object>)tmp;
                 }
                 else
                 {
                     it = new List <object>((object[])tmp);
                 }
                 GXDLMSObjectDefinition item = new GXDLMSObjectDefinition();
                 item.ObjectType  = (ObjectType)Convert.ToInt32(it[0]);
                 item.LogicalName = GXCommon.ToLogicalName((byte[])it[1]);
                 items.Add(item);
             }
         }
         RegisterAssignment = items.ToArray();
     }
     else if (e.Index == 3)
     {
         MaskList.Clear();
         if (e.Value != null)
         {
             foreach (object tmp in (IEnumerable <object>)e.Value)
             {
                 List <object> it;
                 if (tmp is List <object> )
                 {
                     it = (List <object>)tmp;
                 }
                 else
                 {
                     it = new List <object>((object[])tmp);
                 }
                 List <byte> index_list = new List <byte>();
                 foreach (byte b in (IEnumerable <object>)it[1])
                 {
                     index_list.Add(b);
                 }
                 MaskList.Add(new KeyValuePair <byte[], byte[]>((byte[])it[0], index_list.ToArray()));
             }
         }
     }
     else if (e.Index == 4)
     {
         if (e.Value == null)
         {
             ActiveMask = null;
         }
         else
         {
             ActiveMask = (byte[])e.Value;
         }
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }