|
@@ -112,36 +112,11 @@ namespace parkMonitor.server.CoreThread
|
|
|
Timer killTimeoutConnection = new System.Threading.Timer(KillTimeoutConnection, null, 3600000, 3600000);
|
|
|
//Timer checkLocalTimer = new System.Threading.Timer(CheckLocalPool, null, 10000, 300000);
|
|
|
//Timer logTimer = new System.Threading.Timer(displayLog, null, 1000, 30000);
|
|
|
- Object lockObj = new object();
|
|
|
- Command queueCmdRecord = null;
|
|
|
while (!isClosing)
|
|
|
{
|
|
|
- lock (lockObj)
|
|
|
- {
|
|
|
- //判断当前计数是否允许线程创建
|
|
|
- if (queueCmdRecord != null)
|
|
|
- {
|
|
|
- if (queueCmdRecord.id / 6 == Robot.robot1.id && Robot.robot1.waitCount >= 2)
|
|
|
- {
|
|
|
- Thread.Sleep(10000);
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (queueCmdRecord.id / 6 == Robot.robot2.id && Robot.robot2.waitCount >= 2)
|
|
|
- {
|
|
|
- Thread.Sleep(10000);
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
if (initialized && EntityForCore.ins.globalStatus)
|
|
|
{
|
|
|
Command queueCmd = null;
|
|
|
- //等待系统总状态
|
|
|
- Task getSysStatus = Task.Factory.StartNew(() =>
|
|
|
- {
|
|
|
- GetTotalStatus();
|
|
|
- });
|
|
|
//等待号牌资源
|
|
|
Task getCmd = Task.Factory.StartNew(() =>
|
|
|
{
|
|
@@ -157,49 +132,79 @@ namespace parkMonitor.server.CoreThread
|
|
|
queuingThread.SetMessage((Command)queueCmd.Clone());
|
|
|
Thread.Sleep(5000);
|
|
|
}
|
|
|
- else
|
|
|
+ //判断当前计数是否允许线程创建,机械手资源争抢严重则将指令丢回队列
|
|
|
+ else if (queueCmd.id / 6 + 1 == Robot.robot1.id)
|
|
|
{
|
|
|
- break;
|
|
|
+ if ((queueCmd.commandType=='s' && Robot.robot1.parkWaitCount >= 1) || (queueCmd.commandType=='f' && Robot.robot1.fetchWaitCount >= 1))
|
|
|
+ {
|
|
|
+ Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "等待机械手1资源线程过多:" + Robot.robot1.parkWaitCount + "," + Robot.robot1.fetchWaitCount);
|
|
|
+ queueCmd.returnedCount = 10000;
|
|
|
+ queuingThread.SetMessage((Command)queueCmd.Clone());
|
|
|
+ Thread.Sleep(15000);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
+ else if (queueCmd.id / 6 + 1 == Robot.robot2.id)
|
|
|
+ {
|
|
|
+ if ((queueCmd.commandType == 's' && Robot.robot2.parkWaitCount >= 1) || (queueCmd.commandType == 'f' && Robot.robot2.fetchWaitCount >= 1))
|
|
|
+ {
|
|
|
+ Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "等待机械手2资源线程过多:" + Robot.robot2.parkWaitCount + "," + Robot.robot2.fetchWaitCount);
|
|
|
+ queueCmd.returnedCount = 10000;
|
|
|
+ queuingThread.SetMessage((Command)queueCmd.Clone());
|
|
|
+ Thread.Sleep(15000);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- Task.WaitAll(getSysStatus, getCmd);
|
|
|
-
|
|
|
-
|
|
|
- lock (lockObj)
|
|
|
+ Task.WaitAll(getCmd);
|
|
|
+ //等待系统总状态
|
|
|
+ Task getSysStatus = Task.Factory.StartNew(() =>
|
|
|
+ {
|
|
|
+ GetTotalStatus();
|
|
|
+ });
|
|
|
+ Task.WaitAll(getSysStatus);
|
|
|
+ //对依赖同一机械手的线程计数
|
|
|
+ if (queueCmd.id / 6 + 1 == Robot.robot1.id)
|
|
|
{
|
|
|
- if (queueCmdRecord != null)
|
|
|
+ if (queueCmd.commandType == 's')
|
|
|
{
|
|
|
- Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "等待机械手1资源线程计数:" + Robot.robot1.waitCount);
|
|
|
- //对依赖同一机械手的线程计数
|
|
|
- if (queueCmdRecord.id == Robot.robot1.id)
|
|
|
- {
|
|
|
- Robot.robot1.waitCount += 1;
|
|
|
- }
|
|
|
- else if (queueCmdRecord.id == Robot.robot2.id)
|
|
|
- {
|
|
|
- Robot.robot2.waitCount += 1;
|
|
|
- }
|
|
|
+ Robot.robot1.parkWaitCount += 1;
|
|
|
+ }
|
|
|
+ else if (queueCmd.commandType == 'f')
|
|
|
+ {
|
|
|
+ Robot.robot1.fetchWaitCount += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (queueCmd.id / 6 + 1 == Robot.robot2.id)
|
|
|
+ {
|
|
|
+ if (queueCmd.commandType == 's')
|
|
|
+ {
|
|
|
+ Robot.robot2.parkWaitCount += 1;
|
|
|
+ }
|
|
|
+ else if (queueCmd.commandType == 'f')
|
|
|
+ {
|
|
|
+ Robot.robot2.fetchWaitCount += 1;
|
|
|
}
|
|
|
- queueCmdRecord = (Command)queueCmd.Clone();
|
|
|
}
|
|
|
- Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "线程创建:" + queueCmd.LicenseNum + "准备,等待机械手1线程个数:" + Robot.robot1.waitCount);
|
|
|
+ Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "---线程创建:" + queueCmd.LicenseNum + "准备,等待机械手1资源停取线程计数:" + Robot.robot1.parkWaitCount + "," + Robot.robot1.fetchWaitCount);
|
|
|
Task t = Task.Factory.StartNew(() =>
|
|
|
{
|
|
|
- Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "线程创建:" + queueCmd.LicenseNum + "开始");
|
|
|
+ Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "---线程创建:" + queueCmd.LicenseNum + "开始");
|
|
|
SimpleCMDFactory simpleCMDFactory = new SimpleCMDFactory();
|
|
|
AbstractCmd abstractCmd = simpleCMDFactory.createCmd(queueCmd);
|
|
|
abstractCmd.executeCmd(queueCmd);
|
|
|
- Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "线程创建:" + queueCmd.LicenseNum + "完成");
|
|
|
+ Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "---线程创建:" + queueCmd.LicenseNum + "完成");
|
|
|
});
|
|
|
if (t != null)
|
|
|
{
|
|
|
- Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "线程创建:" + queueCmd.LicenseNum + "状态:"+ t.Status);
|
|
|
+ Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "---线程创建:" + queueCmd.LicenseNum + "状态:" + t.Status);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "线程创建:" + queueCmd.LicenseNum + "为空");
|
|
|
+ Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "---线程创建:" + queueCmd.LicenseNum + "为空");
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -227,7 +232,7 @@ namespace parkMonitor.server.CoreThread
|
|
|
normalStatus = Convert.ToInt32(PLCMsg.originalPlcList[equipmentStatus_address].Value);
|
|
|
}
|
|
|
//设备总控状态
|
|
|
- if (normalStatus == 1 && EntityForCore.ins.globalStatus && ParkingBufferManager.ins.checkedAuto)
|
|
|
+ if (normalStatus == 1 && EntityForCore.ins.globalStatus)
|
|
|
{
|
|
|
UILogServer.ins.log("设备总状态正常");
|
|
|
Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "设备总状态正常");
|
|
@@ -299,7 +304,7 @@ namespace parkMonitor.server.CoreThread
|
|
|
}
|
|
|
private void CheckRemotePool(object o)
|
|
|
{
|
|
|
- ConnectionPoolManager.CheckConnPooling(3, 10, ConnectionPoolManager.remoteConf, EntityForCore.remoteBQ);
|
|
|
+ ConnectionPoolManager.CheckConnPooling(3, 10, ConnectionPoolManager.remoteConf, EntityForCore.remoteBQ);
|
|
|
}
|
|
|
private void CheckLocalPool(object o)
|
|
|
{
|