Browse Source

180更新

样式分支
taoye 2 years ago
parent
commit
6096ebc0be
10 changed files with 1004 additions and 675 deletions
  1. +1
    -1
      BPASmart.PageLoad/BPASmart.PageLoad.csproj
  2. +568
    -553
      BPASmartClient.AGV/AGVHelper.cs
  3. +12
    -5
      FryPot_DosingSystem/App.config
  4. +3
    -1
      FryPot_DosingSystem/App.xaml.cs
  5. +73
    -6
      FryPot_DosingSystem/Control/DeviceOperate.cs
  6. +214
    -89
      FryPot_DosingSystem/Control/DosingLogicControl.cs
  7. +34
    -4
      FryPot_DosingSystem/Control/GlobalVariable.cs
  8. +6
    -0
      FryPot_DosingSystem/Model/MaterialType.cs
  9. +25
    -16
      FryPot_DosingSystem/View/NewRecipeView.xaml
  10. +68
    -0
      FryPot_DosingSystem/View/NewRecipeView.xaml.cs

+ 1
- 1
BPASmart.PageLoad/BPASmart.PageLoad.csproj View File

@@ -15,7 +15,7 @@
<ProjectReference Include="..\BeDesignerSCADA\BeDesignerSCADA.csproj" />
<ProjectReference Include="..\BPASmart.Model\BPASmart.Model.csproj" />
<ProjectReference Include="..\BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj" />
<ProjectReference Include="..\BPASmartClient.MessageName\BPASmartClient.MessageName.csproj" />
<!--<ProjectReference Include="..\BPASmartClient.MessageName\BPASmartClient.MessageName.csproj" />-->
<ProjectReference Include="..\BPASmartClient.SCADAControl\BPASmartClient.SCADAControl.csproj" />
</ItemGroup>



+ 568
- 553
BPASmartClient.AGV/AGVHelper.cs
File diff suppressed because it is too large
View File


+ 12
- 5
FryPot_DosingSystem/App.config View File

@@ -1,12 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!--请求报文头-->
<add key="appKey" value="true"/>
<add key="appSecret" value="123"/>
<add key="requestId" value="123"/>
<add key="timestamp" value="123"/>
<add key ="version" value="2.8"/>
<add key="appKey" value="0123456789abcdef"/>
<add key="appSecret" value="0123456789abcdef"/>
<add key ="version" value="2.9"/>
<add key="warehouseId" value=""/>
<add key="jobPriority" value=""/>
<add key="jobPriorityType" value=""/>
<add key="jobType" value="POINT_ROLLER_MOVE"/>
<add key="autoLoad" value="true"/>
<add key="enableIOLoad" value="false"/>
<add key="autoUnload" value="true"/>
<add key="enableIOUnload" value="false"/>
</appSettings>
<!--请求报文体-->
</configuration>

+ 3
- 1
FryPot_DosingSystem/App.xaml.cs View File

