Commit 4d231871 LN

关机功能

1 个父辈 988c40bb
......@@ -423,6 +423,7 @@ namespace OnlineStore.AssemblyLine
private void timer1_Tick(object sender, EventArgs e)
{
LogM();
StopRunProcess();
UpdateControl();
string canScanCode = "";
......@@ -489,6 +490,57 @@ namespace OnlineStore.AssemblyLine
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)
{
if (!toolMenu.Enabled.Equals(isEn))
......
20210511

20221125 :
增加关机功能。
20210511
1.扫码算法更新。
2.HY12顶升之后增加延迟。
3.取消入库任务增加参数。
......
......@@ -361,6 +361,8 @@ namespace OnlineStore.DeviceLibrary
TrayManager.TrayErrorMsg = DateTime.Now.ToLongTimeString() + " " + Name + "托盘号错乱:当前托盘 [" + currTrayNum + "] 上个托盘[" + preTrayNum + "] ,连续两个托盘号一样";
LogUtil.error(Name + "托盘号错乱:当前托盘 [" + currTrayNum + "] 上个托盘[" + preTrayNum + "] ,连续两个托盘号一样");
//托盘号一样,返回false
return false;
}
}
......
......@@ -948,68 +948,75 @@ namespace OnlineStore.DeviceLibrary
private Task ScanCodeTask = null;
private void FI_18_ScanCode()
{
if (CylinderIsOk(IO_Type.SL_MoveCylinder_Take, IO_Type.SL_MoveCylinder_Give))
if (SServerManager.putInEnable(Name))
{
if (YuScanTask == null || YuScanTask.IsCompleted)
if (CylinderIsOk(IO_Type.SL_MoveCylinder_Take, IO_Type.SL_MoveCylinder_Give))
{
ClearTimeoutAlarm("预扫码结束超时");
MoveInfo.NextMoveStep(LineMoveStep.FI_18_ScanCode);
bool isScan = ConfigAppSettings.GetIntValue(Setting_Init.NeedScanCode).Equals(1);
if (YuScanTask == null || YuScanTask.IsCompleted)
{
ClearTimeoutAlarm("预扫码结束超时");
MoveInfo.NextMoveStep(LineMoveStep.FI_18_ScanCode);
bool isScan = ConfigAppSettings.GetIntValue(Setting_Init.NeedScanCode).Equals(1);
LastCodeList = new List<string>();
LastCodeList = new List<string>();
ScanCodeTask = null;
if (NextCodeList.Count > 0)
{
InLog("料盘移栽" + MoveInfo.SLog + ":开始扫码:使用预扫码");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
LastCodeList = new List<string>(NextCodeList);
NextCodeList = new List<string>();
MoveInfo.NextMoveStep(LineMoveStep.FI_21_CylinderTake);
InLog("料盘移栽" + MoveInfo.SLog + ":上料横移取料端");
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Give, IO_Type.SL_MoveCylinder_Take);
}
else if (isScan)
{
InLog("料盘移栽" + MoveInfo.SLog + ":开始扫码");
MoveInfo.OneWaitCanEndStep = true;
MoveInfo.WaitList.Add(WaitResultInfo.WaitFeedScanCode());
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(7000));
try
ScanCodeTask = null;
if (NextCodeList.Count > 0)
{
ScanCodeTask = Task.Factory.StartNew(delegate
InLog("料盘移栽" + MoveInfo.SLog + ":开始扫码:使用预扫码");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
LastCodeList = new List<string>(NextCodeList);
NextCodeList = new List<string>();
MoveInfo.NextMoveStep(LineMoveStep.FI_21_CylinderTake);
InLog("料盘移栽" + MoveInfo.SLog + ":上料横移取料端");
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Give, IO_Type.SL_MoveCylinder_Take);
}
else if (isScan)
{
InLog("料盘移栽" + MoveInfo.SLog + ":开始扫码");
MoveInfo.OneWaitCanEndStep = true;
MoveInfo.WaitList.Add(WaitResultInfo.WaitFeedScanCode());
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(7000));
try
{
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name);
bool hasRightCode = CodeManager.HasRightCode(LastCodeList.ToArray());
if (!hasRightCode)
ScanCodeTask = Task.Factory.StartNew(delegate
{
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name, false, 3000);
}
return LastCodeList;
});
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name);
bool hasRightCode = CodeManager.HasRightCode(LastCodeList.ToArray());
if (!hasRightCode)
{
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name, false, 3000);
}
return LastCodeList;
});
}
catch (Exception ex)
{
LogUtil.error("" + MoveInfo.SLog + ":扫码出错:", ex);
}
//finally
//{
// MoveInfo.EndStepWait();
//}
}
catch (Exception ex)
else
{
LogUtil.error("" + MoveInfo.SLog + ":扫码出错:", ex);
InLog("料盘移栽" + MoveInfo.SLog + ":不需要扫码");
}
//finally
//{
// MoveInfo.EndStepWait();
//}
}
else
else if (MoveInfo.IsTimeOut(60))
{
InLog("料盘移栽" + MoveInfo.SLog + ":不需要扫码");
MoveTimeoutAlarm(MoveInfo, "预扫码结束超时");
}
}
else if (MoveInfo.IsTimeOut(60))
else
{
MoveTimeoutAlarm(MoveInfo, "预扫码结束超时");
FI_17_CylinderGive();
}
}
else
{
FI_17_CylinderGive();
MoveTimeoutAlarm(MoveInfo, "即将关机,暂停抓取料盘");
}
}
private void CheckHasTray()
......
......@@ -151,7 +151,7 @@ namespace OnlineStore.DeviceLibrary
stopWatchCheck();
if (MoveInfo.MoveType.Equals(LineMoveType.None))
{
if (LineManager.Line.CanProcessLine())
if (LineManager.Line.CanProcessLine() && LineManager.Line.HYProcessNewTray())
{
CheckFixture();
}
......@@ -411,11 +411,11 @@ namespace OnlineStore.DeviceLibrary
if (IOValue(IO_Type.HY_TrayCheck).Equals(IO_VALUE.HIGH))
{
//判断是否需要横移托盘,或者取放料
UpdateTrayNum();
UpdateTrayNum();
MoveInfo.NextMoveStep(LineMoveStep.HY05_TrayCheck);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(10000));
//先判断是否需要到出料线,在判断是否需要横移
if (TrayNeedToOutLine(currTrayNum))
{
......
......@@ -149,7 +149,7 @@ namespace OnlineStore.DeviceLibrary
//判断流水线打开了才可以运行
if (MoveInfo.MoveType.Equals(LineMoveType.None))
{
if (LineManager.Line.CanProcessLine())
if (LineManager.Line.CanProcessLine() && LineManager.Line.HYProcessNewTray())
{
CheckFixture();
}
......@@ -185,7 +185,7 @@ namespace OnlineStore.DeviceLibrary
if (Monitor.TryEnter(lockObj, TrayManager.mTimeOut))
{
try
{
{
if (MoveInfo.MoveType.Equals(LineMoveType.None).Equals(false))
{
LogUtil.error(Name + " CheckFixture " + " 不在空闲中,直接返回 ");
......@@ -318,7 +318,7 @@ namespace OnlineStore.DeviceLibrary
if (IOValue(IO_Type.HY_TrayCheck).Equals(IO_VALUE.HIGH))
{
//更新托盘号
UpdateTrayNum();
UpdateTrayNum();
//判断托盘是否需要横移,或进出料线
MoveInfo.NextMoveStep(LineMoveStep.HY05_TrayCheck);
......
......@@ -179,7 +179,7 @@ namespace OnlineStore.DeviceLibrary
BusyMoveProcess();
if (SecondMoveInfo.MoveType.Equals(LineMoveType.None) && (!MoveStop))
{
if (LineManager.Line.OutHyCanProLine())
if (LineManager.Line.OutHyCanProLine() && LineManager.Line.HYProcessNewTray())
{
CheckFixture();
}
......
......@@ -208,7 +208,7 @@ namespace OnlineStore.DeviceLibrary
}
else if (SecondMoveInfo.IsStep(LineMoveStep.JHY_07_TopUp))
{
{
SecondMoveInfo.NextMoveStep(LineMoveStep.JHY_08_LocationUp);
CheckLog(" 接驳台托盘" + SecondMoveInfo.SLog + ":料盘需要横移,定位上升");
LocationCylinderUp(SecondMoveInfo);
......
......@@ -117,7 +117,7 @@ namespace OnlineStore.DeviceLibrary
{
if (MoveInfo.MoveType.Equals(LineMoveType.None))
{
if (LineManager.Line.OutHyCanProLine())
if (LineManager.Line.OutHyCanProLine() && LineManager.Line.HYProcessNewTray())
{
CheckFixture();
}
......
......@@ -446,7 +446,10 @@ namespace OnlineStore.DeviceLibrary
IOMove(IO_Type.Alarm_HddLed, IO_VALUE.HIGH);
}
/// <summary>
/// 关机
/// </summary>
public bool LineStopRun = false;
public void WriteDrivetMotorRun(IO_VALUE value)
{
IOMove(IO_Type.MotorRun_C1_123, value);
......@@ -454,8 +457,30 @@ namespace OnlineStore.DeviceLibrary
IOMove(IO_Type.MotorRun_23458, 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 灯光处理
......@@ -471,7 +496,7 @@ namespace OnlineStore.DeviceLibrary
try
{
DateTime time = DateTime.Now;
if (runStatus <= LineRunStatus.Wait)
if (runStatus <= LineRunStatus.Wait || LineStopRun)
{
CloseLed();
return;
......@@ -728,7 +753,18 @@ namespace OnlineStore.DeviceLibrary
default: break;
}
T3C1_TimerProcess();
T3C1_TimerProcess();
if (LineStopRun)
{
//需要关机
if (MotorHasRun() && LineCanStop())
{
WriteDrivetMotorRun(IO_VALUE.LOW);
LogInfo("收到服务端停机要求,线体还未关闭,停止环形线线体转动");
}
}
else { noReel = false; }
}
catch (Exception ex)
{
......@@ -983,5 +1019,64 @@ namespace OnlineStore.DeviceLibrary
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
......@@ -919,17 +919,19 @@ namespace OnlineStore.DeviceLibrary
{
//判断是否需要顶升
bool isNeed = false;
UpdateTrayNum();
bool result = UpdateTrayNum();
bool isFull = TrayManager.TrayIsFull(currTrayNum);
//出库中,需要拦盘
if (CheckIsNeedOutStore())
{
isNeed = true;
}
else if (isFull && IsInStoreNeed())
{
isNeed = true;
if (result)
{
//出库中,需要拦盘
if (CheckIsNeedOutStore())
{
isNeed = true;
}
else if (isFull && IsInStoreNeed())
{
isNeed = true;
}
}
if (isNeed)
{
......
......@@ -699,6 +699,93 @@ namespace OnlineStore.DeviceLibrary
}
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
{
......@@ -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 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.LoadCSVLibrary</RootNamespace>
<AssemblyName>LoadCSVLibrary</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!