pry 2 years ago
parent
commit
3d533ac6ed
16 changed files with 359 additions and 180 deletions
  1. +35
    -1
      BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
  2. +12
    -63
      BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialModel.cs
  3. +2
    -12
      BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeModel.cs
  4. +1
    -2
      BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs
  5. +8
    -15
      BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs
  6. +2
    -5
      BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs
  7. +1
    -1
      BPASmartClient.JXJFoodSmallStation/App.config
  8. +88
    -26
      BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs
  9. +37
    -22
      BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
  10. +1
    -1
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs
  11. +99
    -0
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialColl.cs
  12. +7
    -0
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeModel.cs
  13. +7
    -0
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs
  14. +51
    -22
      BPASmartClient.JXJFoodSmallStation/View/NewRecipeView.xaml
  15. +6
    -8
      BPASmartClient.JXJFoodSmallStation/ViewModel/NewRecipeViewModel.cs
  16. +2
    -2
      BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs

+ 35
- 1
BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs View File

@@ -53,6 +53,40 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public void Init()
{
ActionManage.GetInstance.Register(new Action<DL_Start_DB>((res) =>
{
if (SiemensDevice.IsConnected)
{
if (res != null)
{
RawMaterials.Clear();
for (int i = 0; i < 15; i++)
{
if (RawMaterialsNamePos.ContainsKey(res.RecipeName)
{
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
RawMaterialName = res.Material[i].Material_Name,
RawMaterialBarrelNum = res.Material[i].Material_BarrelNum,
RawMaterialWeight = res.Material[i].Material_Weight,
RawMaterialLocation = (int)RawMaterialsNamePos[res.Material[i].Material_Name]
});
}
else
{
//报警,配方的原料名称下发和设备不一致
}
}
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
{
RecipeName = res.RecipeName,
RecipeCode = res.RecipeCode,
RawMaterial = RawMaterials,
TrayCode = res.TrayCode
});
}
}
}), "西门子下发配方", true);
ActionManage.GetInstance.Register(new Action<RecipeModel>((res) =>
{
if (SiemensDevice.IsConnected)
{
@@ -76,7 +110,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
//报警,配方的原料名称下发和设备不一致
}
}
Json<LocalRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
{
RecipeName = res.RecipeName,
RecipeCode = res.RecipeCode,


+ 12
- 63
BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialModel.cs View File

@@ -14,6 +14,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
private int _mIp;
public int DeviceIp { get { return _mIp; } set { _mIp = value; } }
/// <summary>
/// 原料名称
/// </summary>
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } }
private string _mRawMaterialName;

/// <summary>
/// 原料对应的桶号
@@ -28,72 +33,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model
private double _mRawMaterialWeight;

/// <summary>
/// 原料对应料仓的位置
/// </summary>
public int RawMaterialLocation { get { return _mRawMaterialLocation; } set { _mRawMaterialLocation = value; OnPropertyChanged(); } }
private int _mRawMaterialLocation;
/// <summary>
/// 原料名称
/// </summary>
public string RawMaterialName { get { return _rawMaterNmae; } set { _rawMaterNmae = value;OnPropertyChanged(); } }

private string _rawMaterNmae;

/// <summary>
/// 原料类型 MW18
/// 1:液体
/// 2:膏体
/// 3:粉体
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public ushort RawMaterialType { get { return _mRawMaterialType; } set { _mRawMaterialType = value; OnPropertyChanged(); } }
private ushort _mRawMaterialType;

/// <summary>
/// 料仓重量反馈 MD40
/// 实际的下料中重量
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public float WeightFeedback { get { return _mWeightFeedback; } set { _mWeightFeedback = value; OnPropertyChanged(); } }
private float _mWeightFeedback;
public float Laying_Off_Weight { get { return _mLaying_Off_Weight; } set { _mLaying_Off_Weight = value; } }
private float _mLaying_Off_Weight;

/// <summary>
/// 上限反馈
/// 原料对应料仓的位置/名称
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public bool UpLimtFeedback { get { return _mUpLimtFeedback; } set { _mUpLimtFeedback = value; OnPropertyChanged(); } }
private bool _mUpLimtFeedback;

/// <summary>
/// 下限反馈
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public bool DownLimtFeedback { get { return _mDownLimtFeedback; } set { _mDownLimtFeedback = value; OnPropertyChanged(); } }
private bool _mDownLimtFeedback;

/// <summary>
/// 下料重量反馈 MD52
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public float UpLimtWeightFeedback { get { return _mUpLimtWeightFeedback; } set { _mUpLimtWeightFeedback = value; OnPropertyChanged(); } }
private float _mUpLimtWeightFeedback;


/// <summary>
/// 原料ID
/// </summary>
public string RawMaterialId { get { return _mRawMaterialId; } set { _mRawMaterialId = value; OnPropertyChanged(); } }
private string _mRawMaterialId;

/// <summary>
/// 原料设备执行状态
/// 1:空闲状态
/// 2:下料中
/// 3:下料完成
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public ushort RecipeStatus { get { return _mRecipeStatus; } set { _mRecipeStatus = value; OnPropertyChanged(); } }
private ushort _mRecipeStatus = 1;
public int RawMaterialLocation { get { return _mRawMaterialLocation; } set { _mRawMaterialLocation = value; OnPropertyChanged(); } }
private int _mRawMaterialLocation;
}
}