@@ -25,7 +25,7 @@ namespace FryPot_DosingSystem
public partial class App : Application
{
public static Window MainWindow;
protected override async void OnStartup(StartupEventArgs e)
protected override async void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
SystemHelper.GetInstance.CreateDesktopShortcut();
@@ -39,7 +39,9 @@ namespace FryPot_DosingSystem
{
mv.Show();
MessageLog.GetInstance.ShowUserLog("用户登录");
await Task.Run(()=> { DeviceOperate deviceOperate = DeviceOperate.GetInstance; });//开启实时PLC数据读取
DosingLogicControl logigControl = DosingLogicControl.GetInstance;//开启逻辑控制任务程序
HubHelper.GetInstance.Connect("192.168.1.20", 8089);
AlarmHelper<AlarmInfo>.Init();//报警实时监控


+ 73
- 6
FryPot_DosingSystem/Control/DeviceOperate.cs View File

@@ -180,7 +180,7 @@ namespace FryPot_DosingSystem.Control
string DeviceName = devices.Devices[i].DeviceName;
switch (DeviceName)
{
case "滚筒输送线": modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("滚筒线PLC连接成功"); break;
case "滚筒输送线": modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("滚筒线PLC连接成功"); break;
case "炒锅1": fryOneModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("1号炒锅PLC连接成功"); break;
case "炒锅2": fryTwoModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("2号炒锅PLC连接成功"); break;
case "炒锅3": fryThreeModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("3号炒锅PLC连接成功"); break;
@@ -259,7 +259,7 @@ namespace FryPot_DosingSystem.Control
DeviceManage devices = Json<DeviceManage>.Data;
var res = devices.Devices.FirstOrDefault(p => p.DeviceName == "炒锅1");
if (res != null)
modbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("1号炒锅PLC重连成功");
fryOneModbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("1号炒锅PLC重连成功");
}
Thread.Sleep(10);
}), $"炒锅1实时数据读取线程");
@@ -289,7 +289,7 @@ namespace FryPot_DosingSystem.Control
DeviceManage devices = Json<DeviceManage>.Data;
var res = devices.Devices.FirstOrDefault(p => p.DeviceName == "炒锅2");
if (res != null)
modbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("2号炒锅PLC重连成功");
fryTwoModbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("2号炒锅PLC重连成功");
}
Thread.Sleep(10);
}), $"炒锅2实时数据读取线程");
@@ -319,7 +319,7 @@ namespace FryPot_DosingSystem.Control
DeviceManage devices = Json<DeviceManage>.Data;
var res = devices.Devices.FirstOrDefault(p => p.DeviceName == "炒锅3");
if (res != null)
modbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("3号炒锅PLC重连成功");
fryThreeModbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("3号炒锅PLC重连成功");
}
Thread.Sleep(10);
}), $"炒锅3实时数据读取线程");
@@ -349,7 +349,7 @@ namespace FryPot_DosingSystem.Control
DeviceManage devices = Json<DeviceManage>.Data;
var res = devices.Devices.FirstOrDefault(p => p.DeviceName == "炒锅4");
if (res != null)
modbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("4号炒锅PLC重连成功");
fryFourModbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("4号炒锅PLC重连成功");
}
Thread.Sleep(10);
}), $"炒锅4实时数据读取线程");
@@ -379,18 +379,85 @@ namespace FryPot_DosingSystem.Control
DeviceManage devices = Json<DeviceManage>.Data;
var res = devices.Devices.FirstOrDefault(p => p.DeviceName == "炒锅5");
if (res != null)
modbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("5号炒锅PLC重连成功");
fryFiveModbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("5号炒锅PLC重连成功");
}
Thread.Sleep(10);
}), $"炒锅5实时数据读取线程");
}
}
/// <summary>
/// 滚筒线写ushort数据
/// </summary>
/// <param name="address"></param>
/// <param name="value"></param>
public void WritePlcData(string address, ushort value)
{
lock (this)
{
modbus.Write(address, value);
}
}
/// <summary>
/// 滚筒线写float数据
/// </summary>
/// <param name="address"></param>
/// <param name="value"></param>
public void WriteRealPlcData(string address, float value)
{
lock (this)
{
modbus.SetReal(address,value);
}
}
/// <summary>
/// 炒锅1工艺数据
/// </summary>
/// <param name="address"></param>
/// <param name="value"></param>
public void WritePotOnePlcData(string address,object value )
{
}
/// <summary>
/// 炒锅2工艺数据
/// </summary>
/// <param name="address"></param>
/// <param name="value"></param>
public void WritePotTwoPlcData(string address, object value)
{


}
/// <summary>
/// 炒锅3工艺数据
/// </summary>
/// <param name="address"></param>
/// <param name="value"></param>
public void WritePotThreePlcData(string address, object value)
{


}
/// <summary>
/// 炒锅4工艺数据
/// </summary>
/// <param name="address"></param>
/// <param name="value"></param>
public void WritePotFourPlcData(string address, object value)
{


}
/// <summary>
/// 炒锅5工艺数据
/// </summary>
/// <param name="address"></param>
/// <param name="value"></param>
public void WritePotFivePlcData(string address, object value)
{


}
public ConcurrentDictionary<string, object> GetAllData()
{


+ 214
- 89
FryPot_DosingSystem/Control/DosingLogicControl.cs View File

@@ -29,6 +29,13 @@ namespace FryPot_DosingSystem.Control
{
public static DosingLogicControl _instance;
public static DosingLogicControl GetInstance => _instance ??= new DosingLogicControl();

/// <summary>
/// 桶净重
/// </summary>
public ushort RollerNetweight =20;

/// <summary>
/// 滚筒线PLC数据
/// </summary>
@@ -1128,6 +1135,7 @@ namespace FryPot_DosingSystem.Control
#region 清洗台到线体4
if (objData.state == "ROLLER_LOAD_FINISH" && LTenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料位置上料完成,指清戏台空桶到上料
{
globalVar.AllowNextEmptyRollerToClean = true;
MessageLog.GetInstance.ShowRunLog("清洗台空桶装载完成");
AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.OnllYes);
AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hs_4);//去四号空桶线
@@ -2045,6 +2053,7 @@ namespace FryPot_DosingSystem.Control
//{
// globalVar.LOneTaskLock = true;
LOneRecipeDataToPlc();
LineOneRecipeExecuteConfirm();
LOneLoadRoller();
LOneFryPotInputMaterial();
LOneFallMaterial();
@@ -2063,6 +2072,7 @@ namespace FryPot_DosingSystem.Control
//{
// globalVar.LTwoTaskLock = true;
LTwoRecipeDataToPlc();
LineOneRecipeExecuteConfirm();
LTwoAgvLoadRoller();
LTwoFryPotInputMaterial();
LTwoFallMaterial();
@@ -2081,6 +2091,7 @@ namespace FryPot_DosingSystem.Control
//{
// globalVar.LThreeTaskLock = true;
LThreeRecipeDataToPlc();
LineOneRecipeExecuteConfirm();
LThreeAgvLoadRoller();
LThreeFryPotInputMaterial();
LThreeFallMaterial();
@@ -2151,7 +2162,7 @@ namespace FryPot_DosingSystem.Control
if (AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble == 0)//输送线无故障
{
//线体1到清洗台
if (!globalVar.rollerLineOne.IsEpmtyBefore && globalVar.rollerLineOne.CanRun)
if (!globalVar.rollerLineOne.IsEpmtyBefore && globalVar.rollerLineOne.CanRun&& globalVar.AllowNextEmptyRollerToClean)
{
var res = InputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineOne.StationEight);
if ((globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.EmptyRollerNums.Count > 0 && globalVar.rollerLineOne.StationEight == globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0) && InputMaterialQuene.Count > 0 && globalVar.rollerLineOne.StationEight != InputMaterialQuene.ElementAt(0).materialType.MaterialLoc) || (res == null && globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.EmptyRollerNums.Count > 0 && globalVar.rollerLineOne.StationEight == globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0)))//一种情况工位8上面有桶且不是配方上的原料桶且工位8的桶号和plc上报的桶号一致,即空桶,另一种在没有下单的情况下,线体上的桶都认为是空桶
@@ -2165,10 +2176,11 @@ namespace FryPot_DosingSystem.Control
string info = AGVHelper.GetInstance.AgvLeaveLOneToClean(id);//1号线到洗桶处
LSevenrobotJobId.Add(id);
// Thread.Sleep(500);
if (LineToCleanCarryTaskErrorCodeAnalysis(info, 1))
if (LineToCleanCarryTaskErrorCodeAnalysis(info, 1))//AGV呼叫成功
{

globalVar.rollerLineOne.IsEpmtyBefore = true;
globalVar.AllowNextEmptyRollerToClean = false;
}
else
{
@@ -2194,7 +2206,7 @@ namespace FryPot_DosingSystem.Control
// 线体2到清洗台
if (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 0)//输送线无故障
{
if (!globalVar.rollerLineTwo.IsEpmtyBefore && globalVar.rollerLineTwo.CanRun)
if (!globalVar.rollerLineTwo.IsEpmtyBefore && globalVar.rollerLineTwo.CanRun&& globalVar.AllowNextEmptyRollerToClean)
{
var res = LTwoInputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineTwo.StationEight);
if ((globalVar.rollerLineTwo.StationEight != 0 && globalVar.rollerLineTwo.EmptyRollerNums.Count > 0 && globalVar.rollerLineTwo.StationEight == globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0) && LTwoInputMaterialQuene.Count > 0 && globalVar.rollerLineTwo.StationEight != LTwoInputMaterialQuene.ElementAt(0).materialType.MaterialLoc) || (res == null && globalVar.rollerLineTwo.StationEight != 0 && globalVar.rollerLineTwo.EmptyRollerNums.Count > 0 && globalVar.rollerLineTwo.StationEight == globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0)))//工位8上面有桶且不是配方上的原料桶,即空桶
@@ -2211,6 +2223,7 @@ namespace FryPot_DosingSystem.Control
{

globalVar.rollerLineTwo.IsEpmtyBefore = true;
globalVar.AllowNextEmptyRollerToClean = false;
}
else
{
@@ -2236,7 +2249,7 @@ namespace FryPot_DosingSystem.Control
//线体3到清洗台
if (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 0)//输送线无故障
{
if (!globalVar.rollerLineThree.IsEpmtyBefore && globalVar.rollerLineThree.CanRun)
if (!globalVar.rollerLineThree.IsEpmtyBefore && globalVar.rollerLineThree.CanRun && globalVar.AllowNextEmptyRollerToClean)
{
var res = LThreeInputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineThree.StationEight);
if ((globalVar.rollerLineThree.StationEight != 0 && globalVar.rollerLineThree.EmptyRollerNums.Count > 0 && globalVar.rollerLineThree.StationEight == globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0) && LThreeInputMaterialQuene.Count > 0 && globalVar.rollerLineThree.StationEight != LThreeInputMaterialQuene.ElementAt(0).materialType.MaterialLoc) || (res == null && globalVar.rollerLineThree.StationEight != 0 && globalVar.rollerLineThree.EmptyRollerNums.Count > 0 && globalVar.rollerLineThree.StationEight == globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0)))//工位8上面有桶且不是配方上的原料桶,即空桶
@@ -2253,6 +2266,7 @@ namespace FryPot_DosingSystem.Control
{

globalVar.rollerLineThree.IsEpmtyBefore = true;
globalVar.AllowNextEmptyRollerToClean = false;
}
else//呼叫失败
{
@@ -2405,6 +2419,7 @@ namespace FryPot_DosingSystem.Control
if (globalVar.LThreeCurrentRecipeName != string.Empty)
{
MessageLog.GetInstance.ShowUserLog($"【3】号滚筒线【{globalVar.LThreeCurrentRecipeName}】 配方制作完成");
PlcLineThreeRecipeDataReset();
if (globalVar.LThreeFryPotSerial == 3)
{
FryPotMonitorManage.GetInstance.fryThree.TotalProduct++;
@@ -2449,7 +2464,7 @@ namespace FryPot_DosingSystem.Control
materialType = result.materialCollection[i],
materialId = result.RecipeId
});
RollerThreeDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight);//3号滚筒线桶号以及重量数据下发
RollerThreeDataWrite(i, result.materialCollection[i].MaterialLoc,(ushort) (result.materialCollection[i].MaterialWeight+RollerNetweight), result.materialCollection[i].MaterialOffset);//3号滚筒线桶号以及重量数据、偏差量下发
}
else
{
@@ -2461,7 +2476,8 @@ namespace FryPot_DosingSystem.Control
}
}
DeviceOperate.GetInstance.WritePlcData("D1043", (ushort)result.materialCollection.Count);//发送3号滚筒线工序数据
globalVar.rollerLineThree.RecipeComMidSingle = 0;
// globalVar.rollerLineThree.RecipeComMidSingle = 0;
WritePlcData("", 1);//配方开始执行命令
}
}

