日期:2014-05-17  浏览次数:22275 次

C# 串口通信问题(提示:端口被关闭)
本帖最后由 z525416460 于 2013-01-06 09:20:09 编辑
        string ls = null;
        /// <summary>
        /// 根据开阀度数打开阀门
        /// </summary>
        /// <param name="ls_CmdType">指令类型</param>
        /// <returns></returns>
        private void SendCommand(string ls_CmdType,string ls_CmdTypeStr,int i)
        {
            DataTable dt = null;
            string terstr = null;//临时数据表存储“H_Termina”
            string ls_teradds = null;//变量TerAdds
            string ls_str = null;//组合参数
            //string ls_wk = null;//临时TerminalID
            string ls_TerRemark = null;//该设备所属com口
            try
            {
            if (ltvEmp.Items.Count > 0)
            {
                
                if (i == -1)
                {
                    terstr = ltvEmp.SelectedItems[0].SubItems[1].Text;
                }
                else
                {
                    terstr = ltvEmp.Items[i].SubItems[1].Text;
                }
                    isml = terstr;
                    Reclb = 1;

                    dt = dbr.getTable("select TerAdds,TerRemark from H_Termina where TerminalID = '" + isml + "'");                   
                    ls_teradds = dt.Rows[0][0].ToString();
  &nbs