Browse Source

临时更新

样式分支
taoye 2 years ago
parent
commit
41471e3ea6
3 changed files with 59 additions and 68 deletions
  1. +1
    -1
      BPASmartClient.Helper/ThreadManage.cs
  2. +56
    -65
      FryPot_DosingSystem/Control/DosingLogicControl.cs
  3. +2
    -2
      FryPot_DosingSystem/View/RecipeSetView.xaml

+ 1
- 1
BPASmartClient.Helper/ThreadManage.cs View File

@@ -32,7 +32,7 @@ namespace BPASmartClient.Helper
if (CancellationTokenSources.ContainsKey(guid + key))
{
CancellationTokenSources[guid + key]?.Cancel();
if (key.Equals("MainTask"))
if (key.Equals("滚筒线1任务线程")||key.Equals("滚筒线2任务线程")||key.Equals("滚筒线3任务线程"))
{
ActionManage.GetInstance.Send("FryPotDosingMainTaskExit");
}


+ 56
- 65
FryPot_DosingSystem/Control/DosingLogicControl.cs View File

@@ -218,7 +218,7 @@ namespace FryPot_DosingSystem.Control
globalVar = new GlobalVariable();
hardWareStatusModel = HardWareStatusViewModel.GetInstance;
ActionManage.GetInstance.Register(new Action<object[]>(RecipeDataParse), "RecipeSetDown");
ActionManage.GetInstance.Register(new Action(() => { RecipeQuene.Clear(); InputMaterialQuene.Clear(); OutputMaterialQuene.Clear(); }), "ClearRecipes");
ActionManage.GetInstance.Register(new Action(() => { RecipeQuene.Clear(); InputMaterialQuene.Clear(); OutputMaterialQuene.Clear(); LTwoInputMaterialQuene.Clear(); LTwoOutputMaterialQuene.Clear(); LThreeInputMaterialQuene.Clear(); LThreeOutputMaterialQuene.Clear(); }), "ClearRecipes");
ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 1; }), "StartPlcInite");
ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 0; }), "EndPlcInite");
ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitMainTask = true; }), "FryPotDosingMainTaskExit");
@@ -226,7 +226,7 @@ namespace FryPot_DosingSystem.Control
HubHelper.GetInstance.Upstreamrequest = new Action<object>(AgvFeedBackUpReportDataAnalysis);
ResetProgram();
ReadPlcData();
IniteTask();
MainTask();
CommandRegist();
}

@@ -433,19 +433,28 @@ namespace FryPot_DosingSystem.Control
if (RTrig.GetInstance("ResetProgram").Start(globalVar.PlcInite == 1))//判断是否初始化 一初始化就重启主任务
{
MessageLog.GetInstance.ShowUserLog("主任务正在重启");
ThreadManage.GetInstance().StopTask("MainTask", new Action(() =>

ThreadManage.GetInstance().StopTask("MainViewReadPlcData", new Action(() =>
{
ThreadManage.GetInstance().StopTask("MainViewReadPlcData", new Action(() =>
ActionManage.GetInstance.CancelRegister("RecipeSetDown");
ActionManage.GetInstance.Register(new Action<object>(RecipeDataParse), "RecipeSetDown");
ActionManage.GetInstance.Send("ClearRecipes");
ThreadManage.GetInstance().StopTask("滚筒线1任务线程", new Action(() =>
{
globalVar = null;
globalVar = new GlobalVariable();
ReicpeNum = 0;
ActionManage.GetInstance.CancelRegister("RecipeSetDown");
ActionManage.GetInstance.Register(new Action<object>(RecipeDataParse), "RecipeSetDown");
ActionManage.GetInstance.Send("ClearRecipes");
ReadPlcData();
IniteTask();
MessageLog.GetInstance.ShowUserLog("主任务重启完成");
ThreadManage.GetInstance().StopTask("滚筒线2任务线程", new Action(() =>
{
ThreadManage.GetInstance().StopTask("滚筒线3任务线程", new Action(() =>
{
globalVar = null;
globalVar = new GlobalVariable();
ReicpeNum = 0;
ReadPlcData();
//MainTask();
MessageLog.GetInstance.ShowUserLog("主任务重启完成");

}));
}));

}));
}));
}
@@ -689,13 +698,13 @@ namespace FryPot_DosingSystem.Control
/// <summary>
/// 初始化任务
/// </summary>
public void IniteTask()
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
MainTask();
}), "MainTask");
}
//public void IniteTask()
//{
// ThreadManage.GetInstance().StartLong(new Action(() =>
// {
// MainTask();
// }), "MainTask");
//}
/// <summary>
/// 配方数据接收
/// </summary>
@@ -705,20 +714,6 @@ namespace FryPot_DosingSystem.Control
{
if (obj != null && obj is NewRecipeModel[] recipes)
{
//int? res = (recipe.materialCollection.ElementAt(0).MaterialLoc) / 100;
//if (res != null)
//{
// switch (res)
// {
// case 1:
// case 4: RecipeQuene.Enqueue(recipe); break;
// case 3: LThreeRecipeQuene.Enqueue(recipe); break;
// case 2:
// case 5: LTwoRecipeQuene.Enqueue(recipe); break;
// }
// ReicpeNum++;
// MessageLog.GetInstance.ShowUserLog($"接收到第{ReicpeNum}个配方");
//}
ReicpeNum = ReicpeNum + recipes.Length;
MessageLog.GetInstance.ShowUserLog($"新接收到{recipes.Length}个配方,总共{ReicpeNum}个配方");
for (int i = 0; i < recipes.Length; i++)
@@ -762,9 +757,11 @@ namespace FryPot_DosingSystem.Control
//LOneFryPotOutputMaterial();
//LTwoFryPotOutputMaterial();
//LThreeFryPotOutputMaterial();
LineOneProcessExecute();
LineTwoProcessExecute();
LineThreeProcessExecute();
ThreadManage.GetInstance().StartLong(new Action(() => { LineOneProcessExecute();Thread.Sleep(10);}) , "滚筒线1任务线程");
ThreadManage.GetInstance().StartLong(new Action(() => { LineTwoProcessExecute(); Thread.Sleep(10); }), "滚筒线2任务线程");
ThreadManage.GetInstance().StartLong(new Action(() => { LineThreeProcessExecute(); Thread.Sleep(10); }), "滚筒线3任务线程");


}
/// <summary>
/// 线体1的执行流程
@@ -774,14 +771,12 @@ namespace FryPot_DosingSystem.Control
if (!globalVar.LOneTaskLock)
{
globalVar.LOneTaskLock = true;
Task.Run(new Action(() =>
{
LOneRecipeDataToPlc();
LOneLoadRoller();
LOneFryPotInputMaterial();
LOneFryPotOutputMaterial();
globalVar.LOneTaskLock = false;
}));
LOneRecipeDataToPlc();
LOneLoadRoller();
LOneFryPotInputMaterial();
LOneFryPotOutputMaterial();
globalVar.LOneTaskLock = false;


}

@@ -794,14 +789,12 @@ namespace FryPot_DosingSystem.Control
if (!globalVar.LTwoTaskLock)
{
globalVar.LTwoTaskLock = true;
Task.Run(new Action(() =>
{
LTwoRecipeDataToPlc();
LTwoAgvLoadRoller();
LTwoFryPotInputMaterial();
LTwoFryPotOutputMaterial();
globalVar.LTwoTaskLock = false;
}));
LTwoRecipeDataToPlc();
LTwoAgvLoadRoller();
LTwoFryPotInputMaterial();
LTwoFryPotOutputMaterial();
globalVar.LTwoTaskLock = false;

}
}
/// <summary>
@@ -812,14 +805,12 @@ namespace FryPot_DosingSystem.Control
if (!globalVar.LThreeTaskLock)
{
globalVar.LThreeTaskLock = true;
Task.Run(new Action(() =>
{
LThreeRecipeDataToPlc();
LThreeAgvLoadRoller();
LThreeFryPotInputMaterial();
LThreeFryPotOutputMaterial();
globalVar.LThreeTaskLock = false;
}));
LThreeRecipeDataToPlc();
LThreeAgvLoadRoller();
LThreeFryPotInputMaterial();
LThreeFryPotOutputMaterial();
globalVar.LThreeTaskLock = false;

}
}

