Commit 6951756a authored by 李冠华's avatar 李冠华

🐞 fix:优化检测台对比仪表发来的数据对比策略,改为每次上电后第一次为请求重发,之后在发正常写入的值。优化上下电策略

parent e9f5f19a
......@@ -3,8 +3,8 @@
uint32_t BenCiXieRuNum = 0U;
uint32_t TotalExecutionNum = 0U;
uint32_t LastNum = 0U;
uint32_t BeforeLastNum = 0U;
uint32_t XieRuLookaheadNum = 0U;
uint32_t XieRuLagNum = 0U;
uint32_t ReceivedValue = 0U;
uint8_t RenWuDelay = 0U;
uint8_t errNum = 0U;
......@@ -17,6 +17,7 @@ uint32_t RS485TXBenCiXieRuNum = 0u;
uint32_t RS485TXTotalExecutionNum = 0u;
uint8_t RerequestCount = 0U;
uint8_t UARTRxBufClean = 0u;
uint32_t BenCiXieRuStoreArr[2] = {0U,0U}; /*此值用于存储刚给表写入的值。当表回复后此值在变化*/
static void NVS_Test_BenCiXieRuNum(void);
static void NVS_Test_Rerequest(void);
......@@ -25,8 +26,8 @@ void NVS_Test_Init(void)
{
BenCiXieRuNum = 0U;
TotalExecutionNum = 0U;
LastNum = 0xFFFFFFFFU;
BeforeLastNum = 0xFFFFFFFFU;
XieRuLookaheadNum = 0xFFFFFFFFU;
XieRuLagNum = 0xFFFFFFFFU;
ReceivedValue = 0U;
RenWuDelay = 0U;
errNum = 0U;
......@@ -39,6 +40,8 @@ void NVS_Test_Init(void)
RS485TXTotalExecutionNum = 0u;
RerequestCount = 0U;
UARTRxBufClean = 0U;
BenCiXieRuStoreArr[0] = 0U;
BenCiXieRuStoreArr[1] = 0U;
}
void NVS_Test_Service(void)
......@@ -49,12 +52,12 @@ void NVS_Test_Service(void)
{
if (errNum == 0U)
{
BeforeLastNum = LastNum;
LastNum = BenCiXieRuNum;
NVS_Test_BenCiXieRuNum();
// XieRuLagNum = XieRuLookaheadNum;
// XieRuLookaheadNum = BenCiXieRuNum;
// NVS_Test_BenCiXieRuNum();
RS485_TX_finish = 0U;/*上电后满足等待时间后,开始发第一帧信号*/
RS485TXBenCiXieRuNum = BenCiXieRuNum;
RS485TXTotalExecutionNum = TotalExecutionNum;
RS485TXBenCiXieRuNum = 0xFFFFEEEEU;
RS485TXTotalExecutionNum = 0xFFFFEEEEU;
huifudelayCount = 0u;
}
}
......@@ -69,11 +72,11 @@ void NVS_Test_Service(void)
huifudelayCount = 0u;
UARTRxBufClean = 0U;
if (TotalExecutionNum != 0U)
if (TotalExecutionNum > 1U)
{
if(JieShouDaoValue != LastNum)
if(JieShouDaoValue != XieRuLagNum)
{
if ((JieShouDaoValue == BeforeLastNum) && (BenCiShangDianZhiXingCount == 0U))
if ((JieShouDaoValue == XieRuLookaheadNum) && (BenCiShangDianZhiXingCount <= 1U))
{
;
}
......@@ -89,18 +92,19 @@ void NVS_Test_Service(void)
StopFlag = 0u;
RerequestCount = 0U;
BenCiShangDianZhiXingCount ++;
BeforeLastNum = LastNum;
LastNum = BenCiXieRuNum;
NVS_Test_BenCiXieRuNum();
TotalExecutionNum ++;
RS485TXBenCiXieRuNum = BenCiXieRuNum;
RS485TXTotalExecutionNum = TotalExecutionNum;
BenCiXieRuStoreArr[1] = BenCiXieRuStoreArr[0];
BenCiXieRuStoreArr[0] = BenCiXieRuNum;
RS485_TX_finish = 0U;/*执行读的功能,对比完没问题再重新外发*/
}
else
{
if(RerequestCount < 3U)
{
StopFlag = 1u;
NVS_Test_Rerequest();
errNum = 0U;
RerequestCount ++;
......@@ -158,7 +162,6 @@ static void NVS_Test_BenCiXieRuNum(void)
static void NVS_Test_Rerequest(void)
{
StopFlag = 1u;
RS485TXBenCiXieRuNum = 0xFFFFEEEEU;
RS485TXTotalExecutionNum = 0xFFFFEEEEU;
RS485_TX_finish = 0U;
......
......@@ -14,8 +14,8 @@
extern uint32_t BenCiXieRuNum;
extern uint32_t TotalExecutionNum;
extern uint32_t LastNum;
extern uint32_t BeforeLastNum;
extern uint32_t XieRuLookaheadNum;
extern uint32_t XieRuLagNum;
extern uint32_t ReceivedValue;
extern uint8_t RenWuDelay;
extern uint32_t TurnOffPowerCount;
......@@ -27,6 +27,8 @@ extern uint16_t huifudelayCount;
extern uint8_t StopFlag;
extern uint32_t RS485TXBenCiXieRuNum;
extern uint32_t RS485TXTotalExecutionNum;
extern uint32_t BenCiXieRuStoreArr[2];
extern void NVS_Test_Init(void);
......
......@@ -42,6 +42,12 @@ void Power_Control_Count(void)
}
}
}
else if(StopFlag == 2U)
{
/*为了进入断电状态*/
PowerCountNum = SHANG_DIAN_TIMES + ShangDianOffset + 1;
StopFlag = 0U;
}
else
{
KL1530ON = 1U;
......
......@@ -10,7 +10,7 @@
#define DUAN_DIAN_STATE 1 /*0--只控制13.5V电,1--控制所有电*/
#define SHANG_DIAN_TIMES 250U /*上电时间*/
#define DUAN_DIAN_TIMES 30U /*断电时长,3s*/
#define DUAN_DIAN_TIMES 40U /*断电时长,4s*/
extern uint8_t KL1530ON;
......
......@@ -354,6 +354,13 @@ void RS485_User_Tx_Data(void)
// RS485_TX_finish = 0U;
if(sendfinishflag == 0)
{
if ((RS485TXBenCiXieRuNum != 0xFFFFEEEEU) && (RS485TXTotalExecutionNum != 0xFFFFEEEEU) && (BenCiShangDianZhiXingCount > 1U) )
{
/*当不是请求重发任务时,发出仪表要写入的数据后,XieRuLookaheadNum立刻置为刚刚要写入的值*/
XieRuLagNum = BenCiXieRuStoreArr[1];
XieRuLookaheadNum = BenCiXieRuStoreArr[0];
}
RS485_TX_finish = 1U;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment