Commit 4d231871 LN

关机功能

1 个父辈 988c40bb
...@@ -423,6 +423,7 @@ namespace OnlineStore.AssemblyLine ...@@ -423,6 +423,7 @@ namespace OnlineStore.AssemblyLine
private void timer1_Tick(object sender, EventArgs e) private void timer1_Tick(object sender, EventArgs e)
{ {
LogM(); LogM();
StopRunProcess();
UpdateControl(); UpdateControl();
string canScanCode = ""; string canScanCode = "";
...@@ -489,6 +490,57 @@ namespace OnlineStore.AssemblyLine ...@@ -489,6 +490,57 @@ namespace OnlineStore.AssemblyLine
SetMenuS(停止TToolStripMenuItem, false); SetMenuS(停止TToolStripMenuItem, false);
} }
} }
bool stopRun = false;
bool stopRequest = false;
DateTime stopTime = new DateTime();
private void StopRunProcess()
{
if (lineBean.runStatus <= LineRunStatus.Wait)
{
return;
}
try
{
if (SServerManager.stopRun(Name))
{
if (!stopRequest)
{
stopTime = DateTime.Now;
stopRequest = true;
//lineBean.WriteDrivetMotorRun(IO_VALUE.LOW);
}
if (!stopRun && stopRequest && (DateTime.Now - stopTime).TotalSeconds > 40)
{
stopRun = true;
lineBean.LineStopRun = true;
//停止所有料仓TToolStripMenuItem_Click(null, null);
if (lineBean.LineCanStop())
{
LogUtil.info("收到服务端停机要求,直接停止环形线");
lineBean.WriteDrivetMotorRun(IO_VALUE.LOW);
}
else
{
LogUtil.info("收到服务端停机要求,托盘还有料,等托盘无料30S后再停止环形线");
}
}
}
else
{
if (stopRun)
{
lineBean.LineStopRun = false;
lineBean.WriteDrivetMotorRun(IO_VALUE.HIGH);
//启动所有料仓AToolStripMenuItem_Click(null, null);
stopRun = false;
LogUtil.info("收到服务端开机要求,启动环形线");
}
stopRequest = false;
}
}
catch { lineBean.WriteDrivetMotorRun(IO_VALUE.HIGH); }
}
private void SetMenuS(ToolStripMenuItem toolMenu, bool isEn) private void SetMenuS(ToolStripMenuItem toolMenu, bool isEn)
{ {
if (!toolMenu.Enabled.Equals(isEn)) if (!toolMenu.Enabled.Equals(isEn))
......
20210511 
20221125 :
增加关机功能。
20210511
1.扫码算法更新。 1.扫码算法更新。
2.HY12顶升之后增加延迟。 2.HY12顶升之后增加延迟。
3.取消入库任务增加参数。 3.取消入库任务增加参数。
......
...@@ -361,6 +361,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -361,6 +361,8 @@ namespace OnlineStore.DeviceLibrary
TrayManager.TrayErrorMsg = DateTime.Now.ToLongTimeString() + " " + Name + "托盘号错乱:当前托盘 [" + currTrayNum + "] 上个托盘[" + preTrayNum + "] ,连续两个托盘号一样"; TrayManager.TrayErrorMsg = DateTime.Now.ToLongTimeString() + " " + Name + "托盘号错乱:当前托盘 [" + currTrayNum + "] 上个托盘[" + preTrayNum + "] ,连续两个托盘号一样";
LogUtil.error(Name + "托盘号错乱:当前托盘 [" + currTrayNum + "] 上个托盘[" + preTrayNum + "] ,连续两个托盘号一样"); LogUtil.error(Name + "托盘号错乱:当前托盘 [" + currTrayNum + "] 上个托盘[" + preTrayNum + "] ,连续两个托盘号一样");
//托盘号一样,返回false
return false;
} }
} }
......
...@@ -948,6 +948,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -948,6 +948,8 @@ namespace OnlineStore.DeviceLibrary
private Task ScanCodeTask = null; private Task ScanCodeTask = null;
private void FI_18_ScanCode() private void FI_18_ScanCode()
{ {
if (SServerManager.putInEnable(Name))
{
if (CylinderIsOk(IO_Type.SL_MoveCylinder_Take, IO_Type.SL_MoveCylinder_Give)) if (CylinderIsOk(IO_Type.SL_MoveCylinder_Take, IO_Type.SL_MoveCylinder_Give))
{ {
if (YuScanTask == null || YuScanTask.IsCompleted) if (YuScanTask == null || YuScanTask.IsCompleted)
...@@ -1012,6 +1014,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -1012,6 +1014,11 @@ namespace OnlineStore.DeviceLibrary
FI_17_CylinderGive(); FI_17_CylinderGive();
} }
} }
else
{
MoveTimeoutAlarm(MoveInfo, "即将关机,暂停抓取料盘");
}
}
private void CheckHasTray() private void CheckHasTray()
{ {
//若BOX和出料都没有在等待Io的过程中则此Io超时异常可能已经处理过 //若BOX和出料都没有在等待Io的过程中则此Io超时异常可能已经处理过
......
...@@ -151,7 +151,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -151,7 +151,7 @@ namespace OnlineStore.DeviceLibrary
stopWatchCheck(); stopWatchCheck();
if (MoveInfo.MoveType.Equals(LineMoveType.None)) if (MoveInfo.MoveType.Equals(LineMoveType.None))
{ {
if (LineManager.Line.CanProcessLine()) if (LineManager.Line.CanProcessLine() && LineManager.Line.HYProcessNewTray())
{ {
CheckFixture(); CheckFixture();
} }
......
...@@ -149,7 +149,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -149,7 +149,7 @@ namespace OnlineStore.DeviceLibrary
//判断流水线打开了才可以运行 //判断流水线打开了才可以运行
if (MoveInfo.MoveType.Equals(LineMoveType.None)) if (MoveInfo.MoveType.Equals(LineMoveType.None))
{ {
if (LineManager.Line.CanProcessLine()) if (LineManager.Line.CanProcessLine() && LineManager.Line.HYProcessNewTray())
{ {
CheckFixture(); CheckFixture();
} }
......
...@@ -179,7 +179,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -179,7 +179,7 @@ namespace OnlineStore.DeviceLibrary
BusyMoveProcess(); BusyMoveProcess();
if (SecondMoveInfo.MoveType.Equals(LineMoveType.None) && (!MoveStop)) if (SecondMoveInfo.MoveType.Equals(LineMoveType.None) && (!MoveStop))
{ {
if (LineManager.Line.OutHyCanProLine()) if (LineManager.Line.OutHyCanProLine() && LineManager.Line.HYProcessNewTray())
{ {
CheckFixture(); CheckFixture();
} }
......
...@@ -117,7 +117,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -117,7 +117,7 @@ namespace OnlineStore.DeviceLibrary
{ {
if (MoveInfo.MoveType.Equals(LineMoveType.None)) if (MoveInfo.MoveType.Equals(LineMoveType.None))
{ {
if (LineManager.Line.OutHyCanProLine()) if (LineManager.Line.OutHyCanProLine() && LineManager.Line.HYProcessNewTray())
{ {
CheckFixture(); CheckFixture();
} }
......
...@@ -446,7 +446,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -446,7 +446,10 @@ namespace OnlineStore.DeviceLibrary
IOMove(IO_Type.Alarm_HddLed, IO_VALUE.HIGH); IOMove(IO_Type.Alarm_HddLed, IO_VALUE.HIGH);
} }
/// <summary>
/// 关机
/// </summary>
public bool LineStopRun = false;
public void WriteDrivetMotorRun(IO_VALUE value) public void WriteDrivetMotorRun(IO_VALUE value)
{ {
IOMove(IO_Type.MotorRun_C1_123, value); IOMove(IO_Type.MotorRun_C1_123, value);
...@@ -454,8 +457,30 @@ namespace OnlineStore.DeviceLibrary ...@@ -454,8 +457,30 @@ namespace OnlineStore.DeviceLibrary
IOMove(IO_Type.MotorRun_23458, value); IOMove(IO_Type.MotorRun_23458, value);
IOMove(IO_Type.MotorRun_679, value); IOMove(IO_Type.MotorRun_679, value);
} }
public bool MotorHasRun()
{
if (IOValue(IO_Type.MotorRun_C1_123).Equals(IO_VALUE.HIGH) ||
IOValue(IO_Type.MotorRun_C1_4).Equals(IO_VALUE.HIGH) ||
IOValue(IO_Type.MotorRun_23458).Equals(IO_VALUE.HIGH) ||
IOValue(IO_Type.MotorRun_679).Equals(IO_VALUE.HIGH)
)
{
return true;
}
return false;
}
/// <summary>
/// 横移是否可以处理新托盘
/// </summary>
/// <returns></returns>
public bool HYProcessNewTray()
{
if ((!LineStopRun) || hasReel())
{
return true;
}
return false;
}
#region 灯光处理 #region 灯光处理
...@@ -471,7 +496,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -471,7 +496,7 @@ namespace OnlineStore.DeviceLibrary
try try
{ {
DateTime time = DateTime.Now; DateTime time = DateTime.Now;
if (runStatus <= LineRunStatus.Wait) if (runStatus <= LineRunStatus.Wait || LineStopRun)
{ {
CloseLed(); CloseLed();
return; return;
...@@ -729,6 +754,17 @@ namespace OnlineStore.DeviceLibrary ...@@ -729,6 +754,17 @@ namespace OnlineStore.DeviceLibrary
} }
T3C1_TimerProcess(); T3C1_TimerProcess();
if (LineStopRun)
{
//需要关机
if (MotorHasRun() && LineCanStop())
{
WriteDrivetMotorRun(IO_VALUE.LOW);
LogInfo("收到服务端停机要求,线体还未关闭,停止环形线线体转动");
}
}
else { noReel = false; }
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -983,5 +1019,64 @@ namespace OnlineStore.DeviceLibrary ...@@ -983,5 +1019,64 @@ namespace OnlineStore.DeviceLibrary
conIsPro = false; conIsPro = false;
} }
} }
/// <summary>
/// 所有托盘都要是空托盘或者禁用托盘
/// </summary>
/// <returns></returns>
public bool hasReel()
{
List<TrayInfo> trayList = TrayManager.getTrayList();
foreach (TrayInfo tray in trayList)
{
if (tray.IsFull)
{
//if (TrayDisableManager.DisableTray(tray.TrayCode))
//{
// continue;
//}
return true;
}
}
return false;
}
/// <summary>
/// 关机功能:判断是否可以关闭线体,验证横移上是否有料盘
/// </summary>
/// <returns></returns>
public bool LineCanStop()
{
if (hasReel())
{
noReel = false;
trayNoReelTime = DateTime.Now;
}
else
{
if (noReel)
{
}
else
{
noReel = true;
trayNoReelTime = DateTime.Now;
}
}
if (noReel)
{
//判断是否已经无料盘30秒
TimeSpan span = DateTime.Now - trayNoReelTime;
if (span.TotalSeconds > 30)
{
return true;
}
}
return false ;
}
public bool noReel=false;
private DateTime trayNoReelTime = DateTime.Now;
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -919,9 +919,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -919,9 +919,10 @@ namespace OnlineStore.DeviceLibrary
{ {
//判断是否需要顶升 //判断是否需要顶升
bool isNeed = false; bool isNeed = false;
UpdateTrayNum(); bool result = UpdateTrayNum();
bool isFull = TrayManager.TrayIsFull(currTrayNum); bool isFull = TrayManager.TrayIsFull(currTrayNum);
if (result)
{
//出库中,需要拦盘 //出库中,需要拦盘
if (CheckIsNeedOutStore()) if (CheckIsNeedOutStore())
{ {
...@@ -931,6 +932,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -931,6 +932,7 @@ namespace OnlineStore.DeviceLibrary
{ {
isNeed = true; isNeed = true;
} }
}
if (isNeed) if (isNeed)
{ {
SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_05_WaitTime); SecondMoveInfo.NextMoveStep(LineMoveStep.MIO_05_WaitTime);
......
...@@ -699,6 +699,93 @@ namespace OnlineStore.DeviceLibrary ...@@ -699,6 +699,93 @@ namespace OnlineStore.DeviceLibrary
} }
return defaultPut; return defaultPut;
} }
public static bool IgnoreServerStop = false;
private static string Addr_stopRun = "/rest/api/qisda/device/stopRun";
/// <summary>
/// 流水线停止运行
/// </summary>
/// <param name="deviceName"></param>
/// <returns>true:停止运行</returns>
public static bool stopRun(string deviceName)
{
if (IgnoreServerStop) return false;
try
{
Dictionary<string, string> paramMap = new Dictionary<string, string>();
//paramMap.Add("barcode", barcode);
string server = GetAddr(Addr_stopRun, paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "");
LogUtil.debug($"{deviceName}stopRun {FormUtil.GetSpanStr(DateTime.Now - startTime)} 【{server}】【{resultStr}】");
ReturnData2 data = JsonHelper.DeserializeJsonToObject<ReturnData2>(resultStr);
if (data != null)
{
bool result = data.data.stopOut;
if (data.code.Equals(0))
{
return result && data.data.unfinishedTask < 1;
}
else if (!data.code.Equals(0))
{
LogUtil.error($"{deviceName} stopRun 返回错误 :{data.msg}={data.msg}");
}
}
}
catch (Exception ex)
{
LogUtil.error(deviceName + " " + ex.ToString());
}
return false;
}
private static string Addr_putInEnable = "/rest/api/qisda/device/putInEnable";
/// <summary>
/// 流水线抓取料盘前获取是否可以继续抓取料盘
/// </summary>
/// <param name="deviceName"></param>
/// <returns></returns>
public static bool putInEnable(string deviceName)
{
if (IgnoreServerStop) return true;
// 返回: // { "code":0,"msg":"ok","data":{"putInEnable":true}}
// code: 0为正常,其他为异常
// msg:消息,
//putInEnable: false 时不允许抓取下一盘,true时允许抓取
try
{
Dictionary<string, string> paramMap = new Dictionary<string, string>();
//paramMap.Add("barcode", barcode);
string server = GetAddr(Addr_putInEnable, paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "");
LogUtil.debug($"{deviceName}putInEnable {FormUtil.GetSpanStr(DateTime.Now - startTime)} 【{server}】【{resultStr}】");
ReturnData1 data = JsonHelper.DeserializeJsonToObject<ReturnData1>(resultStr);
if (data != null)
{
bool result = data.data.putInEnable;
if (data.code.Equals(0))
{
return result;
}
else if (!data.code.Equals(0))
{
LogUtil.error($"{deviceName} putInEnable 返回错误 :{data.msg}={data.msg}");
}
}
}
catch (Exception ex)
{
LogUtil.error(deviceName + " " + ex.ToString());
}
return false;
}
} }
public class ReturnData public class ReturnData
{ {
...@@ -823,6 +910,33 @@ namespace OnlineStore.DeviceLibrary ...@@ -823,6 +910,33 @@ namespace OnlineStore.DeviceLibrary
} }
} }
public class ReturnData2
{
// { "code":0,"msg":"ok","data":true}
public int code { get; set; }
public string msg { get; set; }
public StopRun data { get; set; }
}
public class StopRun
{
public int unfinishedTask { get; set; }
public bool stopOut { get; set; }
}
public class ReturnData1
{
// { "code":0,"msg":"ok","data":true}
public int code { get; set; }
public string msg { get; set; }
public PutInEnable data { get; set; }
}
public class PutInEnable
{
public bool putInEnable { get; set; }
}
} }
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.LoadCSVLibrary</RootNamespace> <RootNamespace>OnlineStore.LoadCSVLibrary</RootNamespace>
<AssemblyName>LoadCSVLibrary</AssemblyName> <AssemblyName>LoadCSVLibrary</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!