@@ -950,7 +941,7 @@ namespace FryPot_DosingSystem.Control
MessageLog.GetInstance.ShowUserLog($"【1】号滚筒线开始制作【{result.RecipeName}】 配方");
for (int i = 0; i < result.materialCollection.Count; i++) //遍历单个配方中所有物料
{
if (result.materialCollection.Count<=8&&result.materialCollection[i].MaterialLoc % 100 == i + 1 && result.materialCollection[i].MaterialLoc / 100 == headNum && (headNum == 1 || headNum == 4))
if (result.materialCollection.Count <= 8 && result.materialCollection[i].MaterialLoc % 100 == i + 1 && result.materialCollection[i].MaterialLoc / 100 == headNum && (headNum == 1 || headNum == 4))
{
//将配方中原料加入新的队列
InputMaterialQuene.Enqueue(new MaterialInfo()
@@ -1430,14 +1421,14 @@ namespace FryPot_DosingSystem.Control
Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
}
MessageLog.GetInstance.ShowRunLog($"炒锅【2】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
MessageLog.GetInstance.ShowRunLog($"炒锅【2】原料:{LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
case 5:
while (globalVar.fryPotFive.InputMaterialArrivedSingle == 0)
{
Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
}
MessageLog.GetInstance.ShowRunLog($"炒锅【5】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
MessageLog.GetInstance.ShowRunLog($"炒锅【5】原料:{LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
}
}
public void FryPotThreeInputMaterialRollerOperate()
@@ -1447,7 +1438,7 @@ namespace FryPot_DosingSystem.Control
Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
}
MessageLog.GetInstance.ShowRunLog($"炒锅【3】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料");
MessageLog.GetInstance.ShowRunLog($"炒锅【3】原料:{LThreeOutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料");
}
/// <summary>
/// 炒锅滚筒空桶出桶处理


+ 2
- 2
FryPot_DosingSystem/View/RecipeSetView.xaml View File

@@ -58,7 +58,7 @@
Foreground="Aqua"
IcoText="&#xe626;"
Cursor="Hand"
Style="{StaticResource NewButtonStyle}"
Style="{StaticResource IcoButtonStyle}"
Command="{Binding NewRecipe}">
</pry:IcoButton>
<pry:IcoButton
@@ -68,7 +68,7 @@
Foreground="Aqua"
IcoText="&#xe626;"
Cursor="Hand"
Style="{StaticResource NewButtonStyle}"
Style="{StaticResource IcoButtonStyle}"
Command="{Binding SaveRecipe}">
</pry:IcoButton>



Loading…
Cancel
Save