+ 2
- 12
BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeModel.cs View File

@@ -15,16 +15,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// </summary>
public class RecipeModel : ObservableObject
{
[Newtonsoft.Json.JsonIgnore]
public bool IsEnable { get { return _mIsEnable; } set { _mIsEnable = value; OnPropertyChanged(); } }
private bool _mIsEnable = true;

/// <summary>
/// 序号
/// </summary>
public int SerialNum { get { return _mSerialNum; } set { _mSerialNum = value; OnPropertyChanged(); } }
private int _mSerialNum;

/// <summary>
/// 配方名称
/// </summary>
@@ -32,9 +22,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model
private string _mRecipeName;

/// <summary>
/// 配方编码
/// 配方ID
/// </summary>
public string RecipeCode { get { return _mRecipCode; } set { _mRecipCode = value; OnPropertyChanged(); } }
public string RecipeCode { get { return _mRecipCode; } set { _mRecipCode = value; OnPropertyChanged(); } }
private string _mRecipCode;

/// <summary>


+ 1
- 2
BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs View File

@@ -1,5 +1,4 @@

using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;


+ 8
- 15
BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs View File

@@ -62,14 +62,11 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
}
else
{

MessageBox.Show("配方名称重复,请重命名!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else//编辑已有配方
{

bom.RawMaterial.Clear();
foreach (var item in RawMaterialsInfo)
{
@@ -91,15 +88,15 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
prop: string recipeCode = new Random().Next(10000, 99999).ToString();//配方唯一ID,后期根据实际要求更改
var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == recipeCode);
if (res == null)
{
Json<LocaPar>.Data.Recipes.Add(new RecipeModel { RecipeCode = recipeCode, RawMaterial = RawMaterialsInfo, RecipeName = RecipeName, TrayCode = TrayCode });//配方添加
Json<LocaPar>.Save();
if (res == null)
{
Json<LocaPar>.Data.Recipes.Add(new RecipeModel { RecipeCode = recipeCode, RawMaterial = RawMaterialsInfo, RecipeName = RecipeName, TrayCode = TrayCode });//配方添加
Json<LocaPar>.Save();
}
else
{
goto prop;
}
else
{
goto prop;
}
ActionManage.GetInstance.Send("CloseRecipeInfosView");
}
else
@@ -115,10 +112,6 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
if (res != null)
RawMaterialsInfo.Remove(res);
});
//ReturnPage = new RelayCommand(() =>
//{
// ActionManage.GetInstance.Send("CloseRecipeInfosView");
//});
}

public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } }


+ 2
- 5
BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs View File

@@ -18,7 +18,6 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
/// <summary>
/// 当前正在制作的配方
/// </summary>