@@ -2480,6 +2496,7 @@ namespace FryPot_DosingSystem.Control
if (globalVar.LTwoCurrentRecipeName != string.Empty)
{
MessageLog.GetInstance.ShowUserLog($"【2】号滚筒线【{globalVar.LTwoCurrentRecipeName}】 配方制作完成");
PlcLineTwoRecipeDataReset();
if (globalVar.LTwoFryPotSerial == 2)
{
FryPotMonitorManage.GetInstance.fryTwo.TotalProduct++;
@@ -2552,7 +2569,7 @@ namespace FryPot_DosingSystem.Control
materialType = result.materialCollection[i],
materialId = result.RecipeId
});
RollerTwoDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight);//2号滚筒线桶号以及重量数据下发
RollerTwoDataWrite(i, result.materialCollection[i].MaterialLoc, (ushort)(result.materialCollection[i].MaterialWeight+RollerNetweight), result.materialCollection[i].MaterialOffset);//2号滚筒线桶号以及重量、偏差量数据下发
}
else
{
@@ -2564,7 +2581,8 @@ namespace FryPot_DosingSystem.Control
}
}
DeviceOperate.GetInstance.WritePlcData("D1026", (ushort)result.materialCollection.Count);//发送2号滚筒线工序数据
globalVar.rollerLineTwo.RecipeComMidSingle = 0;
//globalVar.rollerLineTwo.RecipeComMidSingle = 0;
WritePlcData("", 1);//配方开始执行命令
}
}
}
@@ -2580,6 +2598,7 @@ namespace FryPot_DosingSystem.Control
if (globalVar.LOneCurrentRecipeName != string.Empty)
{
MessageLog.GetInstance.ShowUserLog($"【1】号滚筒线【{globalVar.LOneCurrentRecipeName}】 配方制作完成");
PlcLineOneRecipeDataReset();
if (globalVar.LOneFryPotSerial == 1)
{
FryPotMonitorManage.GetInstance.fryOne.TotalProduct++;
@@ -2649,7 +2668,8 @@ namespace FryPot_DosingSystem.Control
materialType = result.materialCollection[i],
materialId = result.RecipeId
});
RollerOneDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight);//1号滚筒线桶号以及重量数据下发
RollerOneDataWrite(i, result.materialCollection[i].MaterialLoc, (ushort)(result.materialCollection[i].MaterialWeight+RollerNetweight), result.materialCollection[i].MaterialOffset);//1号滚筒线桶号以及重量、偏差量数据下发

}
else
{
@@ -2661,7 +2681,8 @@ namespace FryPot_DosingSystem.Control
}
}
DeviceOperate.GetInstance.WritePlcData("D1009", (ushort)result.materialCollection.Count);//发送1号滚筒线工序数据
globalVar.rollerLineOne.RecipeComMidSingle = 0;//配方完成的中转信号置0
// globalVar.rollerLineOne.RecipeComMidSingle = 0;//配方完成的中转信号置0
WritePlcData("", 1);//配方开始执行命令
}
}

