Exemple #1
0
        private void initControls()
        {
            try
            {
                xmlBMSDoc lineList = new xmlBMSDoc();

                mLineList = new DataTable();
                mLineList = lineList.ReadLineInfoXMLFile();

                // 다중탭 에러발생시 상태관리
                mErrorStatus = new bool[mLineList.Rows.Count];
                for (int i = 0; i < mLineList.Rows.Count; i++)
                {
                    mErrorStatus[i] = false;
                }

                foreach (DataRow row in mLineList.Rows)
                {
                    TabPage tp = new TabPage(row["LineName"].ToString());

                    tabPageControl tpc = new tabPageControl(this,
                                                            row["COM"].ToString(),
                                                            row["LineName"].ToString(),
                                                            row["BaudRate"].ToString(),
                                                            row["Interval"].ToString());

                    tpc.Dock = DockStyle.Fill;


                    mTabPageControl.Add(row["COM"].ToString(), tpc);
                    mTabPageControl[row["COM"].ToString()].ErrorTabPageDraw += MainForm_ErrorTabPageDraw;

                    mTabPage.Add(row["COM"].ToString(), tp);

                    mTabPage[row["COM"].ToString()].Controls.Add(mTabPageControl[row["COM"].ToString()]);
                    //mTabPage[row["COM"].ToString()].BackColor = Color.White;

                    this.tabControl.TabPages.Add(mTabPage[row["COM"].ToString()]);
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #2
0
        /// <summary>
        /// 클래스 초기화
        /// </summary>
        /// <param name="commTable"></param>
        /// <param name="errorTable"></param>
        /// <param name="errorSetTable"></param>
        public ModbusSerialAscii(tabPageControl parent, DataTable dataTable, DataTable commTable, DataTable errorTable, Dictionary <string, DataTable> errorSetTable)
        {
            mGraphData = new ArrayList[commTable.Rows.Count];
            for (int i = 0; i < commTable.Rows.Count; i++)
            {
                mGraphData[i] = new ArrayList();
            }


            mDataTable     = dataTable;
            mCommTable     = commTable;
            mErrorTable    = errorTable;
            mErrorSetTable = errorSetTable;

            Utils util = new Utils();

            mErrorListTable = util.createTable(new string[] { "Error Time", "COM", "BMS ID", "Error Code", "Error Value" }, null);

            mParent = parent;

            // COM 읽어오기
            mLineName = mParent.LineName;
        }
Exemple #3
0
        private void resetControls()
        {
            xmlBMSDoc lineList = new xmlBMSDoc();

            mLineList = new DataTable();
            mLineList = lineList.ReadLineInfoXMLFile();

            // COM 포트가 모두 지워졌으면 컨트롤 전체 삭제
            //if (mLineList.Rows.Count == 0)
            //{
            //    // 삭제
            //    mTabPageControl.Clear();
            //    mTabPage.Clear();
            //    this.tabControl.TabPages.Clear();
            //}



            string[] keyList = new string[mTabPage.Keys.Count];
            mTabPage.Keys.CopyTo(keyList, 0);

            foreach (string key in keyList)
            {
                //mLineList.

                DataRow foundRow = mLineList.Rows.Find(key);

                if (foundRow != null)
                {
                    //MessageBox.Show(foundRow[0].ToString());
                    // 업데이트
                    mTabPage[key].Text = foundRow["LineName"].ToString();

                    mTabPageControl[key].resetTabPageControls(
                        foundRow["COM"].ToString(),
                        foundRow["LineName"].ToString(),
                        foundRow["BaudRate"].ToString(),
                        foundRow["Interval"].ToString());
                }
                else
                {
                    mTabPageControl[key].Stop();    // fix bug (실행중 포트 삭제시 통신이 중지되지 않는 문제)
                    mTabPageControl.Remove(key);
                    this.tabControl.TabPages.Remove(mTabPage[key]);
                    mTabPage.Remove(key);
                }
            }

            // 다중탭 에러발생시 상태관리
            mErrorStatus = new bool[mLineList.Rows.Count];
            for (int i = 0; i < mLineList.Rows.Count; i++)
            {
                mErrorStatus[i] = false;
            }

            foreach (DataRow row in mLineList.Rows)
            {
                // 없다면
                if (!mTabPage.ContainsKey(row["COM"].ToString()))
                {
                    // 탭 페이지 추가
                    TabPage tp = new TabPage(row["LineName"].ToString());

                    tabPageControl tpc = new tabPageControl(this,
                                                            row["COM"].ToString(),
                                                            row["LineName"].ToString(),
                                                            row["BaudRate"].ToString(),
                                                            row["Interval"].ToString());

                    tpc.Dock = DockStyle.Fill;

                    mTabPageControl.Add(row["COM"].ToString(), tpc);
                    mTabPageControl[row["COM"].ToString()].ErrorTabPageDraw += MainForm_ErrorTabPageDraw;

                    mTabPage.Add(row["COM"].ToString(), tp);

                    mTabPage[row["COM"].ToString()].Controls.Add(mTabPageControl[row["COM"].ToString()]);
                    //mTabPage[row["COM"].ToString()].BackColor = Color.White;

                    this.tabControl.TabPages.Add(mTabPage[row["COM"].ToString()]);
                }
            }
        }