public static ObservableCollection<RawMaterialModel> recipeProcesses { get; set; } = new ObservableCollection<RawMaterialModel>();
/// <summary>
/// 等待制作的配方
@@ -37,11 +36,9 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
if (recipeName != null)
{
//配方下发逻辑
var res= Recipes.FirstOrDefault(p=>p.RecipeName==recipeName);
var res = Recipes.FirstOrDefault(p => p.RecipeName == recipeName);
if (res != null)
{
}
ActionManage.GetInstance.Send("手动下发本地配方", res);
}
});


+ 1
- 1
BPASmartClient.JXJFoodSmallStation/App.config View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="HKPlc_IP" value="192.168.0.20"/>
<add key="HKPlc_IP" value="192.168.2.10"/>
<add key="Siemens_IP" value="192.168.0.30"/>
</appSettings>
</configuration>

+ 88
- 26
BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs View File

@@ -6,6 +6,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.S7Net;
using BPASmartClient.CustomResource.Pages.Model;

namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
{
@@ -61,54 +62,115 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
/// </summary>
/// <param name="BarrelNum">单个桶的编号</param>
/// <param name="StockBinLocation">单个桶对应的料仓位置</param>
public void StockBinPar(uint BarrelNum, ushort StockBinLocation)
public void StockBinPar(uint BarrelNum, ushort StockBinLocation, int TrayNum = 1)
{
if (IsConnected)
{
if (BarrelNum >= 1 && BarrelNum <= 4 && StockBinLocation >= 1 && StockBinLocation <= 15)
if (TrayNum == 1)
{
if (BarrelNum == 1)
if (BarrelNum >= 1 && BarrelNum <= 4 && StockBinLocation >= 1 && StockBinLocation <= 15)
{
if (StockBinLocation >= 1 && StockBinLocation <= 8)
if (BarrelNum == 1)
{
HK_PLC_S7.Write<bool>("DB4.DBX10." + (StockBinLocation - 1), true);
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX10." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX11." + (StockBinLocation - 9), true);
}
MessageLog.GetInstance.ShowRunLog($"托盘1—1号桶在料仓{StockBinLocation}配料");
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
else if (BarrelNum == 2)
{
HK_PLC_S7.Write<bool>("DB4.DBX11." + (StockBinLocation - 9), true);
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX12." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX13." + (StockBinLocation - 9), true);
}
MessageLog.GetInstance.ShowRunLog($"托盘1—2号桶在料仓{StockBinLocation}配料");
}
}
else if (BarrelNum == 2)
{
if (StockBinLocation >= 1 && StockBinLocation <= 8)
else if (BarrelNum == 3)
{
HK_PLC_S7.Write<bool>("DB4.DBX12." + (StockBinLocation - 1), true);
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX14." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX15." + (StockBinLocation - 9), true);
}
MessageLog.GetInstance.ShowRunLog($"托盘1—3号桶在料仓{StockBinLocation}配料");
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
else if (BarrelNum == 4)
{
HK_PLC_S7.Write<bool>("DB4.DBX13." + (StockBinLocation - 9), true);
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX16." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX17." + (StockBinLocation - 9), true);
}
MessageLog.GetInstance.ShowRunLog($"托盘1—4号桶在料仓{StockBinLocation}配料");
}
}
else if (BarrelNum == 3)
}
else if (TrayNum == 2)
{
if (BarrelNum >= 1 && BarrelNum <= 4 && StockBinLocation >= 1 && StockBinLocation <= 15)
{
if (StockBinLocation >= 1 && StockBinLocation <= 8)
if (BarrelNum == 1)
{
HK_PLC_S7.Write<bool>("DB4.DBX14." + (StockBinLocation - 1), true);
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX18." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX19." + (StockBinLocation - 9), true);
}
MessageLog.GetInstance.ShowRunLog($"托盘2—1号桶在料仓{StockBinLocation}配料");
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
else if (BarrelNum == 2)
{
HK_PLC_S7.Write<bool>("DB4.DBX15." + (StockBinLocation - 9), true);
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX20." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX21." + (StockBinLocation - 9), true);
}
MessageLog.GetInstance.ShowRunLog($"托盘2—2号桶在料仓{StockBinLocation}配料");
}
}
else if (BarrelNum == 4)
{
if (StockBinLocation >= 1 && StockBinLocation <= 8)
else if (BarrelNum == 3)
{
HK_PLC_S7.Write<bool>("DB4.DBX16." + (StockBinLocation - 1), true);
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX22." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX23." + (StockBinLocation - 9), true);
}
MessageLog.GetInstance.ShowRunLog($"托盘2—3号桶在料仓{StockBinLocation}配料");
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
else if (BarrelNum == 4)
{
HK_PLC_S7.Write<bool>("DB4.DBX17." + (StockBinLocation - 9), true);
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX24." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX25." + (StockBinLocation - 9), true);
}
MessageLog.GetInstance.ShowRunLog($"托盘2—4号桶在料仓{StockBinLocation}配料");
}
}
}


