Commit 49b38109 authored by 潘栩锋's avatar 潘栩锋 🚴

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

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