张洋 4 роки тому
батько
коміт
797657fbf5

+ 1 - 0
bin/Win32/Debug/zhipuzi_pos_windows/skin/setting_dianzicheng.xml

@@ -4,6 +4,7 @@
 		<Label text="电子秤型号" width="260"/>
 		<Combo name="setting_dianzicheng_xinghao" padding="0,9,0,0" width="300" height="26" tooltip="请点击这里选择您的电子秤型号" normalimage="file='Setting_Combox_Normal.png' corner='2,2,24,2'" hotimage="file='Setting_Combox_Hover.png' corner='2,2,24,2'" pushedimage="Setting_Combox_Click.png' corner='2,2,24,2'" textpadding="10,1,1,1" >
 			<ListLabelElement text="大华ACS系列" selected="true" />
+			<ListLabelElement text="顶尖OS2X系列" selected="true" />
 		</Combo>
 	</HorizontalLayout>
 	

BIN
bin/Win32/Release/setup/zhipuzi_pos_windows_setup_1.0.0.4.exe


+ 1 - 1
bin/Win32/Release/setup/智铺子收银系统安装脚本.nsi

@@ -2,7 +2,7 @@
 
 ; HM NIS Edit Wizard helper defines
 !define PRODUCT_NAME "智铺子收银系统"
-!define PRODUCT_VERSION "1.0.0.4"
+!define PRODUCT_VERSION "1.0.0.5"
 !define PRODUCT_PUBLISHER "深圳市迅享智慧云科技有限公司"
 !define PRODUCT_WEB_SITE "https://www.zhipuzi.com"
 !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\${PRODUCT_NAME}.exe"

+ 5 - 3
zhipuzi_pos_windows/helper/CSerialPort.cpp

@@ -40,10 +40,12 @@ CSerialPort::~CSerialPort()
 
 bool CSerialPort::openComm()
 {
-    m_hComm = CreateFile(m_portNum.c_str(),
+	std::wstring realPort = _T("\\\\.\\") + m_portNum;
+    m_hComm = CreateFile(realPort.c_str(),
                          GENERIC_READ | GENERIC_WRITE, //允许读和写
                          0,		//独占方式
-                         NULL, OPEN_EXISTING,   //打开而不是创建
+                         NULL, 
+						 OPEN_EXISTING,   //打开而不是创建
                          0,   //同步方式
                          NULL
                         );
@@ -51,7 +53,7 @@ bool CSerialPort::openComm()
     if(m_hComm == INVALID_HANDLE_VALUE)
     {
         int error = GetLastError();
-
+		
         return false;
 
     }

+ 10 - 0
zhipuzi_pos_windows/page/CSettingPageUI.cpp

@@ -421,6 +421,12 @@ void CSettingPageUI::InitShow()
 		com->SelectItem(0, false, false);
 		com->SetText(L"大华ACS系列");
 	}
+	else if (setting_dianzicheng_xinghao == "dingjian_os2x")
+	{
+		com->SetInternVisible(true);
+		com->SelectItem(1, false, false);
+		com->SetText(L"顶尖OS2X系列");
+	}
 
 	//串口下拉框默认选中
 	CComboUI* com_dianzicheng = static_cast<CComboUI*>(this->FindSubControl(_T("setting_dianzicheng_chuankou")));
@@ -1721,6 +1727,10 @@ void CSettingPageUI::HandleItemSelectMsg(TNotifyUI& msg)
 		{
 			CSetting::GetInstance()->SetParam("setting_dianzicheng_xinghao", "dahua_acs");
 		}
+		else if (com->GetCurSel() == 1)
+		{
+			CSetting::GetInstance()->SetParam("setting_dianzicheng_xinghao", "dingjian_os2x");
+		}
 
 		CChengzhongWorker::GetInstance()->RestartWork();
 	}

BIN
zhipuzi_pos_windows/resource/skin.zip


BIN
zhipuzi_pos_windows/resource/zhipuzi_pos_windows.aps


BIN
zhipuzi_pos_windows/resource/zhipuzi_pos_windows.rc


+ 67 - 13
zhipuzi_pos_windows/worker/CChengzhongWorker.cpp

@@ -53,26 +53,25 @@ void CChengzhongWorker::HandleWork()
 		return;
 	}
 
-	std::string m_chuankou_string = "";
+	std::string m_chuankou_string = "";	
 
-	char a[100] = { 0 };
-
-	//检查监控模式和波特率,如果变了就关闭掉
 	while (m_is_work)
 	{
-		memset(a, 0, 100);
+		//不同型号的电子秤,数据格式可能不一样,处理方式不一样
+		if (setting_dianzicheng_xinghao == "dahua_acs")
+		{
+			char a[100] = { 0 };
 
-		//开始读取串口的数据
-		DWORD nReaded = 0;
+			memset(a, 0, 100);
 
-		m_serial.readFromComm(a, 100, &nReaded);
+			//开始读取串口的数据
+			DWORD nReaded = 0;
 
-		if (nReaded > 0)
-		{
-			//不同型号的电子秤,数据格式可能不一样,处理方式不一样
+			m_serial.readFromComm(a, 100, &nReaded);
 
-			if (setting_dianzicheng_xinghao == "dahua_acs")
+			if (nReaded > 0)
 			{
+
 				//把所有读到的内容,拼接到m_chuankou_string后面,避免有的数据中间截断导致格式混乱
 				m_chuankou_string += a;
 
@@ -142,12 +141,67 @@ void CChengzhongWorker::HandleWork()
 			}
 			else
 			{
-				//暂时不支持的其他型号
+				Sleep(100);
+			}
+		}
+		else if (setting_dianzicheng_xinghao == "dingjian_os2x")
+		{
+			char a[16] = { 0 };
+
+			memset(a, 0, 16);
+
+			//开始读取串口的数据
+			DWORD nReaded = 0;
+
+			m_serial.readFromComm(a, 16, &nReaded);
+
+			if (nReaded > 0)
+			{
+				//把所有读到的内容,拼接到m_chuankou_string后面,避免有的数据中间截断导致格式混乱
+				m_chuankou_string = a;
+
+				if (a[0] != 0x01 || a[1] != 0x02 || a[13] != 0x03 || a[14] != 0x04)
+				{
+					//说明这16个字节的数据不是完整的,这个时候处理方式是把错误数据全部读完,但是不处理,然后下次接着处理
+					std::string show_command = "\x01\x02";
+
+					size_t nPos = m_chuankou_string.find(show_command);
+					if (nPos == m_chuankou_string.npos)
+					{
+						//不存在标志服,数据错误
+						m_chuankou_string = "";
+						continue;
+					}
+
+					//把废数据读出来,不处理,下次重新读16个完整的
+					m_serial.readFromComm(a, nPos, &nReaded);
+
+					m_chuankou_string = "";
+					continue;
+				}
+
+				std::string weight = m_chuankou_string.substr(4, 6);
+
+				if (weight.at(0) == '0')
+				{
+					weight = weight.substr(1);
+				}
+
+				m_weight = weight;
+
+				if (m_hwnd != NULL)
+				{
+					::SendMessage(m_hwnd, WM_CHENGZHONG_SUCCESS, 0, 0);
+				}
+			}
+			else
+			{
 				Sleep(100);
 			}
 		}
 		else
 		{
+			//暂时不支持的其他型号
 			Sleep(100);
 		}
 	}