+ 37
- 22
BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs View File

@@ -56,8 +56,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
ActionManage.GetInstance.Register(new Action<XL_Start_DB>((res) =>
{
if (SiemensDevice.IsConnected)
@@ -96,7 +94,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
try
{
//HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S7200Smart, HK_PLC_IP);
HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP);
//SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
if (HKDevice.IsConnected)
{
@@ -123,8 +121,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
if (SiemensDevice.IsConnected && HKDevice.IsConnected)
{
AgvGetInDelivery();
AgvGetInPickUp();
/*AgvGetInDelivery();
AgvGetInPickUp();*/
}
Thread.Sleep(10);
}), "AGV进站送取货", true);
@@ -527,14 +525,17 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
if (RecipeQueue.Count > 0)
{

int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0));
if (index >= 0 && index < RemoteRecipes.Count)
{
string code = RemoteRecipes.ElementAt(index).RecipeCode;
int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
if (trayCode == 1 && SmallStation.RecipeStatusID == 0)
string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
//MessageLog.GetInstance.ShowRunLog($"开始执行配方{recipeName}");
if ( true) /*trayCode == 1 &&*/
{
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.5") && SmallStation.RecipeStatusID == 0)
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.5") || SmallStation.RecipeStatusID == 0)
{
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
{
@@ -543,18 +544,23 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
HKDevice.HK_PLC_S7.Write("DB3.DBX1.5", false);
HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true);
SmallStation.RecipeStatusID = 1;
MessageLog.GetInstance.ShowRunLog($"{recipeName}配方下发完成");
HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", true);
}
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.3") && SmallStation.RecipeStatusID == 1)
{
HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", false);
SmallStation.RecipeStatusID = 2;
MessageLog.GetInstance.ShowRunLog($"{recipeName}plc端 配方接收完成");
}
if (SmallStation.RecipeStatusID == 2)
{
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0"))
if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0")))
{
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD10");
if (res != null && res is float loc)
var res1= HKDevice.HK_PLC_S7.Read<UInt32>("DB4.DBD26");
var res = HKDevice.HK_PLC_S7.Read<UInt32>("DB3.DBD10");
if (res > 0 && res is UInt32 loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
@@ -564,13 +570,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.0", false);
}
MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_1号桶允许配料");
}
}
else if(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.1"))
else if(RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.1")))
{
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD14");
if (res != null && res is float loc)
if (res > 0 && res is float loc)
{
ushort a = (ushort)loc;
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 1 && loc_index <= 15)
@@ -579,27 +587,33 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.1", false);
}
MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_2号桶允许配料");
}
}
else if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.2"))
else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.2")))
{
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD18");
if (res != null && res is float loc)
if (res > 0 && res is float loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 1 && loc_index <= 15)
{
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.2", false);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 1 && loc_index <= 15)
{
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.2", false);
}
MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_3号桶允许配料");
}
}
}
else if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.3"))
else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.3")))
{
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD22");
if (res != null && res is float loc)
if (res > 0 && res is float loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
@@ -609,11 +623,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.3", false);
}
MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_4号桶允许配料");
}
}
for (int i = 1; i < 16; i++)
{
if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3)
if (RTrig.GetInstance("柔性味魔方配料完成").Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3))
{
int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.CutWeightFeedback;
@@ -628,7 +643,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
}
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1"))
if (RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1")))
{
var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
MessageLog.GetInstance.ShowRunLog($"配方{res.RecipeName}配料完成");


+ 1
- 1
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs View File

@@ -96,7 +96,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
public void Init()
{
TestData();
//TestData();
IpAddressLines();
DeviceDataInit();
ThreadManage.GetInstance().StartLong(new Action(() =>


+ 99
- 0
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialColl.cs View File

@@ -0,0 +1,99 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodSmallStation.Model.RawMaterial
{
public class RawMaterialColl : ObservableObject
{
/// <summary>
/// 原料设备IP
/// </summary>
public string DeviceIp { get; set; }

/// <summary>
/// 原料名称
/// </summary>
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } }
private string _mRawMaterialName;

/// <summary>
/// 原料重量设置
/// </summary>
public uint RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } }
private uint _mRawMaterialWeight;


/// <summary>
/// 原料来源
/// 0:本地
/// 1:设备
/// </summary>
public ushort RawMaterialSource { get { return _mRawMaterialSource; } set { _mRawMaterialSource = value; OnPropertyChanged(); } }
private ushort _mRawMaterialSource;

/// <summary>
/// 原料类型 MW18
/// 1:液体
/// 2:膏体
/// 3:粉体
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public ushort RawMaterialType { get { return _mRawMaterialType; } set { _mRawMaterialType = value; OnPropertyChanged(); } }
private ushort _mRawMaterialType;

/// <summary>
/// 料仓重量反馈 MD40
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public float WeightFeedback { get { return _mWeightFeedback; } set { _mWeightFeedback = value; OnPropertyChanged(); } }
private float _mWeightFeedback;

/// <summary>
/// 上限反馈
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public bool UpLimtFeedback { get { return _mUpLimtFeedback; } set { _mUpLimtFeedback = value; OnPropertyChanged(); } }
private bool _mUpLimtFeedback;

/// <summary>
/// 下限反馈
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public bool DownLimtFeedback { get { return _mDownLimtFeedback; } set { _mDownLimtFeedback = value; OnPropertyChanged(); } }
private bool _mDownLimtFeedback;

/// <summary>
/// 下料重量反馈 MD52
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public float UpLimtWeightFeedback { get { return _mUpLimtWeightFeedback; } set { _mUpLimtWeightFeedback = value; OnPropertyChanged(); } }
private float _mUpLimtWeightFeedback;


/// <summary>
/// 原料ID
/// </summary>
public string RawMaterialId { get { return _mRawMaterialId; } set { _mRawMaterialId = value; OnPropertyChanged(); } }
private string _mRawMaterialId;

/// <summary>
/// 原料设备执行状态
/// 1:等待配料
/// 2:下料中
/// 3:下料完成
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public ushort RecipeStatus { get { return _mRecipeStatus; } set { _mRecipeStatus = value; OnPropertyChanged(); } }
private ushort _mRecipeStatus = 1;

/// <summary>
/// 原料对应的桶号
/// </summary>
public ushort BarrelNum { get { return _mBarrelNum; } set { _mBarrelNum = value; OnPropertyChanged(); } }
private ushort _mBarrelNum = 1;
}
}

+ 7
- 0
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeModel.cs View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using BPASmartClient.JXJFoodSmallStation.Model.RawMaterial;
using BPASmartClient.Model;
using Microsoft.Toolkit.Mvvm.ComponentModel;

@@ -40,6 +41,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
[Newtonsoft.Json.JsonIgnore]
public AutoResetEvent Are { get; set; } = new AutoResetEvent(false);

/// <summary>
/// 托盘编号
/// </summary>
public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } }
private int _mTrayCode;

