Переглянути джерело

吉香居大料站代码

样式分支
pengliangyang 2 роки тому
джерело
коміт
6673cc27f6
34 змінених файлів з 1453 додано та 380 видалено
  1. +1
    -11
      BPASmartClient.JXJFoodBigStation/App.xaml.cs
  2. +1
    -2
      BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj
  3. +43
    -0
      BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs
  4. +10
    -11
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs
  5. +51
    -1
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKPlcCommAddress.cs
  6. +180
    -75
      BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
  7. +92
    -0
      BPASmartClient.JXJFoodBigStation/Model/RawMaterial/DeviceAddress.cs
  8. +15
    -0
      BPASmartClient.JXJFoodBigStation/Model/RawMaterial/LocaPar.cs
  9. +44
    -0
      BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialDeviceStatus.cs
  10. +93
    -0
      BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialModel.cs
  11. +49
    -0
      BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeModel.cs
  12. +7
    -8
      BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeRawMaterial.cs
  13. +304
    -7
      BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensCommAddress.cs
  14. +10
    -10
      BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs
  15. +3
    -2
      BPASmartClient.JXJFoodBigStation/Model/TestData.cs
  16. +36
    -54
      BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml
  17. +15
    -3
      BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs
  18. +41
    -1
      BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs
  19. +0
    -2
      BPASmartClient.JXJFoodSmallStation/App.config
  20. +7
    -8
      BPASmartClient.JXJFoodSmallStation/App.xaml.cs
  21. +1
    -29
      BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj
  22. +1
    -1
      BPASmartClient.JXJFoodSmallStation/Model/DeviceInquire.cs
  23. +49
    -0
      BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs
  24. +10
    -11
      BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs
  25. +47
    -0
      BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKPlcCommAddress.cs
  26. +156
    -57
      BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
  27. +7
    -8
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs
  28. +72
    -5
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensCommAddress.cs
  29. +10
    -10
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs
  30. +3
    -2
      BPASmartClient.JXJFoodSmallStation/Model/TestData.cs
  31. +36
    -54
      BPASmartClient.JXJFoodSmallStation/View/RecipeInfosView.xaml
  32. +15
    -3
      BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs
  33. +41
    -1
      BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs
  34. +3
    -4
      SmartClient.sln

+ 1
- 11
BPASmartClient.JXJFoodBigStation/App.xaml.cs Переглянути файл

@@ -13,7 +13,6 @@ using BPASmartClient.CustomResource.Pages.View;
using BPASmartClient.CustomResource.Pages.ViewModel;
using BPASmartClient.Helper;
using BPASmartClient.JXJFoodBigStation.Model;
using BPASmartClient.Nfc;

namespace BPASmartClient.JXJFoodBigStation
{
@@ -52,7 +51,6 @@ namespace BPASmartClient.JXJFoodBigStation

private void MenuInit()
{
NfcServer.GetInstance.Init();

#region 配方管理菜单
ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
@@ -117,19 +115,11 @@ namespace BPASmartClient.JXJFoodBigStation

#region 硬件设备监控
ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "原料设备列表",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.DeviceListView"
});

DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "设备状态",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem",
AssemblyName = "BPASmartClient.JXJFoodBigStation",
ToggleWindowPath = "View.HardwareStatusView"
});



+ 1
- 2
BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj Переглянути файл

@@ -10,6 +10,7 @@
<ItemGroup>
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" />
<ProjectReference Include="..\BPASmartClient.Modbus\BPASmartClient.Modbus.csproj" />
<ProjectReference Include="..\BPASmartClient.S7Net\BPASmartClient.S7Net.csproj" />
</ItemGroup>

<ItemGroup>
@@ -19,11 +20,9 @@
</Page>
<Page Update="View\RecipeInfosView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="View\RecipeReceiveView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
</ItemGroup>



+ 43
- 0
BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs Переглянути файл

@@ -0,0 +1,43 @@
using BPASmartClient.JXJFoodBigStation.Model.Siemens;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodBigStation.Model
{
public class GVL_BigStation
{
/// <summary>
/// 配方数据
/// </summary>
public ObservableCollection<RemoteRecipeData> RemoteRecipes = new ObservableCollection<RemoteRecipeData>();
/// <summary>
/// 配方队列
/// </summary>
public ConcurrentQueue<long> RecipeQueue = new ConcurrentQueue<long>();
/// <summary>
/// 往输送带下发配方完成
/// </summary>
public bool IssueRecipeFinish { get; set; } = false;
/// <summary>
/// 当前料仓的位置
/// </summary>
public int StockInIsWork { get; set; } = 0;
/// <summary>
/// 单个配方执行完成标志
/// </summary>
public bool RecipeFinish { get; set; } = false;
/// <summary>
/// 记录AGV进站送货的指令顺序
/// </summary>
public int AgvDeliveryPosition { get; set; }= 0;
/// <summary>
/// 记录AGV进站取货的指令顺序
/// </summary>
public int AgvPickUpPosition { get; set; } = 0;
}
}

+ 10
- 11
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs Переглянути файл

@@ -5,15 +5,14 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.S7Net;

namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
public class HKDeviceStatus
{
public ModbusTcp ModBusHK = new ModbusTcp();
public string IpAddress => ModBusHK.IPAdress;
public bool IsConnected => ModBusHK.Connected;

public SiemensHelper HK_PLC_S7 = new SiemensHelper();
public bool IsConnected => HK_PLC_S7.IsConnected;
public void Init()
{
if (IsConnected)
@@ -32,8 +31,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
if (IsConnected)
{
ModBusHK.SetUint(HKPlcCommAddress.SingleStockBinLocationToPLC, value);
ModBusHK.Write(HKPlcCommAddress.SingleDosingFinishToPLC, (ushort)1);
HK_PLC_S7.Write(HKPlcCommAddress.SingleStockBinLocationToPLC, value);
HK_PLC_S7.Write(HKPlcCommAddress.SingleDosingFinishToPLC, (ushort)1);
}
}
/// <summary>
@@ -41,21 +40,21 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
/// </summary>
public void AllowDosingSignReset()
{
ModBusHK.Write(HKPlcCommAddress.IsAllowDosing,(ushort)0);
HK_PLC_S7.Write(HKPlcCommAddress.IsAllowDosing,(ushort)0);
}
/// <summary>
/// 复位plc到达某料仓信号
/// </summary>
public void StockStateSignReset()
{
ModBusHK.Write(HKPlcCommAddress.StockState, (ushort)0);
HK_PLC_S7.Write(HKPlcCommAddress.StockState, (ushort)0);
}
/// <summary>
/// 复位一个配方配料完成信号
/// </summary>
public void RecipeDosingFinishReset()
{
ModBusHK.Write(HKPlcCommAddress.RecipeDosingFinish, (ushort)0);
HK_PLC_S7.Write(HKPlcCommAddress.RecipeDosingFinish, (ushort)0);
}
/// <summary>
/// 下发配方数据
@@ -66,8 +65,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
if (IsConnected)
{
ModBusHK.SetUint(HKPlcCommAddress.BarrelNumToPLC, BarrelNum);
ModBusHK.Write(HKPlcCommAddress.StockBinLocationToPLC, StockBinLocation);
HK_PLC_S7.Write(HKPlcCommAddress.BarrelNumToPLC, BarrelNum);
HK_PLC_S7.Write(HKPlcCommAddress.StockBinLocationToPLC, StockBinLocation);
}
}
}


+ 51
- 1
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKPlcCommAddress.cs Переглянути файл

@@ -9,6 +9,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
public class HKPlcCommAddress
{
#region 海科PLC ==> 上位机
public static string HeartHealth { get; set; } = "M5000.0";
/// <summary>
/// 是否允许配料
/// </summary>
@@ -40,8 +41,57 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
/// 当前配料料仓的位置
/// </summary>
public static string SingleStockBinLocationToPLC { get; set; } = "";

/// <summary>
/// 配方配料完成
/// </summary>
public static string RecipeDosingFinish { get; set; } = "";
#endregion

#region AGV进出站
/// <summary>
/// Agv送货 进站申请
/// </summary>
public static string DeliveryAGVApply { get; set; } = "M4002";
/// <summary>
/// Agv送货 进站申请
/// </summary>
public static string DeliveryAGVIsApply { get; set; } = "M5002";
/// <summary>
/// Agv送货 进站顶升申请
/// </summary>
public static string DeliveryAGVApplyJack { get; set; } = "M4004";
/// <summary>
/// Agv送货 进站顶升申请
/// </summary>
public static string DeliveryAGVIsApplyJack { get; set; } = "M5004";
/// <summary>
/// Agv送货 送货完成
/// </summary>
public static string DeliveryAGVFinsih { get; set; } = "M4005";
/// <summary>
/// Agv送货 工位上有货架
/// </summary>
public static string StationHaveCargo { get; set; } = "M5005";
/// <summary>
/// Agv送货 进站申请
/// </summary>
public static string PickAGVApply { get; set; } = "M4003";
/// <summary>
/// Agv送货 进站申请
/// </summary>
public static string PickAGVIsApply { get; set; } = "M5003";
/// <summary>
/// Agv送货 取货架完成
/// </summary>
public static string PickCargoAGVFinish { get; set; } = "M4006";
/// <summary>
/// Agv送货 取料完成
/// </summary>
public static string PickAGVFinish { get; set; } = "M5006";
/// <summary>
/// 工位上是否有小车
/// </summary>
public static string StationIsExistCar { get; set; } = "M4007";
#endregion
}
}

+ 180
- 75
BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs Переглянути файл

