Commit 49b38109 authored by 潘栩锋's avatar 潘栩锋 :bicyclist:

优化 AD盒脉冲3秒不变化。 状态设置为手动停止

parent 6e5f6b50
...@@ -348,7 +348,10 @@ namespace FlyADBase ...@@ -348,7 +348,10 @@ namespace FlyADBase
/// 用于检测当 为IsRunning时,脉冲是否停了很久。 /// 用于检测当 为IsRunning时,脉冲是否停了很久。
/// </summary> /// </summary>
int last_position = int.MinValue; int last_position = int.MinValue;
/// <summary>
/// 脉冲不变化次数
/// </summary>
int position_no_changed_cnt = 0;
TimeSpan NoTGridTimeOut = TimeSpan.FromSeconds(60); TimeSpan NoTGridTimeOut = TimeSpan.FromSeconds(60);
...@@ -456,17 +459,32 @@ namespace FlyADBase ...@@ -456,17 +459,32 @@ namespace FlyADBase
() => () =>
{ {
if (!IsConnected) if (!IsConnected)
{
position_no_changed_cnt = 0;
return; return;
}
if (DriveStatus != DRIVE_MAN_STATUS.RUNNING) if (DriveStatus != DRIVE_MAN_STATUS.RUNNING)
{
position_no_changed_cnt = 0;
return; return;
}
if (Position != last_position) if (Position != last_position)
{ {
last_position = Position; last_position = Position;
position_no_changed_cnt = 0;
return; return;
} }
position_no_changed_cnt++;
if (driveman_wait.CheckMark(TimeSpan.FromSeconds(3)))//每3秒检查一次 if (position_no_changed_cnt >= 3) {
//连续3秒,脉冲一样
//异常
DriveStatus = DRIVE_MAN_STATUS.STOP_MANUAL;
position_no_changed_cnt = 0;
return;
}
if (driveman_wait.CheckMark(TimeSpan.FromSeconds(2)))//每2秒检查一次
{ {
driveman_wait.Mark(); driveman_wait.Mark();
CurrObjSys.GetValueEx( CurrObjSys.GetValueEx(
......
...@@ -128,24 +128,7 @@ namespace FLY.Thick.Base.Server ...@@ -128,24 +128,7 @@ namespace FLY.Thick.Base.Server
FinishEvent?.Invoke(this, null); FinishEvent?.Invoke(this, null);
base.Stop(); base.Stop();
} }
bool WaitFinish(ref CTRLST src, CTRLST next)
{
switch (mFlyAD.DriveStatus)
{
case DRIVE_MAN_STATUS.STOP://完成任务
case DRIVE_MAN_STATUS.LIMIT:
{
src = next;
return true;
} break;
case DRIVE_MAN_STATUS.STOP_MANUAL://异常
{
NotifyError(ERRNO_Running_Manual);
Stop(); return false;
} break;
}
return false;
}
protected override void OnPoll() protected override void OnPoll()
{ {
switch (state) switch (state)
...@@ -164,7 +147,21 @@ namespace FLY.Thick.Base.Server ...@@ -164,7 +147,21 @@ namespace FLY.Thick.Base.Server
break; break;
case CTRLST.ORIGINWAIT: case CTRLST.ORIGINWAIT:
{ {
WaitFinish(ref state, CTRLST.FORWARD); switch (mFlyAD.DriveStatus)
{
case DRIVE_MAN_STATUS.STOP://完成任务
{
state = CTRLST.FORWARD;
}
break;
case DRIVE_MAN_STATUS.LIMIT:
case DRIVE_MAN_STATUS.STOP_MANUAL://异常
{
NotifyError(ERRNO_Running_Manual);
Stop();
}
break;
}
} break; } break;
case CTRLST.FORWARD: case CTRLST.FORWARD:
{ {
...@@ -192,8 +189,11 @@ namespace FLY.Thick.Base.Server ...@@ -192,8 +189,11 @@ namespace FLY.Thick.Base.Server
} break; } break;
case CTRLST.FORWAIT_1: case CTRLST.FORWAIT_1:
{ {
if (WaitFinish(ref state, CTRLST.FORWAIT_2)) if (WaitFinish())
{
state= CTRLST.FORWAIT_2;
FlushAD(DIRECTION.FORWARD); FlushAD(DIRECTION.FORWARD);
}
} break; } break;
case CTRLST.FORWAIT_2: case CTRLST.FORWAIT_2:
...@@ -220,7 +220,9 @@ namespace FLY.Thick.Base.Server ...@@ -220,7 +220,9 @@ namespace FLY.Thick.Base.Server
} break; } break;
case CTRLST.FORWAIT_SAMPLE: case CTRLST.FORWAIT_SAMPLE:
{ {
WaitFinish(ref state, CTRLST.FORW_SAMPLE); if (WaitFinish()) {
state = CTRLST.FORW_SAMPLE;
}
} break; } break;
case CTRLST.FORW_SAMPLE: case CTRLST.FORW_SAMPLE:
{ {
...@@ -253,8 +255,11 @@ namespace FLY.Thick.Base.Server ...@@ -253,8 +255,11 @@ namespace FLY.Thick.Base.Server
} break; } break;
case CTRLST.BACKWAIT_1: case CTRLST.BACKWAIT_1:
{ {
if (WaitFinish(ref state, CTRLST.BACKWAIT_2)) if (WaitFinish())
{
state = CTRLST.BACKWAIT_2;
FlushAD(DIRECTION.BACKWARD); FlushAD(DIRECTION.BACKWARD);
}
} break; } break;
case CTRLST.BACKWAIT_2: case CTRLST.BACKWAIT_2:
{ {
...@@ -284,7 +289,9 @@ namespace FLY.Thick.Base.Server ...@@ -284,7 +289,9 @@ namespace FLY.Thick.Base.Server
} break; } break;
case CTRLST.BACKWAIT_SAMPLE: case CTRLST.BACKWAIT_SAMPLE:
{ {
WaitFinish(ref state, CTRLST.BACKW_SAMPLE); if (WaitFinish()) {
state = CTRLST.BACKW_SAMPLE;
}
} break; } break;
case CTRLST.BACKW_SAMPLE: case CTRLST.BACKW_SAMPLE:
{ {
...@@ -306,8 +313,11 @@ namespace FLY.Thick.Base.Server ...@@ -306,8 +313,11 @@ namespace FLY.Thick.Base.Server
break; break;
case CTRLST.SCAN_FORWAIT: case CTRLST.SCAN_FORWAIT:
{ {
if (WaitFinish(ref state, CTRLST.SCAN_BACKW)) if (WaitFinish())
{
state = CTRLST.SCAN_BACKW;
FlushAD(DIRECTION.FORWARD); FlushAD(DIRECTION.FORWARD);
}
} }
break; break;
case CTRLST.SCAN_BACKW: case CTRLST.SCAN_BACKW:
...@@ -320,8 +330,11 @@ namespace FLY.Thick.Base.Server ...@@ -320,8 +330,11 @@ namespace FLY.Thick.Base.Server
break; break;
case CTRLST.SCAN_BACKWAIT: case CTRLST.SCAN_BACKWAIT:
{ {
if (WaitFinish(ref state, CTRLST.INIT)) if (WaitFinish())
{
state = CTRLST.INIT;
FlushAD(DIRECTION.BACKWARD); FlushAD(DIRECTION.BACKWARD);
}
} }
break; break;
} }
...@@ -492,24 +505,7 @@ namespace FLY.Thick.Base.Server ...@@ -492,24 +505,7 @@ namespace FLY.Thick.Base.Server
FinishEvent(this, null); FinishEvent(this, null);
base.Stop(); base.Stop();
} }
bool WaitFinish(ref CTRLST src, CTRLST next)
{
switch (mFlyAD.DriveStatus)
{
case DRIVE_MAN_STATUS.STOP://完成任务
case DRIVE_MAN_STATUS.LIMIT:
{
src = next;
return true;
} break;
case DRIVE_MAN_STATUS.STOP_MANUAL://异常
{
NotifyError(ERRNO_Running_Manual);
Stop(); return false;
} break;
}
return false;
}
protected override void OnPoll() protected override void OnPoll()
{ {
switch (state) switch (state)
...@@ -521,7 +517,9 @@ namespace FLY.Thick.Base.Server ...@@ -521,7 +517,9 @@ namespace FLY.Thick.Base.Server
} break; } break;
case CTRLST.READY_ORIGINWAIT: case CTRLST.READY_ORIGINWAIT:
{ {
WaitFinish(ref state, CTRLST.READY_BACKW); if (WaitFinish()) {
state = CTRLST.READY_BACKW;
}
}break; }break;
case CTRLST.READY_BACKW: case CTRLST.READY_BACKW:
{ {
...@@ -532,7 +530,10 @@ namespace FLY.Thick.Base.Server ...@@ -532,7 +530,10 @@ namespace FLY.Thick.Base.Server
} break; } break;
case CTRLST.READY_BACKWAIT: case CTRLST.READY_BACKWAIT:
{ {
WaitFinish(ref state, CTRLST.SFORWARD); if (WaitFinish())
{
state = CTRLST.SFORWARD;
}
} break; } break;
case CTRLST.SFORWARD: case CTRLST.SFORWARD:
{ {
...@@ -542,8 +543,11 @@ namespace FLY.Thick.Base.Server ...@@ -542,8 +543,11 @@ namespace FLY.Thick.Base.Server
} break; } break;
case CTRLST.SFORWAIT_1: case CTRLST.SFORWAIT_1:
{ {
if (WaitFinish(ref state, CTRLST.SFORWAIT_2)) if (WaitFinish())
{
state = CTRLST.SFORWAIT_2;
FlushAD(DIRECTION.FORWARD); FlushAD(DIRECTION.FORWARD);
}
} break; } break;
case CTRLST.SFORWAIT_2: case CTRLST.SFORWAIT_2:
{ {
...@@ -557,8 +561,11 @@ namespace FLY.Thick.Base.Server ...@@ -557,8 +561,11 @@ namespace FLY.Thick.Base.Server
} break; } break;
case CTRLST.SBACKWAIT_1: case CTRLST.SBACKWAIT_1:
{ {
if (WaitFinish(ref state, CTRLST.SBACKWAIT_2)) if (WaitFinish())
FlushAD(DIRECTION.BACKWARD); {
state = CTRLST.SBACKWAIT_2;
FlushAD(DIRECTION.BACKWARD);
}
} break; } break;
case CTRLST.SBACKWAIT_2: case CTRLST.SBACKWAIT_2:
{ {
......
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