/// <summary>
/// 原料集合
/// </summary>


+ 7
- 0
BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs View File

@@ -13,6 +13,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model

public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } }
private string _mRawMaterialName;

/// <summary>
/// 原料对应的桶号
/// </summary>
@@ -31,6 +32,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
public float Laying_Off_Weight { get { return _mLaying_Off_Weight; } set { _mLaying_Off_Weight = value; } }
private float _mLaying_Off_Weight;

/// <summary>
/// 料仓剩余重量
/// </summary>
public double StockBinRemainingWeight { get { return _mStockBinRemainingWeight; } set { _mStockBinRemainingWeight = value; } }
private double _mStockBinRemainingWeight;

/// <summary>
/// 原料对应料仓的位置
/// </summary>


+ 51
- 22
BPASmartClient.JXJFoodSmallStation/View/NewRecipeView.xaml View File

@@ -87,38 +87,67 @@

<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock
Margin="10,0,0,0"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="请输入配方名称:" />

<TextBlock
Margin="0,0,10,0"
HorizontalAlignment="Right"
Background="Transparent"
FontSize="16"
Foreground="Red"
Text="{Binding ErrorInfo}" />

<StackPanel
Grid.Row="1"
<StackPanel Grid.Row="0"
Margin="10,0,0,0"
Orientation="Horizontal">