@@ -1,4 +1,5 @@
using BPASmartClient.Helper;
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.Helper;
using BPASmartClient.JXJFoodBigStation.Model.HK_PLC;
using BPASmartClient.JXJFoodBigStation.Model.Siemens;
using BPASmartClient.Modbus;
@@ -9,78 +10,71 @@ using System.Collections.ObjectModel;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodBigStation.Model
{
public class ProcessControl
{
{
private volatile static ProcessControl _Instance;
public static ProcessControl GetInstance => _Instance ?? (_Instance = new ProcessControl());
private ProcessControl() { }

public ObservableCollection<RemoteRecipeData> RemoteRecipes;
ConcurrentQueue<long> RecipeQueue = new ConcurrentQueue<long>();
ConcurrentQueue<string> DeviceQueue = new ConcurrentQueue<string>();
public ObservableCollection<RemoteRecipeRawMaterial> RawMaterials { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>();
public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
public HKDeviceStatus HKDevice = new HKDeviceStatus();
GVL_BigStation BigStation = new GVL_BigStation();
/// <summary>
/// 接收原料数据
/// </summary>
public RecipeRawMaterial RawMaterial;
public void Init()
{
string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"];
string HK_PLC_Port = ConfigurationManager.AppSettings["HKPlc_Port"];
string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
string Siemens_PLC_Port = ConfigurationManager.AppSettings["Siemens_Port"];
Task.Run(new Action(() =>
{
HKDevice.ModBusHK.ModbusTcpConnect(HK_PLC_IP, int.Parse(HK_PLC_Port));
SiemensDevice.SiemensTcp.ModbusTcpConnect(Siemens_PLC_IP, int.Parse(Siemens_PLC_Port));
if (HKDevice.IsConnected)
{
HKDevice.Init();
}
if (SiemensDevice.IsConnected)
{
SiemensDevice.Init();
}
}));
ActionManage.GetInstance.Register(new Action(()=>
{
}), "给流水线下发配方数据", true);
ActionManage.GetInstance.Register(new Action(() =>
{
if (SiemensDevice.IsConnected)
if (SiemensDevice.IsConnected)
{
var res = SiemensDevice.SiemensTcp.GetString(SiemensCommAddress.RecipeName, (ushort)20);
var res1 = SiemensDevice.SiemensTcp.Read(SiemensCommAddress.RecipeID);
var res2 = SiemensDevice.SiemensTcp.Read(SiemensCommAddress.RawMaterial);
var res = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeName);
var res1 = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeID);
int res2 = SiemensDevice.Siemens_PLC_S7.ReadClass(RawMaterial, 0, 0);
if ((res != null && res is string recipeName) &&
(res1 != null && res1 is uint recipeID) &&
(res2 != null && res2 is ushort[] rawMaterial))
(res2 > 0))
{
RawMaterials.Clear();
RawMaterials.Add(new RemoteRecipeRawMaterial()
int index = Array.FindIndex(Json<RemoteRecipeDataColl>.Data.Recipes.ToArray(), p => p.RecipeCode == recipeID);
if (!(index >= 0))
{
RawMaterialBarrelNum = rawMaterial[0],
RawMaterialLocation= rawMaterial[1],
RawMaterialWeight= rawMaterial[2]
});
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
RawMaterials.Clear();
for (int i = 0; i < 15; i++)
{
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
RawMaterialBarrelNum = RawMaterial.RawMaterialBarrelNum[i],
RawMaterialLocation = RawMaterial.RawMaterialLocation[i],
RawMaterialWeight = RawMaterial.RawMaterialWeight[i]
});
}
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
{
RecipeName = recipeName,
RecipeCode = recipeID,
RawMaterial = RawMaterials
});
}
else
{
RecipeName = recipeName,
RecipeCode = recipeID,
RawMaterial = RawMaterials
});
MessageLog.GetInstance.AlarmLog("配方列表中存在该配方ID");
}
}
}
}), "西门子下发配方", true);
ActionManage.GetInstance.Register(new Action(() =>
{
if (SiemensDevice.IsConnected)
if (SiemensDevice.IsConnected)
{
var res = SiemensDevice.SiemensTcp.Read(SiemensCommAddress.TrayLocationNum);
var res1 = SiemensDevice.SiemensTcp.Read(SiemensCommAddress.RecipeID);
var res = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.TrayLocationNum);
var res1 = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeID);
if (res != null && res is int TrayLocation && res1 != null && res1 is int recipeId)
{
int index = Array.FindIndex(Json<RemoteRecipeDataColl>.Data.Recipes.ToArray(), p => p.RecipeCode == recipeId);
@@ -91,64 +85,175 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
}
}), "AGV到位信号", true);//根据下发的配方ID将 托盘的位置信息添加到配方中

RecipeQueue.Clear();
ReceviceData();
string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"];
string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
try
{
//HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S7200Smart, HK_PLC_IP);
//SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
if (HKDevice.IsConnected)
{
HKDevice.Init();
}
if (SiemensDevice.IsConnected)
{
SiemensDevice.Init();
}
}
catch(Exception ex)
{
}
BigStation.RecipeQueue.Clear();
Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
ThreadManage.GetInstance().StartLong(new Action(() =>
{
ReceviceData();
RecipeInfoToHKPLC();
Thread.Sleep(10);
}), "流程处理", true);
ThreadManage.GetInstance().StartLong(new Action(() => {
if (HKDevice.IsConnected && SiemensDevice.IsConnected)
{
AgvGetInDelivery();
AgvGetInPickUp();
}
Thread.Sleep(10);
}), "AGV进站送取货", true);
}
/// <summary>
/// AGV进站送货
/// </summary>
private void AgvGetInDelivery()
{
switch (BigStation.AgvDeliveryPosition)
{
case 0:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVApply) is bool))
{
BigStation.AgvDeliveryPosition = 1;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApply, true);
}
break;
case 1:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApply) is bool))
{
BigStation.AgvDeliveryPosition = 2;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApply, true);
}
break;
case 2:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVApplyJack) is bool))
{
BigStation.AgvDeliveryPosition = 3;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApplyJack, true);
}
break;
case 3:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApplyJack) is bool))
{
BigStation.AgvDeliveryPosition = 4;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApplyJack, true);
}
break;
case 4:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVFinsih) is bool))
{
BigStation.AgvDeliveryPosition = 5;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVFinsih, true);
}
break;
case 5:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationHaveCargo) is bool))
{
BigStation.AgvDeliveryPosition = 0;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationHaveCargo, true);
}
break;
default:
break;
}
//获取工位上是否有小车
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool)
HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationIsExistCar));
}
/// <summary>
/// AGV进站取货
/// </summary>
private void AgvGetInPickUp()
{
switch (BigStation.AgvPickUpPosition)
{
case 0:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.PickAGVApply) is bool))
{
BigStation.AgvPickUpPosition = 1;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.PickAGVApply, true);
}
break;
case 1:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.PickAGVIsApply) is bool))
{
BigStation.AgvPickUpPosition = 2;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVIsApply, true);
}
break;
case 2:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.PickCargoAGVFinish) is bool))
{
BigStation.AgvPickUpPosition = 3;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.PickCargoAGVFinish, true);
}
break;
case 3:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.PickAGVFinish) is bool))
{
BigStation.AgvPickUpPosition = 0;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVFinish, true);
}
break;
default:
break;
}
}

private void ReceviceData()
{
RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
RawMaterials = TestData.GetInstance.RawMaterials;//添加测试数据
BigStation.RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
if (Json<RemoteRecipeDataColl>.Data.Recipes.Count > 0)
{
foreach (var data in Json<RemoteRecipeDataColl>.Data.Recipes)
{
if(!(RecipeQueue.Contains(data.RecipeCode)))
RecipeQueue.Enqueue(data.RecipeCode);
if(!(BigStation.RecipeQueue.Contains(data.RecipeCode)))
BigStation.RecipeQueue.Enqueue(data.RecipeCode);
}
}
}
/// <summary>
/// 当前料仓的位置
/// </summary>
private int StockInIsWork;
/// <summary>
/// 单个配方执行完成标志
/// </summary>
private bool RecipeFinfish;
private void RecipeInfoToHKPLC()
private void RecipeInfoToHKPLC()
{
if (RecipeQueue.Count > 0)
if (BigStation.RecipeQueue.Count > 0)
{
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0));
if (index >= 0 && index <= RemoteRecipes.Count)
int index = Array.FindIndex(BigStation.RemoteRecipes.ToArray(), p => p.RecipeCode == BigStation.RecipeQueue.ElementAt(0));
if (index >= 0 && index <= BigStation.RemoteRecipes.Count)
{
long code = RemoteRecipes.ElementAt(index).RecipeCode;
if (RTrig.GetInstance("IsAllowDosing").Start(HKDevice.ModBusHK.Read(HKPlcCommAddress.IsAllowDosing) is bool a))
long code = BigStation.RemoteRecipes.ElementAt(index).RecipeCode;
if (RTrig.GetInstance("IsAllowDosing").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.IsAllowDosing) is bool a))
{
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
foreach (var item in BigStation.RemoteRecipes.ElementAt(index).RawMaterial)
{
HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation);
}
HKDevice.AllowDosingSignReset();

BigStation.IssueRecipeFinish = true;
}
if (RTrig.GetInstance("StockState").Start(HKDevice.ModBusHK.Read(HKPlcCommAddress.RecipeDosingFinish) is bool))
if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.RecipeDosingFinish) is bool))
{
HKDevice.RecipeDosingFinishReset();
RecipeQueue.TryDequeue(out code);
BigStation.RecipeQueue.TryDequeue(out code);
Json<RemoteRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
}
}
}
}
private void HKPLCIsWork()
{
}
}
}

+ 92
- 0
BPASmartClient.JXJFoodBigStation/Model/RawMaterial/DeviceAddress.cs Переглянути файл

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