@@ -2669,89 +2690,100 @@ namespace FryPot_DosingSystem.Control

}

/// <summary>
/// 数据下发PLC
/// 线体1配方执行等待下位确认
/// </summary>
//public void RecipeDataToPlc()
//{
// if (RecipeQuene.Count > 0 && OutputMaterialQuene.Count == 0 && InputMaterialQuene.Count == 0)//后续添加其它限制条件
// {
// //NewRecipeModel newRecipe = new NewRecipeModel();
// //MaterialType material = new MaterialType();
// if (RecipeQuene.TryDequeue(out NewRecipeModel result))
// {
// //newRecipe = result;
// MessageLog.GetInstance.ShowRunLog($"开始制作【{result.RecipeName}】 配方");
// //for (int k = 0; k < newRecipe.materialCollection.Count - 1; k++)
// //{
// // for (int j = 0; j < newRecipe.materialCollection.Count - 1 - k; j++)
// // {
// // if (newRecipe.materialCollection[j].MaterialLoc > newRecipe.materialCollection[j + 1].MaterialLoc)
// // {
// // material = newRecipe.materialCollection[j];
// // // newRecipe.materialCollection[j] = null;
// // newRecipe.materialCollection[j] = newRecipe.materialCollection[j + 1];
// // // newRecipe.materialCollection[j + 1] = null;
// // newRecipe.materialCollection[j + 1] = material;
// // }
// // }
// //}
// 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号滚筒线工序数据
// }
// }
// }
public void LineOneRecipeExecuteConfirm()
{
if (globalVar.rollerLineOne.RecipeComMidSingle == 1)
{
if (globalVar.rollerLineOne.ExcuteIsConfirm == 1) //收到下位执行信号
{
globalVar.rollerLineOne.NextStart = true;
globalVar.rollerLineOne.RecipeComMidSingle = 0;//配方完成的中转信号置0
}
else if (globalVar.rollerLineOne.ExcuteIsConfirm == 2) //收到下位取消执行命令
{
globalVar.rollerLineOne.NextStart = false;
//清空配方数据队列
PlcLineOneRecipeDataReset();//PLC复位
InputMaterialQuene.Clear();
MessageLog.GetInstance.ShowRunLog($"下位机操作员取消【1】号线体【{globalVar.LOneCurrentRecipeName}】配方的制作");
MessageLog.GetInstance.ShowUserLog($"下位机操作员取消【1】号线体【{globalVar.LOneCurrentRecipeName}】配方的制作");
globalVar.LOneCurrentRecipeName = string.Empty;
}
else //未收到下位执行信号
{
globalVar.rollerLineOne.NextStart = false;
}
}
}

