Commit 4925708c LN

皮带线停止增加事件触发。

1 个父辈 164fd4bf
...@@ -446,6 +446,7 @@ namespace OnlineStore.AssemblyLine ...@@ -446,6 +446,7 @@ namespace OnlineStore.AssemblyLine
MessageBox.Show("已复制日志到粘贴板!"); MessageBox.Show("已复制日志到粘贴板!");
} }
private DateTime lastLogTime = DateTime.Now; private DateTime lastLogTime = DateTime.Now;
PerformanceCounter curtime = null;
private void LogM() private void LogM()
{ {
try try
...@@ -454,24 +455,20 @@ namespace OnlineStore.AssemblyLine ...@@ -454,24 +455,20 @@ namespace OnlineStore.AssemblyLine
if (sp.TotalMinutes > 10) if (sp.TotalMinutes > 10)
{ {
lastLogTime = DateTime.Now; lastLogTime = DateTime.Now;
Process[] processes = Process.GetProcesses();
long totalMemery = 0; Process process = Process.GetCurrentProcess();
StringBuilder sbResult = new StringBuilder(); if (curtime == null)
var prevCpuTime = TimeSpan.Zero;
int interval = 1000;
foreach (Process process in processes)
{ {
if (process.ProcessName.EndsWith("AssemblyLine")) curtime = new PerformanceCounter("Process", "% Processor Time", process.ProcessName);
}
if (process != null)
{ {
sbResult.AppendFormat(DateTime.Now.ToLongTimeString() + ", 名称:{0} 内存:{1}M ", process.ProcessName, process.PrivateMemorySize64 / 1024 / 1024F); StringBuilder sbResult = new StringBuilder();
totalMemery += process.PrivateMemorySize64 / 1024; PerformanceCounter pf1 = new PerformanceCounter("Process", "Working Set - Private", process.ProcessName);
double value = (process.TotalProcessorTime - prevCpuTime).TotalMilliseconds / interval / Environment.ProcessorCount; sbResult.AppendFormat(DateTime.Now.ToLongTimeString() + ", 名称:{0} 内存:{1}M ", process.ProcessName, Math.Round(pf1.NextValue() / 1024 / 1024F, 2));
sbResult.AppendFormat(" CPU : " + Math.Round(value, 2) + "%"); sbResult.AppendFormat(", CPU : {0} %", curtime.NextValue());
// string result = string.Format("进程总数 {0} 个,共占内存:{1}MB \n", processes.Length, totalMemery / 1024) + sbResult.ToString();
LogUtil.info(sbResult.ToString()); LogUtil.info(sbResult.ToString());
} }
}
} }
} }
catch (Exception ex) catch (Exception ex)
......
...@@ -56,7 +56,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -56,7 +56,7 @@ namespace OnlineStore.DeviceLibrary
TrayLine1 = new OutTrayLineBean(330+ ((id - 1) * 3 + 1),"皮带线" + "_" + ((id - 1) * 3 + 1) + " ", IO_Type.ExitLocation_Check1, IO_Type.ExitTray_Check1, IO_Type.DLine_Run1, IO_Type.MiddleTray_Check3, this.DeviceID); TrayLine1 = new OutTrayLineBean(330+ ((id - 1) * 3 + 1),"皮带线" + "_" + ((id - 1) * 3 + 1) + " ", IO_Type.ExitLocation_Check1, IO_Type.ExitTray_Check1, IO_Type.DLine_Run1, IO_Type.MiddleTray_Check3, this.DeviceID);
TrayLine2 = new OutTrayLineBean(330+((id - 1) * 3 + 2),"皮带线" + "_" + ((id - 1) * 3 + 2) + " ", IO_Type.ExitLocation_Check2, IO_Type.ExitTray_Check2, IO_Type.DLine_Run2, IO_Type.EntryTray_Check3, this.DeviceID); TrayLine2 = new OutTrayLineBean(330+((id - 1) * 3 + 2),"皮带线" + "_" + ((id - 1) * 3 + 2) + " ", IO_Type.ExitLocation_Check2, IO_Type.ExitTray_Check2, IO_Type.DLine_Run2, IO_Type.EntryTray_Check3, this.DeviceID);
} }
Line3Turn = new LineTurnBean(DeviceID); Line3Turn = new LineTurnBean(DeviceID, IO_Type.DLine_Run3, IO_Type.Location_Check3);
if ((DeviceID % 100).Equals(1)) if ((DeviceID % 100).Equals(1))
{ {
Line3MaxPosition = 13; Line3MaxPosition = 13;
...@@ -423,7 +423,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -423,7 +423,7 @@ namespace OnlineStore.DeviceLibrary
//判断皮带三还有料盘,需要转动一个工位 //判断皮带三还有料盘,需要转动一个工位
UpdateLastP(); UpdateLastP();
LogUtil.debug(hengyiName + "空闲,且流水线还有料盘,转动一个工位"); LogUtil.debug(hengyiName + "空闲,且流水线还有料盘,转动一个工位");
Line3Turn.StartLineRun(IO_Type.DLine_Run3, IO_Type.Location_Check3, Line3EndProcess); Line3Turn.StartLineRun( Line3EndProcess);
} }
} }
private void UpdateLastP() private void UpdateLastP()
......
...@@ -318,7 +318,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -318,7 +318,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NextMoveStep(LineMoveStep.DON_05_LineRun); MoveInfo.NextMoveStep(LineMoveStep.DON_05_LineRun);
LogUtil.info(hengyiName + MoveInfo.SLog + "送料,NG->接驳台,转动接驳台皮带"); LogUtil.info(hengyiName + MoveInfo.SLog + "送料,NG->接驳台,转动接驳台皮带");
// IOMove(IO_Type.SeparateDevice_Run, IO_VALUE.HIGH); // IOMove(IO_Type.SeparateDevice_Run, IO_VALUE.HIGH);
Line3Turn.StartLineRun(IO_Type.DLine_Run3, IO_Type.Location_Check3, Line3EndProcess); Line3Turn.StartLineRun( Line3EndProcess);
SeparateLineRun(MoveInfo); SeparateLineRun(MoveInfo);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000)); MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Location_Check3, IO_VALUE.HIGH)); MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Location_Check3, IO_VALUE.HIGH));
......
...@@ -202,17 +202,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -202,17 +202,8 @@ namespace OnlineStore.DeviceLibrary
if (!(oldList[i].Equals(newList[i]))) if (!(oldList[i].Equals(newList[i])))
{ {
needUpdate = true; needUpdate = true;
//if (IsAxisCheckDI(ip, i))
//{
// // LogUtil.info("AIOBOXManager UpdateDI [" + ip + "][" + i + "],从" + oldList[i] + "变为" + newList[i]);
//}
break; break;
} }
//if (needUpdate && i >= 2)
//{
// break;
//}
} }
} }
if (needUpdate) if (needUpdate)
...@@ -225,6 +216,28 @@ namespace OnlineStore.DeviceLibrary ...@@ -225,6 +216,28 @@ namespace OnlineStore.DeviceLibrary
} }
DIValueMap.Add(ip, newList); DIValueMap.Add(ip, newList);
} }
try
{
if (oldList != null && newList != null)
{
foreach (ConfigIO io in DIChangeMap.Keys)
{
if (io.IO_IP.Equals(ip))
{
IO_VALUE oldV = GetBox_Value(oldList[io.GetIOAddr()]);
IO_VALUE newV = GetBox_Value(newList[io.GetIOAddr()]);
if (!oldV.Equals(newV))
{
DIChangeMap[io].Invoke(ip, io.GetIOAddr(), oldV, newV);
}
}
}
}
}
catch (Exception ex)
{
LogUtil.error("UpdateAllDI处理事件出错:" + ex.ToString());
}
} }
} }
} }
...@@ -449,7 +462,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -449,7 +462,8 @@ namespace OnlineStore.DeviceLibrary
if (sta.Equals(Box_Sta.On)) if (sta.Equals(Box_Sta.On))
{ {
value = IO_VALUE.HIGH; value = IO_VALUE.HIGH;
}else }
else
{ {
value = IO_VALUE.LOW; value = IO_VALUE.LOW;
} }
...@@ -458,7 +472,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -458,7 +472,7 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error(" 第【"+i+"】次 GetDIValue [" + ioIP + "] [" + StartAddress + "] 出错:", ex); LogUtil.error(" 第【" + i + "】次 GetDIValue [" + ioIP + "] [" + StartAddress + "] 出错:", ex);
} }
} }
return value; return value;
...@@ -495,6 +509,18 @@ namespace OnlineStore.DeviceLibrary ...@@ -495,6 +509,18 @@ namespace OnlineStore.DeviceLibrary
return Box_Sta.Off; return Box_Sta.Off;
} }
} }
private IO_VALUE GetBox_Value(Box_Sta onOff)
{
if (onOff.Equals(Box_Sta.On))
{
return IO_VALUE.HIGH;
}
else
{
return IO_VALUE.LOW;
}
}
private AIOBOX getAIO(string ioIp) private AIOBOX getAIO(string ioIp)
{ {
......
...@@ -10,6 +10,17 @@ namespace OnlineStore.DeviceLibrary ...@@ -10,6 +10,17 @@ namespace OnlineStore.DeviceLibrary
{ {
public abstract class IOManager public abstract class IOManager
{ {
public delegate void DIChangeDelegate(string ioIP, ushort index, IO_VALUE oldValue, IO_VALUE newValue);
internal static Dictionary<ConfigIO, DIChangeDelegate> DIChangeMap = new Dictionary<ConfigIO, DIChangeDelegate>();
public static void AddDIEvent(string diType,int subType,DIChangeDelegate del)
{
ConfigIO Di = GetDI(diType, subType);
if (Di != null)
{
DIChangeMap.Add(Di, del);
}
}
public static IOManager instance = null; public static IOManager instance = null;
public abstract void ConnectionIOList(List<string> dIODeviceNameList); public abstract void ConnectionIOList(List<string> dIODeviceNameList);
...@@ -22,24 +33,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -22,24 +33,6 @@ namespace OnlineStore.DeviceLibrary
ConfigIO configIo = GetDO(ioType, subType); ConfigIO configIo = GetDO(ioType, subType);
if (configIo != null) if (configIo != null)
{ {
//try
//{
// //如果是出料四阻挡下降,添加日志
// if ((configIo.IO_IP.Equals("192.168.101.49") || configIo.IO_IP.Equals("192.168.101.41")) && configIo.GetIOAddr().Equals(4))
// {
// if (ioValue.Equals(IO_VALUE.HIGH))
// {
// LogUtil.info("IOMove: ioValue= " + ioValue + ", [ " + subType + "] [" + ioType + "] [" + configIo.IO_IP + "][4]");
// }
// else if (instance.GetDOValue(configIo.IO_IP, configIo.SlaveID, configIo.GetIOAddr()).Equals(IO_VALUE.HIGH))
// { //如果上次是high,打印
// LogUtil.info("IOMove: ioValue= " + ioValue + ", [ " + subType + "] [" + ioType + "][" + configIo.IO_IP + "][4]");
// }
// }
//}catch(Exception ex)
//{
//}
instance.WriteSingleDO(configIo.IO_IP, configIo.SlaveID, configIo.GetIOAddr(), ioValue); instance.WriteSingleDO(configIo.IO_IP, configIo.SlaveID, configIo.GetIOAddr(), ioValue);
Thread.Sleep(10); Thread.Sleep(10);
} }
...@@ -105,7 +98,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -105,7 +98,7 @@ namespace OnlineStore.DeviceLibrary
} }
return ioValue; return ioValue;
} }
private static ConfigIO GetDI(string ioType, int subType) internal static ConfigIO GetDI(string ioType, int subType)
{ {
ConfigIO configIo = null; ConfigIO configIo = null;
if (subType <= 0) if (subType <= 0)
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!