namespace BPASmartClient.JXJFoodBigStation.Model
{
public class DeviceAddress
{
#region 源地址
///// <summary>
///// 设备名称起始地址
///// </summary>
//public static string DeviceName { get; set; } = "LW0";

///// <summary>
///// 料仓重量反馈起始地址
///// </summary>
//public static string WeightFeedback { get; set; } = "LW52";//LW204

///// <summary>
///// 重量设置地址
///// </summary>
//public static string WeightSet { get; set; } = "LW21";//LW200

///// <summary>
///// 启动信号地址
///// </summary>
//public static string Start { get; set; } = "LW20";//LW210

///// <summary>
///// 下料重量反馈地址
///// </summary>
//public static string CutWeightFeedback { get; set; } = "LW54";//LW202

///// <summary>
///// 设备运行状态地址
///// </summary>
//public static string RunStatus { get; set; } = "LW55";//LW206

///// <summary>
///// 料仓的位置
///// </summary>
//public static string Location { get; set; } = "LW53";
#endregion
#region 上位机下发
/// <summary>
/// 原料出料重量
/// </summary>
public static string WeightSet { get; set; } = "LW11";
/// <summary>
/// 启动开始配料
/// </summary>
public static string Start { get; set; } = "LW12";
#endregion
#region 上位机读取
/// <summary>
/// 设备运行状态地址
/// </summary>
public static string RunStatus { get; set; } = "LW50";
/// <summary>
/// 报警字
/// </summary>
public static string AlarmInfo { get; set; } = "LW51";
/// <summary>
/// 原料名称
/// </summary>
public static string DeviceName { get; set; } = "LW52";
/// <summary>
/// 料仓的位置
/// </summary>
public static string Location { get; set; } = "LW53";
/// <summary>
/// 原料类型
/// </summary>
public static string RawMaterialType { get; set; } = "LW54";
/// <summary>
/// 出料完成信号
/// </summary>
public static string OutRawMaterialFinish { get; set; } = "LW55";
/// <summary>
/// 料仓重量反馈起始地址
/// </summary>
public static string WeightFeedback { get; set; } = "LW56";
/// <summary>
/// 下料重量反馈地址
/// </summary>
public static string CutWeightFeedback { get; set; } = "LW57";
#endregion
}
}

+ 15
- 0
BPASmartClient.JXJFoodBigStation/Model/RawMaterial/LocaPar.cs Переглянути файл

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using BPASmartClient.JXJFoodBigStation.ViewModel;

namespace BPASmartClient.JXJFoodBigStation.Model
{
public class LocaPar
{
public ObservableCollection<RecipeModel> Recipes { get; set; } = new ObservableCollection<RecipeModel>();
}
}

+ 44
- 0
BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialDeviceStatus.cs Переглянути файл

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

namespace BPASmartClient.JXJFoodBigStation.Model
{
public class RawMaterialDeviceStatus
{
/// <summary>
/// 原料类型
/// 1:液体
/// 2:膏体
/// 3:粉体
/// </summary>
public ushort RawMaterialType { get; set; }

/// <summary>
/// 料仓重量反馈
/// </summary>
public float WeightFeedback { get; set; }

/// <summary>
/// 上限反馈
/// </summary>
public bool UpLimitFeedback { get; set; }

/// <summary>
/// 下限反馈
/// </summary>
public bool DownLimitFeedback { get; set; }

/// <summary>
/// 下料重量反馈
/// </summary>
public float CutWeightFeedback { get; set; }

/// <summary>
/// 设备运行状态
/// </summary>
public ushort RunStatus { get; set; }
}
}

+ 93
- 0
BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialModel.cs Переглянути файл

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

namespace BPASmartClient.JXJFoodBigStation.Model
{
/// <summary>
/// 原料模块
/// </summary>
public class RawMaterialModel : ObservableObject
{
/// <summary>
/// 原料名称
/// </summary>
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } }
private string _mRawMaterialName;

/// <summary>
/// 原料编号
/// </summary>
public int RawMateriaLocation { get { return _mRawMaterialLocation; } set { _mRawMaterialLocation = value; OnPropertyChanged(); } }
private int _mRawMaterialLocation;

/// <summary>
/// 原料设备IP
/// </summary>
public string DeviceIp { get; set; }

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

/// <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;
}
}

+ 49
- 0
BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeModel.cs Переглянути файл

@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using BPASmartClient.JXJFoodBigStation.ViewModel;
using Microsoft.Toolkit.Mvvm.ComponentModel;

namespace BPASmartClient.JXJFoodBigStation.Model
{
/// <summary>
/// 配方模块
/// </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>
public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } }
private string _mRecipeName;

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

[Newtonsoft.Json.JsonIgnore]
public AutoResetEvent Are { get; set; } = new AutoResetEvent(false);

/// <summary>
/// 原料集合
/// </summary>
public ObservableCollection<RawMaterialModel> RawMaterials { get; set; } = new ObservableCollection<RawMaterialModel>();

}
}

+ 7
- 8
BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeRawMaterial.cs Переглянути файл

@@ -6,28 +6,27 @@ using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodBigStation.Model
{
public class RemoteRecipeRawMaterial
public class RemoteRecipeRawMaterial
{
private int _mIp;
public int DeviceIp { get { return _mIp; } set { _mIp = value; } }
public int DeviceIp { get { return _mIp; } set { _mIp = value; }}

private int _mRawMaterialBarrelNum;
/// <summary>
/// 原料对应的桶号
/// </summary>
public int RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; } }
private int _mRawMaterialBarrelNum;

private double _mRawMaterialWeight;
/// <summary>
/// 需要原料重量
/// </summary>
public double RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value;} }
public double RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; } }
private double _mRawMaterialWeight;

private int _mRawMaterialLocation;
/// <summary>
/// 原料对应料仓的位置
/// </summary>
public int RawMaterialLocation { get { return _mRawMaterialLocation; } set { _mRawMaterialLocation = value;} }
public int RawMaterialLocation { get { return _mRawMaterialLocation; } set { _mRawMaterialLocation = value; } }
private int _mRawMaterialLocation;
}
}

+ 304
- 7
BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensCommAddress.cs Переглянути файл

@@ -26,19 +26,316 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
/// </summary>
public static string RawMaterial { get; set; } = "";
#endregion

#region AGV到位(与西门子PLC交互)西门子PLC ==> 上位机
/// <summary>
/// 托盘的位置编号
/// </summary>
public static string TrayLocationNum { get; set; } = "";
/// <summary>
/// 配方ID
/// </summary>
public static string TrayRecipeID { get; set; } = "";
public static string TrayState { get; set; } = "";
/// <summary>
/// 状态信号
/// </summary>
public static string StateSign { get; set; } = "";
#endregion

