private static GXDLMSDayProfile[] LoadDayProfileTable(GXXmlReader reader, string name)
        {
            List <GXDLMSDayProfile> list = new List <GXDLMSDayProfile>();

            if (reader.IsStartElement(name, true))
            {
                while (reader.IsStartElement("Item", true))
                {
                    GXDLMSDayProfile it = new GXDLMSDayProfile();
                    it.DayId = reader.ReadElementContentAsInt("DayId");
                    list.Add(it);
                    List <GXDLMSDayProfileAction> actions = new List <GXDLMSDayProfileAction>();
                    if (reader.IsStartElement("Actions", true))
                    {
                        while (reader.IsStartElement("Action", true))
                        {
                            GXDLMSDayProfileAction d = new GXDLMSDayProfileAction();
                            actions.Add(d);
                            d.StartTime         = new GXTime(reader.ReadElementContentAsString("Start"), CultureInfo.InvariantCulture);
                            d.ScriptLogicalName = reader.ReadElementContentAsString("LN");
                            d.ScriptSelector    = (UInt16)reader.ReadElementContentAsInt("Selector");
                        }
                        reader.ReadEndElement("Actions");
                    }
                    it.DaySchedules = actions.ToArray();
                }
                reader.ReadEndElement(name);
            }
            return(list.ToArray());
        }
示例#2
0
 static GXDLMSDayProfile[] SetDayProfileTable(Object value)
 {
     if (value != null)
     {
         List <GXDLMSDayProfile> items = new List <GXDLMSDayProfile>();
         foreach (object[] item in (object[])value)
         {
             GXDLMSDayProfile it = new GXDLMSDayProfile();
             it.DayId = Convert.ToInt32(item[0]);
             List <GXDLMSDayProfileAction> actions = new List <GXDLMSDayProfileAction>();
             foreach (object[] it2 in (object[])item[1])
             {
                 GXDLMSDayProfileAction ac = new GXDLMSDayProfileAction();
                 if (it2[0] is GXDateTime)
                 {
                     ac.StartTime = (GXDateTime)it2[0];
                 }
                 else
                 {
                     ac.StartTime = (GXDateTime)GXDLMSClient.ChangeType((byte[])it2[0], DataType.Time);
                 }
                 ac.ScriptLogicalName = GXDLMSClient.ChangeType((byte[])it2[1], DataType.OctetString).ToString();
                 ac.ScriptSelector    = Convert.ToUInt16(it2[2]);
                 actions.Add(ac);
             }
             it.DaySchedules = actions.ToArray();
             items.Add(it);
         }
         return(items.ToArray());
     }
     return(null);
 }
 static GXDLMSDayProfile[] SetDayProfileTable(GXDLMSSettings settings, Object value)
 {
     if (value != null)
     {
         List <GXDLMSDayProfile> items = new List <GXDLMSDayProfile>();
         foreach (List <object> item in (List <object>)value)
         {
             GXDLMSDayProfile it = new GXDLMSDayProfile();
             it.DayId = Convert.ToInt32(item[0]);
             List <GXDLMSDayProfileAction> actions = new List <GXDLMSDayProfileAction>();
             foreach (List <object> it2 in (List <object>)item[1])
             {
                 GXDLMSDayProfileAction ac = new GXDLMSDayProfileAction();
                 if (it2[0] is GXTime)
                 {
                     ac.StartTime = (GXTime)it2[0];
                 }
                 else if (it2[0] is GXDateTime)
                 {
                     ac.StartTime = new GXTime((GXDateTime)it2[0]);
                 }
                 else
                 {
                     ac.StartTime = (GXTime)GXDLMSClient.ChangeType((byte[])it2[0], DataType.Time, settings.UseUtc2NormalTime);
                 }
                 ac.ScriptLogicalName = GXCommon.ToLogicalName(it2[1]);
                 ac.ScriptSelector    = Convert.ToUInt16(it2[2]);
                 actions.Add(ac);
             }
             it.DaySchedules = actions.ToArray();
             items.Add(it);
         }
         return(items.ToArray());
     }
     return(null);
 }
示例#4
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 is byte[])
         {
             CalendarNameActive = GXDLMSClient.ChangeType((byte[])value, DataType.String).ToString();
         }
         else
         {
             CalendarNameActive = Convert.ToString(value);
         }
     }
     else if (index == 3)
     {
         SeasonProfileActive = null;
         if (value != null)
         {
             List <GXDLMSSeasonProfile> items = new List <GXDLMSSeasonProfile>();
             foreach (object[] item in (object[])value)
             {
                 GXDLMSSeasonProfile it = new GXDLMSSeasonProfile();
                 it.Name     = GXDLMSClient.ChangeType((byte[])item[0], DataType.String).ToString();
                 it.Start    = (GXDateTime)GXDLMSClient.ChangeType((byte[])item[1], DataType.DateTime);
                 it.WeekName = GXDLMSClient.ChangeType((byte[])item[2], DataType.String).ToString();
                 items.Add(it);
             }
             SeasonProfileActive = items.ToArray();
         }
     }
     else if (index == 4)
     {
         WeekProfileTableActive = null;
         if (value != null)
         {
             List <GXDLMSWeekProfile> items = new List <GXDLMSWeekProfile>();
             foreach (object[] item in (object[])value)
             {
                 GXDLMSWeekProfile it = new GXDLMSWeekProfile();
                 it.Name      = GXDLMSClient.ChangeType((byte[])item[0], DataType.String).ToString();
                 it.Monday    = Convert.ToInt32(item[1]);
                 it.Tuesday   = Convert.ToInt32(item[2]);
                 it.Wednesday = Convert.ToInt32(item[3]);
                 it.Thursday  = Convert.ToInt32(item[4]);
                 it.Friday    = Convert.ToInt32(item[5]);
                 it.Saturday  = Convert.ToInt32(item[6]);
                 it.Sunday    = Convert.ToInt32(item[7]);
                 items.Add(it);
             }
             WeekProfileTableActive = items.ToArray();
         }
     }
     else if (index == 5)
     {
         DayProfileTableActive = null;
         if (value != null)
         {
             List <GXDLMSDayProfile> items = new List <GXDLMSDayProfile>();
             foreach (object[] item in (object[])value)
             {
                 GXDLMSDayProfile it = new GXDLMSDayProfile();
                 it.DayId = Convert.ToInt32(item[0]);
                 List <GXDLMSDayProfileAction> actions = new List <GXDLMSDayProfileAction>();
                 foreach (object[] it2 in (object[])item[1])
                 {
                     GXDLMSDayProfileAction ac = new GXDLMSDayProfileAction();
                     ac.StartTime         = (GXDateTime)GXDLMSClient.ChangeType((byte[])it2[0], DataType.Time);
                     ac.ScriptLogicalName = GXDLMSClient.ChangeType((byte[])it2[1], DataType.String).ToString();
                     ac.ScriptSelector    = Convert.ToUInt16(it2[2]);
                     actions.Add(ac);
                 }
                 it.DaySchedules = actions.ToArray();
                 items.Add(it);
             }
             DayProfileTableActive = items.ToArray();
         }
     }
     else if (index == 6)
     {
         if (value is byte[])
         {
             CalendarNamePassive = GXDLMSClient.ChangeType((byte[])value, DataType.String).ToString();
         }
         else
         {
             CalendarNamePassive = Convert.ToString(value);
         }
     }
     else if (index == 7)
     {
         SeasonProfilePassive = null;
         if (value != null)
         {
             List <GXDLMSSeasonProfile> items = new List <GXDLMSSeasonProfile>();
             foreach (object[] item in (object[])value)
             {
                 GXDLMSSeasonProfile it = new GXDLMSSeasonProfile();
                 it.Name     = GXDLMSClient.ChangeType((byte[])item[0], DataType.String).ToString();
                 it.Start    = (GXDateTime)GXDLMSClient.ChangeType((byte[])item[1], DataType.DateTime);
                 it.WeekName = GXDLMSClient.ChangeType((byte[])item[2], DataType.String).ToString();
                 items.Add(it);
             }
             SeasonProfilePassive = items.ToArray();
         }
     }
     else if (index == 8)
     {
         WeekProfileTablePassive = null;
         if (value != null)
         {
             List <GXDLMSWeekProfile> items = new List <GXDLMSWeekProfile>();
             foreach (object[] item in (object[])value)
             {
                 GXDLMSWeekProfile it = new GXDLMSWeekProfile();
                 it.Name      = GXDLMSClient.ChangeType((byte[])item[0], DataType.String).ToString();
                 it.Monday    = Convert.ToInt32(item[1]);
                 it.Tuesday   = Convert.ToInt32(item[2]);
                 it.Wednesday = Convert.ToInt32(item[3]);
                 it.Thursday  = Convert.ToInt32(item[4]);
                 it.Friday    = Convert.ToInt32(item[5]);
                 it.Saturday  = Convert.ToInt32(item[6]);
                 it.Sunday    = Convert.ToInt32(item[7]);
                 items.Add(it);
             }
             WeekProfileTablePassive = items.ToArray();
         }
     }
     else if (index == 9)
     {
         DayProfileTablePassive = null;
         if (value != null)
         {
             List <GXDLMSDayProfile> items = new List <GXDLMSDayProfile>();
             foreach (object[] item in (object[])value)
             {
                 GXDLMSDayProfile it = new GXDLMSDayProfile();
                 it.DayId = Convert.ToInt32(item[0]);
                 List <GXDLMSDayProfileAction> actions = new List <GXDLMSDayProfileAction>();
                 foreach (object[] it2 in (object[])item[1])
                 {
                     GXDLMSDayProfileAction ac = new GXDLMSDayProfileAction();
                     ac.StartTime         = (GXDateTime)GXDLMSClient.ChangeType((byte[])it2[0], DataType.Time);
                     ac.ScriptLogicalName = GXDLMSClient.ChangeType((byte[])it2[1], DataType.String).ToString();
                     ac.ScriptSelector    = Convert.ToUInt16(it2[2]);
                     actions.Add(ac);
                 }
                 it.DaySchedules = actions.ToArray();
                 items.Add(it);
             }
             DayProfileTablePassive = items.ToArray();
         }
     }
     else if (index == 10)
     {
         if (value is byte[])
         {
             Time = (GXDateTime)GXDLMSClient.ChangeType((byte[])value, DataType.DateTime);
         }
         else
         {
             Time = new GXDateTime(Convert.ToDateTime(value));
         }
     }
     else
     {
         throw new ArgumentException("SetValue failed. Invalid attribute index.");
     }
 }