diff --git a/app/src/main/cpp/SensorsProtocol.cpp b/app/src/main/cpp/SensorsProtocol.cpp index e6b9a07b..4802f3de 100644 --- a/app/src/main/cpp/SensorsProtocol.cpp +++ b/app/src/main/cpp/SensorsProtocol.cpp @@ -1316,7 +1316,7 @@ void GM_StartSerialComm() srdt.ms_dev[i].FirstCmdTimeCnt = get_msec(); srdt.ms_dev[i].recvdatacnt = 0; for(j=0; j 0 )) { srdt.ms_dev[i].SerialCmdidx = 10017; @@ -1640,17 +1640,17 @@ void GM_IsCloseSensors() DebugLog(devparam[i].commid, buf, 'I'); for(j=0;jimage.presetno = presetno; - pPortParam->image.state = Sample; + pPortParam->image.state = SER_SAMPLE; curserial->RevCmdFlag = 1; pPortParam->SerialCmdidx = 1; srdt.sendphotocmdcnt = 0; @@ -2071,7 +2071,7 @@ void CameraPhotoPortDataProcess( int devno) } else { - if((1 == SaveImageDataTofile(devno)) && (Sample == pPortParam->image.state)) + if((1 == SaveImageDataTofile(devno)) && (SER_SAMPLE == pPortParam->image.state)) pPortParam->image.state = PHOTO_SAVE_SUCC; recvend = 1; } @@ -3147,7 +3147,7 @@ void ShxyProtocolDataProcess( int devno) } else pPortParam->aiValue[0].EuValue = fvalue; - pPortParam->aiValue[0].AiState = Sample; + pPortParam->aiValue[0].AiState = SER_SAMPLE; //slantpntmsg[aipnt][0].EuValue = fvalue*slantpntmsg[aipnt][0].AiParam.fFactor\ // +slantpntmsg[aipnt][0].AiParam.EuValueDelta; //slantpntmsg[aipnt][0].AiState = 1; @@ -3176,7 +3176,7 @@ void ShxyProtocolDataProcess( int devno) } else pPortParam->aiValue[1].EuValue = fvalue; - pPortParam->aiValue[1].AiState = Sample; + pPortParam->aiValue[1].AiState = SER_SAMPLE; /*slantpntmsg[aipnt][1].EuValue = fvalue*slantpntmsg[aipnt][1].AiParam.fFactor\ +slantpntmsg[aipnt][1].AiParam.EuValueDelta; slantpntmsg[aipnt][1].AiState = 1;*/ @@ -3207,15 +3207,15 @@ void ShxyProtocolDataProcess( int devno) frnb = (GeneratingRandomNumber()%101-50)/1000.0; pPortParam->aiValue[AirTempNo].EuValue *= (1+frnb); weatherpntmsg[AirTempNo].EuValue *= (1+frnb); - //weatherpntmsg[AirTempNo].AiState = Sample; + //weatherpntmsg[AirTempNo].AiState = SER_SAMPLE; } else { pPortParam->aiValue[AirTempNo].EuValue = fvalue;/*pPortParam->aiValue[0].AiParam.fFactor + pPortParam->aiValue[0].AiParam.EuValueDelta;*/ weatherpntmsg[AirTempNo].EuValue = fvalue;/*weatherpntmsg[AirTempNo].AiParam.fFactor + weatherpntmsg[AirTempNo].AiParam.EuValueDelta;*/ } - pPortParam->aiValue[AirTempNo].AiState = Sample; - weatherpntmsg[AirTempNo].AiState = Sample; + pPortParam->aiValue[AirTempNo].AiState = SER_SAMPLE; + weatherpntmsg[AirTempNo].AiState = SER_SAMPLE; //g_SelfTest.SensorsFault |= (0x01); //if ((gDisSunRain & 0x80) == 0x80) { @@ -3235,8 +3235,8 @@ void ShxyProtocolDataProcess( int devno) pPortParam->aiValue[AtmosNo].EuValue = fvalue;/*pPortParam->aiValue[5].AiParam.fFactor + pPortParam->aiValue[5].AiParam.EuValueDelta;*/ weatherpntmsg[AtmosNo].EuValue = fvalue;/*weatherpntmsg[AtmosNo].AiParam.fFactor + weatherpntmsg[AtmosNo].AiParam.EuValueDelta;*/ } - pPortParam->aiValue[AtmosNo].AiState = Sample; - weatherpntmsg[AtmosNo].AiState = Sample; + pPortParam->aiValue[AtmosNo].AiState = SER_SAMPLE; + weatherpntmsg[AtmosNo].AiState = SER_SAMPLE; //g_SelfTest.SensorsFault |= (0x10); //if ((gDisSunRain & 0x80) == 0x80) { @@ -3256,8 +3256,8 @@ void ShxyProtocolDataProcess( int devno) pPortParam->aiValue[HumidityNo].EuValue = fvalue;/*pPortParam->aiValue[1].AiParam.fFactor + pPortParam->aiValue[1].AiParam.EuValueDelta;*/ weatherpntmsg[HumidityNo].EuValue = fvalue;/*weatherpntmsg[HumidityNo].AiParam.fFactor + weatherpntmsg[HumidityNo].AiParam.EuValueDelta;*/ } - pPortParam->aiValue[HumidityNo].AiState = Sample; - weatherpntmsg[HumidityNo].AiState = Sample; + pPortParam->aiValue[HumidityNo].AiState = SER_SAMPLE; + weatherpntmsg[HumidityNo].AiState = SER_SAMPLE; //g_SelfTest.SensorsFault |= (0x02); //if ((gDisSunRain & 0x80) == 0x80) { @@ -3281,8 +3281,8 @@ void ShxyProtocolDataProcess( int devno) pPortParam->aiValue[WindSpeedNo].EuValue = fvalue;/*pPortParam->aiValue[2].AiParam.fFactor + pPortParam->aiValue[2].AiParam.EuValueDelta;*/ weatherpntmsg[WindSpeedNo].EuValue = fvalue;/*weatherpntmsg[WindSpeedNo].AiParam.fFactor + weatherpntmsg[WindSpeedNo].AiParam.EuValueDelta;*/ } - pPortParam->aiValue[WindSpeedNo].AiState = Sample; - weatherpntmsg[WindSpeedNo].AiState = Sample; + pPortParam->aiValue[WindSpeedNo].AiState = SER_SAMPLE; + weatherpntmsg[WindSpeedNo].AiState = SER_SAMPLE; //g_SelfTest.SensorsFault |= (0x04); //if ((gDisSunRain & 0x10) == 0x10) { @@ -3305,8 +3305,8 @@ void ShxyProtocolDataProcess( int devno) pPortParam->aiValue[WindDirectionNo].EuValue = fvalue;/*pPortParam->aiValue[3].AiParam.fFactor + pPortParam->aiValue[3].AiParam.EuValueDelta;*/ weatherpntmsg[WindDirectionNo].EuValue = fvalue;/*weatherpntmsg[WindDirectionNo].AiParam.fFactor + weatherpntmsg[WindDirectionNo].AiParam.EuValueDelta;*/ } - pPortParam->aiValue[WindDirectionNo].AiState = Sample; - weatherpntmsg[WindDirectionNo].AiState = Sample; + pPortParam->aiValue[WindDirectionNo].AiState = SER_SAMPLE; + weatherpntmsg[WindDirectionNo].AiState = SER_SAMPLE; //g_SelfTest.SensorsFault |= (0x08); //if ((gDisSunRain & 0x10) == 0x10) { @@ -3323,7 +3323,7 @@ void ShxyProtocolDataProcess( int devno) +pPortParam->aiValue[0].AiParam.EuValueDelta;*/ //rallypntmsg[aipnt][0].EuValue = fvalue*rallypntmsg[aipnt][0].AiParam.fFactor\ // +rallypntmsg[aipnt][0].AiParam.EuValueDelta; - pPortParam->aiValue[0].AiState = Sample; + pPortParam->aiValue[0].AiState = SER_SAMPLE; //rallypntmsg[aipnt][0].AiState = 1; sprintf(szbuf, "地址%d拉力:%0.3fKg ", devparam[devno].devaddr, fvalue); DebugLog(devparam[devno].commid, szbuf, 'V'); @@ -3343,7 +3343,7 @@ void ShxyProtocolDataProcess( int devno) //slantpntmsg[aipnt][0].EuValue = fvalue*slantpntmsg[aipnt][0].AiParam.fFactor\ //+slantpntmsg[aipnt][0].AiParam.EuValueDelta; } - pPortParam->aiValue[0].AiState = Sample; + pPortParam->aiValue[0].AiState = SER_SAMPLE; //slantpntmsg[aipnt][0].AiState = 1; sprintf(szbuf, "倾角ID:%d slantangle X=%0.3f ", devparam[devno].devaddr, fvalue); break; @@ -3361,7 +3361,7 @@ void ShxyProtocolDataProcess( int devno) pPortParam->aiValue[1].EuValue = fvalue;/*pPortParam->aiValue[1].AiParam.fFactor\ +pPortParam->aiValue[1].AiParam.EuValueDelta;*/ } - pPortParam->aiValue[1].AiState = Sample; + pPortParam->aiValue[1].AiState = SER_SAMPLE; //slantpntmsg[aipnt][1].AiState = 1; break; @@ -3587,9 +3587,9 @@ int GetWeatherData(Data_DEF *data, int datano) return -1; data->EuValue = weatherpntmsg[datano].EuValue; data->AiState = weatherpntmsg[datano].AiState; - if((SampleFail == data->AiState) || (SamplingSuccess == data->AiState)) + if((SER_SAMPLEFAIL == data->AiState) || (SAMPLINGSUCCESS == data->AiState)) { - weatherpntmsg[datano].AiState = Idle; + weatherpntmsg[datano].AiState = SER_IDLE; return 2; } return 1; @@ -3601,9 +3601,9 @@ int GetAirTempData(Data_DEF *airt) return -1; airt->EuValue = weatherpntmsg[AirTempNo].EuValue; airt->AiState = weatherpntmsg[AirTempNo].AiState; - if((SampleFail == airt->AiState) || (SamplingSuccess == airt->AiState)) + if((SER_SAMPLEFAIL == airt->AiState) || (SAMPLINGSUCCESS == airt->AiState)) { - weatherpntmsg[AirTempNo].AiState = Idle; + weatherpntmsg[AirTempNo].AiState = SER_IDLE; return 2; } return 1; @@ -3615,9 +3615,9 @@ int GetHumidityData(Data_DEF *airt) return -1; airt->EuValue = weatherpntmsg[HumidityNo].EuValue; airt->AiState = weatherpntmsg[HumidityNo].AiState; - if((SampleFail == airt->AiState) || (SamplingSuccess == airt->AiState)) + if((SER_SAMPLEFAIL == airt->AiState) || (SAMPLINGSUCCESS == airt->AiState)) { - weatherpntmsg[HumidityNo].AiState = Idle; + weatherpntmsg[HumidityNo].AiState = SER_IDLE; return 2; } return 1; @@ -3629,9 +3629,9 @@ int GetWindSpeedData(Data_DEF *airt) return -1; airt->EuValue = weatherpntmsg[WindSpeedNo].EuValue; airt->AiState = weatherpntmsg[WindSpeedNo].AiState; - if((SampleFail == airt->AiState) || (SamplingSuccess == airt->AiState)) + if((SER_SAMPLEFAIL == airt->AiState) || (SAMPLINGSUCCESS == airt->AiState)) { - weatherpntmsg[WindSpeedNo].AiState = Idle; + weatherpntmsg[WindSpeedNo].AiState = SER_IDLE; return 2; } return 1; @@ -3643,9 +3643,9 @@ int GetWindDirectionData(Data_DEF *airt) return -1; airt->EuValue = weatherpntmsg[WindDirectionNo].EuValue; airt->AiState = weatherpntmsg[WindDirectionNo].AiState; - if((SampleFail == airt->AiState) || (SamplingSuccess == airt->AiState)) + if((SER_SAMPLEFAIL == airt->AiState) || (SAMPLINGSUCCESS == airt->AiState)) { - weatherpntmsg[WindDirectionNo].AiState = Idle; + weatherpntmsg[WindDirectionNo].AiState = SER_IDLE; return 2; } return 1; @@ -3657,9 +3657,9 @@ int GetRainfallData(Data_DEF *airt) return -1; airt->EuValue = weatherpntmsg[RainfallNo].EuValue; airt->AiState = weatherpntmsg[RainfallNo].AiState; - if((SampleFail == airt->AiState) || (SamplingSuccess == airt->AiState)) + if((SER_SAMPLEFAIL == airt->AiState) || (SAMPLINGSUCCESS == airt->AiState)) { - weatherpntmsg[RainfallNo].AiState = Idle; + weatherpntmsg[RainfallNo].AiState = SER_IDLE; return 2; } return 1; @@ -3671,9 +3671,9 @@ int GetAtmosData(Data_DEF *airt) return -1; airt->EuValue = weatherpntmsg[AtmosNo].EuValue; airt->AiState = weatherpntmsg[AtmosNo].AiState; - if((SampleFail == airt->AiState) || (SamplingSuccess == airt->AiState)) + if((SER_SAMPLEFAIL == airt->AiState) || (SAMPLINGSUCCESS == airt->AiState)) { - weatherpntmsg[AtmosNo].AiState = Idle; + weatherpntmsg[AtmosNo].AiState = SER_IDLE; return 2; } return 1; @@ -3685,9 +3685,9 @@ int GetOpticalRadiationData(Data_DEF *airt) return -1; airt->EuValue = weatherpntmsg[OpticalRadiationNo].EuValue; airt->AiState = weatherpntmsg[OpticalRadiationNo].AiState; - if((SampleFail == airt->AiState) || (SamplingSuccess == airt->AiState)) + if((SER_SAMPLEFAIL == airt->AiState) || (SAMPLINGSUCCESS == airt->AiState)) { - weatherpntmsg[OpticalRadiationNo].AiState = Idle; + weatherpntmsg[OpticalRadiationNo].AiState = SER_IDLE; return 2; } return 1; @@ -3703,9 +3703,9 @@ int GetPullValue(int devno, Data_DEF *data) return -1; data->EuValue = srdt.ms_dev[devno].aiValue[0].EuValue; data->AiState = srdt.ms_dev[devno].aiValue[0].AiState; - if((SampleFail == data->AiState) || (SamplingSuccess == data->AiState)) + if((SER_SAMPLEFAIL == data->AiState) || (SAMPLINGSUCCESS == data->AiState)) { - srdt.ms_dev[devno].aiValue[0].AiState = Idle; + srdt.ms_dev[devno].aiValue[0].AiState = SER_IDLE; return 2; } return 1; @@ -3724,9 +3724,9 @@ int GetAngleValue(int devno, Data_DEF *data, int Xy) data->EuValue = srdt.ms_dev[devno].aiValue[Xy].EuValue; data->AiState = srdt.ms_dev[devno].aiValue[Xy].AiState; - if((SampleFail == data->AiState) || (SamplingSuccess == data->AiState)) + if((SER_SAMPLEFAIL == data->AiState) || (SAMPLINGSUCCESS == data->AiState)) { - srdt.ms_dev[devno].aiValue[Xy].AiState = Idle; + srdt.ms_dev[devno].aiValue[Xy].AiState = SER_IDLE; return 2; } return 1; @@ -3746,9 +3746,9 @@ int GetImage(int devno, IMAGE_DEF *photo) memmove(photo->photoname, srdt.ms_dev[devno].image.photoname, sizeof(photo->photoname)); photo->imagelen = srdt.ms_dev[devno].image.imagelen; photo->state = srdt.ms_dev[devno].image.state; - if((SampleFail == photo->state) || (SamplingSuccess == photo->state)) + if((SER_SAMPLEFAIL == photo->state) || (SAMPLINGSUCCESS == photo->state)) { - srdt.ms_dev[devno].image.state = Idle; + srdt.ms_dev[devno].image.state = SER_IDLE; return 2; } return 1; diff --git a/app/src/main/cpp/SensorsProtocol.h b/app/src/main/cpp/SensorsProtocol.h index 6b9cc830..3b40e8bb 100644 --- a/app/src/main/cpp/SensorsProtocol.h +++ b/app/src/main/cpp/SensorsProtocol.h @@ -63,11 +63,11 @@ typedef long long LONG; #define AtmosNo 5 /* 大气压数据存储序号*/ #define OpticalRadiationNo 6 /* 日照(光辐射)数据存储序号*/ -#define Idle 0 /* 传感器处于空闲状态,未启动采样*/ -#define Sample 1 /* 正在采样过程中*/ -#define SamplingSuccess 2 /* 采样结束,正常读取到数据*/ -#define StartSample 3 /* 启动采样*/ -#define SampleFail -1 /* 采样失败,未采集到数据,传感器故障或未接*/ +#define SER_IDLE 0 /* 传感器处于空闲状态,未启动采样*/ +#define SER_SAMPLE 1 /* 正在采样过程中*/ +#define SAMPLINGSUCCESS 2 /* 采样结束,正常读取到数据*/ +#define SER_STARTSAMPLE 3 /* 启动采样*/ +#define SER_SAMPLEFAIL -1 /* 采样失败,未采集到数据,传感器故障或未接*/ #define PHOTO_SAVE_SUCC 5 /* 图片保存成功*/ #define WEATHER_DATA_NUM 8 /* 气象数据最大数量(一般最多是6要素)*/ diff --git a/app/src/main/cpp/~$函数调用说明.docx b/app/src/main/cpp/~$函数调用说明.docx deleted file mode 100644 index 040ecd4c..00000000 Binary files a/app/src/main/cpp/~$函数调用说明.docx and /dev/null differ