#region Tray配料完成(与西门子PLC交互)上位机 ==> 西门子PLC
public static string TrayLocationNumToPLC { get; set; } = "";
public static string TrayRecipeIDToPLC { get; set; } = "";
public static string TrayStateToPLC { get; set; } = "";
public static string TrayLocationNumToSiemens { get; set; } = "";
public static string TrayRecipeIDToSiemens { get; set; } = "";
public static string TrayStateToSiemens { get; set; } = "";
#endregion
#region AGV小车进出工站1
/// <summary>
/// Agv送货 进站申请 从西门子读取
/// </summary>
public static string DeliveryAGVApply1 { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 写给西门子
/// </summary>
public static string DeliveryAGVIsApply1 { get; set; } = "";
/// <summary>
/// Agv送货 进站顶升申请 从西门子读取
/// </summary>
public static string DeliveryAGVApplyJack1 { get; set; } = "";
/// <summary>
/// Agv送货 进站顶升申请 写给西门子
/// </summary>
public static string DeliveryAGVIsApplyJack1 { get; set; } = "";
/// <summary>
/// Agv送货 送货完成 从西门子读取
/// </summary>
public static string DeliveryAGVFinsih1{ get; set; } = "";
/// <summary>
/// Agv送货 工位上有货架 写给西门子
/// </summary>
public static string StationHaveCargo1 { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 从西门子读取
/// </summary>
public static string PickAGVApply1 { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 写给西门子
/// </summary>
public static string PickAGVIsApply1 { get; set; } = "";
/// <summary>
/// Agv送货 取货架完成 从西门子读取
/// </summary>
public static string PickCargoAGVFinish1 { get; set; } = "";
/// <summary>
/// Agv送货 取料完成 写给西门子
/// </summary>
public static string PickAGVFinish1 { get; set; } = "";
/// <summary>
/// 工位上是否有小车
/// </summary>
public static string StationIsExistCar1 { get; set; } = "";
#endregion
#region AGV小车进出工站2
/// <summary>
/// Agv送货 进站申请 从西门子读取
/// </summary>
public static string DeliveryAGVApply2 { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 写给西门子
/// </summary>
public static string DeliveryAGVIsApply2 { get; set; } = "";
/// <summary>
/// Agv送货 进站顶升申请 从西门子读取
/// </summary>
public static string DeliveryAGVApplyJack2 { get; set; } = "";
/// <summary>
/// Agv送货 进站顶升申请 写给西门子
/// </summary>
public static string DeliveryAGVIsApplyJack2 { get; set; } = "";
/// <summary>
/// Agv送货 送货完成 从西门子读取
/// </summary>
public static string DeliveryAGVFinsih2 { get; set; } = "";
/// <summary>
/// Agv送货 工位上有货架 写给西门子
/// </summary>
public static string StationHaveCargo2 { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 从西门子读取
/// </summary>
public static string PickAGVApply2 { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 写给西门子
/// </summary>
public static string PickAGVIsApply2 { get; set; } = "";
/// <summary>
/// Agv送货 取货架完成 从西门子读取
/// </summary>
public static string PickCargoAGVFinish2 { get; set; } = "";
/// <summary>
/// Agv送货 取料完成 写给西门子
/// </summary>
public static string PickAGVFinish2 { get; set; } = "";
/// <summary>
/// 工位上是否有小车
/// </summary>
public static string StationIsExistCar2 { get; set; } = "";
#endregion
#region AGV小车进出工站3
/// <summary>
/// Agv送货 进站申请 从西门子读取
/// </summary>
public static string DeliveryAGVApply3 { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 写给西门子
/// </summary>
public static string DeliveryAGVIsApply3 { get; set; } = "";
/// <summary>
/// Agv送货 进站顶升申请 从西门子读取
/// </summary>
public static string DeliveryAGVApplyJack3 { get; set; } = "";
/// <summary>
/// Agv送货 进站顶升申请 写给西门子
/// </summary>
public static string DeliveryAGVIsApplyJack3 { get; set; } = "";
/// <summary>
/// Agv送货 送货完成 从西门子读取
/// </summary>
public static string DeliveryAGVFinsih3 { get; set; } = "";
/// <summary>
/// Agv送货 工位上有货架 写给西门子
/// </summary>
public static string StationHaveCargo3 { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 从西门子读取
/// </summary>
public static string PickAGVApply3 { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 写给西门子
/// </summary>
public static string PickAGVIsApply3 { get; set; } = "";
/// <summary>
/// Agv送货 取货架完成 从西门子读取
/// </summary>
public static string PickCargoAGVFinish3 { get; set; } = "";
/// <summary>
/// Agv送货 取料完成 写给西门子
/// </summary>
public static string PickAGVFinish3 { get; set; } = "";
/// <summary>
/// 工位上是否有小车
/// </summary>
public static string StationIsExistCar3 { get; set; } = "";
#endregion
#region AGV小车进出工站4
/// <summary>
/// Agv送货 进站申请 从西门子读取
/// </summary>
public static string DeliveryAGVApply4 { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 写给西门子
/// </summary>
public static string DeliveryAGVIsApply4 { get; set; } = "";
/// <summary>
/// Agv送货 进站顶升申请 从西门子读取
/// </summary>
public static string DeliveryAGVApplyJack4 { get; set; } = "";
/// <summary>
/// Agv送货 进站顶升申请 写给西门子
/// </summary>
public static string DeliveryAGVIsApplyJack4 { get; set; } = "";
/// <summary>
/// Agv送货 送货完成 从西门子读取
/// </summary>
public static string DeliveryAGVFinsih4 { get; set; } = "";
/// <summary>
/// Agv送货 工位上有货架 写给西门子
/// </summary>
public static string StationHaveCargo4 { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 从西门子读取
/// </summary>
public static string PickAGVApply4 { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 写给西门子
/// </summary>
public static string PickAGVIsApply4 { get; set; } = "";
/// <summary>
/// Agv送货 取货架完成 从西门子读取
/// </summary>
public static string PickCargoAGVFinish4 { get; set; } = "";
/// <summary>
/// Agv送货 取料完成 写给西门子
/// </summary>
public static string PickAGVFinish4 { get; set; } = "";
/// <summary>
/// 工位上是否有小车
/// </summary>
public static string StationIsExistCar4 { get; set; } = "";
#endregion
#region AGV小车进出工站5
/// <summary>
/// Agv送货 进站申请 从西门子读取
/// </summary>
public static string DeliveryAGVApply5 { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 写给西门子
/// </summary>
public static string DeliveryAGVIsApply5 { get; set; } = "";
/// <summary>
/// Agv送货 进站顶升申请 从西门子读取
/// </summary>
public static string DeliveryAGVApplyJack5 { get; set; } = "";
/// <summary>
/// Agv送货 进站顶升申请 写给西门子
/// </summary>
public static string DeliveryAGVIsApplyJack5 { get; set; } = "";
/// <summary>
/// Agv送货 送货完成 从西门子读取
/// </summary>
public static string DeliveryAGVFinsih5 { get; set; } = "";
/// <summary>
/// Agv送货 工位上有货架 写给西门子
/// </summary>
public static string StationHaveCargo5 { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 从西门子读取
/// </summary>
public static string PickAGVApply5 { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 写给西门子
/// </summary>
public static string PickAGVIsApply5 { get; set; } = "";
/// <summary>
/// Agv送货 取货架完成 从西门子读取
/// </summary>
public static string PickCargoAGVFinish5 { get; set; } = "";
/// <summary>
/// Agv送货 取料完成 写给西门子
/// </summary>
public static string PickAGVFinish5 { get; set; } = "";
/// <summary>
/// 工位上是否有小车
/// </summary>
public static string StationIsExistCar5 { get; set; } = "";
#endregion
#region AGV小车进出工站6
/// <summary>
/// Agv送货 进站申请 从西门子读取
/// </summary>
public static string DeliveryAGVApply6 { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 写给西门子
/// </summary>
public static string DeliveryAGVIsApply6 { get; set; } = "";
/// <summary>
/// Agv送货 进站顶升申请 从西门子读取
/// </summary>
public static string DeliveryAGVApplyJack6 { get; set; } = "";
/// <summary>
/// Agv送货 进站顶升申请 写给西门子
/// </summary>
public static string DeliveryAGVIsApplyJack6 { get; set; } = "";
/// <summary>
/// Agv送货 送货完成 从西门子读取
/// </summary>
public static string DeliveryAGVFinsih6 { get; set; } = "";
/// <summary>
/// Agv送货 工位上有货架 写给西门子
/// </summary>
public static string StationHaveCargo6 { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 从西门子读取
/// </summary>
public static string PickAGVApply6 { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 写给西门子
/// </summary>
public static string PickAGVIsApply6 { get; set; } = "";
/// <summary>
/// Agv送货 取货架完成 从西门子读取
/// </summary>
public static string PickCargoAGVFinish6 { get; set; } = "";
/// <summary>
/// Agv送货 取料完成 写给西门子
/// </summary>
public static string PickAGVFinish6 { get; set; } = "";
/// <summary>
/// 工位上是否有小车
/// </summary>
public static string StationIsExistCar6 { get; set; } = "";
#endregion
}

public class RecipeRawMaterial
{
/// <summary>
/// 原料对应的桶号
/// </summary>
public int[] RawMaterialBarrelNum = new int[15];
/// <summary>
/// 需要原料重量
/// </summary>
public double[] RawMaterialWeight = new double[15];
/// <summary>
/// 原料对应料仓的位置
/// </summary>
public int[] RawMaterialLocation = new int[15];
}

}

+ 10
- 10
BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs Переглянути файл

@@ -5,28 +5,28 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.S7Net;

namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
public class SiemensDeviceStatus
{
public ModbusTcp SiemensTcp = new ModbusTcp();
public bool IsConnected => SiemensTcp.Connected;
public string IpAddress => SiemensTcp.IPAdress;
public SiemensHelper Siemens_PLC_S7 = new SiemensHelper();
public bool IsConnected => Siemens_PLC_S7.IsConnected;

/// <summary>
/// 配方接收信号复位
/// </summary>
public void RecipeSignReset()
{
this.SiemensTcp.Write(SiemensCommAddress.RecipeState, (ushort)0);
this.Siemens_PLC_S7.Write(SiemensCommAddress.RecipeState, (ushort)0);
}
/// <summary>
/// AGV到位信号复位
/// </summary>
public void AgvSignReset()
{
this.SiemensTcp.Write(SiemensCommAddress.TrayState, (ushort)0);
this.Siemens_PLC_S7.Write(SiemensCommAddress.StateSign, (ushort)0);
}
public void Init()
{
@@ -34,13 +34,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
var res = this.SiemensTcp.Read(SiemensCommAddress.RecipeState);
var res = this.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeState);
if (res != null && RTrig.GetInstance("RecipeTrig").Start(res is bool SignTrig))
{
ActionManage.GetInstance.Send("西门子下发配方");
RecipeSignReset();
}
var AgvState = this.SiemensTcp.Read(SiemensCommAddress.TrayState);
var AgvState = this.Siemens_PLC_S7.Read(SiemensCommAddress.StateSign);
if (AgvState != null && RTrig.GetInstance("AgvTrig").Start(res is bool AgvSignTrig))
{
ActionManage.GetInstance.Send("AGV到位信号");
@@ -56,9 +56,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
/// <param name="recipeID"></param>
private void DosingFinsih(int TrayLocation,int recipeID)
{
this.SiemensTcp.Write(SiemensCommAddress.TrayLocationNumToPLC, TrayLocation);
this.SiemensTcp.Write(SiemensCommAddress.TrayStateToPLC, 1);
this.SiemensTcp.Write(SiemensCommAddress.TrayRecipeIDToPLC, recipeID);
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayLocationNumToSiemens, TrayLocation);
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayStateToSiemens, 1);
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayRecipeIDToSiemens, recipeID);
}
}
}

+ 3
- 2
BPASmartClient.JXJFoodBigStation/Model/TestData.cs Переглянути файл

@@ -13,6 +13,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
public volatile static TestData Instance;
public static TestData GetInstance => Instance ?? (Instance = new TestData());
public ObservableCollection<RemoteRecipeData> Recipes { get; set; } = new ObservableCollection<RemoteRecipeData>();
public ObservableCollection<RemoteRecipeRawMaterial> RawMaterials { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>();
public TestData()
{
@@ -53,7 +54,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
RawMaterialLocation = RawMaterialLocation2
});

Json<RemoteRecipeDataColl>.Data.Recipes.Add(new Model.RemoteRecipeData()
Recipes.Add(new Model.RemoteRecipeData()
{
RecipeName = recipeName,
RecipeCode = recipeCode,
@@ -99,7 +100,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
RawMaterialLocation = RawMaterialLocation2_2
});

Json<RemoteRecipeDataColl>.Data.Recipes.Add(new Model.RemoteRecipeData()
Recipes.Add(new Model.RemoteRecipeData()
{
RecipeName = recipeName_2,
RecipeCode = recipeCode_2,


+ 36
- 54
BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml Переглянути файл

@@ -28,7 +28,7 @@

<ResourceDictionary>
<!--#region ListBox样式-->
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">
<!--<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="BorderBrush" Value="{x:Null}" />
@@ -45,7 +45,7 @@
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Style>-->
<!--#endregion-->
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
@@ -58,14 +58,13 @@
</Border.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="5" />
<RowDefinition />
</Grid.RowDefinitions>

<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
@@ -77,8 +76,11 @@
<TextBlock Margin="10,0,0,0" Background="Transparent" FontSize="20" Foreground="#FF2AB2E7" Text="配方编号:" />
<TextBlock Grid.Row="1" Margin="10,0,0,0" Background="Transparent" FontSize="20" Foreground="#FF2AB2E7" Text="{Binding RecipeCode}" />
</WrapPanel>

<Grid Grid.Row="2">
<WrapPanel Grid.Row="2">
<TextBlock Margin="10,0,0,0" Background="Transparent" FontSize="20" Foreground="#FF2AB2E7" Text="托盘编号:" />
<TextBlock Grid.Row="1" Margin="10,0,0,0" Background="Transparent" FontSize="20" Foreground="#FF2AB2E7" Text="{Binding TrayCode}" />
</WrapPanel>
<Grid Grid.Row="3">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
@@ -86,10 +88,10 @@
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="9*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" HorizontalAlignment="Center">小料</TextBlock>
<TextBlock Grid.Row="0" HorizontalAlignment="Center">大料站</TextBlock>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="1*"></RowDefinition>
<RowDefinition Height="20"></RowDefinition>
<RowDefinition Height="9*"></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0" >
@@ -102,52 +104,32 @@
<TextBlock FontSize="16" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Top">原料位置</TextBlock>
<TextBlock FontSize="16" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Top">原料重量</TextBlock>
</Grid>
<!--<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<Grid>
<ItemsControl ItemsSource="{Binding RawMaterials}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid x:Name="gr" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding RawMaterialBarrelNum}"></TextBlock>
<TextBlock Grid.Column="1" Text="{Binding RawmaterialLocation}"></TextBlock>
<TextBlock Grid.Column="2" Text="{Binding RawMaterialWeight}"></TextBlock>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

</Grid>
</ScrollViewer>-->

<ItemsControl ItemsSource="{Binding RawMaterials}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid x:Name="gr" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding RawMaterialBarrelNum}"></TextBlock>
<TextBlock Grid.Column="1" Text="{Binding RawMaterialLocation}"></TextBlock>
<TextBlock Grid.Column="2" Text="{Binding RawMaterialWeight}"></TextBlock>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Auto" >
<ItemsControl ItemsSource="{Binding RawMaterialsInfo}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid x:Name="grb" Height="25" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="20" Foreground="#FF2AB2E7" Text="{Binding RawMaterialBarrelNum}"></TextBlock>
<TextBlock Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="20" Foreground="#FF2AB2E7" Text="{Binding RawMaterialLocation}"></TextBlock>
<TextBlock Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="20" Foreground="#FF2AB2E7" Text="{Binding RawMaterialWeight}"></TextBlock>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="grb" Property="Background" Value="#112AB2E7" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Grid>
<Grid Grid.Row="3">
<Grid Grid.Row="4">
<Button Command="{Binding ReturnPage}" Width="200" >返回</Button>
</Grid>
</Grid>


+ 15
- 3
BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs Переглянути файл

@@ -22,10 +22,18 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
{
RecipeName = rm.RecipeName;
RecipeCode = rm.RecipeCode;
RawMaterials = rm.RawMaterial;
TrayCode = rm.TrayCode;
//RawMaterialsInfo = rm.RawMaterial;
//var rest = RawMaterialsInfo.GetHashCode();

foreach (var item in rm.RawMaterial)
{
RawMaterialsInfo.Add(item);
}
}
}), "RecipeInfo");
ReturnPage = new RelayCommand(() =>

ReturnPage = new RelayCommand(() =>
{
ActionManage.GetInstance.Send("CloseRecipeInfosView");
});
@@ -37,7 +45,11 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } }
private long _mRecipeCode;

public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } }
private int _mTrayCode;

public RelayCommand ReturnPage { get; set; }
public ObservableCollection<RemoteRecipeRawMaterial> RawMaterials { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>();

public ObservableCollection<RemoteRecipeRawMaterial> RawMaterialsInfo { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>();
}
}

+ 41
- 1
BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs Переглянути файл

@@ -23,6 +23,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
{
public class RecipeReceiveViewModel : ObservableObject
{
ObservableCollection<RemoteRecipeRawMaterial> RawMaterials { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>();
public RecipeReceiveViewModel()
{
//Json<LocaPar>.Read();
@@ -35,14 +36,53 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
RecipeInfosView nrv = new RecipeInfosView();
var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == num);
ActionManage.GetInstance.Send("RecipeInfo", res);
nrv.ShowDialog();
nrv.Show();
MessageLog.GetInstance.ShowUserLog($"查看配方——{res.RecipeName}");
}
});
NewSimulateRecipe = new RelayCommand(() =>
{
RawMaterials.Clear();
string recipeName = "配方" + (Json<RemoteRecipeDataColl>.Data.Recipes.Count + 1) + "";
go:
long recipeCode = new Random().Next(1000, 9999);
foreach (var item in Recipes)
{
if (item.RecipeCode == recipeCode)
{
goto go;
}
}
int trayCode = new Random().Next(1, 3);
for (int i = 1; i < 16; i++)
{
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
RawMaterialWeight = new Random().Next(10, 1000),
RawMaterialBarrelNum = new Random().Next(1, 3),
RawMaterialLocation = i,
});
}
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
{
RecipeName = recipeName,
RecipeCode = recipeCode,
TrayCode = trayCode,
RawMaterial = RawMaterials,
});

});
ClearAllRecipe = new RelayCommand(() =>
{
Json<RemoteRecipeDataColl>.Data.Recipes.Clear();
});
}

public RelayCommand<object> DetailsCommand { get; set; }

public RelayCommand NewSimulateRecipe { get; set; }
public RelayCommand ClearAllRecipe { get; set; }

public ObservableCollection<RemoteRecipeData> Recipes { get; set; }
}
}

+ 0
- 2
BPASmartClient.JXJFoodSmallStation/App.config Переглянути файл

@@ -2,8 +2,6 @@
<configuration>
<appSettings>
<add key="HKPlc_IP" value="192.168.0.20"/>
<add key="HKPlc_Port" value="502"/>
<add key="Siemens_IP" value="192.168.0.30"/>
<add key="Siemens_Port" value="502"/>
</appSettings>
</configuration>

+ 7
- 8
BPASmartClient.JXJFoodSmallStation/App.xaml.cs Переглянути файл

@@ -30,7 +30,6 @@ namespace BPASmartClient.JXJFoodSmallStation
DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化
ProcessControl.GetInstance.Init();
MainView mv = new MainView();
//mv.Show();
LoginView lv = new LoginView();
var res = lv.ShowDialog();
if (res != null && res == true)
@@ -53,25 +52,25 @@ namespace BPASmartClient.JXJFoodSmallStation

private void MenuInit()
{
NfcServer.GetInstance.Init();
//NfcServer.GetInstance.Init();

#region 配方管理菜单
ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
RecipeManage.Add(new SubMenumodel()
/*RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "本地配方管理",
SubMenuPermission = new Permission[] { Permission.管理员 },
AssemblyName = "BPASmartClient.JXJFoodSmallStation",
ToggleWindowPath = "View.RecipeSettingsView"
});
});*/

RecipeManage.Add(new SubMenumodel()
/*RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "本地配方下发",
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员 },
AssemblyName = "BPASmartClient.JXJFoodSmallStation",
ToggleWindowPath = "View.RecipeControlView"
});
});*/
RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "服务配方管理",
@@ -176,13 +175,13 @@ namespace BPASmartClient.JXJFoodSmallStation
ToggleWindowPath = "Pages.View.PasswordChangeView"
});

UserManager.Add(new SubMenumodel()
/* UserManager.Add(new SubMenumodel()
{
SubMenuName = "NFC登录设置",
SubMenuPermission = new Permission[] { Permission.管理员 },
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.NfcSetView"
});
});*/

MenuManage.GetInstance.menuModels.Add(new MenuModel()
{


+ 1
- 29
BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj Переглянути файл

@@ -16,35 +16,7 @@
<ItemGroup>
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" />
<ProjectReference Include="..\BPASmartClient.Modbus\BPASmartClient.Modbus.csproj" />
<ProjectReference Include="..\BPASmartClient.S7Net\BPASmartClient.S7Net.csproj" />
</ItemGroup>

<!--<ItemGroup>
<Page Update="View\ChangeDeviceNameView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="View\DeviceListView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="View\HardwareStatusView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="View\NewRecipeView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="View\RecipeControlView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="View\RecipeInfosView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="View\RecipeReceiveView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="View\RecipeSettingsView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
</ItemGroup>-->

</Project>

+ 1
- 1
BPASmartClient.JXJFoodSmallStation/Model/DeviceInquire.cs Переглянути файл

@@ -207,7 +207,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
public void StatusReset()
{
this.modbusTcp.Write(DeviceAddress.RunStatus, (ushort)0);
this.modbusTcp.Write(DeviceAddress.RunStatus, (ushort)0);//OutRawMaterialFinish复位出料完成信号
}
public void OutRawMaterialReset()
{


+ 49
- 0
BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs Переглянути файл

@@ -0,0 +1,49 @@
using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodSmallStation.Model
{
public class GVL_SmallStation
{
/// <summary>
/// 配方数据
/// </summary>
public ObservableCollection<RemoteRecipeData> RemoteRecipes = new ObservableCollection<RemoteRecipeData>();
/// <summary>
/// 配方队列
/// </summary>
public ConcurrentQueue<long> RecipeQueue = new ConcurrentQueue<long>();

/// <summary>
/// 往输送带下发配方完成
/// </summary>
public bool IssueRecipeFinish { get; set; } = false;
public bool IsAllow { get; set; } = false;

public bool IsAllowOut { set; get; } = false;
/// <summary>
/// 当前料仓的位置
/// </summary>
public int StockInIsWork { get; set; } = 0;
/// <summary>
/// 单个配方执行完成标志
/// </summary>
public bool RecipeFinish { get; set; } = false;

/// <summary>
/// 记录AGV进站送货的指令顺序
/// </summary>
public int AgvDeliveryPosition { get; set; }= 0;
/// <summary>
/// 记录AGV进站取货的指令顺序
/// </summary>
public int AgvPickUpPosition { get; set; } = 0;
}
}

+ 10
- 11
BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs Переглянути файл

@@ -5,15 +5,14 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.S7Net;

namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
{
public class HKDeviceStatus
{
public ModbusTcp ModBusHK = new ModbusTcp();
public string IpAddress => ModBusHK.IPAdress;
public bool IsConnected => ModBusHK.Connected;

public SiemensHelper HK_PLC_S7 = new SiemensHelper();
public bool IsConnected => HK_PLC_S7.IsConnected;
public void Init()
{
if (IsConnected)
@@ -32,8 +31,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
{
if (IsConnected)
{
ModBusHK.SetUint(HKPlcCommAddress.SingleStockBinLocationToPLC, value);
ModBusHK.Write(HKPlcCommAddress.SingleDosingFinishToPLC, (ushort)1);
HK_PLC_S7.Write(HKPlcCommAddress.SingleStockBinLocationToPLC, value);
HK_PLC_S7.Write(HKPlcCommAddress.SingleDosingFinishToPLC, (ushort)1);
}
}
/// <summary>
@@ -41,21 +40,21 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
/// </summary>
public void AllowDosingSignReset()
{
ModBusHK.Write(HKPlcCommAddress.IsAllowDosing,(ushort)0);
HK_PLC_S7.Write(HKPlcCommAddress.IsAllowDosing,(ushort)0);
}
/// <summary>
/// 复位plc到达某料仓信号
/// </summary>
public void StockStateSignReset()
{
ModBusHK.Write(HKPlcCommAddress.StockState, (ushort)0);
HK_PLC_S7.Write(HKPlcCommAddress.StockState, (ushort)0);
}
/// <summary>
/// 复位一个配方配料完成信号
/// </summary>
public void RecipeDosingFinishReset()
{
ModBusHK.Write(HKPlcCommAddress.RecipeDosingFinish, (ushort)0);
HK_PLC_S7.Write(HKPlcCommAddress.RecipeDosingFinish, (ushort)0);
}
/// <summary>
/// 下发配方数据
@@ -66,8 +65,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
{
if (IsConnected)
{
ModBusHK.SetUint(HKPlcCommAddress.BarrelNumToPLC, BarrelNum);
ModBusHK.Write(HKPlcCommAddress.StockBinLocationToPLC, StockBinLocation);
HK_PLC_S7.Write(HKPlcCommAddress.BarrelNumToPLC, BarrelNum);
HK_PLC_S7.Write(HKPlcCommAddress.StockBinLocationToPLC, StockBinLocation);
}
}
}


+ 47
- 0
BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKPlcCommAddress.cs Переглянути файл

@@ -43,5 +43,52 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC

public static string RecipeDosingFinish { get; set; } = "";
#endregion

#region AGV进出站
/// <summary>
/// Agv送货 进站申请
/// </summary>
public static string DeliveryAGVApply { get; set; } = "";
/// <summary>
/// Agv送货 进站申请
/// </summary>
public static string DeliveryAGVIsApply { get; set; } = "";
/// <summary>
/// Agv送货 进站顶升申请
/// </summary>
public static string DeliveryAGVApplyJack { get; set; } = "";
/// <summary>
/// Agv送货 进站顶升申请
/// </summary>
public static string DeliveryAGVIsApplyJack { get; set; } = "";
/// <summary>
/// Agv送货 送货完成
/// </summary>
public static string DeliveryAGVFinsih { get; set; } = "";
/// <summary>
/// Agv送货 工位上有货架
/// </summary>
public static string StationHaveCargo { get; set; } = "";
/// <summary>
/// Agv送货 进站申请
/// </summary>
public static string PickAGVApply { get; set; } = "";
/// <summary>
/// Agv送货 进站申请
/// </summary>
public static string PickAGVIsApply { get; set; } = "";
/// <summary>
/// Agv送货 取货架完成
/// </summary>
public static string PickCargoAGVFinish { get; set; } = "";
/// <summary>
/// Agv送货 取料完成
/// </summary>
public static string PickAGVFinish { get; set; } = "";
/// <summary>
/// 工位上是否有小车
/// </summary>
public static string StationIsExistCar { get; set; } = "";
#endregion
}
}

+ 156
- 57
BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs Переглянути файл

@@ -15,37 +15,43 @@ using System.Threading.Tasks;
namespace BPASmartClient.JXJFoodSmallStation.Model
{
public class ProcessControl
{
{
private volatile static ProcessControl _Instance;
public static ProcessControl GetInstance => _Instance ?? (_Instance = new ProcessControl());
private ProcessControl() { }

public ObservableCollection<RemoteRecipeData> RemoteRecipes = new ObservableCollection<RemoteRecipeData>();
ConcurrentQueue<long> RecipeQueue = new ConcurrentQueue<long>();
public ObservableCollection<RemoteRecipeRawMaterial> RawMaterials { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>();

public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
public HKDeviceStatus HKDevice = new HKDeviceStatus();
GVL_SmallStation SmallStation = new GVL_SmallStation();
/// <summary>
/// 接收原料数据
/// </summary>
public RecipeRawMaterial RawMaterial;
public void Init()
{
ActionManage.GetInstance.Register(new Action(() =>
{
if (SiemensDevice.IsConnected)
{
var res = SiemensDevice.SiemensTcp.GetString(SiemensCommAddress.RecipeName, (ushort)20);
var res1 = SiemensDevice.SiemensTcp.Read(SiemensCommAddress.RecipeID);
var res2 = SiemensDevice.SiemensTcp.Read(SiemensCommAddress.RawMaterial);
var res = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeName);
var res1 = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeID);
int res2 = SiemensDevice.Siemens_PLC_S7.ReadClass(RawMaterial, 0, 0);
if ((res != null && res is string recipeName) &&
(res1 != null && res1 is uint recipeID) &&
(res2 != null && res2 is ushort[] rawMaterial))
(res2 > 0))
{
RawMaterials.Clear();
RawMaterials.Add(new RemoteRecipeRawMaterial()
for (int i = 0; i < 15; i++)
{
RawMaterialBarrelNum = rawMaterial[0],
RawMaterialLocation = rawMaterial[1],
RawMaterialWeight = rawMaterial[2]
});
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
RawMaterialBarrelNum = RawMaterial.RawMaterialBarrelNum[i],
RawMaterialLocation = RawMaterial.RawMaterialLocation[i],
RawMaterialWeight = RawMaterial.RawMaterialWeight[i]
});
}
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
{
RecipeName = recipeName,
@@ -59,8 +65,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
if (SiemensDevice.IsConnected)
{
var res = SiemensDevice.SiemensTcp.Read(SiemensCommAddress.TrayLocationNum);
var res1 = SiemensDevice.SiemensTcp.Read(SiemensCommAddress.RecipeID);
var res = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.TrayLocationNum);
var res1 = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeID);
if (res != null && res is int TrayLocation && res1 != null && res1 is int recipeId)
{
int index = Array.FindIndex(Json<RemoteRecipeDataColl>.Data.Recipes.ToArray(), p => p.RecipeCode == recipeId);
@@ -72,14 +78,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}), "AGV到位信号", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"];
string HK_PLC_Port = ConfigurationManager.AppSettings["HKPlc_Port"];
string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
string Siemens_PLC_Port = ConfigurationManager.AppSettings["Siemens_Port"];
Task.Run(new Action(() =>
try
{
HKDevice.ModBusHK.ModbusTcpConnect(HK_PLC_IP, int.Parse(HK_PLC_Port));
SiemensDevice.SiemensTcp.ModbusTcpConnect(Siemens_PLC_IP, int.Parse(Siemens_PLC_Port));
if (HKDevice.IsConnected)
//HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S7200Smart, HK_PLC_IP);
//SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
if (HKDevice.IsConnected)
{
HKDevice.Init();
}
@@ -87,85 +91,180 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
SiemensDevice.Init();
}
}));
RecipeQueue.Clear();
RawMaterials = TestData.GetInstance.RawMaterials;//添加测试数据
}
catch(Exception ex)
{
}
SmallStation.RecipeQueue.Clear();
Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
ThreadManage.GetInstance().StartLong(new Action(() =>
{
RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
ReceviceData();
RecipeInfoToHKPLC();
Thread.Sleep(10);
}), "流程处理", true);
ThreadManage.GetInstance().StartLong(new Action(() => {
if (SiemensDevice.IsConnected && HKDevice.IsConnected)
{
AgvGetInDelivery();
AgvGetInPickUp();
}
Thread.Sleep(10);
}), "AGV进站送取货", true);
}
/// <summary>
/// AGV进站送货
/// </summary>
private void AgvGetInDelivery()
{
switch (SmallStation.AgvDeliveryPosition)
{
case 0:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVApply) is bool))
{
SmallStation.AgvDeliveryPosition = 1;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApply, true);
}
break;
case 1:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApply) is bool))
{
SmallStation.AgvDeliveryPosition = 2;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApply, true);
}
break;
case 2:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVApplyJack) is bool))
{
SmallStation.AgvDeliveryPosition = 3;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApplyJack, true);
}
break;
case 3:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApplyJack) is bool))
{
SmallStation.AgvDeliveryPosition = 4;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApplyJack, true);
}
break;
case 4:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVFinsih) is bool))
{
SmallStation.AgvDeliveryPosition = 5;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVFinsih, true);
}
break;
case 5:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationHaveCargo) is bool))
{
SmallStation.AgvDeliveryPosition = 0;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationHaveCargo, true);
}
break;
default:
break;
}
//获取工位上是否有小车
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool)
HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationIsExistCar));
}
/// <summary>
/// AGV进站取货
/// </summary>
private void AgvGetInPickUp()
{
switch (SmallStation.AgvPickUpPosition)
{
case 0:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.PickAGVApply) is bool))
{
SmallStation.AgvPickUpPosition = 1;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.PickAGVApply, true);
}
break;
case 1:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.PickAGVIsApply) is bool))
{
SmallStation.AgvPickUpPosition = 2;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVIsApply, true);
}
break;
case 2:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.PickCargoAGVFinish) is bool))
{
SmallStation.AgvPickUpPosition = 3;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.PickCargoAGVFinish, true);
}
break;
case 3:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.PickAGVFinish) is bool))
{
SmallStation.AgvPickUpPosition = 0;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVFinish, true);
}
break;
default:
break;
}
}

