예제 #1
0
        public AIMap(string aimName, List <KeyValuePair <string, string> > aimData, SlaveTypes sType)
        {
            string strRoutineName = "AIMap";

            try
            {
                slaveType = sType;
                SetSupportedAttributes();//IMP: Call only after slave types are set...
                SetSupportedDataTypes();
                SetSupportedCommandTypes();
                //First set the root element value...
                try
                {
                    aimnType = (aimType)Enum.Parse(typeof(aimType), aimName);
                }
                catch (System.ArgumentException)
                {
                    Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", aimName);
                }
                //Parse n store values...
                if (aimData != null && aimData.Count > 0)
                {
                    foreach (KeyValuePair <string, string> aimkp in aimData)
                    {
                        Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", aimkp.Key, aimkp.Value);
                        try
                        {
                            if (this.GetType().GetProperty(aimkp.Key) != null) //Ajay: 10/08/2018
                            {
                                this.GetType().GetProperty(aimkp.Key).SetValue(this, aimkp.Value);
                            }
                        }
                        catch (System.NullReferenceException)
                        {
                            Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", aimkp.Key, aimkp.Value);
                        }
                    }
                    Utils.Write(VerboseLevel.DEBUG, "\n");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
파일: AIMap.cs 프로젝트: Namrata2392/OPP
        public AIMap(string aimName, List <KeyValuePair <string, string> > aimData, SlaveTypes sType)
        {
            string strRoutineName = "AIMap";

            try
            {
                slaveType = sType;
                SetSupportedAttributes();//IMP: Call only after slave types are set...
                SetSupportedDataTypes();
                SetSupportedCommandTypes();
                SetSupportedEventClass();
                SetSupportedEventVariation();
                SetSupportedVariation();
                try
                {
                    aimnType = (aimType)Enum.Parse(typeof(aimType), aimName);
                }
                catch (System.ArgumentException) { }
                if (aimData != null && aimData.Count > 0) //Parse n store values...
                {
                    foreach (KeyValuePair <string, string> aimkp in aimData)
                    {
                        try
                        {
                            if (this.GetType().GetProperty(aimkp.Key) != null) //Ajay: 03/07/2018
                            {
                                this.GetType().GetProperty(aimkp.Key).SetValue(this, aimkp.Value);
                            }
                        }
                        catch (System.NullReferenceException) { }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
        public AIMap(XmlNode aimNode, SlaveTypes sType)
        {
            string strRoutineName = "AIMap";

            try
            {
                slaveType = sType;
                SetSupportedAttributes();//IMP: Call only after slave types are set...
                SetSupportedDataTypes();
                SetSupportedCommandTypes();
                Utils.WriteLine(VerboseLevel.DEBUG, "aimNode name: '{0}'", aimNode.Name); //Parse n store values...
                if (aimNode.Attributes != null)
                {
                    //First set the root element value...
                    try
                    {
                        aimnType = (aimType)Enum.Parse(typeof(aimType), aimNode.Name);
                    }
                    catch (System.ArgumentException)
                    {
                        Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", aimNode.Name);
                    }
                    //Namrata: 07/11/2017
                    if ((slaveType == SlaveTypes.IEC101SLAVE) || (slaveType == SlaveTypes.IEC104) || (slaveType == SlaveTypes.MODBUSSLAVE) || (slaveType == SlaveTypes.UNKNOWN))
                    {
                        foreach (XmlAttribute item in aimNode.Attributes)
                        {
                            Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", item.Name, item.Value);
                            try
                            {
                                if (this.GetType().GetProperty(item.Name) != null) //Ajay: 10/08/2018
                                {
                                    this.GetType().GetProperty(item.Name).SetValue(this, item.Value);
                                }
                            }
                            catch (System.NullReferenceException)
                            {
                                Utils.WriteLine(VerboseLevel.WARNING, "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 (aimNode.Name == "AI")
                        {
                            foreach (XmlAttribute xmlattribute in aimNode.Attributes)
                            {
                                Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", xmlattribute.Name, xmlattribute.Value);
                                try
                                {
                                    if (xmlattribute.Name == "ReportingIndex")
                                    {
                                        iec61850reportingindex = aimNode.Attributes[1].Value;
                                    }
                                    else
                                    {
                                        if (this.GetType().GetProperty(xmlattribute.Name) != null) //Ajay: 10/08/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 (aimNode.NodeType == XmlNodeType.Comment)
                {
                    isNodeComment = true;
                    comment       = aimNode.Value;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #4
0
파일: AIMap.cs 프로젝트: Namrata2392/OPP
        public AIMap(XmlNode aimNode, SlaveTypes sType)
        {
            string strRoutineName = "AIMap";

            try
            {
                slaveType = sType;
                SetSupportedAttributes();//IMP: Call only after slave types are set...
                SetSupportedDataTypes();
                SetSupportedCommandTypes();
                SetSupportedEventClass();
                SetSupportedEventVariation();
                SetSupportedVariation();
                if (aimNode.Attributes != null)
                {
                    //First set the root element value...
                    try
                    {
                        aimnType = (aimType)Enum.Parse(typeof(aimType), aimNode.Name);
                    }
                    catch (System.ArgumentException) { }
                    //Namrata: 07/11/2017
                    if ((slaveType == SlaveTypes.DNP3SLAVE) || (slaveType == SlaveTypes.IEC101SLAVE) || (slaveType == SlaveTypes.IEC104) || (slaveType == SlaveTypes.MODBUSSLAVE) || (slaveType == SlaveTypes.UNKNOWN) || (slaveType == SlaveTypes.SPORTSLAVE) || (slaveType == SlaveTypes.SMSSLAVE) || (slaveType == SlaveTypes.MQTTSLAVE))
                    {
                        foreach (XmlAttribute item in aimNode.Attributes)
                        {
                            try
                            {
                                if (this.GetType().GetProperty(item.Name) != null) //Ajay: 03/07/2018
                                {
                                    this.GetType().GetProperty(item.Name).SetValue(this, item.Value);
                                }
                            }
                            catch (System.NullReferenceException) { }
                        }
                    }
                    if (slaveType == SlaveTypes.GRAPHICALDISPLAYSLAVE)
                    {
                        if (aimNode.Name == "AI")
                        {
                            foreach (XmlAttribute xmlattribute in aimNode.Attributes)
                            {
                                try
                                {
                                    if (xmlattribute.Name == "Unit")
                                    {
                                        unitID = aimNode.Attributes[3].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) { }
                            }
                        }
                    }

                    //Namrata: 07/11/2017
                    #region If slaveType Type is IEC61850Server
                    if (slaveType == SlaveTypes.IEC61850Server)
                    {
                        if (aimNode.Name == "AI")
                        {
                            foreach (XmlAttribute xmlattribute in aimNode.Attributes)
                            {
                                try
                                {
                                    if (xmlattribute.Name == "ReportingIndex")
                                    {
                                        iec61850reportingindex = aimNode.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) { }
                            }
                        }
                    }
                    #endregion If slaveType Type is IEC61850Server
                }
                else if (aimNode.NodeType == XmlNodeType.Comment)
                {
                    isNodeComment = true;
                    comment       = aimNode.Value;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }