Esempio n. 1
0
        public SMSSlave(string mbsName, List <KeyValuePair <string, string> > mbsData, TreeNode tn)
        {
            string strRoutineName = "SMSSlave";

            UFSMS.btnAddClick            += new System.EventHandler(this.btnAdd_Click);
            UFSMS.btnDeleteClick         += new System.EventHandler(this.btnDelete_Click);
            UFSMS.btnDoneClick           += new System.EventHandler(this.btnDone_Click);
            UFSMS.btnCancelClick         += new System.EventHandler(this.btnCancel_Click);
            UFSMS.btnFirstClick          += new System.EventHandler(this.btnFirst_Click);
            UFSMS.btnPrevClick           += new System.EventHandler(this.btnPrev_Click);
            UFSMS.btnNextClick           += new System.EventHandler(this.btnNext_Click);
            UFSMS.btnLastClick           += new System.EventHandler(this.btnLast_Click);
            UFSMS.lvUFSMSListItemCheck   += new System.Windows.Forms.ItemCheckEventHandler(this.lvUFSMSList_ItemCheck);
            UFSMS.lvUFSMSListDoubleClick += new System.EventHandler(this.lvUFSMSList_DoubleClick);
            addListHeaders();
            try
            {
                try
                {
                    sType = (slaveType)Enum.Parse(typeof(slaveType), mbsName);
                }
                catch (System.ArgumentException)
                {
                    Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", mbsName);
                }
                if (mbsData != null && mbsData.Count > 0)
                {
                    foreach (KeyValuePair <string, string> mbskp in mbsData)
                    {
                        Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", mbskp.Key, mbskp.Value);
                        try
                        {
                            if (this.GetType().GetProperty(mbskp.Key) != null) //Ajay: 03/07/2018
                            {
                                this.GetType().GetProperty(mbskp.Key).SetValue(this, mbskp.Value);
                            }
                        }
                        catch (System.NullReferenceException)
                        {
                            Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value:{1}", mbskp.Key, mbskp.Value);
                        }
                    }
                    Utils.Write(VerboseLevel.DEBUG, "\n");
                    if (tn != null)
                    {
                        tn.Nodes.Clear();
                    }
                    SMSSlaveTreeNode = tn;//Save local copy so we can use it to manually add nodes in above constructor...
                    if (tn != null)
                    {
                        tn.Text = "SMSSlave " + "SMSSlave_" + this.SlaveNum;
                    }
                    Utils.SMSSlaveTreeNode = tn;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        public IEC104Slave(XmlNode sNode, TreeNode tn)
        {
            string strRoutineName = "IEC104Slave";

            try
            {
                SetSupportedASDUSizes();
                SetSupportedIOASizes();
                SetSupportedCOTSizes();
                this.fillOptions();

                //IMP: Use tn when we want to further add child nodes to 'IEC104'. Check if it's null...

                //Parse n store values...
                Utils.WriteLine(VerboseLevel.DEBUG, "sNode name: '{0}'", sNode.Name);
                if (sNode.Attributes != null)
                {
                    //First set the root element value...
                    try
                    {
                        sType = (slaveType)Enum.Parse(typeof(slaveType), sNode.Name);
                    }
                    catch (System.ArgumentException)
                    {
                        Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", sNode.Name);
                    }

                    foreach (XmlAttribute item in sNode.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, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value:{1}", item.Name, item.Value);
                        }
                    }
                    Utils.Write(VerboseLevel.DEBUG, "\n");
                }
                else if (sNode.NodeType == XmlNodeType.Comment)
                {
                    isNodeComment = true;
                    comment       = sNode.Value;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            //Not Used: uciec.lblMain.Text += slaveNum;
        }
Esempio n. 3
0
        public MODBUSSlave(XmlNode sNode, TreeNode tn)
        {
            string strRoutineName = "MODBUSSlave";

            try
            {
                //this.fillOptions();
                Utils.WriteLine(VerboseLevel.DEBUG, "sNode name: '{0}'", sNode.Name);
                if (sNode.Attributes != null)
                {
                    try
                    {
                        sType = (slaveType)Enum.Parse(typeof(slaveType), sNode.Name);
                    }
                    catch (System.ArgumentException)
                    {
                        Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", sNode.Name);
                    }

                    foreach (XmlAttribute item in sNode.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, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value:{1}", item.Name, item.Value);
                        }
                    }
                    Utils.Write(VerboseLevel.DEBUG, "\n");
                }
                else if (sNode.NodeType == XmlNodeType.Comment)
                {
                    isNodeComment = true;
                    comment       = sNode.Value;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 4
0
        public IEC101Slave(string s101Name, List <KeyValuePair <string, string> > s101Data, TreeNode tn)
        {
            string strRoutineName = "IEC101Slave";

            try
            {
                SetSupportedASDUSizes();
                SetSupportedIOASizes();
                SetSupportedCOTSizes();
                SetSupportedPortNumber();
                SetSupportedLinkAddressSizes();
                try
                {
                    sType = (slaveType)Enum.Parse(typeof(slaveType), s101Name);
                }
                catch (System.ArgumentException)
                {
                    Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", s101Name);
                }
                //Parse n store values...
                if (s101Data != null && s101Data.Count > 0)
                {
                    foreach (KeyValuePair <string, string> s104kp in s101Data)
                    {
                        Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", s104kp.Key, s104kp.Value);
                        try
                        {
                            if (this.GetType().GetProperty(s104kp.Key) != null) //Ajay: 10/08/2018
                            {
                                this.GetType().GetProperty(s104kp.Key).SetValue(this, s104kp.Value);
                            }
                        }
                        catch (System.NullReferenceException)
                        {
                            Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value:{1}", s104kp.Key, s104kp.Value);
                        }
                    }
                    Utils.Write(VerboseLevel.DEBUG, "\n");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 5
0
        public MODBUSSlave(string mbsName, List <KeyValuePair <string, string> > mbsData, TreeNode tn)
        {
            string strRoutineName = "MODBUSSlave";

            try
            {
                //this.fillOptions();
                try
                {
                    sType = (slaveType)Enum.Parse(typeof(slaveType), mbsName);
                }
                catch (System.ArgumentException)
                {
                    Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", mbsName);
                }
                if (mbsData != null && mbsData.Count > 0)
                {
                    foreach (KeyValuePair <string, string> mbskp in mbsData)
                    {
                        Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", mbskp.Key, mbskp.Value);
                        try
                        {
                            if (this.GetType().GetProperty(mbskp.Key) != null) //Ajay: 03/07/2018
                            {
                                this.GetType().GetProperty(mbskp.Key).SetValue(this, mbskp.Value);
                            }
                        }
                        catch (System.NullReferenceException)
                        {
                            Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value:{1}", mbskp.Key, mbskp.Value);
                        }
                    }
                    Utils.Write(VerboseLevel.DEBUG, "\n");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 6
0
        public SMSSlave(XmlNode sNode, TreeNode tn)
        {
            UFSMS.btnAddClick            += new System.EventHandler(this.btnAdd_Click);
            UFSMS.btnDeleteClick         += new System.EventHandler(this.btnDelete_Click);
            UFSMS.btnDoneClick           += new System.EventHandler(this.btnDone_Click);
            UFSMS.btnCancelClick         += new System.EventHandler(this.btnCancel_Click);
            UFSMS.btnFirstClick          += new System.EventHandler(this.btnFirst_Click);
            UFSMS.btnPrevClick           += new System.EventHandler(this.btnPrev_Click);
            UFSMS.btnNextClick           += new System.EventHandler(this.btnNext_Click);
            UFSMS.btnLastClick           += new System.EventHandler(this.btnLast_Click);
            UFSMS.lvUFSMSListItemCheck   += new System.Windows.Forms.ItemCheckEventHandler(this.lvUFSMSList_ItemCheck);
            UFSMS.lvUFSMSListDoubleClick += new System.EventHandler(this.lvUFSMSList_DoubleClick);
            addListHeaders();
            string strRoutineName = "SMSSlave";

            try
            {
                if (sNode.Attributes != null)
                {
                    try
                    {
                        sType = (slaveType)Enum.Parse(typeof(slaveType), sNode.Name);
                    }
                    catch (System.ArgumentException)
                    {
                        Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", sNode.Name);
                    }

                    foreach (XmlAttribute item in sNode.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, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value:{1}", item.Name, item.Value);
                        }
                    }
                    Utils.Write(VerboseLevel.DEBUG, "\n");
                    if (tn != null)
                    {
                        tn.Nodes.Clear();
                    }
                    SMSSlaveTreeNode = tn;//Save local copy so we can use it to manually add nodes in above constructor...
                    if (tn != null)
                    {
                        tn.Text = "SMSSlave " + "SMSSlave_" + this.SlaveNum;
                    }
                    parseIECGNode(sNode, tn);
                }
                else if (sNode.NodeType == XmlNodeType.Comment)
                {
                    isNodeComment = true;
                    comment       = sNode.Value;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }