@ -41,6 +41,14 @@ public class SheetMetalPlanTaskHandle
public static event RefreshChat RefreshChatEvent ;
# endregion
#region 刷新创建计划
/// <summary>
/// 刷新创建计划
/// </summary>
public delegate void RefreshPlanInfo ( SheetMetaSendPlanInfoView planInfo ) ;
public static event RefreshPlanInfo RefreshPlanInfoEvent ;
# endregion
#region 刷新当前正在执行的计划
/// <summary>
/// 刷新当前正在执行的计划
@ -168,8 +176,8 @@ public class SheetMetalPlanTaskHandle
obj_sidePanel . plc . WriteInt32 ( "D6020" , planInfo . PlanAmount ) ;
obj_sidePanel . plc . WriteInt32 ( "D6021" , 1 ) ;
Console . WriteLine ( $"{DateTime.Now.ToString(" HH : m : s ")}===>等待 背 板设备应答。。。。。。") ;
RefreshExecInfoEvent ? . Invoke ( $"等待 背 板设备应答。。。。。。") ;
Console . WriteLine ( $"{DateTime.Now.ToString(" HH : m : s ")}===>等待 前 板设备应答。。。。。。") ;
RefreshExecInfoEvent ? . Invoke ( $"等待 前 板设备应答。。。。。。") ;
#region PLC反馈信号逻辑处理
//循环读取PLC应答信号, PLC应答后复位应答信号、更新计划状态为执行中
bool isFlag = true ;
@ -179,8 +187,8 @@ public class SheetMetalPlanTaskHandle
if ( obj_sidePanel . plc . ReadInt32 ( "D6021" ) = = 2 )
{
obj_sidePanel . plc . WriteInt32 ( "D6021" , 0 ) ;
Console . WriteLine ( $"{DateTime.Now.ToString(" HH : m : s ")}===>收到 背板 板设备应答信号,复位应答地址") ;
RefreshExecInfoEvent ? . Invoke ( $"收到 背 板板设备应答信号,复位应答地址") ;
Console . WriteLine ( $"{DateTime.Now.ToString(" HH : m : s ")}===>收到 前 板设备应答信号,复位应答地址") ;
RefreshExecInfoEvent ? . Invoke ( $"收到 前 板板设备应答信号,复位应答地址") ;
isFlag = false ;
}
Thread . Sleep ( 2000 ) ;
@ -206,13 +214,14 @@ public class SheetMetalPlanTaskHandle
//更新前端展示图表
RefreshCreatePlanInfoEvent ? . Invoke ( ) ; //更新界面
RefreshChatEvent ? . Invoke ( ) ; //刷新图表
RefreshPlanInfoEvent ? . Invoke ( planInfo ) ; //刷新计划执行
}
}
} ) ;
}
catch ( Exception ex )
{
MessageBox . Show ( $" 背 板⽣产计划下发异常:{ex.Message}", "提示" , MessageBoxButton . OK , MessageBoxImage . Error ,
MessageBox . Show ( $" 前 板⽣产计划下发异常:{ex.Message}", "提示" , MessageBoxButton . OK , MessageBoxImage . Error ,
MessageBoxResult . OK , MessageBoxOptions . DefaultDesktopOnly ) ;
}
}
@ -263,6 +272,7 @@ public class SheetMetalPlanTaskHandle
//更新前端展示图表
RefreshCreatePlanInfoEvent ? . Invoke ( ) ; //更新界面
RefreshChatEvent ? . Invoke ( ) ; //刷新图表
//RefreshPlanInfoEvent?.Invoke(planInfo);
}
# endregion
@ -313,22 +323,15 @@ public class SheetMetalPlanTaskHandle
if ( planInfo . PlanType = = 1 )
{
if ( planInfo . PlanAmount = = sumBackPanelAmount )
if ( sumSidePanelAmount < = sumBackPanelAmount )
{
if ( sumSidePanelAmount < = sumBackPanelAmount )
{
sumAmount = sumSidePanelAmount ;
isComplate = false ;
}
else
{
sumAmount = planInfo . PlanAmount ;
isComplate = false ;
}
sumAmount = sumSidePanelAmount ;
isComplate = false ;
}
else
{
sumAmount = sumSidePanelAmount ;
sumAmount = planInfo . PlanAmount ;
isComplate = false ;
}
}
@ -359,7 +362,12 @@ public class SheetMetalPlanTaskHandle
if ( result )
{
//更新前端展示图表
// RefreshCreatePlanInfoEvent?.Invoke();//更新界面
// RefreshCreatePlanInfoEvent?.Invoke();//更新界面
if ( planInfo . PlanType = = 3 )
{
RefreshCreatePlanInfoEvent ? . Invoke ( ) ; //更新界面
RefreshPlanInfoEvent ? . Invoke ( planInfo ) ;
}
RefreshChatEvent ? . Invoke ( ) ; //刷新图表
}
@ -396,20 +404,24 @@ public class SheetMetalPlanTaskHandle
List < RecordBackPanelComplate > backPanelComplates = _backPanelComplateServices . Query ( x = > x . ProductlineCode = = "1001" & & x . PlanCode = = planInfo . TaskCode ) ;
int sumBackPanelAmount = backPanelComplates . Sum ( x = > x . OutPutAmount ) ;
Console . WriteLine ( $"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount}; 围 板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}") ;
RefreshExecInfoEvent ? . Invoke ( $"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount}; 围 板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}") ;
Console . WriteLine ( $"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount}; 前 板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}") ;
RefreshExecInfoEvent ? . Invoke ( $"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount}; 前 板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}") ;
int sumAmount = 0 ;
if ( planInfo . PlanType = = 1 )
{
if ( sumSidePanelAmount > = sumBackPanelAmount )
if ( sumSidePanelAmount > = sumBackPanelAmount & & sumBackPanelAmount ! = 0 )
{
sumAmount = sumBackPanelAmount ;
}
else
if ( sumBackPanelAmount = = 0 )
{
sumAmount = sumSidePanelAmount ;
sumAmount = 0 ;
}
if ( planInfo . PlanAmount = = sumSidePanelAmount )
{
isComplate = false ;
}
}
else if ( planInfo . PlanType = = 2 )
{
@ -432,15 +444,18 @@ public class SheetMetalPlanTaskHandle
obj . CompleteAmount = planInfo . CompleteAmount ;
obj . ExecuteStatus = planInfo . ExecuteStatus ;
bool result = _executePlanInfoServices . UpdateExecutePlanInfo ( obj ) . Result ;
if ( result )
{
//更新前端展示图表
RefreshCreatePlanInfoEvent ? . Invoke ( ) ; //更新界面
RefreshChatEvent ? . Invoke ( ) ; //刷新图表
}
Thread . Sleep ( 5000 ) ;
} while ( isComplate ) ;
if ( ! isComplate )
{
//更新前端展示图表
//RefreshCreatePlanInfoEvent?.Invoke();//更新界面
RefreshChatEvent ? . Invoke ( ) ; //刷新图表
//SheetMetaSendPlanInfoView planInfo = planInfoList.FirstOrDefault(d => d.TaskCode == planCode);
RefreshPlanInfoEvent ? . Invoke ( planInfo ) ; //刷新计划执行
}
}
}
catch ( Exception ex )
@ -537,8 +552,8 @@ public class SheetMetalPlanTaskHandle
List < RecordBackPanelComplate > backPanelComplates = _backPanelComplateServices . Query ( x = > x . ProductlineCode = = "1001" & & x . PlanCode = = planInfo . TaskCode ) ;
int sumBackPanelAmount = backPanelComplates . Sum ( x = > x . OutPutAmount ) ;
Console . WriteLine ( $"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount}; 围 板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}") ;
RefreshExecInfoEvent ? . Invoke ( $"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount}; 围 板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}") ;
Console . WriteLine ( $"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount}; 前 板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}") ;
RefreshExecInfoEvent ? . Invoke ( $"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount}; 前 板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}") ;
int sumAmount = 0 ;
if ( planInfo . PlanType = = 1 )
@ -610,8 +625,8 @@ public class SheetMetalPlanTaskHandle
obj_sidePanel . plc . WriteInt32 ( "D6020" , planInfo . PlanAmount ) ;
obj_sidePanel . plc . WriteInt32 ( "D6021" , 1 ) ;
Console . WriteLine ( $"{DateTime.Now.ToString(" HH : m : s ")}===>等待 围 板设备应答。。。。。。") ;
RefreshExecInfoEvent ? . Invoke ( "等待 围 板设备应答......") ;
Console . WriteLine ( $"{DateTime.Now.ToString(" HH : m : s ")}===>等待 前 板设备应答。。。。。。") ;
RefreshExecInfoEvent ? . Invoke ( "等待 前 板设备应答......") ;
//下发完成后读取PLC应答, 应答后复位应答信号
#region PLC反馈信号逻辑处理
@ -623,8 +638,8 @@ public class SheetMetalPlanTaskHandle
if ( obj_sidePanel . plc . ReadInt32 ( "D6021" ) = = 2 )
{
obj_sidePanel . plc . WriteInt32 ( "D6021" , 0 ) ;
Console . WriteLine ( $"{DateTime.Now.ToString(" HH : m : s ")}===>收到 围 板设备应答信号,复位应答地址") ;
RefreshExecInfoEvent ? . Invoke ( "收到 围 板设备应答信号,复位应答地址") ;
Console . WriteLine ( $"{DateTime.Now.ToString(" HH : m : s ")}===>收到 前 板设备应答信号,复位应答地址") ;
RefreshExecInfoEvent ? . Invoke ( "收到 前 板设备应答信号,复位应答地址") ;
isFlag = false ;
}
Thread . Sleep ( 2000 ) ;
@ -703,14 +718,14 @@ public class SheetMetalPlanTaskHandle
}
catch ( Exception ex )
{
MessageBox . Show ( $" 围 板⽣产计划下发异常:{ex.Message}", "提示" , MessageBoxButton . OK , MessageBoxImage . Error ,
MessageBox . Show ( $" 前 板⽣产计划下发异常:{ex.Message}", "提示" , MessageBoxButton . OK , MessageBoxImage . Error ,
MessageBoxResult . OK , MessageBoxOptions . DefaultDesktopOnly ) ;
}
}
/// <summary>
/// 下发 围 板生产计划
/// 下发 前 板生产计划
/// </summary>
/// <param name="planInfo"></param>
/// <param name="obj"></param>
@ -729,8 +744,8 @@ public class SheetMetalPlanTaskHandle
obj_sidePanel . plc . WriteInt32 ( "D6020" , planInfo . PlanAmount ) ;
obj_sidePanel . plc . WriteInt32 ( "D6021" , 1 ) ;
Console . WriteLine ( $"{DateTime.Now.ToString(" HH : m : s ")}===>等待 围 板设备应答。。。。。。") ;
RefreshExecInfoEvent ? . Invoke ( "等待 围 板设备应答......") ;
Console . WriteLine ( $"{DateTime.Now.ToString(" HH : m : s ")}===>等待 前 板设备应答。。。。。。") ;
RefreshExecInfoEvent ? . Invoke ( "等待 前 板设备应答......") ;
//下发完成后读取PLC应答, 应答后复位应答信号
#region PLC反馈信号逻辑处理
@ -741,8 +756,8 @@ public class SheetMetalPlanTaskHandle
if ( obj_sidePanel . plc . ReadInt32 ( "D6021" ) = = 2 )
{
obj_sidePanel . plc . WriteInt32 ( "D6021" , 0 ) ;
Console . WriteLine ( $"{DateTime.Now.ToString(" HH : m : s ")}===>收到 围 板设备应答信号,复位应答地址") ;
RefreshExecInfoEvent ? . Invoke ( "收到 围 板设备应答信号......") ;
Console . WriteLine ( $"{DateTime.Now.ToString(" HH : m : s ")}===>收到 前 板设备应答信号,复位应答地址") ;
RefreshExecInfoEvent ? . Invoke ( "收到 前 板设备应答信号......") ;
isFlag = false ;
}
Thread . Sleep ( 2000 ) ;
@ -773,13 +788,13 @@ public class SheetMetalPlanTaskHandle
}
catch ( Exception ex )
{
MessageBox . Show ( $" 围 板⽣产计划下发异常:{ex.Message}", "提示" , MessageBoxButton . OK , MessageBoxImage . Error ,
MessageBox . Show ( $" 前 板⽣产计划下发异常:{ex.Message}", "提示" , MessageBoxButton . OK , MessageBoxImage . Error ,
MessageBoxResult . OK , MessageBoxOptions . DefaultDesktopOnly ) ;
}
}
/// <summary>
/// 读取 围 板生产数据
/// 读取 前 板生产数据
/// </summary>
/// <param name="obj"></param>
public void ReadDeviceComplate_SidePanel ( PlcModel obj )
@ -813,8 +828,8 @@ public class SheetMetalPlanTaskHandle
//生产节拍
int productionBeat = short . Parse ( bytesToHexStr ( info . Skip ( 51 ) . Take ( 4 ) . ToArray ( ) , 4 ) , System . Globalization . NumberStyles . HexNumber ) ;
Console . WriteLine ( $" 围 板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}") ;
RefreshExecInfoEvent ? . Invoke ( $" 围 板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}") ;
Console . WriteLine ( $" 前 板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}") ;
RefreshExecInfoEvent ? . Invoke ( $" 前 板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}") ;
//添加完工记录
RecordSidePanelComplate sidePanelComplate = new RecordSidePanelComplate ( )
@ -869,8 +884,8 @@ public class SheetMetalPlanTaskHandle
if ( planInfo . PlanAmount - sumComplateAmount = = 0 )
{
isFlag = false ;
Console . WriteLine ( $" 围 板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}") ;
RefreshExecInfoEvent ? . Invoke ( $" 围 板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}") ;
Console . WriteLine ( $" 前 板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}") ;
RefreshExecInfoEvent ? . Invoke ( $" 前 板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}") ;
}
}
}
@ -888,6 +903,13 @@ public class SheetMetalPlanTaskHandle
RefreshCreatePlanInfoEvent ? . Invoke ( ) ; //更新界面
RefreshChatEvent ? . Invoke ( ) ; //刷新图表
RefreshCreatePlanInfoEvent ? . Invoke ( ) ;
var planInfoList = _executePlanInfoServices . QuerySheetMetalSendPlanData ( "1001" ) ;
if ( planInfoList ! = null & & planInfoList . Count ! = 0 )
{
SheetMetaSendPlanInfoView planInfo = planInfoList . FirstOrDefault ( d = > d . TaskCode = = planCode . Replace ( "\0" , "" ) . Trim ( ) ) ;
RefreshPlanInfoEvent ? . Invoke ( planInfo ) ; //刷新计划执行
}
}
Thread . Sleep ( 5000 ) ;
} while ( isFlag ) ;
@ -897,12 +919,13 @@ public class SheetMetalPlanTaskHandle
//更新前端展示图表
RefreshCreatePlanInfoEvent ? . Invoke ( ) ; //更新界面
RefreshChatEvent ? . Invoke ( ) ; //刷新图表
}
}
catch ( Exception e )
{
Console . WriteLine ( $"读取 围 板设备完成数据异常:{e.Message}") ;
RefreshExecInfoEvent ? . Invoke ( $"读取 围 板设备完成数据异常:{e.Message}") ;
Console . WriteLine ( $"读取 前 板设备完成数据异常:{e.Message}") ;
RefreshExecInfoEvent ? . Invoke ( $"读取 前 板设备完成数据异常:{e.Message}") ;
}
}