Esempio n. 1
0
 public DIMap(string dimName, List <KeyValuePair <string, string> > dimData, SlaveTypes sType)
 {
     slaveType = sType;
     SetSupportedAttributes();//IMP: Call only after slave types are set...
     SetSupportedDataTypes();
     SetSupportedCommandTypes();
     SetSupportedEventClass();
     SetSupportedEventVariation();
     SetSupportedVariation();
     //First set the root element value...
     try
     {
         dimnType = (dimType)Enum.Parse(typeof(dimType), dimName);
     }
     catch (System.ArgumentException)
     {
         Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", dimName);
     }
     //Parse n store values...
     if (dimData != null && dimData.Count > 0)
     {
         foreach (KeyValuePair <string, string> dimkp in dimData)
         {
             Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", dimkp.Key, dimkp.Value);
             try
             {
                 if (this.GetType().GetProperty(dimkp.Key) != null) //Ajay: 02/07/2018
                 {
                     this.GetType().GetProperty(dimkp.Key).SetValue(this, dimkp.Value);
                 }
             }
             catch (System.NullReferenceException)
             {
                 Utils.WriteLine(VerboseLevel.WARNING, "DIMap: Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", dimkp.Key, dimkp.Value);
             }
         }
         Utils.Write(VerboseLevel.DEBUG, "\n");
     }
 }
Esempio n. 2
0
 public DIMap(XmlNode dimNode, SlaveTypes sType)
 {
     slaveType = sType;
     SetSupportedAttributes();//IMP: Call only after slave types are set...
     SetSupportedDataTypes();
     SetSupportedCommandTypes();
     SetSupportedEventClass();
     SetSupportedEventVariation();
     SetSupportedVariation();
     //Parse n store values...
     Utils.WriteLine(VerboseLevel.DEBUG, "dimNode name: '{0}'", dimNode.Name);
     if (dimNode.Attributes != null)
     {
         //First set the root element value...
         try
         {
             dimnType = (dimType)Enum.Parse(typeof(dimType), dimNode.Name);
         }
         catch (System.ArgumentException)
         {
             Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", dimNode.Name);
         }
         if ((slaveType == SlaveTypes.DNP3SLAVE) || (slaveType == SlaveTypes.GRAPHICALDISPLAYSLAVE) || (slaveType == SlaveTypes.IEC101SLAVE) || (slaveType == SlaveTypes.IEC104) || (slaveType == SlaveTypes.MODBUSSLAVE) || (slaveType == SlaveTypes.SPORTSLAVE) || (slaveType == SlaveTypes.MQTTSLAVE) || (slaveType == SlaveTypes.SMSSLAVE)) //Ajay: 10/08/2018 SPORTSLAVE added to condition. SPORT mapping not showing by Aditya K mail dtd. 09/08/2018
         {
             foreach (XmlAttribute item in dimNode.Attributes)
             {
                 Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", item.Name, item.Value);
                 try
                 {
                     if (this.GetType().GetProperty(item.Name) != null) //Ajay: 03/07/2018
                     {
                         this.GetType().GetProperty(item.Name).SetValue(this, item.Value);
                     }
                 }
                 catch (System.NullReferenceException)
                 {
                     Utils.WriteLine(VerboseLevel.WARNING, "DIMap: Field doesn't exist. XML and class fields mismatch!!! Key: {0} value: {1}", item.Name, item.Value);
                 }
             }
         }
         //Namrata: 07/11/2017
         // If slaveType Type is IEC61850Server
         if (slaveType == SlaveTypes.IEC61850Server)
         {
             if (dimNode.Name == "DI")
             {
                 foreach (XmlAttribute xmlattribute in dimNode.Attributes)
                 {
                     Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", xmlattribute.Name, xmlattribute.Value);
                     try
                     {
                         if (xmlattribute.Name == "ReportingIndex")
                         {
                             iec61850reportingindex = dimNode.Attributes[1].Value;
                         }
                         else
                         {
                             if (this.GetType().GetProperty(xmlattribute.Name) != null) //Ajay: 03/07/2018
                             {
                                 this.GetType().GetProperty(xmlattribute.Name).SetValue(this, xmlattribute.Value);
                             }
                         }
                     }
                     catch (System.NullReferenceException)
                     {
                         Utils.WriteLine(VerboseLevel.WARNING, "DI: Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", xmlattribute.Name, xmlattribute.Value);
                     }
                 }
             }
         }
         Utils.Write(VerboseLevel.DEBUG, "\n");
     }
     else if (dimNode.NodeType == XmlNodeType.Comment)
     {
         isNodeComment = true;
         comment       = dimNode.Value;
     }
 }