Browse Source

180项目逻辑控制更新

样式分支
taoye 2 years ago
parent
commit
36b2acd335
13 changed files with 986 additions and 97 deletions
  1. +88
    -3
      BPASmartClient.AGV/AGVHelper.cs
  2. +1
    -1
      BPASmartClient.Helper/RTrig.cs
  3. +4
    -0
      BPASmartClient.Helper/ThreadManage.cs
  4. +777
    -70
      FryPot_DosingSystem/Control/DosingLogicControl.cs
  5. +35
    -11
      FryPot_DosingSystem/Control/GlobalVariable.cs
  6. +15
    -0
      FryPot_DosingSystem/Control/MaterialInfo.cs
  7. +1
    -0
      FryPot_DosingSystem/FryPot_DosingSystem.csproj
  8. +4
    -4
      FryPot_DosingSystem/Model/MaterialType.cs
  9. +1
    -1
      FryPot_DosingSystem/Model/RecipeModel.cs
  10. +5
    -0
      FryPot_DosingSystem/View/MainWindow.xaml
  11. +28
    -6
      FryPot_DosingSystem/ViewModel/MainViewModel.cs
  12. +3
    -0
      FryPot_DosingSystem/ViewModel/RecipeSetDownViewModel.cs
  13. +24
    -1
      SmartClient.sln

+ 88
- 3
BPASmartClient.AGV/AGVHelper.cs View File

@@ -52,9 +52,94 @@ namespace BPASmartClient.AGV
request.Abort();
}
return retString;//返回响应报文


}
/// <summary>
/// AGV去1号线体装桶
/// </summary>
/// <returns></returns>
public string AgvToLineOneLoadRoller()
{
string url = "";
string head = "";
string body = "";
return HttpRequest(url,head,body);
}
/// <summary>
/// AGV去2号线体装桶
/// </summary>
/// <returns></returns>
public string AgvToLineTwoLoadRoller()
{
string url = "";
string head = "";
string body = "";
return HttpRequest(url, head, body);
}
/// <summary>
/// AGV去3号线体装桶
/// </summary>
/// <returns></returns>
public string AgvToLineThreeLoadRoller()
{
string url = "";
string head = "";
string body = "";
return HttpRequest(url, head, body);
}
/// <summary>
/// AGV离开炒锅1
/// </summary>
/// <returns></returns>
public string AgvLeaveFryPotOne()
{
string url = "";
string head = "";
string body = "";
return HttpRequest(url, head, body);
}
/// <summary>
/// AGV离开炒锅2
/// </summary>
/// <returns></returns>
public string AgvLeaveFryPotTwo()
{
string url = "";
string head = "";
string body = "";
return HttpRequest(url, head, body);
}
/// <summary>
/// AGV离开炒锅3
/// </summary>
/// <returns></returns>
public string AgvLeaveFryPotThree()
{
string url = "";
string head = "";
string body = "";
return HttpRequest(url, head, body);
}
/// <summary>
/// AGV离开炒锅4
/// </summary>
/// <returns></returns>
public string AgvLeaveFryPotFour()
{
string url = "";
string head = "";
string body = "";
return HttpRequest(url, head, body);
}
/// <summary>
/// AGV离开炒锅5
/// </summary>
/// <returns></returns>
public string AgvLeaveFryPotFive()
{
string url = "";
string head = "";
string body = "";
return HttpRequest(url, head, body);
}
}
}

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

@@ -15,7 +15,7 @@ namespace BPASmartClient.Helper
private volatile static ConcurrentDictionary<string, RTrig> _Instance;
public static RTrig GetInstance(string name)
{
if (_Instance == null) _Instance = new ConcurrentDictionary<string, RTrig>();
if (_Instance == null) _Instance = new ConcurrentDictionary<string, RTrig>();
if (!_Instance.ContainsKey(name)) _Instance.TryAdd(name, new RTrig());
return _Instance[name];
}


+ 4
- 0
BPASmartClient.Helper/ThreadManage.cs View File

@@ -32,6 +32,10 @@ namespace BPASmartClient.Helper
if (CancellationTokenSources.ContainsKey(guid + key))
{
CancellationTokenSources[guid + key]?.Cancel();
if (key.Equals("MainTask"))
{
ActionManage.GetInstance.Send("FryPotDosingMainTaskExit");
}
ActionManage.GetInstance.Register(ExitCallback, guid + key);
}
else


+ 777
- 70
FryPot_DosingSystem/Control/DosingLogicControl.cs View File

@@ -1,4 +1,6 @@
using BPASmartClient.Helper;
using BPASmartClient.AGV;
using BPASmartClient.Helper;
using BPASmartClient.Message;
using FryPot_DosingSystem.Model;
using System;
using System.Collections.Concurrent;
@@ -14,13 +16,78 @@ namespace FryPot_DosingSystem.Control
internal class DosingLogicControl
{
public static DosingLogicControl _instance;
public static DosingLogicControl GetInstance=>_instance ??= new DosingLogicControl();
public ConcurrentDictionary<string,object> PlcReadData=new ConcurrentDictionary<string, object>();
public static DosingLogicControl GetInstance => _instance ??= new DosingLogicControl();
public ConcurrentDictionary<string, object> PlcReadData = new ConcurrentDictionary<string, object>();
/// <summary>
/// 配方队列
/// </summary>
public ConcurrentQueue<NewRecipeModel> RecipeQuene = new ConcurrentQueue<NewRecipeModel>();
/// <summary>
/// 进料原料队列
/// </summary>
public ConcurrentQueue<MaterialInfo> InputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
/// <summary>
/// 出料原料队列
/// </summary>
public ConcurrentQueue<MaterialInfo> OutputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
/// <summary>
/// 全局变量对象声明
/// </summary>
GlobalVariable globalVar;

#region 上位机内部变量
int lineAlarm = 0;//线体故障信号 1:无故障 -1:故障
int FryPotAlarm = 0;//炒锅滚筒故障信号 1:无故障 -1:故障
int ReicpeNum = 0;//记录接收到的配方数
#endregion
#region agv临时变量
bool agvArriveLine = false;//agv是否到达线体装料位置
bool agvArriveFryPot = false;//agv是否到达炒锅送料位置
bool agvFryPotEmptyRollerArrive = false;//agv是否拿到炒锅空桶
#endregion
public DosingLogicControl()
{
globalVar = new GlobalVariable();
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(() => { globalVar.PlcInite = 1; }), "StartPlcInite");
ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 0; }), "EndPlcInite");
ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitMainTask = true; }), "FryPotDosingMainTaskExit");
ResetProgram();
ReadPlcData();
IniteTask();
}
/// <summary>
/// 主任务重启
/// </summary>
private void ResetProgram()
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (RTrig.GetInstance("ResetProgram").Start(globalVar.PlcInite == 1))//判断是否初始化 一初始化就重启主任务
{
MessageLog.GetInstance.Show("主任务正在重启");
ThreadManage.GetInstance().StopTask("MainTask", new Action(() =>
{
ThreadManage.GetInstance().StopTask("MainViewReadPlcData", 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.Show("主任务重启完成");
}));
}));
}