//}
/// <summary>
/// AGV到配方线体1装桶以及出料到炒锅
/// 线体2配方执行等待下位确认
/// </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号线体装桶
// }
// }
public void LineTwoRecipeExecuteConfirm()
{
if (globalVar.rollerLineTwo.RecipeComMidSingle == 1)
{
if (globalVar.rollerLineTwo.ExcuteIsConfirm == 1) //收到下位执行信号
{
globalVar.rollerLineTwo.NextStart = true;
globalVar.rollerLineTwo.RecipeComMidSingle = 0;//配方完成的中转信号置0
}
else if (globalVar.rollerLineTwo.ExcuteIsConfirm == 2) //收到下位取消执行命令
{
globalVar.rollerLineTwo.NextStart = false;
//清空配方数据队列
PlcLineTwoRecipeDataReset();//PLC复位
LTwoInputMaterialQuene.Clear();
MessageLog.GetInstance.ShowRunLog($"下位机操作员取消【2】号线体【{globalVar.LTwoCurrentRecipeName}】配方的制作");
MessageLog.GetInstance.ShowUserLog($"下位机操作员取消【2】号线体【{globalVar.LTwoCurrentRecipeName}】配方的制作");
globalVar.LTwoCurrentRecipeName = string.Empty;
}
else //未收到下位执行信号
{
globalVar.rollerLineTwo.NextStart = false;
}
}
}
/// <summary>
/// 线体3配方执行等待下位确认
/// </summary>
public void LineThreeRecipeExecuteConfirm()
{
if (globalVar.rollerLineThree.RecipeComMidSingle == 1)
{
if (globalVar.rollerLineThree.ExcuteIsConfirm == 1) //收到下位执行信号
{
globalVar.rollerLineThree.NextStart = true;
globalVar.rollerLineThree.RecipeComMidSingle = 0;//配方完成的中转信号置0
}
else if (globalVar.rollerLineThree.ExcuteIsConfirm == 2) //收到下位取消执行命令
{
globalVar.rollerLineThree.NextStart = false;
//清空配方数据队列
PlcLineThreeRecipeDataReset();//PLC复位
LThreeInputMaterialQuene.Clear();
MessageLog.GetInstance.ShowRunLog($"下位机操作员取消【3】号线体【{globalVar.LThreeCurrentRecipeName}】配方的制作");
MessageLog.GetInstance.ShowUserLog($"下位机操作员取消【3】号线体【{globalVar.LThreeCurrentRecipeName}】配方的制作");
globalVar.LThreeCurrentRecipeName = string.Empty;
}
else //未收到下位执行信号
{
globalVar.rollerLineThree.NextStart = false;
}
}
}

