diff --git a/dispatch2/jni/common/BackendThread.cpp b/dispatch2/jni/common/BackendThread.cpp index 72c25d888d98c39f01b0e8b89fb880e9ad3273a4..baa62311f4391018ddfb780f60daa8487c4a3b18 100644 --- a/dispatch2/jni/common/BackendThread.cpp +++ b/dispatch2/jni/common/BackendThread.cpp @@ -151,7 +151,7 @@ void BackendThread::CMyThread::run(void *pdata) initDivice.UpdateDataToServer(); // 更新时间 + 趟次 usleep(100 * 1000); CUpdateApplicationThread UpdateApplicationThread; -// UpdateApplicationThread.start(pCommonData); + UpdateApplicationThread.start(pCommonData); usleep(100 * 1000); sleep(10); diff --git a/dispatch2/jni/common/common.cpp b/dispatch2/jni/common/common.cpp index fbd37becc21339265819b10eb41599e2d90d318b..dbd3e171b0f225b0408f851d724b462e1044de7d 100644 --- a/dispatch2/jni/common/common.cpp +++ b/dispatch2/jni/common/common.cpp @@ -1408,27 +1408,27 @@ string UIcommon::GetTimeString() struct tm *t = TimeHelper::getDateTime(); char timeStr[100]; -// t->tm_hour += 8; -// // 处理小时数超过23的情况 -// if (t->tm_hour >= 24) { -// t->tm_hour -= 24; -// t->tm_mday++; // 如果小时数超过23,则需要增加日期 -// -// // 检查日期是否超过了当月的最后一天 -// struct tm checkTime = *t; -// mktime(&checkTime); // 这会标准化 tm 结构,包括处理月份和年份的变化 -// if (checkTime.tm_mday != t->tm_mday) { -// // 如果日期变化了,说明原日期是当月的最后一天,需要回滚日期,并增加月份 -// t->tm_mday = 1; -// t->tm_mon++; -// -// // 如果月份也超过了11,则需要增加年份 -// if (t->tm_mon > 11) { -// t->tm_mon = 0; // 月份从0开始计数(0=1月,11=12月) -// t->tm_year++; -// } -// } -// } + t->tm_hour += 8; + // 处理小时数超过23的情况 + if (t->tm_hour >= 24) { + t->tm_hour -= 24; + t->tm_mday++; // 如果小时数超过23,则需要增加日期 + + // 检查日期是否超过了当月的最后一天 + struct tm checkTime = *t; + mktime(&checkTime); // 这会标准化 tm 结构,包括处理月份和年份的变化 + if (checkTime.tm_mday != t->tm_mday) { + // 如果日期变化了,说明原日期是当月的最后一天,需要回滚日期,并增加月份 + t->tm_mday = 1; + t->tm_mon++; + + // 如果月份也超过了11,则需要增加年份 + if (t->tm_mon > 11) { + t->tm_mon = 0; // 月份从0开始计数(0=1月,11=12月) + t->tm_year++; + } + } + } static const char *day[] = { "日", "一", "二", "三", "四", "五", "六" }; sprintf(timeStr, "%d年%02d月%02d日 %02d:%02d:%02d 星期%s", diff --git a/dispatch2/jni/common/common.h b/dispatch2/jni/common/common.h index eb5872b772e3d123064d32a0b1486facfe7614f9..d9df3c3bb81ec850fca696a0d8bab3aec1e62ec8 100644 --- a/dispatch2/jni/common/common.h +++ b/dispatch2/jni/common/common.h @@ -61,7 +61,7 @@ #include "../activity/trunkWindowActivity.h" -#define CURRENT_VERSION "1.0.7" +#define CURRENT_VERSION "1.0.6" #define WEB_SERVER "http://uatiot.bdsaas.cc" #define WEB_SERVER_PORT "iot" #define GPS_SERVER "39.104.14.181" @@ -170,12 +170,12 @@ struct stumodels struct stuKeyData { bool bsendunbind; // 挖装完成按键 - bool bkeycanceldown; + bool bkeycanceldown; // 重新匹配按键 // bool bkeycanceldownmsg; - bool bkeyfaultdown; - bool bkeyParkingdown; - bool bkeyburstdown; - bool bkeyrepairdown; + bool bkeyfaultdown; // ** + bool bkeyParkingdown; // ** + bool bkeyburstdown; // ** + bool bkeyrepairdown; // ** // bool bpoweron; }; @@ -332,9 +332,9 @@ struct stuDiggerData bool bgetdistance; // 收到 The current distance is: int truckdistance; // 当前距离 int lockindex; - bool bsendrang; // 发送 range 时 true - bool bgetrangerp; - bool bsendconnect; + bool bsendrang; // 发送 TTM:RANG + bool bgetrangerp; // 发送 TTM:RANG 收到ERP + bool bsendconnect; // 发送 TTM:CONN- int isendcount; bool bgetbinddis; // 收到 The current distance is: bool bcangetdis; @@ -352,7 +352,7 @@ struct stuDiggerData bool bbindtimeout; // 正在装载 绑定超时(150) int ibindtime; bool bgetunbind; // 收到 MSG:UNBIND - bool bgetcancel; // 收到 MSG:BINDERROR + bool bgetcancel; // 收到 MSG:BINDERROR重新匹配 }; struct stuTruckData @@ -362,7 +362,7 @@ struct stuTruckData uint8_t DiggerId[3]; bool bGetDiggerID; bool bbindstatus; // 收到 STA-FXXXXXX connected - bool brecvbindstatus; + bool brecvbindstatus; // TTM:STA- 收到绑定状态 bool bGetDiggerNum; bool bGetDiggerNummsg; bool bGetDiggerDrvID; @@ -370,31 +370,31 @@ struct stuTruckData uint8_t DiggerDrvID[4]; bool bGetDistance; uint8_t distance[4]; - bool btransportend; - bool bliftup; + bool btransportend; // 举升传感器触发 + bool bliftup; // 举升传感器触发 bool blocking; bool blift; - bool brecvdata; + bool brecvdata; // 收到值 bool brecvunbind; // 收到 sta-000 或 disconnected // bool bbinded; bool bbinding; char strDiggerNum[8]; bool bBeginLoad; // 开始装载 bool bEndload; // 结束装载 - bool bPreunbind; + bool bPreunbind; // ** bool bPreunbindmsg; char strDiggerIMEI[32]; bool bGetDiggerIMEI; bool bGetDiggerIMEImsg; - bool bCancelKey; - bool bsendsta; - bool brecvsta; + bool bCancelKey; // 重新匹配 + bool bsendsta; // 发完 TTM:STA- + bool brecvsta; // TTM:STA-000 或 收到 STA-123 bool blocked; bool bunbinddigger; bool bliftpair; - bool bpairing; // 信标配对 + bool bpairing; // 点击按钮后 发送信标配对 bool bSendpairing; // 信标配对中 - bool bPairOK; + bool bPairOK; // 收到 RSSI 配对成功 bool bCheckBLE; }; @@ -415,14 +415,14 @@ struct stuPolePunchData struct stulifttime { int itimes; - bool devicesleep; + bool devicesleep; // 开始运输--- }; struct studevicestatus { - bool lockmodelresponse; - int lockmodelerrortimes; - bool lockmodelisOK; + bool lockmodelresponse; // 握手模块 有无收到值 + int lockmodelerrortimes; // 握手连续 XX 秒 没有收到值 + bool lockmodelisOK; // 握手模块 状态是否正常 true is ok bool liftmodelresponse; int liftmodelerrortimes; bool liftmodelisOK; diff --git a/dispatch2/jni/interface/CinitDevice.cpp b/dispatch2/jni/interface/CinitDevice.cpp index d6542bfe488fc01ef4ae317eeaa7540e15aa7f0e..06b48fcc1567eb138c7a297603f1c47ec82c9217 100644 --- a/dispatch2/jni/interface/CinitDevice.cpp +++ b/dispatch2/jni/interface/CinitDevice.cpp @@ -162,6 +162,7 @@ int CinitDevice::UpdateDataToServer() { struct tm *t = TimeHelper::getDateTime(); time_t itime = syncDateTime(); + LOGI("CinitDevice,itime is %ld", itime); if (t != NULL) { getDateIsSuccess = true; diff --git a/dispatch2/jni/logic/trunkWindowLogic.cc b/dispatch2/jni/logic/trunkWindowLogic.cc index e1487998a60b9dd48758b104b6b70757d9308b8e..41b2bcb6059393c4a96e176ee4d0e246bb65c75a 100644 --- a/dispatch2/jni/logic/trunkWindowLogic.cc +++ b/dispatch2/jni/logic/trunkWindowLogic.cc @@ -97,8 +97,6 @@ static bool Button3_1_7Press = false; static bool binit = false; -static ZKMediaPlayer sPlayer(ZKMediaPlayer::E_MEDIA_TYPE_AUDIO); - static bool onButtonClick_ButtonTest01(ZKButton *pButton); static bool onButtonClick_ButtonTest02(ZKButton *pButton); static bool onButtonClick_ButtonTest03(ZKButton *pButton); @@ -107,6 +105,8 @@ static bool onButtonClick_buttonMessage(ZKButton *pButton); static bool onButtonClick_Button3_2_10(ZKButton *pButton); static bool onButtonClick_Button6_2(ZKButton *pButton); +static ZKMediaPlayer sPlayer(ZKMediaPlayer::E_MEDIA_TYPE_AUDIO); + static void getDataFromJson(); /* @@ -482,6 +482,7 @@ static void initWinUI() { // LOGI("---g_spurtCode = %s----", g_spurtCode.c_str()); // LOGI("----carType = %d----", carType); if (g_spurtCode != "000" && carType != 0) { + sPlayer.play("/mnt/extsd/music/010.mp3"); showNavibarBtn(true); bMainWindow = true; g_WinData.loadWinData.iLoadStatus = 1; // 运输状态 : 等待装载 @@ -536,7 +537,7 @@ static void onUI_init() { pCommonData->Disply.bstartThread = false; -// sleep(10); + sleep(10); BackendThread::CMyThread MyThread; MyThread.start(NULL); @@ -827,37 +828,58 @@ static void UpdateWindow3_2Text() { } static int sPlayertmp = 0; +static int sPlayertmp2 = 0; +static int sPlayertmp3 = 0; +static int sPlayertmp4 = 0; + static void UpdateLoadStatus() { LOGI("UpdateLoadStatus%d---bMainWindow is %d", __LINE__, bMainWindow); if (!bMainWindow) { return; } - sPlayertmp++; + // 1 等待装载; 2 正在装载; 3 开始运输; 4 正在排土 switch (g_WinData.loadWinData.iLoadStatus) { case 1: - if( sPlayertmp == 1){ - sPlayer.play("/mnt/extsd/music/"); -// LOGE("++++++++++ test,line is %d",__LINE__); + sPlayertmp++; + if( sPlayertmp == 4){ + sPlayer.play("/mnt/extsd/music/002.mp3"); } - if(sPlayertmp == 11){ + if(sPlayertmp == 34){ sPlayertmp = 0; -// LOGE("++++++++++ test,line is %d",__LINE__); } -// LOGE("++++++++++ test,line is %d",__LINE__); onButtonClick_ButtonTest01(NULL); break; case 2: - sPlayer.play("/mnt/extsd/music/"); + sPlayertmp2++; + if(sPlayertmp2 == 1){ + sPlayer.play("/mnt/extsd/music/001.mp3"); + } + if(sPlayertmp2 == 13){ + sPlayertmp2 = 0; + } + onButtonClick_ButtonTest02(NULL); break; case 3: - sPlayer.play("/mnt/extsd/music/"); + sPlayertmp3++; + if(sPlayertmp3 == 1){ + sPlayer.play("/mnt/extsd/music/004.mp3"); + } + if(sPlayertmp3 == 11){ + sPlayertmp3 = 0; + } onButtonClick_ButtonTest03(NULL); break; case 4: - sPlayer.play("/mnt/extsd/music/"); + sPlayertmp4++; + if(sPlayertmp4 == 1){ + sPlayer.play("/mnt/extsd/music/"); + } + if(sPlayertmp4 == 11){ + sPlayertmp4 = 0; + } onButtonClick_ButtonTest04(NULL); break; default: @@ -1102,7 +1124,7 @@ static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = { { 5, 800 }, { 6, 1000 }, { 7, 1000 }, -// { 8, 60000 },//修改3秒 到 8 秒 + { 8, 3000 }, { 9, 1000 }, { 10, 1000 }, { 11, 100 }, @@ -1142,10 +1164,9 @@ static bool onUI_Timer(int id) { break; case 7: UpdateServerMsgText(); - Update4GWinText(); break; case 8: -// Update4GWinText(); + Update4GWinText(); break; case 9: GetPowerStatus(); @@ -1305,7 +1326,7 @@ static bool onButtonClick_Button2_3_1(ZKButton *pButton) { HideAllWindows(); //隐藏窗口容器 ShowWaitLoad(); // 显示等待装载界面 - pCommonData->KeyData.bkeycanceldown = true; // 按键发送解绑 重新匹配 + pCommonData->KeyData.bkeycanceldown = true; // 重新匹配 return false; } @@ -1316,7 +1337,7 @@ static bool onButtonClick_Button2_3_2(ZKButton *pButton) { // HideAllWindows(); //隐藏窗口容器 // ShowWindow(mWindow1Ptr, mWindow2_2Ptr, mWindow2_5Ptr); - pCommonData->KeyData.bsendunbind = true; // 按键发送解绑 挖装完成 + pCommonData->KeyData.bsendunbind = true; // 挖装完成 // pCommonData->DiggerData.blift = true; pCommonData->DiggerData.bliftmsg = true; @@ -1936,6 +1957,7 @@ static bool onButtonClick_Button4_2_1(ZKButton *pButton) { static bool onButtonClick_Button4_2_2(ZKButton *pButton) { LOGD(" ButtonClick Button4_2_2 临停按钮 !!!\n"); + sPlayer.play("/mnt/extsd/music/015.mp3"); // 临停按钮 ShowAbnormalWin(0); Button4_2_2Press = true; @@ -1945,6 +1967,7 @@ static bool onButtonClick_Button4_2_2(ZKButton *pButton) { static bool onButtonClick_Button4_2_3(ZKButton *pButton) { LOGD(" ButtonClick Button4_2_3 故障按钮 !!!\n"); + sPlayer.play("/mnt/extsd/music/015.mp3"); // 故障按钮 ShowAbnormalWin(1); Button4_2_3Press = true; @@ -1954,6 +1977,7 @@ static bool onButtonClick_Button4_2_3(ZKButton *pButton) { static bool onButtonClick_Button4_2_4(ZKButton *pButton) { LOGD(" ButtonClick Button4_2_4 报修按钮 !!!\n"); + sPlayer.play("/mnt/extsd/music/015.mp3"); // 报修按钮 ShowAbnormalWin(2); Button4_2_4Press = true; @@ -1964,6 +1988,7 @@ static bool onButtonClick_Button4_2_4(ZKButton *pButton) { static bool onButtonClick_Button4_2_5(ZKButton *pButton) { LOGD(" ButtonClick Button4_2_5 打黄油按钮 !!!\n"); // 打黄油按钮 + sPlayer.play("/mnt/extsd/music/015.mp3"); ShowAbnormalWin(4); Button4_2_5Press = true; diff --git a/dispatch2/jni/thread/CDiggerLockModelMsg.cpp b/dispatch2/jni/thread/CDiggerLockModelMsg.cpp index 87060e965efc5ea4b3e6989194713ee3f9551488..48d2559c397ebbb125189867150a0889aefc145f 100644 --- a/dispatch2/jni/thread/CDiggerLockModelMsg.cpp +++ b/dispatch2/jni/thread/CDiggerLockModelMsg.cpp @@ -106,6 +106,7 @@ void CDiggerLockModelMsg::RecvSerialPortMsg(CommonData *pCommonData) pCommonData->DiggerData.sendimei = 0; pCommonData->DiggerData.bGetTruckIMEImsg = false;// 收到 MSG:IMEI } + } else { @@ -119,7 +120,7 @@ void CDiggerLockModelMsg::RecvSerialPortMsg(CommonData *pCommonData) // } if (pCommonData->DiggerData.bliftmsg) // 挖机按键挖装完成 || 长距离 大于1 按键“挖装完成” || || || || - { + {// ** m_bscandis = false; m_bbegintodis = false; pCommonData->DiggerData.bliftmsg = false; @@ -136,7 +137,7 @@ void CDiggerLockModelMsg::RecvSerialPortMsg(CommonData *pCommonData) } cout << "====m_bbegintodis: " << m_bbegintodis << endl; - if (m_bbegintodis) + if (m_bbegintodis) // 开始测距 { cout << "++++m_bbegintodis: " << m_bbegintodis << endl; char bufstatus[32]; diff --git a/dispatch2/jni/thread/CDiggerLockModelMsg.h b/dispatch2/jni/thread/CDiggerLockModelMsg.h index d1857b76627fc34387201a780c2ca699aa843bd0..777bc9948782365f29af91475a90906c97536071 100644 --- a/dispatch2/jni/thread/CDiggerLockModelMsg.h +++ b/dispatch2/jni/thread/CDiggerLockModelMsg.h @@ -17,9 +17,9 @@ class CDiggerLockModelMsg : public util::thread_t { public: static string m_strimei; - static bool m_bbindone; - static bool m_bscandis; - static bool m_bbegintodis; + static bool m_bbindone; // 收到 TTM:STA-12312313 或 TTM:CONN-MAC + static bool m_bscandis; // ** + static bool m_bbegintodis; // 开始测距 static CLockModelCom *m_pLockModelCom; // static CScreenCom *m_pScreenCom; diff --git a/dispatch2/jni/thread/CDiggerModel.cpp b/dispatch2/jni/thread/CDiggerModel.cpp index aa7ac5c8de0d27e5990270412b33b588363973e7..538aceff4f5c509593c0ae9d6b223438b972162e 100644 --- a/dispatch2/jni/thread/CDiggerModel.cpp +++ b/dispatch2/jni/thread/CDiggerModel.cpp @@ -81,7 +81,7 @@ int CDiggerModel::m_gettrucknumcount; bool CDiggerModel::m_bsendconnnect; bool CDiggerModel::m_bhavebinded; -bool CDiggerModel::m_senddatafail; +bool CDiggerModel::m_senddatafail; // 发送挖机车牌号 或 挖机 IMEI号 超过5次 int CDiggerModel::m_geterpcount; int CDiggerModel::m_waitbind; @@ -150,7 +150,7 @@ string CDiggerModel::HexToString(uint8_t *pSrc, int len) void CDiggerModel::run(void *pdata) { CommonData *pCommonData = (CommonData *)pdata; - pCommonData->TruckData.bEndload = false; + pCommonData->TruckData.bEndload = false; // 结束装载 pCommonData->DiggerData.brecvTruckNum = false; pCommonData->DiggerData.brecvTruckIMEI = false; pCommonData->DiggerData.bnomalunbind = false; @@ -161,8 +161,9 @@ void CDiggerModel::run(void *pdata) pCommonData->DiggerData.bhavebinded = false; pCommonData->DiggerData.bgetunbind = false; pCommonData->DiggerData.bgetcancel = false; + pCommonData->KeyData.bsendunbind = false; // 挖装完成按键 - m_bscan = true; + m_bscan = true; // 默认可扫描 m_bscanbind = true; m_index = 0; @@ -206,7 +207,7 @@ void CDiggerModel::run(void *pdata) while (1) { - if (pCommonData->DiggerData.bHasUnBindTruck)//收到TTM:MAC-DCON + if (pCommonData->DiggerData.bHasUnBindTruck) // 串口收到 TTM:MAC-DCON 断开连接指令 { m_sendbind = 0; // m_bscan = true; @@ -226,7 +227,7 @@ void CDiggerModel::run(void *pdata) // pCommonData->DiggerData.bliftmsg = true; if (m_bspeak == true) { - m_bspeak = false; + m_bspeak = false; // 运输状态 :等待装载 } } @@ -436,7 +437,8 @@ void CDiggerModel::SendCmdToSerialPort(CommonData *pCommonData) cout << "m_bscan:" << m_bscan << endl; cout << "m_bbind:" << m_bbind << endl; cout << "m_bcanbind:" << m_bbind << endl; - LOGI("m_bcanbind:%d; m_bbind:%d; m_bscan:%d", m_bcanbind, m_bbind, m_bscan); + LOGI("CDiggerModel, m_bcanbind: %d, m_bbind: %d; m_bscan: %d, line is %d", + m_bcanbind, m_bbind, m_bscan, __LINE__); if (m_bscan && !m_bbind) // 开始扫描 扫描 && 未绑定状态 --> 发送扫描指令 { // pCommonData->DiggerData.bhavescanTruck = false; @@ -444,8 +446,8 @@ void CDiggerModel::SendCmdToSerialPort(CommonData *pCommonData) char buf[32]; strcpy(buf, "TTM:SCAN"); m_pLockModelCom1->sendtolockmodel(buf, strlen(buf)); - LOGD("CDiggerModel, buf = %s, line is %d", - buf, __LINE__); +// LOGD("CDiggerModel, buf = %s, line is %d", +// buf, __LINE__); // m_pLockModelCom2->sendtolockmodel(buf, strlen(buf)); sleep(3); } @@ -494,7 +496,7 @@ void CDiggerModel::clearCurrentRecord() g_RecordData.transportDistance.clear(); } -//(挖装完成按键 || 收到自卸车发来的MSG:UNBIND)& (绑定-收到imei/车牌 ||发送挖机车牌号 和 挖机 IMEI号 超过5次 ) +//(挖装完成按键 || 收到自卸车发来的MSG:UNBIND(挖装完成))& (绑定-收到imei/车牌 ||发送挖机车牌号 和 挖机 IMEI号 超过5次 ) void CDiggerModel::dealliftmsg(CommonData *pCommonData) {// 处理解绑 按键(挖机/自卸车) // common::WriteLog("---dealliftmsg---\n"); @@ -524,7 +526,8 @@ void CDiggerModel::dealliftmsg(CommonData *pCommonData) m_pLockModelCom->sendtolockmodel(unBindCmd, strlen(unBindCmd)); LOGD("CDiggerModel, unBindCmd = %s, line is %d", unBindCmd, __LINE__); - sleep(1); +// sleep(1); + sleep(10); SetLoadendRecord(pCommonData); @@ -546,10 +549,10 @@ void CDiggerModel::dealliftmsg(CommonData *pCommonData) // m_pScreenCom->ShowMessageDE("2装载结束"); // sleep(2); - pCommonData->TruckData.bbinding = false; +// pCommonData->TruckData.bbinding = false; cleartempdata(); - pCommonData->TruckData.btransportend = false; +// pCommonData->TruckData.btransportend = false; cout << "m_senddatafail : " << m_senddatafail << endl; if (!m_senddatafail) // !发送数据失败 {//----发送数据成功 @@ -737,7 +740,7 @@ void CDiggerModel::GetTruckIMEI(CommonData *pCommonData) void CDiggerModel::dealrecvbindstatus(CommonData *pCommonData) { // 收到sta-0000 / sta-123 if (pCommonData->DiggerData.bbindstatus || pCommonData->DiggerData.bbindstatus2) - { + {// sta-123 // if (m_waitkeytimes == 0) // { // m_bbeginspeak = false; @@ -748,7 +751,7 @@ void CDiggerModel::dealrecvbindstatus(CommonData *pCommonData) m_bscan = false; } else - { + {// 收到sta-0000 m_sendbind = 0; m_waitkeytimes = 0; m_unbindtimes++; @@ -798,7 +801,7 @@ void CDiggerModel::dealbinded(CommonData *pCommonData) // pCommonData->TruckData.lockbegintime = common::GetTimeString(); pCommonData->DiggerData.bWaitLoardEnd = true; pCommonData->DiggerData.bFirstDK3 = true; - pCommonData->TruckData.bBeginLoad = true; + pCommonData->TruckData.bBeginLoad = true; // 开始装载 pCommonData->DiggerData.bnomalunbind = false; // pCommonData->DiggerData.bhavescanTruck = false; pCommonData->DiggerData.bhavebinded = true; // 正在装 @@ -837,8 +840,8 @@ void CDiggerModel::dealcancel(CommonData *pCommonData) m_getdistance = false; m_bhavebinded = false; // m_scannoresponse = 0; - pCommonData->TruckData.bbinding = false; - pCommonData->TruckData.btransportend = false; +// pCommonData->TruckData.bbinding = false; +// pCommonData->TruckData.btransportend = false; pCommonData->TruckData.bEndload = false; pCommonData->DiggerData.brecvTruckNum = false; pCommonData->DiggerData.brecvTruckIMEI = false; @@ -852,6 +855,17 @@ void CDiggerModel::dealcancel(CommonData *pCommonData) pCommonData->DiggerData.ibindtime = 0; cleartempdata(); + // 先发送 MSG:BINDERROR 再解绑 + char send1[64]; + sprintf(send1, "MSG:CANCELED\r\n"); + m_pLockModelCom->sendtolockmodel(send1, strlen(send1)); + + printf("send IMEImsg:%s\n", send1); + LOGD("send IMEImsg:%s", send1); + sleep(3); + + LOGD("CDiggerModel, send1 = %s, line is %d", + send1, __LINE__); char unBindCmd[32]; strcpy(unBindCmd, "TTM:DISC-ALL"); m_pLockModelCom->sendtolockmodel(unBindCmd, strlen(unBindCmd)); @@ -875,20 +889,21 @@ void CDiggerModel::dealcancel(CommonData *pCommonData) void CDiggerModel::RecvSerialPortMsg(CommonData *pCommonData) { if ((pCommonData->KeyData.bsendunbind || pCommonData->DiggerData.bgetunbind) && (m_bbind || m_senddatafail)) - {// (挖装完成按键 || 收到自卸车发来的MSG:UNBIND)& (绑定-收到imei/车牌 ||发送挖机车牌号 和 挖机 IMEI号 超过5次 ) + {// (挖装完成按键 || 收到自卸车的MSG:UNBIND挖装完车)& (绑定-收到imei/车牌 ||发送挖机车牌号 和 挖机 IMEI号 超过5次 ) pCommonData->KeyData.bsendunbind = false; - pCommonData->DiggerData.bnomalunbind = true; // 正常解绑 pCommonData->DiggerData.bgetunbind = false; + + pCommonData->DiggerData.bnomalunbind = true; // 正常解绑 dealliftmsg(pCommonData); } if (pCommonData->KeyData.bkeycanceldown || pCommonData->DiggerData.bgetcancel) {// 重新匹配按钮 || 收到自卸车发来的 MSG:BINDERROR - dealcancel(pCommonData); pCommonData->KeyData.bkeycanceldown = false; pCommonData->DiggerData.bgetcancel = false; pCommonData->DiggerData.bnomalunbind = false; + dealcancel(pCommonData); g_WinData.loadWinData.iLoadStatus = 1; // 运输状态 :等待装载 } @@ -1012,7 +1027,7 @@ void CDiggerModel::RecvSerialPortMsg(CommonData *pCommonData) } } - if (m_unbindtimes > 0) + if (m_unbindtimes > 0) // 多次收到sta { m_sendbindmsg = false; } @@ -1037,7 +1052,7 @@ void CDiggerModel::RecvSerialPortMsg(CommonData *pCommonData) printf("pCommonData->DiggerData.bgetrangerp: %d\n", pCommonData->DiggerData.bgetrangerp); if (m_bbind && pCommonData->DiggerData.bgetrangerp) - {// 绑定 且 + {// 绑定 且 发送测距 且 收到 ERP m_getrangerpcount++; pCommonData->DiggerData.bgetrangerp = false; } @@ -1049,7 +1064,8 @@ void CDiggerModel::RecvSerialPortMsg(CommonData *pCommonData) } printf("m_getrangerpcount: %d\n", m_getrangerpcount); - if (m_getrangerpcount > 8) + LOGI("m_getrangerpcount: %d\n", m_getrangerpcount); + if (m_getrangerpcount > 8) // 发送测距 且 收到 ERP 次数 大于8次后 { m_currentdis = 0; m_binddis = 0; diff --git a/dispatch2/jni/thread/CDiggerModel.h b/dispatch2/jni/thread/CDiggerModel.h index 9da7be49f4b10f3707fce39e28cef6563a336626..c1be3add50449bf2e24ffc597059d687e3de10cb 100644 --- a/dispatch2/jni/thread/CDiggerModel.h +++ b/dispatch2/jni/thread/CDiggerModel.h @@ -32,17 +32,17 @@ public: static vector m_vecLastScandata; // 最后一次扫描 static vector m_vecCacheScandata; // 临时扫描缓冲 static bool m_bcanbind; - static bool m_bscan; + static bool m_bscan; // 扫描 static bool m_bscanbind; static bool m_bbind; - static bool m_sendbindmsg; + static bool m_sendbindmsg; // 发送绑定消息 TTM:CONN- static int m_sendbind; - static int m_waitkeytimes; - static bool m_bbindone; - static int m_bindtimmes; + static int m_waitkeytimes; // 等待解绑按钮 时间 + static bool m_bbindone; // 收到 TTM:STA-12312313 或 TTM:CONN-MAC + static int m_bindtimmes; // ** - static int m_unbindtimes; + static int m_unbindtimes; // 多次收到sta static bool m_brecvTrucknum; // 获取到卡车车牌号 static bool m_brecvTruckIMEI; @@ -66,7 +66,7 @@ public: static int m_binddis; static int m_currentdis; - static int m_getrangerpcount; + static int m_getrangerpcount; // 发送测距 且 收到 ERP的次数 static int m_longdistancecount; static bool m_getdistance; // int m_bindeddis; diff --git a/dispatch2/jni/thread/CDiggerRecv485Thread.cpp b/dispatch2/jni/thread/CDiggerRecv485Thread.cpp index a9ebb24084937de95cb54ce7dfec3ab8559b143d..a0669eb1c514e957f299015d334a7dc79eb96de0 100644 --- a/dispatch2/jni/thread/CDiggerRecv485Thread.cpp +++ b/dispatch2/jni/thread/CDiggerRecv485Thread.cpp @@ -54,7 +54,7 @@ void CDiggerRecv485Thread::run(void *pdata) pCommonData = (struct CommonData *)pdata; pCommonData->DiggerData.bGetTruckNum = false; // 收到 MSG:VEHICLECODE - pCommonData->DiggerData.bGetLoadQuality = false; // * + //wyb pCommonData->DiggerData.bGetLoadQuality = false; // * pCommonData->DiggerData.bGetDriverID = false; // * pCommonData->DiggerData.bHasUnBindTruck = false; // 收到TTM:MAC-DCON pCommonData->DiggerData.TruckNum = -1; // * @@ -79,7 +79,7 @@ void CDiggerRecv485Thread::run(void *pdata) LOGD("CDiggerRecv485Thread,read len = %d, data= %s, line is %d", len, ret, __LINE__); g_WinData.loadWinData.strtext = ret; - pCommonData->devicestatus.lockmodelresponse = true; + pCommonData->devicestatus.lockmodelresponse = true; // 握手模块 有无收到值 g_WinData.settingsWindow3_1Data.iLockModelRSSIState = "正常"; pCommonData->DiggerData.isendcount = 0; @@ -286,7 +286,7 @@ void CDiggerRecv485Thread::run(void *pdata) if (bgeterp) { // pCommonData->DiggerData.isendcount = 0; - if (pCommonData->DiggerData.bsendrang) + if (pCommonData->DiggerData.bsendrang) // 发送TTM:RANG 且 收到 ERP { pCommonData->DiggerData.bgetrangerp = true; pCommonData->DiggerData.bsendrang = false; @@ -305,10 +305,10 @@ void CDiggerRecv485Thread::run(void *pdata) bool bgetunbindmsg = common::contains(ret, "MSG:UNBIND"); if (bgetunbindmsg) { - pCommonData->DiggerData.bgetunbind = true; + pCommonData->DiggerData.bgetunbind = true; // 收到自卸车的挖装完车 } - bool bgetcancelmsg = common::contains(ret, "MSG:BINDERROR"); + bool bgetcancelmsg = common::contains(ret, "MSG:BINDERROR"); // 收到自卸车的重新匹配 if (bgetcancelmsg) { pCommonData->DiggerData.bgetcancel = true; diff --git a/dispatch2/jni/thread/CDiggerRecvLockmodel2.cpp b/dispatch2/jni/thread/CDiggerRecvLockmodel2.cpp index cd3ee25f31627d60db3f2c4ff36f7e0aef90a715..6a16359a3fb41d4cceb6e51808bda3b6fdcfbe34 100644 --- a/dispatch2/jni/thread/CDiggerRecvLockmodel2.cpp +++ b/dispatch2/jni/thread/CDiggerRecvLockmodel2.cpp @@ -53,7 +53,7 @@ void CDiggerRecvLockmodel2::run(void *pdata) pCommonData = (struct CommonData *)pdata; pCommonData->DiggerData.bGetTruckNum = false; - pCommonData->DiggerData.bGetLoadQuality = false; + //wyb pCommonData->DiggerData.bGetLoadQuality = false; pCommonData->DiggerData.bGetDriverID = false; pCommonData->DiggerData.bHasUnBindTruck = false; pCommonData->DiggerData.TruckNum = -1; diff --git a/dispatch2/jni/thread/CLoadStatus.cpp b/dispatch2/jni/thread/CLoadStatus.cpp index d0a0d071dd9d756461ed0d3aec229f0ab93ec044..10812aaf8bb61980458c7cc4bbca0f02378aaac3 100644 --- a/dispatch2/jni/thread/CLoadStatus.cpp +++ b/dispatch2/jni/thread/CLoadStatus.cpp @@ -35,13 +35,13 @@ void CLoadStatus::run(void *pdata) pCommonData->TruckData.bEndload = false; while (1) { - if (pCommonData->TruckData.bBeginLoad) + if (pCommonData->TruckData.bBeginLoad) // 发送 100020 { BeginLoad(pCommonData); pCommonData->TruckData.bBeginLoad = false; } - if (pCommonData->TruckData.bEndload) + if (pCommonData->TruckData.bEndload) // 发送 100030 { Endload(pCommonData); pCommonData->TruckData.bEndload = false; diff --git a/dispatch2/jni/thread/CNFCModel.cpp b/dispatch2/jni/thread/CNFCModel.cpp index c113b1290d0c2cf41699a01c65e26e5cd2c05581..8e1d8f34073d2625f67aaaef13c356361a37de67 100644 --- a/dispatch2/jni/thread/CNFCModel.cpp +++ b/dispatch2/jni/thread/CNFCModel.cpp @@ -34,6 +34,9 @@ string CNFCModel::m_nickName; string CNFCModel::m_shiftScheduling; int CNFCModel::m_TransportTimes; + +static ZKMediaPlayer sPlayer(ZKMediaPlayer::E_MEDIA_TYPE_AUDIO); + CNFCModel::CNFCModel() { m_TransportTimes = 0; @@ -107,6 +110,7 @@ void CNFCModel::run(void *pdata) g_RecordData.vehicleDumperDriverIpassId = m_strNFCID; Attendance(pCommonData); // report clock in data to web 上传打卡数据 + sPlayer.play("/mnt/extsd/music/006.mp3");// 打卡成功 sleep(1); getDriverInfo(); // get driver name diff --git a/dispatch2/jni/thread/CTimerThread.cpp b/dispatch2/jni/thread/CTimerThread.cpp index 815465f4c7ddbe636bdbc45eca076980110019a9..84cb98e405e201b97342e63e2a22326516ec11d9 100644 --- a/dispatch2/jni/thread/CTimerThread.cpp +++ b/dispatch2/jni/thread/CTimerThread.cpp @@ -51,7 +51,7 @@ void CTimerThread::run(void *pdata) { struct CommonData *pCommonData; pCommonData = (struct CommonData *)pdata; - pCommonData->lifttime.devicesleep = false;// 设备停止休眠 == 设备不休眠 + pCommonData->lifttime.devicesleep = false; // 设备停止休眠 == 设备不休眠 pCommonData->devicestatus.liftmodelisOK = true; pCommonData->devicestatus.lockmodelisOK = true; pCommonData->devicestatus.OBDModelIsOK = true; @@ -80,7 +80,7 @@ void CTimerThread::run(void *pdata) } if (pCommonData->lifttime.itimes >= 60 * 15) - { + {// 15分钟后 唤醒 // if (pCommonData->TruckData.bliftup) // { // pCommonData->TruckData.bliftup = false; @@ -91,21 +91,21 @@ void CTimerThread::run(void *pdata) 设置从模TTM:ROL-0 主模TTM:ROL-1 */ char send1[32]; - strcpy(send1, "TTM:POW-1"); - m_pLockModelCom->sendtolockmodel(send1, strlen(send1)); + strcpy(send1, "TTM:POW-1"); // 唤醒 pow-1 休眠 pow-0 + m_pLockModelCom->sendtolockmodel(send1, strlen(send1)); // 15分钟后唤醒 common::WriteLog("m_pLockModelCom->sendtolockmodel: TTM:POW-1\n"); // LOGI("m_pLockModelCom->sendtolockmodel: TTM:POW-1\n"); LOGD("CTimerThread, send1 = %s, line is %d", send1, __LINE__); - pCommonData->lifttime.devicesleep = false;// 设备停止休眠 + pCommonData->lifttime.devicesleep = false;// 设备停止休眠 即唤醒 pCommonData->lifttime.itimes = 0; sleep(1); // } } if (!pCommonData->devicestatus.liftmodelresponse) - { + {// 15分钟后 唤醒 pCommonData->devicestatus.liftmodelerrortimes++; } @@ -117,13 +117,13 @@ void CTimerThread::run(void *pdata) } if (pCommonData->devicestatus.liftmodelerrortimes >= (60 * 60 * 2)) - { + {// 2小时没有握手信号 pCommonData->devicestatus.liftmodelresponse = false; pCommonData->devicestatus.liftmodelerrortimes = 0; pCommonData->devicestatus.liftmodelisOK = false; } - if (!pCommonData->devicestatus.lockmodelresponse) + if (!pCommonData->devicestatus.lockmodelresponse) // 握手没有收到值 { pCommonData->devicestatus.lockmodelerrortimes++; } @@ -135,17 +135,17 @@ void CTimerThread::run(void *pdata) pCommonData->devicestatus.lockmodelerrortimes = 0; } - if (pCommonData->devicestatus.lockmodelerrortimes >= (60 * 60 * 2)) + if (pCommonData->devicestatus.lockmodelerrortimes >= (60 * 60 * 2)) // { pCommonData->devicestatus.lockmodelresponse = false; pCommonData->devicestatus.lockmodelerrortimes = 0; - pCommonData->devicestatus.lockmodelisOK = false; + pCommonData->devicestatus.lockmodelisOK = false; // 异常 g_WinData.settingsWindow3_1Data.iLockModelRSSIState = "异常"; g_WinData.settingsWindow3_2Data.iLockModelRSSIState = "异常"; } if (pCommonData->DiggerData.bsendconnect && pCommonData->DiggerData.bcangetdis) - { + {// 发送 TTM:CONN- pCommonData->DiggerData.isendcount++; } @@ -199,7 +199,7 @@ void CTimerThread::run(void *pdata) LOGI("pCommonData->TruckData.bsendsta : %d\n", pCommonData->TruckData.bsendsta); // if (pCommonData->TruckData.bsendsta) if (pCommonData->TruckData.bsendsta && !pCommonData->lifttime.devicesleep) - {// 且 设备没有休眠 + {// 发送 sta后 且 !设备休眠(唤醒) m_sendsta++; // pCommonData->TruckData.bsendsta = false; } @@ -213,7 +213,7 @@ void CTimerThread::run(void *pdata) cout << "m_sendsta: " << m_sendsta << endl; common::WriteLog("m_sendsta : %d\n", m_sendsta); - if (m_sendsta > 10) + if (m_sendsta > 10) // 10次没有收到TTM:STA- { // 设置从模TTM:ROL-0 主模TTM:ROL-1 char send1[32]; @@ -238,7 +238,7 @@ void CTimerThread::run(void *pdata) cout << "m_rstcount: " << m_rstcount << endl; if ((m_rstcount > 10) && g_vehicleType == 1) - { + {// 挖机 每10秒发一次 重置 m_rstcount = 0; if (!pCommonData->TruckData.blocked) { diff --git a/dispatch2/jni/thread/CTruckLockmodelMsg.cpp b/dispatch2/jni/thread/CTruckLockmodelMsg.cpp index 98ecd1c9edd602b0ca2e981ac0567c4d0086bdf8..74beaffa97e7df5cbd527ec098e20d06c145bcfd 100644 --- a/dispatch2/jni/thread/CTruckLockmodelMsg.cpp +++ b/dispatch2/jni/thread/CTruckLockmodelMsg.cpp @@ -31,8 +31,8 @@ CTruckLockmodelMsg::~CTruckLockmodelMsg() void CTruckLockmodelMsg::run(void *pdata) { CommonData *pCommonData = (CommonData *)pdata; - pCommonData->KeyData.bsendunbind = false; - pCommonData->TruckData.btransportend = false; +// wyb pCommonData->KeyData.bsendunbind = false; +// pCommonData->TruckData.btransportend = false; m_pLockModelCom = CLockModelCom::GetInstance1(); diff --git a/dispatch2/jni/thread/CTruckModel.cpp b/dispatch2/jni/thread/CTruckModel.cpp index 75c41e43b7c620f4ea4c0e90cdac9a997101f7bc..ba5cd64269279f1e711fa2036324876ade878d67 100644 --- a/dispatch2/jni/thread/CTruckModel.cpp +++ b/dispatch2/jni/thread/CTruckModel.cpp @@ -26,7 +26,7 @@ extern WinData g_WinData; string CTruckModel::m_strcurrentID; bool CTruckModel::m_bscan; -bool CTruckModel::m_bbind; +bool CTruckModel::m_bbind; // 是否绑定 收到 imei和 车牌号后 置 true int CTruckModel::m_waitkeytimes; string CTruckModel::m_LoadQuality; bool CTruckModel::m_bbindone; @@ -36,12 +36,12 @@ int CTruckModel::m_unbindtimes; uint8_t CTruckModel::m_currentID[3]; int CTruckModel::unbindcount; -bool CTruckModel::m_bbeginspeak; +bool CTruckModel::m_bbeginspeak; // 开始绑定 CLockModelCom *CTruckModel::m_pLockModelCom; CIOCom *CTruckModel::m_pIOCom; string CTruckModel::m_strimei; int CTruckModel::m_TransportTimes; -bool CTruckModel::m_bscanbind; +bool CTruckModel::m_bscanbind; // 查询设备绑定状态 bool CTruckModel::m_bGetDiggerNum; bool CTruckModel::m_bGetDiggerIMEI; @@ -94,19 +94,22 @@ CTruckModel::~CTruckModel() void CTruckModel::run(void *pdata) { CommonData *pCommonData = (CommonData *)pdata; - pCommonData->KeyData.bsendunbind = false; // 按键发送解绑 - pCommonData->TruckData.btransportend = false; - pCommonData->TruckData.bliftup = false; - pCommonData->TruckData.bbinding = false; - pCommonData->TruckData.bBeginLoad = false; - pCommonData->TruckData.bEndload = false; - pCommonData->TruckData.bsendsta = false; + pCommonData->KeyData.bsendunbind = false; // 挖装完成按键 + pCommonData->TruckData.btransportend = false; // 举升传感器触发 + pCommonData->TruckData.bliftup = false; // 举升传感器触发 +// wyb pCommonData->TruckData.bbinding = false; + pCommonData->TruckData.bBeginLoad = false; // 开始装载 + pCommonData->TruckData.bEndload = false; // 结束装载 + pCommonData->TruckData.bsendsta = false; // 发完 TTM:STA- pCommonData->TruckData.blocked = false; - pCommonData->lifttime.devicesleep = false; // 设备停止休眠 == 设备不休眠 - pCommonData->TruckData.bunbinddigger = false; + pCommonData->lifttime.devicesleep = false; // 设备停止休眠 == 设备不休眠 + pCommonData->TruckData.bunbinddigger = false; // 解绑挖机 开始运输 pCommonData->lifttime.itimes = 0; pCommonData->TruckData.bliftpair = false; + pCommonData->TruckData.bCancelKey = false; // 重新匹配 + pCommonData->TruckData.brecvunbind = false; + m_bscan = true; m_bscanbind = true; @@ -149,12 +152,12 @@ void CTruckModel::SendCmdToSerialPort(CommonData *pCommonData) cout << "m_sendbindmsg:" << m_sendbindmsg << endl; cout << "m_bscanbind:" << m_bscanbind << endl; - if (m_bscanbind) + if (m_bscanbind) // 没有在处理绑定 { char bufstatus[32]; strcpy(bufstatus, "TTM:STA?"); m_pLockModelCom->sendtolockmodel(bufstatus, strlen(bufstatus)); - pCommonData->TruckData.bsendsta = true; // 发送查询当前状态(握手) + pCommonData->TruckData.bsendsta = true; // 发送查询当前状态(握手)---给定时器 sleep(2); } } @@ -186,8 +189,7 @@ void CTruckModel::dealbtransportend(CommonData *pCommonData) // pCommonData->lifttime.devicesleep = false; // 设备停止休眠 == 设备不休眠 pCommonData->lifttime.itimes = 0; - pCommonData->TruckData.bbinding = false; - pCommonData->TruckData.btransportend = false; + // wyb pCommonData->TruckData.bbinding = false; //m_pScreenCom->ShowMessageDE("4运输结束"); // g_WinData.loadWinData.iLoadStatus = 4; // 运输状态 :运输结束/正在排土 @@ -242,7 +244,7 @@ void CTruckModel::dealbtransportend(CommonData *pCommonData) void CTruckModel::dealGetDiggerNum(CommonData *pCommonData) { - // 处理获取到的 挖机 车牌 + // 串口获取到的 挖机 车牌 char text[64] = {0}; sprintf(text, "%s", pCommonData->TruckData.strDiggerNum); cout << "strDiggerNum text:" << text << endl; @@ -259,9 +261,11 @@ void CTruckModel::dealGetDiggerNum(CommonData *pCommonData) m_waitkeytimes = 0; m_bscan = false; m_bGetDiggerNum = true; - pCommonData->TruckData.bGetDiggerNum = false; + m_bscanbind = true; // sleep(1); + + pCommonData->TruckData.bGetDiggerNum = false; } void CTruckModel::dealGetDiggerIMEI(CommonData *pCommonData) @@ -273,6 +277,7 @@ void CTruckModel::dealGetDiggerIMEI(CommonData *pCommonData) g_strIMEI = text; m_bGetDiggerIMEI = true; m_bscanbind = true; + pCommonData->TruckData.bGetDiggerIMEI = false; } @@ -311,13 +316,13 @@ void CTruckModel::dealLoadend(CommonData *pCommonData) // 开始运输 m_bbindone = false; m_bindtimmes = 0; unbindcount = 0; - pCommonData->TruckData.bPreunbind = false; +// pCommonData->TruckData.bPreunbind = false; m_lockedtimeend = 0; m_lockedtimebegin = 0; pCommonData->lifttime.devicesleep = true; // 设备休眠 == 设备不休眠 pCommonData->lifttime.itimes = 0; - pCommonData->TruckData.bbinding = false; + // wyb pCommonData->TruckData.bbinding = false; pCommonData->TruckData.bEndload = true; pCommonData->TruckData.bunbinddigger = true; m_bbeginspeak = false; @@ -445,13 +450,13 @@ vector CTruckModel::MySplit(const string &str, const string &pattern) } void CTruckModel::dealCancel(CommonData *pCommonData) -{ +{// 绑错取消 m_bhavebinded = false; - pCommonData->TruckData.blocked = false; +// pCommonData->TruckData.blocked = false; // m_pScreenCom->ShowMessageDE("绑错取消"); //sleep(2); // m_pScreenCom->ShowMessageDC("绑错取消"); - //sleep(2); + sleep(2); // 设备休眠 char send0[32]; @@ -459,7 +464,9 @@ void CTruckModel::dealCancel(CommonData *pCommonData) m_pLockModelCom->sendtolockmodel(send0, strlen(send0)); LOGD("CTruckModel, send0 = %s, line is %d", send0, __LINE__); - sleep(58 * 15); +// sleep(58 * 15); + sleep(60); +// sleep(60 * 3); // 唤醒 char send1[32]; @@ -475,20 +482,19 @@ void CTruckModel::dealCancel(CommonData *pCommonData) } void CTruckModel::dealbindstatusmsg(CommonData *pCommonData) -{ - if (pCommonData->TruckData.bbindstatus) +{//TTM:STA- + if (pCommonData->TruckData.bbindstatus) // 收到 STA-FXXXXXX { m_bbindone = true; m_waitkeytimes++; m_unbindtimes = 0; } else - { + {// 收到 STA-000000000000 m_waitkeytimes = 0; m_bindtimmes = 0; m_unbindtimes++; } - pCommonData->TruckData.brecvbindstatus = false; } void CTruckModel::dealbinddonemsg(CommonData *pCommonData) @@ -508,8 +514,8 @@ void CTruckModel::dealbinddonemsg(CommonData *pCommonData) void CTruckModel::dealunbindmsg(CommonData *pCommonData) { cout << "dealunbindmsg pCommonData->TruckData.brecvunbind : " << pCommonData->TruckData.brecvunbind << endl; - if (pCommonData->TruckData.brecvunbind) // 收到 STA-000000000000 或 disconnected - { + if (pCommonData->TruckData.brecvunbind && !pCommonData->TruckData.bCancelKey && !pCommonData->KeyData.bkeycanceldown) + {// (收到 STA-000000000000 或 disconnected) 且 没有收到挖机重新匹配 且 没有重新匹配 unbindcount++; pCommonData->TruckData.brecvunbind = false; } @@ -520,22 +526,46 @@ void CTruckModel::dealunbindmsg(CommonData *pCommonData) pCommonData->TruckData.bbindstatus = false; } - if (pCommonData->TruckData.bCancelKey) // 收到 MSG:CANCELED - { + +// if (pCommonData->TruckData.bCancelKey) + if (pCommonData->TruckData.bCancelKey && pCommonData->TruckData.brecvunbind) + {// 收到挖机重新匹配 MSG:CANCELED 且 解绑 + LOGE("test"); + LOGE("pCommonData->TruckData.bCancelKey is %d, pCommonData->TruckData.brecvunbind is %d", + pCommonData->TruckData.bCancelKey,pCommonData->TruckData.brecvunbind); + g_WinData.loadWinData.iLoadStatus = 1; // 运输状态 :等待装载 + pCommonData->TruckData.bCheckBLE = true; + m_bbind = false; + m_bbeginspeak = false; + m_bscanbind = true; + m_bGetDiggerNum = false; + m_bGetDiggerIMEI = false; + m_bindtimmes = 0; + m_bbindone = false; + unbindcount = 0; + pCommonData->TruckData.blocked = false; + +// sendcancelmsg(pCommonData); // 重新匹配 + pCommonData->TruckData.bCancelKey = false; + pCommonData->TruckData.brecvunbind = false; dealCancel(pCommonData); } + LOGE("pCommonData->TruckData.bCancelKey is %d, pCommonData->TruckData.brecvunbind is %d", + pCommonData->TruckData.bCancelKey,pCommonData->TruckData.brecvunbind); + + LOGE("test"); cout << "unbindcount : " << unbindcount << endl; cout << "m_bbind : " << m_bbind << endl; // common::WriteLog("m_bbind: %d", m_bbind); - if (unbindcount > 0 && m_bbind) //&& pCommonData->TruckData.bPreunbind - {// + if (unbindcount > 0 && m_bbind && !pCommonData->TruckData.bCancelKey) //&& pCommonData->TruckData.bPreunbind + {// 多次( 收到 STA-000000000000 或 disconnected) 且 绑定中 dealLoadend(pCommonData);// 开始运输 } // common::WriteLog("m_bbind222: %d", m_bbind); - if (m_sendbindmsg && m_unbindtimes > 0) + if (m_sendbindmsg && m_unbindtimes > 0)// 多次收到 STA-00 { // m_bbind = false; m_sendbindmsg = false; @@ -552,7 +582,7 @@ void CTruckModel::dealunbindmsg(CommonData *pCommonData) } void CTruckModel::sendunbindmsg(CommonData *pCommonData) -{ +{// 按钮发送解绑 挖装完成 char unbind_msg[32]; strcpy(unbind_msg, "MSG:UNBIND\r\n"); m_pLockModelCom->sendtolockmodel(unbind_msg, strlen(unbind_msg)); @@ -576,11 +606,13 @@ void CTruckModel::RecvSerialPortMsg(CommonData *pCommonData) if (pCommonData->TruckData.btransportend) { // 运输结束 dealbtransportend(pCommonData); + pCommonData->TruckData.btransportend = false; } - if (pCommonData->TruckData.brecvbindstatus) + if (pCommonData->TruckData.brecvbindstatus) // TTM:STA-000 123 { dealbindstatusmsg(pCommonData); + pCommonData->TruckData.brecvbindstatus = false; } if (m_bbindone) @@ -589,7 +621,7 @@ void CTruckModel::RecvSerialPortMsg(CommonData *pCommonData) } if (pCommonData->TruckData.bGetDiggerNum) - { // 处理获取到的 挖机 车牌 + { // 串口获取到的 挖机 车牌 dealGetDiggerNum(pCommonData); } @@ -601,9 +633,10 @@ void CTruckModel::RecvSerialPortMsg(CommonData *pCommonData) if (m_bGetDiggerNum && m_bGetDiggerIMEI) { // 绑定 m_bscanbind = true; + m_bbind = true; + m_bGetDiggerNum = false; m_bGetDiggerIMEI = false; - m_bbind = true; } if (!m_bbind && unbindcount > 0) @@ -630,26 +663,27 @@ void CTruckModel::RecvSerialPortMsg(CommonData *pCommonData) pCommonData->KeyData.bsendunbind = false; } - if (pCommonData->KeyData.bkeycanceldown) // 按键发送解绑 重新匹配 -> MSG:BINDERROR + if (pCommonData->KeyData.bkeycanceldown) // 重新匹配 -> MSG:BINDERROR { - pCommonData->KeyData.bkeycanceldown = false; pCommonData->TruckData.bCheckBLE = true; m_bbind = false; m_bbeginspeak = false; - m_bscanbind = true; m_bGetDiggerNum = false; m_bGetDiggerIMEI = false; m_bindtimmes = 0; m_bbindone = false; unbindcount = 0; - pCommonData->TruckData.blocked = false; - sendcancelmsg(pCommonData); + pCommonData->TruckData.blocked = false; g_WinData.loadWinData.iLoadStatus = 1; // 运输状态 :等待装载 + + sendcancelmsg(pCommonData); // 重新匹配 + + pCommonData->KeyData.bkeycanceldown = false; } - dealunbindmsg(pCommonData); + dealunbindmsg(pCommonData); // 处理解绑 } void CTruckModel::setrundata(string key, string data) diff --git a/dispatch2/jni/thread/CTruckModel.h b/dispatch2/jni/thread/CTruckModel.h index 3e087ed85d42d66c0429477920bfecb027969618..29d91f985c10c2beec47d57fc5cfd3cceda62257 100644 --- a/dispatch2/jni/thread/CTruckModel.h +++ b/dispatch2/jni/thread/CTruckModel.h @@ -26,16 +26,16 @@ public: static bool m_bbindone; static int m_bindtimmes; static bool m_sendbindmsg; - static int m_unbindtimes; + static int m_unbindtimes; // 收到 STA-00 次数 static uint8_t m_currentID[3]; static int unbindcount; // 收到 sta-000 或 disconnected - static bool m_bbeginspeak; + static bool m_bbeginspeak; // 开始绑定 static CLockModelCom *m_pLockModelCom; static CScreenCom *m_pScreenCom; static CIOCom *m_pIOCom; static string m_strimei; - static int m_TransportTimes; + static int m_TransportTimes; // 趟次 static bool m_bscanbind; // 查询设备绑定状态 static bool m_bGetDiggerNum; diff --git a/dispatch2/jni/thread/CTruckRecv485Thread.cpp b/dispatch2/jni/thread/CTruckRecv485Thread.cpp index cb114a376869f9c43f239f748e0d7825543b5dfa..42877c7ad02d8aba28005ae2e3fa08d35d2bf271 100644 --- a/dispatch2/jni/thread/CTruckRecv485Thread.cpp +++ b/dispatch2/jni/thread/CTruckRecv485Thread.cpp @@ -39,19 +39,23 @@ void CTruckRecv485Thread::run(void *pdata) memset(pCommonData->TruckData.DiggerDrvID, 0, 4); pCommonData->TruckData.DiggerNum = -1; - pCommonData->DiggerData.bGetLoadQuality = false; +//wyb pCommonData->DiggerData.bGetLoadQuality = false; pCommonData->TruckData.bGetDiggerNum = false; pCommonData->TruckData.bGetDiggerDrvID = false; pCommonData->TruckData.bGetDistance = false; - pCommonData->KeyData.bkeyfaultdown = false; - pCommonData->KeyData.bkeyParkingdown = false; - pCommonData->KeyData.bkeyburstdown = false; - pCommonData->KeyData.bkeyrepairdown = false; +//wyb pCommonData->KeyData.bkeyfaultdown = false; +//wyb pCommonData->KeyData.bkeyParkingdown = false; +//wyb pCommonData->KeyData.bkeyburstdown = false; +//wyb pCommonData->KeyData.bkeyrepairdown = false; pCommonData->TruckData.brecvbindstatus = false; - pCommonData->TruckData.brecvdata = false; - pCommonData->TruckData.brecvunbind = false; +//wyb pCommonData->TruckData.brecvdata = false; + pCommonData->devicestatus.lockmodelresponse = true; + + pCommonData->TruckData.bCancelKey = false; // 重新匹配 + pCommonData->TruckData.brecvunbind = false; + char ret[1024]; m_count = 0; m_pLockModelCom = CLockModelCom::GetInstance1(); // 串口2 握手数据 @@ -64,9 +68,8 @@ void CTruckRecv485Thread::run(void *pdata) if (len > 0) { pCommonData->devicestatus.lockmodelresponse = true; - pCommonData->TruckData.brecvdata = true; +// wyb pCommonData->TruckData.brecvdata = true; g_WinData.settingsWindow3_2Data.iLockModelRSSIState = "正常"; - printf("SerialTransmit recv %d data, real data is : %s", len, ret); // common::WriteLog("SerialTransmit recv %d data, real data is : %s", len, ret); LOGD("CTruckRecv485Thread,recvlockmodel len = %d, data= %s, line is %d", @@ -104,6 +107,7 @@ void CTruckRecv485Thread::run(void *pdata) } bool bunbind = common::contains(ret, "disconnected"); // 收到 解绑 + LOGE("bunbind is %d", bunbind); if (bunbind) { pCommonData->TruckData.bbindstatus = false; @@ -129,7 +133,7 @@ void CTruckRecv485Thread::run(void *pdata) bool bgetDiggernum = common::contains(ret, "MSG:VEHICLECODE"); if (bgetDiggernum) - { + {// 串口获取到的 挖机 车牌 vector listvehicleCode0 = common::MySplit(ret, "\r\n"); // 使用分隔符 "\r\n" 进行拆分,将拆分后的子串组成的向量赋值给 listvehicleCode0 变量 vector listvehicleCode = common::MySplit(ret, "+"); // 使用分隔符 "+" 进行拆分,将拆分后的子串组成的向量赋值给 listvehicleCode0 变量 if (listvehicleCode.size() < 2) diff --git a/dispatch2/jni/thread/GpsModel.cpp b/dispatch2/jni/thread/GpsModel.cpp index 8acac294f3c4935ba217a50c92f33695838651fe..49e8238620ad3c12b5c4d697f7dc084c549864f0 100644 --- a/dispatch2/jni/thread/GpsModel.cpp +++ b/dispatch2/jni/thread/GpsModel.cpp @@ -23,7 +23,7 @@ GpsModel::~GpsModel() { void GpsModel::ParseGpsData(string strText, CommonData *pCommonData) -{ +{// 具体解析详见 千寻步光_数据接口协议 pCommonData->Gps.direction = 0; pCommonData->Gps.height = 0; pCommonData->Gps.latitude = 0; @@ -34,7 +34,7 @@ void GpsModel::ParseGpsData(string strText, CommonData *pCommonData) { for (unsigned int i = 0; i < Listtemp.size(); i++) { - bool bcontains1 = common::contains(Listtemp[i], "$BDGGA"); + bool bcontains1 = common::contains(Listtemp[i], "$BDGGA");//消息头 if (bcontains1) { vector listGNGGA = common::MySplit(Listtemp[i], ","); @@ -52,7 +52,7 @@ void GpsModel::ParseGpsData(string strText, CommonData *pCommonData) memset(szLatitude, 0, 32); sprintf(szLatitude, "%.2f%s", ftemp1, list1[1].c_str()); pCommonData->Gps.latitude = atof(szLatitude); - g_WinData.settingsWindow3_1Data.latitude = atof(szLatitude); + g_WinData.settingsWindow3_1Data.latitude = atof(szLatitude);// 纬度 g_WinData.settingsWindow3_2Data.latitude = atof(szLatitude); } if (list2.size() > 1) @@ -62,7 +62,7 @@ void GpsModel::ParseGpsData(string strText, CommonData *pCommonData) memset(szlongitude, 0, 32); sprintf(szlongitude, "%.2f%s", ftemp2, list2[1].c_str()); pCommonData->Gps.longitude = atof(szlongitude); - g_WinData.settingsWindow3_1Data.longitude = atof(szlongitude); + g_WinData.settingsWindow3_1Data.longitude = atof(szlongitude);// 经度 g_WinData.settingsWindow3_2Data.longitude = atof(szlongitude); } } @@ -72,7 +72,7 @@ void GpsModel::ParseGpsData(string strText, CommonData *pCommonData) if(listGNGGA[9].length() > 1) { pCommonData->Gps.height = (int)atof(listGNGGA[9].c_str()); - g_WinData.carInfoWin1Data.iElevation = pCommonData->Gps.height; + g_WinData.carInfoWin1Data.iElevation = pCommonData->Gps.height; // 海拔高度 m } } } @@ -125,6 +125,8 @@ void GpsModel::run(void *pdata) m_pGPSCom->recvGPS(data, 2048); string strText = string(data); // cout << "GpsModel strText: " << strText << endl; +// LOGD("GpsModel, data is: %s", +// strText.c_str()); ParseGpsData(strText, pCommonData); sleep(1); diff --git a/dispatch2/jni/thread/nvrio.cpp b/dispatch2/jni/thread/nvrio.cpp index 2c08b0e310312040739f9fc7284e60abf76e5b12..9d765a16ee73e16f6b6ad3315fa5cdb5241b74eb 100644 --- a/dispatch2/jni/thread/nvrio.cpp +++ b/dispatch2/jni/thread/nvrio.cpp @@ -355,7 +355,7 @@ void nvrio::run(void *pdata) { LOGI("nvrio recv %d data, real data is : %s\n", n, Dst); - if(pCommonData->TruckData.bSendpairing)//配对中时 + if(pCommonData->TruckData.bSendpairing) // 处理开始配对---配对中时 { bool bOK = common::contains(Dst, "RSSI"); if(bOK) @@ -396,7 +396,7 @@ void nvrio::run(void *pdata) // blast = bopen; // // pCommonData->TruckData.bliftpair = false; // pCommonData->devicestatus.liftmodelresponse = true; -//// g_WinData.loadWinData.iLoadStatus = 1; // 运输状态 :等待装载 +// g_WinData.loadWinData.iLoadStatus = 1; // 运输状态 :等待装载 // } // bool bSTAunpair = common::contains(Dst, "TTM:STA-UNPAIR"); diff --git a/dispatch2/jni/thread/sendtoio.cpp b/dispatch2/jni/thread/sendtoio.cpp index 1e46770ce6c3bd84a8036403242b2a34c98a0f09..56550aa3e4c04c396cd4b7e3fcb807213d5df589 100644 --- a/dispatch2/jni/thread/sendtoio.cpp +++ b/dispatch2/jni/thread/sendtoio.cpp @@ -20,9 +20,11 @@ void CSendtoio::run(void *pdata) LOGI("CSendtoio::run, pCommonData->TruckData.bliftpair = : %d", pCommonData->TruckData.bliftpair); if(pCommonData->TruckData.bliftpair || - (pCommonData->TruckData.bCheckBLE && !pCommonData->TruckData.bpairing && !pCommonData->TruckData.bSendpairing) + (pCommonData->TruckData.bCheckBLE && + !pCommonData->TruckData.bpairing + && !pCommonData->TruckData.bSendpairing) ) - {// 或 ( 且 未发送配对指令的时候) + {// 自卸车 开始运输后 或 ( 且! 配对中 且 !发送配对指令的时候) char bufstatus[32]; strcpy(bufstatus, "TTM:INFO"); printf("sendtoIO %d data, real data is : %s\n", strlen(bufstatus), bufstatus); @@ -35,6 +37,7 @@ void CSendtoio::run(void *pdata) strcpy(buf, "TTM:PAIR"); m_pIOCom->sendtoIO(buf, strlen(buf)); pCommonData->TruckData.bpairing = false; + pCommonData->TruckData.bSendpairing = true; // 配对中 }