private void ReceviceData()
{
SmallStation.RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
if (Json<RemoteRecipeDataColl>.Data.Recipes.Count > 0)
{
foreach (var data in Json<RemoteRecipeDataColl>.Data.Recipes)
{
if(!(RecipeQueue.Contains(data.RecipeCode)))
RecipeQueue.Enqueue(data.RecipeCode);
if(!(SmallStation.RecipeQueue.Contains(data.RecipeCode)))
SmallStation.RecipeQueue.Enqueue(data.RecipeCode);
}
}
}
/// <summary>
/// 当前料仓的位置
/// </summary>
private int StockInIsWork;
/// <summary>
/// 单个配方执行完成标志
/// </summary>
private bool RecipeFinfish;
private void RecipeInfoToHKPLC()
private void RecipeInfoToHKPLC()
{
if (RecipeQueue.Count > 0)
if (SmallStation.RecipeQueue.Count > 0)
{
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0));
if (index >= 0 && index <= RemoteRecipes.Count)
int index = Array.FindIndex(SmallStation.RemoteRecipes.ToArray(), p => p.RecipeCode == SmallStation.RecipeQueue.ElementAt(0));
if (index >= 0 && index <= SmallStation.RemoteRecipes.Count)
{
long code = RemoteRecipes.ElementAt(index).RecipeCode;
if (RTrig.GetInstance("IsAllowDosing").Start(HKDevice.ModBusHK.Read(HKPlcCommAddress.IsAllowDosing) is bool a))
long code = SmallStation.RemoteRecipes.ElementAt(index).RecipeCode;
if (RTrig.GetInstance("IsAllowDosing").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.IsAllowDosing) is bool a))
{
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
foreach (var item in SmallStation.RemoteRecipes.ElementAt(index).RawMaterial)
{
HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation);
}
HKDevice.AllowDosingSignReset();

