Example #1
0
 void IGXDLMSBase.Load(GXXmlReader reader)
 {
     Time      = reader.ReadElementContentAsDateTime("Time");
     TimeZone  = reader.ReadElementContentAsInt("TimeZone");
     Status    = (ClockStatus)reader.ReadElementContentAsInt("Status");
     Begin     = reader.ReadElementContentAsDateTime("Begin");
     End       = reader.ReadElementContentAsDateTime("End");
     Deviation = reader.ReadElementContentAsInt("Deviation");
     Enabled   = reader.ReadElementContentAsInt("Enabled") != 0;
     ClockBase = (ClockBase)reader.ReadElementContentAsInt("ClockBase");
 }
Example #2
0
        void IGXDLMSBase.Load(GXXmlReader reader)
        {
            if (string.Compare("Time", reader.Name, true) == 0)
            {
                Time = new GXDateTime(reader.ReadElementContentAsString("Time"), CultureInfo.InvariantCulture);
            }
            TimeZone = reader.ReadElementContentAsInt("TimeZone");
            Status   = (ClockStatus)reader.ReadElementContentAsInt("Status");
            string str = reader.ReadElementContentAsString("Begin");

            if (str != null)
            {
                Begin = new GXDateTime(str, CultureInfo.InvariantCulture);
            }
            str = reader.ReadElementContentAsString("End");
            if (str != null)
            {
                End = new GXDateTime(str, CultureInfo.InvariantCulture);
            }
            Deviation = reader.ReadElementContentAsInt("Deviation");
            Enabled   = reader.ReadElementContentAsInt("Enabled") != 0;
            ClockBase = (ClockBase)reader.ReadElementContentAsInt("ClockBase");
        }
Example #3
0
 void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         LogicalName = GXCommon.ToLogicalName(e.Value);
     }
     else if (e.Index == 2)
     {
         if (e.Value == null)
         {
             Time = new GXDateTime(DateTime.MinValue);
         }
         else
         {
             if (e.Value is byte[])
             {
                 e.Value = GXDLMSClient.ChangeType((byte[])e.Value, DataType.DateTime, settings.UseUtc2NormalTime);
             }
             else if (e.Value is string)
             {
                 e.Value = new GXDateTime((string)e.Value);
             }
             if (e.Value is GXDateTime)
             {
                 Time = (GXDateTime)e.Value;
             }
             else if (e.Value is String)
             {
                 DateTime tm;
                 if (!DateTime.TryParse((String)e.Value, out tm))
                 {
                     Time = DateTime.ParseExact((String)e.Value, CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern + " " + CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern, CultureInfo.CurrentUICulture);
                 }
                 else
                 {
                     Time = tm;
                 }
             }
             else
             {
                 Time = Convert.ToDateTime(e.Value);
             }
         }
     }
     else if (e.Index == 3)
     {
         TimeZone = Convert.ToInt32(e.Value);
     }
     else if (e.Index == 4)
     {
         Status = (ClockStatus)Convert.ToInt32(e.Value);
     }
     else if (e.Index == 5)
     {
         if (e.Value == null)
         {
             Begin = new GXDateTime(DateTime.MinValue);
         }
         else
         {
             if (e.Value is byte[])
             {
                 e.Value = GXDLMSClient.ChangeType((byte[])e.Value, DataType.DateTime, settings.UseUtc2NormalTime);
             }
             else if (e.Value is string)
             {
                 e.Value = new GXDateTime((string)e.Value);
             }
             Begin = (GXDateTime)e.Value;
         }
     }
     else if (e.Index == 6)
     {
         if (e.Value == null)
         {
             End = new GXDateTime(DateTime.MinValue);
         }
         else
         {
             if (e.Value is byte[])
             {
                 e.Value = GXDLMSClient.ChangeType((byte[])e.Value, DataType.DateTime, settings.UseUtc2NormalTime);
             }
             else if (e.Value is string)
             {
                 e.Value = new GXDateTime((string)e.Value);
             }
             End = (GXDateTime)e.Value;
         }
     }
     else if (e.Index == 7)
     {
         Deviation = Convert.ToInt32(e.Value);
     }
     else if (e.Index == 8)
     {
         Enabled = Convert.ToBoolean(e.Value);
         if (settings.IsServer)
         {
             if (Enabled)
             {
                 Status |= ClockStatus.DaylightSavingActive;
             }
             else
             {
                 Status &= ~ClockStatus.DaylightSavingActive;
             }
         }
     }
     else if (e.Index == 9)
     {
         ClockBase = (ClockBase)Convert.ToInt32(e.Value);
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }
Example #4
0
 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)
     {
         if (value == null)
         {
             Time = new GXDateTime(DateTime.MinValue);
         }
         else
         {
             if (value is byte[])
             {
                 value = GXDLMSClient.ChangeType((byte[])value, DataType.DateTime);
             }
             Time = (GXDateTime)value;
         }
     }
     else if (index == 3)
     {
         TimeZone = Convert.ToInt32(value);
     }
     else if (index == 4)
     {
         Status = (ClockStatus)Convert.ToInt32(value);
     }
     else if (index == 5)
     {
         if (value == null)
         {
             Begin = new GXDateTime(DateTime.MinValue);
         }
         else
         {
             if (value is byte[])
             {
                 value = GXDLMSClient.ChangeType((byte[])value, DataType.DateTime);
             }
             Begin = (GXDateTime)value;
         }
     }
     else if (index == 6)
     {
         if (value == null)
         {
             End = new GXDateTime(DateTime.MinValue);
         }
         else
         {
             if (value is byte[])
             {
                 value = GXDLMSClient.ChangeType((byte[])value, DataType.DateTime);
             }
             End = (GXDateTime)value;
         }
     }
     else if (index == 7)
     {
         Deviation = Convert.ToInt32(value);
     }
     else if (index == 8)
     {
         Enabled = Convert.ToBoolean(value);
     }
     else if (index == 9)
     {
         ClockBase = (ClockBase)Convert.ToInt32(value);
     }
     else
     {
         throw new ArgumentException("SetValue failed. Invalid attribute index.");
     }
 }
