|
@@ -254,10 +254,9 @@ void CChengzhongWnd::ReadChuankouValue()
|
|
|
//把所有读到的内容,拼接到m_chuankou_string后面,避免有的数据中间截断导致格式混乱
|
|
//把所有读到的内容,拼接到m_chuankou_string后面,避免有的数据中间截断导致格式混乱
|
|
|
m_chuankou_string += a;
|
|
m_chuankou_string += a;
|
|
|
|
|
|
|
|
- //已经有7个字符了,那么判断是稳定模式还是极速模式
|
|
|
|
|
std::string show_command = "\n\r";
|
|
std::string show_command = "\n\r";
|
|
|
|
|
|
|
|
- int nPos = m_chuankou_string.find(show_command);
|
|
|
|
|
|
|
+ size_t nPos = m_chuankou_string.find(show_command);
|
|
|
if (nPos == m_chuankou_string.npos)
|
|
if (nPos == m_chuankou_string.npos)
|
|
|
{
|
|
{
|
|
|
//没有读到足够的长度,继续读
|
|
//没有读到足够的长度,继续读
|
|
@@ -277,7 +276,7 @@ void CChengzhongWnd::ReadChuankouValue()
|
|
|
}
|
|
}
|
|
|
else if (nPos >= 20)
|
|
else if (nPos >= 20)
|
|
|
{
|
|
{
|
|
|
- //说明前面有20个字符,在极速模式下可以直接得到重量了
|
|
|
|
|
|
|
+ //说明前面有20个字符,首先肯定不是稳定模式而是极速模式,另外在极速模式下可以直接得到重量了
|
|
|
weight = m_chuankou_string.substr(nPos - 20, 5);
|
|
weight = m_chuankou_string.substr(nPos - 20, 5);
|
|
|
|
|
|
|
|
m_chuankou_string = m_chuankou_string.substr(nPos + 2);
|
|
m_chuankou_string = m_chuankou_string.substr(nPos + 2);
|
|
@@ -316,6 +315,10 @@ void CChengzhongWnd::ReadChuankouValue()
|
|
|
|
|
|
|
|
SendMessage(WM_CHENGZHONG_SUCCESS, 0, 0);
|
|
SendMessage(WM_CHENGZHONG_SUCCESS, 0, 0);
|
|
|
}
|
|
}
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ Sleep(200);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
m_is_chuangkou_working = false;
|
|
m_is_chuangkou_working = false;
|
|
@@ -323,6 +326,12 @@ void CChengzhongWnd::ReadChuankouValue()
|
|
|
|
|
|
|
|
void CChengzhongWnd::SaveWeight()
|
|
void CChengzhongWnd::SaveWeight()
|
|
|
{
|
|
{
|
|
|
|
|
+ if (m_is_watching == false)
|
|
|
|
|
+ {
|
|
|
|
|
+ //串口都还没打开,禁止退出
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
wstring wsReason = pContent->GetText();
|
|
wstring wsReason = pContent->GetText();
|
|
|
|
|
|
|
@@ -353,6 +362,12 @@ void CChengzhongWnd::SaveWeight()
|
|
|
|
|
|
|
|
void CChengzhongWnd::Quit()
|
|
void CChengzhongWnd::Quit()
|
|
|
{
|
|
{
|
|
|
|
|
+ if (m_is_watching == false)
|
|
|
|
|
+ {
|
|
|
|
|
+ //串口都还没打开,禁止退出
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
m_is_watching = false;
|
|
m_is_watching = false;
|
|
|
|
|
|
|
|
//关闭串口,关闭之后读取串口的工作线程会退出
|
|
//关闭串口,关闭之后读取串口的工作线程会退出
|