|
@@ -1052,12 +1052,17 @@ void TestService::OnTimer2()
|
|
Ret_Value TestService::Pressure_RoughAdjust(const TestExpect& expect)
|
|
Ret_Value TestService::Pressure_RoughAdjust(const TestExpect& expect)
|
|
{
|
|
{
|
|
Ret_Value ret_v = Ret_OK;
|
|
Ret_Value ret_v = Ret_OK;
|
|
- int count = 0;
|
|
|
|
|
|
+ int keep_count = 0;
|
|
|
|
|
|
bool bOpen1 = false;
|
|
bool bOpen1 = false;
|
|
bool bOpen2 = false;
|
|
bool bOpen2 = false;
|
|
bool bOpen3 = false;
|
|
bool bOpen3 = false;
|
|
|
|
|
|
|
|
+ //bool inTake_Open = false;
|
|
|
|
+ int exceed_times = 0;
|
|
|
|
+ int exceed_count = 0;
|
|
|
|
+ int delay_count = 0;
|
|
|
|
+
|
|
QElapsedTimer timer;
|
|
QElapsedTimer timer;
|
|
timer.start();
|
|
timer.start();
|
|
float current_pressure;
|
|
float current_pressure;
|
|
@@ -1067,9 +1072,13 @@ Ret_Value TestService::Pressure_RoughAdjust(const TestExpect& expect)
|
|
|
|
|
|
current_pressure = calculate_averagepressure();
|
|
current_pressure = calculate_averagepressure();
|
|
|
|
|
|
- if(current_pressure >= expect.target+0.1){
|
|
|
|
|
|
+ if(current_pressure >= expect.target+0.02){
|
|
|
|
|
|
- count++;
|
|
|
|
|
|
+ if(0 == exceed_count){
|
|
|
|
+ exceed_times++;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ exceed_count++;
|
|
|
|
|
|
if(bOpen1){
|
|
if(bOpen1){
|
|
if(Valve_op(Valve_ID_ROUGH_0, Valve_OP_Close))
|
|
if(Valve_op(Valve_ID_ROUGH_0, Valve_OP_Close))
|
|
@@ -1086,32 +1095,74 @@ Ret_Value TestService::Pressure_RoughAdjust(const TestExpect& expect)
|
|
bOpen3 = false;
|
|
bOpen3 = false;
|
|
}
|
|
}
|
|
|
|
|
|
- //break;
|
|
|
|
- }else if(current_pressure < expect.target) {
|
|
|
|
|
|
+ if(exceed_count >= 30){
|
|
|
|
+ keep_count = 50;
|
|
|
|
+ }
|
|
|
|
|
|
- count =0;
|
|
|
|
|
|
+ if(exceed_times == 1){
|
|
|
|
+ delay_count = 15;
|
|
|
|
+ }else if(exceed_times == 2){
|
|
|
|
+ delay_count = 10;
|
|
|
|
+ }else {
|
|
|
|
+ delay_count = 5;
|
|
|
|
+ }
|
|
|
|
|
|
- if(!bOpen1){
|
|
|
|
- bOpen1 = Valve_op(Valve_ID_ROUGH_0, Valve_OP_Open);
|
|
|
|
|
|
+ //break;
|
|
|
|
+ }else if(current_pressure >= expect.target && current_pressure < expect.target+0.02){
|
|
|
|
+ //从超出, 回落到该区间
|
|
|
|
+ if(exceed_count > 0){
|
|
|
|
+ keep_count++;
|
|
}
|
|
}
|
|
|
|
|
|
- if(!bOpen2){
|
|
|
|
- bOpen2 = Valve_op(Valve_ID_ROUGH_1, Valve_OP_Open);
|
|
|
|
|
|
+ //exceed_count = 0;
|
|
|
|
+
|
|
|
|
+ }else if(current_pressure < expect.target) {
|
|
|
|
+
|
|
|
|
+ exceed_count =0;
|
|
|
|
+ if(delay_count > 0){
|
|
|
|
+ delay_count--;
|
|
}
|
|
}
|
|
|
|
|
|
- if(!bOpen3){
|
|
|
|
- bOpen3 = Valve_op(Valve_ID_ROUGH_2, Valve_OP_Open);
|
|
|
|
|
|
+ if(0 == delay_count){
|
|
|
|
+
|
|
|
|
+ if(0 == exceed_times){
|
|
|
|
+ if(!bOpen1){
|
|
|
|
+ bOpen1 = Valve_op(Valve_ID_ROUGH_0, Valve_OP_Open);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!bOpen2){
|
|
|
|
+ bOpen2 = Valve_op(Valve_ID_ROUGH_1, Valve_OP_Open);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!bOpen3){
|
|
|
|
+ bOpen3 = Valve_op(Valve_ID_ROUGH_2, Valve_OP_Open);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }else if(1 == exceed_times){
|
|
|
|
+ if(!bOpen1){
|
|
|
|
+ bOpen1 = Valve_op(Valve_ID_ROUGH_0, Valve_OP_Open);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!bOpen2){
|
|
|
|
+ bOpen2 = Valve_op(Valve_ID_ROUGH_1, Valve_OP_Open);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ if(!bOpen1){
|
|
|
|
+ bOpen1 = Valve_op(Valve_ID_ROUGH_0, Valve_OP_Open);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
- }else{
|
|
|
|
- count++;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- if(count >= 240){ //about 60s
|
|
|
|
|
|
+ if(keep_count >= 30){ //about 60s
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
- QThread::msleep(500);
|
|
|
|
|
|
+ QThread::msleep(1000);
|
|
|
|
|
|
int remainingtime = expect.timeout*1000 - timer.elapsed();
|
|
int remainingtime = expect.timeout*1000 - timer.elapsed();
|
|
if(remainingtime <= 0){
|
|
if(remainingtime <= 0){
|
|
@@ -1153,36 +1204,85 @@ Ret_Value TestService::Pressure_Adjust(const TestExpect& expect)
|
|
{
|
|
{
|
|
PID pid = PID(1, 20, -10, 5.1, 28.0, 1.0);
|
|
PID pid = PID(1, 20, -10, 5.1, 28.0, 1.0);
|
|
|
|
|
|
- float current_pressure;
|
|
|
|
|
|
+ double current_pressure;
|
|
|
|
+ //double last_pressure;
|
|
Ret_Value ret_v = Ret_OK;
|
|
Ret_Value ret_v = Ret_OK;
|
|
int voltage_offset = 0;
|
|
int voltage_offset = 0;
|
|
int keep_times = 0;
|
|
int keep_times = 0;
|
|
QElapsedTimer timer;
|
|
QElapsedTimer timer;
|
|
|
|
+ bool inTake_Open = false;
|
|
|
|
+ int exceed_times = 0;
|
|
|
|
+ int exceed_count = 0;
|
|
|
|
+ int delay_count = 0;
|
|
|
|
+
|
|
|
|
|
|
- Valve_op(Valve_ID_INTAKE, Valve_OP_Open);
|
|
|
|
|
|
+ inTake_Open = Valve_op(Valve_ID_INTAKE, Valve_OP_Open);
|
|
timer.start();
|
|
timer.start();
|
|
|
|
|
|
while(m_bRunning){
|
|
while(m_bRunning){
|
|
|
|
|
|
current_pressure = calculate_averagepressure();
|
|
current_pressure = calculate_averagepressure();
|
|
|
|
|
|
- double inc = pid.calculate(expect.target, current_pressure);
|
|
|
|
|
|
+ if(current_pressure > expect.target + 0.05){
|
|
|
|
+ if(exceed_count == 0){
|
|
|
|
+ exceed_times++;
|
|
|
|
+ }
|
|
|
|
|
|
- voltage_offset = (inc);
|
|
|
|
|
|
+ exceed_count++;
|
|
|
|
+ if(inTake_Open == true){
|
|
|
|
+ if(Valve_op(Valve_ID_INTAKE, Valve_OP_Close)){
|
|
|
|
+ inTake_Open = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- if(!Adjust_pressure(expect.start_voltage+voltage_offset)){
|
|
|
|
- QThread::msleep(200);
|
|
|
|
- if(!Adjust_pressure(expect.start_voltage+voltage_offset)){
|
|
|
|
- qDebug("communication error, ajust_pressure failed");
|
|
|
|
- ret_v = Ret_Failed;
|
|
|
|
- break;
|
|
|
|
|
|
+ if(exceed_count > 15){
|
|
|
|
+ keep_times = 20;
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- if(abs(current_pressure - (expect.target+0.05)) < 0.05){
|
|
|
|
- keep_times++;
|
|
|
|
|
|
+ if(exceed_times == 1){
|
|
|
|
+ delay_count = 15;
|
|
|
|
+ }else if(exceed_times == 2){
|
|
|
|
+ delay_count = 10;
|
|
|
|
+ }else{
|
|
|
|
+ delay_count = 5;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }else if(current_pressure >= expect.target && current_pressure <= expect.target+0.05){
|
|
|
|
+ if(exceed_count > 0){
|
|
|
|
+ keep_times = 20;
|
|
|
|
+ }
|
|
|
|
+ exceed_count= 0;
|
|
|
|
+
|
|
}else{
|
|
}else{
|
|
- keep_times=0;
|
|
|
|
|
|
+
|
|
|
|
+ exceed_count= 0;
|
|
|
|
+ if(delay_count > 0){
|
|
|
|
+ delay_count--;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(0 == delay_count){
|
|
|
|
+
|
|
|
|
+ if(false == inTake_Open){
|
|
|
|
+ inTake_Open = Valve_op(Valve_ID_INTAKE, Valve_OP_Open);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ double inc = pid.calculate(expect.target, current_pressure);
|
|
|
|
+
|
|
|
|
+ voltage_offset = (inc);
|
|
|
|
+
|
|
|
|
+ if(!Adjust_pressure(expect.start_voltage+voltage_offset)){
|
|
|
|
+ QThread::msleep(200);
|
|
|
|
+ if(!Adjust_pressure(expect.start_voltage+voltage_offset)){
|
|
|
|
+ qDebug("communication error, ajust_pressure failed");
|
|
|
|
+ ret_v = Ret_Failed;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
if(keep_times >= 15){
|
|
if(keep_times >= 15){
|
|
@@ -1191,8 +1291,6 @@ Ret_Value TestService::Pressure_Adjust(const TestExpect& expect)
|
|
|
|
|
|
QThread::msleep(1000);
|
|
QThread::msleep(1000);
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
int remainingtime = expect.timeout*1000 - timer.elapsed();
|
|
int remainingtime = expect.timeout*1000 - timer.elapsed();
|
|
if(remainingtime < 0){
|
|
if(remainingtime < 0){
|
|
ret_v = Ret_Timeout;
|
|
ret_v = Ret_Timeout;
|
|
@@ -1202,6 +1300,7 @@ Ret_Value TestService::Pressure_Adjust(const TestExpect& expect)
|
|
}
|
|
}
|
|
|
|
|
|
Valve_op(Valve_ID_INTAKE, Valve_OP_Close);
|
|
Valve_op(Valve_ID_INTAKE, Valve_OP_Close);
|
|
|
|
+ Adjust_pressure(0);
|
|
|
|
|
|
if(!m_bRunning){
|
|
if(!m_bRunning){
|
|
// be stoped
|
|
// be stoped
|
|
@@ -1400,6 +1499,51 @@ Ret_Value TestService::Pressure_Relief(const TestExpect& expect)
|
|
return ret_v;
|
|
return ret_v;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+Ret_Value TestService::Pressure_Relief()
|
|
|
|
+{
|
|
|
|
+ Ret_Value ret_v = Ret_OK;
|
|
|
|
+ bool bVent_Open = false;
|
|
|
|
+
|
|
|
|
+ Valve_op(Valve_ID_PRESSURESENSOR, Valve_OP_Open);
|
|
|
|
+
|
|
|
|
+ //等待压力清零
|
|
|
|
+ float current_pressure;
|
|
|
|
+ int keep_count = 0;
|
|
|
|
+
|
|
|
|
+ while(m_bRunning){
|
|
|
|
+
|
|
|
|
+ //打开泄压阀
|
|
|
|
+ if(bVent_Open == false){
|
|
|
|
+ bVent_Open = Valve_op(Valve_ID_VENT, Valve_OP_Open);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ QThread::msleep(1000);
|
|
|
|
+
|
|
|
|
+ current_pressure = calculate_averagepressure();
|
|
|
|
+ if(abs(current_pressure) < 0.5){
|
|
|
|
+ keep_count++;
|
|
|
|
+ if(keep_count > 10){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ keep_count = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //关闭泄压阀
|
|
|
|
+ if(bVent_Open == true){
|
|
|
|
+ Valve_op(Valve_ID_VENT, Valve_OP_Close);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!m_bRunning){
|
|
|
|
+ ret_v = Ret_Exit;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return ret_v;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
Ret_Value TestService::Pressure_Keep(int keeptime, float threshold, float& delta)
|
|
Ret_Value TestService::Pressure_Keep(int keeptime, float threshold, float& delta)
|
|
{
|
|
{
|
|
int count = 0;
|
|
int count = 0;
|
|
@@ -1537,7 +1681,7 @@ void TestService::run()
|
|
Valve_op(Valve_ID_PRESSURESENSOR, Valve_OP_Open);
|
|
Valve_op(Valve_ID_PRESSURESENSOR, Valve_OP_Open);
|
|
|
|
|
|
// 如果容积大于 1000L , 才进入粗调步骤
|
|
// 如果容积大于 1000L , 才进入粗调步骤
|
|
- if(m_tank.get_compartment(m_compartmentid).m_volume >= 1000){
|
|
|
|
|
|
+ if(m_tank.get_compartment(m_compartmentid).m_volume >= 500){
|
|
m_step = Test_Step_AddPressure;
|
|
m_step = Test_Step_AddPressure;
|
|
}else{
|
|
}else{
|
|
m_step = Test_Step_AdjustPressure;
|
|
m_step = Test_Step_AdjustPressure;
|
|
@@ -1988,7 +2132,7 @@ void TestService::run()
|
|
|
|
|
|
// 检测 5分钟都没超限,就是通过了
|
|
// 检测 5分钟都没超限,就是通过了
|
|
float delta = 0;
|
|
float delta = 0;
|
|
- float threshold = 0.2;
|
|
|
|
|
|
+ float threshold = 0.6;
|
|
bool bPassed = true;
|
|
bool bPassed = true;
|
|
|
|
|
|
ret_v = Pressure_Keep(5*60, threshold, delta);
|
|
ret_v = Pressure_Keep(5*60, threshold, delta);
|
|
@@ -2050,7 +2194,8 @@ void TestService::run()
|
|
case QMessageBox::Yes:
|
|
case QMessageBox::Yes:
|
|
qDebug()<<"Yes";
|
|
qDebug()<<"Yes";
|
|
// 打开泄压阀
|
|
// 打开泄压阀
|
|
- Valve_op(Valve_ID_VENT, Valve_OP_Open);
|
|
|
|
|
|
+ //Valve_op(Valve_ID_VENT, Valve_OP_Open);
|
|
|
|
+ Pressure_Relief();
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
@@ -2069,6 +2214,7 @@ void TestService::run()
|
|
|
|
|
|
// 复位
|
|
// 复位
|
|
Adjust_pressure(0);
|
|
Adjust_pressure(0);
|
|
|
|
+ Valve_op(Valve_ID_All, Valve_OP_Close);
|
|
|
|
|
|
//m_pTimer_1->stop();
|
|
//m_pTimer_1->stop();
|
|
|
|
|