示例#1
0
        private void Startblock_Click(object sender, EventArgs e)
        {
            string BoardNumber = this.BoardNumber;
            string RelatedPort = "";
            string DeviceType  = "";
            string stringName  = "";
            string PortData    = "";
            string PortBind    = "";


            if (this.Startblock.currentState == "1")
            {
                //      dataPT.GetBoardPortByNameBdnum(stringName, BoardNumber, ref RelatedPort, ref DeviceType);

                int k = 0, a = 0;
                a = this.Controls.Count;
                object[] comps = new object[a];
                foreach (object o in this.Controls)
                {
                    comps[k] = o;
                    Type t = comps[k].GetType();
                    if (t.Name.Equals("TextBox"))
                    {
                        TextBox currentcomp = (TextBox)comps[k];
                        stringName = "Dechp_" + currentcomp.Name;
                        dataPT.GetBoardPortByNameBdnum(stringName, BoardNumber, ref RelatedPort, ref DeviceType);
                        currentcomp.BoardNumber = BoardNumber;
                        currentcomp.RelatedPort = RelatedPort;
                        currentcomp.rtdm        = rtdm;
                        // currentcomp.Name = stringName;
                        if (currentcomp.rtdm == null)
                        {
                            return;
                        }
                    }
                    if (t.Name.Equals("ButtonCheck"))
                    {
                        ButtonCheck currentcomp = (ButtonCheck)comps[k];
                        stringName = "Dechp_" + currentcomp.Name;
                        dataPT.GetBoardPortByNameBdnum(stringName, BoardNumber, ref RelatedPort, ref DeviceType);
                        currentcomp.BoardNumber = BoardNumber;
                        currentcomp.RelatedPort = RelatedPort;
                        currentcomp.CDrtdm      = rtdm;
                        // currentcomp.Name = stringName;
                        if (currentcomp.rtdm == null)
                        {
                            return;
                        }
                    }
                    else if (t.Name.Equals("statusIndicator"))
                    {
                        statusIndicator currentcomp = (statusIndicator)comps[k];
                        stringName = "Dechp_" + currentcomp.Name;
                        dataPT.GetBoardPortByNameBdnum(stringName, BoardNumber, ref RelatedPort, ref DeviceType);
                        currentcomp.BoardNumber  = BoardNumber;
                        currentcomp.RelatedPort  = RelatedPort;
                        currentcomp.currentState = rtdm.GetDataByBoardPort(BoardNumber, RelatedPort);
                        currentcomp.rtdm         = rtdm;
                        if (currentcomp.rtdm == null)
                        {
                            return;
                        }
                    }
                    else if (t.Name.Equals("levelmeter"))
                    {
                        levelmeter currentcomp = (levelmeter)comps[k];
                        stringName = "Dechp_" + currentcomp.Name;
                        dataPT.GetBoardPortByNameBdnum(stringName, BoardNumber, ref RelatedPort, ref DeviceType);
                        currentcomp.BoardNumber = BoardNumber;
                        currentcomp.RelatedPort = RelatedPort;
                        currentcomp.Value       = (int)(float.Parse(rtdm.GetDataByBoardPort(this.BoardNumber, RelatedPort)));
                        currentcomp.rtdm        = rtdm;
                        if (currentcomp.rtdm == null)
                        {
                            return;
                        }
                    }
                    else if (t.Name.Equals("SendButton"))
                    {
                        SendButton currentcomp = (SendButton)comps[k];
                        stringName = "Dechp_" + currentcomp.Name;
                        dataPT.GetBoardPortByNameBdnum(stringName, BoardNumber, ref RelatedPort, ref DeviceType);
                        currentcomp.BoardNumber = BoardNumber;
                        currentcomp.RelatedPort = RelatedPort;
                        dataPT.GetBoardSendPortByNameBdnum(stringName, BoardNumber, ref RelatedPort, ref PortData, ref PortBind);
                        currentcomp.PortBind      = PortBind;
                        currentcomp.sendData.Text = rtdm.GetDataByBoardPort(this.BoardNumber, RelatedPort);
                        currentcomp.rtdm          = rtdm;
                        if (currentcomp.rtdm == null)
                        {
                            return;
                        }
                    }

                    k++;
                }
            }
        }
示例#2
0
        private void Startblock_Click(object sender, EventArgs e)
        {
            string BoardNumber = this.BoardNumber;
            string RelatedPort = "";
            string DeviceType  = "";
            string stringName  = "";

            // dataSend.SendControlData(this.Startblock.currentState, Startblock.RelatedPort, Startblock.PortBind, this.BoardNumber);

            if (this.Startblock.currentState == "1")
            {
                //   dataPT.GetBoardPortByNameBdnum(stringName, BoardNumber, ref RelatedPort, ref DeviceType);

                int i = 0, j = 0, k = 0, l = 0, a = 0;
                a = this.Controls.Count;
                object[] comps = new object[a];
                foreach (object o in this.Controls)
                {
                    comps[k] = o;
                    Type t = comps[k].GetType();
                    if (t.Name.Equals("TextBox"))
                    {
                        TextBox currentcomp = (TextBox)comps[k];
                        stringName = "Readjhw_" + currentcomp.Name;
                        dataPT.GetBoardPortByNameBdnum(stringName, BoardNumber, ref RelatedPort, ref DeviceType);
                        currentcomp.BoardNumber = BoardNumber;
                        currentcomp.RelatedPort = RelatedPort;
                        currentcomp.rtdm        = rtdm;
                        currentcomp.Name        = stringName;
                        if (currentcomp.rtdm == null)
                        {
                            return;
                        }

                        i++;
                    }
                    else if (t.Name.Equals("statusIndicator"))
                    {
                        statusIndicator currentcomp = (statusIndicator)comps[k];
                        stringName = "Readjhw_" + currentcomp.Name;
                        dataPT.GetBoardPortByNameBdnum(stringName, BoardNumber, ref RelatedPort, ref DeviceType);
                        currentcomp.BoardNumber  = BoardNumber;
                        currentcomp.RelatedPort  = RelatedPort;
                        currentcomp.currentState = rtdm.GetDataByBoardPort(BoardNumber, RelatedPort);
                        currentcomp.rtdm         = rtdm;
                        if (currentcomp.rtdm == null)
                        {
                            return;
                        }
                        //    this.Start();
                        j++;
                    }
                    else if (t.Name.Equals("levelmeter"))
                    {
                        levelmeter currentcomp = (levelmeter)comps[k];
                        stringName = "Readjhw_" + currentcomp.Name;
                        dataPT.GetBoardPortByNameBdnum(stringName, BoardNumber, ref RelatedPort, ref DeviceType);
                        currentcomp.BoardNumber = BoardNumber;
                        currentcomp.RelatedPort = RelatedPort;
                        //string decVal = rtdm.GetDataByBoardPort(BoardNumber, RelatedPort);
                        //string[] decValMatix = decVal.Split('.');
                        //int value = int.Parse(decValMatix[0]);
                        currentcomp.stringName = stringName;
                        currentcomp.rtdm       = rtdm;
                        currentcomp.Value      = (int)(float.Parse(rtdm.GetDataByBoardPort(this.BoardNumber, RelatedPort)));
                        //  currentcomp.Value = int.Parse(rtdm.GetDataByBoardPort(BoardNumber, RelatedPort));
                        currentcomp.rtdm = rtdm;
                        if (currentcomp.rtdm == null)
                        {
                            return;
                        }
                        //    this.Start();
                        l++;
                    }
                    k++;
                }
            }
        }