Exemplo n.º 1
0
        public int openTspDialog(Pu pu, int channelNo)
        {
            foreach (OneDialog dlg in m_tspDialogs)
            {
                if (dlg.pu.id.Equals(pu.id, StringComparison.CurrentCultureIgnoreCase) &&
                    dlg.channelNo == channelNo)
                {
                    LogHelper.LogHelper.RecordLog(51, string.Format("已经发送打开[{0}, {1}]串口通道的命令", pu.puName, channelNo));
                    return(-1);
                }
            }
            IntPtr dialog = IntPtr.Zero;

            int ret = BVCU.ManagedLayer_CuOpenTspDialog(m_bvsdkHandle, ref dialog, m_session.Handle, Encoding.UTF8.GetBytes(pu.id), channelNo, m_bvsdkEventHandler.tspDialog_OnEvent, m_bvsdkEventHandler.tspDialog_OnData);

            if (BVCU.BVCU_RESULT_S_OK == ret)
            {
                OneDialog dlg = new OneDialog();
                dlg.dialogHandle = dialog;
                dlg.channelNo    = channelNo;
                dlg.pu           = pu;
                m_tspDialogs.Add(dlg);

                LogHelper.LogHelper.RecordLog(0, string.Format("正在打开设备:{0}, 通道:{1}的串口", pu.puName, channelNo));
                return(0);
            }
            else
            {
                string errorMsg = string.Format("打开{0}的{1}串口失败(错误码:{2})", pu.puName, channelNo, ret);
                MessageBox.Show(errorMsg);
                LogHelper.LogHelper.RecordLog(100, errorMsg);
            }
            return(-1);
        }
Exemplo n.º 2
0
        public int openTspDialog(Session.Pu pu, int channelNo)
        {
            foreach (OneDialog dlg in m_tspDialogs)
            {
                if (dlg.pu.id.Equals(pu.id, StringComparison.CurrentCultureIgnoreCase) &&
                    dlg.channelNo == channelNo)
                {
                    return(-1);
                }
            }
            IntPtr dialog = IntPtr.Zero;

            if (BVCU.ManagedLayer_CuOpenTspDialog(m_bvsdkHandle, ref dialog, m_session.Handle, Encoding.UTF8.GetBytes(pu.id),
                                                  channelNo, m_bvsdkEventHandler.tspDialog_OnEvent, m_bvsdkEventHandler.tspDialog_OnData)
                == BVCU.BVCU_RESULT_S_OK)
            {
                OneDialog dlg = new OneDialog();
                dlg.dialogHandle = dialog;
                dlg.channelNo    = channelNo;
                dlg.pu           = pu;
                m_tspDialogs.Add(dlg);
                return(0);
            }
            return(-1);
        }