SmallStation.IssueRecipeFinish = true;
}
if (RTrig.GetInstance("StockState").Start(HKDevice.ModBusHK.Read(HKPlcCommAddress.StockState) is bool))
if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StockState) is bool) && SmallStation.IssueRecipeFinish)
{
var res = HKDevice.ModBusHK.Read(HKPlcCommAddress.StockBinLocation);
var res = HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StockBinLocation);
if (res != null && res is int 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;
int loc_index = Array.FindIndex(SmallStation.RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
double weight = SmallStation.RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 1 && loc_index <= 15)
{
DeviceInquire.GetInstance.GetDeviceObject(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
StockInIsWork = loc_index;
SmallStation.StockInIsWork = loc_index;
HKDevice.StockStateSignReset();
}
}
}
if (RTrig.GetInstance("OutRawMaterialFinish").Start(DeviceInquire.GetInstance.GetDeviceObject(StockInIsWork).modbusTcp.Read(DeviceAddress.OutRawMaterialFinish) is bool))
if (RTrig.GetInstance("OutRawMaterialFinish").Start(DeviceInquire.GetInstance.GetDeviceObject(SmallStation.StockInIsWork).modbusTcp.Read(DeviceAddress.OutRawMaterialFinish) is bool))
{
HKDevice.SingleDosing((uint)StockInIsWork);
DeviceInquire.GetInstance.GetDeviceObject(StockInIsWork).OutRawMaterialReset();
HKDevice.SingleDosing((uint)SmallStation.StockInIsWork);
DeviceInquire.GetInstance.GetDeviceObject(SmallStation.StockInIsWork).OutRawMaterialReset();
}
if (RTrig.GetInstance("StockState").Start(HKDevice.ModBusHK.Read(HKPlcCommAddress.RecipeDosingFinish) is bool))
if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.RecipeDosingFinish) is bool))
{
HKDevice.RecipeDosingFinishReset();
RecipeQueue.TryDequeue(out code);
SmallStation.RecipeQueue.TryDequeue(out code);
Json<RemoteRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
}
}
}
}
private void HKPLCIsWork()
{
}
}
}

