Example #1
0
        /************************************************************************/
        /* 窗口初始化                                                                     */
        /************************************************************************/
        private void InitSerialPort()
        {
            m_SPManager = new 串口管理();
            m_SPList    = new ArrayList();


            int nPorts = 0;

            try
            {
                nPorts = int.Parse(ReadIni("COMSET", "nPorts", ""));
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + ",请在Config.ini文件中设置串口的个数为数字格式!");
            }
            for (int i = 1; i <= nPorts; i++)
            {
                string name_port    = "ComPortName" + i.ToString();
                string name_comPort = ReadIni("COMSET", name_port, "");
                if (name_comPort == "")
                {
                    return;
                }
                串口名及其事件 SPNameAndEvent = new 串口名及其事件();
                SPNameAndEvent.串口名  = name_comPort;
                SPNameAndEvent.串口事件 = 接收到数据;
                m_SPList.Add(SPNameAndEvent);
                m_SPManager.增加串口(SPNameAndEvent);
                if (!m_SPManager.打开串口(name_comPort))
                {
                    string show = name_comPort + "未能打开!";
                    MessageBox.Show(show);
                }
            }
            string def = "def";

            m_name_errorReturnPort = ReadIni("COMSET", "ErrorReturnPort", def);
        }
Example #2
0
        /// <summary>
        /// 初始化串口管理
        /// </summary>
        private void InitSerialPort()
        {
            m_SPManager = new 串口管理();
            m_SPList = new ArrayList();

            int nPorts=0;
            try
            {
                nPorts = int.Parse(ReadIni("COMSET", "nPorts", ""));
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message + ",请在Config.ini文件中设置串口的个数为数字格式!");
            }
            for (int i=1;i<=nPorts;i++)
            {
                string name_port="ComPortName"+i.ToString();
                string name_comPort = ReadIni("COMSET", name_port, "");
                if (name_comPort == "")
                {
                    return;
                }
                串口名及其事件 SPNameAndEvent = new 串口名及其事件();
                SPNameAndEvent.串口名 = name_comPort;
                SPNameAndEvent.串口事件 = 接收到数据;
                m_SPList.Add(SPNameAndEvent);
                m_SPManager.增加串口(SPNameAndEvent);
                if (!m_SPManager.打开串口(name_comPort))
                {
                    string show = name_comPort + "未能打开!";
                    MessageBox.Show(show);
                }
            }
            string def = "def";
            m_name_errorReturnPort = ReadIni("COMSET", "ErrorReturnPort", def);
        }
 //const string m_no_endFlag = "";
 public SendDataDlg(串口管理 SPManager)
 {
     InitializeComponent();
     m_SPManager = SPManager;
 }
 //const string m_no_endFlag = "";
 public SendDataDlg(串口管理 SPManager)
 {
     InitializeComponent();
     m_SPManager = SPManager;            
 }