change - 出库任务下发

foamRearStore
wenjy 1 year ago
parent 6442753c80
commit fd527cbdc2

Binary file not shown.

@ -39,6 +39,8 @@ namespace Aucma.Scada.Business
private TaskHandleBusiness taskHandleBusiness = TaskHandleBusiness.Instance;
private Semaphore m_SendTaskSem = new Semaphore(0, 100000);
/// <summary>
/// 初始化出库任务
/// </summary>
@ -235,30 +237,30 @@ namespace Aucma.Scada.Business
private void StartTimerPassDown()
{
try
{
if (!timer.Enabled)
{
timer.Elapsed += new System.Timers.ElapsedEventHandler(PassDownTaskInfoByTimer);
timer.AutoReset = true;
timer.Enabled = false;
timer.Start();
PrintLogInfoMessage("StartTimerPassDown(),开启定时获取出库任务进行下发");
}
}
catch (Exception ex)
{
PrintLogErrorMessage("开启定时下发出库任务异常", ex);
}
//try
//{
// if (!timer.Enabled)
// {
// timer.Elapsed += new System.Timers.ElapsedEventHandler(PassDownTaskInfoByTimer);
// timer.AutoReset = true;
// timer.Enabled = false;
// timer.Start();
// PrintLogInfoMessage("StartTimerPassDown(),开启定时获取出库任务进行下发");
// }
//}
//catch (Exception ex)
//{
// PrintLogErrorMessage("开启定时下发出库任务异常", ex);
//}
}
/// <summary>
/// 依次获取任务队列进行下发
/// object sender, System.Timers.ElapsedEventArgs e
/// </summary>
/// <param name="source"></param>
/// <param name="e"></param>
private void PassDownTaskInfoByTimer(object sender, System.Timers.ElapsedEventArgs e)
private bool PassDownTaskInfoByTimer()
{
List<RealTaskInfo> realTasks = new List<RealTaskInfo>();
RealTaskInfo shellTask = _taskInfoService.GetTaskInfoByStoreCode(appConfig.shellStoreCode, 2);
@ -275,23 +277,25 @@ namespace Aucma.Scada.Business
if (result)
{
foreach(var item in realTasks)
GetAllRelese(m_SendTaskSem);
foreach (var item in realTasks)
{
RefreshScanMateriaCodeEvent?.Invoke(item.materialCode, item.materialType, item.spaceName, item.storeCode);
taskHandleBusiness.SendOutStoreTask(item);
}
if (timer.Enabled)
if (m_SendTaskSem.WaitOne(5000, false))
{
timer.Stop();
timer.Close();
timer.Dispose();
timer = new System.Timers.Timer(5000);
return true;
}
else
{
return false;
}
}
}
}
return false;
}
#endregion
@ -400,5 +404,15 @@ namespace Aucma.Scada.Business
RefreshLogMessageEvent?.Invoke(message);
logHelper.Error(message, ex);
}
private void GetAllRelese(Semaphore sph)
{
bool res = sph.WaitOne(1, false);
if (res)
{
// LogHelper.RfidLog("信号量手动释放");
GetAllRelese(sph);
}
}
}
}

@ -46,16 +46,33 @@ namespace Aucma.Scada.Business
public bool SendOutStoreTask(RealTaskInfo realTaskInfo)
{
bool result = false;
string spaceCode = string.Empty;
string amount = string.Empty;
string taskCode = string.Empty;
string answer = string.Empty;
try
{
if(realTaskInfo.storeCode == appConfig.shellStoreCode)
{
spaceCode = plcConfig.out_shell_spaceCode;
amount = plcConfig.out_shell_amount;
taskCode = plcConfig.out_shell_task;
}else if (realTaskInfo.storeCode == appConfig.linerStoreCode)
{
spaceCode = plcConfig.out_liner_spaceCode;
amount = plcConfig.out_liner_amount;
taskCode = plcConfig.out_liner_task;
}
//写入货道号
_plc.writeStringByAddress(plcConfig.out_shell_spaceCode, realTaskInfo.spaceCode);
_plc.writeStringByAddress(spaceCode, realTaskInfo.spaceCode);
//写入出库数量
_plc.writeInt32ByAddress(plcConfig.out_shell_amount, realTaskInfo.planAmount);
_plc.writeInt32ByAddress(amount, realTaskInfo.planAmount);
//写入任务号
_plc.writeStringByAddress(plcConfig.out_shell_task, realTaskInfo.taskCode);
_plc.writeStringByAddress(taskCode,realTaskInfo.taskCode);
//写入应答字
_plc.writeInt32ByAddress("", 1);
_plc.writeInt32ByAddress(answer, 1);
result = true;
}

@ -27,4 +27,3 @@ C:\项目代码\澳柯玛MES项目\Aucma.Scada\HighWayIot.Log4net\obj\Debug\High
C:\项目代码\澳柯玛MES项目\Aucma.Scada\HighWayIot.Log4net\obj\Debug\HighWayIot.Log4net.csproj.CopyComplete
C:\项目代码\澳柯玛MES项目\Aucma.Scada\HighWayIot.Log4net\obj\Debug\HighWayIot.Log4net.dll
C:\项目代码\澳柯玛MES项目\Aucma.Scada\HighWayIot.Log4net\obj\Debug\HighWayIot.Log4net.pdb
C:\项目代码\澳柯玛MES项目\Aucma.Scada\HighWayIot.Log4net\obj\Debug\HighWayIot.Log4net.csproj.AssemblyReference.cache

@ -29,4 +29,3 @@ C:\项目代码\澳柯玛MES项目\Aucma.Scada\HighWayIot.TouchSocket\obj\Debug\
C:\项目代码\澳柯玛MES项目\Aucma.Scada\HighWayIot.TouchSocket\obj\Debug\HighWayIot.TouchSocket.csproj.CopyComplete
C:\项目代码\澳柯玛MES项目\Aucma.Scada\HighWayIot.TouchSocket\obj\Debug\HighWayIot.TouchSocket.dll
C:\项目代码\澳柯玛MES项目\Aucma.Scada\HighWayIot.TouchSocket\obj\Debug\HighWayIot.TouchSocket.pdb
C:\项目代码\澳柯玛MES项目\Aucma.Scada\HighWayIot.TouchSocket\obj\Debug\HighWayIot.TouchSocket.csproj.AssemblyReference.cache

Loading…
Cancel
Save