+ 7
- 8
BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs Переглянути файл

@@ -6,28 +6,27 @@ using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodSmallStation.Model
{
public class RemoteRecipeRawMaterial
public class RemoteRecipeRawMaterial
{
private int _mIp;
public int DeviceIp { get { return _mIp; } set { _mIp = value; } }
public int DeviceIp { get { return _mIp; } set { _mIp = value; }}

private int _mRawMaterialBarrelNum;
/// <summary>
/// 原料对应的桶号
/// </summary>
public int RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; } }
private int _mRawMaterialBarrelNum;

private double _mRawMaterialWeight;
/// <summary>
/// 需要原料重量
/// </summary>
public double RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value;} }
public double RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; } }
private double _mRawMaterialWeight;

private int _mRawMaterialLocation;
/// <summary>
/// 原料对应料仓的位置
/// </summary>
public int RawMaterialLocation { get { return _mRawMaterialLocation; } set { _mRawMaterialLocation = value;} }
public int RawMaterialLocation { get { return _mRawMaterialLocation; } set { _mRawMaterialLocation = value; } }
private int _mRawMaterialLocation;
}
}

+ 72
- 5
BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensCommAddress.cs Переглянути файл

@@ -28,17 +28,84 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
#endregion

#region AGV到位(与西门子PLC交互)西门子PLC ==> 上位机
/// <summary>
/// 托盘的位置编号
/// </summary>
public static string TrayLocationNum { get; set; } = "";
/// <summary>
/// 配方ID
/// </summary>
public static string TrayRecipeID { get; set; } = "";
public static string TrayState { get; set; } = "";
/// <summary>
/// 状态信号
/// </summary>
public static string StateSign { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 从西门子读取
/// </summary>
public static string DeliveryAGVApply { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 写给西门子
/// </summary>
public static string DeliveryAGVIsApply { get; set; } = "";
/// <summary>
/// Agv送货 进站顶升申请 从西门子读取
/// </summary>
public static string DeliveryAGVApplyJack { get; set; } = "";
/// <summary>
/// Agv送货 进站顶升申请 写给西门子
/// </summary>
public static string DeliveryAGVIsApplyJack { get; set; } = "";
/// <summary>
/// Agv送货 送货完成 从西门子读取
/// </summary>
public static string DeliveryAGVFinsih { get; set; } = "";
/// <summary>
/// Agv送货 工位上有货架 写给西门子
/// </summary>
public static string StationHaveCargo { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 从西门子读取
/// </summary>
public static string PickAGVApply { get; set; } = "";
/// <summary>
/// Agv送货 进站申请 写给西门子
/// </summary>
public static string PickAGVIsApply { get; set; } = "";
/// <summary>
/// Agv送货 取货架完成 从西门子读取
/// </summary>
public static string PickCargoAGVFinish { get; set; } = "";
/// <summary>
/// Agv送货 取料完成 写给西门子
/// </summary>
public static string PickAGVFinish { get; set; } = "";
/// <summary>
/// 工位上是否有小车
/// </summary>
public static string StationIsExistCar { get; set; } = "";
#endregion

#region Tray配料完成(与西门子PLC交互)上位机 ==> 西门子PLC
public static string TrayLocationNumToPLC { get; set; } = "";
public static string TrayRecipeIDToPLC { get; set; } = "";
public static string TrayStateToPLC { get; set; } = "";
public static string TrayLocationNumToSiemens { get; set; } = "";
public static string TrayRecipeIDToSiemens { get; set; } = "";
public static string TrayStateToSiemens { get; set; } = "";
#endregion
}

public class RecipeRawMaterial
{
/// <summary>
/// 原料对应的桶号
/// </summary>
public int[] RawMaterialBarrelNum = new int[15];
/// <summary>
/// 需要原料重量
/// </summary>
public double[] RawMaterialWeight = new double[15];
/// <summary>
/// 原料对应料仓的位置
/// </summary>
public int[] RawMaterialLocation = new int[15];
}

}

+ 10
- 10
BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs Переглянути файл

@@ -5,28 +5,28 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.S7Net;

namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
{
public class SiemensDeviceStatus
{
public ModbusTcp SiemensTcp = new ModbusTcp();
public bool IsConnected => SiemensTcp.Connected;
public string IpAddress => SiemensTcp.IPAdress;
public SiemensHelper Siemens_PLC_S7 = new SiemensHelper();
public bool IsConnected => Siemens_PLC_S7.IsConnected;

/// <summary>
/// 配方接收信号复位
/// </summary>
public void RecipeSignReset()
{
this.SiemensTcp.Write(SiemensCommAddress.RecipeState, (ushort)0);
this.Siemens_PLC_S7.Write(SiemensCommAddress.RecipeState, (ushort)0);
}
/// <summary>
/// AGV到位信号复位
/// </summary>
public void AgvSignReset()
{
this.SiemensTcp.Write(SiemensCommAddress.TrayState, (ushort)0);
this.Siemens_PLC_S7.Write(SiemensCommAddress.StateSign, (ushort)0);
}
public void Init()
{
@@ -34,13 +34,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
var res = this.SiemensTcp.Read(SiemensCommAddress.RecipeState);
var res = this.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeState);
if (res != null && RTrig.GetInstance("RecipeTrig").Start(res is bool SignTrig))
{
ActionManage.GetInstance.Send("西门子下发配方");
RecipeSignReset();
}
var AgvState = this.SiemensTcp.Read(SiemensCommAddress.TrayState);
var AgvState = this.Siemens_PLC_S7.Read(SiemensCommAddress.StateSign);
if (AgvState != null && RTrig.GetInstance("AgvTrig").Start(res is bool AgvSignTrig))
{
ActionManage.GetInstance.Send("AGV到位信号");
@@ -56,9 +56,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
/// <param name="recipeID"></param>
private void DosingFinsih(int TrayLocation,int recipeID)
{
this.SiemensTcp.Write(SiemensCommAddress.TrayLocationNumToPLC, TrayLocation);
this.SiemensTcp.Write(SiemensCommAddress.TrayStateToPLC, 1);
this.SiemensTcp.Write(SiemensCommAddress.TrayRecipeIDToPLC, recipeID);
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayLocationNumToSiemens, TrayLocation);
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayStateToSiemens, 1);
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayRecipeIDToSiemens, recipeID);
}
}
}