//}
/// <summary>
/// AGV到配方线体1装桶以及出料到炒锅
/// </summary>
public void LOneLoadRoller()
{
if (InputMaterialQuene.Count > 0)
if (InputMaterialQuene.Count > 0&& globalVar.rollerLineOne.NextStart)
{
AgvToLineOneLoadRoller();
AgvFromLineOneToFryPot();//AGV到1号线体装桶
@@ -2777,7 +2809,7 @@ namespace FryPot_DosingSystem.Control
/// </summary>
public void LTwoAgvLoadRoller()
{
if (LTwoInputMaterialQuene.Count > 0)
if (LTwoInputMaterialQuene.Count > 0&& globalVar.rollerLineTwo.NextStart)
{
AgvToLineTwoLoadRoller();
AgvFromLineTwoToFryPot();//AGV到2号线体装桶
@@ -2803,7 +2835,7 @@ namespace FryPot_DosingSystem.Control
/// </summary>
public void LThreeAgvLoadRoller()
{
if (LThreeInputMaterialQuene.Count > 0)
if (LThreeInputMaterialQuene.Count > 0&& globalVar.rollerLineThree.NextStart)
{

AgvToLineThreeLoadRoller();
@@ -4241,41 +4273,49 @@ namespace FryPot_DosingSystem.Control
/// <param name="count"></param>
/// <param name="materialLoc"></param>
/// <param name="materialWeight"></param>
public void RollerOneDataWrite(int count, ushort materialLoc, ushort materialWeight)
public void RollerOneDataWrite(int count, ushort materialLoc, ushort materialWeight,float materialOffset)
{
switch (count)
{
case 0:
DeviceOperate.GetInstance.WritePlcData("D1001", materialLoc);//桶1位置
DeviceOperate.GetInstance.WritePlcData("D1010", materialWeight);//桶2重量
DeviceOperate.GetInstance.WritePlcData("D1010", materialWeight);//桶1重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶重1量偏差
break;
case 1:
DeviceOperate.GetInstance.WritePlcData("D1002", materialLoc);//桶2位置
DeviceOperate.GetInstance.WritePlcData("D1011", materialWeight);//桶2重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶2重量偏差
break;
case 2:
DeviceOperate.GetInstance.WritePlcData("D1003", materialLoc);//桶3位置
DeviceOperate.GetInstance.WritePlcData("D1012", materialWeight);//桶3重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶3重量偏差
break;
case 3:
DeviceOperate.GetInstance.WritePlcData("D1004", materialLoc);//桶4位置
DeviceOperate.GetInstance.WritePlcData("D1013", materialWeight);//桶4重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶4重量偏差
break;
case 4:
DeviceOperate.GetInstance.WritePlcData("D1005", materialLoc);//桶5位置
DeviceOperate.GetInstance.WritePlcData("D1014", materialWeight);//桶5重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶5重量偏差
break;
case 5:
DeviceOperate.GetInstance.WritePlcData("D1006", materialLoc);//桶6位置
DeviceOperate.GetInstance.WritePlcData("D1015", materialWeight);//桶6重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶6重量偏差
break;
case 6:
DeviceOperate.GetInstance.WritePlcData("D1007", materialLoc);//桶7位置
DeviceOperate.GetInstance.WritePlcData("D1016", materialWeight);//桶7重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶7重量偏差
break;
case 7:
DeviceOperate.GetInstance.WritePlcData("D1008", materialLoc);//桶8位置
DeviceOperate.GetInstance.WritePlcData("D1017", materialWeight);//桶8重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶8重量偏差
break;

}
@@ -4286,41 +4326,49 @@ namespace FryPot_DosingSystem.Control
/// <param name="count"></param>
/// <param name="materialLoc"></param>
/// <param name="materialWeight"></param>
public void RollerTwoDataWrite(int count, ushort materialLoc, ushort materialWeight)
public void RollerTwoDataWrite(int count, ushort materialLoc, ushort materialWeight,float materialOffset)
{
switch (count)
{
case 0:
DeviceOperate.GetInstance.WritePlcData("D1018", materialLoc);//桶1位置
DeviceOperate.GetInstance.WritePlcData("D1027", materialWeight);//桶2重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶重1量偏差
break;
case 1:
DeviceOperate.GetInstance.WritePlcData("D1019", materialLoc);//桶2位置
DeviceOperate.GetInstance.WritePlcData("D1028", materialWeight);//桶2重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶重2量偏差
break;
case 2:
DeviceOperate.GetInstance.WritePlcData("D1020", materialLoc);//桶3位置
DeviceOperate.GetInstance.WritePlcData("D1029", materialWeight);//桶3重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶重3量偏差
break;
case 3:
DeviceOperate.GetInstance.WritePlcData("D1021", materialLoc);//桶4位置
DeviceOperate.GetInstance.WritePlcData("D1030", materialWeight);//桶4重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶重4量偏差
break;
case 4:
DeviceOperate.GetInstance.WritePlcData("D1022", materialLoc);//桶5位置
DeviceOperate.GetInstance.WritePlcData("D1031", materialWeight);//桶5重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶重5量偏差
break;
case 5:
DeviceOperate.GetInstance.WritePlcData("D1023", materialLoc);//桶6位置
DeviceOperate.GetInstance.WritePlcData("D1032", materialWeight);//桶6重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶重6量偏差
break;
case 6:
DeviceOperate.GetInstance.WritePlcData("D1024", materialLoc);//桶7位置
DeviceOperate.GetInstance.WritePlcData("D1033", materialWeight);//桶7重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶重7量偏差
break;
case 7:
DeviceOperate.GetInstance.WritePlcData("D1025", materialLoc);//桶8位置
DeviceOperate.GetInstance.WritePlcData("D1034", materialWeight);//桶8重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶重8量偏差
break;

}
@@ -4331,41 +4379,49 @@ namespace FryPot_DosingSystem.Control
/// <param name="count"></param>
/// <param name="materialLoc"></param>
/// <param name="materialWeight"></param>
public void RollerThreeDataWrite(int count, ushort materialLoc, ushort materialWeight)
public void RollerThreeDataWrite(int count, ushort materialLoc, ushort materialWeight,float materialOffset)
{
switch (count)
{
case 0:
DeviceOperate.GetInstance.WritePlcData("D1035", materialLoc);//桶1位置
DeviceOperate.GetInstance.WritePlcData("D1044", materialWeight);//桶2重量
DeviceOperate.GetInstance.WritePlcData("D1044", materialWeight);//桶1重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶重1量偏差
break;
case 1:
DeviceOperate.GetInstance.WritePlcData("D1036", materialLoc);//桶2位置
DeviceOperate.GetInstance.WritePlcData("D1045", materialWeight);//桶2重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶重2量偏差
break;
case 2:
DeviceOperate.GetInstance.WritePlcData("D1037", materialLoc);//桶3位置
DeviceOperate.GetInstance.WritePlcData("D1046", materialWeight);//桶3重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶重3量偏差
break;
case 3:
DeviceOperate.GetInstance.WritePlcData("D1038", materialLoc);//桶4位置
DeviceOperate.GetInstance.WritePlcData("D1047", materialWeight);//桶4重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶重4量偏差
break;
case 4:
DeviceOperate.GetInstance.WritePlcData("D1039", materialLoc);//桶5位置
DeviceOperate.GetInstance.WritePlcData("D1048", materialWeight);//桶5重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶重5量偏差
break;
case 5:
DeviceOperate.GetInstance.WritePlcData("D1040", materialLoc);//桶6位置
DeviceOperate.GetInstance.WritePlcData("D1049", materialWeight);//桶6重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶重6量偏差
break;
case 6:
DeviceOperate.GetInstance.WritePlcData("D1041", materialLoc);//桶7位置
DeviceOperate.GetInstance.WritePlcData("D1050", materialWeight);//桶7重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶重7量偏差
break;
case 7:
DeviceOperate.GetInstance.WritePlcData("D1042", materialLoc);//桶8位置
DeviceOperate.GetInstance.WritePlcData("D1051", materialWeight);//桶8重量
DeviceOperate.GetInstance.WriteRealPlcData("", materialOffset);//桶重8量偏差
break;

}
@@ -4521,5 +4577,74 @@ namespace FryPot_DosingSystem.Control
FryPotThreeAlarm = 1;
}

/// <summary>
/// PLC线体1配方数据复位功能
/// </summary>
public void PlcLineOneRecipeDataReset()
{
WritePlcData("D1001",0);
WritePlcData("D1002", 0);
WritePlcData("D1003", 0);
WritePlcData("D1004", 0);
WritePlcData("D1005", 0);
WritePlcData("D1006", 0);
WritePlcData("D1007", 0);
WritePlcData("D1008", 0);
WritePlcData("D1009", 0);
WritePlcData("D1010", 0);
WritePlcData("D1011", 0);
WritePlcData("D1012", 0);
WritePlcData("D1013", 0);
WritePlcData("D1014", 0);
WritePlcData("D1015", 0);
WritePlcData("D1016", 0);
WritePlcData("D1017", 0);
}
/// <summary>
/// PLC线体2配方数据复位功能
/// </summary>
public void PlcLineTwoRecipeDataReset()
{
WritePlcData("D1018", 0);
WritePlcData("D1019", 0);
WritePlcData("D1020", 0);
WritePlcData("D1021", 0);
WritePlcData("D1022", 0);
WritePlcData("D1023", 0);
WritePlcData("D1024", 0);
WritePlcData("D1025", 0);
WritePlcData("D1026", 0);
WritePlcData("D1027", 0);
WritePlcData("D1028", 0);
WritePlcData("D1029", 0);
WritePlcData("D1030", 0);
WritePlcData("D1031", 0);
WritePlcData("D1032", 0);
WritePlcData("D1033", 0);
WritePlcData("D1034", 0);
}
/// <summary>
/// PLC线体3配方数据复位功能
/// </summary>
public void PlcLineThreeRecipeDataReset()
{
WritePlcData("D1035", 0);
WritePlcData("D1036", 0);
WritePlcData("D1037", 0);
WritePlcData("D1038", 0);
WritePlcData("D1039", 0);
WritePlcData("D1040", 0);
WritePlcData("D1041", 0);
WritePlcData("D1042", 0);
WritePlcData("D1043", 0);
WritePlcData("D1044", 0);
WritePlcData("D1045", 0);
WritePlcData("D1046", 0);
WritePlcData("D1047", 0);
WritePlcData("D1048", 0);
WritePlcData("D1049", 0);
WritePlcData("D1050", 0);
WritePlcData("D1051", 0);
}
}
}

+ 34
- 4
FryPot_DosingSystem/Control/GlobalVariable.cs View File

@@ -128,7 +128,6 @@ namespace FryPot_DosingSystem.Control
public string LThreeCurrentRecipeName { get; set; } = string.Empty;
#endregion
#region 线体1流程互锁变量

public bool LoadRoller { get; set; }

public bool AgvToFryPot { get; set; }
@@ -197,7 +196,12 @@ namespace FryPot_DosingSystem.Control
public bool agvArriveLineOneLoadCom { get; set; } //agv线体1空桶上料完成
public bool agvArriveLineTwoLoadCom { get; set; } //agv线体2空桶上料完成
public bool agvArriveLineThreeLoadCom { get; set; }//agv线体3空桶上料完成

/// <summary>
/// 允许下一个空桶去洗桶
/// </summary>
public bool AllowNextEmptyRollerToClean { get; set; } = true;

#endregion
}
/// <summary>
@@ -282,8 +286,14 @@ namespace FryPot_DosingSystem.Control
/// AGV从线体1到达清洗台
/// </summary>
public bool agvArriveCleanUnLoad { get; set; }


/// <summary>
/// 下位确认执行信号 true:执行 false:不执行
/// </summary>
public ushort ExcuteIsConfirm { get; set;} //默认为:0,确认执行:1,取消执行:2
/// <summary>
/// 线体1流程控制互锁信号
/// </summary>
public bool NextStart { get; set; }
}
/// <summary>
/// 滚筒线2相关变量
@@ -364,6 +374,16 @@ namespace FryPot_DosingSystem.Control
/// AGV从线体2到达清洗台
/// </summary>
public bool agvArriveCleanUnLoad { get; set; }


/// <summary>
/// 下位确认执行信号 true:执行 false:不执行
/// </summary>
public ushort ExcuteIsConfirm { get; set; }
/// <summary>
/// 线体1流程控制互锁信号
/// </summary>
public bool NextStart { get; set; }
}
/// <summary>
/// 滚筒线3相关变量
@@ -445,6 +465,16 @@ namespace FryPot_DosingSystem.Control
/// AGV从线体3到达清洗台
/// </summary>
public bool agvArriveCleanUnLoad { get; set; }

/// <summary>
/// 下位确认执行信号 true:执行 false:不执行
/// </summary>
public ushort ExcuteIsConfirm { get; set; }
/// <summary>
/// 线体1流程控制互锁信号
/// </summary>
public bool NextStart { get; set; }

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


+ 6
- 0
FryPot_DosingSystem/Model/MaterialType.cs View File

@@ -24,6 +24,12 @@ namespace FryPot_DosingSystem.Model
/// </summary>
private ushort _materialWeight;
public ushort MaterialWeight { get { return _materialWeight; }set { _materialWeight = value;OnPropertyChanged(); } }

/// <summary>
/// 原料偏差
/// </summary>
private float _materialOffset;
public float MaterialOffset { get { return _materialOffset;}set { _materialOffset = value;OnPropertyChanged(); } }
/// <summary>
/// 原料对应桶位置
/// </summary>


+ 25
- 16
FryPot_DosingSystem/View/NewRecipeView.xaml View File

@@ -229,9 +229,10 @@
</UniformGrid>
<Grid Grid.Row="2" Background="#FF2AB2E7" Margin="0,0,0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="210"/>
<ColumnDefinition Width="225"/>
<ColumnDefinition Width="225"/>
<ColumnDefinition Width="170"/>
<ColumnDefinition Width="170"/>
<ColumnDefinition Width="170"/>
<ColumnDefinition Width="170"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="原料名称" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/>
@@ -240,7 +241,9 @@
<GridSplitter Grid.Column="1"></GridSplitter>
<TextBlock Grid.Column="2" Text="原料重量" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"></TextBlock>
<GridSplitter Grid.Column="2"></GridSplitter>
<TextBlock Grid.Column="3" Text="操作" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
<TextBlock Grid.Column="3" Text="原料偏差" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"></TextBlock>
<GridSplitter Grid.Column="3"></GridSplitter>
<TextBlock Grid.Column="4" Text="操作" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
</Grid>
<ScrollViewer Grid.Row="3" VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding materials}">
@@ -256,13 +259,14 @@
<ControlTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="210"/>
<ColumnDefinition Width="170"/>

<ColumnDefinition Width="210"></ColumnDefinition>
<ColumnDefinition Width="225"></ColumnDefinition>
<ColumnDefinition Width="170"></ColumnDefinition>
<ColumnDefinition Width="170"></ColumnDefinition>
<ColumnDefinition Width="170"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<ComboBox ItemsSource="{Binding DataContext.materialNames,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" Text="{Binding MaterialName}" Margin="10,0,0,10" Width="190" FontSize="14" KeyUp="ComboBox_KeyUp" LostFocus="ComboBox_LostFocus" Style="{StaticResource ComboBoxStyle1}" Height="30">
<ComboBox ItemsSource="{Binding DataContext.materialNames,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" Text="{Binding MaterialName}" Margin="10,0,0,10" Width="160" FontSize="14" KeyUp="ComboBox_KeyUp" LostFocus="ComboBox_LostFocus" Style="{StaticResource ComboBoxStyle1}" Height="30">
<ComboBox.ItemContainerStyle>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="Background" Value="White" />
@@ -274,22 +278,27 @@
</ComboBox>
<StackPanel Grid.Column="1" Orientation="Horizontal" >
<TextBox Text="{Binding MaterialLoc}" Background="Transparent" FontSize="14" Height="30"
BorderBrush="#e69519" Foreground="LightGray" Width="170" Margin="35,0,0,10" ></TextBox>
BorderBrush="#e69519" Foreground="LightGray" Width="160" Margin="5,0,0,10" ></TextBox>

</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Column="2">
<TextBox Text="{Binding MaterialWeight}" Background="Transparent" FontSize="14" Height="30"
BorderBrush="#e69519" Foreground="LightGray" Width="170" Margin="35,0,0,10" ></TextBox>
<TextBlock VerticalAlignment="Center" FontSize="14" Margin="4,0,0,10" Text="g" Foreground="#e69519" ></TextBlock>
<TextBox Text="{Binding MaterialWeight}" Background="Transparent" FontSize="14" Height="30" LostFocus="TextBox_LostFocus_1"
BorderBrush="#e69519" Foreground="LightGray" Width="140" Margin="5,0,0,10" ></TextBox>
<TextBlock VerticalAlignment="Center" FontSize="14" Margin="4,0,0,10" Text="Kg" Foreground="#e69519" ></TextBlock>
</StackPanel>
<Button Grid.Column="3"
<StackPanel Orientation="Horizontal" Grid.Column="3">
<TextBox Text="{Binding MaterialOffset}" Background="Transparent" FontSize="14" Height="30" LostFocus="TextBox_LostFocus"
BorderBrush="#e69519" Foreground="LightGray" Width="140" Margin="5,0,0,10" ></TextBox>
<TextBlock VerticalAlignment="Center" FontSize="14" Margin="4,0,0,10" Text="Kg" Foreground="#e69519" ></TextBlock>
</StackPanel>
<Button Grid.Column="4"
Content="删除"
Width="94"
Width="100"
Height="30"
FontSize="14"
Margin="0,0,20,10"
Margin="5,0,20,10"
Background="Transparent"
BorderBrush="#e69519" Foreground="LightGray" HorizontalAlignment="Right"
BorderBrush="#e69519" Foreground="LightGray" HorizontalAlignment="Center"
Command="{Binding DataContext.RemoveRecipe,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}"
CommandParameter="{Binding MaterialCode}"></Button>
</Grid>


+ 68
- 0
FryPot_DosingSystem/View/NewRecipeView.xaml.cs View File

@@ -22,6 +22,7 @@ namespace FryPot_DosingSystem.View
/// </summary>
public partial class NewRecipeView : Window
{
int maxMaterialWeight = 250;
public NewRecipeView()
{
InitializeComponent();
@@ -85,5 +86,72 @@ namespace FryPot_DosingSystem.View
}
}
}

/// <summary>
/// 偏差值验证
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TextBox_LostFocus(object sender, RoutedEventArgs e)
{
if(sender is TextBox)
{
try
{
TextBox text = sender as TextBox;
if (text.Text != null)
{
double offset = float.Parse((text.Text));
if (offset < 0)
{
MessageBox.Show("偏差值无效输入", "警告", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
}
}
}
catch (Exception)
{

MessageBox.Show("偏差值非法输入", "警告", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
}
}
}
/// <summary>
/// 料桶重量验证
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TextBox_LostFocus_1(object sender, RoutedEventArgs e)
{
if (sender is TextBox)
{
try
{
TextBox text = sender as TextBox;
if (text != null)
{
double weight = Convert.ToDouble(text.Text);
if (weight < 0)
{
MessageBox.Show("原料重量非法输入", "警告", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
}
else if (weight > maxMaterialWeight)
{
MessageBox.Show("原料重量超出上限", "警告", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
}
else
{
text.Text = Math.Ceiling(weight).ToString();
}

}
}
catch (Exception)
{

MessageBox.Show("原料重量非法输入", "警告", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
}
}
}
}
}

Loading…
Cancel
Save