Example #5
0
 void IGXDLMSBase.SetValue(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)
     {
         if (value == null)
         {
             Time = new GXDateTime(DateTime.MinValue);
         }
         else
         {
             if (value is byte[])
             {
                 value = GXDLMSClient.ChangeType((byte[]) value, DataType.DateTime);
             }                    
             Time = (GXDateTime)value;
         }
     }
     else if (index == 3)
     {
         TimeZone = Convert.ToInt32(value);
     }
     else if (index == 4)
     {
         Status = (ClockStatus)Convert.ToInt32(value);
     }
     else if (index == 5)
     {
         if (value == null)
         {
             Begin = new GXDateTime(DateTime.MinValue);
         }
         else
         {
             if (value is byte[])
             {
                 value = GXDLMSClient.ChangeType((byte[])value, DataType.DateTime);
             }
             Begin = (GXDateTime)value;
         }                
     }
     else if (index == 6)
     {
         if (value == null)
         {
             End = new GXDateTime(DateTime.MinValue);
         }
         else
         {
             if (value is byte[])
             {
                 value = GXDLMSClient.ChangeType((byte[])value, DataType.DateTime);
             }
             End = (GXDateTime)value;
         }                
     }
     else if (index == 7)
     {
         Deviation = Convert.ToInt32(value);
     }
     else if (index == 8)
     {
         Enabled = Convert.ToBoolean(value);
     }
     else if (index == 9)
     {
         ClockBase = (ClockBase)Convert.ToInt32(value);
     }
     else
     {
         throw new ArgumentException("SetValue failed. Invalid attribute index.");
     }
 }
Example #6
0
 void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         if (e.Value is string)
         {
             LogicalName = e.Value.ToString();
         }
         else if (e.Value != null)
         {
             LogicalName = GXDLMSClient.ChangeType((byte[])e.Value, DataType.OctetString).ToString();
         }
     }
     else if (e.Index == 2)
     {
         if (e.Value == null)
         {
             Time = new GXDateTime(DateTime.MinValue);
         }
         else
         {
             if (e.Value is byte[])
             {
                 e.Value = GXDLMSClient.ChangeType((byte[])e.Value, DataType.DateTime);
             }
             if (e.Value is GXDateTime)
             {
                 Time = (GXDateTime)e.Value;
             }
             else if (e.Value is String)
             {
                 Time = DateTime.ParseExact((String)e.Value, CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern + " " + CultureInfo.CurrentUICulture.DateTimeFormat.LongTimePattern, CultureInfo.CurrentUICulture);
             }
             else
             {
                 Time = Convert.ToDateTime(e.Value);
             }
         }
     }
     else if (e.Index == 3)
     {
         TimeZone = Convert.ToInt32(e.Value);
     }
     else if (e.Index == 4)
     {
         Status = (ClockStatus)Convert.ToInt32(e.Value);
     }
     else if (e.Index == 5)
     {
         if (e.Value == null)
         {
             Begin = new GXDateTime(DateTime.MinValue);
         }
         else
         {
             if (e.Value is byte[])
             {
                 e.Value = GXDLMSClient.ChangeType((byte[])e.Value, DataType.DateTime);
             }
             Begin = (GXDateTime)e.Value;
         }
     }
     else if (e.Index == 6)
     {
         if (e.Value == null)
         {
             End = new GXDateTime(DateTime.MinValue);
         }
         else
         {
             if (e.Value is byte[])
             {
                 e.Value = GXDLMSClient.ChangeType((byte[])e.Value, DataType.DateTime);
             }
             End = (GXDateTime)e.Value;
         }
     }
     else if (e.Index == 7)
     {
         Deviation = Convert.ToInt32(e.Value);
     }
     else if (e.Index == 8)
     {
         Enabled = Convert.ToBoolean(e.Value);
     }
     else if (e.Index == 9)
     {
         ClockBase = (ClockBase)Convert.ToInt32(e.Value);
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }