Exemplo n.º 1
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)
     {
         Mode = (AutoConnectMode)Convert.ToInt32(value);
     }
     else if (index == 3)
     {
         ListeningWindow.Clear();
         if (value != null)
         {
             foreach (Object[] item in (Object[])value)
             {
                 GXDateTime start = (GXDateTime)GXDLMSClient.ChangeType((byte[])item[0], DataType.DateTime);
                 GXDateTime end   = (GXDateTime)GXDLMSClient.ChangeType((byte[])item[1], DataType.DateTime);
                 ListeningWindow.Add(new KeyValuePair <GXDateTime, GXDateTime>(start, end));
             }
         }
     }
     else if (index == 4)
     {
         Status = (AutoAnswerStatus)Convert.ToInt32(value);
     }
     else if (index == 5)
     {
         NumberOfCalls = Convert.ToInt32(value);
     }
     else if (index == 6)
     {
         NumberOfRingsInListeningWindow = NumberOfRingsOutListeningWindow = 0;
         if (value != null)
         {
             NumberOfRingsInListeningWindow  = Convert.ToInt32(((Object[])value)[0]);
             NumberOfRingsOutListeningWindow = Convert.ToInt32(((Object[])value)[1]);
         }
     }
     else
     {
         throw new ArgumentException("SetValue failed. Invalid attribute index.");
     }
 }
Exemplo n.º 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, false).ToString();
         }
     }
     else if (e.Index == 2)
     {
         Mode = (AutoAnswerMode)Convert.ToInt32(e.Value);
     }
     else if (e.Index == 3)
     {
         ListeningWindow.Clear();
         if (e.Value != null)
         {
             foreach (Object[] item in (Object[])e.Value)
             {
                 GXDateTime start = (GXDateTime)GXDLMSClient.ChangeType((byte[])item[0], DataType.DateTime, settings.UseUtc2NormalTime);
                 GXDateTime end   = (GXDateTime)GXDLMSClient.ChangeType((byte[])item[1], DataType.DateTime, settings.UseUtc2NormalTime);
                 ListeningWindow.Add(new KeyValuePair <GXDateTime, GXDateTime>(start, end));
             }
         }
     }
     else if (e.Index == 4)
     {
         Status = (AutoAnswerStatus)Convert.ToInt32(e.Value);
     }
     else if (e.Index == 5)
     {
         NumberOfCalls = Convert.ToInt32(e.Value);
     }
     else if (e.Index == 6)
     {
         NumberOfRingsInListeningWindow = NumberOfRingsOutListeningWindow = 0;
         if (e.Value != null)
         {
             NumberOfRingsInListeningWindow  = Convert.ToInt32(((Object[])e.Value)[0]);
             NumberOfRingsOutListeningWindow = Convert.ToInt32(((Object[])e.Value)[1]);
         }
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }
Exemplo n.º 3
0
 void IGXDLMSBase.Load(GXXmlReader reader)
 {
     Mode = (AutoAnswerMode)reader.ReadElementContentAsInt("Mode");
     ListeningWindow.Clear();
     if (reader.IsStartElement("ListeningWindow", true))
     {
         while (reader.IsStartElement("Item", true))
         {
             GXDateTime start = new GXDateTime(reader.ReadElementContentAsString("Start"));
             GXDateTime end   = new GXDateTime(reader.ReadElementContentAsString("End"));
             ListeningWindow.Add(new KeyValuePair <DLMS.GXDateTime, DLMS.GXDateTime>(start, end));
         }
         reader.ReadEndElement("ListeningWindow");
     }
     Status        = (AutoAnswerStatus)reader.ReadElementContentAsInt("Status");
     NumberOfCalls = reader.ReadElementContentAsInt("NumberOfCalls");
     NumberOfRingsInListeningWindow  = reader.ReadElementContentAsInt("NumberOfRingsInListeningWindow");
     NumberOfRingsOutListeningWindow = reader.ReadElementContentAsInt("NumberOfRingsOutListeningWindow");
 }
Exemplo n.º 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)
            {
                ListeningWindow.Clear();
                if (value is Object[])
                {
                    foreach (object it in value as Object[])
                    {
                        Object[]   tmp   = it as Object[];
                        GXDateTime start = GXDLMSClient.ChangeType((byte[])tmp[0], DataType.DateTime) as GXDateTime;
                        GXDateTime end   = GXDLMSClient.ChangeType((byte[])tmp[1], DataType.DateTime) as GXDateTime;
                        ListeningWindow.Add(new KeyValuePair <GXDateTime, GXDateTime>(start, end));
                    }
                }
            }
            else if (index == 3)
            {
                if (value is Object[])
                {
                    List <string> tmp = new List <string>();
                    foreach (object it in value as Object[])
                    {
                        tmp.Add(ASCIIEncoding.ASCII.GetString((byte[])it));
                    }
                    AllowedSenders = tmp.ToArray();
                }
                else
                {
                    AllowedSenders = new string[0];
                }
            }
            else if (index == 4)
            {
                SendersAndActions.Clear();
                if (value is Object[])
                {
                    foreach (object it in value as Object[])
                    {
                        Object[] tmp  = it as Object[];
                        string   id   = ASCIIEncoding.ASCII.GetString((byte[])tmp[0]);
                        Object[] tmp2 = tmp[1] as Object[];

                        /*TODO:
                         * KeyValuePair<int, GXDLMSScriptAction> executed_script = new KeyValuePair<int, GXDLMSScriptAction>(Convert.ToInt32(tmp2[1], tmp2[2]));
                         * SendersAndActions.Add(new KeyValuePair<string, KeyValuePair<int, GXDLMSScriptAction>>(id, tmp[1] as GXDateTime));
                         * */
                    }
                }
            }
            else
            {
                throw new ArgumentException("SetValue failed. Invalid attribute index.");
            }
        }
        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)
            {
                ListeningWindow.Clear();
                if (e.Value is Object[])
                {
                    foreach (object it in e.Value as Object[])
                    {
                        Object[]   tmp   = it as Object[];
                        GXDateTime start = GXDLMSClient.ChangeType((byte[])tmp[0], DataType.DateTime) as GXDateTime;
                        GXDateTime end   = GXDLMSClient.ChangeType((byte[])tmp[1], DataType.DateTime) as GXDateTime;
                        ListeningWindow.Add(new KeyValuePair <GXDateTime, GXDateTime>(start, end));
                    }
                }
            }
            else if (e.Index == 3)
            {
                if (e.Value is Object[])
                {
                    List <string> tmp = new List <string>();
                    foreach (object it in e.Value as Object[])
                    {
                        tmp.Add(ASCIIEncoding.ASCII.GetString((byte[])it));
                    }
                    AllowedSenders = tmp.ToArray();
                }
                else
                {
                    AllowedSenders = new string[0];
                }
            }
            else if (e.Index == 4)
            {
                SendersAndActions.Clear();
                if (e.Value is Object[])
                {
                    foreach (object it in e.Value as Object[])
                    {
                        Object[] tmp  = it as Object[];
                        string   id   = ASCIIEncoding.ASCII.GetString((byte[])tmp[0]);
                        Object[] tmp2 = tmp[1] as Object[];

                        /*TODO:
                         * KeyValuePair<int, GXDLMSScriptAction> executed_script = new KeyValuePair<int, GXDLMSScriptAction>(Convert.ToInt32(tmp2[1], tmp2[2]));
                         * SendersAndActions.Add(new KeyValuePair<string, KeyValuePair<int, GXDLMSScriptAction>>(id, tmp[1] as GXDateTime));
                         * */
                    }
                }
            }
            else
            {
                e.Error = ErrorCode.ReadWriteDenied;
            }
        }
Exemplo n.º 6
0
 void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         LogicalName = GXCommon.ToLogicalName(e.Value);
     }
     else if (e.Index == 2)
     {
         Mode = (AutoAnswerMode)Convert.ToInt32(e.Value);
     }
     else if (e.Index == 3)
     {
         ListeningWindow.Clear();
         if (e.Value != null)
         {
             foreach (object tmp in (IEnumerable <object>)e.Value)
             {
                 List <object> item;
                 if (tmp is List <object> )
                 {
                     item = (List <object>)tmp;
                 }
                 else
                 {
                     item = new List <object>((object[])tmp);
                 }
                 GXDateTime start = (GXDateTime)GXDLMSClient.ChangeType((byte[])item[0], DataType.DateTime, settings.UseUtc2NormalTime);
                 GXDateTime end   = (GXDateTime)GXDLMSClient.ChangeType((byte[])item[1], DataType.DateTime, settings.UseUtc2NormalTime);
                 ListeningWindow.Add(new KeyValuePair <GXDateTime, GXDateTime>(start, end));
             }
         }
     }
     else if (e.Index == 4)
     {
         Status = (AutoAnswerStatus)Convert.ToInt32(e.Value);
     }
     else if (e.Index == 5)
     {
         NumberOfCalls = Convert.ToInt32(e.Value);
     }
     else if (e.Index == 6)
     {
         NumberOfRingsInListeningWindow = NumberOfRingsOutListeningWindow = 0;
         if (e.Value != null)
         {
             List <object> arr;
             if (e.Value is List <object> )
             {
                 arr = (List <object>)e.Value;
             }
             else
             {
                 arr = new List <object>((object[])e.Value);
             }
             NumberOfRingsInListeningWindow  = Convert.ToInt32(arr[0]);
             NumberOfRingsOutListeningWindow = Convert.ToInt32(arr[1]);
         }
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }