Commit b48a0a32 LN

1

1 个父辈 c7e73822
......@@ -88,6 +88,7 @@
<Compile Include="DeviceLibrary\ReelParam.cs" />
<Compile Include="DeviceLibrary\ServerCommunication.cs" />
<Compile Include="DeviceLibrary\AxisBean.cs" />
<Compile Include="theMachine\BaseBean.cs" />
<Compile Include="theMachine\ReelTransport.cs" />
<Compile Include="theMachine\Common.cs" />
<Compile Include="theMachine\InReelBean.cs" />
......

namespace DeviceLibrary
{
public class BaseBean
{
public string Name = "";
public string WarnMsg = "";
public MoveInfo MoveInfo;
protected void SetWarnMsg(string msg = "", MsgLevel level = MsgLevel.warning, ErrInfo errInfo = ErrInfo.Empty)
{
if (msg.Equals(""))
{
WarnMsg = "";
return;
}
WarnMsg = msg;
//暂无NG空位
Msg.add(msg, level, errInfo);
if (RobotManage.mainMachine != null)
{
RobotManage.mainMachine.MsgEvent(Msg.get());
}
}
protected void ClearWarnMsg(string v)
{
if (WarnMsg.Contains(v))
{
SetWarnMsg("");
}
}
}
}
\ No newline at end of file
......@@ -6,10 +6,8 @@ using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text.RegularExpressions;
namespace DeviceLibrary
{
......@@ -324,13 +322,28 @@ namespace DeviceLibrary
List<Msg> mm = new List<Msg>(msg);
return mm;
}
public static void add(string m, MsgLevel ml, ErrInfo errInfo= ErrInfo.Empty)
public static void add(string m, MsgLevel ml, ErrInfo errInfo = ErrInfo.Empty)
{
lock (msg)
{
if (ml.Equals(MsgLevel.info))
{
}
else if (ml.Equals(MsgLevel.warning))
{
LogUtil.info(m);
}
else if (ml.Equals(MsgLevel.alarm))
{
LogUtil.error(m);
}
var fm = msg.Find((x) => x.msgtxt == m);
if (fm==null)
if (fm == null)
{
msg.Add(new Msg { msgtxt = m, msgLevel = ml, datetime = DateTime.Now, errInfo = errInfo });
}
}
}
static bool _setlogones = false;
......
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class InReelBean
public class InReelBean:BaseBean
{
//设备名称
public string Name;
//料盘检测信号
public string Reel_Check = "Reel_Check";
MoveInfo MoveInfo;
public string WarnMsg = "";
//private string LastCode;
private List<CodeLibrary.CodeInfo> LastCode;
......@@ -45,7 +41,7 @@ namespace DeviceLibrary
MoveInfo.NewMove(MoveStep.Wait);
MoveInfo.log("执行重置,清理当前条码:"+LastCode);
LastCode = new List<CodeLibrary.CodeInfo>();
WarnMsg = "";
SetWarnMsg();
}
public bool ReelReady()
......@@ -61,7 +57,7 @@ namespace DeviceLibrary
MoveInfo.NewMove(MoveStep.Wait);
MoveInfo.log("料盘已离开:执行重置,清理当前条码:" + LastCode);
LastCode = new List<CodeLibrary.CodeInfo> ();
WarnMsg = "";
SetWarnMsg();
}
bool pause = false;
......@@ -96,7 +92,7 @@ namespace DeviceLibrary
MoveInfo.NewMove(MoveStep.IN01_WaitCheck);
MoveInfo.log("检测到料盘信号");
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(Reel_Check, IO_VALUE.HIGH));
WarnMsg = "";
SetWarnMsg();
}
}
else
......@@ -115,7 +111,7 @@ namespace DeviceLibrary
}
else if (MoveInfo.IsTimeOut(60))
{
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveStep + "] 扫码执行结束超时 [" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
SetWarnMsg( MoveInfo.Name + "[" + MoveInfo.MoveStep + "] 扫码执行结束超时 [" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒");
}
break;
case MoveStep.IN03_GetPos:
......@@ -126,7 +122,7 @@ namespace DeviceLibrary
}
else if (MoveInfo.IsTimeOut(60))
{
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveStep + "] 获取库位号超时 [" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
SetWarnMsg( MoveInfo.Name + "[" + MoveInfo.MoveStep + "] 获取库位号超时 [" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒");
}
break;
case MoveStep.IN05_ReelReady:
......@@ -186,7 +182,7 @@ namespace DeviceLibrary
if (String.IsNullOrEmpty(shelfRfid))
{
//无可用料架
WarnMsg = $"{Name}:{codestr}暂无可用料架";
SetWarnMsg( $"{Name}:{codestr}暂无可用料架");
MoveInfo.errlog("获取库位号: " + WarnMsg + ",等待3秒后重新获取");
Thread.Sleep(3000);
}
......@@ -204,7 +200,7 @@ namespace DeviceLibrary
}
else
{
WarnMsg = " getLocation " + outMsg;
SetWarnMsg( " getLocation " + outMsg);
}
break;
}
......@@ -218,13 +214,7 @@ namespace DeviceLibrary
}
}
private void ClearWarnMsg(string v)
{
if (WarnMsg.Contains(v))
{
WarnMsg = "";
}
}
bool movelock = false;
internal void Lock()
......
......@@ -76,7 +76,7 @@ namespace DeviceLibrary
}
private void RightNgDoorOpen()
{
clearNgPos("NG_7");
clearNgPos("NG_2");
}
}
......
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DeviceLibrary
{
......@@ -75,6 +71,7 @@ namespace DeviceLibrary
public MainMachine(Robot_Config _config) {
Config = _config;
Name = "出料机构";
crc.LanguageChangeEvent += Crc_LanguageChangeEvent;
StoreMoveInfo = new MoveInfo("移库调度");
StoreMoveInfo.SetStateDelegate(StoreState);
......@@ -121,11 +118,12 @@ namespace DeviceLibrary
inReelBeans.Add(inReel);
}
for (int i = 1; i < 5; i++)
{
OutShelfBean outShelf = new OutShelfBean("U" + i);
outShelfBeans.Add(outShelf.Name, outShelf);
}
outShelfBeans.Add("U1", new OutShelfBean("U1", Config.RFID_U1));
outShelfBeans.Add("U2", new OutShelfBean("U2", Config.RFID_U2));
outShelfBeans.Add("U3", new OutShelfBean("U3", Config.RFID_U3));
outShelfBeans.Add("U4", new OutShelfBean("U4", Config.RFID_U4));
LedProcessInit();
LoadOk = true;
}
......@@ -286,7 +284,14 @@ namespace DeviceLibrary
}
public void BeginHomeReset(bool firstRun=false) {
public bool BeginHomeReset(bool firstRun=false) {
if (IOManager.IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW))
{
Msg.add("急停未开,回原失败", MsgLevel.alarm, ErrInfo.SuddenStop);
return false;
}
if (!firstRun)
{
StopMove();
......@@ -307,6 +312,7 @@ namespace DeviceLibrary
{
bean.Reset();
}
return true;
}
//强制回原
bool forceHome=true;
......@@ -714,5 +720,10 @@ namespace DeviceLibrary
}
return targetPosName;
}
public void MsgEvent(List<Msg> msgs)
{
ProcessMsgEvent?.Invoke(msgs);
}
}
}
\ No newline at end of file
using CodeLibrary;
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
namespace DeviceLibrary
......@@ -50,6 +47,8 @@ namespace DeviceLibrary
if (ngPos == "")
{
//暂无NG空位
Msg.add("[" + inReel.Name + "]获取NG库位号失败",MsgLevel.warning,ErrInfo.Empty);
ProcessMsgEvent?.Invoke(Msg.get());
}
else
{
......@@ -73,6 +72,12 @@ namespace DeviceLibrary
StoreMoveInfo.log("出库料准备放料:" + StoreMoveInfo.MoveParam.ToStr());
break;
}
else
{
//暂无NG空位
Msg.add("[" + inReel.Name + "]获取库位号失败", MsgLevel.warning, ErrInfo.Empty);
ProcessMsgEvent?.Invoke(Msg.get());
}
}
}
}
......
......@@ -112,8 +112,13 @@ namespace DeviceLibrary
}
string lastmsg = "";
public void log(string msg) {
msg = $"[{Name}][{moveStep}][{MoveParam.TargetPos}-{MoveParam.WareCode}]{msg}";
msg = $"[{Name}][{moveStep}][{MoveParam.TargetPos}-{MoveParam.WareCode}]: {msg}";
if (MoveParam.TargetPos.Equals("") && MoveParam.WareCode.Equals(""))
{
msg = $"[{Name}][{moveStep}]: {msg}";
}
if (String.Compare(lastmsg,msg, StringComparison.Ordinal)!=0)
{
lastmsg = msg;
......
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text;
namespace DeviceLibrary
{
public class OutShelfBean
public class OutShelfBean: BaseBean
{
public static PuYueRFID_C2S RFID = null;
public string Name;
MoveInfo MoveInfo;
public string WarnMsg = "";
public static PuYueRFID_C2S RFID = null;
/// <summary>
/// 出料口定位气缸,high=up,low=down
/// </summary>
private CylinderManger locationCylinder;
public ShelfInfo CurrShelf;
public string rfidIp;
public OutShelfBean(string name )
public OutShelfBean(string name, string ip)
{
this.Name = name;
MoveInfo = new MoveInfo(name );
this.Name = name;
this.rfidIp = ip;
MoveInfo = new MoveInfo(name);
#region 初始化IO
string ioStr = name + "_";
......@@ -43,7 +38,7 @@ namespace DeviceLibrary
RFID = new PuYueRFID_C2S(rfidIp);
if (!RFID.Open())
{
LogUtil.info(name + " RFID 打开失败:" + rfidIp);
SetWarnMsg(name + " RFID 打开失败:" + rfidIp);
}
#endregion
}
......@@ -133,7 +128,7 @@ namespace DeviceLibrary
else
{
locationCylinder.ToHigh(null);
WarnMsg = "定位气缸不到位";
SetWarnMsg( Name+"定位气缸不到位",MsgLevel.alarm);
}
}
return false;
......@@ -352,6 +347,7 @@ namespace DeviceLibrary
}
else
{
MoveInfo.log("未读取到RFID,等待1秒后重新读取");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
}
......@@ -364,6 +360,7 @@ namespace DeviceLibrary
}
private bool ReadShelfId()
{
CurrShelf = new ShelfInfo("");
if (RFID.Open())
{
if (RFID.ReadByte(0x20, 16, out byte[] data))
......@@ -376,14 +373,12 @@ namespace DeviceLibrary
else
{
//读取失败,重试之类
WarnMsg = "RFID[" + rfidIp + "]读取失败";
LogUtil.error(WarnMsg);
SetWarnMsg(Name+ "RFID[" + rfidIp + "]读取失败",MsgLevel.alarm);
}
}
else
{
WarnMsg = "RFID[" + rfidIp + "]打开失败";
LogUtil.error(WarnMsg);
{
SetWarnMsg(Name + "RFID[" + rfidIp + "]打开失败", MsgLevel.alarm);
}
return false;
}
......
......@@ -6,9 +6,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DeviceLibrary
......@@ -62,11 +60,12 @@ namespace DeviceLibrary
//public static SocketScanner socketScanner;
public static HIKCamera CameraA=new HIKCamera();
public static void Init() {
public static void Init()
{
string msg = "";
try
{
mainMachine = null;
mainMachine = null;
string configFile = Path.Combine(baseDir, "config\\Config.csv");
Config = new Robot_Config(0, "", configFile);
Config = (Robot_Config)CSVConfigReader.LoadConfig(Config);
......@@ -80,7 +79,8 @@ namespace DeviceLibrary
var MagzinePostion = CSVPositionReader<ACStorePosition>.LoadCSVFile(MagzinePostionFile);
var OrtherPostion = CSVPositionReader<ACStorePosition>.LoadCSVFile(OrtherPostionFile);
}
catch(Exception ex) {
catch (Exception ex)
{
LogUtil.info("加载库位失败:" + ex);
IsLoadOk = false;
msg += "加载库位失败" + "\n";
......@@ -92,16 +92,13 @@ namespace DeviceLibrary
if (!IOManager.ConnectionIOList(new List<string>()))
{
IsLoadOk = false;
msg += crc.GetString(L.iocard_init_fail, "IO板卡初始化失败")+ "\n";
}
msg += crc.GetString(L.iocard_init_fail, "IO板卡初始化失败") + "\n";
}
IOManager.IOMove(IO_Type.Camera_Led, IO_VALUE.HIGH);
}
catch (Exception ex) {
catch (Exception ex)
{
LoadFinishEvent?.Invoke(false, ex.Message);
return;
}
......@@ -118,13 +115,17 @@ namespace DeviceLibrary
if (!IsConfigMode)
return;
}
mainThread = new Thread(new ThreadStart(mainMachine.Start));
mainThread.Start();
isRunning = true;
GC.KeepAlive(mainThread);
bool result= mainMachine.BeginHomeReset(true);
if (result)
{
mainThread = new Thread(new ThreadStart(mainMachine.Start));
mainThread.Start();
mainMachine.BeginHomeReset(true);
isRunning = true;
GC.KeepAlive(mainThread);
}
//Task.Run(()=> {
// AxisBean.List.ForEach((x) => { AxisManager.AlarmClear(x.Config.DeviceName, x.Config.GetAxisValue()); });
......
......@@ -7,8 +7,7 @@ AXIS,,ѹ,Comp_Axis,3,HC,,100000,0,0,0,40000,0,10,700,0,0
PRO,50,RFID-U1,RFID_U1,192.168.10.1,,,,,,,,,,,,
PRO,50,RFID-U2,RFID_U2,192.168.10.2,,,,,,,,,,,,
PRO,50,RFID-U3,RFID_U3,192.168.10.3,,,,,,,,,,,,
PRO,50,RFID-U4,RFID_U4,192.168.10.4,,,,,,,,,,,,
PRO,50,RFID-U5,RFID_U5,192.168.10.5,,,,,,,,,,,,
PRO,50,RFID-U4,RFID_U4,192.168.10.4,,,,,,,,,,,,
,,,,,,,,,,,,,,,,
DI,0,急停,SuddenStop_BTN,0,HC,X00,,,,,,,,,,
DI,0,复位,Reset_BTN,1,HC,X01,,,,,,,,,,
......
......@@ -60,12 +60,7 @@ namespace OnlineStore.LoadCSVLibrary
/// PRO,50,RFID-U4,RFID_U4,192.168.10.4,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("RFID_U4")]
public string RFID_U4 { get; set; }
/// <summary>
/// PRO,50,RFID-U5,RFID_U5,192.168.10.5,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("RFID_U5")]
public string RFID_U5 { get; set; }
public string RFID_U4 { get; set; }
/// <summary>
......
......@@ -76,22 +76,22 @@ namespace TheMachine
listView1.View = View.Details;
AddHeader(listView1, "", 0);
AddHeader(listView1, crc.GetString("Res0048", "时间"), 150);
AddHeader(listView1, crc.GetString("Res0047", "信息"), 530);
AddHeader(listView1, crc.GetString("Res0047", "信息"), listView1.Width-150-3);
listView1.ColumnWidthChanging += listView_ColumnWidthChanging;
#endregion
#region 状态信息listview初始化
stateView.View = View.Details;
AddHeader(stateView, "", 0);
AddHeader(stateView, crc.GetString("Res0049", "模块"), 200);
AddHeader(stateView, crc.GetString("Res0049", "模块"), 120);
AddHeader(stateView, crc.GetString("Res0050", "步骤"), 200);
AddHeader(stateView, crc.GetString("Res0047", "信息"), 500);
AddHeader(stateView, crc.GetString("Res0047", "信息"), stateView.Width-120-200-3);
stateView.ColumnWidthChanging += listView_ColumnWidthChanging;
#endregion
#region 物料信息显示列表
listReelInfo.View = View.Details;
AddHeader(listReelInfo, "", 0);
AddHeader(listReelInfo, "位置", 200);
AddHeader(listReelInfo, "位置", 100);
AddHeader(listReelInfo, "料盘信息", listReelInfo.Width-200-3);
listReelInfo.ColumnWidthChanging += listView_ColumnWidthChanging;
#endregion
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!