Commit 63f15d87 刘韬

1

1 个父辈 e9c35325
......@@ -156,6 +156,9 @@
<Compile Include="userControl\FixtureSizeConfigControl.Designer.cs">
<DependentUpon>FixtureSizeConfigControl.cs</DependentUpon>
</Compile>
<Compile Include="userControl\ToucDownBtn.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="VirtuallyStore\BufferSlotsManger.cs" />
<Compile Include="VirtuallyStore\CommandList.cs" />
<Compile Include="VirtuallyStore\Reference.cs" />
......
......@@ -54,66 +54,24 @@ namespace DeviceLibrary
Msg += string.Format("...伺服忙碌,急停{0}次", openretry);
Thread.Sleep(100);
}
//if (AxisManager.GetAlarmStatus(portName, slvAddr) != 0)
//{
// AxisManager.AlarmClear(portName, slvAddr);
// Msg += string.Format("...尝试清除报警第(0)次", openretry);
// Thread.Sleep(100);
//}
AxisManager.ServoOn(portName, slvAddr);
Thread.Sleep(200);
if (AxisManager.IsServeoOn(portName, slvAddr))
{
Msg += "...使能成功";
Msg += "..." + "使能成功";
openretry = 0;
return true;
}
else
Msg += "...尝试使能失败";
Msg += "..." + "尝试使能失败";
Thread.Sleep(1000);
if (openretry < 5)
Msg = "伺服连接中...";
Msg = "伺服连接中" + "...";
}
return false;
}
/// <summary>
/// 打开所有轴
/// </summary>
/// <returns></returns>
private bool OpenAxis(out string msg)
{
msg = "";
//判断轴是否正常
string portName = Config.DeviceName;
short slvAddr = Config.GetAxisValue();
if (AxisManager.IsServeoOn(portName, slvAddr))
{
LogUtil.info(AxisName + "成功打开");
}
else
{
//清理报警,再重新打开一次
LogUtil.info(AxisName + "第一次打开失败,先清理一下报警,再重新打开一次");
AxisManager.AlarmClear(portName, slvAddr);
System.Threading.Thread.Sleep(1000);
AxisManager.ServoOn(portName, slvAddr);
System.Threading.Thread.Sleep(100);
if (AxisManager.IsServeoOn(portName, slvAddr))
{
LogUtil.info(AxisName + "清理报警后重新打卡轴成功:" + Config.Explain);
}
else
{
AxisManager.ServoOff(portName, slvAddr);
msg = "打开轴" + Config.Explain + "失败 ";
LogUtil.info(AxisName + msg);
return false;
}
}
return true;
}
public void ServoOff()
{
LogUtil.info("ServoOff【" + AxisName + "】");
......@@ -204,7 +162,7 @@ namespace DeviceLibrary
int isAlarm = AxisManager.GetAlarmStatus(deviceName, axisNo);
if (isAlarm.Equals(1))
{
clearMsg = "清理报警,";
clearMsg = "清理报警" + ",";
AxisManager.AlarmClear(deviceName, axisNo);
Thread.Sleep(200);
AxisManager.ServoOn(deviceName, axisNo);
......@@ -225,7 +183,7 @@ namespace DeviceLibrary
}
else
{
msg = $"{MoveInfo.Name} {MoveInfo.MoveStep} {axis.DisplayStr},目标位置{targetPosition},当前位置{outCount},误差过大,需要报警";
msg = $"{MoveInfo.Name} {MoveInfo.MoveStep} {axis.DisplayStr}," + "目标位置" + $"{targetPosition}," + "当前位置" + $"{outCount}" + ",误差过大,需要报警";
MoveInfo.error(msg);
}
}
......@@ -253,7 +211,7 @@ namespace DeviceLibrary
}
else
{
msg = MoveInfo.Name + " " + MoveInfo.MoveStep + axis.DisplayStr + ",收到原点完成信号,当前位置[" + outCount + "],误差过大,需要报警";
msg = MoveInfo.Name + " " + MoveInfo.MoveStep + axis.DisplayStr + "," + "收到原点完成信号,当前位置" + "[" + outCount + "]," + "误差过大,需要报警";
MoveInfo.error(msg);
}
}
......
......@@ -42,12 +42,14 @@ namespace DeviceLibrary
if (robot.CurDashboardReponse.Contains("PROTECTIVE_STOP"))
{
robot.SendCMD("unlock protective stop", 0);
return;
}
return;
}
robot.SendCMD("programState", 0);
Thread.Sleep(300);
Thread.Sleep(700);
if (!robot.CurDashboardReponse.Contains("PLAYING"))
{
RobotStatus = false;
......
......@@ -54,6 +54,11 @@ namespace DeviceLibrary
OutMaterialTaskCount = data["pizzaBox"] + data["pcb"] + data["tray"];
OutReelTaskCount = data["reel"];
}
var remoteLoad = new RemoteLoad();
remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.TrayType = TrayTypeE.MTP1.ToString();
var r = TrayManager.IsNeedProcessNG(remoteLoad);
TheLine.UploadCustData("IsNeedProcessNG", r ? "true" : "false");
//if (!RobotManage.isRunning)
// ProcessMsg(MsgService.MSList);
//if (!string.IsNullOrWhiteSpace(server))
......
......@@ -70,7 +70,7 @@ namespace DeviceLibrary
{
if (RobotManage.isRunning)
{
ProcessMsg(VMsg.msg);
//ProcessMsg(VMsg.msg);
SendLineStatus();
}
}
......@@ -83,18 +83,36 @@ namespace DeviceLibrary
}
}
public void ProcessMsg(List<Msg> msg) {
WarnMsg = string.Join(",", msg.Select(x =>
public void ProcessMsg(List<Msg> msg)
{
if (msg == null)
return;
WarnMsg = string.Join("\r\n", msg.Select(x =>
{
if (x.msgLevel == MsgLevel.warning || x.msgLevel == MsgLevel.alarm)
{
return x.msgtxt;
return GetMsgPrefix(x.msgLevel) + x.msgtxt;
}
return null;
}
).Where(x=>!string.IsNullOrEmpty(x)));
).Where(x => !string.IsNullOrEmpty(x)));
}
string GetMsgPrefix(MsgLevel msgLevel)
{
switch (msgLevel)
{
case MsgLevel.info:
return "I=";
case MsgLevel.warning:
return "W=";
case MsgLevel.alarm:
return "A=";
}
return "";
}
public bool SendStoreState(string posid, string barcode, StoreStatus storeStatus)
{
......
......@@ -103,22 +103,23 @@ namespace DeviceLibrary
else if ((DateTime.Now - LastStatusTime).TotalSeconds > 30)
{
TerminalError = true;
if (InStoreJobInfo!=null)
if (InStoreJobInfo != null)
CurrentTerminalReelID = InStoreJobInfo.WareNum;
if (RTStoreStatus == RTStoreStatus.InStoreReady)
{
VLog.Error($"入库超时出错,没有执行入库过程,RTStoreStatus={RTStoreStatus}:" + InStoreJobInfo?.ToStr());
CurrentTowerStatusText = crc.GetString("Res0065","入库错误,没有执行入库过程");
CurrentTowerStatusText = crc.GetString("Res0065", "入库错误,没有执行入库过程");
}
else if (RTStoreStatus == RTStoreStatus.LockToInStore)
{
VLog.Error($"入库超时出错,没有检测到料盘,RTStoreStatus={RTStoreStatus}:" + InStoreJobInfo?.ToStr());
CurrentTowerStatusText = crc.GetString("Res0065","入库错误,没有执行入库过程");
CurrentTowerStatusText = crc.GetString("Res0065", "入库错误,没有执行入库过程");
}
else
{
VLog.Error($"未知状态超时,RTStoreStatus={RTStoreStatus}:" + InStoreJobInfo?.ToStr());
}
Msg.add($"TerminalError" + "入库超时", MsgLevel.warning);
}
}
else if (ti.StatusCode == 1031)
......@@ -144,7 +145,7 @@ namespace DeviceLibrary
if (!ServerCM.BeginInStore(CID, InStoreJobInfo, VLog))
{
RTStoreStatus = RTStoreStatus.LockToInStore;
Msg.add(CID + crc.GetString("Res0051", "无法入库"), MsgLevel.alarm);
//Msg.add(CID + crc.GetString("Res0051", "无法入库"), MsgLevel.alarm);
VLog.Info("入库指令失败:" + InStoreJobInfo.ToStr());
}
CurrentTerminalReelID = InStoreJobInfo.WareNum;
......@@ -179,8 +180,9 @@ namespace DeviceLibrary
}
else if (ti.StatusCode == 310117 || ti.StatusCode == 310249)
{
Msg.add($"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}", MsgLevel.warning);
RTStoreStatus = RTStoreStatus.InStoreError;
ServerCM.storeStatus = StoreStatus.InStoreError;
ServerCM.storeStatus = StoreStatus.InStoreFaild;
InStoreJobInfo = null;
}
else if (ti.StatusCode < 10000)
......@@ -188,10 +190,12 @@ namespace DeviceLibrary
RTStoreStatus = RTStoreStatus.Busy;
ServerCM.storeStatus = StoreStatus.None;
//VLog.Info($"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}");
Msg.add($"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}", MsgLevel.alarm);
}
else
{
//VLog.Error($"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}");
Msg.add($"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}", MsgLevel.alarm);
ServerCM.storeStatus = StoreStatus.InTrouble;
RTStoreStatus = RTStoreStatus.Error;
}
......@@ -239,8 +243,14 @@ namespace DeviceLibrary
SlotsInfo[$"{w}x{h}"] = $"{ti.Slots[i].Slots_used}/{ti.Slots[i].Slots_free}";
}
}
catch (Exception ex) {
VLog.Error("VStore Error:"+ex);
catch (Exception ex)
{
VLog.Error("VStore Error:" + ex);
}
finally
{
ServerCM.ProcessMsg(Msg.msg);
Msg.clear();
}
}
public Dictionary<string, string> SlotsInfo = new Dictionary<string, string>();
......@@ -266,6 +276,8 @@ namespace DeviceLibrary
public volatile JobInfo InStoreJobInfo;
StoreJobList OutStoreJobList;
public void RequestInStore(JobInfo jobInfo) {
LastStatusTime=DateTime.Now;
TerminalError = false;
InStoreJobInfo = jobInfo.Clone();
//return vc.BeginInStore(CID, jobInfo);
}
......
......@@ -148,15 +148,17 @@ namespace DeviceLibrary
{
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveStep + "] " + crc.GetString("Res0157", "等待") + "(" + io.DisplayStr + "=" + wait.IoValue + $")" + crc.GetString("Res0158", "超时");
Msg.add(WarnMsg, wait.NeedAlarm?MsgLevel.alarm: MsgLevel.warning);
if (wait.NeedAlarm)
{
Msg.add(WarnMsg, wait.NeedAlarm ? MsgLevel.alarm : MsgLevel.warning);
RobotManage.UserPause(WarnMsg);
return true;
}
if (NoAlarm())
{
//Alarm(AlarmType.IoSingleTimeOut, WarnMsg);
MoveInfo.error(WarnMsg);
//MoveInfo.error(WarnMsg);
//MoveInfo.errlog(WarnMsg);
if (!MoveInfo.OneWaitCanEndStep)
{
......
......@@ -15,6 +15,7 @@ namespace DeviceLibrary
public class DeviceRunControl
{
public static List<ManualResetEvent> manualResets = new List<ManualResetEvent>();
public static List<DeviceRunControl> DeviceRunControlList = new List<DeviceRunControl>();
List<IDevice> DevicesList;
string DeviceListName;
ManualResetEvent resetEvent = new ManualResetEvent(false);
......@@ -31,52 +32,71 @@ namespace DeviceLibrary
resetEvent.Reset();
}
void Run() {
LogUtil.info($"{DeviceListName}设备线程启动");
LogUtil.info($"{DeviceListName} 设备线程启动");
while (RobotManage.mainMachine.mstart)
{
Thread.Sleep(150);
ManualResetEvent.WaitAll(new ManualResetEvent[] { RobotManage.mainMachine.ResetEvent });
Debug.WriteLine($"DeviceRunControl canRunning:{RobotManage.mainMachine.canRunning}, mstart:{RobotManage.mainMachine.mstart}");
if (!RobotManage.mainMachine.canRunning || !RobotManage.mainMachine.mstart)
try
{
if (RobotManage.mainMachine.mstart) {
DevicesList.ForEach(x =>
{
x.FrontStopProcess();
});
}
continue;
}
DevicesList.ForEach(x =>
{
try
Thread.Sleep(200);
ManualResetEvent.WaitAll(new ManualResetEvent[] { RobotManage.mainMachine.ResetEvent });
Debug.WriteLine($"DeviceRunControl:{DeviceListName} canRunning:{RobotManage.mainMachine.canRunning}, mstart:{RobotManage.mainMachine.mstart}");
if (!RobotManage.mainMachine.canRunning || !RobotManage.mainMachine.mstart)
{
x.Process();
if (RobotManage.mainMachine.mstart)
{
DevicesList.ForEach(x =>
{
x.FrontStopProcess();
});
}
continue;
}
catch (Exception ex)
DevicesList.ForEach(x =>
{
MsgService.MSList[x.GroupName].add(ex.ToString(), MsgLevel.warning);
MsgService.MSList[x.GroupName].setlogones();
LogUtil.error($"{DeviceListName} 出错:"+ ex);
}
finally
try
{
x.Process();
}
catch (Exception ex)
{
LogUtil.error($"{DeviceListName} 出错:" + ex);
MsgService.MSList[x.GroupName].add(ex.ToString(), MsgLevel.warning);
MsgService.MSList[x.GroupName].setlogones();
}
finally
{
MsgService.MSList[x.GroupName].Show();
}
});
if (!RobotManage.mainMachine.UserPause && RobotManage.mainMachine.mstart)
{
MsgService.MSList[x.GroupName].Show();
DevicesList.ForEach(x =>
{
MsgService.MSList[x.GroupName].clear();
});
}
});
//ProcessMoveinfoEvent?.Invoke(MoveInfo.List);
if (!RobotManage.mainMachine.UserPause && RobotManage.mainMachine.mstart)
}
catch(Exception ex) {
LogUtil.error($"{DeviceListName} 设备线程出错:"+ex);
}
finally
{
DevicesList.ForEach(x =>
{
MsgService.MSList[x.GroupName].clear();
});
resetEvent.Set();
}
resetEvent.Set();
}
LogUtil.info($"{DeviceListName}设备线程已退出.");
LogUtil.info($"{DeviceListName} 设备线程已退出.");
}
public static void AddDevice(string name, List<IDevice> devices)
{
DeviceRunControlList.Add(new DeviceRunControl(name, devices));
}
public static void StartAll()
{
DeviceRunControlList.ForEach(x => { x.Start(); });
}
}
}
\ No newline at end of file
......@@ -16,7 +16,7 @@ namespace DeviceLibrary
{
void ioMonitor()
{
if (IOValue(IO_Type.Airpressure_Check).Equals(IO_VALUE.LOW)) {
if (IOValue(IO_Type.Airpressure_Check).Equals(IO_VALUE.LOW) && !G.simulate) {
Msg.add(crc.GetString("Res0166","未检测到气压信号."), MsgLevel.warning);
}
}
......
......@@ -230,14 +230,8 @@ namespace DeviceLibrary
internal DateTime checkAlarmTime = DateTime.Now;
public bool DeviceCheck() {
bool ok = true;
isInSuddenDown = IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW);
if (IOValue(IO_Type.AutoRun_Single).Equals(IO_VALUE.LOW)) {
Msg.add(crc.GetString("Res0001","自动运行开关未开"), MsgLevel.warning);
DeviceSuddenStop();
lastSafeCheckStatus = false;
ok = false;
}
else if (UserPause)
if (UserPause)
{
Msg.add(crc.GetString("Res0175", "系统暂停"), MsgLevel.warning);
DeviceSuddenStop();
......@@ -245,6 +239,15 @@ namespace DeviceLibrary
ok = false;
return ok;
}
if (G.simulate)
return true;
isInSuddenDown = IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW);
if (IOValue(IO_Type.AutoRun_Single).Equals(IO_VALUE.LOW)) {
Msg.add(crc.GetString("Res0001","自动运行开关未开"), MsgLevel.warning);
DeviceSuddenStop();
lastSafeCheckStatus = false;
ok = false;
}
else if (isInSuddenDown)
{
Msg.add(crc.GetString("Res0176", "急停中"), MsgLevel.alarm);
......@@ -255,7 +258,7 @@ namespace DeviceLibrary
Msg.add(crc.GetString("Res0177", "系统需要重置"), MsgLevel.alarm);
ok = false;
}
if (IOValue(IO_Type.Airpressure_Check).Equals(IO_VALUE.LOW))
if (IOValue(IO_Type.Airpressure_Check).Equals(IO_VALUE.LOW) && !G.simulate)
{
if (lastAirCloseTime == DateTime.MinValue)
lastAirCloseTime = DateTime.Now;
......
......@@ -262,32 +262,28 @@ namespace DeviceLibrary
{
if (IsHomeMove)
{
return "轴【" + AxisInfo.DisplayStr + "】原点返回";
return "轴" + "【" + AxisInfo.DisplayStr + "】" + "原点返回";
}
else
{
return "轴【" + AxisInfo.DisplayStr + "】绝对运动,目标位置【" + TargetPosition + "】";
return "轴" + "【" + AxisInfo.DisplayStr + "】" + "绝对运动,目标位置" + "【" + TargetPosition + "】";
}
}
else if (WaitType.Equals(WaitEnum.W002_IOValue))
{
return "等待【" + IoType + "】=【" + IoValue + "】";
return "等待" + "【" + IoType + "】=【" + IoValue + "】";
}
else if (WaitType.Equals(WaitEnum.W003_Time))
{
return "时间等待:【" + TimeMSeconds + "】毫秒";
}
else if (WaitType.Equals(WaitEnum.W005_ShuoKe))
{
return "硕科电机目标位置:【" + TargetPosition + "】 ";
return "时间等待" + ":【" + TimeMSeconds + "】" + "毫秒";
}
else if (WaitType.Equals(WaitEnum.W006_AxisOrg))
{
return "轴【" + AxisInfo.DisplayStr + "】ORG信号:【" + IoValue + "】 ";
return "轴" + "【" + AxisInfo.DisplayStr + "】" + "ORG信号" + ":【" + IoValue + "】";
}
else if (WaitType.Equals(WaitEnum.W007_ReelHeight))
{
return "料盘高度【" + TargetPosition + "】 ";
return "料盘高度" + "【" + TargetPosition + "】";
}
else if (WaitType.Equals(WaitEnum.W008_BatchAxis))
{
......@@ -303,7 +299,7 @@ namespace DeviceLibrary
}
else
{
return "Wait位置类型:WaitType=【" + WaitType + "】";
return "WaitType=【" + WaitType + "】";
}
}
/// <summary>
......
......@@ -59,7 +59,9 @@ namespace DeviceLibrary
{
var remoteLoad = JsonConvert.DeserializeObject<RemoteLoad>(message);
Seq = remoteLoad.Seq;
lastresult[Seq] = RemoteResult.None;
lock (lastresult) {
lastresult[Seq] = RemoteResult.None;
}
switch (remoteLoad.Action)
{
case "SetTrayRequest":
......@@ -77,9 +79,15 @@ namespace DeviceLibrary
case "IsNeedProcessNG":
isok = TrayManager.IsNeedProcessNG(remoteLoad);
break;
case "Heartbeats": //客户端心跳包
isok = true;
break;
case "OK":
case "FAIL":
lastresult[Seq] = remoteLoad.Action == "OK" ? RemoteResult.True : RemoteResult.False;
lock (lastresult)
{
lastresult[Seq] = remoteLoad.Action == "OK" ? RemoteResult.True : RemoteResult.False;
}
LogUtil.info($"[{remoteLoad.GroupName}] Revice Command Callback:" + remoteLoad.Action);
return;
default:
......@@ -113,7 +121,10 @@ namespace DeviceLibrary
if (remoteLoad.RequestLoadInfo != null && string.IsNullOrEmpty(remoteLoad.RequestLoadInfo.DeviceGroupName))
remoteLoad.RequestLoadInfo.DeviceGroupName = GroupName;
LogUtil.info($"[{GroupName}],发送:{remoteLoad.Action},Seq:{remoteLoad.Seq}");
lastresult[remoteLoad.Seq] = RemoteResult.None;
lock (lastresult)
{
lastresult[remoteLoad.Seq] = RemoteResult.None;
}
SendMessage(GroupName, remoteLoad);
return WaitResult(GroupName, remoteLoad.Seq,waittime);
}
......
......@@ -54,9 +54,10 @@ namespace DeviceLibrary
{
LogUtil.info("加载位置文件:" + configFile);
}
else {
else
{
IsLoadOk = false;
msg += crc.GetString("Res0180","找不到库位配置文件")+ "\n";
msg += crc.GetString("Res0180", "找不到库位配置文件") + "\n";
}
string MI1PostionFile = "config\\MI1Postion.csv";
......@@ -76,34 +77,12 @@ namespace DeviceLibrary
Robot_CI.SetSpeedRate(Setting_Init.URRobot_CI_Speed_Rate);
VStoreCollection = new VStoreCollection();
//if (Robot_MI1.StartRobot()) {
// LogUtil.info("MI1 UR机器人启动成功,"+ Robot_MI1.GetStatus());
//} else {
// IsLoadOk = false;
// msg += "MI1 UR机器人启动失败" + "\n";
//}
//if (Robot_MI2.StartRobot())
//{
// LogUtil.info("MI2 UR机器人启动成功," + Robot_MI2.GetStatus());
//}
//else
//{
// IsLoadOk = false;
// msg += "MI2 UR机器人启动失败" + "\n";
//}
//if (Robot_CI.StartRobot())
//{
// LogUtil.info("CI UR机器人启动成功," + Robot_CI.GetStatus());
//}
//else
//{
// IsLoadOk = false;
// msg += "CI UR机器人启动失败" + "\n";
//}
CodeManager.LoadConfig();
RemoteService.Init();
mainMachine = new MainMachine(out string m);
if (!string.IsNullOrWhiteSpace(m)) {
if (!string.IsNullOrWhiteSpace(m))
{
IsLoadOk = false;
msg += m;
}
......@@ -111,14 +90,20 @@ namespace DeviceLibrary
if (!IOManager.ConnectionIOList(new List<string>()))
{
IsLoadOk = false;
msg += crc.GetString("Res0181","IO板卡初始化失败")+ "\n";
msg += crc.GetString("Res0181", "IO板卡初始化失败") + "\n";
}
DeviceRunControl.AddDevice("SideMove", SideMove.DeviceList.Values.ToList<IDevice>());
DeviceRunControl.AddDevice("TransplantMove", TransplantMove.DeviceList.Values.ToList<IDevice>());
//DeviceRunControl.AddDevice("TrayStop", TrayStop.DeviceList.Values.ToList<IDevice>());
DeviceRunControl.AddDevice("MI", MI.DeviceList.Values.ToList<IDevice>());
//IsLoadOk = true;
TrayStop.DeviceList.Values.ToList<IDevice>().ForEach(device => { DeviceRunControl.AddDevice(device.GroupName, new List<IDevice>() { device }); });
if (G.simulate)
IsLoadOk = true;
}
catch (Exception ex) {
catch (Exception ex)
{
LogUtil.error(ex.ToString());
MessageBox.Show(ex.ToString());
LoadFinishEvent?.Invoke(false, ex.Message);
......@@ -142,20 +127,12 @@ namespace DeviceLibrary
mainThread.Start();
VStoreCollection.Start();
Thread.Sleep(50);
var d1 = new DeviceRunControl("SideMove", SideMove.DeviceList.Values.ToList<IDevice>());
var d2 = new DeviceRunControl("TransplantMove", TransplantMove.DeviceList.Values.ToList<IDevice>());
var d3 = new DeviceRunControl("TrayStop", TrayStop.DeviceList.Values.ToList<IDevice>());
var d4 = new DeviceRunControl("MI", MI.DeviceList.Values.ToList<IDevice>());
isRunning = true;
GC.KeepAlive(mainThread);
mainMachine.BeginHomeReset(true);
d1.Start();
d2.Start();
d3.Start();
d4.Start();
DeviceRunControl.StartAll();
}
public static void Stop()
......
......@@ -27,12 +27,13 @@ namespace DeviceLibrary
public static bool Process(MoveInfo moveInfo,string rfid, int addr,int reelcheck, out TrayInfo trayInfo) {
lock (Traylist)
{
moveInfo.log($"处理RFID:{rfid},地址{addr},设备:{(AddrDesc.ContainsKey(addr)? AddrDesc[addr]:"")}");
if (!Traylist.ContainsKey(rfid))
{
Traylist.Add(rfid, new TrayInfo());
Traylist[rfid].RFID = rfid;
}
moveInfo.log($"处理RFID:{rfid},地址{addr},设备:{(AddrDesc.ContainsKey(addr) ? AddrDesc[addr] : "")},{(Traylist[rfid].HasLoad? Traylist[rfid].TrayParam?.ToStr():"no metrial")}");
Traylist[rfid].LastUpdateTime = DateTime.Now;
Traylist[rfid].LastAddr = addr;
Traylist[rfid].Destination = TrayManager.AddrDesc[Traylist[rfid].DestinationAddr];
......@@ -56,7 +57,7 @@ namespace DeviceLibrary
{
lock (Traylist)
{
LogUtil.info($"SetTrayLoadInfo:{rfid},{requestLoadInfo?.LoadParam?.ToStr()},{requestLoadInfo?.DeviceGroupName}");
LogUtil.info($"SetTrayLoadInfo:{rfid},{requestLoadInfo?.DeviceGroupName},{requestLoadInfo?.LoadParam?.ToStr()}");
if (!Traylist.ContainsKey(rfid)) {
Traylist.Add(rfid, new TrayInfo());
Traylist[rfid].RFID = rfid;
......@@ -73,7 +74,7 @@ namespace DeviceLibrary
Traylist[rfid].TrayParam = requestLoadInfo.LoadParam.clone();
Traylist[rfid].DestinationAddr = GetAddrByGroupName(requestLoadInfo.DeviceGroupName);
Traylist[rfid].HasLoadCheck = 1;
LogUtil.info("设置托盘信息:" + Traylist[rfid].LoadType + "," + Traylist[rfid].TrayParam.ToStr() + "," + requestLoadInfo.DeviceGroupName);
LogUtil.info("设置托盘信息:"+ rfid+"," + requestLoadInfo.DeviceGroupName + "," + Traylist[rfid].LoadType + "," + Traylist[rfid].TrayParam.ToStr() );
}
SaveTrayInfo();
}
......@@ -275,7 +276,7 @@ namespace DeviceLibrary
public static bool IsNeedProcessNG(RemoteLoad remoteLoad)
{
var requestLoadInfo = remoteLoad.RequestLoadInfo;
var xx = TrayManager.Traylist.Values.ToList().Where(t => t.HasLoad && t.LoadType == requestLoadInfo.GetTrayType && (t.LastAddr >= 20 || t.LastAddr < 2));
var xx = TrayManager.Traylist.Values.ToList().Where(t => t.HasLoad && t.LoadType == requestLoadInfo.GetTrayType && (t.LastAddr >= 20 || t.LastAddr <= 3));
return xx.Count() > 0;
}
......@@ -350,7 +351,7 @@ namespace DeviceLibrary
public DirectionE Direction { get => (Destination ==StoreCID.AMH_ML5_1 || Destination == StoreCID.AMH_ML5_2) ? DirectionE.Out : DirectionE.In; }
public bool isOnline = true;
public void SetToEmpty() {
LogUtil.info("清空托盘信息,原信息:"+ Direction + "," + TrayParam?.ToStr()+ "," + LoadType+ "," + LoadType + ",");
LogUtil.info("清空托盘信息,原信息:" + RFID + "," + Direction + "," + TrayParam?.ToStr()+ "," + LoadType+ "," + LoadType + ",");
LoadType = TrayTypeE.None;
DestinationAddr = -1;
TrayParam = new ReelParam();
......
......@@ -88,8 +88,9 @@ namespace DeviceLibrary
{
try
{
LogUtil.OutputDebugString($"{GroupName} DeviceState:" + DeviceState.ToString());
MsgService.MSList[GroupName + "-T"].clear();
LogUtil.OutputDebugString("DeviceState:" + DeviceState.ToString());
if (!DeviceCheck())
{
......@@ -118,11 +119,11 @@ namespace DeviceLibrary
private bool DeviceCheck()
{
if (!Robot.ClientIsConnected)
{
Msg.add(POS_Start + crc.GetString("Res0011", "机器人未连接MT,无法操作."), MsgLevel.alarm);
return false;
}
//if (!Robot.ClientIsConnected)
//{
// Msg.add(POS_Start + crc.GetString("Res0011", "机器人未连接MT,无法操作."), MsgLevel.alarm);
// return false;
//}
if (!robotHelper.RobotStatus) {
Msg.add(POS_Start + crc.GetString("Res0058","机器人当前不可用"), MsgLevel.alarm);
return false;
......@@ -179,9 +180,9 @@ namespace DeviceLibrary
MoveInfo.log("机器人开始取料");
break;
case MoveStep.MI_02:
if (RoboMoveInfo.MoveStep == MoveStep.MI_ReelTacked)
if (RoboMoveInfo.MoveStep >= MoveStep.MI_08)
{
MoveInfo.NextMoveStep(MoveStep.MI_04);
MoveInfo.NextMoveStep(MoveStep.MI_03);
if (FromPos.PositionNum.EndsWith("MT"))
{
RemoteLoad remoteLoad = new RemoteLoad();
......@@ -201,6 +202,12 @@ namespace DeviceLibrary
}
break;
case MoveStep.MI_03:
if (RoboMoveInfo.MoveStep == MoveStep.MI_ReelTacked)
{
MoveInfo.NextMoveStep(MoveStep.MI_04);
}
break;
case MoveStep.MI_04:
if (CurrentVStore.RTStoreStatus == RTStoreStatus.Ready || CurrentVStore.RTStoreStatus == RTStoreStatus.LockToInStore)
{
......@@ -321,6 +328,7 @@ namespace DeviceLibrary
&& IOValue(IO_Type.MI_Robot_Clamp_Check).Equals(IO_VALUE.LOW))
{
MoveInfo.log("机器人抓取NG料后发现夹爪上没有料,流程结束处理");
TrayStop.DeviceList[GroupName].TrayRelease();
RoboMoveInfo.NextMoveStep(MoveStep.Wait);
MoveInfo.NextMoveStep(MoveStep.Wait);
}
......
......@@ -94,7 +94,7 @@ namespace DeviceLibrary
switch (MoveInfo.MoveStep)
{
case MoveStep.Wait:
if (RobotManage.mainMachine.IOValue(IO_Type.ML5_DoorSafeCheck).Equals(IO_VALUE.LOW))
if ((GroupName == "AMH-ML5-1" || GroupName == "AMH-ML5-2") && RobotManage.mainMachine.IOValue(IO_Type.ML5_DoorSafeCheck).Equals(IO_VALUE.LOW))
{
Msg.add(crc.GetString("Res0041","ML5料口门光栅被遮挡"), MsgLevel.warning);
return;
......@@ -239,11 +239,16 @@ namespace DeviceLibrary
remoteLoad.RequestLoadInfo.IsEmpty = false;
MoveInfo.remoteLoad = remoteLoad;
var result = RemoteService.SendAndWait(GroupName, remoteLoad);
if (result != RemoteResult.True)
if (result == RemoteResult.False)
{
MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
MoveInfo.log($"{GroupName} 请求出库失败:{result}");
}
else if (result == RemoteResult.Timeout)
{
MoveInfo.NextMoveStep(MoveStep.TrayStop_03);
MoveInfo.log($"{GroupName} 请求出库失败:{result}");
}
else
{
SRec.info(crc.GetString("Res0042","托盘挡停"), GroupName, crc.GetString("Res0025","载物托盘"), crc.GetString("Res0044","等待物料被接走"), CurrrentRFID, remoteLoad.RequestLoadInfo.LoadParam.WareCode);
......@@ -251,40 +256,6 @@ namespace DeviceLibrary
}
return;
}
/*
else if ((trayInfo.DestinationAddr == DeviceGroup.addr_1 || trayInfo.DestinationAddr == -1) &&
((GroupName == "AMH-ML5-1" && CurrrentRFID.StartsWith("MTP2")) ||
(GroupName == "AMH-ML5-2" && CurrrentRFID.StartsWith("MTP1")))
&& IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.HIGH))
{
MoveInfo.log($"{GroupName} NG出库流程");
//NG物料
MoveInfo.NextMoveStep(MoveStep.TrayStop_07);
RemoteLoad remoteLoad = new RemoteLoad();
remoteLoad.Seq = DateTime.Now.Ticks;
remoteLoad.Action = "TrayReady";
remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.TrayType = trayInfo.TrayType.ToString();
remoteLoad.RequestLoadInfo.LoadParam = new ReelParam();
remoteLoad.RequestLoadInfo.LoadParam.PlateW = 794;
remoteLoad.RequestLoadInfo.LoadParam.PlateH = 120;
remoteLoad.RequestLoadInfo.LoadParam.IsNg = true;
remoteLoad.RequestLoadInfo.LoadParam.NgMsg = "[MT]"+ crc.GetString("Res0045","无信息物料");
remoteLoad.RequestLoadInfo.IsEmpty = false;
MoveInfo.remoteLoad = remoteLoad;
var result = RemoteService.SendAndWait(GroupName, remoteLoad);
if (result != RemoteResult.True)
{
MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
MoveInfo.log($"{GroupName} 请求NG出库失败:{result}");
}
else
{
MoveInfo.log($"{GroupName} 请求NG出库成功");
}
return;
}*/
else
MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
}
......@@ -309,9 +280,9 @@ namespace DeviceLibrary
Location.ToLow(MoveInfo);
break;
case MoveStep.TrayStop_05:
if (RobotManage.mainMachine.IOValue(IO_Type.ML5_DoorSafeCheck).Equals(IO_VALUE.LOW))
if ((GroupName == "AMH-ML5-1" || GroupName == "AMH-ML5-2") && RobotManage.mainMachine.IOValue(IO_Type.ML5_DoorSafeCheck).Equals(IO_VALUE.LOW))
{
Msg.add(crc.GetString("Res0041","ML5料口门光栅被遮挡"), MsgLevel.warning);
Msg.add(crc.GetString("Res0041", "ML5料口门光栅被遮挡"), MsgLevel.warning);
return;
}
MoveInfo.NextMoveStep(MoveStep.TrayStop_06);
......@@ -334,8 +305,11 @@ namespace DeviceLibrary
break;
case MoveStep.TrayStop_07:
MoveInfo.NextMoveStep(MoveStep.TrayStop_WaitLoadProcess);
Location.ToHigh(MoveInfo);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
if (GroupName != "AMH-MI1" && GroupName != "AMH-MI2" && GroupName != "CI")
{
Location.ToHigh(MoveInfo);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
break;
case MoveStep.TrayStop_WaitLoadProcess:
Msg.add(crc.GetString("Res0046","等待处理物料"),MsgLevel.info);
......@@ -406,7 +380,7 @@ namespace DeviceLibrary
}
else if (RobotManage.mainMachine.IOValue(IO_Type.ML5_DoorSafeCheck).Equals(IO_VALUE.LOW))
{
Msg.add(crc.GetString("Res0041","ML5料口门光栅被遮挡"), MsgLevel.warning);
Msg.add(crc.GetString("Res0041", "ML5料口门光栅被遮挡"), MsgLevel.warning);
return false;
}
else
......
......@@ -76,10 +76,10 @@
this.btnAxisStop = new System.Windows.Forms.Button();
this.btnAxisReturnHome = new System.Windows.Forms.Button();
this.cmbAxis = new System.Windows.Forms.ComboBox();
this.btnDelMove = new System.Windows.Forms.Button();
this.btnDelMove = new ToucDownBtn();
this.btnOpenAxis = new System.Windows.Forms.Button();
this.btnCloseAxis = new System.Windows.Forms.Button();
this.btnAddMove = new System.Windows.Forms.Button();
this.btnAddMove = new ToucDownBtn();
this.txtASpeed = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label47 = new System.Windows.Forms.Label();
......@@ -952,8 +952,8 @@
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txtServoStatue;
private System.Windows.Forms.Button btnDelMove;
private System.Windows.Forms.Button btnAddMove;
private ToucDownBtn btnDelMove;
private ToucDownBtn btnAddMove;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.ComboBox comjSpeed;
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
class ToucDownBtn : System.Windows.Forms.Button
{
public const int WM_POINTERDOWN = 0x246;
public const int WM_POINTERUP = 0x247;
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_POINTERDOWN:
{
MouseEventArgs args = new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0);
OnMouseDown(args);
//Console.WriteLine("WM_POINTERDOWN");
break;
}
case WM_POINTERUP:
{
MouseEventArgs args = new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0);
OnMouseUp(args);
//Console.WriteLine("WM_POINTERUP");
break;
}
}
base.WndProc(ref m);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore
{
public class G
{
public static bool simulate = false;
}
}
......@@ -52,6 +52,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CSVExection.cs" />
<Compile Include="G.cs" />
<Compile Include="position\RobotPosition.cs" />
<Compile Include="position\DeviceGroup.cs" />
<Compile Include="position\ACSAStorePosition.cs" />
......
......@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
......@@ -212,7 +213,8 @@ public class ReelParam
/// NG口位置,1=左侧,2=右侧
/// </summary>
/// <param name="NgPos"></param>
public void logresult(int NgPos = 0)
/// <param name="isInstore"></param>
public void logresult(int NgPos = 0,bool isInstore=true)
{
if (!islog)
{
......@@ -244,11 +246,32 @@ public class ReelParam
ngMsgData.ngPos = NgPos;
ngMsgData.ngMsg = NgMsg;
ngMsgData.barcode = WareCode;
ngMsgData.type = "1";
ngMsgData.mType = "";
ngMsgData.type = isInstore?"1":"0";
ngMsgData.posName = getposname(PosID);
TheLine.uploadNgReel(ngMsgData);
});
}
string getposname(string posid) {
switch(posid)
{
case "NG_7_1":
return "R-SLOT1";
case "NG_13_1":
return "R-SLOT2";
case "NG_13_2":
return "R-SLOT3";
case "DoorL4":
return "L-SLOT1";
case "NG_BOX_1NG":
return "L-SLOT2";
case "NG_BOX_2NG":
return "L-SLOT3";
case "NG_BOX_3NG":
return "L-SLOT4";
default:
return posid;
}
}
}
}
public enum DoorStatusE {
......
......@@ -2,6 +2,7 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
......@@ -18,7 +19,7 @@ public class RemoteClient
{
GroupName = groupName;
Serveraddr = serveraddr;
timer = new System.Timers.Timer(2000);
timer = new System.Timers.Timer(1000*10);
timer.Enabled = false;
timer.AutoReset = true;
timer.Elapsed += Timer_Elapsed;
......@@ -55,25 +56,38 @@ public class RemoteClient
int errstatuscounr = 0;
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
{
Debug.WriteLine("WebSocketState:"+ webSocket.State);
if (webSocket.State == WebSocket4Net.WebSocketState.Closed)
{
try
{
LOGGER.Info($"Remote:{GroupName} 重新连接");
webSocket.Open();
timeoutCount = 0;
errstatuscounr = 0;
}
catch { }
}
else if (webSocket.State == WebSocket4Net.WebSocketState.Connecting) {
else if (webSocket.State == WebSocket4Net.WebSocketState.Connecting)
{
errstatuscounr++;
if (errstatuscounr > 5) {
if (errstatuscounr > 5)
{
LOGGER.Error($"Remote:{GroupName} Connecting 超时");
try { webSocket.Close(); } catch { }
webSocket.Open();
errstatuscounr = 0;
}
}
else if (webSocket.State == WebSocket4Net.WebSocketState.Open)
{
RemoteLoad remoteLoad = new RemoteLoad();
remoteLoad.Seq = DateTime.Now.Ticks;
remoteLoad.Action = "Heartbeats";
remoteLoad.GroupName = GroupName;
SendAndWait(remoteLoad);
//webSocket.Send(JsonConvert.SerializeObject(remoteLoad));
}
}
volatile RemoteResult lastresult = RemoteResult.None;
private void WebSocket_MessageReceived(object sender, WebSocket4Net.MessageReceivedEventArgs e)
......@@ -95,7 +109,7 @@ public class RemoteClient
case "OK":
case "FAIL":
lastresult = remoteLoad.Action == "OK" ? RemoteResult.True : RemoteResult.False;
LOGGER.Info("Revice Command Callback:" + remoteLoad.GroupName + " -" + remoteLoad.Action + " ,Seq:" + remoteLoad.Seq);
LOGGER.Info("Revice Command Callback:" + remoteLoad.GroupName + " - " + remoteLoad.Action + " ,Seq:" + remoteLoad.Seq);
return;
default:
if (actionlist.ContainsKey(remoteLoad.Action)) {
......@@ -128,24 +142,37 @@ public class RemoteClient
timeoutCount++;
lastresult = RemoteResult.Timeout;
if (timeoutCount > 3)
{
LOGGER.Error("强制断开连接");
webSocket.Close();
timeoutCount = 0;
}
}
else {
timeoutCount = 0;
}
return lastresult;
}
/// <summary>
/// 发送并等待结果
/// </summary>
/// <param name="remoteLoad"></param>
/// <param name="waittime"></param>
/// <returns></returns>
public RemoteResult SendAndWait(RemoteLoad remoteLoad, int waittime= 3000) {
remoteLoad.Seq = DateTime.Now.Ticks;
remoteLoad.GroupName = GroupName;
if (remoteLoad.RequestLoadInfo != null)
{
if (string.IsNullOrEmpty(remoteLoad.RequestLoadInfo.DeviceGroupName))
remoteLoad.RequestLoadInfo.DeviceGroupName = GroupName;
lock (webSocket) {
remoteLoad.Seq = DateTime.Now.Ticks;
remoteLoad.GroupName = GroupName;
if (remoteLoad.RequestLoadInfo != null)
{
if (string.IsNullOrEmpty(remoteLoad.RequestLoadInfo.DeviceGroupName))
remoteLoad.RequestLoadInfo.DeviceGroupName = GroupName;
}
lastresult = RemoteResult.None;
LOGGER.Info($"Send remote command: {GroupName} - " + remoteLoad.Action + $", seq:{remoteLoad.Seq}");
webSocket.Send(JsonConvert.SerializeObject(remoteLoad));
return WaitResult(waittime);
}
lastresult = RemoteResult.None;
webSocket.Send(JsonConvert.SerializeObject(remoteLoad));
return WaitResult(waittime);
}
void SendResult(bool result,long Seq)
{
......
......@@ -116,11 +116,54 @@ namespace RemoteSheardObject
{
var postData = new Dictionary<string, string>()
{
{"ngMsgData",ngPos.ToString() }
{"ngPos",ngPos.ToString() }
};
string url = CombineUrl(Config.Get("Device_Server_Address"), "/rest/micron/device/clearNgPos");
string url = "/rest/micron/device/clearNgPos";
var resultStr = SubmitPostData(url, postData);
}
/// <summary>
/// 上传自定义数据
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public static void UploadCustData(string key,string value)
{
var postData = new Dictionary<string, string>()
{
{"key",key },
{"value",value }
};
string url = "/rest/micron/device/updateData";
var resultStr = SubmitPostData(url, postData);
}
/// <summary>
/// 上传自定义数据
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public static string GetCustData(string key)
{
var postData = new Dictionary<string, string>()
{
{"key",key}
};
string url = "/rest/micron/device/getData";
var resultStr = SubmitPostData(url, postData);
var r= JsonConvert.DeserializeObject<ResultData2>(resultStr);
if (!string.IsNullOrWhiteSpace(r.data)) {
return r.data;
}
return null;
}
public class ResultData2
{
//{"code":0,"msg":"ok","data":"7"}
public int code { get; set; }
public string msg { get; set; }
public string data { get; set; }
}
public class ResultData
{
//{"code":0,"msg":"ok","data":"7"}
......
......@@ -21,8 +21,11 @@ namespace TheMachine
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
static void Main(string[] args)
{
if (args.ToList().FindIndex(a=>a.Contains("simulate"))>=0)
OnlineStore.G.simulate = true;
_ = new Mutex(true, Application.ProductName, out bool ret);
if (!ret)
......@@ -33,6 +36,13 @@ namespace TheMachine
//MessageBox.Show("该程序已经启动", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
var process = Process.GetCurrentProcess();
Process[] processes = Process.GetProcessesByName(process.ProcessName);
foreach (Process p in processes)
{
if (p.Id!=process.Id)
p.Kill();
}
var currnetdrive = System.IO.Path.GetPathRoot(Application.StartupPath);
var drives = System.IO.DriveInfo.GetDrives();
foreach (var drive in drives) {
......
......@@ -20,7 +20,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!