|
@@ -45,6 +45,7 @@ static signed short WeightConst_WeightCur_last3=0;
|
|
|
|
|
|
static long WeightConst_WeightSum = 0; //当前重量总和
|
|
static long WeightConst_WeightSum = 0; //当前重量总和
|
|
unsigned char WeightConst_oksum = 0; //符合目标重量数
|
|
unsigned char WeightConst_oksum = 0; //符合目标重量数
|
|
|
|
+unsigned char WeightConst_joksum = 0; //符合目标重量数
|
|
unsigned char WeightConst_allsum = 0; //总重量值数
|
|
unsigned char WeightConst_allsum = 0; //总重量值数
|
|
static unsigned char WeightConst_uoksum = 0;
|
|
static unsigned char WeightConst_uoksum = 0;
|
|
static unsigned char WeightConst_foksum = 0;
|
|
static unsigned char WeightConst_foksum = 0;
|
|
@@ -161,7 +162,10 @@ static void setWeightSM() { //
|
|
WeightConst_oksum++;
|
|
WeightConst_oksum++;
|
|
WeightConst_WeightOK=WeightConst_WeightCurTem;
|
|
WeightConst_WeightOK=WeightConst_WeightCurTem;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ if (WeightConst_WeightCurTem > WeightConst_WeightTargetAllowMax)
|
|
|
|
+ WeightConst_joksum++;
|
|
|
|
+
|
|
//WeightConst_WeightTargetAllow
|
|
//WeightConst_WeightTargetAllow
|
|
if ((WeightConst_WeightCurTem>WeightConst_WeightTargetAllowMin && pf_comp.data.addorout==0)
|
|
if ((WeightConst_WeightCurTem>WeightConst_WeightTargetAllowMin && pf_comp.data.addorout==0)
|
|
||(WeightConst_WeightCurTem<WeightConst_WeightTargetAllowMin && pf_comp.data.addorout==1))
|
|
||(WeightConst_WeightCurTem<WeightConst_WeightTargetAllowMin && pf_comp.data.addorout==1))
|
|
@@ -267,7 +271,10 @@ void CheckWeightthread(void) {
|
|
if (WeightConst_WeightCount>0)
|
|
if (WeightConst_WeightCount>0)
|
|
WeightConst_WeightCur = WeightConst_WeightSum / WeightConst_WeightCount;
|
|
WeightConst_WeightCur = WeightConst_WeightSum / WeightConst_WeightCount;
|
|
|
|
|
|
-
|
|
|
|
|
|
+ WeightConst_WeightSum = 0;
|
|
|
|
+ WeightConst_WeightCount = 0; //重量数
|
|
|
|
+ WeightConst_WeightMax = -32768; //最大重量
|
|
|
|
+ WeightConst_WeightMin = 32767; //最小重量
|
|
if (WeightConst_WeightCurCount >= 0x0F) { //15秒准备发送后台重
|
|
if (WeightConst_WeightCurCount >= 0x0F) { //15秒准备发送后台重
|
|
rt_sem_take(setTIME_lock, RT_WAITING_FOREVER);
|
|
rt_sem_take(setTIME_lock, RT_WAITING_FOREVER);
|
|
timeweight.Buffer[3] =TimeConst.Buffer[0];
|
|
timeweight.Buffer[3] =TimeConst.Buffer[0];
|
|
@@ -293,22 +300,12 @@ void CheckWeightthread(void) {
|
|
}
|
|
}
|
|
rt_sem_release(weight_lock);
|
|
rt_sem_release(weight_lock);
|
|
if (WeightConst_Product_Run > 0) {
|
|
if (WeightConst_Product_Run > 0) {
|
|
- if (WeightConst_AutoSingleNSecondPoint>=pf_comp.data.autosecond || WeightConst_AutoSingleNSecondPoint>=30)
|
|
|
|
|
|
+ if (WeightConst_AutoSingleNSecondPoint >= (pf_comp.data.autosecond * 3) || WeightConst_AutoSingleNSecondPoint>=30)
|
|
WeightConst_AutoSingleNSecondPoint = 0;
|
|
WeightConst_AutoSingleNSecondPoint = 0;
|
|
|
|
|
|
WeightConst_AutoSingleNSecondNum[WeightConst_AutoSingleNSecondPoint][0] = WeightConst_oksum;
|
|
WeightConst_AutoSingleNSecondNum[WeightConst_AutoSingleNSecondPoint][0] = WeightConst_oksum;
|
|
WeightConst_AutoSingleNSecondNum[WeightConst_AutoSingleNSecondPoint][1] = WeightConst_allsum;
|
|
WeightConst_AutoSingleNSecondNum[WeightConst_AutoSingleNSecondPoint][1] = WeightConst_allsum;
|
|
- if (//( WeightConst_WeightMax - WeightConst_WeightMin)>WeightConst_WeightTargetAllow &&
|
|
|
|
- WeightConst_WeightCur > WeightConst_WeightTargetAllowMax
|
|
|
|
- && pf_comp.data.autosecond>0 && WeightConst_WeightHaveBegin==1)
|
|
|
|
- WeightConst_AutoSingleNSecondNum[WeightConst_AutoSingleNSecondPoint][2] = 1;
|
|
|
|
- else
|
|
|
|
- WeightConst_AutoSingleNSecondNum[WeightConst_AutoSingleNSecondPoint][2] = 0;
|
|
|
|
-
|
|
|
|
- WeightConst_WeightSum = 0;
|
|
|
|
- WeightConst_WeightCount = 0; //重量数
|
|
|
|
- WeightConst_WeightMax = -32768; //最大重量
|
|
|
|
- WeightConst_WeightMin = 32767; //最小重量
|
|
|
|
|
|
+ WeightConst_AutoSingleNSecondNum[WeightConst_AutoSingleNSecondPoint][2] = WeightConst_joksum;
|
|
|
|
|
|
WeightConst_AutoSingleNSecondPoint++;
|
|
WeightConst_AutoSingleNSecondPoint++;
|
|
|
|
|
|
@@ -316,7 +313,7 @@ void CheckWeightthread(void) {
|
|
WeightConst_uallsum = 0;
|
|
WeightConst_uallsum = 0;
|
|
WeightConst_foksum = 0;
|
|
WeightConst_foksum = 0;
|
|
|
|
|
|
- for (int CheckWeight_i = 0; CheckWeight_i < pf_comp.data.autosecond; CheckWeight_i++) {
|
|
|
|
|
|
+ for (int CheckWeight_i = 0; CheckWeight_i < (pf_comp.data.autosecond * 3); CheckWeight_i++) {
|
|
WeightConst_uoksum = WeightConst_uoksum + WeightConst_AutoSingleNSecondNum[CheckWeight_i][0];
|
|
WeightConst_uoksum = WeightConst_uoksum + WeightConst_AutoSingleNSecondNum[CheckWeight_i][0];
|
|
WeightConst_uallsum = WeightConst_uallsum + WeightConst_AutoSingleNSecondNum[CheckWeight_i][1];
|
|
WeightConst_uallsum = WeightConst_uallsum + WeightConst_AutoSingleNSecondNum[CheckWeight_i][1];
|
|
WeightConst_foksum = WeightConst_foksum + WeightConst_AutoSingleNSecondNum[CheckWeight_i][2];
|
|
WeightConst_foksum = WeightConst_foksum + WeightConst_AutoSingleNSecondNum[CheckWeight_i][2];
|
|
@@ -347,11 +344,13 @@ void CheckWeightthread(void) {
|
|
}
|
|
}
|
|
|
|
|
|
WeightConst_oksum = 0;
|
|
WeightConst_oksum = 0;
|
|
|
|
+ WeightConst_joksum = 0;
|
|
WeightConst_allsum = 0;
|
|
WeightConst_allsum = 0;
|
|
WeightConst_uoksum = 0;
|
|
WeightConst_uoksum = 0;
|
|
WeightConst_uallsum = 0;
|
|
WeightConst_uallsum = 0;
|
|
WeightConst_foksum = 0;
|
|
WeightConst_foksum = 0;
|
|
// sendWeight(); //检查是否需要保存实时重量
|
|
// sendWeight(); //检查是否需要保存实时重量
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
WeightConst_WeightCurCount++;
|
|
WeightConst_WeightCurCount++;
|
|
@@ -370,7 +369,7 @@ void CheckWeightthread(void) {
|
|
// WeightConst_Product_Run_time = 0;
|
|
// WeightConst_Product_Run_time = 0;
|
|
HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR3, WeightConst_Product_Run_time);
|
|
HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR3, WeightConst_Product_Run_time);
|
|
}
|
|
}
|
|
- rt_thread_mdelay(998);
|
|
|
|
|
|
+ rt_thread_mdelay(1000);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|