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));
......
...@@ -37,7 +37,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -37,7 +37,6 @@ namespace OnlineStore.DeviceLibrary
public OutTrayLineBean(int id, string name, string exitLocationS, string exittrayS, string lineRundo, string line3checkDi, int dId) public OutTrayLineBean(int id, string name, string exitLocationS, string exittrayS, string lineRundo, string line3checkDi, int dId)
{ {
this.Id = id; this.Id = id;
lineRun = new LineTurnBean(dId);
this.equipBeanId = dId; this.equipBeanId = dId;
this.Name = name; this.Name = name;
MoveInfo = new LineMoveInfo(Id, name); MoveInfo = new LineMoveInfo(Id, name);
...@@ -45,6 +44,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -45,6 +44,7 @@ namespace OnlineStore.DeviceLibrary
this.ExitTray_Check = exittrayS; this.ExitTray_Check = exittrayS;
this.LineRun_Do = lineRundo; this.LineRun_Do = lineRundo;
this.Line3_TrayCheck = line3checkDi; this.Line3_TrayCheck = line3checkDi;
lineRun = new LineTurnBean(dId, LineRun_Do, ExitLocation_Check);
} }
public void StopRun() public void StopRun()
...@@ -61,20 +61,20 @@ namespace OnlineStore.DeviceLibrary ...@@ -61,20 +61,20 @@ namespace OnlineStore.DeviceLibrary
{ {
if (LastTrayPosition <= 1) if (LastTrayPosition <= 1)
{ {
LogUtil.error(Name + " 启动送料【" + moveParam.ToStr() + "】 失败,入口有料" , Id * 1000 + 32); LogUtil.error(Name + " 启动送料【" + moveParam.ToStr() + "】 失败,入口有料", Id * 1000 + 32);
return false; return false;
} }
//MoveInfo.MoveParam = moveParam; //MoveInfo.MoveParam = moveParam;
MoveInfo.NewMove(LineMoveType.OutStore, moveParam); MoveInfo.NewMove(LineMoveType.OutStore, moveParam);
posId = moveParam.PosId + "[" + moveParam.WareCode + "]["+moveParam.rfid+"]"; posId = moveParam.PosId + "[" + moveParam.WareCode + "][" + moveParam.rfid + "]";
if (moveParam.InStoreNg) if (moveParam.InStoreNg)
{ {
posId =moveParam.rfid+ "NG料" + "[" + moveParam.WareCode + "]"; posId = moveParam.rfid + "NG料" + "[" + moveParam.WareCode + "]";
} }
MoveInfo.NextMoveStep(LineMoveStep.DLO_01_NGBack); MoveInfo.NextMoveStep(LineMoveStep.DLO_01_NGBack);
LogUtil.info(Name + "开始送料【" + moveParam.ToStr() + "】:" + MoveInfo.SLog + "NG气缸后退"); LogUtil.info(Name + "开始送料【" + moveParam.ToStr() + "】:" + MoveInfo.SLog + "NG气缸后退");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300)); MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
if (equipBeanId.Equals(302) ) if (equipBeanId.Equals(302))
{ {
if (equipBean.CylinderIsOk(IO_Type.NGCylinder_Before, IO_Type.NGCylinder_After)) if (equipBean.CylinderIsOk(IO_Type.NGCylinder_Before, IO_Type.NGCylinder_After))
{ {
...@@ -182,7 +182,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -182,7 +182,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NextMoveStep(LineMoveStep.DLO_07_LineRun); MoveInfo.NextMoveStep(LineMoveStep.DLO_07_LineRun);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000)); MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
LogUtil.info(Name + "送料【" + posId + "】:" + MoveInfo.SLog + " [" + LastTrayPosition + "],转动到下个工位"); LogUtil.info(Name + "送料【" + posId + "】:" + MoveInfo.SLog + " [" + LastTrayPosition + "],转动到下个工位");
lineRun.StartLineRun(LineRun_Do, ExitLocation_Check, LineEndProcess); lineRun.StartLineRun(LineEndProcess);
} }
else if (MoveInfo.MoveStep.Equals(LineMoveStep.DLO_07_LineRun)) else if (MoveInfo.MoveStep.Equals(LineMoveStep.DLO_07_LineRun))
...@@ -218,7 +218,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -218,7 +218,7 @@ namespace OnlineStore.DeviceLibrary
} }
private bool LineTurnIsStop() private bool LineTurnIsStop()
{ {
if (lineRun.InTurn.Equals(false) ) if (lineRun.InTurn.Equals(false))
{ {
if (equipBean.IOValue(LineRun_Do).Equals(IO_VALUE.LOW)) if (equipBean.IOValue(LineRun_Do).Equals(IO_VALUE.LOW))
{ {
...@@ -281,24 +281,23 @@ namespace OnlineStore.DeviceLibrary ...@@ -281,24 +281,23 @@ namespace OnlineStore.DeviceLibrary
public void TimerPro() public void TimerPro()
{ {
//皮带线1出口无料 //皮带线1出口无料
if (IsInTurn().Equals(false) && HasTray()&&lineRun.CanStart()) if (IsInTurn().Equals(false) && HasTray() && lineRun.CanStart())
{ {
if (MoveInfo.MoveType.Equals(LineMoveType.None) && if (MoveInfo.MoveType.Equals(LineMoveType.None) &&
equipBean.IOValue(ExitTray_Check).Equals(IO_VALUE.LOW)) equipBean.IOValue(ExitTray_Check).Equals(IO_VALUE.LOW))
{ {
//皮带线1出口无料 //皮带线1出口无料
lineRun.StartLineRun(LineEndProcess);
lineRun.StartLineRun(LineRun_Do, ExitLocation_Check, LineEndProcess);
} }
else if (MoveInfo.MoveStep <= LineMoveStep.DLO_01_NGBack&&MoveInfo.IsInWait.Equals(false) && else if (MoveInfo.MoveStep <= LineMoveStep.DLO_01_NGBack && MoveInfo.IsInWait.Equals(false) &&
equipBean.IOValue(ExitTray_Check).Equals(IO_VALUE.HIGH)) equipBean.IOValue(ExitTray_Check).Equals(IO_VALUE.HIGH))
{ {
//皮带线1出口有料,皮带3入库无料,且在停止状态 //皮带线1出口有料,皮带3入库无料,且在停止状态
if (equipBean.Line3TurnIsStop() && equipBean.IOValue(Line3_TrayCheck).Equals(IO_VALUE.LOW)) if (equipBean.Line3TurnIsStop() && equipBean.IOValue(Line3_TrayCheck).Equals(IO_VALUE.LOW))
{ {
Line3CanRun = false; Line3CanRun = false;
LogUtil.debug(Name+ "出口有料,且"+ Line3_TrayCheck + "=LOW,转动一个工位,["+LineRun_Do+"] ["+ExitLocation_Check+"]"); LogUtil.debug(Name + "出口有料,且" + Line3_TrayCheck + "=LOW,转动一个工位,[" + LineRun_Do + "] [" + ExitLocation_Check + "]");
lineRun.StartLineRun(LineRun_Do, ExitLocation_Check, LineEndProcess); lineRun.StartLineRun(LineEndProcess);
} }
} }
} }
...@@ -310,10 +309,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -310,10 +309,14 @@ namespace OnlineStore.DeviceLibrary
public delegate void TurnEndDel(bool result); public delegate void TurnEndDel(bool result);
public TurnEndDel turnEnd = null; public TurnEndDel turnEnd = null;
public bool InTurn = false; public bool InTurn = false;
private string LastMoveDO = ""; private string MoveDO = "";
private string LastCheckDI = ""; private string CheckDI = "";
private int subType = 0; private int subType = 0;
internal DateTime LastEndTime = DateTime.Now; internal DateTime LastEndTime = DateTime.Now;
private bool WaitCheckDI_High = false;
private bool CheckDIHigh = false;
public bool CanStart(int totalMS = 1000) public bool CanStart(int totalMS = 1000)
{ {
TimeSpan span = DateTime.Now - LastEndTime; TimeSpan span = DateTime.Now - LastEndTime;
...@@ -323,50 +326,83 @@ namespace OnlineStore.DeviceLibrary ...@@ -323,50 +326,83 @@ namespace OnlineStore.DeviceLibrary
} }
return false; return false;
} }
public LineTurnBean(int subType, string moveDO = "", string checkDI = "")
public LineTurnBean(int subType)
{ {
this.subType = subType; this.subType = subType;
this.MoveDO = moveDO;
this.CheckDI = checkDI;
if (!moveDO.Equals("") && (!checkDI.Equals("")))
{
//添加事件
AIOBOXManager.AddDIEvent(checkDI, subType, DIChangePro);
}
}
public void DIChangePro(string ioIP, ushort index, IO_VALUE oldValue, IO_VALUE newValue)
{
if (WaitCheckDI_High && InTurn && (!CheckDIHigh) && oldValue.Equals(IO_VALUE.LOW) && newValue.Equals(IO_VALUE.HIGH))
{
ConfigIO config = IOManager.GetDI(CheckDI, subType);
if (config.IO_IP.Equals(ioIP) && config.GetIOAddr().Equals(index))
{
LogUtil.info("收到DIChangeDelegate[" + ioIP + "][" + index + "][" + oldValue + "][" + newValue + "],更新CheckDIHigh=true ");
CheckDIHigh = true;
}
}
} }
public void StopLineRun() public void StopLineRun()
{ {
if (InTurn) if (InTurn)
{ {
WaitCheckDI_High = false;
CheckDIHigh = false;
InTurn = false; InTurn = false;
} }
} }
public void StartLineRun(TurnEndDel endProcess, int timeOutMS = 30000)
{
StartLineRun(MoveDO, CheckDI, endProcess, timeOutMS);
}
private int canWhileCount = 3; private int canWhileCount = 3;
public void StartLineRun(string moveDO, string checkDI, TurnEndDel endProcess, int timeOutMS = 30000) public void StartLineRun(string moveDO, string checkDI, TurnEndDel endProcess, int timeOutMS = 30000)
{ {
MoveDO = moveDO;
CheckDI = checkDI;
InTurn = true; InTurn = true;
this.turnEnd = endProcess; this.turnEnd = endProcess;
Task.Factory.StartNew(delegate Task.Factory.StartNew(delegate
{ {
canWhileCount = 3; canWhileCount = 3;
LineRunAndWait(moveDO, checkDI, timeOutMS); LineRunAndWait(timeOutMS);
}); });
} }
private string LineRunAndWait(string moveDO, string checkDI, int timeOutMS = 30000) private string LineRunAndWait(int timeOutMS = 30000)
{ {
LastMoveDO = moveDO; //MoveDO = moveDO;
LastCheckDI = checkDI; //CheckDI = checkDI;
LogUtil.debug(subType+ "开始转动:" + moveDO+",等待信号:"+checkDI+""); string logName = "LineTurn[" + subType + "][" + MoveDO + "][" + CheckDI + "] ";
IOManager.IOMove(moveDO, IO_VALUE.HIGH, subType); LogUtil.debug("开始转动:" + logName);
IOManager.IOMove(MoveDO, IO_VALUE.HIGH, subType);
InTurn = true; InTurn = true;
DateTime startTime = DateTime.Now; DateTime startTime = DateTime.Now;
string result = ""; string result = "";
bool isStop = false; bool isStop = false;
WaitCheckDI_High = false;
CheckDIHigh = false;
//先等待信号灭一次,然后再亮时停止 //先等待信号灭一次,然后再亮时停止
while (true) while (true)
{ {
Thread.Sleep(20); Thread.Sleep(20);
TimeSpan span = DateTime.Now - startTime; TimeSpan span = DateTime.Now - startTime;
if (span.TotalSeconds > 1 && IOManager.IOValue(moveDO, subType).Equals(IO_VALUE.LOW)) if (span.TotalSeconds > 1 && IOManager.IOValue(MoveDO, subType).Equals(IO_VALUE.LOW))
{ {
LogUtil.error(subType + " LineRunAndWait1 转动[" + moveDO + "][" + checkDI + "],已等待[" + FormUtil.GetSpanStr(span) + "],重写IO:" + moveDO); LogUtil.error(logName + "转动,已等待[" + FormUtil.GetSpanStr(span) + "],重写DO");
IOManager.IOMove(moveDO, IO_VALUE.HIGH, subType); IOManager.IOMove(MoveDO, IO_VALUE.HIGH, subType);
} }
if (!InTurn) if (!InTurn)
{ {
...@@ -379,7 +415,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -379,7 +415,7 @@ namespace OnlineStore.DeviceLibrary
result = "转动超时"; result = "转动超时";
} }
//判断Buzy及位置是否结束 //判断Buzy及位置是否结束
else if (IOManager.IOValue(checkDI, subType).Equals(IO_VALUE.LOW)) else if (IOManager.IOValue(CheckDI, subType).Equals(IO_VALUE.LOW))
{ {
isStop = true; isStop = true;
} }
...@@ -387,27 +423,29 @@ namespace OnlineStore.DeviceLibrary ...@@ -387,27 +423,29 @@ namespace OnlineStore.DeviceLibrary
{ {
if (result.Equals("")) if (result.Equals(""))
{ {
LogUtil.debug(subType + "验证" + checkDI + "=Low结束:" + result); LogUtil.debug(logName + "验证" + CheckDI + "=Low结束:" + result);
} }
else else
{ {
LogUtil.info(subType + "[" + moveDO + "] [" + checkDI + "] 验证" + checkDI + "=Low结束:" + result); LogUtil.info(logName + " 验证" + CheckDI + "=Low结束:" + result);
} }
break; break;
} }
} }
result = ""; result = "";
isStop = false; isStop = false;
WaitCheckDI_High = true;
CheckDIHigh = false;
while (true) while (true)
{ {
Thread.Sleep(10); Thread.Sleep(10);
TimeSpan span = DateTime.Now - startTime; TimeSpan span = DateTime.Now - startTime;
bool isRestart = false; bool isRestart = false;
if (span.TotalSeconds > 2 && IOManager.IOValue(moveDO, subType).Equals(IO_VALUE.LOW)) if (span.TotalSeconds > 2 && IOManager.IOValue(MoveDO, subType).Equals(IO_VALUE.LOW))
{ {
LogUtil.error(subType + " LineRunAndWait2 转动[" + moveDO + "][" + checkDI + "],已等待[" + FormUtil.GetSpanStr(span) + "],重写IO:" + moveDO); LogUtil.error(logName + " 转动已等待[" + FormUtil.GetSpanStr(span) + "],重写DO");
IOManager.IOMove(moveDO, IO_VALUE.HIGH, subType); IOManager.IOMove(MoveDO, IO_VALUE.HIGH, subType);
} }
if (!InTurn) if (!InTurn)
{ {
...@@ -420,14 +458,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -420,14 +458,14 @@ namespace OnlineStore.DeviceLibrary
result = "转动超时"; result = "转动超时";
} }
//判断Buzy及位置是否结束 //判断Buzy及位置是否结束
else if (IOManager.IOValue(checkDI, subType).Equals(IO_VALUE.HIGH)) else if (IOManager.IOValue(CheckDI, subType).Equals(IO_VALUE.HIGH) || CheckDIHigh)
{ {
if (canWhileCount > 0 && span.TotalMilliseconds < 800) if (canWhileCount > 0 && span.TotalMilliseconds < 800)
{ {
isRestart = true ; isRestart = true;
canWhileCount--; canWhileCount--;
LogUtil.info(subType + " 异常停止,重新开始转动:[" + moveDO + "] [" + checkDI + "] 耗时 [" + FormUtil.GetSpanStr(span) + "]["+canWhileCount+"]"); LogUtil.info(logName + " 异常停止,重新开始转动: 耗时 [" + FormUtil.GetSpanStr(span) + "][" + canWhileCount + "]");
return LineRunAndWait(moveDO, checkDI, timeOutMS); return LineRunAndWait(timeOutMS);
} }
isStop = true; isStop = true;
} }
...@@ -438,19 +476,19 @@ namespace OnlineStore.DeviceLibrary ...@@ -438,19 +476,19 @@ namespace OnlineStore.DeviceLibrary
//正常4-5秒 //正常4-5秒
if (span.TotalSeconds >= 1 && span.TotalSeconds <= 6) if (span.TotalSeconds >= 1 && span.TotalSeconds <= 6)
{ {
LogUtil.debug(subType + "停止运动:[" + moveDO + "] [" + checkDI + "] 耗时 [" + FormUtil.GetSpanStr(span) + "][" + canWhileCount + "]"); LogUtil.debug(logName + "停止运动: 耗时 [" + FormUtil.GetSpanStr(span) + "][" + canWhileCount + "]");
} }
else else
{ {
LogUtil.info(subType + "停止运动:[" + moveDO + "] [" + checkDI + "] 耗时 [" + FormUtil.GetSpanStr(span) + "][" + canWhileCount + "]"); LogUtil.info(logName + "停止运动: 耗时 [" + FormUtil.GetSpanStr(span) + "][" + canWhileCount + "]");
} }
} }
else else
{ {
LogUtil.info(subType + "[" + moveDO + "] [" + checkDI + "] 停止运动:" + result + " " + moveDO); LogUtil.info(logName + " 停止运动:" + result + " " + MoveDO);
} }
LastEndTime = DateTime.Now; LastEndTime = DateTime.Now;
IOManager.IOMove(moveDO, IO_VALUE.LOW, subType); IOManager.IOMove(MoveDO, IO_VALUE.LOW, subType);
if (!isRestart) if (!isRestart)
{ {
Task.Factory.StartNew(delegate Task.Factory.StartNew(delegate
...@@ -459,6 +497,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -459,6 +497,8 @@ namespace OnlineStore.DeviceLibrary
}); });
} }
InTurn = false; InTurn = false;
WaitCheckDI_High = false;
CheckDIHigh = false;
return result; return result;
} }
} }
......
...@@ -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!