From ef1a061fadf54d7f7c3881c9d531bb9166dd0821 Mon Sep 17 00:00:00 2001 From: jxjajs Date: Thu, 26 Dec 2024 17:42:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B0=94=E8=B1=A1=E6=95=B0=E6=8D=AE=E6=89=93?= =?UTF-8?q?=E5=8D=B0=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/SensorsProtocol.cpp | 46 ++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/SensorsProtocol.cpp b/app/src/main/cpp/SensorsProtocol.cpp index 767d371d..e321e78e 100644 --- a/app/src/main/cpp/SensorsProtocol.cpp +++ b/app/src/main/cpp/SensorsProtocol.cpp @@ -692,7 +692,7 @@ void Gm_OpenSerialPort(int devidx) fd = ::open(devparam[devidx].pathname, O_RDWR | O_NDELAY); if (fd < 0) { - sprintf(szbuf, "装置%d 打开串口%d %s失败!fd=%d", devidx+1, devparam[devidx].pathname, devparam[devidx].commid+1, fd); + sprintf(szbuf, "装置%d 打开串口%d %s失败!fd=%d", devidx+1, devparam[devidx].commid+1, devparam[devidx].pathname, fd); DebugLog(devparam[devidx].commid, szbuf, 'E'); return; } @@ -3094,7 +3094,7 @@ void ShxyProtocolDataProcess(int devno) //if ((gDisSunRain & 0x80) == 0x80) { sprintf(szbuf, "%s气压:%0.3f ", szbuf, fvalue); - DebugLog(devparam[devno].commid, szbuf, 'V'); + //DebugLog(devparam[devno].commid, szbuf, 'V'); } break; case 3: /*湿度*/ @@ -3115,12 +3115,52 @@ void ShxyProtocolDataProcess(int devno) //if ((gDisSunRain & 0x80) == 0x80) { sprintf(szbuf, "%s湿度:%0.3f ", szbuf, fvalue); - DebugLog(devparam[devno].commid, szbuf, 'V'); + if(datanum < 6) + DebugLog(devparam[devno].commid, szbuf, 'V'); } break; case 4: /*雨量*/ + if ((fvalue < 0) || (fvalue > 10000)) + { + frnb = (GeneratingRandomNumber() % 41 - 20) / 1000.0; + pPortParam->aiValue[RainfallNo].EuValue *= (1 + frnb); + weatherpntmsg[RainfallNo].EuValue *= (1 + frnb); + } + else + { + pPortParam->aiValue[RainfallNo].EuValue = fvalue;/*pPortParam->aiValue[1].AiParam.fFactor + pPortParam->aiValue[1].AiParam.EuValueDelta;*/ + weatherpntmsg[RainfallNo].EuValue = fvalue;/*weatherpntmsg[HumidityNo].AiParam.fFactor + weatherpntmsg[HumidityNo].AiParam.EuValueDelta;*/ + } + pPortParam->aiValue[RainfallNo].AiState = SER_SAMPLE; + weatherpntmsg[RainfallNo].AiState = SER_SAMPLE; + //g_SelfTest.SensorsFault |= (0x02); + //if ((gDisSunRain & 0x80) == 0x80) + { + sprintf(szbuf, "%s雨量:%0.3f ", szbuf, fvalue); + if(datanum < 7) + DebugLog(devparam[devno].commid, szbuf, 'V'); + } break; case 5: /*日照*/ + if ((fvalue < 0) || (fvalue > 10000)) + { + frnb = (GeneratingRandomNumber() % 41 - 20) / 1000.0; + pPortParam->aiValue[OpticalRadiationNo].EuValue *= (1 + frnb); + weatherpntmsg[OpticalRadiationNo].EuValue *= (1 + frnb); + } + else + { + pPortParam->aiValue[OpticalRadiationNo].EuValue = fvalue;/*pPortParam->aiValue[1].AiParam.fFactor + pPortParam->aiValue[1].AiParam.EuValueDelta;*/ + weatherpntmsg[OpticalRadiationNo].EuValue = fvalue;/*weatherpntmsg[HumidityNo].AiParam.fFactor + weatherpntmsg[HumidityNo].AiParam.EuValueDelta;*/ + } + pPortParam->aiValue[OpticalRadiationNo].AiState = SER_SAMPLE; + weatherpntmsg[OpticalRadiationNo].AiState = SER_SAMPLE; + //g_SelfTest.SensorsFault |= (0x02); + //if ((gDisSunRain & 0x80) == 0x80) + { + sprintf(szbuf, "%s日照:%0.3f ", szbuf, fvalue); + DebugLog(devparam[devno].commid, szbuf, 'V'); + } break; case 6: /*风速*/ if ((fvalue < 0) || (fvalue > 80))