Thread.Sleep(10);
}), "ResetProgram");
}
/// <summary>
/// 实时获取plc数据
/// </summary>
public void ReadPlcData()
@@ -29,93 +96,96 @@ namespace FryPot_DosingSystem.Control
{
GetAddressData("D2001", new Action<ushort[]>((data) =>
{
GlobalVariable.rollerLineOne.StationOne = data[0];
GlobalVariable.rollerLineOne.StationTwo = data[1];
GlobalVariable.rollerLineOne.StationThree = data[2];
GlobalVariable.rollerLineOne.StationFour = data[3];
GlobalVariable.rollerLineOne.StationFive = data[4];
GlobalVariable.rollerLineOne.StationSix = data[5];
GlobalVariable.rollerLineOne.StationSeven = data[6];
GlobalVariable.rollerLineOne.StationEight = data[7];
globalVar.rollerLineOne.StationOne = data[0];
globalVar.rollerLineOne.StationTwo = data[1];
globalVar.rollerLineOne.StationThree = data[2];
globalVar.rollerLineOne.StationFour = data[3];
globalVar.rollerLineOne.StationFive = data[4];
globalVar.rollerLineOne.StationSix = data[5];
globalVar.rollerLineOne.StationSeven = data[6];
globalVar.rollerLineOne.StationEight = data[7];
}));
GetAddressData("D2011", new Action<ushort[]>((data) =>
{
GlobalVariable.rollerLineTwo.StationOne = data[0];
GlobalVariable.rollerLineTwo.StationTwo = data[1];
GlobalVariable.rollerLineTwo.StationThree = data[2];
GlobalVariable.rollerLineTwo.StationFour = data[3];
GlobalVariable.rollerLineTwo.StationFive = data[4];
GlobalVariable.rollerLineTwo.StationSix = data[5];
GlobalVariable.rollerLineTwo.StationSeven = data[6];
GlobalVariable.rollerLineTwo.StationEight = data[7];
globalVar.rollerLineTwo.StationOne = data[0];
globalVar.rollerLineTwo.StationTwo = data[1];
globalVar.rollerLineTwo.StationThree = data[2];
globalVar.rollerLineTwo.StationFour = data[3];
globalVar.rollerLineTwo.StationFive = data[4];
globalVar.rollerLineTwo.StationSix = data[5];
globalVar.rollerLineTwo.StationSeven = data[6];
globalVar.rollerLineTwo.StationEight = data[7];
}));
GetAddressData("D2021", new Action<ushort[]>((data) =>
{
GlobalVariable.rollerLineThree.StationOne = data[0];
GlobalVariable.rollerLineThree.StationTwo = data[1];
GlobalVariable.rollerLineThree.StationThree = data[2];
GlobalVariable.rollerLineThree.StationFour = data[3];
GlobalVariable.rollerLineThree.StationFive = data[4];
GlobalVariable.rollerLineThree.StationSix = data[5];
GlobalVariable.rollerLineThree.StationSeven = data[6];
GlobalVariable.rollerLineThree.StationEight = data[7];
globalVar.rollerLineThree.StationOne = data[0];
globalVar.rollerLineThree.StationTwo = data[1];
globalVar.rollerLineThree.StationThree = data[2];
globalVar.rollerLineThree.StationFour = data[3];
globalVar.rollerLineThree.StationFive = data[4];
globalVar.rollerLineThree.StationSix = data[5];
globalVar.rollerLineThree.StationSeven = data[6];
globalVar.rollerLineThree.StationEight = data[7];
}));
GetAddressData("D2040", new Action<ushort[]>((data) =>
{
GlobalVariable.fryPotOne.InputMaterialRollerRunningSingle = data[0];
GlobalVariable.fryPotTwo.InputMaterialRollerRunningSingle = data[1];
GlobalVariable.fryPotThree.InputMaterialRollerRunningSingle = data[2];
GlobalVariable.fryPotFour.InputMaterialRollerRunningSingle = data[3];
GlobalVariable.fryPotFive.InputMaterialRollerRunningSingle= data[4];
globalVar.fryPotOne.InputMaterialRollerRunningSingle = data[0];
globalVar.fryPotTwo.InputMaterialRollerRunningSingle = data[1];
globalVar.fryPotThree.InputMaterialRollerRunningSingle = data[2];
globalVar.fryPotFour.InputMaterialRollerRunningSingle = data[3];
globalVar.fryPotFive.InputMaterialRollerRunningSingle = data[4];
}));
GetAddressData("D2045", new Action<ushort[]>((data) =>
{
GlobalVariable.fryPotOne.InputMaterialArrivedSingle = data[0];
GlobalVariable.fryPotTwo.InputMaterialArrivedSingle = data[1];
GlobalVariable.fryPotThree.InputMaterialArrivedSingle = data[2];
GlobalVariable.fryPotFour.InputMaterialArrivedSingle = data[3];
GlobalVariable.fryPotFive.InputMaterialArrivedSingle = data[4];
globalVar.fryPotOne.InputMaterialArrivedSingle = data[0];
globalVar.fryPotTwo.InputMaterialArrivedSingle = data[1];
globalVar.fryPotThree.InputMaterialArrivedSingle = data[2];
globalVar.fryPotFour.InputMaterialArrivedSingle = data[3];
globalVar.fryPotFive.InputMaterialArrivedSingle = data[4];
}));
GetAddressData("D2050", new Action<ushort[]>((data) =>
{
GlobalVariable.fryPotOne.EmptyBarrelArrivedSingle = data[0];
GlobalVariable.fryPotTwo.EmptyBarrelArrivedSingle = data[1];
GlobalVariable.fryPotThree.EmptyBarrelArrivedSingle = data[2];
GlobalVariable.fryPotFour.EmptyBarrelArrivedSingle = data[3];
GlobalVariable.fryPotFive.EmptyBarrelArrivedSingle = data[4];
globalVar.fryPotOne.EmptyBarrelArrivedSingle = data[0];
globalVar.fryPotTwo.EmptyBarrelArrivedSingle = data[1];
globalVar.fryPotThree.EmptyBarrelArrivedSingle = data[2];
globalVar.fryPotFour.EmptyBarrelArrivedSingle = data[3];
globalVar.fryPotFive.EmptyBarrelArrivedSingle = data[4];
}));
GetAddressData("D2065", new Action<ushort[]>((data) =>
{
GlobalVariable.fryPotOne.EmptyBarrelRollerRunningSingle = data[0];
GlobalVariable.fryPotTwo.EmptyBarrelRollerRunningSingle = data[1];
GlobalVariable.fryPotThree.EmptyBarrelRollerRunningSingle = data[2];
GlobalVariable.fryPotFour.EmptyBarrelRollerRunningSingle = data[3];
GlobalVariable.fryPotFive.EmptyBarrelRollerRunningSingle = data[4];
globalVar.fryPotOne.EmptyBarrelRollerRunningSingle = data[0];
globalVar.fryPotTwo.EmptyBarrelRollerRunningSingle = data[1];
globalVar.fryPotThree.EmptyBarrelRollerRunningSingle = data[2];
globalVar.fryPotFour.EmptyBarrelRollerRunningSingle = data[3];
globalVar.fryPotFive.EmptyBarrelRollerRunningSingle = data[4];
}));
GetAddressData("D2070", new Action<ushort[]>((data) =>
{
GlobalVariable.fryPotOne.RollerTroubleSingle = data[0];
GlobalVariable.fryPotTwo.RollerTroubleSingle = data[1];
GlobalVariable.fryPotThree.RollerTroubleSingle = data[2];
GlobalVariable.fryPotFour.RollerTroubleSingle = data[3];
GlobalVariable.fryPotFive.RollerTroubleSingle = data[4];
globalVar.fryPotOne.RollerTroubleSingle = data[0];
globalVar.fryPotTwo.RollerTroubleSingle = data[1];
globalVar.fryPotThree.RollerTroubleSingle = data[2];
globalVar.fryPotFour.RollerTroubleSingle = data[3];
globalVar.fryPotFive.RollerTroubleSingle = data[4];
}));
GetAddressData("D2078",new Action<ushort[]>(data => {
GlobalVariable.rollerLineOne.RecipeCompleteSingle = data[0];
GlobalVariable.rollerLineTwo.RecipeCompleteSingle = data[1];
GlobalVariable.rollerLineThree.RecipeCompleteSingle = data[2];
GetAddressData("D2078", new Action<ushort[]>(data =>
{
globalVar.rollerLineOne.RecipeCompleteSingle = data[0];
globalVar.rollerLineTwo.RecipeCompleteSingle = data[1];
globalVar.rollerLineThree.RecipeCompleteSingle = data[2];
}));
GetAddressData("D2075",new Action<ushort[]>(data => {
GlobalVariable.CleadBarrelEnterSingle = data[0];
GetAddressData("D2075", new Action<ushort[]>(data =>
{

globalVar.CleadBarrelEnterSingle = data[0];
}));
GetAddressData("D2077", new Action<ushort[]>(data => {
GetAddressData("D2077", new Action<ushort[]>(data =>
{

GlobalVariable.CleadBarrelExitSingle = data[0];
globalVar.CleadBarrelExitSingle = data[0];
}));
Thread.Sleep(10);
}), "MainViewReadPlcData");
}

/// <summary>
@@ -125,7 +195,7 @@ namespace FryPot_DosingSystem.Control
/// <returns></returns>
public void GetAddressData(string address, Action<ushort[]> action)
{
PlcReadData= DeviceOperate.GetInstance.GetAllData();
PlcReadData = DeviceOperate.GetInstance.GetAllData();
if (PlcReadData.ContainsKey(address))
{
action((ushort[])(PlcReadData[address]));
@@ -137,7 +207,7 @@ namespace FryPot_DosingSystem.Control
/// <param name="address"></param>
/// <param name="Value"></param>
public void WritePlcData(string address, ushort Value)
{
{
DeviceOperate.GetInstance.WritePlcData(address, Value);
}
/// <summary>
@@ -145,18 +215,655 @@ namespace FryPot_DosingSystem.Control
/// </summary>
public void IniteTask()
{
ThreadManage.GetInstance().StartLong(new Action(() => {
ThreadManage.GetInstance().StartLong(new Action(() =>
{
MainTask();
}),"启动主任务循环",true);
}), "MainTask");
}
/// <summary>
/// 配方数据接收
/// </summary>
public void RecipeDataParse(object obj)
{
if (obj != null && obj is NewRecipeModel recipe)
{
RecipeQuene.Enqueue(recipe);
ReicpeNum++;
MessageLog.GetInstance.Show($"接收到{ReicpeNum}个配方");
}

}
/// <summary>
/// 开启主任务
/// </summary>
public void MainTask()
{
{
RecipeDataToPlc();
AgvLoadRoller();
FryPotInputMaterial();
FryPotOutputMaterial();
}
/// <summary>
/// 数据下发PLC
/// </summary>
public void RecipeDataToPlc()
{
if (RecipeQuene.Count > 0 && OutputMaterialQuene.Count == 0 && InputMaterialQuene.Count == 0)//后续添加其它限制条件
{

if (RecipeQuene.TryDequeue(out NewRecipeModel result))
{
MessageLog.GetInstance.Show($"开始制作【{result.RecipeName}】 配方");
for (int i = 0; i < result.materialCollection.Count; i++) //遍历单个配方中所有物料
{
//将配方中原料加入新的队列
InputMaterialQuene.Enqueue(new MaterialInfo()
{
materialType = result.materialCollection[i],
materialId = result.RecipeId
});
ushort n = result.materialCollection[i].MaterialLoc;
switch (n / 100)
{
case 1:
case 4: RollerOneDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight); break;//1号滚筒线桶号以及重量数据下发
case 2:
case 5: RollerTwoDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight); break;//2号滚筒线桶号以及重量数据下发
case 3: RollerThreeDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight); break;//3号滚筒线桶号以及重量数据下发
}
}
switch (result.materialCollection[0].MaterialLoc / 100)
{
case 1:
DeviceOperate.GetInstance.WritePlcData("D1009", (ushort)result.materialCollection.Count); break;//发送1号滚筒线工序数据
case 2:
DeviceOperate.GetInstance.WritePlcData("D1026", (ushort)result.materialCollection.Count); break;//发送2号滚筒线工序数据
case 3:
DeviceOperate.GetInstance.WritePlcData("D1043", (ushort)result.materialCollection.Count); break;//发送3号滚筒线工序数据
}
}
}

}
/// <summary>
/// AGV到配方对应线体装桶以及出料到炒锅
/// </summary>
public void AgvLoadRoller()
{
lineAlarm = 0;
if (InputMaterialQuene.Count > 0)
{
switch (InputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
{
case 1:
case 4: AgvToLineOneLoadRoller(); AgvFromLineOneToFryPot(); break;//AGV到1号线体装桶
case 2:
case 5: AgvToLineTwoLoadRoller(); AgvFromLineTwoToFryPot(); break;//AGV到2号线体装桶
case 3: AgvToLineThreeLoadRoller(); AgvFromLineThreeToFryPot(); break;//AGV到3号线体装桶
}
}

}
/// <summary>
/// AGV从炒锅送料位置到倒料过程处理
/// </summary>
public void FryPotInputMaterial()
{
if (OutputMaterialQuene.Count > 0 && !globalVar.InOrOutputLock)
{
while (!agvArriveFryPot)//等待agv到达炒锅位置
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
AgvArriveFryPotSingleSetDown();
FryPotRollerTroubleCheck();
if (FryPotAlarm == 1)//炒锅滚筒无故障
{
//炒锅滚筒进料运行到位处理
FryPotInputMaterialRollerOperate();
globalVar.InOrOutputLock = true;
}
else
{
//MessageLog.GetInstance.ShowEx($"警告:炒锅{OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100}滚筒故障!!!");
}
}

}
/// <summary>
/// 炒锅出桶
/// </summary>
public void FryPotOutputMaterial()
{
if (OutputMaterialQuene.Count > 0 && globalVar.InOrOutputLock)
{
while (!agvArriveFryPot)//等待agv到达炒锅位置
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
AgvArriveFryPotOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号
FryPotRollerTroubleCheck();
if (FryPotAlarm == 1)//无故障
{
FryPotOutEmpetyRollerOperate();
if (OutputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))//空桶出桶后,出料原料队列移除对应原料
{
while (!agvFryPotEmptyRollerArrive)//等待AGV拿到出桶空桶
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
//AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅
globalVar.AllowAgvToLineLoadRoller = true;
globalVar.InOrOutputLock = false;
}
}
else//有故障
{

}
}
}
/// <summary>
/// 炒锅滚筒进料运行到位处理
/// </summary>
public void FryPotInputMaterialRollerOperate()
{
switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
{
case 1:
while (globalVar.fryPotOne.InputMaterialArrivedSingle == 0 || globalVar.fryPotOne.InputMaterialRollerRunningSingle == 0)
{
Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
}
MessageLog.GetInstance.Show($"炒锅【1】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
case 2:
while (globalVar.fryPotTwo.InputMaterialArrivedSingle == 0 || globalVar.fryPotTwo.InputMaterialRollerRunningSingle == 0)
{
Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
}
MessageLog.GetInstance.Show($"炒锅【2】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
case 3:
while (globalVar.fryPotThree.InputMaterialArrivedSingle == 0 || globalVar.fryPotThree.InputMaterialRollerRunningSingle == 0)
{
Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
}
MessageLog.GetInstance.Show($"炒锅【3】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
case 4:
while (globalVar.fryPotFour.InputMaterialArrivedSingle == 0 || globalVar.fryPotFour.InputMaterialRollerRunningSingle == 0)
{
Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
}
MessageLog.GetInstance.Show($"炒锅【4】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
case 5:
while (globalVar.fryPotFive.InputMaterialArrivedSingle == 0 || globalVar.fryPotFive.InputMaterialRollerRunningSingle == 0)
{
Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
}
MessageLog.GetInstance.Show($"炒锅【5】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
}

}
/// <summary>
/// 炒锅滚筒空桶出桶处理
/// </summary>
public void FryPotOutEmpetyRollerOperate()
{
switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
{
case 1: while (globalVar.fryPotOne.EmptyBarrelArrivedSingle == 0 || globalVar.fryPotOne.EmptyBarrelRollerRunningSingle == 0) { Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
} MessageLog.GetInstance.Show($"炒锅【1】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break;
case 2: while (globalVar.fryPotTwo.EmptyBarrelArrivedSingle == 0 || globalVar.fryPotTwo.EmptyBarrelRollerRunningSingle == 0) { Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
} MessageLog.GetInstance.Show($"炒锅【2】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break;
case 3: while (globalVar.fryPotThree.EmptyBarrelArrivedSingle == 0 || globalVar.fryPotThree.EmptyBarrelRollerRunningSingle == 0) { Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
} MessageLog.GetInstance.Show($"炒锅【3】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break;
case 4: while (globalVar.fryPotFour.EmptyBarrelArrivedSingle == 0 || globalVar.fryPotFour.EmptyBarrelRollerRunningSingle == 0) { Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
} MessageLog.GetInstance.Show($"炒锅【4】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break;
case 5: while (globalVar.fryPotFive.EmptyBarrelArrivedSingle == 0 || globalVar.fryPotFive.EmptyBarrelRollerRunningSingle == 0) { Thread.Sleep(5); if (globalVar.ExitMainTask)
return;
} MessageLog.GetInstance.Show($"炒锅【5】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break;

}
}
/// <summary>
/// 发送agv送料就位信号至PLC(线体到炒锅)
/// </summary>
public void AgvArriveFryPotSingleSetDown()
{
switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
{
case 1: DeviceOperate.GetInstance.WritePlcData("D1055", 1); break;//agv到炒锅1送料就位信号
case 2: DeviceOperate.GetInstance.WritePlcData("D1056", 1); break;//agv到炒锅2送料就位信号
case 3: DeviceOperate.GetInstance.WritePlcData("D1057", 1); break;//agv到炒锅3送料就位信号
case 4: DeviceOperate.GetInstance.WritePlcData("D1058", 1); break;//agv到炒锅4送料就位信号
case 5: DeviceOperate.GetInstance.WritePlcData("D1059", 1); break;//agv到炒锅5送料就位信号
}
}
/// <summary>
/// 发送agv回桶就位信号至PLC
/// </summary>
public void AgvArriveFryPotOutEmptyRollerSingleSetDown()
{
switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
{
case 1: DeviceOperate.GetInstance.WritePlcData("D1060", 1); break;//agv到炒锅1送料就位信号
case 2: DeviceOperate.GetInstance.WritePlcData("D1061", 1); break;//agv到炒锅2送料就位信号
case 3: DeviceOperate.GetInstance.WritePlcData("D1062", 1); break;//agv到炒锅3送料就位信号
case 4: DeviceOperate.GetInstance.WritePlcData("D1063", 1); break;//agv到炒锅4送料就位信号
case 5: DeviceOperate.GetInstance.WritePlcData("D1064", 1); break;//agv到炒锅5送料就位信号
}
}
/// <summary>
/// 处理agv从线体1到送料到炒锅的条件
/// </summary>
/// <param name="lineAlarm"></param>
public void AgvFromLineOneToFryPot()
{
erp: if (lineAlarm == 1)//无故障
{
while (!agvArriveLine)//等待AGV到线体装料位置
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
agvArriveLine = false;
AgvArriveLineSingelSetDown();
if (InputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
{
while (!(globalVar.rollerLineOne.StationEight == materialInfo.materialType.MaterialLoc))//等待线体工号位8存放对应原料桶号
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
OutputMaterialQuene.Enqueue(materialInfo);
//原料到位,agv到位,agv运料到炒锅
}

}
else//有故障
{
while (lineAlarm == -1)
{
Thread.Sleep(50);
if (globalVar.ExitMainTask)
return;
}
MessageLog.GetInstance.Show("线体【1】滚筒故障解除,继续运行");
lineAlarm = 1;
goto erp;
}
}
/// <summary>
/// 处理agv从线体2到送料到炒锅的条件
/// </summary>
/// <param name="lineAlarm"></param>
public void AgvFromLineTwoToFryPot()
{
erp: if (lineAlarm == 1)//无故障
{
while (!agvArriveLine)//等待AGV到线体装料位置
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
agvArriveLine = false;
AgvArriveLineSingelSetDown();
if (InputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
{
while (!(globalVar.rollerLineTwo.StationEight == materialInfo.materialType.MaterialLoc))//等待线体工号位8存放对应原料桶号
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
OutputMaterialQuene.Enqueue(materialInfo);
//原料到位,agv到位,agv运料到炒锅
}

}
else//有故障
{
while (lineAlarm == -1)
{
Thread.Sleep(50);
if (globalVar.ExitMainTask)
return;
}
MessageLog.GetInstance.Show("线体【2】滚筒故障解除,继续运行");
lineAlarm = 1;
goto erp;
}
}
/// <summary>
/// 处理agv从线体3到送料到炒锅的条件
/// </summary>
/// <param name="lineAlarm"></param>
public void AgvFromLineThreeToFryPot()
{
erp: if (lineAlarm == 1)//无故障
{
while (!agvArriveLine)//等待AGV到线体装料位置
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
agvArriveLine = false;
AgvArriveLineSingelSetDown();
if (InputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
{
while (!(globalVar.rollerLineThree.StationEight == materialInfo.materialType.MaterialLoc))//等待线体工号位8存放对应原料桶号
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
OutputMaterialQuene.Enqueue(materialInfo);
//原料到位,agv到位,agv运料到炒锅
}

}
else//有故障
{
while (lineAlarm == -1)
{
Thread.Sleep(50);
if (globalVar.ExitMainTask)
return;
}
MessageLog.GetInstance.Show("线体【3】滚筒故障解除,继续运行");
lineAlarm = 1;
goto erp;
}
}
public void AgvToLineOneLoadRoller()
{
if (globalVar.rollerLineOne.OutMaterialingTroubleSingle == 0)//输送线无故障
{
if (InputMaterialQuene.Count > 0)
{
while (!globalVar.AllowAgvToLineLoadRoller || globalVar.rollerLineOne.OutMaterialingSingle == 0)
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
AGVHelper.GetInstance.AgvToLineOneLoadRoller();
MessageLog.GetInstance.Show("AGV去1号线体");
globalVar.AllowAgvToLineLoadRoller = false;
}
}
else
{
MessageLog.GetInstance.ShowEx("警告:滚筒输送线体【1】故障!!!");
lineAlarm = -1;
}
lineAlarm = 1;
}
public void AgvToLineTwoLoadRoller()
{
if (globalVar.rollerLineTwo.OutMaterialingTroubleSingle == 0)//输送线无故障
{
if (InputMaterialQuene.Count > 0)
{
while (!globalVar.AllowAgvToLineLoadRoller || globalVar.rollerLineOne.OutMaterialingSingle == 0) //后续考虑是否用while
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
AGVHelper.GetInstance.AgvToLineTwoLoadRoller();
MessageLog.GetInstance.Show("AGV去2号线体");
globalVar.AllowAgvToLineLoadRoller = false;
}

}
else
{
MessageLog.GetInstance.ShowEx("警告:滚筒输送线体【2】故障!!!");
lineAlarm = -1;
}
lineAlarm = 1;
}
public void AgvToLineThreeLoadRoller()
{
if (globalVar.rollerLineThree.OutMaterialingTroubleSingle == 0)//输送线无故障
{
if (InputMaterialQuene.Count > 0)
{
while (!globalVar.AllowAgvToLineLoadRoller || globalVar.rollerLineOne.OutMaterialingSingle == 0) //后续考虑是否用while
{
Thread.Sleep(5);
if (globalVar.ExitMainTask)
return;
}
AGVHelper.GetInstance.AgvToLineThreeLoadRoller();
MessageLog.GetInstance.Show("AGV去3号线体");
globalVar.AllowAgvToLineLoadRoller = false;
}

}
else
{
MessageLog.GetInstance.ShowEx("警告:滚筒输送线体【3】故障!!!");
lineAlarm = -1;
}
lineAlarm = 1;
}
/// <summary>
/// 1号线体数据下发
/// </summary>
/// <param name="count"></param>
/// <param name="materialLoc"></param>
/// <param name="materialWeight"></param>
public void RollerOneDataWrite(int count, ushort materialLoc, ushort materialWeight)
{
switch (count)
{
case 0:
DeviceOperate.GetInstance.WritePlcData("D1001", materialLoc);//桶1位置
DeviceOperate.GetInstance.WritePlcData("D1010", materialWeight);//桶2重量
break;
case 1:
DeviceOperate.GetInstance.WritePlcData("D1002", materialLoc);//桶2位置
DeviceOperate.GetInstance.WritePlcData("D1011", materialWeight);//桶2重量
break;
case 2:
DeviceOperate.GetInstance.WritePlcData("D1003", materialLoc);//桶3位置
DeviceOperate.GetInstance.WritePlcData("D1012", materialWeight);//桶3重量
break;
case 3:
DeviceOperate.GetInstance.WritePlcData("D1004", materialLoc);//桶4位置
DeviceOperate.GetInstance.WritePlcData("D1013", materialWeight);//桶4重量
break;
case 4:
DeviceOperate.GetInstance.WritePlcData("D1005", materialLoc);//桶5位置
DeviceOperate.GetInstance.WritePlcData("D1014", materialWeight);//桶5重量
break;
case 5:
DeviceOperate.GetInstance.WritePlcData("D1006", materialLoc);//桶6位置
DeviceOperate.GetInstance.WritePlcData("D1015", materialWeight);//桶6重量
break;
case 6:
DeviceOperate.GetInstance.WritePlcData("D1007", materialLoc);//桶7位置
DeviceOperate.GetInstance.WritePlcData("D1016", materialWeight);//桶7重量
break;
case 7:
DeviceOperate.GetInstance.WritePlcData("D1008", materialLoc);//桶8位置
DeviceOperate.GetInstance.WritePlcData("D1017", materialWeight);//桶8重量
break;

}
}
/// <summary>
/// 2号线体数据下发
/// </summary>
/// <param name="count"></param>
/// <param name="materialLoc"></param>
/// <param name="materialWeight"></param>
public void RollerTwoDataWrite(int count, ushort materialLoc, ushort materialWeight)
{
switch (count)
{
case 0:
DeviceOperate.GetInstance.WritePlcData("D1018", materialLoc);//桶1位置
DeviceOperate.GetInstance.WritePlcData("D1027", materialWeight);//桶2重量
break;
case 1:
DeviceOperate.GetInstance.WritePlcData("D1019", materialLoc);//桶2位置
DeviceOperate.GetInstance.WritePlcData("D1028", materialWeight);//桶2重量
break;
case 2:
DeviceOperate.GetInstance.WritePlcData("D1020", materialLoc);//桶3位置
DeviceOperate.GetInstance.WritePlcData("D1029", materialWeight);//桶3重量
break;
case 3:
DeviceOperate.GetInstance.WritePlcData("D1021", materialLoc);//桶4位置
DeviceOperate.GetInstance.WritePlcData("D1030", materialWeight);//桶4重量
break;
case 4:
DeviceOperate.GetInstance.WritePlcData("D1022", materialLoc);//桶5位置
DeviceOperate.GetInstance.WritePlcData("D1031", materialWeight);//桶5重量
break;
case 5:
DeviceOperate.GetInstance.WritePlcData("D1023", materialLoc);//桶6位置
DeviceOperate.GetInstance.WritePlcData("D1032", materialWeight);//桶6重量
break;
case 6:
DeviceOperate.GetInstance.WritePlcData("D1024", materialLoc);//桶7位置
DeviceOperate.GetInstance.WritePlcData("D1033", materialWeight);//桶7重量
break;
case 7:
DeviceOperate.GetInstance.WritePlcData("D1025", materialLoc);//桶8位置
DeviceOperate.GetInstance.WritePlcData("D1034", materialWeight);//桶8重量
break;

}
}
/// <summary>
/// 3号线体数据下发
/// </summary>
/// <param name="count"></param>
/// <param name="materialLoc"></param>
/// <param name="materialWeight"></param>
public void RollerThreeDataWrite(int count, ushort materialLoc, ushort materialWeight)
{
switch (count)
{
case 0:
DeviceOperate.GetInstance.WritePlcData("D1035", materialLoc);//桶1位置
DeviceOperate.GetInstance.WritePlcData("D1044", materialWeight);//桶2重量
break;
case 1:
DeviceOperate.GetInstance.WritePlcData("D1036", materialLoc);//桶2位置
DeviceOperate.GetInstance.WritePlcData("D1045", materialWeight);//桶2重量
break;
case 2:
DeviceOperate.GetInstance.WritePlcData("D1037", materialLoc);//桶3位置
DeviceOperate.GetInstance.WritePlcData("D1046", materialWeight);//桶3重量
break;
case 3:
DeviceOperate.GetInstance.WritePlcData("D1038", materialLoc);//桶4位置
DeviceOperate.GetInstance.WritePlcData("D1047", materialWeight);//桶4重量
break;
case 4:
DeviceOperate.GetInstance.WritePlcData("D1039", materialLoc);//桶5位置
DeviceOperate.GetInstance.WritePlcData("D1048", materialWeight);//桶5重量
break;
case 5:
DeviceOperate.GetInstance.WritePlcData("D1040", materialLoc);//桶6位置
DeviceOperate.GetInstance.WritePlcData("D1049", materialWeight);//桶6重量
break;
case 6:
DeviceOperate.GetInstance.WritePlcData("D1041", materialLoc);//桶7位置
DeviceOperate.GetInstance.WritePlcData("D1050", materialWeight);//桶7重量
break;
case 7:
DeviceOperate.GetInstance.WritePlcData("D1042", materialLoc);//桶8位置
DeviceOperate.GetInstance.WritePlcData("D1051", materialWeight);//桶8重量
break;

}

}
/// <summary>
/// AGV进料就位信号下发至PLC
/// </summary>
public void AgvArriveLineSingelSetDown()
{
switch (InputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
{
case 1:
case 4: DeviceOperate.GetInstance.WritePlcData("D1052", 1); break;//AGV进料就位信号1
case 2:
case 5: DeviceOperate.GetInstance.WritePlcData("D1053", 1); break;//AGV进料就位信号2
case 3: DeviceOperate.GetInstance.WritePlcData("D1054", 1); break;//AGV进料就位信号3
}

}
/// <summary>
/// 炒锅滚筒信号检测
/// </summary>
public void FryPotRollerTroubleCheck()
{
FryPotAlarm = 0;
switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
{
case 1:
if (globalVar.fryPotOne.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowEx("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotOne.RollerTroubleSingle == 1)
{
Thread.Sleep(50); if (globalVar.ExitMainTask)
return;
}
FryPotAlarm = 1; break;
case 2:
if (globalVar.fryPotTwo.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowEx("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotTwo.RollerTroubleSingle == 1)
{
Thread.Sleep(50); if (globalVar.ExitMainTask)
return;
}
FryPotAlarm = 1; break;
case 3:
if (globalVar.fryPotThree.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowEx("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotThree.RollerTroubleSingle == 1)
{
Thread.Sleep(50); if (globalVar.ExitMainTask)
return;
}
FryPotAlarm = 1; break;
case 4:
if (globalVar.fryPotFour.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowEx("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotFour.RollerTroubleSingle == 1)
{
Thread.Sleep(50); if (globalVar.ExitMainTask)
return;
}
FryPotAlarm = 1; break;
case 5:
if (globalVar.fryPotFive.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowEx("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotFive.RollerTroubleSingle == 1)
{
Thread.Sleep(50); if (globalVar.ExitMainTask)
return;
}
FryPotAlarm = 1; break;

}
}

}
}

+ 35
- 11
FryPot_DosingSystem/Control/GlobalVariable.cs View File

@@ -9,48 +9,70 @@ namespace FryPot_DosingSystem.Control
/// <summary>
/// plc变量
/// </summary>
internal static class GlobalVariable
internal class GlobalVariable
{
/// <summary>
/// 滚筒线1
/// </summary>
public static RollerLineOne rollerLineOne = new RollerLineOne();
public RollerLineOne rollerLineOne = new RollerLineOne();
/// <summary>
/// 滚筒线2
/// </summary>
public static RollerLineTwo rollerLineTwo = new RollerLineTwo();
public RollerLineTwo rollerLineTwo = new RollerLineTwo();
/// <summary>
/// 滚筒线3
/// </summary>
public static RollerLineThree rollerLineThree = new RollerLineThree();
public RollerLineThree rollerLineThree = new RollerLineThree();
/// <summary>
/// 炒锅1
/// </summary>
public static FryPotOne fryPotOne= new FryPotOne();
public FryPotOne fryPotOne= new FryPotOne();
/// <summary>
/// 炒锅2
/// </summary>
public static FryPotTwo fryPotTwo= new FryPotTwo();
public FryPotTwo fryPotTwo= new FryPotTwo();
/// <summary>
/// 炒锅3
/// </summary>
public static FryPotThree fryPotThree= new FryPotThree();
public FryPotThree fryPotThree= new FryPotThree();
/// <summary>
/// 炒锅4
/// </summary>
public static FryPotFour fryPotFour= new FryPotFour();
public FryPotFour fryPotFour= new FryPotFour();
/// <summary>
/// 炒锅5
/// </summary>
public static FryPotFive fryPotFive= new FryPotFive();
public FryPotFive fryPotFive= new FryPotFive();
/// <summary>
/// 洗桶进桶滚筒运行信号
/// </summary>
public static ushort CleadBarrelEnterSingle { get; set; }
public ushort CleadBarrelEnterSingle { get; set; }
/// <summary>
/// 洗桶出桶滚筒运行信号
/// </summary>
public static ushort CleadBarrelExitSingle { get; set; }
public ushort CleadBarrelExitSingle { get; set; }
/// <summary>
/// PLC初始化状态
/// </summary>
public ushort PlcInite { get; set; }
#region 上位机内部逻辑条件
/// <summary>
/// 退出主任务循环
/// </summary>
public bool ExitMainTask { get; set; }
/// <summary>
/// 允许AGV去线体装桶条件
/// </summary>
public bool AllowAgvToLineLoadRoller { get; set; } = true;
/// <summary>
/// 配方唯一ID
/// </summary>
public string RecipeId { get; set; }
/// <summary>
/// 进桶出桶互锁
/// </summary>
public bool InOrOutputLock { get; set; }
#endregion

}
/// <summary>
@@ -102,6 +124,8 @@ namespace FryPot_DosingSystem.Control
/// 当前线体配方完成信号
/// </summary>
public ushort RecipeCompleteSingle { get; set; }


}
/// <summary>
/// 滚筒线2相关变量


+ 15
- 0
FryPot_DosingSystem/Control/MaterialInfo.cs View File

@@ -0,0 +1,15 @@
using FryPot_DosingSystem.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FryPot_DosingSystem.Control
{
internal class MaterialInfo
{
public MaterialType materialType { get; set;}
public string materialId { get; set; }//原料所属配方的唯一ID
}
}

+ 1
- 0
FryPot_DosingSystem/FryPot_DosingSystem.csproj View File

@@ -21,6 +21,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmartClient.AGV\BPASmartClient.AGV.csproj" />
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" />
<ProjectReference Include="..\BPASmartClient.Helper\BPASmartClient.Helper.csproj" />
<ProjectReference Include="..\BPASmartClient.Modbus\BPASmartClient.Modbus.csproj" />


+ 4
- 4
FryPot_DosingSystem/Model/MaterialType.cs View File

@@ -22,13 +22,13 @@ namespace FryPot_DosingSystem.Model
/// <summary>
/// 原料重量
/// </summary>
private string _materialWeight;
public string MaterialWeight { get { return _materialWeight; }set { _materialWeight = value;OnPropertyChanged(); } }
private ushort _materialWeight;
public ushort MaterialWeight { get { return _materialWeight; }set { _materialWeight = value;OnPropertyChanged(); } }
/// <summary>
/// 原料对应桶位置
/// </summary>
private string _materialLoc;
public string MaterialLoc { get { return _materialLoc; } set { _materialLoc = value; OnPropertyChanged(); } }
private ushort _materialLoc;
public ushort MaterialLoc { get { return _materialLoc; } set { _materialLoc = value; OnPropertyChanged(); } }

}


+ 1
- 1
FryPot_DosingSystem/Model/RecipeModel.cs View File

@@ -22,7 +22,7 @@ namespace FryPot_DosingSystem.Model
public string RecipeName { get { return _recipeName; } set { _recipeName = value;OnPropertyChanged(); } }

/// <summary>
/// 配下发状况信息
/// 配下发状况信息
/// </summary>
private string _recipeSetInfo;
public string RecipeSetInfo { get { return _recipeSetInfo; } set { _recipeSetInfo = value; OnPropertyChanged(); } }


+ 5
- 0
FryPot_DosingSystem/View/MainWindow.xaml View File

@@ -226,6 +226,11 @@ ScrollViewer.HorizontalScrollBarVisibility="Hidden"
Margin="5,0,5,0"
Content="开机启动"
IsChecked="{Binding AutoStart}" />
<CheckBox
Margin="5,0,5,0"
Content="设备初始化"
IsChecked="{Binding Status}"
/>
</StackPanel>

<TextBlock


+ 28
- 6
FryPot_DosingSystem/ViewModel/MainViewModel.cs View File

@@ -32,7 +32,7 @@ namespace FryPot_DosingSystem.ViewModel
/// 当前登陆信息
/// </summary>
private UserInfo _currentLoginAccount;
public UserInfo CurrentLoginAccount { get { return _currentLoginAccount; } set { _currentLoginAccount = value;OnPropertyChanged(); } }
public UserInfo CurrentLoginAccount { get { return _currentLoginAccount; } set { _currentLoginAccount = value; OnPropertyChanged(); } }
/// <summary>
/// 不同权限显示不同菜单
/// </summary>
@@ -47,6 +47,28 @@ namespace FryPot_DosingSystem.ViewModel
/// </summary>
public bool AutoStart { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } }

private bool _status;
/// <summary>
/// 设备初始化状态
/// </summary>
public bool Status
{
get { return _status; }
set
{
if (value)
{
ActionManage.GetInstance.Send("StartPlcInite");
}
else
{
ActionManage.GetInstance.Send("EndPlcInite");
}
_status = value;
OnPropertyChanged();
}
}

private Authority authority;
public Authority Authority
{
@@ -65,15 +87,15 @@ namespace FryPot_DosingSystem.ViewModel
}
public MainViewModel()
{
LogViewModel model= LogViewModel.GetInstance;
DeviceOperate deviceOperate=DeviceOperate.GetInstance;//开启实时PLC数据读取
LogViewModel model = LogViewModel.GetInstance;
DeviceOperate deviceOperate = DeviceOperate.GetInstance;//开启实时PLC数据读取
DosingLogicControl logigControl = DosingLogicControl.GetInstance;//开启逻辑控制任务程序
TogglePag = new RelayCommand<object>(DoNavChanged);
Login = new RelayCommand(() =>
{
ActionManage.GetInstance.CancelRegister("ContentUpdate");
ActionManage.GetInstance.Register(new Func<object>(() => { return "注册"; }), "ContentUpdate");
DoNavChanged("AdministratorLoginView.用户登陆");
DoNavChanged("AdministratorLoginView.用户登陆");
UserManagement = false;
});
PasswordChange = new RelayCommand(() =>
@@ -106,7 +128,7 @@ namespace FryPot_DosingSystem.ViewModel
menus.Add(new ActionMenu() { MenuName = "状态监测", CommandParameter = "HardWareStatusView.状态监测", Authority = new Authority[] { Authority.管理员, Authority.技术员, Authority.操作员, Authority.观察员 } });
menus.Add(new ActionMenu() { MenuName = "日志信息", CommandParameter = "LogView.日志信息", Authority = new Authority[] { Authority.管理员, Authority.技术员, Authority.操作员, Authority.观察员 } });
menus.Add(new ActionMenu() { MenuName = "报警记录", CommandParameter = "", Authority = new Authority[] { Authority.管理员, Authority.技术员, Authority.操作员, Authority.观察员 } });
}

public void DoNavChanged(object obj)
@@ -135,7 +157,7 @@ namespace FryPot_DosingSystem.ViewModel
var strs = str.Split("-=");
if (strs != null && strs.Length == 3)
{
var us = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == strs[0] && p.Password == strs[1]&& strs[2] == p.Authority.ToString());
var us = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == strs[0] && p.Password == strs[1] && strs[2] == p.Authority.ToString());
if (us != null)
{
Authority = us.Authority;


+ 3
- 0
FryPot_DosingSystem/ViewModel/RecipeSetDownViewModel.cs View File

@@ -1,4 +1,5 @@
using BPASmartClient.Helper;
using BPASmartClient.Message;
using FryPot_DosingSystem.Model;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
@@ -56,7 +57,9 @@ namespace FryPot_DosingSystem.ViewModel
/// </summary>
public void RecipeSetDown(NewRecipeModel recipeModel)
{
ActionManage.GetInstance.Send("RecipeSetDown",recipeModel);
recipeModel.RecipeSetInfo = "下发成功";
}
}
}

+ 24
- 1
SmartClient.sln View File

@@ -100,7 +100,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkTJuicer"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.AGV", "BPASmartClient.AGV\BPASmartClient.AGV.csproj", "{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.MorkT_Show", "BPASmartClient.MorkT_Show\BPASmartClient.MorkT_Show.csproj", "{3653724D-3683-4722-B978-EB88DD4AE5DB}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkT_Show", "BPASmartClient.MorkT_Show\BPASmartClient.MorkT_Show.csproj", "{3653724D-3683-4722-B978-EB88DD4AE5DB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FryPot_DosingSystem", "FryPot_DosingSystem\FryPot_DosingSystem.csproj", "{D638DFA2-D160-4D32-912F-385BC04A9382}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -936,6 +938,26 @@ Global
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x64.Build.0 = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x86.ActiveCfg = Release|Any CPU
{3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x86.Build.0 = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|ARM.ActiveCfg = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|ARM.Build.0 = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|ARM64.Build.0 = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|x64.ActiveCfg = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|x64.Build.0 = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|x86.ActiveCfg = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Debug|x86.Build.0 = Debug|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|Any CPU.Build.0 = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|ARM.ActiveCfg = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|ARM.Build.0 = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|ARM64.ActiveCfg = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|ARM64.Build.0 = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|x64.ActiveCfg = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|x64.Build.0 = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|x86.ActiveCfg = Release|Any CPU
{D638DFA2-D160-4D32-912F-385BC04A9382}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -982,6 +1004,7 @@ Global
{724087A3-E7E7-4494-B844-414FF5CD1D40} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F}
{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625}
{3653724D-3683-4722-B978-EB88DD4AE5DB} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F}
{D638DFA2-D160-4D32-912F-385BC04A9382} = {8712125E-14CD-4E1B-A1CE-4BDE03805942}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC}


Loading…
Cancel
Save