Commit 43513024 刘韬

1

1 个父辈 821c9a8e
...@@ -137,6 +137,7 @@ namespace OnlineStore.Common ...@@ -137,6 +137,7 @@ namespace OnlineStore.Common
lastlog = msg; lastlog = msg;
} }
} }
[System.Runtime.InteropServices.DllImport("kernel32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
public static extern void OutputDebugString(string message);
} }
} }
...@@ -82,6 +82,7 @@ public class HIKCamera ...@@ -82,6 +82,7 @@ public class HIKCamera
} }
void startCamera() void startCamera()
{ {
int errorsleeptime = 5000;
camerathreadrun = true; camerathreadrun = true;
while (camerathreadrun) while (camerathreadrun)
{ {
...@@ -91,18 +92,22 @@ public class HIKCamera ...@@ -91,18 +92,22 @@ public class HIKCamera
if (bmp != null) if (bmp != null)
{ {
errortimes = 0; errortimes = 0;
errorsleeptime = 5000;
camera_event?.Invoke(this, bmp); camera_event?.Invoke(this, bmp);
} }
else if (bmp == null && errortimes < 5) else if (bmp == null && errortimes < 5)
{ {
errortimes++; errortimes++;
LogUtil.error(Name + $"相机获取图像出错,{errortimes}"); LogUtil.error(Name + $"相机获取图像出错,{errortimes}");
Thread.Sleep(5000); Thread.Sleep(errorsleeptime);
} }
else if (errortimes == 5) else if (errortimes == 5)
{ {
camera.Open(); camera.Close(DeviceName);
errortimes++; Thread.Sleep(1000);
camera.Open(DeviceName);
errortimes=0;
errorsleeptime = errorsleeptime * 2;
LogUtil.error(Name + $"相机错误次数过多,重新打开,{errortimes}"); LogUtil.error(Name + $"相机错误次数过多,重新打开,{errortimes}");
} }
else if (errortimes == 6) else if (errortimes == 6)
...@@ -117,7 +122,11 @@ public class HIKCamera ...@@ -117,7 +122,11 @@ public class HIKCamera
errortimes++; errortimes++;
} }
} }
camera.Close(); try
{
camera.Close(DeviceName);
}
catch { }
camera.Dispose(); camera.Dispose();
} }
public void CameraGrabOne(string filename) public void CameraGrabOne(string filename)
......
...@@ -37,7 +37,7 @@ namespace DeviceLibrary ...@@ -37,7 +37,7 @@ namespace DeviceLibrary
continue; continue;
} }
//LogUtil.OutputDebugString($"IOMonitor: {timediff.TotalMilliseconds},{iOMonitorStrut.Interval},last_iO_VALUE:{iOMonitorStrut.last_iO_VALUE},IOVALUE:{current_iovalue},Need:{iOMonitorStrut.iO_VALUE}"); LogUtil.OutputDebugString($"IOMonitor: {timediff.TotalMilliseconds},{iOMonitorStrut.Interval},last_iO_VALUE:{iOMonitorStrut.last_iO_VALUE},IOVALUE:{current_iovalue},Need:{iOMonitorStrut.iO_VALUE}");
if (timediff.TotalMilliseconds > iOMonitorStrut.Interval && iOMonitorStrut.last_iO_VALUE != current_iovalue && current_iovalue== iOMonitorStrut.iO_VALUE) if (timediff.TotalMilliseconds > iOMonitorStrut.Interval && iOMonitorStrut.last_iO_VALUE != current_iovalue && current_iovalue== iOMonitorStrut.iO_VALUE)
{ {
...@@ -55,7 +55,8 @@ namespace DeviceLibrary ...@@ -55,7 +55,8 @@ namespace DeviceLibrary
else if (iOMonitorStrut.last_iO_VALUE == current_iovalue) else if (iOMonitorStrut.last_iO_VALUE == current_iovalue)
{ {
iOMonitorStrut.deboundCount = 0; iOMonitorStrut.deboundCount = 0;
} }else
iOMonitorStrut.last_iO_VALUE = current_iovalue;
} }
} }
......
...@@ -107,6 +107,7 @@ public class OKLEController ...@@ -107,6 +107,7 @@ public class OKLEController
} }
public static double SetZero(string port) public static double SetZero(string port)
{ {
return 0;
double weight = 0d; double weight = 0d;
AcSerialBean sb = GetSerialBean(port); AcSerialBean sb = GetSerialBean(port);
if (sb == null) if (sb == null)
......
...@@ -29,14 +29,17 @@ namespace DeviceLibrary ...@@ -29,14 +29,17 @@ namespace DeviceLibrary
{ {
Config = _Config; Config = _Config;
mainMachine = _mainMachine; mainMachine = _mainMachine;
MoveInfo = new MoveInfo("行走机构"); MoveInfo = new MoveInfo("行走机构",false);
#region 初始化伺服轴 #region 初始化伺服轴
XAxis = _mainMachine.XAxis; XAxis = _mainMachine.XAxis;
YAxis = _mainMachine.YAxis; YAxis = _mainMachine.YAxis;
ZAxis = _mainMachine.ZAxis; ZAxis = _mainMachine.ZAxis;
#endregion #endregion
} }
public void Reset() {
MoveInfo.NewMove(MoveStep.Wait);
MoveInfo.log("执行重置");
}
StoreMoveType storeMoveType = StoreMoveType.None; StoreMoveType storeMoveType = StoreMoveType.None;
string WareCode=""; string WareCode="";
public bool Start(BoxStorePosition from, BoxStorePosition to, StoreMoveType _storeMoveType, string warecode) public bool Start(BoxStorePosition from, BoxStorePosition to, StoreMoveType _storeMoveType, string warecode)
......
...@@ -11,18 +11,30 @@ namespace DeviceLibrary ...@@ -11,18 +11,30 @@ namespace DeviceLibrary
class OutStoreJobList class OutStoreJobList
{ {
static ConcurrentQueue<JobInfo> jobInfos = new ConcurrentQueue<JobInfo>(); static ConcurrentQueue<JobInfo> jobInfos = new ConcurrentQueue<JobInfo>();
public static void Enqueue(JobInfo jobInfo) { static string lastoutpos = "";
public static void Enqueue(JobInfo jobInfo)
{
lock (jobInfos)
{
if (lastoutpos == jobInfo.PosId)
return;
var l = jobInfos.ToList().Find((x) => { return x.PosId == jobInfo.PosId; }); var l = jobInfos.ToList().Find((x) => { return x.PosId == jobInfo.PosId; });
if (l == null) if (l == null)
{ {
jobInfos.Enqueue(jobInfo); jobInfos.Enqueue(jobInfo);
LogUtil.info("出库任务加入队列:" + jobInfo.ToStr()); LogUtil.info("出库任务加入队列:" + jobInfo.ToStr());
}else }
else
LogUtil.info("出库任务已存在队列中:" + jobInfo.ToStr()); LogUtil.info("出库任务已存在队列中:" + jobInfo.ToStr());
} }
}
public static bool Dequeue(out JobInfo jobInfo) public static bool Dequeue(out JobInfo jobInfo)
{ {
return jobInfos.TryDequeue(out jobInfo); if (jobInfos.TryDequeue(out jobInfo)) {
lastoutpos = jobInfo.PosId;
return true;
}
return false;
} }
public static int Count { public static int Count {
get => jobInfos.Count; get => jobInfos.Count;
......
...@@ -15,13 +15,31 @@ namespace DeviceLibrary ...@@ -15,13 +15,31 @@ namespace DeviceLibrary
{ {
void BtnProcess() void BtnProcess()
{ {
//侧按钮按下,有料,出料 //A侧按钮按下,有料,出料
if (InMoveInfo.IsStep(MoveStep.Wait) if (InMoveInfo.IsStep(MoveStep.Wait)
&& IOValue(IO_Type.InStart_BTN).Equals(IO_VALUE.HIGH)) && IOValue(IO_Type.InStart_BTN).Equals(IO_VALUE.HIGH))
{ {
} }
} //B侧按钮按下,有料,出料
if (IOValue(IO_Type.OutLeave_BTN).Equals(IO_VALUE.HIGH))
{
}
}
void OutLeave_BTN() {
if (IOValue(IO_Type.OutExitCar_Check).Equals(IO_VALUE.HIGH))
{
LogUtil.info("踩下出口脚踏开关,线体运行5秒,出口阻挡下降");
LineOut.LineRun("btnout", 5);
CylinderMove(null, IO_Type.OutExitStop_Down, IO_Type.OutExitStop_Up, IO_VALUE.LOW);
Thread.Sleep(5000);
CylinderMove(null, IO_Type.OutExitStop_Down, IO_Type.OutExitStop_Up, IO_VALUE.HIGH);
}
else {
LogUtil.info("踩下出口脚踏开关,出口没有对接小车结束");
}
}
} }
} }
...@@ -80,7 +80,7 @@ namespace DeviceLibrary ...@@ -80,7 +80,7 @@ namespace DeviceLibrary
else if (wait.WaitType.Equals(WaitEnum.W002_IOValue)) else if (wait.WaitType.Equals(WaitEnum.W002_IOValue))
{ {
ConfigIO io = RobotManage.Config.getWaitIO(wait.IoType); ConfigIO io = RobotManage.Config.getWaitIO(wait.IoType);
NotOkMsg = " 等待【" + io.DisplayStr + "】=【" + wait.IoValue + "】"; NotOkMsg = MoveInfo.Name+" 等待【" + io.DisplayStr + "】=【" + wait.IoValue + "】";
wait.IsEnd = IOManager.IOValue(wait.IoType).Equals(wait.IoValue); wait.IsEnd = IOManager.IOValue(wait.IoType).Equals(wait.IoValue);
if (!wait.IsEnd) if (!wait.IsEnd)
{ {
...@@ -88,7 +88,7 @@ namespace DeviceLibrary ...@@ -88,7 +88,7 @@ namespace DeviceLibrary
if (span.TotalMilliseconds > timeOutMs && NoAlarm()) if (span.TotalMilliseconds > timeOutMs && NoAlarm())
{ {
WarnMsg = Name + "[" + MoveInfo.MoveStep + "] 等待(" + io.DisplayStr + "=" + wait.IoValue + ") 超时"; WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveStep + "] 等待(" + io.DisplayStr + "=" + wait.IoValue + ") 超时";
Msg.add(WarnMsg, MsgLevel.warning); Msg.add(WarnMsg, MsgLevel.warning);
if (NoAlarm()) if (NoAlarm())
...@@ -139,7 +139,7 @@ namespace DeviceLibrary ...@@ -139,7 +139,7 @@ namespace DeviceLibrary
} }
else if (span.TotalSeconds > MoveInfo.TimeOutSeconds) else if (span.TotalSeconds > MoveInfo.TimeOutSeconds)
{ {
WarnMsg = Name + "[" + MoveInfo.MoveStep + "]等待" + NotOkMsg + "超时[" + Math.Round(span.TotalSeconds, 1) + "]秒"; WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveStep + "]等待" + NotOkMsg + "超时[" + Math.Round(span.TotalSeconds, 1) + "]秒";
int second = (int)(MoveInfo.TimeOutSeconds / span.TotalSeconds) * 10; int second = (int)(MoveInfo.TimeOutSeconds / span.TotalSeconds) * 10;
if (second > 120) if (second > 120)
......
...@@ -166,7 +166,7 @@ namespace DeviceLibrary ...@@ -166,7 +166,7 @@ namespace DeviceLibrary
} }
break; break;
case MoveStep.In07: case MoveStep.In07:
if (IOValue(IO_Type.InOverHead_Check).Equals(IO_VALUE.HIGH)) { if (IOValue(IO_Type.InOverHead_Check).Equals(IO_VALUE.LOW)) {
LineIn.LineStop("work"); LineIn.LineStop("work");
InMoveInfo.log($"X18检测到物料超高,停止滚筒"); InMoveInfo.log($"X18检测到物料超高,停止滚筒");
InMoveInfo.NextMoveStep(MoveStep.InOverHead); InMoveInfo.NextMoveStep(MoveStep.InOverHead);
...@@ -196,11 +196,14 @@ namespace DeviceLibrary ...@@ -196,11 +196,14 @@ namespace DeviceLibrary
} }
break; break;
case MoveStep.In09: case MoveStep.In09:
InMoveInfo.NextMoveStep(MoveStep.InWaitBoxLeave); InMoveInfo.NextMoveStep(MoveStep.In10);
InSideLift.LiftUp(InMoveInfo); InSideLift.LiftUp(InMoveInfo);
InMoveInfo.log("顶升上升,等待周转箱到位"); InMoveInfo.log("顶升上升,等待周转箱到位");
InMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.InEndMaterialTop_Check, IO_VALUE.HIGH)); InMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.InEndMaterialTop_Check, IO_VALUE.HIGH));
break; break;
case MoveStep.In10:
InMoveInfo.NextMoveStep(MoveStep.InWaitBoxLeave);
break;
case MoveStep.InWaitBoxLeave: case MoveStep.InWaitBoxLeave:
Msg.add("周转箱等待入库", MsgLevel.info); Msg.add("周转箱等待入库", MsgLevel.info);
ServerCM.storeStatus = StoreStatus.InStoreExecute; ServerCM.storeStatus = StoreStatus.InStoreExecute;
...@@ -215,16 +218,16 @@ namespace DeviceLibrary ...@@ -215,16 +218,16 @@ namespace DeviceLibrary
Msg.add("X18检测到物料超高,请取出周转箱", MsgLevel.warning); Msg.add("X18检测到物料超高,请取出周转箱", MsgLevel.warning);
if (IOMonitor.IODebound(IO_Type.InStopMaterial_Check, Config, IO_VALUE.LOW)) { if (IOMonitor.IODebound(IO_Type.InStopMaterial_Check, Config, IO_VALUE.LOW)) {
CylinderMove(InMoveInfo, IO_Type.InStop_Down, IO_Type.InStop_Up, IO_VALUE.HIGH); CylinderMove(InMoveInfo, IO_Type.InStop_Down, IO_Type.InStop_Up, IO_VALUE.HIGH);
InMoveInfo.NextMoveStep(MoveStep.Wait); InMoveInfo.NewMove(MoveStep.Wait);
} }
break; break;
case MoveStep.InReset: case MoveStep.InReset:
InMoveInfo.NextMoveStep(MoveStep.Wait);
InMoveInfo.log("入库线体状态重置");
CylinderMove(InMoveInfo, IO_Type.InStop_Down, IO_Type.InStop_Up, IO_VALUE.HIGH); CylinderMove(InMoveInfo, IO_Type.InStop_Down, IO_Type.InStop_Up, IO_VALUE.HIGH);
CylinderMove(InMoveInfo, IO_Type.InMaterialLocation_Bck, IO_Type.InMaterialLocation_Fwd, IO_VALUE.LOW); CylinderMove(InMoveInfo, IO_Type.InMaterialLocation_Bck, IO_Type.InMaterialLocation_Fwd, IO_VALUE.LOW);
InSideLift.LiftDown(InMoveInfo); InSideLift.LiftDown(InMoveInfo);
LineIn.LineStop("work"); LineIn.LineStop("work");
InMoveInfo.NewMove(MoveStep.Wait);
InMoveInfo.log("入库线体状态重置");
break; break;
default: default:
InMoveInfo.log($"未找到对应步骤:{InMoveInfo.MoveStep}"); InMoveInfo.log($"未找到对应步骤:{InMoveInfo.MoveStep}");
......
...@@ -56,7 +56,7 @@ namespace DeviceLibrary ...@@ -56,7 +56,7 @@ namespace DeviceLibrary
if (IOValue(IO_Type.OutExit_SafetyGrating).Equals(IO_VALUE.LOW)) if (IOValue(IO_Type.OutExit_SafetyGrating).Equals(IO_VALUE.LOW))
{ {
if (!IgnoreSafecheck && !IgnoreGratingSignal if (!IgnoreSafecheck && !IgnoreGratingSignal
&& IOValue(IO_Type.InFrontCar_Check).Equals(IO_VALUE.LOW)) && IOValue(IO_Type.OutExitCar_Check).Equals(IO_VALUE.LOW))
{ {
ok = false; ok = false;
LineOut.Pause(); LineOut.Pause();
......
...@@ -59,12 +59,12 @@ namespace DeviceLibrary ...@@ -59,12 +59,12 @@ namespace DeviceLibrary
} }
break; break;
case MoveStep.Out01: case MoveStep.Out01:
OutMoveInfo.NextMoveStep(MoveStep.Out02);
if (IOMonitor.IODebound(IO_Type.OutStopMaterial_Check, Config, IO_VALUE.LOW, 2000) && IOMonitor.IODebound(IO_Type.OutExitMaterial_Check, Config, IO_VALUE.LOW, 2000)) if (IOMonitor.IODebound(IO_Type.OutStopMaterial_Check, Config, IO_VALUE.LOW, 2000) && IOMonitor.IODebound(IO_Type.OutExitMaterial_Check, Config, IO_VALUE.LOW, 2000))
{ {
OutMoveInfo.NextMoveStep(MoveStep.Out02);
LineOut.LineRun("out", 999); LineOut.LineRun("out", 999);
CylinderMove(OutMoveInfo, IO_Type.OutStop_Down, IO_Type.OutStop_Up, IO_VALUE.LOW); CylinderMove(OutMoveInfo, IO_Type.OutStop_Down, IO_Type.OutStop_Up, IO_VALUE.LOW);
OutMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.OutExitMaterial_Check, IO_VALUE.HIGH)); OutMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.OutStopMaterial_Check, IO_VALUE.HIGH));
OutMoveInfo.log($"线体转动"); OutMoveInfo.log($"线体转动");
} }
else else
...@@ -74,18 +74,25 @@ namespace DeviceLibrary ...@@ -74,18 +74,25 @@ namespace DeviceLibrary
break; break;
case MoveStep.Out02: case MoveStep.Out02:
OutMoveInfo.NextMoveStep(MoveStep.Out03); OutMoveInfo.NextMoveStep(MoveStep.Out03);
LineOut.LineRun("work", 6); LineOut.LineRun("out", 6);
OutMoveInfo.log($"料箱抵达出口"); OutMoveInfo.log($"料箱抵达出口等待阻挡信号X33消失");
OutMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000)); OutMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
OutMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.OutStopMaterial_Check, IO_VALUE.LOW));
break; break;
case MoveStep.Out03: case MoveStep.Out03:
OutMoveInfo.NextMoveStep(MoveStep.Out04); OutMoveInfo.NextMoveStep(MoveStep.Out04);
LineOut.LineRun("out", 5);
OutMoveInfo.log($"料箱抵达出口再运行5秒");
OutMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
break;
case MoveStep.Out04:
OutMoveInfo.NextMoveStep(MoveStep.Out05);
CylinderMove(OutMoveInfo, IO_Type.OutStop_Down, IO_Type.OutStop_Up, IO_VALUE.HIGH); CylinderMove(OutMoveInfo, IO_Type.OutStop_Down, IO_Type.OutStop_Up, IO_VALUE.HIGH);
OutSideLift.LiftDown(OutMoveInfo); OutSideLift.LiftUp(OutMoveInfo);
OutMoveInfo.log($"出料中间阻挡升起"); OutMoveInfo.log($"出料中间阻挡升起");
ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreEnd); ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreEnd);
break; break;
case MoveStep.Out04: case MoveStep.Out05:
OutMoveInfo.NextMoveStep(MoveStep.Wait); OutMoveInfo.NextMoveStep(MoveStep.Wait);
break; break;
default: default:
......
...@@ -121,6 +121,7 @@ namespace DeviceLibrary ...@@ -121,6 +121,7 @@ namespace DeviceLibrary
AlarmBuzzer.SetOnOffAction(() =>{ IOMove(IO_Type.Alarm_Buzzer, IO_VALUE.HIGH); }, () => { IOMove(IO_Type.Alarm_Buzzer, IO_VALUE.LOW); }); AlarmBuzzer.SetOnOffAction(() =>{ IOMove(IO_Type.Alarm_Buzzer, IO_VALUE.HIGH); }, () => { IOMove(IO_Type.Alarm_Buzzer, IO_VALUE.LOW); });
IOMonitor.RegisterIO(IO_Type.OutLeave_BTN, Config, IO_VALUE.HIGH, OutLeave_BTN,2500,100);
LedProcessInit(); LedProcessInit();
} }
private (bool, string) ZAxis_interference(int from, int to) private (bool, string) ZAxis_interference(int from, int to)
...@@ -357,8 +358,13 @@ namespace DeviceLibrary ...@@ -357,8 +358,13 @@ namespace DeviceLibrary
case MoveStep.HEND_HomeReset: case MoveStep.HEND_HomeReset:
OKLEController.SetZero(Config.WeightSensorPort); OKLEController.SetZero(Config.WeightSensorPort);
forceHome = false; forceHome = false;
InMoveInfo.NewMove(MoveStep.Wait);
OutMoveInfo.NewMove(MoveStep.Wait);
StoreMoveInfo.NewMove(MoveStep.Wait);
boxTransport.Reset();
ResetMoveInfo.log("回原完成"); ResetMoveInfo.log("回原完成");
ResetMoveInfo.EndMove(); ResetMoveInfo.EndMove();
runStatus = RunStatus.Running; runStatus = RunStatus.Running;
ServerCM.storeStatus = StoreStatus.StoreOnline; ServerCM.storeStatus = StoreStatus.StoreOnline;
break; break;
......
...@@ -69,6 +69,7 @@ namespace DeviceLibrary ...@@ -69,6 +69,7 @@ namespace DeviceLibrary
msg += $"称重传感器初始化失败 Port:{Config.WeightSensorPort}\n"; msg += $"称重传感器初始化失败 Port:{Config.WeightSensorPort}\n";
} }
} }
OKLEController.SetZero(Config.WeightSensorPort);
if (!CameraA.LoadCameraConfig("CameraA", out string errmsg)) if (!CameraA.LoadCameraConfig("CameraA", out string errmsg))
{ {
IsLoadOk = false; IsLoadOk = false;
......
...@@ -399,7 +399,7 @@ namespace TheMachine ...@@ -399,7 +399,7 @@ namespace TheMachine
private void btn_inreset_Click(object sender, EventArgs e) private void btn_inreset_Click(object sender, EventArgs e)
{ {
if (RobotManage.mainMachine.IOValue(IO_Type.InStopMaterial_Check).Equals(IO_VALUE.HIGH) || if (RobotManage.mainMachine.IOValue(IO_Type.InStopMaterial_Check).Equals(IO_VALUE.HIGH) ||
RobotManage.mainMachine.IOValue(IO_Type.InOverHead_Check).Equals(IO_VALUE.HIGH) || RobotManage.mainMachine.IOValue(IO_Type.InOverHead_Check).Equals(IO_VALUE.LOW) ||
RobotManage.mainMachine.IOValue(IO_Type.InEndMaterialBottom_Check).Equals(IO_VALUE.HIGH) || RobotManage.mainMachine.IOValue(IO_Type.InEndMaterialBottom_Check).Equals(IO_VALUE.HIGH) ||
RobotManage.mainMachine.IOValue(IO_Type.InEndMaterialTop_Check).Equals(IO_VALUE.HIGH) RobotManage.mainMachine.IOValue(IO_Type.InEndMaterialTop_Check).Equals(IO_VALUE.HIGH)
) { ) {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!