<TextBlock
Margin="0,0,0,0"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="配方名称:" />
<TextBox
Grid.Column="1"
Width="200"
Width="150"
Height="30"
Margin="0,0,7,0"
Margin="0,0,0,0"
FontSize="16"
Text="{Binding RecipeName}" />
<TextBlock
Margin="0,0,10,0"
HorizontalAlignment="Right"
Background="Transparent"
FontSize="16"
Foreground="Red"
Text="{Binding ErrorInfo}" />
</StackPanel>
<StackPanel Grid.Row="1"
Margin="10,0,0,0"
Orientation="Horizontal">
<TextBlock
Margin="0,0,0,0"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="配方编号:" />
<TextBox
Width="150"
Height="30"
Margin="0,0,0,0"
FontSize="16"
Text="{Binding RecipeCode}" />
<TextBlock
Margin="10,0,0,0"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="托盘编号:" />
<TextBox
Width="150"
Height="30"
Margin="0,0,0,0"
FontSize="16"
Text="{Binding RecipeCode}" />
</StackPanel>

<StackPanel
Grid.Row="2"
Margin="10,0,0,0"
Orientation="Horizontal">

<Button
Width="148"


+ 6
- 8
BPASmartClient.JXJFoodSmallStation/ViewModel/NewRecipeViewModel.cs View File

@@ -10,6 +10,7 @@ using BPASmartClient.Helper;
using BPASmartClient.JXJFoodSmallStation.Model;
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.Model;
using BPASmartClient.JXJFoodSmallStation.Model.RawMaterial;

namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
@@ -26,7 +27,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
RawMaterials.Add(item);
}
RecipCode = rm.RecipCode;
RecipeCode = rm.RecipCode;
}
}), "Details");

@@ -70,10 +71,9 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
RawMaterials.ElementAt(i).RawMaterialSource = su.RawMaterialSource;
}

}

if (RecipCode.Length <= 0)//新建配方
if (RecipeCode.Length <= 0)//新建配方
{
var res = Array.FindIndex(Json<LocaPar>.Data.Recipes.ToArray(), p => p.RecipeName == RecipeName);

@@ -88,7 +88,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
}
else//修改配方
{
var res = Array.FindIndex(Json<LocaPar>.Data.Recipes.ToArray(), p => p.RecipCode == RecipCode);
var res = Array.FindIndex(Json<LocaPar>.Data.Recipes.ToArray(), p => p.RecipCode == RecipeCode);
if (res >= 0 && res < Json<LocaPar>.Data.Recipes.Count)
{
Json<LocaPar>.Data.Recipes.ElementAt(res).RecipeName = RecipeName;
@@ -138,7 +138,6 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
foreach (var item in Global.DeviceRawMaterials)
{
if (Global.userInfo.devRawMaterials.FirstOrDefault(p => p.RawMaterialName == item.RawMaterialName) != null) RawMaterialNames.Add(item.RawMaterialName);

}
foreach (var item in Json<LocaMaterial>.Data.LocalMaterails)
{
@@ -163,9 +162,8 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
});
}



private string RecipCode = string.Empty;
public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } }
private string _mRecipeCode = string.Empty;

public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } }
private string _mRecipeName = string.Empty;


+ 2
- 2
BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs View File

@@ -58,8 +58,8 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
RawMaterialWeight = new Random().Next(10, 1000),
RawMaterialBarrelNum = (short)new Random().Next(1, 3),
RawMaterialWeight = new Random().Next(10, 20),
RawMaterialBarrelNum = (short)new Random().Next(1, 5),
RawMaterialLocation = i,
});
}


Loading…
Cancel
Save