Commit 990fc02d 刘韬

1

1 个父辈 d6d176be
......@@ -138,6 +138,7 @@ namespace OnlineStore.Common
begin_open_string_door,
string_not_onposition_01,
begin_close_string_door,
tray_detect_reel_01
tray_detect_reel_01,
system_running_cantmove
}
}
......@@ -75,7 +75,9 @@
<Compile Include="DeviceLibrary\AcSerialBean.cs" />
<Compile Include="DeviceLibrary\Camera.cs" />
<Compile Include="DeviceLibrary\CameraTest.cs" />
<Compile Include="DeviceLibrary\CylinderManger.cs" />
<Compile Include="DeviceLibrary\IOMonitor.cs" />
<Compile Include="DeviceLibrary\I_SafetyDevice.cs" />
<Compile Include="DeviceLibrary\LiftMonitor.cs" />
<Compile Include="DeviceLibrary\LineRunMonitor.cs" />
<Compile Include="DeviceLibrary\C8WeightSensor.cs" />
......
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class CylinderManger : ISafetyDevice
{
string High;
string Low;
string Name;
IO_VALUE currentIOvalue = IO_VALUE.None;
public CylinderManger(string name,string high,string low) {
High = high;
Low = low;
Name = name;
SafetyDevice.AddDevice(this);
}
bool IsHigh = true;
public void ToHigh(MoveInfo moveInfo) {
currentIOvalue = IO_VALUE.HIGH;
if (moveInfo != null)
{
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(Low, IO_VALUE.LOW));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(High, IO_VALUE.HIGH));
}
Resume();
LogUtil.info($"{Name},设置{High}=High");
}
public void ToLow(MoveInfo moveInfo)
{
currentIOvalue = IO_VALUE.LOW;
if (moveInfo != null)
{
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(Low, IO_VALUE.HIGH));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(High, IO_VALUE.LOW));
}
Resume();
LogUtil.info($"{Name},设置{High}=Low");
}
public void Pause()
{
LogUtil.info($"{Name},停止运行");
IOManager.IOMove(Low, IO_VALUE.LOW);
IOManager.IOMove(High, IO_VALUE.LOW);
}
public void Resume()
{
if (currentIOvalue == IO_VALUE.None)
return;
IOManager.IOMove(Low, currentIOvalue == IO_VALUE.LOW ? IO_VALUE.HIGH : IO_VALUE.LOW);
IOManager.IOMove(High, currentIOvalue == IO_VALUE.HIGH ? IO_VALUE.HIGH : IO_VALUE.LOW);
LogUtil.info($"{Name},恢复运行");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
interface ISafetyDevice
{
void Pause();
void Resume();
}
class SafetyDevice
{
static List<ISafetyDevice> List = new List<ISafetyDevice>();
public static void AddDevice(ISafetyDevice safetyDevice)
{
List.Add(safetyDevice);
}
public static void PauseAll() {
List.ForEach(x => x.Pause());
}
public static void ResumeAll() {
List.ForEach(x => x.Resume());
}
}
}
......@@ -9,7 +9,7 @@ using System.Timers;
namespace DeviceLibrary
{
public class LineRunMonitor
public class LineRunMonitor : ISafetyDevice
{
Timer lineTimer = null;
Dictionary<string, DateTime> linrunlist = new Dictionary<string, DateTime>();
......@@ -22,6 +22,7 @@ namespace DeviceLibrary
LineIO = io;
LineRevIO = rev_io;
LineInit();
SafetyDevice.AddDevice(this);
}
//public bool Reversal { get; set; }
void LineInit()
......
......@@ -304,8 +304,9 @@ namespace DeviceLibrary
/// <param name="moveInfo"></param>
public void CloseFlipDoor(MoveInfo moveInfo) {
LogUtil.info("关闭翻板门");
IOMove(IO_Type.ReelFlipDoor_Home, IO_VALUE.LOW);
IOMove(IO_Type.ReelFlipDoor_Work, IO_VALUE.HIGH);
//IOMove(IO_Type.ReelFlipDoor_Home, IO_VALUE.LOW);
//IOMove(IO_Type.ReelFlipDoor_Work, IO_VALUE.HIGH);
FlipDoor.ToHigh(null);
if (moveInfo != null)
{
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.ReelFlipDoor_L_Work, IO_VALUE.HIGH));
......@@ -324,8 +325,10 @@ namespace DeviceLibrary
LogUtil.info("打开翻板门");
else
moveInfo.log("打开翻板门");
IOMove(IO_Type.ReelFlipDoor_Work, IO_VALUE.LOW);
IOMove(IO_Type.ReelFlipDoor_Home, IO_VALUE.HIGH);
//IOMove(IO_Type.ReelFlipDoor_Work, IO_VALUE.LOW);
//IOMove(IO_Type.ReelFlipDoor_Home, IO_VALUE.HIGH);
FlipDoor.ToLow(null);
if (moveInfo != null)
{
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.ReelFlipDoor_L_Home, IO_VALUE.HIGH));
......
......@@ -53,6 +53,8 @@ namespace DeviceLibrary
internal AxisBean Clamp_Axis;
public LineRunMonitor Line;
public CylinderManger SingleDoor;
public CylinderManger FlipDoor;
ReelTransport boxTransport;
public bool boxTransportIsFree { get => boxTransport.IsComplateOrFree; }
......@@ -102,7 +104,8 @@ namespace DeviceLibrary
Crc_LanguageChangeEvent(null, EventArgs.Empty);
#endregion
Line = new LineRunMonitor("料串进出机构", Config.DOList[IO_Type.LineRun].GetIOAddr(),Config.DOList[IO_Type.LineRev].GetIOAddr());
SingleDoor = new CylinderManger("单料们", IO_Type.NGDoor_Open, IO_Type.NGDoor_Close);
FlipDoor = new CylinderManger("翻板托盘", IO_Type.ReelFlipDoor_Work, IO_Type.ReelFlipDoor_Home);
boxTransport = new ReelTransport(Config, this);
boxTransport.InOutEndProcessEvent += delegate (string posid, StoreMoveType storeMoveType, bool arg4)
......@@ -191,11 +194,8 @@ namespace DeviceLibrary
{
BtnProcess();
canRunning = SafeCheck();
if (canRunning && !lastSafeCheckStatus)
{
}
lastSafeCheckStatus = canRunning;
//if (canRunning && !lastSafeCheckStatus){}
//lastSafeCheckStatus = canRunning;
}
Thread.Sleep(200);
if (!canRunning || !mstart)
......@@ -313,7 +313,8 @@ namespace DeviceLibrary
InOut_Axis.HomeMove(ResetMoveInfo, forceHome);
Batch_Axis.HomeMove(ResetMoveInfo, forceHome);
CylinderMove(ResetMoveInfo, IO_Type.StringPosChecker_Home, IO_Type.StringPosChecker_Work, IO_VALUE.LOW);
CylinderMove(ResetMoveInfo, IO_Type.NGDoor_Close, IO_Type.NGDoor_Open, IO_VALUE.LOW);
//CylinderMove(ResetMoveInfo, IO_Type.NGDoor_Close, IO_Type.NGDoor_Open, IO_VALUE.LOW);
SingleDoor.ToLow(ResetMoveInfo);
break;
case MoveStep.H02_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H03_HomeReset);
......@@ -390,7 +391,8 @@ namespace DeviceLibrary
case MoveStep.H12_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H13_HomeReset);
ResetMoveInfo.log("打开NG口门");
CylinderMove(ResetMoveInfo, IO_Type.NGDoor_Close, IO_Type.NGDoor_Open, IO_VALUE.HIGH);
//CylinderMove(null, IO_Type.NGDoor_Close, IO_Type.NGDoor_Open, IO_VALUE.HIGH);
SingleDoor.ToHigh(null);
break;
case MoveStep.H13_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H14_HomeReset);
......@@ -399,6 +401,8 @@ namespace DeviceLibrary
Msg.add(crc.GetString(L.x29_low_no_reel, "传感器X29未检测到单料口料盘."), MsgLevel.alarm);
RobotManage.UserPause("传感器X29未检测到单料口料盘.");
}
//CylinderMove(ResetMoveInfo, IO_Type.NGDoor_Close, IO_Type.NGDoor_Open, IO_VALUE.HIGH);
SingleDoor.ToHigh(ResetMoveInfo);
break;
case MoveStep.H14_HomeReset:
if (NGDoor_Tray_Test_Reel)
......@@ -439,7 +443,8 @@ namespace DeviceLibrary
{
ResetMoveInfo.NextMoveStep(MoveStep.HEND_HomeReset);
ResetMoveInfo.log("关门NG口门");
CylinderMove(ResetMoveInfo, IO_Type.NGDoor_Close, IO_Type.NGDoor_Open, IO_VALUE.LOW);
//CylinderMove(ResetMoveInfo, IO_Type.NGDoor_Close, IO_Type.NGDoor_Open, IO_VALUE.LOW);
SingleDoor.ToLow(ResetMoveInfo);
OpenFlipDoor(ResetMoveInfo);
}
else
......@@ -513,6 +518,10 @@ namespace DeviceLibrary
}
Msg.add(crc.GetString(L.back_safedoor_not_close, "后侧防护门没有关闭") + (ok ? ignorestring : ""), MsgLevel.warning);
}
if (!lastSafeCheckStatus && ok)
{
SafetyDevice.ResumeAll();
}
lastSafeCheckStatus = ok;
return ok;
}
......@@ -522,16 +531,13 @@ namespace DeviceLibrary
{
AxisBean.StopMultiAxis(AxisBean.List);
MoveInfo.List.ForEach((m) => { m.CanWhileCount = 5; });
SafetyDevice.PauseAll();
if (runStatus == RunStatus.HomeReset)
{
ResetMoveInfo.NewMove(MoveStep.H01_HomeReset);
}
}
}
void DeviceResume() {
Line.Resume();
}
/// <summary>
/// 最后一次气压检测变为0的时间
......
......@@ -241,7 +241,8 @@ namespace DeviceLibrary
case MoveStep.NGOUT_01:
ClampMoveInfo.NextMoveStep(MoveStep.NGOUT_02);
ClampMoveInfo.log("打开单料口门");
CylinderMove(ClampMoveInfo, IO_Type.NGDoor_Close, IO_Type.NGDoor_Open, IO_VALUE.HIGH);
//CylinderMove(null, IO_Type.NGDoor_Close, IO_Type.NGDoor_Open, IO_VALUE.HIGH);
SingleDoor.ToHigh(null);
break;
case MoveStep.NGOUT_02:
ClampMoveInfo.NextMoveStep(MoveStep.NGOUT_03);
......@@ -251,6 +252,8 @@ namespace DeviceLibrary
Msg.add(ClampMoveInfo.MoveParam.NgMsg, MsgLevel.warning);
RobotManage.UserPause("传感器X29未检测到单料口料盘");
}
//CylinderMove(ClampMoveInfo, IO_Type.NGDoor_Close, IO_Type.NGDoor_Open, IO_VALUE.HIGH);
SingleDoor.ToHigh(ClampMoveInfo);
break;
case MoveStep.NGOUT_03:
Msg.add(ClampMoveInfo.MoveParam.NgMsg, MsgLevel.warning);
......@@ -292,7 +295,8 @@ namespace DeviceLibrary
{
ClampMoveInfo.NextMoveStep(MoveStep.Wait);
ClampMoveInfo.log("关门NG口门");
CylinderMove(ClampMoveInfo, IO_Type.NGDoor_Close, IO_Type.NGDoor_Open, IO_VALUE.LOW);
//CylinderMove(ClampMoveInfo, IO_Type.NGDoor_Close, IO_Type.NGDoor_Open, IO_VALUE.LOW);
SingleDoor.ToLow(ClampMoveInfo);
OpenFlipDoor(ClampMoveInfo);
}
else
......@@ -308,14 +312,16 @@ namespace DeviceLibrary
case MoveStep.SingleIn_01:
ClampMoveInfo.NextMoveStep(MoveStep.SingleInReady);
ClampMoveInfo.log("开始单盘入库, 打开紧急料口");
CylinderMove(ClampMoveInfo, IO_Type.NGDoor_Close, IO_Type.NGDoor_Open, IO_VALUE.HIGH);
//CylinderMove(ClampMoveInfo, IO_Type.NGDoor_Close, IO_Type.NGDoor_Open, IO_VALUE.HIGH);
SingleDoor.ToHigh(ClampMoveInfo);
break;
case MoveStep.SingleInReady:
Msg.add(crc.GetString(L.wait_put_reel_into_ngdoor, "等待放入单盘入库料盘"), MsgLevel.warning);
break;
case MoveStep.SingleInRun:
ClampMoveInfo.NextMoveStep(MoveStep.ReelClamp_09);
CylinderMove(ClampMoveInfo, IO_Type.NGDoor_Close, IO_Type.NGDoor_Open, IO_VALUE.LOW);
//CylinderMove(ClampMoveInfo, IO_Type.NGDoor_Close, IO_Type.NGDoor_Open, IO_VALUE.LOW);
SingleDoor.ToLow(ClampMoveInfo);
ClampMoveInfo.MoveParam.PlateW = 7;
ClampMoveInfo.MoveParam.PlateH = 100;
break;
......
......@@ -264,8 +264,16 @@ namespace TheMachine
public delegate void setmsgdelegate(List<Msg> msgs);
private void MainMachine_ProcessMsgEvent(List<Msg> msgs)
{
var d = new setmsgdelegate(SetMsg);
this.Invoke(d, msgs);
if (msgs == null || msgs.Count == 0)
return;
try
{
var d = new setmsgdelegate(SetMsg);
this.Invoke(d, msgs);
}
catch(Exception e) {
LogUtil.info("MainMachine_ProcessMsgEvent:" + e.ToString());
}
}
private void RobotManage_LoadFinishEvent(bool state, string msg)
......@@ -314,6 +322,9 @@ namespace TheMachine
listView1.Items.Clear();
foreach (Msg msg in msgs)
{
if (string.IsNullOrEmpty(msg.msgtxt) || msg.datetime==null)
continue;
ListViewItem lvi = new ListViewItem(new string[] { "", msg.datetime.ToString(), msg.msgtxt });
if (msg.msgLevel == MsgLevel.info)
lvi.ForeColor = Color.DarkGreen;
......
......@@ -85,9 +85,9 @@ namespace TheMachine
//MessageBox.Show("该程序已经启动", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
//Application.ThreadException += Application_ThreadException;
//Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
//AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Application.ThreadException += Application_ThreadException;
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Environment.CurrentDirectory = Application.StartupPath;
XmlConfigurator.Configure();
......
using DeviceLibrary;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
......@@ -211,6 +212,11 @@ namespace TheMachine
}
private void Button_Click(object sender, EventArgs e)
{
if (RobotManage.isRunning) {
MessageBox.Show(crc.GetString(L.system_running_cantmove,"系统正在运行,不能手动控制伺服"));
return;
}
var cc = tableLayoutPanel1.Controls.Find(((Button)sender).Name, false);
var speed = tableLayoutPanel1.Controls.Find(((Button)sender).Name+ "_speed", false);
......@@ -225,6 +231,7 @@ namespace TheMachine
var targetSpeed = int.Parse(speed[0].Text);
var AddSpeed = configMoveAxis.AddSpeed > 0 ? configMoveAxis.AddSpeed : targetSpeed * 4;
var DelSpeed = configMoveAxis.DelSpeed > 0 ? configMoveAxis.DelSpeed : targetSpeed * 4;
LogUtil.info($"手动点击:{((Button)sender).Text},pos:{targetpos}");
AxisManager.AbsMove("", configMoveAxis.GetAxisValue(), targetpos, targetSpeed, AddSpeed, DelSpeed);//, configMoveAxis.AddSpeed, configMoveAxis.DelSpeed);
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!