Commit 40e19609 刘韬

稳定版

1 个父辈 1587d8a9
...@@ -36,6 +36,12 @@ namespace OnlineStore.Common ...@@ -36,6 +36,12 @@ namespace OnlineStore.Common
[MyConfigComment("屏蔽日志窗口")] [MyConfigComment("屏蔽日志窗口")]
public static MyConfig<bool> Device_DisableLogWindow = true; public static MyConfig<bool> Device_DisableLogWindow = true;
[MyConfigComment("出库任务数量大于值时治具托盘全部从LS3转移走")]
public static MyConfig<int> Device_LS3_MTP2_OutTaskMaxCount = 5;
[MyConfigComment("出库任务数量大于值时料盘托盘全部从LS3转移走")]
public static MyConfig<int> Device_LS3_MTP1_OutTaskMaxCount = 5;
[MyConfigComment("URRobot_MI1_IP")] [MyConfigComment("URRobot_MI1_IP")]
public static MyConfig<string> URRobot_MI1_IP; public static MyConfig<string> URRobot_MI1_IP;
[MyConfigComment("URRobot_MI1_速度倍率")] [MyConfigComment("URRobot_MI1_速度倍率")]
......
...@@ -139,18 +139,16 @@ namespace OnlineStore.Common ...@@ -139,18 +139,16 @@ namespace OnlineStore.Common
return result; return result;
} }
static object lockpost = new object(); static object lockpost = new object();
public static Operation Post(string url, Operation operation, int timeout = 5000, bool printlog = false) public static Operation Post(string url, Operation operation, int timeout, out string log)
{ {
log = "";
try try
{ {
string json = JsonHelper.SerializeObject(operation); string json = JsonHelper.SerializeObject(operation);
string result = Post(url, json, timeout); string result = Post(url, json, timeout);
Operation op = JsonHelper.DeserializeJsonToObject<Operation>(result); Operation op = JsonHelper.DeserializeJsonToObject<Operation>(result);
if (printlog) log = "Send [" + json + "] Revice [" + result + "]";
{
LogUtil.info("Send [" + json + "] Revice [" + result + "]");
}
return op; return op;
} }
catch (Exception ex) catch (Exception ex)
......
...@@ -156,6 +156,7 @@ ...@@ -156,6 +156,7 @@
<Compile Include="userControl\FixtureSizeConfigControl.Designer.cs"> <Compile Include="userControl\FixtureSizeConfigControl.Designer.cs">
<DependentUpon>FixtureSizeConfigControl.cs</DependentUpon> <DependentUpon>FixtureSizeConfigControl.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="VirtuallyStore\BufferSlotsManger.cs" />
<Compile Include="VirtuallyStore\CommandList.cs" /> <Compile Include="VirtuallyStore\CommandList.cs" />
<Compile Include="VirtuallyStore\Reference.cs" /> <Compile Include="VirtuallyStore\Reference.cs" />
<Compile Include="VirtuallyStore\VMsg.cs" /> <Compile Include="VirtuallyStore\VMsg.cs" />
......
...@@ -43,7 +43,7 @@ namespace DeviceLibrary ...@@ -43,7 +43,7 @@ namespace DeviceLibrary
if (canStopLine(out _) && isIOon)//(DOValue(LineIO).Equals(IO_VALUE.HIGH) || DOValue(LineRevIO).Equals(IO_VALUE.HIGH))) if (canStopLine(out _) && isIOon)//(DOValue(LineIO).Equals(IO_VALUE.HIGH) || DOValue(LineRevIO).Equals(IO_VALUE.HIGH)))
{ {
IOSTOP(); IOSTOP();
LogUtil.info(Name + $" 线体管理器 停止线体."); LogUtil.info("["+ Name+"]" + $" 线体管理器 停止线体.");
} }
} }
} }
......
using OnlineStore.Common; using OnlineStore;
using OnlineStore.Common;
using Robot.UR; using Robot.UR;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -48,12 +49,14 @@ namespace DeviceLibrary ...@@ -48,12 +49,14 @@ namespace DeviceLibrary
{ {
RobotStatus = false; RobotStatus = false;
//Msg.add(POS_Start + "机器人状态异常:" + Robot.CurDashboardReponse, MsgLevel.alarm); //Msg.add(POS_Start + "机器人状态异常:" + Robot.CurDashboardReponse, MsgLevel.alarm);
robot.PlayProgram(); robot.StopProgram();
} }
else if (!robot.ClientIsConnected) { else if (!robot.ClientIsConnected) {
RobotStatus = false; RobotStatus = false;
robot.StopProgram(); robot.StopProgram();
Thread.Sleep(300);
robot.StopRobot();
} }
else else
RobotStatus = true; RobotStatus = true;
...@@ -61,7 +64,7 @@ namespace DeviceLibrary ...@@ -61,7 +64,7 @@ namespace DeviceLibrary
public void Move(MoveInfo moveInfo, int movecmd) { public void Move(MoveInfo moveInfo, int movecmd) {
if (moveInfo != null) if (moveInfo != null)
{ {
moveInfo.WaitList.Add(WaitResultInfo.WaitAction(new Func<WaitResultInfo, bool>(IsMoveOk), "等待" + $"[{robot.Name}]" + "移动到位")); moveInfo.WaitList.Add(WaitResultInfo.WaitAction(new Func<WaitResultInfo, bool>(IsMoveOk), crc.GetString("Res0157","等待") + $"[{robot.Name}]" + crc.GetString("Res0057","移动到位")));
} }
lastMoveCmd = movecmd; lastMoveCmd = movecmd;
robot.SendMoveCmd(movecmd, Setting_Init.URRobot_MI1_Speed_Rate); robot.SendMoveCmd(movecmd, Setting_Init.URRobot_MI1_Speed_Rate);
...@@ -91,4 +94,4 @@ namespace DeviceLibrary ...@@ -91,4 +94,4 @@ namespace DeviceLibrary
RobotCheck.Enabled = false; RobotCheck.Enabled = false;
} }
} }
} }
\ No newline at end of file \ No newline at end of file
using OnlineStore; using OnlineStore;
using OnlineStore.Common; using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary; using OnlineStore.LoadCSVLibrary;
using RemoteSheardObject;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -12,7 +13,7 @@ using System.Threading.Tasks; ...@@ -12,7 +13,7 @@ using System.Threading.Tasks;
namespace DeviceLibrary namespace DeviceLibrary
{ {
class ServerCommunication public class ServerCommunication
{ {
volatile StoreStatus _storeStatus = StoreStatus.Debugging; volatile StoreStatus _storeStatus = StoreStatus.Debugging;
public StoreStatus storeStatus { public StoreStatus storeStatus {
...@@ -41,10 +42,18 @@ namespace DeviceLibrary ...@@ -41,10 +42,18 @@ namespace DeviceLibrary
GC.KeepAlive(serverConnectTimer); GC.KeepAlive(serverConnectTimer);
LogUtil.info($"server:{server},cid:{CID}"); LogUtil.info($"server:{server},cid:{CID}");
} }
public int OutMaterialTaskCount = 0;
public int OutReelTaskCount = 0;
private void ServerConnectTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) private void ServerConnectTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{ {
try try
{ {
if (!string.IsNullOrEmpty(server) && server.ToLower().StartsWith("http"))
{
var data = TheLine.GetTaskCount();
OutMaterialTaskCount = data["pizzaBox"] + data["pcb"] + data["tray"];
OutReelTaskCount = data["reel"];
}
//if (!RobotManage.isRunning) //if (!RobotManage.isRunning)
// ProcessMsg(MsgService.MSList); // ProcessMsg(MsgService.MSList);
//if (!string.IsNullOrWhiteSpace(server)) //if (!string.IsNullOrWhiteSpace(server))
...@@ -54,7 +63,8 @@ namespace DeviceLibrary ...@@ -54,7 +63,8 @@ namespace DeviceLibrary
{ {
LogUtil.info($"ServerConnectTimer_Elapsed:{ex}"); LogUtil.info($"ServerConnectTimer_Elapsed:{ex}");
} }
finally { finally
{
//Monitor.Exit(serverConnectTimer); //Monitor.Exit(serverConnectTimer);
} }
} }
...@@ -75,7 +85,7 @@ namespace DeviceLibrary ...@@ -75,7 +85,7 @@ namespace DeviceLibrary
} }
).Where(x=>!string.IsNullOrEmpty(x))); ).Where(x=>!string.IsNullOrEmpty(x)));
} }
public void SendInStoreRequest(string[] codelist, ReelParam reel,bool printlog=false) { public void SendInStoreRequest(string[] codelist, ReelParam reel) {
if (RobotManage.InoutDebugMode) if (RobotManage.InoutDebugMode)
return; return;
...@@ -86,11 +96,12 @@ namespace DeviceLibrary ...@@ -86,11 +96,12 @@ namespace DeviceLibrary
operation.op = 1; operation.op = 1;
operation.data = new Dictionary<string, string>() { { "code", code }, { "boxId", StoreID.ToString() }, { "doorReelSignal", "1" } }; operation.data = new Dictionary<string, string>() { { "code", code }, { "boxId", StoreID.ToString() }, { "doorReelSignal", "1" } };
Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, 15000, printlog); Operation resultOperation = OnlineStore.Common.HttpHelper.Post(GetPostApi(), operation, 15000, out string log);
if (resultOperation==null || operation.seq != resultOperation.seq) if (resultOperation==null || operation.seq != resultOperation.seq)
{ {
LogUtil.error(log);
Thread.Sleep(1000); Thread.Sleep(1000);
SendInStoreRequest(codelist, reel, printlog); SendInStoreRequest(codelist, reel);
return; return;
} }
ResultProcess(resultOperation); ResultProcess(resultOperation);
...@@ -109,7 +120,7 @@ namespace DeviceLibrary ...@@ -109,7 +120,7 @@ namespace DeviceLibrary
LogUtil.info(JsonHelper.SerializeObject(operation)); LogUtil.info(JsonHelper.SerializeObject(operation));
if (RobotManage.InoutDebugMode) if (RobotManage.InoutDebugMode)
return true; return true;
Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, 15000); Operation resultOperation = OnlineStore.Common.HttpHelper.Post(GetPostApi(), operation, 15000,out _);
if (resultOperation == null) if (resultOperation == null)
{ {
...@@ -253,7 +264,7 @@ namespace DeviceLibrary ...@@ -253,7 +264,7 @@ namespace DeviceLibrary
printlog = true; printlog = true;
} }
Operation resultOperation = HttpHelper.Post(GetPostApi(), lineOperation,700, printlog); Operation resultOperation = OnlineStore.Common.HttpHelper.Post(GetPostApi(), lineOperation,700, out string log);
if (resultOperation != null) if (resultOperation != null)
getthtime = 0; getthtime = 0;
//LogUtil.info(JsonHelper.SerializeObject(resultOperation.data)); //LogUtil.info(JsonHelper.SerializeObject(resultOperation.data));
......
using Newtonsoft.Json;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
class BufferSlotsManger
{
Dictionary<string, BufferSlotInfo> bufferSlotInfos = new Dictionary<string, BufferSlotInfo>();
string DeviceName;
public BufferSlotsManger(string devicename)
{
DeviceName = devicename;
LoadData();
for (int i = 0; i < 8; i++)
{
string sloatkey = DeviceName + "_B0" + (i + 1);
if (!bufferSlotInfos.ContainsKey(sloatkey))
{
bufferSlotInfos.Add(sloatkey, new BufferSlotInfo(sloatkey));
}
}
}
public string GetFreeSlot()
{
lock (bufferSlotInfos)
{
var slot = bufferSlotInfos.Values.ToList().Find(s => !s.HasReel);
return slot?.Name;
}
}
public string GetInstoreSlot(out JobInfo jobInfo)
{
lock (bufferSlotInfos)
{
var slot = bufferSlotInfos.Values.ToList().Find(s => s.HasReel && s.IsInstore);
jobInfo = slot?.JobInfo.Clone();
return slot?.Name;
}
}
public string GetOutstoreSlot(out JobInfo jobInfo)
{
lock (bufferSlotInfos)
{
var slot = bufferSlotInfos.Values.ToList().Find(s => s.HasReel && !s.IsInstore);
jobInfo = slot?.JobInfo.Clone();
return slot?.Name;
}
}
public void SetSlotInfo(string name, bool isinstore, JobInfo jobInfo)
{
lock (bufferSlotInfos)
{
bufferSlotInfos[name].IsInstore = isinstore;
bufferSlotInfos[name].JobInfo = jobInfo.Clone();
bufferSlotInfos[name].HasReel = true;
}
SaveData();
}
public void ClearSlot(string name)
{
lock (bufferSlotInfos)
{
bufferSlotInfos[name].HasReel = false;
}
SaveData();
}
void LoadData() {
string filename = $"Config\\BufferSlotsList_{DeviceName}.temp";
if (File.Exists(filename))
{
bool isreadok = false;
try
{
var tl = File.ReadAllText(filename);
bufferSlotInfos = JsonConvert.DeserializeObject<Dictionary<string, BufferSlotInfo>>(tl);
isreadok = bufferSlotInfos != null;
if (!isreadok)
LogUtil.error("启动时缓存料盘信息加载失败:"+DeviceName);
}
catch (Exception ex)
{
LogUtil.error("启动时缓存料盘信息加载失败:" + DeviceName + ex);
}
if (isreadok)
return;
try
{
var tl = File.ReadAllText(filename+"~");
bufferSlotInfos = JsonConvert.DeserializeObject<Dictionary<string, BufferSlotInfo>>(tl);
if (bufferSlotInfos == null)
{
LogUtil.error("启动时备份缓存料盘加载失败:"+DeviceName);
bufferSlotInfos = new Dictionary<string, BufferSlotInfo>();
}
}
catch (Exception ex)
{
LogUtil.error("启动时托盘备份信息加载失败:" + ex);
bufferSlotInfos = new Dictionary<string, BufferSlotInfo>();
}
}
}
void SaveData() {
string filename = $"Config\\BufferSlotsList_{DeviceName}.temp";
try
{
var TL = bufferSlotInfos.Where(t => t.Value.HasReel).ToDictionary(a => a.Key, a => a.Value);
ConfigHelper.Config.FileSave(JsonConvert.SerializeObject(TL), filename+"~");
ConfigHelper.Config.FileSave(JsonConvert.SerializeObject(TL), filename);
}
catch (Exception ex)
{
LogUtil.error("托盘信息保存失败:" + ex);
}
}
}
class BufferSlotInfo {
public string Name;
public bool HasReel;
public bool IsInstore;
public JobInfo JobInfo;
public BufferSlotInfo(string name) {
Name = name;
}
}
}
...@@ -15,14 +15,20 @@ namespace DeviceLibrary ...@@ -15,14 +15,20 @@ namespace DeviceLibrary
Prefix = prefix; Prefix = prefix;
log = LogManager.GetLogger(logname); log = LogManager.GetLogger(logname);
} }
string lastinfo = "";
public void Info(string txt) { public void Info(string txt) {
if (String.Compare(lastinfo, txt, StringComparison.Ordinal) == 0)
return;
if (Prefix != "") if (Prefix != "")
txt =$"[{Prefix}] "+ txt; txt =$"[{Prefix}] "+ txt;
log.Info(txt); log.Info(txt);
} }
string lasterr = "";
public void Error(string txt) public void Error(string txt)
{ {
if (String.Compare(lasterr, txt, StringComparison.Ordinal) == 0)
return;
if (Prefix != "") if (Prefix != "")
txt = $"[{Prefix}] " + txt; txt = $"[{Prefix}] " + txt;
log.Error(txt); log.Error(txt);
......
...@@ -114,20 +114,20 @@ namespace DeviceLibrary ...@@ -114,20 +114,20 @@ namespace DeviceLibrary
LogUtil.info(JsonHelper.SerializeObject(operation)); LogUtil.info(JsonHelper.SerializeObject(operation));
if (RobotManage.InoutDebugMode) if (RobotManage.InoutDebugMode)
return true; return true;
Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, 5000); Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, 5000,out string log);
if (resultOperation == null) if (resultOperation == null)
{ {
LogUtil.info($"SendStoreState error,posid:{barcode}, storeStatus:{storeStatus}"); VLog.Error($"SendStoreState error,posid:{barcode}, storeStatus:{storeStatus}");
return false; return false;
} }
if (operation.seq != resultOperation.seq) if (operation.seq != resultOperation.seq)
{ {
LogUtil.info($"SendStoreState seq error,posid:{barcode}, storeStatus:{storeStatus}"); VLog.Error($"SendStoreState seq error,posid:{barcode}, storeStatus:{storeStatus}");
return false; return false;
} }
VLog.Info(log);
LogUtil.info($"SendStoreState success,posid:{barcode}, storeStatus:{storeStatus}"); VLog.Info($"SendStoreState success,posid:{barcode}, storeStatus:{storeStatus}");
ResultProcess(resultOperation); ResultProcess(resultOperation);
} }
return true; return true;
...@@ -238,7 +238,7 @@ namespace DeviceLibrary ...@@ -238,7 +238,7 @@ namespace DeviceLibrary
printlog = true; printlog = true;
} }
Operation resultOperation = HttpHelper.Post(GetPostApi(), lineOperation,700, printlog); Operation resultOperation = HttpHelper.Post(GetPostApi(), lineOperation,700, out string log);
if (resultOperation != null) if (resultOperation != null)
getthtime = 0; getthtime = 0;
//LogUtil.info(JsonHelper.SerializeObject(resultOperation.data)); //LogUtil.info(JsonHelper.SerializeObject(resultOperation.data));
...@@ -407,7 +407,7 @@ namespace DeviceLibrary ...@@ -407,7 +407,7 @@ namespace DeviceLibrary
else else
{ {
JobInfo jobInfo = new JobInfo(code, posIdStr, plateW, plateH); JobInfo jobInfo = new JobInfo(code, posIdStr, plateW, plateH);
OutStoreEvent?.Invoke("服务器", jobInfo); OutStoreEvent?.Invoke(crc.GetString("Res0064","服务器"), jobInfo);
} }
TimeSpan span = DateTime.Now - time; TimeSpan span = DateTime.Now - time;
......
...@@ -47,156 +47,218 @@ namespace DeviceLibrary ...@@ -47,156 +47,218 @@ namespace DeviceLibrary
//MI.DeviceList[TowerList.List[CurrentOutJobInfo.CID].DeviceGroupName].EnqueueOutStore(CurrentOutJobInfo); //MI.DeviceList[TowerList.List[CurrentOutJobInfo.CID].DeviceGroupName].EnqueueOutStore(CurrentOutJobInfo);
} }
public string CurrentTowerStatusText="";
public RTStoreStatus RTStoreStatus = RTStoreStatus.Offline; public RTStoreStatus RTStoreStatus = RTStoreStatus.Offline;
public volatile bool TerminalError = false;
DateTime LastStatusTime = DateTime.Now; DateTime LastStatusTime = DateTime.Now;
int LastStatusCode = 0;
internal void VTowerProcess() { internal void VTowerProcess() {
var ti = ServerCM.GetTowerDetailInformation(CID); try
if (ti != null)
{ {
ServerCM.Temperature = ti.Temperature; var ti = ServerCM.GetTowerDetailInformation(CID);
ServerCM.Humidity = ti.Humidity; if (ti != null)
if (ti.StatusCode == 26)
{ {
ServerCM.storeStatus = StoreStatus.StoreOnline; if (LastStatusCode != ti.StatusCode)
if (RTStoreStatus != RTStoreStatus.LockToInStore)
{ {
if (RTStoreStatus != RTStoreStatus.Ready) LastStatusCode = ti.StatusCode;
VLog.Info("料仓已空闲"); VLog.Info($"RTStoreStatus:{RTStoreStatus},StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}");
RTStoreStatus = RTStoreStatus.Ready; }
if (OutStoreJobList.Count > 0) CurrentTowerStatusText = $"[TI={ti.StatusCode}-{ti.StatusText}]";
ServerCM.Temperature = ti.Temperature;
ServerCM.Humidity = ti.Humidity;
if (ti.StatusCode == 26)
{
ServerCM.storeStatus = StoreStatus.StoreOnline;
if (RTStoreStatus != RTStoreStatus.LockToInStore && RTStoreStatus != RTStoreStatus.InStoreReady)
{ {
if (OutStoreJobList.Dequeue(out JobInfo jobInfo)) if (RTStoreStatus != RTStoreStatus.Ready)
VLog.Info("料仓已空闲");
RTStoreStatus = RTStoreStatus.Ready;
TerminalError = false;
LastStatusTime = DateTime.Now;
if (OutStoreJobList.Count > 0)
{ {
RTStoreStatus = RTStoreStatus.LockToInStore; if (OutStoreJobList.Dequeue(out JobInfo jobInfo))
if (!ServerCM.BeginOutStore(jobInfo.Clone(), VLog)) { {
RTStoreStatus = RTStoreStatus.Ready; RTStoreStatus = RTStoreStatus.LockToInStore;
if (!ServerCM.BeginOutStore(jobInfo.Clone(), VLog))
{
RTStoreStatus = RTStoreStatus.Ready;
}
CurrentTerminalReelID = jobInfo.WareNum;
}
}
if (InStoreJobInfo != null)
{
VLog.Info("入库成功:" + InStoreJobInfo.ToStr());
string[] substrings = InStoreJobInfo.WareNum.Split('#');
if (substrings.Length > 2)
{
string secondSubstring = substrings[1].Substring(1);
InStoreEnd(secondSubstring);
} }
CurrentTerminalReelID = jobInfo.WareNum; InStoreJobInfo = null;
} }
} }
if (InStoreJobInfo != null) else if ((DateTime.Now - LastStatusTime).TotalSeconds > 30)
{ {
VLog.Info("入库成功:" + InStoreJobInfo.ToStr()); TerminalError = true;
string[] substrings = InStoreJobInfo.WareNum.Split('#'); if (RTStoreStatus == RTStoreStatus.InStoreReady)
if (substrings.Length > 2)
{ {
string secondSubstring = substrings[1].Substring(1); VLog.Error($"入库超时出错,没有执行入库过程,RTStoreStatus={RTStoreStatus}:" + InStoreJobInfo?.ToStr());
InStoreEnd(secondSubstring); CurrentTowerStatusText = crc.GetString("Res0065","入库错误,没有执行入库过程");
}
else if (RTStoreStatus == RTStoreStatus.LockToInStore)
{
VLog.Error($"入库超时出错,没有检测到料盘,RTStoreStatus={RTStoreStatus}:" + InStoreJobInfo?.ToStr());
CurrentTowerStatusText = crc.GetString("Res0065","入库错误,没有执行入库过程");
}
else
{
VLog.Error($"未知状态超时,RTStoreStatus={RTStoreStatus}:" + InStoreJobInfo?.ToStr());
} }
InStoreJobInfo = null;
} }
} }
else else if (ti.StatusCode == 1031)
{ {
Msg.add("料仓为入库锁定状态,请检查舱门口料盘状态", MsgLevel.alarm); ServerCM.storeStatus = StoreStatus.InStoreExecute;
} if (RTStoreStatus != RTStoreStatus.InStoreExecute)
} VLog.Info("入库执行中");
else if (ti.StatusCode == 1031) RTStoreStatus = RTStoreStatus.InStoreExecute;
{ //InStoreJobInfo = null;
ServerCM.storeStatus = StoreStatus.InStoreExecute;
if (RTStoreStatus != RTStoreStatus.InStoreExecute)
VLog.Info("入库执行中");
RTStoreStatus = RTStoreStatus.InStoreExecute;
//InStoreJobInfo = null;
}
else if (ti.StatusCode == 1032)
{
if ((DateTime.Now - LastStatusTime).TotalSeconds > 30) {
RTStoreStatus = RTStoreStatus.InStoreDataTimeOut;
} }
if (RTStoreStatus != RTStoreStatus.InStoreReady && InStoreJobInfo != null) else if (ti.StatusCode == 1032)
{ {
LastStatusTime = DateTime.Now; if ((DateTime.Now - LastStatusTime).TotalSeconds > 30)
VLog.Info("物料已在舱口");
RTStoreStatus = RTStoreStatus.InStoreReady;
if (!ServerCM.BeginInStore(CID, InStoreJobInfo, VLog))
{ {
RTStoreStatus = RTStoreStatus.LockToInStore; RTStoreStatus = RTStoreStatus.InStoreDataTimeOut;
Msg.add(CID + crc.GetString("Res0051", "无法入库"), MsgLevel.alarm);
VLog.Info("入库指令失败:" + InStoreJobInfo.ToStr());
} }
CurrentTerminalReelID = InStoreJobInfo.WareNum; if (RTStoreStatus != RTStoreStatus.InStoreReady && InStoreJobInfo != null)
//Thread.Sleep() {
LastStatusTime = DateTime.Now;
VLog.Info("物料已在舱口");
RTStoreStatus = RTStoreStatus.InStoreReady;
if (!ServerCM.BeginInStore(CID, InStoreJobInfo, VLog))
{
RTStoreStatus = RTStoreStatus.LockToInStore;
Msg.add(CID + crc.GetString("Res0051", "无法入库"), MsgLevel.alarm);
VLog.Info("入库指令失败:" + InStoreJobInfo.ToStr());
}
CurrentTerminalReelID = InStoreJobInfo.WareNum;
//Thread.Sleep()
}
} }
} else if (ti.StatusCode == 1040)
else if (ti.StatusCode == 1040)
{
ServerCM.storeStatus = StoreStatus.OutMoveExecute;
if (RTStoreStatus != RTStoreStatus.OutMoveExecute)
VLog.Info("出库执行中");
RTStoreStatus = RTStoreStatus.OutMoveExecute;
}
else if (ti.StatusCode == 1041)
{
if (RTStoreStatus != RTStoreStatus.OutStoreReady)
{ {
VLog.Info("出库已完成"); ServerCM.storeStatus = StoreStatus.OutMoveExecute;
OutStoreEnd(CurrentTerminalReelID, CID); if (RTStoreStatus != RTStoreStatus.OutMoveExecute)
VLog.Info("出库执行中");
RTStoreStatus = RTStoreStatus.OutMoveExecute;
} }
else if (ti.StatusCode == 1041)
{
if (RTStoreStatus != RTStoreStatus.OutStoreReady)
{
VLog.Info("出库已完成");
InStoreJobInfo = null;
OutStoreEnd(CurrentTerminalReelID, CID);
}
RTStoreStatus = RTStoreStatus.OutStoreReady; RTStoreStatus = RTStoreStatus.OutStoreReady;
OutStoreJobList.ClearLastPosid(); OutStoreJobList.ClearLastPosid();
} }
else if (ti.StatusCode == 0 || ti.StatusCode == 18) else if (ti.StatusCode == 0 || ti.StatusCode == 18)
{ {
RTStoreStatus = RTStoreStatus.Offline; RTStoreStatus = RTStoreStatus.Offline;
ServerCM.storeStatus = StoreStatus.None; ServerCM.storeStatus = StoreStatus.None;
}else if (ti.StatusCode == 310117) }
{ else if (ti.StatusCode == 310117 || ti.StatusCode == 310249)
RTStoreStatus = RTStoreStatus.InStoreError; {
ServerCM.storeStatus = StoreStatus.InStoreError; RTStoreStatus = RTStoreStatus.InStoreError;
ServerCM.storeStatus = StoreStatus.InStoreError;
InStoreJobInfo = null;
}
else if (ti.StatusCode < 10000)
{
RTStoreStatus = RTStoreStatus.Busy;
ServerCM.storeStatus = StoreStatus.None;
//VLog.Info($"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}");
}
else
{
//VLog.Error($"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}");
ServerCM.storeStatus = StoreStatus.InTrouble;
RTStoreStatus = RTStoreStatus.Error;
}
} }
else if (ti.StatusCode < 10000) else
{ {
RTStoreStatus = RTStoreStatus.Busy;
ServerCM.storeStatus = StoreStatus.None; ServerCM.storeStatus = StoreStatus.None;
VLog.Info($"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}"); RTStoreStatus = RTStoreStatus.Offline;
} }
else /*
18 offline
26 Ready/Idle
1031 loading material
1032 material put into Terminal from outside
1040 出库执行中
1041 unloading material 物料已到舱门口
1042 material unloaded to Terminal from Tower 物料已取走
6015 Reel already loaded.
3068 初始化中
310249 Error Reel Sensor (249)
*/
//统计剩余容量
for (int i = 0; i < ti.Slots.Count; i++)
{ {
VLog.Error($"StatusCode:{ti.StatusCode},StatusText:{ti.StatusText},OnlineStatus:{ti.OnlineStatus}"); var sn = ti.Slots[i].Slotname;
ServerCM.storeStatus = StoreStatus.InTrouble; int w = 0;
RTStoreStatus = RTStoreStatus.Error; int h = 0;
if (sn.StartsWith("s15"))
{
w = 15;
int.TryParse(sn.Substring(3), out h);
}
else if (sn.StartsWith("s13"))
{
w = 13;
int.TryParse(sn.Substring(3), out h);
}
else if (sn.StartsWith("s7"))
{
w = 7;
int.TryParse(sn.Substring(2), out h);
}
//boxStatus.data.Add("capacity", "7X8=1000;7X12=345;13X32=100;");
SlotsInfo[$"{w}x{h}"] = $"{ti.Slots[i].Slots_used}/{ti.Slots[i].Slots_free}";
} }
} }
else { catch (Exception ex) {
VLog.Error("VStore Error:"+ex);
ServerCM.storeStatus = StoreStatus.None;
RTStoreStatus = RTStoreStatus.Offline;
} }
/*
18 offline
26 Ready/Idle
1031 loading material
1032 material put into Terminal from outside
1040 出库执行中
1041 unloading material 物料已到舱门口
1042 material unloaded to Terminal from Tower 物料已取走
6015 Reel already loaded.
3068 初始化中
*/
} }
public Dictionary<string, string> SlotsInfo = new Dictionary<string, string>();
public string GetStateStr() public string GetStateStr()
{ {
if (RTStoreStatus == RTStoreStatus.OutStoreReady) if (RTStoreStatus == RTStoreStatus.OutStoreReady)
return "出库中" + (!string.IsNullOrEmpty(CurrentTerminalReelID)?"SN:" + CurrentTerminalReelID:""); return crc.GetString("Res0066","出库中") + (!string.IsNullOrEmpty(CurrentTerminalReelID)?"SN:" + CurrentTerminalReelID:"");
if (RTStoreStatus == RTStoreStatus.LockToInStore) { if (RTStoreStatus == RTStoreStatus.LockToInStore) {
return "等待入库信息"; return crc.GetString("Res0067","等待入库信息");
} }
if ( RTStoreStatus == RTStoreStatus.InStoreExecute || RTStoreStatus == RTStoreStatus.InStoreReady) if ( RTStoreStatus == RTStoreStatus.InStoreExecute || RTStoreStatus == RTStoreStatus.InStoreReady)
{ {
return "入库中" + " Barcode:" + InStoreJobInfo?.WareNum; return crc.GetString("Res0068","入库中") + " Barcode:" + InStoreJobInfo?.WareNum;
} }
if (RTStoreStatus == RTStoreStatus.InStoreError) if (RTStoreStatus == RTStoreStatus.InStoreError)
{ {
return "入库出错,物料NG"; return crc.GetString("Res0069","入库出错,物料NG");
} }
return "空闲中"; return crc.GetString("Res0070","空闲中");
} }
public volatile JobInfo InStoreJobInfo; public volatile JobInfo InStoreJobInfo;
......
...@@ -92,7 +92,12 @@ namespace DeviceLibrary ...@@ -92,7 +92,12 @@ namespace DeviceLibrary
MsgService.MSList["RT-" + vs.CID].clear(); MsgService.MSList["RT-" + vs.CID].clear();
vs.VTowerProcess(); vs.VTowerProcess();
} }
finally { catch (Exception ex)
{
VLog.Error("VTowerProcess error:"+ex);
}
finally
{
MsgService.MSList["RT-" + vs.CID].Show(); MsgService.MSList["RT-" + vs.CID].Show();
} }
}); });
......
...@@ -33,10 +33,18 @@ namespace DeviceLibrary ...@@ -33,10 +33,18 @@ namespace DeviceLibrary
LogUtil.info($"{DeviceListName}设备线程启动"); LogUtil.info($"{DeviceListName}设备线程启动");
while (RobotManage.mainMachine.mstart) while (RobotManage.mainMachine.mstart)
{ {
Thread.Sleep(200); Thread.Sleep(150);
ManualResetEvent.WaitAll(new ManualResetEvent[] { RobotManage.mainMachine.ResetEvent }); ManualResetEvent.WaitAll(new ManualResetEvent[] { RobotManage.mainMachine.ResetEvent });
if (!RobotManage.mainMachine.canRunning || !RobotManage.mainMachine.mstart) if (!RobotManage.mainMachine.canRunning || !RobotManage.mainMachine.mstart)
continue; {
if (RobotManage.mainMachine.mstart) {
DevicesList.ForEach(x =>
{
x.FrontStopProcess();
});
}
continue;
}
DevicesList.ForEach(x => DevicesList.ForEach(x =>
{ {
try try
...@@ -47,6 +55,7 @@ namespace DeviceLibrary ...@@ -47,6 +55,7 @@ namespace DeviceLibrary
{ {
MsgService.MSList[x.GroupName].add(ex.ToString(), MsgLevel.warning); MsgService.MSList[x.GroupName].add(ex.ToString(), MsgLevel.warning);
MsgService.MSList[x.GroupName].setlogones(); MsgService.MSList[x.GroupName].setlogones();
LogUtil.error($"{DeviceListName} 出错:"+ ex);
} }
finally finally
{ {
......
...@@ -33,7 +33,7 @@ namespace DeviceLibrary ...@@ -33,7 +33,7 @@ namespace DeviceLibrary
public Dictionary<string, DeviceGroup> DeviceGroup { get=>RobotManage.DeviceGroup; } public Dictionary<string, DeviceGroup> DeviceGroup { get=>RobotManage.DeviceGroup; }
public bool UserPause { get; set; } = false; public bool UserPause { get; set; } = false;
ServerCommunication ServerCM; public ServerCommunication ServerCM;
public ManualResetEvent ResetEvent = new ManualResetEvent(true); public ManualResetEvent ResetEvent = new ManualResetEvent(true);
...@@ -90,14 +90,15 @@ namespace DeviceLibrary ...@@ -90,14 +90,15 @@ namespace DeviceLibrary
while (mstart) { while (mstart) {
try try
{ {
canRunning = DeviceCheck(); canRunning = DeviceCheck();
if (canRunning) if (canRunning)
{ {
ResetEvent.Set();
BtnProcess(); BtnProcess();
canRunning = SafeCheck(); canRunning = SafeCheck();
} }
Thread.Sleep(200); Thread.Sleep(150);
ResetEvent.Set();
if (!canRunning || !mstart) if (!canRunning || !mstart)
continue; continue;
if (runStatus == RunStatus.Running) if (runStatus == RunStatus.Running)
...@@ -155,6 +156,11 @@ namespace DeviceLibrary ...@@ -155,6 +156,11 @@ namespace DeviceLibrary
} }
public void Stop() { public void Stop() {
mstart = false; mstart = false;
DeviceSnapshot();
SideMove.DeviceList.Values.ToList().ForEach(s => s.Stop());
TransplantMove.DeviceList.Values.ToList().ForEach(s => s.Stop());
TrayStop.DeviceList.Values.ToList().ForEach(s => s.Stop());
MI.DeviceList.Values.ToList().ForEach(s => s.Stop());
IOMove(IO_Type.Line_Run, IO_VALUE.LOW); IOMove(IO_Type.Line_Run, IO_VALUE.LOW);
ResetEvent.Set(); ResetEvent.Set();
Alarm(AlarmType.None); Alarm(AlarmType.None);
...@@ -290,5 +296,34 @@ namespace DeviceLibrary ...@@ -290,5 +296,34 @@ namespace DeviceLibrary
} }
return ok; return ok;
} }
public void DeviceSnapshot()
{
LogUtil.info("===开始记录系统当前情况.===");
MoveInfo.List.ForEach(m => {
LogUtil.info($"\t{m.Name}: {m.MoveStep}\t{m.MoveParam.ToStr()}");
});
AxisBean.List.ToList().ForEach(al => {
al.Value.ForEach(ax => {
LogUtil.info($"\t{ax.AxisName}: {ax.GetAclPosition()}");
});
});
VStoreCollection.VStoreList.Values.ToList().ForEach(vs => {
LogUtil.info($"\t{vs.TowerName}\t{vs.CID}: {vs.RTStoreStatus}\tCurrentTerminalReelID:{vs.CurrentTerminalReelID}\tInStoreJobInfo:{vs.InStoreJobInfo?.ToStr()}");
});
ConfigHelper.Config.Configlist.ToList().ForEach(cc => {
LogUtil.info($"\t{cc.Key}: {cc.Value}");
});
MsgService.MSList.ToList().ForEach(msl =>
{
msl.Value.get().ToList().ForEach(cc =>
{
LogUtil.info($"\t{cc.datetime}\t{cc.msgLevel}\t{cc.msgtxt} ");
});
});
LogUtil.info("===记录结束.===");
}
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -116,6 +116,7 @@ namespace DeviceLibrary ...@@ -116,6 +116,7 @@ namespace DeviceLibrary
MI_08, MI_08,
MI_09, MI_09,
MI_10, MI_10,
MI_ReelTacked,
MI_11, MI_11,
MI_12, MI_12,
MI_13, MI_13,
......
...@@ -74,10 +74,13 @@ namespace DeviceLibrary ...@@ -74,10 +74,13 @@ namespace DeviceLibrary
case "IsFree": case "IsFree":
isok = TrayManager.IsFree(remoteLoad); isok = TrayManager.IsFree(remoteLoad);
break; break;
case "IsNeedProcessNG":
isok = TrayManager.IsNeedProcessNG(remoteLoad);
break;
case "OK": case "OK":
case "FAIL": case "FAIL":
lastresult[Seq] = remoteLoad.Action == "OK" ? RemoteResult.True : RemoteResult.False; lastresult[Seq] = remoteLoad.Action == "OK" ? RemoteResult.True : RemoteResult.False;
LogUtil.info("Revice Command Callback:" + remoteLoad.GroupName + " - " + remoteLoad.Action); LogUtil.info($"[{remoteLoad.GroupName}] Revice Command Callback:" + remoteLoad.Action);
return; return;
default: default:
break; break;
...@@ -100,7 +103,7 @@ namespace DeviceLibrary ...@@ -100,7 +103,7 @@ namespace DeviceLibrary
allClients[deviceGroupName].Send(JsonConvert.SerializeObject(message)); allClients[deviceGroupName].Send(JsonConvert.SerializeObject(message));
} }
catch (Exception ex){ catch (Exception ex){
LogUtil.info($"设备:{deviceGroupName} 消息发送出错:"+ex.ToString()); LogUtil.error($"设备:{deviceGroupName} 消息发送出错:"+ex.ToString());
} }
} }
...@@ -109,7 +112,7 @@ namespace DeviceLibrary ...@@ -109,7 +112,7 @@ namespace DeviceLibrary
remoteLoad.GroupName = GroupName; remoteLoad.GroupName = GroupName;
if (remoteLoad.RequestLoadInfo != null && string.IsNullOrEmpty(remoteLoad.RequestLoadInfo.DeviceGroupName)) if (remoteLoad.RequestLoadInfo != null && string.IsNullOrEmpty(remoteLoad.RequestLoadInfo.DeviceGroupName))
remoteLoad.RequestLoadInfo.DeviceGroupName = GroupName; remoteLoad.RequestLoadInfo.DeviceGroupName = GroupName;
LogUtil.info($"{GroupName},发送:{remoteLoad.Action},Seq:{remoteLoad.Seq}"); LogUtil.info($"[{GroupName}],发送:{remoteLoad.Action},Seq:{remoteLoad.Seq}");
lastresult[remoteLoad.Seq] = RemoteResult.None; lastresult[remoteLoad.Seq] = RemoteResult.None;
SendMessage(GroupName, remoteLoad); SendMessage(GroupName, remoteLoad);
return WaitResult(GroupName, remoteLoad.Seq,waittime); return WaitResult(GroupName, remoteLoad.Seq,waittime);
...@@ -118,22 +121,30 @@ namespace DeviceLibrary ...@@ -118,22 +121,30 @@ namespace DeviceLibrary
{ {
if (!lastresult.ContainsKey(seq)) if (!lastresult.ContainsKey(seq))
return RemoteResult.Timeout; return RemoteResult.Timeout;
while (lastresult[seq] == RemoteResult.None && waittime > 0) try
{
System.Threading.Thread.Sleep(50);
waittime = waittime - 50;
}
if (lastresult[seq] == RemoteResult.None)
{
LogUtil.info($"等待{GroupName}反馈超时 seq:"+seq);
lastresult[seq] = RemoteResult.Timeout;
}
var result = lastresult[seq];
lock (lastresult)
{ {
lastresult.Remove(seq); while (lastresult[seq] == RemoteResult.None && waittime > 0)
{
System.Threading.Thread.Sleep(50);
waittime = waittime - 50;
}
if (lastresult[seq] == RemoteResult.None)
{
LogUtil.info($"等待{GroupName}反馈超时 seq:" + seq);
lastresult[seq] = RemoteResult.Timeout;
}
var result = lastresult[seq];
lock (lastresult)
{
lastresult.Remove(seq);
}
return result;
} }
return result; catch(Exception ex) {
LogUtil.error($"等待{GroupName}反馈超时 seq:" + seq +" 出错:"+ex);
return RemoteResult.Timeout;
}
} }
public static void SendResult(string deviceGroupName, bool result,long Seq) public static void SendResult(string deviceGroupName, bool result,long Seq)
{ {
......
...@@ -190,6 +190,7 @@ namespace DeviceLibrary ...@@ -190,6 +190,7 @@ namespace DeviceLibrary
LogUtil.info("用户暂停"); LogUtil.info("用户暂停");
else else
LogUtil.info("系统暂停: "+msg); LogUtil.info("系统暂停: "+msg);
mainMachine.DeviceSnapshot();
Thread.Sleep(500); Thread.Sleep(500);
} }
else else
......
...@@ -37,10 +37,11 @@ namespace DeviceLibrary ...@@ -37,10 +37,11 @@ namespace DeviceLibrary
Traylist[rfid].LastAddr = addr; Traylist[rfid].LastAddr = addr;
Traylist[rfid].Destination = TrayManager.AddrDesc[Traylist[rfid].DestinationAddr]; Traylist[rfid].Destination = TrayManager.AddrDesc[Traylist[rfid].DestinationAddr];
Traylist[rfid].LastPosition = TrayManager.AddrDesc[Traylist[rfid].LastAddr]; Traylist[rfid].LastPosition = TrayManager.AddrDesc[Traylist[rfid].LastAddr];
if (reelcheck == 0) if (Traylist[rfid].TrayType == TrayTypeE.MTP1 && (addr == 16 || addr == 20 || addr == 5 || addr == 3))
Traylist[rfid].HasLoadCheck--; Traylist[rfid].HasLoadCheck += reelcheck == 0 ? -1 : 1;
else if (reelcheck == 1) else if (Traylist[rfid].TrayType == TrayTypeE.MTP2)
Traylist[rfid].HasLoadCheck = 1; Traylist[rfid].HasLoadCheck += reelcheck == 0 ? -1 : 1;
trayInfo = Traylist[rfid]; trayInfo = Traylist[rfid];
//Statistics(); //Statistics();
} }
...@@ -56,6 +57,12 @@ namespace DeviceLibrary ...@@ -56,6 +57,12 @@ namespace DeviceLibrary
lock (Traylist) lock (Traylist)
{ {
LogUtil.info($"SetTrayLoadInfo:{rfid},{requestLoadInfo?.LoadParam?.ToStr()},{requestLoadInfo?.DeviceGroupName}"); LogUtil.info($"SetTrayLoadInfo:{rfid},{requestLoadInfo?.LoadParam?.ToStr()},{requestLoadInfo?.DeviceGroupName}");
if (!Traylist.ContainsKey(rfid)) {
Traylist.Add(rfid, new TrayInfo());
Traylist[rfid].RFID = rfid;
Traylist[rfid].LastUpdateTime = DateTime.Now;
}
if (requestLoadInfo == null) if (requestLoadInfo == null)
{ {
Traylist[rfid].SetToEmpty(); Traylist[rfid].SetToEmpty();
...@@ -131,13 +138,21 @@ namespace DeviceLibrary ...@@ -131,13 +138,21 @@ namespace DeviceLibrary
TrayRequest[remoteLoad.GroupName] = remoteLoad.RequestLoadInfo; TrayRequest[remoteLoad.GroupName] = remoteLoad.RequestLoadInfo;
} }
} }
public static bool CalcNeedTrans(int curaddr1, int destaddr1, bool hasload) { public static bool CalcNeedTrans(int curaddr1, int destaddr1, bool hasload,TrayTypeE trayType) {
if (!hasload) if (!hasload)
{ {
var addrs = TrayRequest.Values.Select(x => new { TaryType = x.GetTrayType, Addr = GetAddrByGroupName(x.DeviceGroupName) }).ToList(); if (curaddr1 == 19 && RobotManage.mainMachine.ServerCM.OutMaterialTaskCount > Setting_Init.Device_LS3_MTP2_OutTaskMaxCount && trayType== TrayTypeE.MTP2)
{
return true;
}
if (curaddr1 == 19 && RobotManage.mainMachine.ServerCM.OutReelTaskCount > Setting_Init.Device_LS3_MTP1_OutTaskMaxCount && trayType == TrayTypeE.MTP1)
{
return true;
}
var addrs = TrayRequest.Values.Where(x=>x.TrayType==trayType.ToString()).Select(x => new { TaryType = x.GetTrayType, Addr = GetAddrByGroupName(x.DeviceGroupName) }).ToList();
foreach (var a in addrs) foreach (var a in addrs)
{ {
var trayaddrs = TrayManager.Traylist.Values.Where(t => (DateTime.Now - t.LastUpdateTime).TotalSeconds < 30 && t.TrayType == a.TaryType && !hasload).Select(t => t.LastAddr).ToList(); var trayaddrs = TrayManager.Traylist.Values.Where(t => (DateTime.Now - t.LastUpdateTime).TotalSeconds < 60 && t.TrayType == a.TaryType && !hasload).Select(t => t.LastAddr).ToList();
if (trayaddrs.Count == 0) if (trayaddrs.Count == 0)
return false; return false;
...@@ -252,6 +267,17 @@ namespace DeviceLibrary ...@@ -252,6 +267,17 @@ namespace DeviceLibrary
} }
return false; return false;
} }
/// <summary>
/// 是否需要等待处理NG物料
/// </summary>
/// <param name="remoteLoad"></param>
/// <returns></returns>
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));
return xx.Count() > 0;
}
/// <summary> /// <summary>
/// 空托盘数量 /// 空托盘数量
......
...@@ -17,6 +17,7 @@ namespace DeviceLibrary ...@@ -17,6 +17,7 @@ namespace DeviceLibrary
void TrayRelease(); void TrayRelease();
bool IsFree(); bool IsFree();
bool FrontCheck(int curaddr); bool FrontCheck(int curaddr);
void FrontStopProcess();
} }
public enum DeviceStateE public enum DeviceStateE
......
...@@ -32,9 +32,10 @@ namespace DeviceLibrary ...@@ -32,9 +32,10 @@ namespace DeviceLibrary
MoveInfo RoboMoveInfo; MoveInfo RoboMoveInfo;
//CylinderManger Location; //CylinderManger Location;
public AxisBean Comp; public AxisBean Comp;
public AxisBean Rotate; //public AxisBean Rotate;
URRobotControl Robot; URRobotControl Robot;
RobotHelper robotHelper; RobotHelper robotHelper;
BufferSlotsManger BufferSlotsManger;
string POS_Start = "MI1"; string POS_Start = "MI1";
public MI(DeviceGroup device,out string msg) : base() public MI(DeviceGroup device,out string msg) : base()
{ {
...@@ -56,9 +57,10 @@ namespace DeviceLibrary ...@@ -56,9 +57,10 @@ namespace DeviceLibrary
} }
robotHelper = new RobotHelper(Robot); robotHelper = new RobotHelper(Robot);
Comp = AxisBean.List[DeviceGroup.GroupName][0]; Comp = AxisBean.List[DeviceGroup.GroupName][0];
Rotate = AxisBean.List[DeviceGroup.GroupName][1]; //Rotate = AxisBean.List[DeviceGroup.GroupName][1];
BufferSlotsManger = new BufferSlotsManger(POS_Start);
} }
...@@ -102,6 +104,14 @@ namespace DeviceLibrary ...@@ -102,6 +104,14 @@ namespace DeviceLibrary
MsgService.MSList[GroupName + "-T"].Show(); MsgService.MSList[GroupName + "-T"].Show();
} }
} }
public void Reset()
{
Robot.SendMoveCmd(1, Setting_Init.URRobot_CI_Speed_Rate);
Config.Set("RuntimeRobot_MoveStep", "Wait");
Config.Set("RuntimeRobot_Arm_MoveStep", "Wait");
}
private bool DeviceCheck() private bool DeviceCheck()
{ {
...@@ -111,7 +121,7 @@ namespace DeviceLibrary ...@@ -111,7 +121,7 @@ namespace DeviceLibrary
return false; return false;
} }
if (!robotHelper.RobotStatus) { if (!robotHelper.RobotStatus) {
Msg.add(POS_Start + "机器人当前不可用", MsgLevel.alarm); Msg.add(POS_Start + crc.GetString("Res0058","机器人当前不可用"), MsgLevel.alarm);
return false; return false;
} }
return true; return true;
...@@ -161,15 +171,14 @@ namespace DeviceLibrary ...@@ -161,15 +171,14 @@ namespace DeviceLibrary
break; break;
case MoveStep.MI_01: case MoveStep.MI_01:
MoveInfo.NextMoveStep(MoveStep.MI_02); MoveInfo.NextMoveStep(MoveStep.MI_02);
//Location.ToHigh(MoveInfo);
RoboMoveInfo.MoveParam = MoveInfo.MoveParam.clone(); RoboMoveInfo.MoveParam = MoveInfo.MoveParam.clone();
RoboMoveInfo.NextMoveStep(MoveStep.MI_01); RoboMoveInfo.NextMoveStep(MoveStep.MI_01);
MoveInfo.log("机器人开始取料"); MoveInfo.log("机器人开始取料");
break; break;
case MoveStep.MI_02: case MoveStep.MI_02:
if (RoboMoveInfo.MoveStep >= MoveStep.MI_40) if (RoboMoveInfo.MoveStep == MoveStep.MI_ReelTacked)
{ {
MoveInfo.NextMoveStep(MoveStep.MI_03); MoveInfo.NextMoveStep(MoveStep.MI_04);
if (FromPos.PositionNum.EndsWith("MT")) if (FromPos.PositionNum.EndsWith("MT"))
{ {
RemoteLoad remoteLoad = new RemoteLoad(); RemoteLoad remoteLoad = new RemoteLoad();
...@@ -189,15 +198,19 @@ namespace DeviceLibrary ...@@ -189,15 +198,19 @@ namespace DeviceLibrary
} }
break; break;
case MoveStep.MI_03: case MoveStep.MI_04:
if (RoboMoveInfo.MoveStep >= MoveStep.MI_44) if (CurrentVStore.RTStoreStatus == RTStoreStatus.Ready || CurrentVStore.RTStoreStatus == RTStoreStatus.LockToInStore)
{ {
MoveInfo.NextMoveStep(MoveStep.MI_04); MoveInfo.NextMoveStep(MoveStep.MI_05);
RoboMoveInfo.NextMoveStep(MoveStep.MI_40);
MoveInfo.log("机器人开始放料");
CurrentVStore.RequestInStore(new JobInfo(RoboMoveInfo.MoveParam.WareCode, "", RoboMoveInfo.MoveParam.PlateW, RoboMoveInfo.MoveParam.PlateH)); CurrentVStore.RequestInStore(new JobInfo(RoboMoveInfo.MoveParam.WareCode, "", RoboMoveInfo.MoveParam.PlateW, RoboMoveInfo.MoveParam.PlateH));
}
else {
MoveInfo.log("机器人放料时发现舱门口有料");
} }
break; break;
case MoveStep.MI_04: case MoveStep.MI_05:
if (RoboMoveInfo.MoveStep == MoveStep.Wait) if (RoboMoveInfo.MoveStep == MoveStep.Wait)
{ {
MoveInfo.log("放入料仓口完成:"+ RoboMoveInfo.MoveParam.ToStr()); MoveInfo.log("放入料仓口完成:"+ RoboMoveInfo.MoveParam.ToStr());
...@@ -206,58 +219,57 @@ namespace DeviceLibrary ...@@ -206,58 +219,57 @@ namespace DeviceLibrary
break; break;
case MoveStep.MI_50: case MoveStep.MI_50:
CurrntOutReadyStore = VStoreCollection.VStoreList.Values.ToList().Find(vs => vs.RTStoreStatus == RTStoreStatus.OutStoreReady); var InStoreError = VStoreCollection.VStoreList.Values.ToList().Find(vs => vs.RTStoreStatus == RTStoreStatus.InStoreError || vs.RTStoreStatus == RTStoreStatus.InStoreDataTimeOut || vs.TerminalError);
if (CurrntOutReadyStore != null) if (InStoreError != null)
{ {
if (string.IsNullOrEmpty(CurrntOutReadyStore.CurrentTerminalReelID)) var result = TheLine.GetReelSize<ResultData>(InStoreError.CurrentTerminalReelID);
{ if (result != null && result.code == 0)
MoveInfo.log("当前出库料仓:" + CurrntOutReadyStore.CID + "已是出库完成状态,但是还没有读到物料完成通知");
return;
}
if (!VStoreCollection.OutStoreReelInfo.ContainsKey(CurrntOutReadyStore.CurrentTerminalReelID))
{ {
MoveInfo.log("当前出库料仓:" + CurrntOutReadyStore.CID + ",没有找到料盘信息:" + CurrntOutReadyStore.CurrentTerminalReelID); CurrntOutReadyStore = InStoreError;
var result = TheLine.GetReelSize<ResultData>(CurrntOutReadyStore.CurrentTerminalReelID); InStoreError.ServerCM.cancelPutInTask(InStoreError.CurrentTerminalReelID);
if (result != null && result.code == 0) CurrentJobInfo = new JobInfo(InStoreError.CurrentTerminalReelID, "", int.Parse(result.data["plateW"]), int.Parse(result.data["plateH"]));
{ InStoreError.InStoreJobInfo = null;
CurrentJobInfo = new JobInfo(CurrntOutReadyStore.CurrentTerminalReelID, "", int.Parse(result.data["plateW"]), int.Parse(result.data["plateH"])); MoveInfo.log("从服务器检索到物料数据:" + CurrentJobInfo.ToStr());
MoveInfo.log("从服务器检索到物料数据:" + CurrentJobInfo.ToStr()); MoveInfo.MoveParam.IsNg = true;
MoveInfo.MoveParam.NgMsg = InStoreError.CID + "-" + InStoreError.CurrentTowerStatusText;
} MoveInfo.log("检测到有料仓入库NG:" + MoveInfo.MoveParam.NgMsg);
else
return;
} }
else else
{ {
var job = VStoreCollection.OutStoreReelInfo[CurrntOutReadyStore.CurrentTerminalReelID]; MoveInfo.log("没有找到,在等待出库的料仓");
CurrentJobInfo = job.Clone(); MoveInfo.NextMoveStep(MoveStep.Wait);
TrayStop.DeviceList[GroupName].TrayRelease();
return;
} }
} }
else else {
{ var random = new Random(DateTime.Now.Millisecond);
var InStoreError = VStoreCollection.VStoreList.Values.ToList().Find(vs => vs.RTStoreStatus == RTStoreStatus.InStoreError ||vs.RTStoreStatus == RTStoreStatus.InStoreDataTimeOut); CurrntOutReadyStore = VStoreCollection.VStoreList.Values.ToList().FindAll(vs => vs.RTStoreStatus == RTStoreStatus.OutStoreReady).OrderBy(x => random.Next()).FirstOrDefault();
if (CurrntOutReadyStore != null)
if (InStoreError != null)
{ {
var result = TheLine.GetReelSize<ResultData>(InStoreError.CurrentTerminalReelID); if (string.IsNullOrEmpty(CurrntOutReadyStore.CurrentTerminalReelID))
if (result != null && result.code == 0) {
MoveInfo.log("当前出库料仓:" + CurrntOutReadyStore.CID + "已是出库完成状态,但是还没有读到物料完成通知");
return;
}
if (!VStoreCollection.OutStoreReelInfo.ContainsKey(CurrntOutReadyStore.CurrentTerminalReelID))
{ {
CurrntOutReadyStore = InStoreError; MoveInfo.log("当前出库料仓:" + CurrntOutReadyStore.CID + ",没有找到料盘信息:" + CurrntOutReadyStore.CurrentTerminalReelID);
InStoreError.ServerCM.cancelPutInTask(InStoreError.CurrentTerminalReelID); var result = TheLine.GetReelSize<ResultData>(CurrntOutReadyStore.CurrentTerminalReelID);
CurrentJobInfo = new JobInfo(InStoreError.CurrentTerminalReelID, "", int.Parse(result.data["plateW"]), int.Parse(result.data["plateH"])); if (result != null && result.code == 0)
InStoreError.InStoreJobInfo = null; {
MoveInfo.log("从服务器检索到物料数据:" + CurrentJobInfo.ToStr()); CurrentJobInfo = new JobInfo(CurrntOutReadyStore.CurrentTerminalReelID, "", int.Parse(result.data["plateW"]), int.Parse(result.data["plateH"]));
MoveInfo.MoveParam.IsNg = true; MoveInfo.log("从服务器检索到物料数据:" + CurrentJobInfo.ToStr());
MoveInfo.MoveParam.NgMsg = InStoreError.CID + "入库异常";
MoveInfo.log("检测到有料仓入库NG:" + InStoreError.CID); }
else
return;
} }
else else
{ {
MoveInfo.log("没有找到,在等待出库的料仓"); var job = VStoreCollection.OutStoreReelInfo[CurrntOutReadyStore.CurrentTerminalReelID];
MoveInfo.NextMoveStep(MoveStep.Wait); CurrentJobInfo = job.Clone();
TrayStop.DeviceList[GroupName].TrayRelease(); }
return; }
} }
else else
{ {
...@@ -266,7 +278,7 @@ namespace DeviceLibrary ...@@ -266,7 +278,7 @@ namespace DeviceLibrary
TrayStop.DeviceList[GroupName].TrayRelease(); TrayStop.DeviceList[GroupName].TrayRelease();
return; return;
} }
} }
MoveInfo.log("收到物料出库任务:" + CurrentJobInfo.ToStr()); MoveInfo.log("收到物料出库任务:" + CurrentJobInfo.ToStr());
MoveInfo.MoveParam.WareCode = CurrentJobInfo.WareNum; MoveInfo.MoveParam.WareCode = CurrentJobInfo.WareNum;
MoveInfo.MoveParam.PosID = CurrentJobInfo.PosId; MoveInfo.MoveParam.PosID = CurrentJobInfo.PosId;
...@@ -285,10 +297,10 @@ namespace DeviceLibrary ...@@ -285,10 +297,10 @@ namespace DeviceLibrary
MoveInfo.NextMoveStep(MoveStep.MI_52); MoveInfo.NextMoveStep(MoveStep.MI_52);
RoboMoveInfo.MoveParam = MoveInfo.MoveParam.clone(); RoboMoveInfo.MoveParam = MoveInfo.MoveParam.clone();
RoboMoveInfo.NextMoveStep(MoveStep.MI_01); RoboMoveInfo.NextMoveStep(MoveStep.MI_01);
MoveInfo.log("机器人开始取料"); MoveInfo.log("机器人开始取料");
break; break;
case MoveStep.MI_52: case MoveStep.MI_52:
if (RoboMoveInfo.MoveStep >= MoveStep.MI_40) if (RoboMoveInfo.MoveStep == MoveStep.MI_ReelTacked)
{ {
MoveInfo.NextMoveStep(MoveStep.MI_53); MoveInfo.NextMoveStep(MoveStep.MI_53);
lock (VStoreCollection.OutStoreReelInfo) lock (VStoreCollection.OutStoreReelInfo)
...@@ -297,11 +309,26 @@ namespace DeviceLibrary ...@@ -297,11 +309,26 @@ namespace DeviceLibrary
//CurrntOutReadyStore.CurrentTerminalReelID = ""; //CurrntOutReadyStore.CurrentTerminalReelID = "";
} }
TheLine.UpdateLocInfo("", MoveInfo.MoveParam.WareCode, TheLine.LineStatusE.INROBOT, GroupName); TheLine.UpdateLocInfo("", MoveInfo.MoveParam.WareCode, TheLine.LineStatusE.INROBOT, GroupName);
MoveInfo.log("机器人已取到料"); MoveInfo.log("机器人已取到料");
if (CurrntOutReadyStore.TerminalError) {
MoveInfo.log($"当前出库料仓[{CurrntOutReadyStore.CID}]存在状态错误:" + CurrntOutReadyStore.RTStoreStatus);
CurrntOutReadyStore.RTStoreStatus = RTStoreStatus.Busy;
}
if (MoveInfo.MoveParam.IsNg && CurrntOutReadyStore.TerminalError && IOValue(IO_Type.MI_Robot_Reel_Check).Equals(IO_VALUE.LOW)
&& IOValue(IO_Type.MI_Robot_Clamp_Check).Equals(IO_VALUE.LOW))
{
MoveInfo.log("机器人抓取NG料后发现夹爪上没有料,流程结束处理");
RoboMoveInfo.NextMoveStep(MoveStep.Wait);
MoveInfo.NextMoveStep(MoveStep.Wait);
}
} }
break; break;
case MoveStep.MI_53: case MoveStep.MI_53:
MoveInfo.NextMoveStep(MoveStep.MI_54);
RoboMoveInfo.NextMoveStep(MoveStep.MI_40);
MoveInfo.log("机器人开始放料");
break;
case MoveStep.MI_54:
if (RoboMoveInfo.MoveStep >= MoveStep.MI_44) if (RoboMoveInfo.MoveStep >= MoveStep.MI_44)
{ {
MoveInfo.log("机器人完成放料"); MoveInfo.log("机器人完成放料");
...@@ -315,10 +342,10 @@ namespace DeviceLibrary ...@@ -315,10 +342,10 @@ namespace DeviceLibrary
TrayManager.TrayRelease(remoteLoad); //这条会自动放行托盘并且写入托盘目的地 TrayManager.TrayRelease(remoteLoad); //这条会自动放行托盘并且写入托盘目的地
TheLine.UpdateLocInfo("", MoveInfo.MoveParam.WareCode, TheLine.LineStatusE.INLINE, CurrrentRFID); TheLine.UpdateLocInfo("", MoveInfo.MoveParam.WareCode, TheLine.LineStatusE.INLINE, CurrrentRFID);
MoveInfo.NextMoveStep(MoveStep.MI_54); MoveInfo.NextMoveStep(MoveStep.MI_55);
} }
break; break;
case MoveStep.MI_54: case MoveStep.MI_55:
if (RoboMoveInfo.MoveStep == MoveStep.Wait) if (RoboMoveInfo.MoveStep == MoveStep.Wait)
{ {
MoveInfo.log("机器人任务结束"); MoveInfo.log("机器人任务结束");
...@@ -388,11 +415,11 @@ namespace DeviceLibrary ...@@ -388,11 +415,11 @@ namespace DeviceLibrary
RoboMoveInfo.log("机器人到P1"); RoboMoveInfo.log("机器人到P1");
break; break;
case MoveStep.MI_08: case MoveStep.MI_08:
RoboMoveInfo.NextMoveStep(MoveStep.MI_40); RoboMoveInfo.NextMoveStep(MoveStep.MI_ReelTacked);
RoboMoveInfo.log("机器人取料完成"); RoboMoveInfo.log("机器人取料完成");
break; break;
//放料到缓存位置 //机器人放料
case MoveStep.MI_40: case MoveStep.MI_40:
RoboMoveInfo.NextMoveStep(MoveStep.MI_41); RoboMoveInfo.NextMoveStep(MoveStep.MI_41);
robotHelper.Move(RoboMoveInfo, ToPos.Put_P2); robotHelper.Move(RoboMoveInfo, ToPos.Put_P2);
...@@ -646,7 +673,7 @@ namespace DeviceLibrary ...@@ -646,7 +673,7 @@ namespace DeviceLibrary
MoveInfo.NextMoveStep(MoveStep.H02_HomeReset); MoveInfo.NextMoveStep(MoveStep.H02_HomeReset);
} }
else { else {
Msg.add("机器人状态异常:" + Robot.CurDashboardReponse, MsgLevel.alarm); Msg.add(crc.GetString("Res0059","机器人状态异常:") + Robot.CurDashboardReponse, MsgLevel.alarm);
} }
break; break;
case MoveStep.H12_HomeReset: case MoveStep.H12_HomeReset:
...@@ -686,9 +713,13 @@ namespace DeviceLibrary ...@@ -686,9 +713,13 @@ namespace DeviceLibrary
if (reelParam == null) if (reelParam == null)
{ {
//空托盘,判断有没有出库任务 //空托盘,判断有没有出库任务
var sc = VStoreCollection.VStoreList.Values.ToList().Find(vs=>vs.RTStoreStatus==RTStoreStatus.OutStoreReady || vs.RTStoreStatus == RTStoreStatus.InStoreError); var sc = VStoreCollection.VStoreList.Values.ToList().Find(vs=>vs.RTStoreStatus==RTStoreStatus.OutStoreReady || vs.RTStoreStatus == RTStoreStatus.InStoreError|| vs.RTStoreStatus == RTStoreStatus.InStoreDataTimeOut || vs.TerminalError);
return (sc != null); return (sc != null);
} }
if (string.IsNullOrEmpty(reelParam.SubCID)) {
MoveInfo.log("SubCID为空");
return false;
}
if (!VStoreCollection.VStoreList.ContainsKey(reelParam.SubCID)) { if (!VStoreCollection.VStoreList.ContainsKey(reelParam.SubCID)) {
MoveInfo.log("RT料仓CID不存在:"+ reelParam.SubCID); MoveInfo.log("RT料仓CID不存在:"+ reelParam.SubCID);
...@@ -736,5 +767,10 @@ namespace DeviceLibrary ...@@ -736,5 +767,10 @@ namespace DeviceLibrary
return RobotManage.CIPostion[pos]; return RobotManage.CIPostion[pos];
} }
public void FrontStopProcess()
{
//throw new NotImplementedException();
}
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -41,8 +41,8 @@ namespace DeviceLibrary ...@@ -41,8 +41,8 @@ namespace DeviceLibrary
DeviceGroup = device; DeviceGroup = device;
GroupName = DeviceGroup.GroupName; GroupName = DeviceGroup.GroupName;
Msg = new MsgService(GroupName); Msg = new MsgService(GroupName);
LSAMoveInfo = new MoveInfo(GroupName + "_A"); LSAMoveInfo = new MoveInfo(GroupName + "_1");
LSBMoveInfo = new MoveInfo(GroupName + "_B"); LSBMoveInfo = new MoveInfo(GroupName + "_2");
Location_A = new CylinderManger($"A侧顶升", GroupName, IO_Type.Ls_A_Location_Up, IO_Type.Ls_A_Location_Down); Location_A = new CylinderManger($"A侧顶升", GroupName, IO_Type.Ls_A_Location_Up, IO_Type.Ls_A_Location_Down);
Location_B = new CylinderManger($"B侧顶升", GroupName, IO_Type.Ls_B_Location_Up, IO_Type.Ls_B_Location_Down); Location_B = new CylinderManger($"B侧顶升", GroupName, IO_Type.Ls_B_Location_Up, IO_Type.Ls_B_Location_Down);
...@@ -86,6 +86,8 @@ namespace DeviceLibrary ...@@ -86,6 +86,8 @@ namespace DeviceLibrary
DeviceState = DeviceStateE.Stop; DeviceState = DeviceStateE.Stop;
Line.LineStop("n"); Line.LineStop("n");
LSAMoveInfo.log("停止运行"); LSAMoveInfo.log("停止运行");
Task.Run(() => { Task.Delay(1000).Wait(); IOMove(IO_Type.Ls_A_Front_Stop, IO_VALUE.LOW); IOMove(IO_Type.Ls_B_Front_Stop, IO_VALUE.LOW); Line.LineStop("n"); });
} }
public void Process() public void Process()
{ {
...@@ -123,16 +125,16 @@ namespace DeviceLibrary ...@@ -123,16 +125,16 @@ namespace DeviceLibrary
case MoveStep.SideMove_01: case MoveStep.SideMove_01:
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_01); LSAMoveInfo.NextMoveStep(MoveStep.SideMove_01);
bool Forcetry = false; bool Forcetry = false;
if (LastGoInFail && (LastGoInFailTime - DateTime.Now).TotalSeconds > 10) //if (LastGoInFail && (LastGoInFailTime - DateTime.Now).TotalSeconds > 10)
{ //{
Forcetry = true; // Forcetry = true;
LSAMoveInfo.log("上次托盘进入失败本次重试"); // LSAMoveInfo.log("上次托盘进入失败本次重试");
} //}
if (IOValue(IO_Type.Ls_B_Tray_Check).Equals(IO_VALUE.HIGH)) //if (IOValue(IO_Type.Ls_B_Tray_Check).Equals(IO_VALUE.HIGH))
{ //{
break; // break;
} //}
else //else
if (IOValue(IO_Type.Ls_A_Tray_Check).Equals(IO_VALUE.HIGH)) if (IOValue(IO_Type.Ls_A_Tray_Check).Equals(IO_VALUE.HIGH))
{ {
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_04); LSAMoveInfo.NextMoveStep(MoveStep.SideMove_04);
...@@ -143,10 +145,9 @@ namespace DeviceLibrary ...@@ -143,10 +145,9 @@ namespace DeviceLibrary
{ {
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_02); LSAMoveInfo.NextMoveStep(MoveStep.SideMove_02);
Location_A.ToLow(LSAMoveInfo); Location_A.ToLow(LSAMoveInfo);
//Location_B.ToLow(LSAMoveInfo); //Location_B.ToLow(LSAMoveInfo);
LSAMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500)); //LSAMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
} }
else else
{ {
...@@ -164,7 +165,7 @@ namespace DeviceLibrary ...@@ -164,7 +165,7 @@ namespace DeviceLibrary
{ {
IOMove(IO_Type.Ls_A_Front_Stop, IO_VALUE.LOW); IOMove(IO_Type.Ls_A_Front_Stop, IO_VALUE.LOW);
} }
if (IOValue(IO_Type.Ls_A_Tray_Check).Equals(IO_VALUE.HIGH)) { if (IOMonitor.IODebound(IO_Type.Ls_A_Tray_Check,GroupName,IO_VALUE.HIGH)) {
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_04); LSAMoveInfo.NextMoveStep(MoveStep.SideMove_04);
LSAMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500)); LSAMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
LastGoInFail = false; LastGoInFail = false;
...@@ -183,7 +184,7 @@ namespace DeviceLibrary ...@@ -183,7 +184,7 @@ namespace DeviceLibrary
case MoveStep.SideMove_04: case MoveStep.SideMove_04:
if (!FwdFree(DeviceGroup.addr_1)) if (!FwdFree(DeviceGroup.addr_1))
return; return;
if (LSBMoveInfo.MoveStep==MoveStep.Wait) if (LSBMoveInfo.MoveStep==MoveStep.Wait && IOMonitor.IODebound(IO_Type.Ls_B_Tray_Check,GroupName,IO_VALUE.LOW,1000))
{ {
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_06); LSAMoveInfo.NextMoveStep(MoveStep.SideMove_06);
IOMove(IO_Type.Ls_B_BufStop_Fwd, IO_VALUE.HIGH, 500); IOMove(IO_Type.Ls_B_BufStop_Fwd, IO_VALUE.HIGH, 500);
...@@ -204,6 +205,7 @@ namespace DeviceLibrary ...@@ -204,6 +205,7 @@ namespace DeviceLibrary
case MoveStep.SideMove_07: case MoveStep.SideMove_07:
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_08); LSAMoveInfo.NextMoveStep(MoveStep.SideMove_08);
LSAMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Ls_B_Tray_Check, IO_VALUE.HIGH)); LSAMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Ls_B_Tray_Check, IO_VALUE.HIGH));
LSAMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Ls_A_Tray_Check, IO_VALUE.LOW));
break; break;
case MoveStep.SideMove_08: case MoveStep.SideMove_08:
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_09); LSAMoveInfo.NextMoveStep(MoveStep.SideMove_09);
...@@ -218,6 +220,7 @@ namespace DeviceLibrary ...@@ -218,6 +220,7 @@ namespace DeviceLibrary
break; break;
case MoveStep.SideMove_10: case MoveStep.SideMove_10:
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_01); LSAMoveInfo.NextMoveStep(MoveStep.SideMove_01);
break; break;
} }
} }
...@@ -282,16 +285,17 @@ namespace DeviceLibrary ...@@ -282,16 +285,17 @@ namespace DeviceLibrary
Minfo.NextMoveStep(MoveStep.SideMove_01); Minfo.NextMoveStep(MoveStep.SideMove_01);
bool Forcetry = false; bool Forcetry = false;
if (LastGoInFail && (LastGoInFailTime - DateTime.Now).TotalSeconds > 5) //if (LastGoInFail && (LastGoInFailTime - DateTime.Now).TotalSeconds > 5)
{ //{
Forcetry = true; // Forcetry = true;
LSAMoveInfo.log("上次托盘进入失败本次重试"); // LSAMoveInfo.log("上次托盘进入失败本次重试");
} //}
if (lsb.MoveStep >= MoveStep.SideMove_10 && lsb.MoveStep < MoveStep.SideMove_50) { if (lsb.MoveStep >= MoveStep.SideMove_10 && lsb.MoveStep < MoveStep.SideMove_50) {
Msg.add(sideb+crc.GetString("Res0015","侧穿越中"), MsgLevel.info); Msg.add(sideb+crc.GetString("Res0015","侧穿越中"), MsgLevel.info);
}else if (IOValue(Ls_A_Tray_Check).Equals(IO_VALUE.HIGH)) }
else if (IOValue(Ls_A_Tray_Check).Equals(IO_VALUE.HIGH))
{ {
Minfo.log("中间检测到托盘"); Minfo.log("中间检测到托盘");
Minfo.NextMoveStep(MoveStep.SideMove_06); Minfo.NextMoveStep(MoveStep.SideMove_06);
...@@ -301,7 +305,8 @@ namespace DeviceLibrary ...@@ -301,7 +305,8 @@ namespace DeviceLibrary
{ {
Minfo.NextMoveStep(MoveStep.SideMove_02); Minfo.NextMoveStep(MoveStep.SideMove_02);
Location_a.ToLow(Minfo); Location_a.ToLow(Minfo);
IOMove(Ls_A_Stop, IO_VALUE.LOW); if (LS_Type == LS_TypeE.OneWay && Minfo == LSAMoveInfo)
IOMove(Ls_A_Stop, IO_VALUE.LOW);
} }
else else
{ {
...@@ -313,7 +318,8 @@ namespace DeviceLibrary ...@@ -313,7 +318,8 @@ namespace DeviceLibrary
Minfo.log($"{Ls_A_Front_Stop}下降,{Ls_A_BufStop_Rwd}回退"); Minfo.log($"{Ls_A_Front_Stop}下降,{Ls_A_BufStop_Rwd}回退");
//IOMove(Ls_A_Front_Stop, IO_VALUE.HIGH, Ls_A_Front_Check, IO_VALUE.LOW, StopDelayMS); //IOMove(Ls_A_Front_Stop, IO_VALUE.HIGH, Ls_A_Front_Check, IO_VALUE.LOW, StopDelayMS);
IOMove(Ls_A_Front_Stop, IO_VALUE.HIGH); IOMove(Ls_A_Front_Stop, IO_VALUE.HIGH);
IOMove(Ls_A_BufStop_Rwd, IO_VALUE.HIGH, StopBufDelayMS); if (LS_Type == LS_TypeE.OneWay && Minfo == LSAMoveInfo)
IOMove(Ls_A_BufStop_Rwd, IO_VALUE.HIGH, StopBufDelayMS);
break; break;
case MoveStep.SideMove_03: case MoveStep.SideMove_03:
if (IOValue(Ls_A_Front_Check).Equals(IO_VALUE.LOW)) if (IOValue(Ls_A_Front_Check).Equals(IO_VALUE.LOW))
...@@ -355,7 +361,7 @@ namespace DeviceLibrary ...@@ -355,7 +361,7 @@ namespace DeviceLibrary
var rfid = Common.RfidFilter(data); var rfid = Common.RfidFilter(data);
TrayManager.Process(Minfo,rfid, addr,-1, out TrayInfo trayInfo); TrayManager.Process(Minfo,rfid, addr,-1, out TrayInfo trayInfo);
if (TrayManager.CalcNeedTrans(addr, trayInfo.DestinationAddr, trayInfo.HasLoad)) if (TrayManager.CalcNeedTrans(addr, trayInfo.DestinationAddr, trayInfo.HasLoad, trayInfo.TrayType))
Minfo.NextMoveStep(MoveStep.SideMove_10); Minfo.NextMoveStep(MoveStep.SideMove_10);
else else
Minfo.NextMoveStep(MoveStep.SideMove_06); Minfo.NextMoveStep(MoveStep.SideMove_06);
...@@ -393,7 +399,7 @@ namespace DeviceLibrary ...@@ -393,7 +399,7 @@ namespace DeviceLibrary
IOMove(Ls_A_Stop, IO_VALUE.LOW); IOMove(Ls_A_Stop, IO_VALUE.LOW);
Minfo.NextMoveStep(MoveStep.SideMove_08); Minfo.NextMoveStep(MoveStep.SideMove_08);
} }
else if (Minfo.IsTimeOut(5)) { else if (Minfo.IsTimeOut(10)) {
Minfo.NextMoveStep(MoveStep.SideMove_06); Minfo.NextMoveStep(MoveStep.SideMove_06);
} }
break; break;
...@@ -412,35 +418,43 @@ namespace DeviceLibrary ...@@ -412,35 +418,43 @@ namespace DeviceLibrary
else if (lsb.MoveStep >= MoveStep.SideMove_10) else if (lsb.MoveStep >= MoveStep.SideMove_10)
{ {
Minfo.NextMoveStep(MoveStep.SideMove_06); Minfo.NextMoveStep(MoveStep.SideMove_06);
Minfo.log($"{sideb}侧也在等待横移,本侧直接穿过"); Minfo.log(string.Format("{0}侧也在等待横移,本侧直接穿过", sideb));
} }
else if (LSBMoveInfo.MoveStep == MoveStep.SideMove_10 && Minfo == LSAMoveInfo) else if (LSBMoveInfo.MoveStep == MoveStep.SideMove_10 && Minfo == LSAMoveInfo)
{ {
Minfo.NextMoveStep(MoveStep.SideMove_11); Minfo.NextMoveStep(MoveStep.SideMove_11);
} }
else{ else{
Msg.add($"等待{sideb}侧空闲", MsgLevel.info); Msg.add(string.Format(crc.GetString("Res0060","等待{0}侧空闲"), sideb), MsgLevel.info);
} }
break; break;
case MoveStep.SideMove_11: case MoveStep.SideMove_11:
if (IOMonitor.IODebound(Ls_B_Tray_Check,GroupName, IO_VALUE.LOW))
Minfo.NextMoveStep(MoveStep.SideMove_12); {
Location_a.ToHigh(Minfo); Minfo.NextMoveStep(MoveStep.SideMove_12);
Location_b.ToHigh(Minfo); Location_a.ToHigh(Minfo);
IOMove(Ls_B_BufStop_Fwd, IO_VALUE.HIGH, StopBufDelayMS); Location_b.ToHigh(Minfo);
//Minfo.log($"2侧顶升升起"); IOMove(Ls_B_BufStop_Fwd, IO_VALUE.HIGH, StopBufDelayMS);
Minfo.log($"{sideb}侧已无托盘");
}
else
{
Msg.add(string.Format(crc.GetString("Res0061","等待{0}侧托盘离开"), sideb), MsgLevel.info);
}
break; break;
case MoveStep.SideMove_12: case MoveStep.SideMove_12:
Minfo.NextMoveStep(MoveStep.SideMove_13); Minfo.NextMoveStep(MoveStep.SideMove_13);
Line.LineRun("n", Minfo==LSAMoveInfo? false:true, 999); Line.LineRun("n", Minfo==LSAMoveInfo? false:true, 999);
Minfo.WaitList.Add(WaitResultInfo.WaitIO(Ls_B_Tray_Check, IO_VALUE.HIGH)); Minfo.WaitList.Add(WaitResultInfo.WaitIO(Ls_B_Tray_Check, IO_VALUE.HIGH));
Minfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
//Minfo.log($"横移线体运行"); //Minfo.log($"横移线体运行");
break; break;
case MoveStep.SideMove_13: case MoveStep.SideMove_13:
Minfo.NextMoveStep(MoveStep.SideMove_01); Minfo.NextMoveStep(MoveStep.SideMove_01);
Location_a.ToLow(Minfo); Location_a.ToLow(Minfo);
Minfo.WaitList.Add(WaitResultInfo.WaitTime(500)); Minfo.WaitList.Add(WaitResultInfo.WaitTime(500));
lsb.NextMoveStep(MoveStep.SideMove_50); lsb.NextMoveStep(MoveStep.SideMove_50);
lsb.WaitList.Add(WaitResultInfo.WaitTime(1000));
Minfo.log($"横移本侧结束"); Minfo.log($"横移本侧结束");
break; break;
///本侧接管横移后通过 ///本侧接管横移后通过
...@@ -594,9 +608,24 @@ namespace DeviceLibrary ...@@ -594,9 +608,24 @@ namespace DeviceLibrary
{ {
if (DeviceGroup.addr_1 == curaddr) if (DeviceGroup.addr_1 == curaddr)
return IOValue(IO_Type.Ls_A_Front_Check).Equals(IO_VALUE.LOW); return IOValue(IO_Type.Ls_A_Front_Check).Equals(IO_VALUE.LOW);
else else if (LS_Type != LS_TypeE.NoRfid)
return IOValue(IO_Type.Ls_B_Front_Check).Equals(IO_VALUE.LOW); return IOValue(IO_Type.Ls_B_Front_Check).Equals(IO_VALUE.LOW);
else
return true;
} }
public void FrontStopProcess()
{
if (IOValue(IO_Type.Ls_A_Front_Check).Equals(IO_VALUE.LOW))
{
IOMove(IO_Type.Ls_A_Front_Stop, IO_VALUE.LOW);
}
if (LS_Type != LS_TypeE.NoRfid && IOValue(IO_Type.Ls_B_Front_Check).Equals(IO_VALUE.LOW))
{
IOMove(IO_Type.Ls_B_Front_Stop, IO_VALUE.LOW);
}
}
enum LS_TypeE { enum LS_TypeE {
NoRfid, NoRfid,
OneWay, OneWay,
......
...@@ -69,6 +69,8 @@ namespace DeviceLibrary ...@@ -69,6 +69,8 @@ namespace DeviceLibrary
{ {
DeviceState = DeviceStateE.Stop; DeviceState = DeviceStateE.Stop;
MoveInfo.log("停止运行"); MoveInfo.log("停止运行");
Task.Run(() => { Task.Delay(1000).Wait(); IOMove(IO_Type.AMH_Front_Stop, IO_VALUE.LOW); });
} }
public void Process() public void Process()
{ {
...@@ -147,7 +149,7 @@ namespace DeviceLibrary ...@@ -147,7 +149,7 @@ namespace DeviceLibrary
if (IOValue(IO_Type.AMH_Reel_Check).Equals(IO_VALUE.HIGH)) if (IOValue(IO_Type.AMH_Reel_Check).Equals(IO_VALUE.HIGH))
{ {
RemoteLoad remoteLoad1 = new RemoteLoad(); RemoteLoad remoteLoad1 = new RemoteLoad();
remoteLoad1.Seq = DateTime.Now.Ticks; remoteLoad1.Seq = Snowflake.Instance().GetId();
remoteLoad1.Action = "DoorLock"; remoteLoad1.Action = "DoorLock";
remoteLoad1.RequestLoadInfo = new RequestLoadInfo(); remoteLoad1.RequestLoadInfo = new RequestLoadInfo();
remoteLoad1.RequestLoadInfo.IsEmpty = false; remoteLoad1.RequestLoadInfo.IsEmpty = false;
...@@ -188,7 +190,7 @@ namespace DeviceLibrary ...@@ -188,7 +190,7 @@ namespace DeviceLibrary
if (IOValue(IO_Type.AMH_Reel_Check).Equals(IO_VALUE.LOW)) if (IOValue(IO_Type.AMH_Reel_Check).Equals(IO_VALUE.LOW))
{ {
RemoteLoad remoteLoad2 = new RemoteLoad(); RemoteLoad remoteLoad2 = new RemoteLoad();
remoteLoad2.Seq = DateTime.Now.Ticks; remoteLoad2.Seq = Snowflake.Instance().GetId();
remoteLoad2.Action = "DoorLock"; remoteLoad2.Action = "DoorLock";
remoteLoad2.RequestLoadInfo = new RequestLoadInfo(); remoteLoad2.RequestLoadInfo = new RequestLoadInfo();
remoteLoad2.RequestLoadInfo.IsEmpty = true; remoteLoad2.RequestLoadInfo.IsEmpty = true;
...@@ -248,7 +250,7 @@ namespace DeviceLibrary ...@@ -248,7 +250,7 @@ namespace DeviceLibrary
IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.LOW); IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.LOW);
MoveInfo.NextMoveStep(MoveStep.Wait); MoveInfo.NextMoveStep(MoveStep.Wait);
if (GroupName == "AMH-SBSH2") if (GroupName == "AMH-SBSH2")
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000)); MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(4000));
MoveInfo.log("托盘已放行"); MoveInfo.log("托盘已放行");
} else if (MoveInfo.IsTimeOut(10)) { } else if (MoveInfo.IsTimeOut(10)) {
MoveInfo.log("托盘放行失败,重新放行"); MoveInfo.log("托盘放行失败,重新放行");
...@@ -293,7 +295,7 @@ namespace DeviceLibrary ...@@ -293,7 +295,7 @@ namespace DeviceLibrary
MoveInfo.NextMoveStep(MoveStep.TransplantMove_14); MoveInfo.NextMoveStep(MoveStep.TransplantMove_14);
MoveInfo.log("检测到物料已离开"); MoveInfo.log("检测到物料已离开");
} }
else { else if (MoveInfo.IsTimeOut(1)) {
MetrialGetRetry++; MetrialGetRetry++;
if (MetrialGetRetry > 3) { if (MetrialGetRetry > 3) {
Msg.add($"{MoveInfo.Name}取料失败", MsgLevel.alarm); Msg.add($"{MoveInfo.Name}取料失败", MsgLevel.alarm);
...@@ -368,7 +370,7 @@ namespace DeviceLibrary ...@@ -368,7 +370,7 @@ namespace DeviceLibrary
MoveInfo.NextMoveStep(MoveStep.TransplantMove_24); MoveInfo.NextMoveStep(MoveStep.TransplantMove_24);
var remoteLoad = new RemoteLoad(); var remoteLoad = new RemoteLoad();
remoteLoad.Seq = DateTime.Now.Ticks; remoteLoad.Seq = Snowflake.Instance().GetId();
remoteLoad.Action = "DoorRelease"; remoteLoad.Action = "DoorRelease";
remoteLoad.RequestLoadInfo = new RequestLoadInfo(); remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.IsEmpty = true;//true出库 false入库 remoteLoad.RequestLoadInfo.IsEmpty = true;//true出库 false入库
...@@ -427,7 +429,7 @@ namespace DeviceLibrary ...@@ -427,7 +429,7 @@ namespace DeviceLibrary
IOMove(IO_Type.AMH_Sucker, IO_VALUE.LOW); IOMove(IO_Type.AMH_Sucker, IO_VALUE.LOW);
IOMove(IO_Type.AMH_Sucker_Release, IO_VALUE.HIGH,2000); IOMove(IO_Type.AMH_Sucker_Release, IO_VALUE.HIGH,2000);
ConfigHelper.Config.Set($"Runtime_{GroupName}_IsSucker", false); ConfigHelper.Config.Set($"Runtime_{GroupName}_IsSucker", false);
TheLine.UpdateLocInfo("", MoveInfo.MoveParam.WareCode, TheLine.LineStatusE.BOXDOOR, GroupName); //TheLine.UpdateLocInfo("", MoveInfo.MoveParam.WareCode, TheLine.LineStatusE.BOXDOOR, GroupName);
break; break;
case MoveStep.TransplantMove_27: case MoveStep.TransplantMove_27:
...@@ -502,7 +504,7 @@ namespace DeviceLibrary ...@@ -502,7 +504,7 @@ namespace DeviceLibrary
case MoveStep.TransplantMove_06: case MoveStep.TransplantMove_06:
RemoteLoad remoteLoad = new RemoteLoad(); RemoteLoad remoteLoad = new RemoteLoad();
remoteLoad.Action = "DoorRelease"; remoteLoad.Action = "DoorRelease";
remoteLoad.Seq = DateTime.Now.Ticks; remoteLoad.Seq = Snowflake.Instance().GetId();
remoteLoad.RequestLoadInfo = new RequestLoadInfo(); remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.IsEmpty=false; remoteLoad.RequestLoadInfo.IsEmpty=false;
remoteLoad.RequestLoadInfo.LoadParam = MoveInfo2.MoveParam.clone(); remoteLoad.RequestLoadInfo.LoadParam = MoveInfo2.MoveParam.clone();
...@@ -607,10 +609,12 @@ namespace DeviceLibrary ...@@ -607,10 +609,12 @@ namespace DeviceLibrary
public bool IsFree() public bool IsFree()
{ {
if (MoveInfo2.MoveStep != MoveStep.Wait) { if (MoveInfo2.MoveStep != MoveStep.Wait || MoveInfo.MoveStep > MoveStep.TransplantMove_26) {
return false; return false;
} }
if (MoveInfo.MoveStep >= MoveStep.TransplantMove_10 && MoveInfo.MoveStep <= MoveStep.TransplantMove_20)
return false;
return true; return true;
} }
...@@ -624,5 +628,13 @@ namespace DeviceLibrary ...@@ -624,5 +628,13 @@ namespace DeviceLibrary
MoveInfo.NewMove(MoveStep.H01_HomeReset); MoveInfo.NewMove(MoveStep.H01_HomeReset);
MoveInfo.log("开始重置"); MoveInfo.log("开始重置");
} }
public void FrontStopProcess()
{
if (IOValue(IO_Type.AMH_Front_Check).Equals(IO_VALUE.LOW))
{
IOMove(IO_Type.AMH_Front_Stop, IO_VALUE.LOW);
}
}
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -72,6 +72,8 @@ namespace DeviceLibrary ...@@ -72,6 +72,8 @@ namespace DeviceLibrary
{ {
DeviceState = DeviceStateE.Stop; DeviceState = DeviceStateE.Stop;
MoveInfo.log("停止运行"); MoveInfo.log("停止运行");
Task.Run(() => { Task.Delay(1000).Wait(); IOMove(IO_Type.AMH_Front_Stop, IO_VALUE.LOW); });
} }
public void Process() public void Process()
{ {
...@@ -211,7 +213,7 @@ namespace DeviceLibrary ...@@ -211,7 +213,7 @@ namespace DeviceLibrary
//空托盘 //空托盘
MoveInfo.NextMoveStep(MoveStep.TrayStop_07); MoveInfo.NextMoveStep(MoveStep.TrayStop_07);
RemoteLoad remoteLoad = new RemoteLoad(); RemoteLoad remoteLoad = new RemoteLoad();
remoteLoad.Seq = DateTime.Now.Ticks; remoteLoad.Seq = Snowflake.Instance().GetId();
remoteLoad.Action = "TrayReady"; remoteLoad.Action = "TrayReady";
remoteLoad.RequestLoadInfo = new RequestLoadInfo(); remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.TrayType = trayInfo.TrayType.ToString(); remoteLoad.RequestLoadInfo.TrayType = trayInfo.TrayType.ToString();
...@@ -229,7 +231,7 @@ namespace DeviceLibrary ...@@ -229,7 +231,7 @@ namespace DeviceLibrary
//有物料 //有物料
MoveInfo.NextMoveStep(MoveStep.TrayStop_07); MoveInfo.NextMoveStep(MoveStep.TrayStop_07);
RemoteLoad remoteLoad = new RemoteLoad(); RemoteLoad remoteLoad = new RemoteLoad();
remoteLoad.Seq = DateTime.Now.Ticks; remoteLoad.Seq = Snowflake.Instance().GetId();
remoteLoad.Action = "TrayReady"; remoteLoad.Action = "TrayReady";
remoteLoad.RequestLoadInfo = new RequestLoadInfo(); remoteLoad.RequestLoadInfo = new RequestLoadInfo();
remoteLoad.RequestLoadInfo.TrayType = trayInfo.TrayType.ToString(); remoteLoad.RequestLoadInfo.TrayType = trayInfo.TrayType.ToString();
...@@ -368,7 +370,7 @@ namespace DeviceLibrary ...@@ -368,7 +370,7 @@ namespace DeviceLibrary
{ {
if (IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.LOW)) if (IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.LOW))
{ {
Msg.add("托盘放料后没有检测到物料", MsgLevel.alarm); Msg.add(crc.GetString("Res0062","托盘放料后没有检测到物料"), MsgLevel.alarm);
return; return;
} }
} }
...@@ -383,7 +385,7 @@ namespace DeviceLibrary ...@@ -383,7 +385,7 @@ namespace DeviceLibrary
if (GroupName == "AMH-ML5-1" || GroupName == "AMH-ML5-2") if (GroupName == "AMH-ML5-1" || GroupName == "AMH-ML5-2")
{ {
var remoteLoad = new RemoteLoad(); var remoteLoad = new RemoteLoad();
remoteLoad.Seq = DateTime.Now.Ticks; remoteLoad.Seq = Snowflake.Instance().GetId();
remoteLoad.Action = "IsSafe"; remoteLoad.Action = "IsSafe";
remoteLoad.RequestLoadInfo = new RequestLoadInfo(); remoteLoad.RequestLoadInfo = new RequestLoadInfo();
var result = RemoteService.SendAndWait(GroupName, remoteLoad,6000); var result = RemoteService.SendAndWait(GroupName, remoteLoad,6000);
...@@ -421,7 +423,7 @@ namespace DeviceLibrary ...@@ -421,7 +423,7 @@ namespace DeviceLibrary
/// 释放托盘 /// 释放托盘
/// </summary> /// </summary>
public void TrayRelease() { public void TrayRelease() {
MoveInfo.log("释放托盘"); MoveInfo.log("释放托盘:" + CurrrentRFID);
MoveInfo.NextMoveStep(MoveStep.TrayStop_LoadProcessed); MoveInfo.NextMoveStep(MoveStep.TrayStop_LoadProcessed);
if (TrayManager.Traylist.ContainsKey(CurrrentRFID) && TrayManager.Traylist[CurrrentRFID].HasLoad) if (TrayManager.Traylist.ContainsKey(CurrrentRFID) && TrayManager.Traylist[CurrrentRFID].HasLoad)
{ {
...@@ -453,7 +455,7 @@ namespace DeviceLibrary ...@@ -453,7 +455,7 @@ namespace DeviceLibrary
if (GroupName == d && MI.DeviceList[d].DeviceState != DeviceStateE.Run if (GroupName == d && MI.DeviceList[d].DeviceState != DeviceStateE.Run
&& MI.DeviceList[d].MoveInfo.MoveStep != MoveStep.Wait) && MI.DeviceList[d].MoveInfo.MoveStep != MoveStep.Wait)
{ {
Msg.add("等待" + d + "完成复位", MsgLevel.warning); Msg.add(crc.GetString("Res0157","等待") + d + crc.GetString("Res0063","完成复位"), MsgLevel.warning);
} }
else if (GroupName == d && MI.DeviceList[d].DeviceState == DeviceStateE.Run else if (GroupName == d && MI.DeviceList[d].DeviceState == DeviceStateE.Run
&& MI.DeviceList[d].MoveInfo.MoveStep != MoveStep.Wait) && MI.DeviceList[d].MoveInfo.MoveStep != MoveStep.Wait)
...@@ -497,5 +499,13 @@ namespace DeviceLibrary ...@@ -497,5 +499,13 @@ namespace DeviceLibrary
{ {
return IOValue(IO_Type.MI_Front_Check).Equals(IO_VALUE.LOW); return IOValue(IO_Type.MI_Front_Check).Equals(IO_VALUE.LOW);
} }
public void FrontStopProcess()
{
if (IOValue(IO_Type.MI_Front_Check).Equals(IO_VALUE.LOW))
{
IOMove(IO_Type.AMH_Front_Stop, IO_VALUE.LOW);
}
}
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -38,9 +38,7 @@ ...@@ -38,9 +38,7 @@
this.lblAxEncAcc = new System.Windows.Forms.Label(); this.lblAxEncAcc = new System.Windows.Forms.Label();
this.lblINP = new System.Windows.Forms.Label(); this.lblINP = new System.Windows.Forms.Label();
this.lblBUSY = new System.Windows.Forms.Label(); this.lblBUSY = new System.Windows.Forms.Label();
this.lblNEL = new System.Windows.Forms.Label();
this.lblORG = new System.Windows.Forms.Label(); this.lblORG = new System.Windows.Forms.Label();
this.lblPEL = new System.Windows.Forms.Label();
this.lblSvOn = new System.Windows.Forms.Label(); this.lblSvOn = new System.Windows.Forms.Label();
this.lblEMG = new System.Windows.Forms.Label(); this.lblEMG = new System.Windows.Forms.Label();
this.lblWARN = new System.Windows.Forms.Label(); this.lblWARN = new System.Windows.Forms.Label();
...@@ -94,9 +92,7 @@ ...@@ -94,9 +92,7 @@
this.txtAPosition = new System.Windows.Forms.TextBox(); this.txtAPosition = new System.Windows.Forms.TextBox();
this.label46 = new System.Windows.Forms.Label(); this.label46 = new System.Windows.Forms.Label();
this.label48 = new System.Windows.Forms.Label(); this.label48 = new System.Windows.Forms.Label();
this.label45 = new System.Windows.Forms.Label();
this.txtAxisValue = new System.Windows.Forms.TextBox(); this.txtAxisValue = new System.Windows.Forms.TextBox();
this.txtAxisDeviceName = new System.Windows.Forms.TextBox();
this.lblServerOn = new System.Windows.Forms.Label(); this.lblServerOn = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components); this.timer1 = new System.Windows.Forms.Timer(this.components);
this.groupAxis.SuspendLayout(); this.groupAxis.SuspendLayout();
...@@ -132,9 +128,7 @@ ...@@ -132,9 +128,7 @@
this.groupBox2.Controls.Add(this.lblAxEncAcc); this.groupBox2.Controls.Add(this.lblAxEncAcc);
this.groupBox2.Controls.Add(this.lblINP); this.groupBox2.Controls.Add(this.lblINP);
this.groupBox2.Controls.Add(this.lblBUSY); this.groupBox2.Controls.Add(this.lblBUSY);
this.groupBox2.Controls.Add(this.lblNEL);
this.groupBox2.Controls.Add(this.lblORG); this.groupBox2.Controls.Add(this.lblORG);
this.groupBox2.Controls.Add(this.lblPEL);
this.groupBox2.Controls.Add(this.lblSvOn); this.groupBox2.Controls.Add(this.lblSvOn);
this.groupBox2.Controls.Add(this.lblEMG); this.groupBox2.Controls.Add(this.lblEMG);
this.groupBox2.Controls.Add(this.lblWARN); this.groupBox2.Controls.Add(this.lblWARN);
...@@ -169,7 +163,6 @@ ...@@ -169,7 +163,6 @@
this.lblAlarmcode.Tag = "not"; this.lblAlarmcode.Tag = "not";
this.lblAlarmcode.Text = "ErrCode:160"; this.lblAlarmcode.Text = "ErrCode:160";
this.lblAlarmcode.Visible = false; this.lblAlarmcode.Visible = false;
this.lblAlarmcode.Click += new System.EventHandler(this.lblAlarmcode_Click);
// //
// label4 // label4
// //
...@@ -218,9 +211,9 @@ ...@@ -218,9 +211,9 @@
// lblINP // lblINP
// //
this.lblINP.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.lblINP.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblINP.Location = new System.Drawing.Point(414, 24); this.lblINP.Location = new System.Drawing.Point(388, 24);
this.lblINP.Name = "lblINP"; this.lblINP.Name = "lblINP";
this.lblINP.Size = new System.Drawing.Size(56, 30); this.lblINP.Size = new System.Drawing.Size(70, 30);
this.lblINP.TabIndex = 10; this.lblINP.TabIndex = 10;
this.lblINP.Text = "到位"; this.lblINP.Text = "到位";
this.lblINP.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.lblINP.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
...@@ -228,49 +221,29 @@ ...@@ -228,49 +221,29 @@
// lblBUSY // lblBUSY
// //
this.lblBUSY.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.lblBUSY.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblBUSY.Location = new System.Drawing.Point(356, 24); this.lblBUSY.Location = new System.Drawing.Point(312, 24);
this.lblBUSY.Name = "lblBUSY"; this.lblBUSY.Name = "lblBUSY";
this.lblBUSY.Size = new System.Drawing.Size(56, 30); this.lblBUSY.Size = new System.Drawing.Size(70, 30);
this.lblBUSY.TabIndex = 9; this.lblBUSY.TabIndex = 9;
this.lblBUSY.Text = "忙碌"; this.lblBUSY.Text = "忙碌";
this.lblBUSY.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.lblBUSY.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
// //
// lblNEL
//
this.lblNEL.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblNEL.Location = new System.Drawing.Point(298, 24);
this.lblNEL.Name = "lblNEL";
this.lblNEL.Size = new System.Drawing.Size(56, 30);
this.lblNEL.TabIndex = 8;
this.lblNEL.Text = "负极限";
this.lblNEL.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblORG // lblORG
// //
this.lblORG.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.lblORG.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblORG.Location = new System.Drawing.Point(240, 24); this.lblORG.Location = new System.Drawing.Point(236, 24);
this.lblORG.Name = "lblORG"; this.lblORG.Name = "lblORG";
this.lblORG.Size = new System.Drawing.Size(56, 30); this.lblORG.Size = new System.Drawing.Size(70, 30);
this.lblORG.TabIndex = 7; this.lblORG.TabIndex = 7;
this.lblORG.Text = "原点"; this.lblORG.Text = "原点";
this.lblORG.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.lblORG.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
// //
// lblPEL
//
this.lblPEL.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblPEL.Location = new System.Drawing.Point(182, 24);
this.lblPEL.Name = "lblPEL";
this.lblPEL.Size = new System.Drawing.Size(56, 30);
this.lblPEL.TabIndex = 6;
this.lblPEL.Text = "正极限";
this.lblPEL.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblSvOn // lblSvOn
// //
this.lblSvOn.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.lblSvOn.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblSvOn.Location = new System.Drawing.Point(8, 24); this.lblSvOn.Location = new System.Drawing.Point(8, 24);
this.lblSvOn.Name = "lblSvOn"; this.lblSvOn.Name = "lblSvOn";
this.lblSvOn.Size = new System.Drawing.Size(56, 30); this.lblSvOn.Size = new System.Drawing.Size(70, 30);
this.lblSvOn.TabIndex = 5; this.lblSvOn.TabIndex = 5;
this.lblSvOn.Text = "伺服"; this.lblSvOn.Text = "伺服";
this.lblSvOn.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.lblSvOn.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
...@@ -278,9 +251,9 @@ ...@@ -278,9 +251,9 @@
// lblEMG // lblEMG
// //
this.lblEMG.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.lblEMG.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblEMG.Location = new System.Drawing.Point(124, 24); this.lblEMG.Location = new System.Drawing.Point(160, 24);
this.lblEMG.Name = "lblEMG"; this.lblEMG.Name = "lblEMG";
this.lblEMG.Size = new System.Drawing.Size(56, 30); this.lblEMG.Size = new System.Drawing.Size(70, 30);
this.lblEMG.TabIndex = 4; this.lblEMG.TabIndex = 4;
this.lblEMG.Text = "急停"; this.lblEMG.Text = "急停";
this.lblEMG.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.lblEMG.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
...@@ -288,9 +261,9 @@ ...@@ -288,9 +261,9 @@
// lblWARN // lblWARN
// //
this.lblWARN.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.lblWARN.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblWARN.Location = new System.Drawing.Point(472, 24); this.lblWARN.Location = new System.Drawing.Point(464, 24);
this.lblWARN.Name = "lblWARN"; this.lblWARN.Name = "lblWARN";
this.lblWARN.Size = new System.Drawing.Size(56, 30); this.lblWARN.Size = new System.Drawing.Size(70, 30);
this.lblWARN.TabIndex = 3; this.lblWARN.TabIndex = 3;
this.lblWARN.Text = "警告"; this.lblWARN.Text = "警告";
this.lblWARN.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.lblWARN.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
...@@ -298,9 +271,9 @@ ...@@ -298,9 +271,9 @@
// lblALM // lblALM
// //
this.lblALM.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.lblALM.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblALM.Location = new System.Drawing.Point(66, 24); this.lblALM.Location = new System.Drawing.Point(84, 24);
this.lblALM.Name = "lblALM"; this.lblALM.Name = "lblALM";
this.lblALM.Size = new System.Drawing.Size(56, 30); this.lblALM.Size = new System.Drawing.Size(70, 30);
this.lblALM.TabIndex = 2; this.lblALM.TabIndex = 2;
this.lblALM.Text = "报警"; this.lblALM.Text = "报警";
this.lblALM.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.lblALM.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
...@@ -592,9 +565,7 @@ ...@@ -592,9 +565,7 @@
this.panel1.Controls.Add(this.txtAPosition); this.panel1.Controls.Add(this.txtAPosition);
this.panel1.Controls.Add(this.label46); this.panel1.Controls.Add(this.label46);
this.panel1.Controls.Add(this.label48); this.panel1.Controls.Add(this.label48);
this.panel1.Controls.Add(this.label45);
this.panel1.Controls.Add(this.txtAxisValue); this.panel1.Controls.Add(this.txtAxisValue);
this.panel1.Controls.Add(this.txtAxisDeviceName);
this.panel1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.panel1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.panel1.Location = new System.Drawing.Point(7, 17); this.panel1.Location = new System.Drawing.Point(7, 17);
this.panel1.Name = "panel1"; this.panel1.Name = "panel1";
...@@ -875,7 +846,7 @@ ...@@ -875,7 +846,7 @@
// //
this.label46.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label46.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label46.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; this.label46.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label46.Location = new System.Drawing.Point(6, 93); this.label46.Location = new System.Drawing.Point(4, 54);
this.label46.Name = "label46"; this.label46.Name = "label46";
this.label46.Size = new System.Drawing.Size(71, 17); this.label46.Size = new System.Drawing.Size(71, 17);
this.label46.TabIndex = 239; this.label46.TabIndex = 239;
...@@ -896,21 +867,10 @@ ...@@ -896,21 +867,10 @@
this.label48.Text = "目标位置:"; this.label48.Text = "目标位置:";
this.label48.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.label48.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
// //
// label45
//
this.label45.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label45.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label45.Location = new System.Drawing.Point(8, 53);
this.label45.Name = "label45";
this.label45.Size = new System.Drawing.Size(69, 20);
this.label45.TabIndex = 240;
this.label45.Text = "端口号:";
this.label45.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// txtAxisValue // txtAxisValue
// //
this.txtAxisValue.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.txtAxisValue.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtAxisValue.Location = new System.Drawing.Point(83, 87); this.txtAxisValue.Location = new System.Drawing.Point(81, 48);
this.txtAxisValue.MaxLength = 10; this.txtAxisValue.MaxLength = 10;
this.txtAxisValue.Name = "txtAxisValue"; this.txtAxisValue.Name = "txtAxisValue";
this.txtAxisValue.ReadOnly = true; this.txtAxisValue.ReadOnly = true;
...@@ -919,18 +879,6 @@ ...@@ -919,18 +879,6 @@
this.txtAxisValue.Tag = "not"; this.txtAxisValue.Tag = "not";
this.txtAxisValue.Text = "0"; this.txtAxisValue.Text = "0";
// //
// txtAxisDeviceName
//
this.txtAxisDeviceName.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtAxisDeviceName.Location = new System.Drawing.Point(83, 48);
this.txtAxisDeviceName.MaxLength = 10;
this.txtAxisDeviceName.Name = "txtAxisDeviceName";
this.txtAxisDeviceName.ReadOnly = true;
this.txtAxisDeviceName.Size = new System.Drawing.Size(50, 26);
this.txtAxisDeviceName.TabIndex = 241;
this.txtAxisDeviceName.Tag = "not";
this.txtAxisDeviceName.Text = "0";
//
// lblServerOn // lblServerOn
// //
this.lblServerOn.AutoSize = true; this.lblServerOn.AutoSize = true;
...@@ -995,8 +943,6 @@ ...@@ -995,8 +943,6 @@
internal System.Windows.Forms.Label label48; internal System.Windows.Forms.Label label48;
internal System.Windows.Forms.Button btnAxisStop; internal System.Windows.Forms.Button btnAxisStop;
private System.Windows.Forms.TextBox txtAxisValue; private System.Windows.Forms.TextBox txtAxisValue;
private System.Windows.Forms.TextBox txtAxisDeviceName;
private System.Windows.Forms.Label label45;
private System.Windows.Forms.Label label46; private System.Windows.Forms.Label label46;
private System.Windows.Forms.Label label49; private System.Windows.Forms.Label label49;
private System.Windows.Forms.Label label24; private System.Windows.Forms.Label label24;
...@@ -1019,9 +965,7 @@ ...@@ -1019,9 +965,7 @@
private System.Windows.Forms.Label lblAxEncAcc; private System.Windows.Forms.Label lblAxEncAcc;
private System.Windows.Forms.Label lblINP; private System.Windows.Forms.Label lblINP;
private System.Windows.Forms.Label lblBUSY; private System.Windows.Forms.Label lblBUSY;
private System.Windows.Forms.Label lblNEL;
private System.Windows.Forms.Label lblORG; private System.Windows.Forms.Label lblORG;
private System.Windows.Forms.Label lblPEL;
private System.Windows.Forms.Label lblSvOn; private System.Windows.Forms.Label lblSvOn;
private System.Windows.Forms.Label lblEMG; private System.Windows.Forms.Label lblEMG;
private System.Windows.Forms.Label lblWARN; private System.Windows.Forms.Label lblWARN;
......
...@@ -26,9 +26,6 @@ namespace DeviceLibrary ...@@ -26,9 +26,6 @@ namespace DeviceLibrary
public AxisMoveControl() public AxisMoveControl()
{ {
InitializeComponent(); InitializeComponent();
if (DesignMode)
return;
this.Tag = "not";
crc.OpenResourceLog = true; crc.OpenResourceLog = true;
crc.LanguageChangeEvent += Crc_LanguageChangeEvent; crc.LanguageChangeEvent += Crc_LanguageChangeEvent;
crc.CurrLanguage = Setting_Init.Device_Default_Language; crc.CurrLanguage = Setting_Init.Device_Default_Language;
...@@ -56,7 +53,7 @@ namespace DeviceLibrary ...@@ -56,7 +53,7 @@ namespace DeviceLibrary
currentAxis = axisList[0]; currentAxis = axisList[0];
PortName = axisList[0].Config.DeviceName; PortName = axisList[0].Config.DeviceName;
SlvAddr = axisList[0].Config.GetAxisValue(); SlvAddr = axisList[0].Config.GetAxisValue();
txtAxisDeviceName.Text = PortName; //txtAxisDeviceName.Text = PortName;
txtAxisValue.Text = SlvAddr.ToString(); txtAxisValue.Text = SlvAddr.ToString();
} }
btnAddMove.BackColor = Color.White; btnAddMove.BackColor = Color.White;
...@@ -227,7 +224,7 @@ namespace DeviceLibrary ...@@ -227,7 +224,7 @@ namespace DeviceLibrary
axis = axisList[cmbAxis.SelectedIndex].Config; axis = axisList[cmbAxis.SelectedIndex].Config;
PortName = axis.DeviceName; PortName = axis.DeviceName;
SlvAddr = axis.GetAxisValue(); SlvAddr = axis.GetAxisValue();
txtAxisDeviceName.Text = PortName; //txtAxisDeviceName.Text = PortName;
txtAxisValue.Text = SlvAddr.ToString(); txtAxisValue.Text = SlvAddr.ToString();
Color color = Color.Black; Color color = Color.Black;
...@@ -348,15 +345,15 @@ namespace DeviceLibrary ...@@ -348,15 +345,15 @@ namespace DeviceLibrary
private void timer1_Tick(object sender, EventArgs e) private void timer1_Tick(object sender, EventArgs e)
{ {
//LogUtil.OutputDebugString($"timer1_Tick:{this.Visible}"); LogUtil.OutputDebugString($"timer1_Tick:{this.Visible}");
if (this.Visible && !DesignMode) if (this.Visible)
{ {
ReadAxisStatus(); ReadAxisStatus();
} }
} }
private void ReadAxisStatus() private void ReadAxisStatus()
{ {
groupBox2.Text = cmbAxis.Text + "-"+crc.GetString("Res0189","状态监控"); groupBox2.Text = cmbAxis.Text + "-" + crc.GetString("AxisMoveControl_groupAxis_groupBox2_Text","状态监控");
//【1】更新轴号 //【1】更新轴号
short axisNo = SlvAddr; short axisNo = SlvAddr;
if (axisNo < 0) if (axisNo < 0)
...@@ -396,9 +393,9 @@ namespace DeviceLibrary ...@@ -396,9 +393,9 @@ namespace DeviceLibrary
{ {
return; return;
} }
ShowlbSts(lblPEL, sts.PEL); //正限位信号 //ShowlbSts(lblPEL, sts.PEL); //正限位信号
ShowlbSts(lblORG, sts.ORG); //原点信号 ShowlbSts(lblORG, sts.ORG); //原点信号
ShowlbSts(lblNEL, sts.NEL); //负限位信号 //ShowlbSts(lblNEL, sts.NEL); //负限位信号
//label59.Text = ConvertDecimalToBinary(nTimerAxSts[0]); //轴状态是按bit进行解读,因此这里将AxSts转换为二进制bit进行显示 //label59.Text = ConvertDecimalToBinary(nTimerAxSts[0]); //轴状态是按bit进行解读,因此这里将AxSts转换为二进制bit进行显示
lblAxPrfPos.Text = HCBoardManager.GetAxisPrfPos(axisNo).ToString(); lblAxPrfPos.Text = HCBoardManager.GetAxisPrfPos(axisNo).ToString();
...@@ -447,12 +444,5 @@ namespace DeviceLibrary ...@@ -447,12 +444,5 @@ namespace DeviceLibrary
lbl.BackColor = this.BackColor; lbl.BackColor = this.BackColor;
} }
} }
private void lblAlarmcode_Click(object sender, EventArgs e)
{
var s = string.Join(",", HuichuanLibrary.HCBoardManager.GetAxisErrorDetail(SlvAddr));
MessageBox.Show(s);
LogUtil.error(s);
}
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -206,7 +206,36 @@ public class ReelParam ...@@ -206,7 +206,36 @@ public class ReelParam
return $":[{PosID}][{WareCode}][{RFID}][{PlateW}x{PlateH}]"; return $":[{PosID}][{WareCode}][{RFID}][{PlateW}x{PlateH}]";
} }
} }
bool islog = false;
public void logresult()
{
if (!islog)
{
islog = true;
var datetime = DateTime.Now;
string countfile = $"\\Logs\\NGLOG_{datetime:yyyyMMdd}.csv";
Directory.CreateDirectory("\\Logs\\");
if (!File.Exists(countfile))
{
StreamWriter sw1 = new StreamWriter(countfile, true, Encoding.GetEncoding("GB2312"));
sw1.WriteLine($"WareCode,SN,PN,Date,NgMsg");
sw1.Close();
sw1.Dispose();
}
try
{
var sw = new StreamWriter(countfile, true, Encoding.GetEncoding("GB2312"));
//var sw = File.Open(countfile, FileMode.Append, FileAccess.Write);
// string s = $"\r\n{ReeID},{PN},{PlateW}x{PlateH},{ReelDest},{NgMsg},{QTY},{WareCode}";
//var b = Encoding.GetEncoding("gb2312").GetBytes(s);
//sw.Write(b, 0, b.Length);
sw.WriteLine($"{WareCode},{RI},{PN},{datetime:yyyy/MM/dd HH:mm:ss},{NgMsg}");
sw.Close();
sw.Dispose();
}
catch { }
}
}
} }
public enum DoorStatusE { public enum DoorStatusE {
Busy, Busy,
......
...@@ -46,7 +46,7 @@ public class RemoteClient ...@@ -46,7 +46,7 @@ public class RemoteClient
{ {
if (LastState != webSocket.State) if (LastState != webSocket.State)
{ {
LOGGER.Info($"Remote:{GroupName} 掉线了"); LOGGER.Error($"Remote:{GroupName} 掉线了");
} }
LastState = webSocket.State; LastState = webSocket.State;
} }
...@@ -68,7 +68,7 @@ public class RemoteClient ...@@ -68,7 +68,7 @@ public class RemoteClient
else if (webSocket.State == WebSocket4Net.WebSocketState.Connecting) { else if (webSocket.State == WebSocket4Net.WebSocketState.Connecting) {
errstatuscounr++; errstatuscounr++;
if (errstatuscounr > 5) { if (errstatuscounr > 5) {
LOGGER.Info($"Remote:{GroupName} Connecting 超时"); LOGGER.Error($"Remote:{GroupName} Connecting 超时");
try { webSocket.Close(); } catch { } try { webSocket.Close(); } catch { }
webSocket.Open(); webSocket.Open();
errstatuscounr = 0; errstatuscounr = 0;
...@@ -87,7 +87,7 @@ public class RemoteClient ...@@ -87,7 +87,7 @@ public class RemoteClient
} }
catch catch
{ {
LOGGER.Info("Cant Deserialize remote command:" + e.Message); LOGGER.Error("Cant Deserialize remote command:" + e.Message);
return; return;
} }
switch (remoteLoad.Action) switch (remoteLoad.Action)
...@@ -124,7 +124,7 @@ public class RemoteClient ...@@ -124,7 +124,7 @@ public class RemoteClient
} }
if (lastresult == RemoteResult.None) if (lastresult == RemoteResult.None)
{ {
LOGGER.Info("等待远程反馈超时"); LOGGER.Error("等待远程反馈超时");
timeoutCount++; timeoutCount++;
lastresult = RemoteResult.Timeout; lastresult = RemoteResult.Timeout;
if (timeoutCount > 3) if (timeoutCount > 3)
......
...@@ -94,6 +94,7 @@ ...@@ -94,6 +94,7 @@
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RemoteClient.cs" /> <Compile Include="RemoteClient.cs" />
<Compile Include="SLog.cs" /> <Compile Include="SLog.cs" />
<Compile Include="Snowflake.cs" />
<Compile Include="StoreCID.cs" /> <Compile Include="StoreCID.cs" />
<Compile Include="TheLine.cs" /> <Compile Include="TheLine.cs" />
</ItemGroup> </ItemGroup>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace RemoteSheardObject
{
/// <summary>
/// 动态生产有规律的ID Snowflake算法是Twitter的工程师为实现递增而不重复的ID实现的
/// http://blog.csdn.net/w200221626/article/details/52064976
/// C# 实现 Snowflake算法
/// </summary>
public class Snowflake
{
private static long machineId;//机器ID
private static long datacenterId = 0L;//数据ID
private static long sequence = 0L;//计数从零开始
private static long twepoch = 687888001020L; //唯一时间随机量
private static long machineIdBits = 5L; //机器码字节数
private static long datacenterIdBits = 5L;//数据字节数
public static long maxMachineId = -1L ^ -1L << (int)machineIdBits; //最大机器ID
private static long maxDatacenterId = -1L ^ (-1L << (int)datacenterIdBits);//最大数据ID
private static long sequenceBits = 12L; //计数器字节数,12个字节用来保存计数码
private static long machineIdShift = sequenceBits; //机器码数据左移位数,就是后面计数器占用的位数
private static long datacenterIdShift = sequenceBits + machineIdBits;
private static long timestampLeftShift = sequenceBits + machineIdBits + datacenterIdBits; //时间戳左移动位数就是机器码+计数器总字节数+数据字节数
public static long sequenceMask = -1L ^ -1L << (int)sequenceBits; //一微秒内可以产生计数,如果达到该值则等到下一微妙在进行生成
private static long lastTimestamp = -1L;//最后时间戳
private static object syncRoot = new object();//加锁对象
static Snowflake snowflake;
public static Snowflake Instance()
{
if (snowflake == null)
snowflake = new Snowflake();
return snowflake;
}
public Snowflake()
{
Snowflakes(0L, -1);
}
public Snowflake(long machineId)
{
Snowflakes(machineId, -1);
}
public Snowflake(long machineId, long datacenterId)
{
Snowflakes(machineId, datacenterId);
}
private void Snowflakes(long machineId, long datacenterId)
{
if (machineId >= 0)
{
if (machineId > maxMachineId)
{
throw new Exception("机器码ID非法");
}
Snowflake.machineId = machineId;
}
if (datacenterId >= 0)
{
if (datacenterId > maxDatacenterId)
{
throw new Exception("数据中心ID非法");
}
Snowflake.datacenterId = datacenterId;
}
}
/// <summary>
/// 生成当前时间戳
/// </summary>
/// <returns>毫秒</returns>
private static long GetTimestamp()
{
//让他2000年开始
return (long)(DateTime.UtcNow - new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;
}
/// <summary>
/// 获取下一微秒时间戳
/// </summary>
/// <param name="lastTimestamp"></param>
/// <returns></returns>
private static long GetNextTimestamp(long lastTimestamp)
{
long timestamp = GetTimestamp();
int count = 0;
while (timestamp <= lastTimestamp)//这里获取新的时间,可能会有错,这算法与comb一样对机器时间的要求很严格
{
count++;
if (count > 10)
throw new Exception("机器的时间可能不对");
Thread.Sleep(1);
timestamp = GetTimestamp();
}
return timestamp;
}
/// <summary>
/// 获取长整形的ID
/// </summary>
/// <returns></returns>
public long GetId()
{
lock (syncRoot)
{
long timestamp = GetTimestamp();
if (Snowflake.lastTimestamp == timestamp)
{ //同一微妙中生成ID
sequence = (sequence + 1) & sequenceMask; //用&运算计算该微秒内产生的计数是否已经到达上限
if (sequence == 0)
{
//一微妙内产生的ID计数已达上限,等待下一微妙
timestamp = GetNextTimestamp(Snowflake.lastTimestamp);
}
}
else
{
//不同微秒生成ID
sequence = 0L;
}
if (timestamp < lastTimestamp)
{
throw new Exception("时间戳比上一次生成ID时时间戳还小,故异常");
}
Snowflake.lastTimestamp = timestamp; //把当前时间戳保存为最后生成ID的时间戳
long Id = ((timestamp - twepoch) << (int)timestampLeftShift)
| (datacenterId << (int)datacenterIdShift)
| (machineId << (int)machineIdShift)
| sequence;
return Id;
}
}
}
}
using ConfigHelper; using ConfigHelper;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -33,6 +33,10 @@ namespace RemoteSheardObject ...@@ -33,6 +33,10 @@ namespace RemoteSheardObject
return !string.IsNullOrEmpty(SubmitPostData("/service/store/robotBox/updateLocInfo", postData)); return !string.IsNullOrEmpty(SubmitPostData("/service/store/robotBox/updateLocInfo", postData));
} }
/// <summary>
/// 获取正在进行的任务数量
/// </summary>
/// <returns></returns>
public static Dictionary<string,int> GetTaskCount() public static Dictionary<string,int> GetTaskCount()
{ {
//pizzaBox,pcb,tray,reel //pizzaBox,pcb,tray,reel
...@@ -46,13 +50,13 @@ namespace RemoteSheardObject ...@@ -46,13 +50,13 @@ namespace RemoteSheardObject
taskdata["reel"] = 0; taskdata["reel"] = 0;
var result= JsonConvert.DeserializeObject<ResultData>(SubmitPostData("/rest/micron/device/getTaskCount", postData)); var result= JsonConvert.DeserializeObject<ResultData>(SubmitPostData("/rest/micron/device/getTaskCount", postData));
if (result.code != 0) if (result==null || result.code != 0)
return taskdata; return taskdata;
foreach (var k in taskdata.Keys) foreach (var k in taskdata.Keys.ToArray())
{ {
if (result.data.ContainsKey(k)) if (result.data.ContainsKey(k+"_out"))
taskdata[k] = int.Parse(result.data[k]); taskdata[k] = int.Parse(result.data[k + "_out"]);
} }
return taskdata; return taskdata;
} }
...@@ -129,7 +133,8 @@ namespace RemoteSheardObject ...@@ -129,7 +133,8 @@ namespace RemoteSheardObject
} }
//去掉最后一个"&"符号 //去掉最后一个"&"符号
postDataString.Length--; if (postDataString.Length>0)
postDataString.Length--;
//将POST请求参数转换为字节数组 //将POST请求参数转换为字节数组
byte[] bytes = Encoding.UTF8.GetBytes(postDataString.ToString()); byte[] bytes = Encoding.UTF8.GetBytes(postDataString.ToString());
...@@ -144,7 +149,7 @@ namespace RemoteSheardObject ...@@ -144,7 +149,7 @@ namespace RemoteSheardObject
catch (Exception ex) catch (Exception ex)
{ {
// 捕获任何网络异常,并输出错误信息 // 捕获任何网络异常,并输出错误信息
Console.WriteLine("提交POST请求时发生错误:" + ex.Message); //Console.WriteLine(crc.GetString("Res0071","提交POST请求时发生错误:") + ex.Message);
// 请求失败,返回false // 请求失败,返回false
return ""; return "";
...@@ -152,4 +157,4 @@ namespace RemoteSheardObject ...@@ -152,4 +157,4 @@ namespace RemoteSheardObject
} }
} }
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -58,7 +58,14 @@ namespace TheMachine ...@@ -58,7 +58,14 @@ namespace TheMachine
{ {
e.Cancel = true; e.Cancel = true;
this.WindowState = FormWindowState.Minimized; this.WindowState = FormWindowState.Minimized;
return;
} }
LogUtil.info("系统强制退出应用 step1");
btn_stop_Click(sender, EventArgs.Empty);
Thread.Sleep(2000);
LogUtil.info("系统强制退出应用 step2");
Application.Exit();
LogUtil.info("系统强制退出应用 step3");
} }
//LogControl lc = new LogControl(); //LogControl lc = new LogControl();
...@@ -355,18 +362,7 @@ namespace TheMachine ...@@ -355,18 +362,7 @@ namespace TheMachine
{ {
if (!RobotManage.isRunning) if (!RobotManage.isRunning)
{ {
//if (RobotManage.mainMachine.IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW))
//{
// RobotManage.mainMachine.Msg.add(crc.GetString("Res0017","急停中,无法启动"), MsgLevel.warning);
// RobotManage.mainMachine.Msg.Show();
// //return;
//}
//if (RobotManage.mainMachine.IOValue(IO_Type.AutoRun_Single).Equals(IO_VALUE.LOW))
//{
// RobotManage.mainMachine.Msg.add(crc.GetString("Res0018","运行开关没有打开,无法启动"), MsgLevel.warning);
// RobotManage.mainMachine.Msg.Show();
// //return;
//}
LogUtil.info("用户按下启动:"+ sender.ToString()); LogUtil.info("用户按下启动:"+ sender.ToString());
RobotManage.Start(); RobotManage.Start();
userpause = false; userpause = false;
......
using ConfigHelper; using ConfigHelper;
using log4net.Config; using log4net.Config;
using Microsoft.Win32.TaskScheduler;
using OnlineStore.Common; using OnlineStore.Common;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -46,8 +47,7 @@ namespace TheMachine ...@@ -46,8 +47,7 @@ namespace TheMachine
} }
} }
} }
Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true).SetValue(Application.ProductName, Application.ExecutablePath); AddOrUpdateStartupTask();
Config.LoadMyConfig(new Setting_Init().GetType()); Config.LoadMyConfig(new Setting_Init().GetType());
Application.ThreadException += Application_ThreadException; Application.ThreadException += Application_ThreadException;
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
...@@ -103,6 +103,43 @@ namespace TheMachine ...@@ -103,6 +103,43 @@ namespace TheMachine
public const int SW_RESTORE = 9; public const int SW_RESTORE = 9;
#endregion #endregion
public static void AddOrUpdateStartupTask()
{
// 获取当前程序的路径和名称
string appPath = Process.GetCurrentProcess().MainModule.FileName;
string TaskName = "AutoStartup_" + Process.GetCurrentProcess().MainModule.ModuleName;
// 创建或更新计划任务
using (TaskService taskService = new TaskService())
{
// 获取任务定义,如果不存在则创建新的任务定义
TaskDefinition taskDefinition;
if (taskService.GetTask(TaskName) != null)
{
taskDefinition = taskService.GetTask(TaskName).Definition;
}
else
{
taskDefinition = taskService.NewTask();
taskDefinition.RegistrationInfo.Description = TaskName;
}
if (taskDefinition.Triggers.Count == 0 || taskDefinition.Triggers[0].TriggerType != TaskTriggerType.Logon)
{
// 设置触发器为用户登录后启动
LogonTrigger logonTrigger = (LogonTrigger)taskDefinition.Triggers.Add(new LogonTrigger());
logonTrigger.Delay = TimeSpan.FromSeconds(5);
}
// 设置操作为启动应用程序
taskDefinition.Actions.Clear();
taskDefinition.Actions.Add(new ExecAction(appPath, null, System.IO.Path.GetDirectoryName(appPath)));
// 设置任务的运行权限为管理员权限
taskDefinition.Principal.RunLevel = TaskRunLevel.Highest;
// 保存任务
taskService.RootFolder.RegisterTaskDefinition(TaskName, taskDefinition, TaskCreation.CreateOrUpdate, null, null, TaskLogonType.InteractiveToken, null);
}
}
} }
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<ProjectGuid>{61FDFF14-8BB7-439A-85A0-592E3011F4C4}</ProjectGuid> <ProjectGuid>{61FDFF14-8BB7-439A-85A0-592E3011F4C4}</ProjectGuid>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<RootNamespace>TheMachine</RootNamespace> <RootNamespace>TheMachine</RootNamespace>
<AssemblyName>CycleLine</AssemblyName> <AssemblyName>MT</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
...@@ -60,6 +60,9 @@ ...@@ -60,6 +60,9 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\增广夹爪\Rmaxis\bin\Debug\log4net.dll</HintPath> <HintPath>..\..\增广夹爪\Rmaxis\bin\Debug\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.Win32.TaskScheduler, Version=2.10.1.0, Culture=neutral, PublicKeyToken=e25603a88b3aa7da, processorArchitecture=MSIL">
<HintPath>..\packages\TaskScheduler.2.10.1\lib\net452\Microsoft.Win32.TaskScheduler.dll</HintPath>
</Reference>
<Reference Include="Neotel.Rmaxis"> <Reference Include="Neotel.Rmaxis">
<HintPath>..\..\增广夹爪\Rmaxis\bin\Debug\Neotel.Rmaxis.dll</HintPath> <HintPath>..\..\增广夹爪\Rmaxis\bin\Debug\Neotel.Rmaxis.dll</HintPath>
</Reference> </Reference>
...@@ -68,6 +71,7 @@ ...@@ -68,6 +71,7 @@
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
...@@ -292,6 +296,7 @@ ...@@ -292,6 +296,7 @@
<DependentUpon>uc_boxdebug.cs</DependentUpon> <DependentUpon>uc_boxdebug.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<None Include="app.manifest" /> <None Include="app.manifest" />
<None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />
......
...@@ -145,9 +145,12 @@ namespace TheMachine ...@@ -145,9 +145,12 @@ namespace TheMachine
listView1.Items[ti.RFID].ForeColor = Color.DarkGray; listView1.Items[ti.RFID].ForeColor = Color.DarkGray;
else else
listView1.Items[ti.RFID].ForeColor = Color.Black; listView1.Items[ti.RFID].ForeColor = Color.Black;
if (ti.HasLoad && ti.TrayParam.IsNg) {
listView1.Items[ti.RFID].ForeColor = Color.Orange;
}
if (ti.HasLoad && ti.HasLoadCheck<0) if (ti.HasLoad && ti.HasLoadCheck<0)
listView1.Items[ti.RFID].ForeColor = Color.Red; listView1.Items[ti.RFID].ForeColor = Color.Red;
} }
ListView2.Items.Clear(); ListView2.Items.Clear();
foreach (var tivk in TrayManager.TrayRequest.ToArray()) foreach (var tivk in TrayManager.TrayRequest.ToArray())
...@@ -181,13 +184,15 @@ namespace TheMachine ...@@ -181,13 +184,15 @@ namespace TheMachine
gb_trayinfo.Visible = false; gb_trayinfo.Visible = false;
return; return;
} }
var ti = TrayManager.Traylist[listView1.SelectedItems[0].Text];
string txt = "RFID" + ": " + listView1.SelectedItems[0].Text; string txt = "RFID" + ": " + listView1.SelectedItems[0].Text;
txt += "\r\n"+crc.GetString("Res0021","托盘类型") + ": " + listView1.SelectedItems[0].SubItems[2].Text; txt += "\r\n"+crc.GetString("Res0021","托盘类型") + ": " + listView1.SelectedItems[0].SubItems[2].Text;
txt += "\r\n"+crc.GetString("Res0055","物料") + ": " + listView1.SelectedItems[0].SubItems[3].Text; txt += "\r\n"+crc.GetString("Res0055","物料") + ": " + listView1.SelectedItems[0].SubItems[3].Text;
txt += "\r\n"+crc.GetString("Res0023","目的地") + ": " + listView1.SelectedItems[0].SubItems[4].Text; txt += "\r\n"+crc.GetString("Res0023","目的地") + ": " + listView1.SelectedItems[0].SubItems[4].Text;
txt += "\r\n"+"Code" + ": " + listView1.SelectedItems[0].SubItems[6].Text; txt += "\r\n"+"Code" + ": " + listView1.SelectedItems[0].SubItems[6].Text;
if (ti.HasLoad && ti.TrayParam.IsNg) {
txt += "\r\n" + "NgMsg" + ": " + ti.TrayParam.NgMsg;
}
lbl_info.Text = txt; lbl_info.Text = txt;
gb_trayinfo.Visible = true; gb_trayinfo.Visible = true;
} }
......
using DeviceLibrary; using DeviceLibrary;
using OnlineStore; using OnlineStore;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -75,8 +75,8 @@ namespace TheMachine.device.Other ...@@ -75,8 +75,8 @@ namespace TheMachine.device.Other
{ {
stateView.Items.Clear(); stateView.Items.Clear();
foreach (var store in VStoreCollection.VStoreList.Values.ToList()) { foreach (var store in VStoreCollection.VStoreList.Values.ToList()) {
ListViewItem lvi = new ListViewItem(new string[] { "", store.CID, store.RTStoreStatus.ToString(), store.GetStateStr() }); ListViewItem lvi = new ListViewItem(new string[] { "", TowerList.List[store.CID].TowerName+"-"+store.CID, store.RTStoreStatus.ToString(), store.GetStateStr() });
stateView.Items.Add(lvi); stateView.Items.Add(lvi);
} }
} }
...@@ -85,11 +85,11 @@ namespace TheMachine.device.Other ...@@ -85,11 +85,11 @@ namespace TheMachine.device.Other
{ {
if (RobotManage.isRunning) if (RobotManage.isRunning)
{ {
MessageBox.Show("请先停止系统运行"); MessageBox.Show(crc.GetString("Res0072","请先停止系统运行"));
return; return;
} }
MI.DeviceList["AMH-MI1"]. MI.DeviceList["AMH-MI1"].Reset();
} }
} }
} }
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="TaskScheduler" version="2.10.1" targetFramework="net461" />
</packages>
\ No newline at end of file \ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!