+ 3
- 2
BPASmartClient.JXJFoodSmallStation/Model/TestData.cs Переглянути файл

@@ -13,6 +13,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
public volatile static TestData Instance;
public static TestData GetInstance => Instance ?? (Instance = new TestData());
public ObservableCollection<RemoteRecipeData> Recipes { get; set; } = new ObservableCollection<RemoteRecipeData>();
public ObservableCollection<RemoteRecipeRawMaterial> RawMaterials { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>();
public TestData()
{
@@ -53,7 +54,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
RawMaterialLocation = RawMaterialLocation2
});

Json<RemoteRecipeDataColl>.Data.Recipes.Add(new Model.RemoteRecipeData()
Recipes.Add(new Model.RemoteRecipeData()
{
RecipeName = recipeName,
RecipeCode = recipeCode,
@@ -99,7 +100,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
RawMaterialLocation = RawMaterialLocation2_2
});

Json<RemoteRecipeDataColl>.Data.Recipes.Add(new Model.RemoteRecipeData()
Recipes.Add(new Model.RemoteRecipeData()
{
RecipeName = recipeName_2,
RecipeCode = recipeCode_2,


+ 36
- 54
BPASmartClient.JXJFoodSmallStation/View/RecipeInfosView.xaml Переглянути файл

@@ -28,7 +28,7 @@

<ResourceDictionary>
<!--#region ListBox样式-->
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">
<!--<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="BorderBrush" Value="{x:Null}" />
@@ -45,7 +45,7 @@
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Style>-->
<!--#endregion-->
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
@@ -58,14 +58,13 @@
</Border.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="5" />
<RowDefinition />
</Grid.RowDefinitions>

<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
@@ -77,8 +76,11 @@
<TextBlock Margin="10,0,0,0" Background="Transparent" FontSize="20" Foreground="#FF2AB2E7" Text="配方编号:" />
<TextBlock Grid.Row="1" Margin="10,0,0,0" Background="Transparent" FontSize="20" Foreground="#FF2AB2E7" Text="{Binding RecipeCode}" />
</WrapPanel>

<Grid Grid.Row="2">
<WrapPanel Grid.Row="2">
<TextBlock Margin="10,0,0,0" Background="Transparent" FontSize="20" Foreground="#FF2AB2E7" Text="托盘编号:" />
<TextBlock Grid.Row="1" Margin="10,0,0,0" Background="Transparent" FontSize="20" Foreground="#FF2AB2E7" Text="{Binding TrayCode}" />
</WrapPanel>
<Grid Grid.Row="3">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
@@ -86,10 +88,10 @@
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="9*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" HorizontalAlignment="Center">小料</TextBlock>
<TextBlock Grid.Row="0" HorizontalAlignment="Center">小料</TextBlock>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="1*"></RowDefinition>
<RowDefinition Height="20"></RowDefinition>
<RowDefinition Height="9*"></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0" >
@@ -102,52 +104,32 @@
<TextBlock FontSize="16" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Top">原料位置</TextBlock>
<TextBlock FontSize="16" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Top">原料重量</TextBlock>
</Grid>
<!--<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<Grid>
<ItemsControl ItemsSource="{Binding RawMaterials}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid x:Name="gr" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding RawMaterialBarrelNum}"></TextBlock>
<TextBlock Grid.Column="1" Text="{Binding RawmaterialLocation}"></TextBlock>
<TextBlock Grid.Column="2" Text="{Binding RawMaterialWeight}"></TextBlock>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

</Grid>
</ScrollViewer>-->

<ItemsControl ItemsSource="{Binding RawMaterials}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid x:Name="gr" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding RawMaterialBarrelNum}"></TextBlock>
<TextBlock Grid.Column="1" Text="{Binding RawMaterialLocation}"></TextBlock>
<TextBlock Grid.Column="2" Text="{Binding RawMaterialWeight}"></TextBlock>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Auto" >
<ItemsControl ItemsSource="{Binding RawMaterialsInfo}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid x:Name="grb" Height="25" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="20" Foreground="#FF2AB2E7" Text="{Binding RawMaterialBarrelNum}"></TextBlock>
<TextBlock Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="20" Foreground="#FF2AB2E7" Text="{Binding RawMaterialLocation}"></TextBlock>
<TextBlock Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="20" Foreground="#FF2AB2E7" Text="{Binding RawMaterialWeight}"></TextBlock>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="grb" Property="Background" Value="#112AB2E7" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Grid>
<Grid Grid.Row="3">
<Grid Grid.Row="4">
<Button Command="{Binding ReturnPage}" Width="200" >返回</Button>
</Grid>
</Grid>


+ 15
- 3
BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs Переглянути файл

@@ -22,10 +22,18 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
RecipeName = rm.RecipeName;
RecipeCode = rm.RecipeCode;
RawMaterials = rm.RawMaterial;
TrayCode = rm.TrayCode;
//RawMaterialsInfo = rm.RawMaterial;
//var rest = RawMaterialsInfo.GetHashCode();

foreach (var item in rm.RawMaterial)
{
RawMaterialsInfo.Add(item);
}
}
}), "RecipeInfo");
ReturnPage = new RelayCommand(() =>

ReturnPage = new RelayCommand(() =>
{
ActionManage.GetInstance.Send("CloseRecipeInfosView");
});
@@ -37,7 +45,11 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } }
private long _mRecipeCode;

public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } }
private int _mTrayCode;

public RelayCommand ReturnPage { get; set; }
public ObservableCollection<RemoteRecipeRawMaterial> RawMaterials { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>();

public ObservableCollection<RemoteRecipeRawMaterial> RawMaterialsInfo { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>();
}
}

+ 41
- 1
BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs Переглянути файл

@@ -23,6 +23,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
public class RecipeReceiveViewModel : ObservableObject
{
ObservableCollection<RemoteRecipeRawMaterial> RawMaterials { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>();
public RecipeReceiveViewModel()
{
//Json<LocaPar>.Read();
@@ -35,14 +36,53 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
RecipeInfosView nrv = new RecipeInfosView();
var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == num);
ActionManage.GetInstance.Send("RecipeInfo", res);
nrv.ShowDialog();
nrv.Show();
MessageLog.GetInstance.ShowUserLog($"查看配方——{res.RecipeName}");
}
});
NewSimulateRecipe = new RelayCommand(() =>
{
RawMaterials.Clear();
string recipeName = "配方" + (Json<RemoteRecipeDataColl>.Data.Recipes.Count + 1) + "";
go:
long recipeCode = new Random().Next(1000, 9999);
foreach (var item in Recipes)
{
if (item.RecipeCode == recipeCode)
{
goto go;
}
}
int trayCode = new Random().Next(1, 3);
for (int i = 1; i < 16; i++)
{
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
RawMaterialWeight = new Random().Next(10, 1000),
RawMaterialBarrelNum = new Random().Next(1, 3),
RawMaterialLocation = i,
});
}
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
{
RecipeName = recipeName,
RecipeCode = recipeCode,
TrayCode = trayCode,
RawMaterial = RawMaterials,
});

});
ClearAllRecipe = new RelayCommand(() =>
{
Json<RemoteRecipeDataColl>.Data.Recipes.Clear();
});
}

public RelayCommand<object> DetailsCommand { get; set; }

public RelayCommand NewSimulateRecipe { get; set; }
public RelayCommand ClearAllRecipe { get; set; }

public ObservableCollection<RemoteRecipeData> Recipes { get; set; }
}
}

+ 3
- 4
SmartClient.sln Переглянути файл

@@ -121,17 +121,16 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.KHKJ", "BPASmartClient.KHKJ\BPASmartClient.KHKJ.csproj", "{C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkTM", "BPASmartClient.MorkTM\BPASmartClient.MorkTM.csproj", "{1612F583-D328-45C6-8BB1-5D41B8F1D216}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.KHKJ", "BPASmartClient.KHKJ\BPASmartClient.KHKJ.csproj", "{C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.Nfc", "BPASmartClient.Nfc\BPASmartClient.Nfc.csproj", "{42D35B7C-764C-4692-AA85-9B343A0F5B7F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.Argox", "BPASmartClient.Argox\BPASmartClient.Argox.csproj", "{B8D499BA-A18A-4FD6-B036-44F02B4D164B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.S7Net", "BPASmartClient.S7Net\BPASmartClient.S7Net.csproj", "{D1F2379E-1755-4B50-9D67-15C960C33FFA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.S7Net", "BPASmartClient.S7Net\BPASmartClient.S7Net.csproj", "{D1F2379E-1755-4B50-9D67-15C960C33FFA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.JXJFoodBigStation", "BPASmartClient.JXJFoodBigStation\BPASmartClient.JXJFoodBigStation.csproj", "{FA695D7E-6F12-4483-A16D-8494609FAE68}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.JXJFoodBigStation", "BPASmartClient.JXJFoodBigStation\BPASmartClient.JXJFoodBigStation.csproj", "{FA695D7E-6F12-4483-A16D-8494609FAE68}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.JXJFoodSmallStation", "BPASmartClient.JXJFoodSmallStation\BPASmartClient.JXJFoodSmallStation.csproj", "{D609C4CF-FA5C-4D39-B12F-07A60FFE5E40}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.JXJFoodSmallStation", "BPASmartClient.JXJFoodSmallStation\BPASmartClient.JXJFoodSmallStation.csproj", "{D609C4CF-FA5C-4D39-B12F-07A60FFE5E40}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution


Завантаження…
Відмінити
Зберегти