@@ -39,7 +39,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||||
/// 订单请求 | /// 订单请求 | ||||
/// </summary> | /// </summary> | ||||
public static bool Order_Request { get; set; } = false; | public static bool Order_Request { get; set; } = false; | ||||
public static int SiemensSendRecipeStatus { get; set; } = 0; | |||||
public const int StockBinNum = 12; | |||||
public const int Max_DosingSotckBinNum = 14; | |||||
} | } | ||||
} | } |
@@ -49,12 +49,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||||
ActionManage.GetInstance.Register(new Action<object>((res) => | ActionManage.GetInstance.Register(new Action<object>((res) => | ||||
{ | { | ||||
ObservableCollection<RawMaterial> RawMaterials = new ObservableCollection<RawMaterial>(); | ObservableCollection<RawMaterial> RawMaterials = new ObservableCollection<RawMaterial>(); | ||||
if (SiemensDevice.IsConnected ||true) | |||||
if (SiemensDevice.IsConnected) | |||||
{ | { | ||||
if (res != null && res is DL_Start_DB recipe) | if (res != null && res is DL_Start_DB recipe) | ||||
{ | { | ||||
RawMaterials.Clear(); | RawMaterials.Clear(); | ||||
for (int i = 0; i < 12; i++) | |||||
for (int i = 0; i < GVL_BigStation.Max_DosingSotckBinNum; i++) | |||||
{ | { | ||||
if (RawMaterialsNamePos.ContainsKey(recipe.Material[i].Material_Name)) | if (RawMaterialsNamePos.ContainsKey(recipe.Material[i].Material_Name)) | ||||
{ | { | ||||
@@ -71,12 +71,15 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||||
//报警,配方的原料名称下发和设备不一致 | //报警,配方的原料名称下发和设备不一致 | ||||
} | } | ||||
} | } | ||||
Json<RemoteRecipe>.Data.Recipes.Add(new RecipeData() | |||||
App.Current.Dispatcher.Invoke(() => | |||||
{ | { | ||||
RecipeName = recipe.RecipeName, | |||||
RecipeCode = recipe.RecipeCode, | |||||
RawMaterial = RawMaterials, | |||||
//TrayCode = recipe.Order_No, | |||||
Json<RemoteRecipe>.Data.Recipes.Add(new RecipeData() | |||||
{ | |||||
RecipeName = recipe.RecipeName, | |||||
RecipeCode = recipe.RecipeCode, | |||||
RawMaterial = RawMaterials, | |||||
TrayCode = recipe.Job_No, | |||||
}); | |||||
}); | }); | ||||
} | } | ||||
} | } | ||||
@@ -86,7 +89,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||||
try | try | ||||
{ | { | ||||
//HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); | //HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); | ||||
//SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); | |||||
SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); | |||||
if (HKDevice.IsConnected) | if (HKDevice.IsConnected) | ||||
{ | { | ||||
HKDevice.Init(); | HKDevice.Init(); | ||||
@@ -132,25 +135,134 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||||
{ | { | ||||
foreach (var data in Recipes) | foreach (var data in Recipes) | ||||
{ | { | ||||
if (RecipeQueue1.Count == 0 && !RecipeQueue2.Contains(data.RecipeCode) && !RecipeQueue3.Contains(data.RecipeCode) && !RecipeQueue4.Contains(data.RecipeCode)) | |||||
if (RecipeQueue1.Count == 0 && !RecipeQueue2.Contains(data.RecipeCode) && !RecipeQueue3.Contains(data.RecipeCode) && !RecipeQueue4.Contains(data.RecipeCode)) | |||||
{ | { | ||||
if (!(RecipeQueue1.Contains(data.RecipeCode))) | if (!(RecipeQueue1.Contains(data.RecipeCode))) | ||||
RecipeQueue1.Enqueue(data.RecipeCode); | |||||
{ | |||||
if (SiemensDevice.DL_Status is DL_Status_DB status) | |||||
{ | |||||
if (GVL_BigStation.SiemensSendRecipeStatus == 3) | |||||
{ | |||||
GVL_BigStation.SiemensSendRecipeStatus = 4; | |||||
SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); | |||||
SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); | |||||
} | |||||
if (GVL_BigStation.SiemensSendRecipeStatus == 4) | |||||
{ | |||||
if (SiemensDevice.DL_Status.Dosing_Start_ACK) | |||||
{ | |||||
GVL_BigStation.SiemensSendRecipeStatus = 5; | |||||
SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); | |||||
SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false); | |||||
} | |||||
} | |||||
if (GVL_BigStation.SiemensSendRecipeStatus == 5) | |||||
{ | |||||
if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) | |||||
{ | |||||
GVL_BigStation.SiemensSendRecipeStatus = 6; | |||||
RecipeQueue1.Enqueue(data.RecipeCode); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
else if (RecipeQueue2.Count == 0 && !RecipeQueue1.Contains(data.RecipeCode) && !RecipeQueue3.Contains(data.RecipeCode) && !RecipeQueue4.Contains(data.RecipeCode)) | |||||
else if (RecipeQueue2.Count == 0 && !RecipeQueue1.Contains(data.RecipeCode) && !RecipeQueue3.Contains(data.RecipeCode) && !RecipeQueue4.Contains(data.RecipeCode)) | |||||
{ | { | ||||
if (!(RecipeQueue2.Contains(data.RecipeCode))) | if (!(RecipeQueue2.Contains(data.RecipeCode))) | ||||
RecipeQueue2.Enqueue(data.RecipeCode); | |||||
{ | |||||
if (SiemensDevice.DL_Status is DL_Status_DB status) | |||||
{ | |||||
if (GVL_BigStation.SiemensSendRecipeStatus == 3) | |||||
{ | |||||
GVL_BigStation.SiemensSendRecipeStatus = 4; | |||||
SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); | |||||
SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); | |||||
} | |||||
if (GVL_BigStation.SiemensSendRecipeStatus == 4) | |||||
{ | |||||
if (SiemensDevice.DL_Status.Dosing_Start_ACK) | |||||
{ | |||||
GVL_BigStation.SiemensSendRecipeStatus = 5; | |||||
SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); | |||||
SiemensDevice.Siemens_PLC_S7.Write("DB3231.DBX28.0", false); | |||||
} | |||||
} | |||||
if (GVL_BigStation.SiemensSendRecipeStatus == 5) | |||||
{ | |||||
if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) | |||||
{ | |||||
GVL_BigStation.SiemensSendRecipeStatus = 6; | |||||
RecipeQueue2.Enqueue(data.RecipeCode); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
else if (RecipeQueue3.Count == 0 && !RecipeQueue1.Contains(data.RecipeCode) && !RecipeQueue2.Contains(data.RecipeCode) && !RecipeQueue4.Contains(data.RecipeCode)) | else if (RecipeQueue3.Count == 0 && !RecipeQueue1.Contains(data.RecipeCode) && !RecipeQueue2.Contains(data.RecipeCode) && !RecipeQueue4.Contains(data.RecipeCode)) | ||||
{ | { | ||||
if (!(RecipeQueue3.Contains(data.RecipeCode))) | |||||
RecipeQueue3.Enqueue(data.RecipeCode); | |||||
if (!(RecipeQueue3.Contains(data.RecipeCode))) | |||||
{ | |||||
if (SiemensDevice.DL_Status is DL_Status_DB status) | |||||
{ | |||||
if (GVL_BigStation.SiemensSendRecipeStatus == 3) | |||||
{ | |||||
GVL_BigStation.SiemensSendRecipeStatus = 4; | |||||
SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); | |||||
SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); | |||||
} | |||||
if (GVL_BigStation.SiemensSendRecipeStatus == 4) | |||||
{ | |||||
if (SiemensDevice.DL_Status.Dosing_Start_ACK) | |||||
{ | |||||
GVL_BigStation.SiemensSendRecipeStatus = 5; | |||||
SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); | |||||
SiemensDevice.Siemens_PLC_S7.Write("DB3231.DBX28.0", false); | |||||
} | |||||
} | |||||
if (GVL_BigStation.SiemensSendRecipeStatus == 5) | |||||
{ | |||||
if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) | |||||
{ | |||||
GVL_BigStation.SiemensSendRecipeStatus = 6; | |||||
RecipeQueue3.Enqueue(data.RecipeCode); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
else if (RecipeQueue4.Count == 0 && !RecipeQueue1.Contains(data.RecipeCode) && !RecipeQueue2.Contains(data.RecipeCode) && !RecipeQueue3.Contains(data.RecipeCode)) | else if (RecipeQueue4.Count == 0 && !RecipeQueue1.Contains(data.RecipeCode) && !RecipeQueue2.Contains(data.RecipeCode) && !RecipeQueue3.Contains(data.RecipeCode)) | ||||
{ | { | ||||
if (!(RecipeQueue4.Contains(data.RecipeCode))) | |||||
RecipeQueue4.Enqueue(data.RecipeCode); | |||||
if (!(RecipeQueue4.Contains(data.RecipeCode))) | |||||
{ | |||||
if (SiemensDevice.DL_Status is DL_Status_DB status) | |||||
{ | |||||
if (GVL_BigStation.SiemensSendRecipeStatus == 3) | |||||
{ | |||||
GVL_BigStation.SiemensSendRecipeStatus = 4; | |||||
SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); | |||||
SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); | |||||
} | |||||
if (GVL_BigStation.SiemensSendRecipeStatus == 4) | |||||
{ | |||||
if (SiemensDevice.DL_Status.Dosing_Start_ACK) | |||||
{ | |||||
GVL_BigStation.SiemensSendRecipeStatus = 5; | |||||
SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); | |||||
SiemensDevice.Siemens_PLC_S7.Write("DB3231.DBX28.0", false); | |||||
} | |||||
} | |||||
if (GVL_BigStation.SiemensSendRecipeStatus == 5) | |||||
{ | |||||
if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) | |||||
{ | |||||
GVL_BigStation.SiemensSendRecipeStatus = 6; | |||||
RecipeQueue4.Enqueue(data.RecipeCode); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -266,6 +378,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||||
} | } | ||||
if (SiemensDevice.IsConnected) | if (SiemensDevice.IsConnected) | ||||
{ | { | ||||
FinishData.Ask_For_Finish = true; | |||||
GVL_BigStation.SiemensSendRecipeStatus = 7; | |||||
SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 2361); | SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 2361); | ||||
} | } | ||||
RecipeQueue1.TryDequeue(out code); | RecipeQueue1.TryDequeue(out code); | ||||
@@ -705,6 +819,22 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||||
RawMaterialsNamePos.Clear(); | RawMaterialsNamePos.Clear(); | ||||
if (!HKDevice.IsConnected) | if (!HKDevice.IsConnected) | ||||
{ | { | ||||
RawMaterialsNamePos.Add("A10", 1); | |||||
RawMaterialsNamePos.Add("A20", 2); | |||||
RawMaterialsNamePos.Add("A30", 3); | |||||
RawMaterialsNamePos.Add("A40", 4); | |||||
RawMaterialsNamePos.Add("A50", 5); | |||||
RawMaterialsNamePos.Add("A60", 6); | |||||
RawMaterialsNamePos.Add("A70", 7); | |||||
RawMaterialsNamePos.Add("A80", 8); | |||||
RawMaterialsNamePos.Add("A90", 9); | |||||
RawMaterialsNamePos.Add("A100", 10); | |||||
RawMaterialsNamePos.Add("A110", 11); | |||||
RawMaterialsNamePos.Add("A120", 12); | |||||
RawMaterialsNamePos.Add("A130", 13); | |||||
RawMaterialsNamePos.Add("A140", 14); | |||||
} | |||||
/* | |||||
HKDevice.StockBinName.RawMaterialName1 = "1"; | HKDevice.StockBinName.RawMaterialName1 = "1"; | ||||
HKDevice.StockBinName.RawMaterialName2 = "2"; | HKDevice.StockBinName.RawMaterialName2 = "2"; | ||||
HKDevice.StockBinName.RawMaterialName3 = "3"; | HKDevice.StockBinName.RawMaterialName3 = "3"; | ||||
@@ -775,7 +905,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||||
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName14)) | if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName14)) | ||||
{ | { | ||||
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName14, 14); | RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName14, 14); | ||||
} | |||||
}*/ | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -7,12 +7,12 @@ using System.Threading.Tasks; | |||||
namespace BPASmartClient.JXJFoodBigStation.Model.Siemens | namespace BPASmartClient.JXJFoodBigStation.Model.Siemens | ||||
{ | { | ||||
internal class DL_Status_DB | |||||
public class DL_Status_DB | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 配料开始 | |||||
/// 配料开始确认 | |||||
/// </summary> | /// </summary> | ||||
public bool Dosing_Start { get; set; } | |||||
public bool Dosing_Start_ACK { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 配料开始确认 | /// 配料开始确认 | ||||
/// </summary> | /// </summary> | ||||
@@ -29,18 +29,21 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens | |||||
/// 生产工单 | /// 生产工单 | ||||
/// </summary> | /// </summary> | ||||
public string RecipeCode { get; set; } | public string RecipeCode { get; set; } | ||||
public bool Dosing_Cancel4 { get; set; } | |||||
/// <summary> | |||||
/// 配料开始 | |||||
/// </summary> | |||||
public bool Dosing_Start { get; set; } | |||||
public bool Dosing_Cancel5 { get; set; } | |||||
public bool Allow_Agv_Put { get; set; } | |||||
public bool Dosing_Cancel6 { get; set; } | |||||
public bool Allow_Agv_Get { get; set; } | |||||
public bool Dosing_Cancel7 { get; set; } | |||||
public bool Allow_Agv_Get_Empty { get; set; } | |||||
public short Dosing_Cancel8 { get; set; } | |||||
public short Pallet_Position_Occ { get; set; } | |||||
public short Dosing_Cancel9 { get; set; } | public short Dosing_Cancel9 { get; set; } | ||||
public short[] Standby2 { get; set; } = new short[4]; | |||||
public short[] Standby2 { get; set; } = new short[3]; | |||||
} | } | ||||
} | } |
@@ -15,6 +15,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens | |||||
public SiemensHelper Siemens_PLC_S7 = new SiemensHelper(); | public SiemensHelper Siemens_PLC_S7 = new SiemensHelper(); | ||||
public bool IsConnected => Siemens_PLC_S7.IsConnected; | public bool IsConnected => Siemens_PLC_S7.IsConnected; | ||||
public DL_Status_DB DL_Status = new DL_Status_DB(); | |||||
bool a = false; | bool a = false; | ||||
public void Init() | public void Init() | ||||
{ | { | ||||
@@ -34,7 +35,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens | |||||
start.RecipeCode = "1201"; | start.RecipeCode = "1201"; | ||||
start.Order_Request_Ack = true; | start.Order_Request_Ack = true; | ||||
for (int i = 0; i < GVL_BigStation.StockBinNum ; i++) | |||||
for (int i = 0; i < GVL_BigStation.Max_DosingSotckBinNum ; i++) | |||||
{ | { | ||||
start.Material[i] = new UDT(); | start.Material[i] = new UDT(); | ||||
start.Material[i].Material_Name = "" + (i +1); | start.Material[i].Material_Name = "" + (i +1); | ||||
@@ -42,25 +43,43 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens | |||||
start.Material[i].Material_BarrelNum = (short)(i + 1); | start.Material[i].Material_BarrelNum = (short)(i + 1); | ||||
} | } | ||||
} | } | ||||
if (RTrig.GetInstance("Order_Request").Start(GVL_BigStation.Order_Request)) | |||||
if (RTrig.GetInstance("Order_Request").Start(GVL_BigStation.Order_Request) && GVL_BigStation.SiemensSendRecipeStatus == 0) | |||||
{ | { | ||||
start.Order_Request = true; | |||||
Siemens_PLC_S7.WriteClass<DL_Start_DB>(start, 2301); | |||||
GVL_BigStation.SiemensSendRecipeStatus = 1; | |||||
this.Siemens_PLC_S7.Write("DB2301.DBX330.0", true); | |||||
} | } | ||||
if (RTrig.GetInstance("Order_Request_Ack").Start(start.Order_Request_Ack)) | |||||
if (RTrig.GetInstance("Order_Request_Ack").Start(start.Order_Request_Ack) && GVL_BigStation.SiemensSendRecipeStatus == 1) | |||||
{ | { | ||||
GVL_BigStation.SiemensSendRecipeStatus = 2; | |||||
ActionManage.GetInstance.Send("SiemensSendRecipe", start); | ActionManage.GetInstance.Send("SiemensSendRecipe", start); | ||||
this.Siemens_PLC_S7.Write("DB2301.DBX330.0", false); | |||||
} | |||||
if (TTrig.GetInstance("Order_Request_Ack").Start(start.Order_Request_Ack) && GVL_BigStation.SiemensSendRecipeStatus == 2) | |||||
{ | |||||
GVL_BigStation.SiemensSendRecipeStatus = 3; | |||||
GVL_BigStation.Order_Request = false; | |||||
} | } | ||||
} | } | ||||
if (res1 != null && res1 is DL_Status_DB status) | if (res1 != null && res1 is DL_Status_DB status) | ||||
{ | { | ||||
DL_Status = status; | |||||
} | } | ||||
if (res2 != null && res2.Ask_For_Finish_PLC) | |||||
if (res2 != null && res2 is DL_Finish_DB finish) | |||||
{ | { | ||||
ActionManage.GetInstance.Send("配料完成信号确认完成"); | |||||
res2.Ask_For_Finish_PLC = false; | |||||
this.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(res2, 3); | |||||
if (RTrig.GetInstance("Ask_For_Finish_PLC").Start(finish.Ask_For_Finish_PLC) && GVL_BigStation.SiemensSendRecipeStatus == 7) | |||||
{ | |||||
finish.Order_No = ""; | |||||
finish.Product_Code = ""; | |||||
finish.job_No = 0; | |||||
for (int i = 0; i < 20; i++) | |||||
{ | |||||
finish.Material[i] = new UDT1(); | |||||
} | |||||
GVL_BigStation.SiemensSendRecipeStatus = 0; | |||||
finish.Ask_For_Finish = false; | |||||
finish.ProcessTime = 0; | |||||
this.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(finish, 2261); | |||||
} | |||||
} | } | ||||
Thread.Sleep(10); | Thread.Sleep(10); | ||||
}), "监听服务数据"); | }), "监听服务数据"); | ||||
@@ -48,6 +48,7 @@ namespace BPASmartClient.JXJFoodSmallStation | |||||
base.OnExit(e); | base.OnExit(e); | ||||
Json<LocaPar>.Save(); | Json<LocaPar>.Save(); | ||||
Json<LocalRecipeDataColl>.Save(); | Json<LocalRecipeDataColl>.Save(); | ||||
Json<RemoteRecipeDataColl>.Save(); | |||||
MessageNotify.GetInstance.LogSave(); | MessageNotify.GetInstance.LogSave(); | ||||
ThreadManage.GetInstance().Dispose(); | ThreadManage.GetInstance().Dispose(); | ||||
} | } | ||||
@@ -268,6 +269,7 @@ namespace BPASmartClient.JXJFoodSmallStation | |||||
Json<DevicePar>.Read(); | Json<DevicePar>.Read(); | ||||
Json<WindSendDevicePar>.Read(); | Json<WindSendDevicePar>.Read(); | ||||
Json<LocalRecipeDataColl>.Read(); | Json<LocalRecipeDataColl>.Read(); | ||||
Json<RemoteRecipeDataColl>.Read(); | |||||
} | } | ||||
} | } | ||||
@@ -23,14 +23,17 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||||
/// <summary> | /// <summary> | ||||
/// 风送料仓数目 | /// 风送料仓数目 | ||||
/// </summary> | /// </summary> | ||||
public const int Max_PowderSotckBinNum = 15; | |||||
public const int Max_PowderSotckBinNum = 5; | |||||
public bool HeartBeatToPlc { get; set; } = false; | public bool HeartBeatToPlc { get; set; } = false; | ||||
public bool HeartBeatFromPlc { get; set; } = false; | public bool HeartBeatFromPlc { get; set; } = false; | ||||
/// <summary> | /// <summary> | ||||
/// 是否允许西门子下发配方 | /// 是否允许西门子下发配方 | ||||
/// </summary> | /// </summary> | ||||
public static bool IsAllowSiemensSendRecipe { get; set; } = false; | public static bool IsAllowSiemensSendRecipe { get; set; } = false; | ||||
/// <summary> | |||||
/// 西门子下发配方状态 0:等待下发配方 1:请求下发配方 2:上位机接收配方 3:配方接收完成 4:请求配料 5:西门子开始配料确认 6:配方配料完成 7:配料完成确认 | |||||
/// </summary> | |||||
public static int SiemensSendRecipeStatus { get; set; } = 0; | |||||
/// <summary> | /// <summary> | ||||
/// 往输送带下发配方完成 | /// 往输送带下发配方完成 | ||||
/// </summary> | /// </summary> | ||||
@@ -114,6 +117,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||||
/// 是否使用本地模拟订单+风送配方 | /// 是否使用本地模拟订单+风送配方 | ||||
/// </summary> | /// </summary> | ||||
public bool IsUseWindSendDosing { get; set; } | public bool IsUseWindSendDosing { get; set; } | ||||
public static int test1 = 1; | |||||
#endregion | #endregion | ||||
} | } | ||||
} | } |
@@ -50,6 +50,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||||
public RecipeRawMaterial RawMaterial; | public RecipeRawMaterial RawMaterial; | ||||
public void Init() | public void Init() | ||||
{ | { | ||||
testData(); | |||||
for (int i = 0; i < 16; i++) | for (int i = 0; i < 16; i++) | ||||
{ | { | ||||
if (DeviceInquire.GetInstance.GetDevice(i).DeviceName != null) | if (DeviceInquire.GetInstance.GetDevice(i).DeviceName != null) | ||||
@@ -69,57 +70,91 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||||
{ | { | ||||
if (res != null && res is XL_Start_DB recipe) | if (res != null && res is XL_Start_DB recipe) | ||||
{ | { | ||||
RawMaterials.Clear(); | |||||
for (int i = 0; i < GVL_SmallStation.Max_DosingSotckBinNum; i++) | |||||
{ | |||||
if (!string.IsNullOrEmpty(recipe.Material[i].Material_Name)) | |||||
if (!string.IsNullOrEmpty(recipe.RecipeCode)) { | |||||
RawMaterials.Clear(); | |||||
for (int i = 0; i < GVL_SmallStation.Max_DosingSotckBinNum; i++) | |||||
{ | { | ||||
if (RawMaterialsNamePos.ContainsKey(recipe.Material[i].Material_Name)) | |||||
if (!string.IsNullOrEmpty(recipe.Material[i].Material_Name)) | |||||
{ | { | ||||
RawMaterials.Add(new RemoteRecipeRawMaterial() | |||||
if (RawMaterialsNamePos.ContainsKey(recipe.Material[i].Material_Name)) | |||||
{ | { | ||||
RawMaterialName = recipe.Material[i].Material_Name, | |||||
RawMaterialBarrelNum = recipe.Material[i].Material_BarrelNum, | |||||
RawMaterialWeight = recipe.Material[i].Material_Weight, | |||||
RawMaterialLocation = (int)RawMaterialsNamePos[recipe.Material[i].Material_Name] | |||||
}); | |||||
RawMaterials.Add(new RemoteRecipeRawMaterial() | |||||
{ | |||||
RawMaterialName = recipe.Material[i].Material_Name, | |||||
RawMaterialBarrelNum = recipe.Material[i].Material_BarrelNum, | |||||
RawMaterialWeight = recipe.Material[i].Material_Weight, | |||||
RawMaterialLocation = (int)RawMaterialsNamePos[recipe.Material[i].Material_Name] | |||||
}); | |||||
} | |||||
else | |||||
{ | |||||
//MessageNotify.GetInstance.AlarmLog("配方名称与本地不符合"); | |||||
} | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
//MessageNotify.GetInstance.AlarmLog("配方名称与本地不符合"); | |||||
break; | |||||
} | } | ||||
} | } | ||||
else | |||||
for (int i = 0; i < GVL_SmallStation.Max_PowderSotckBinNum; i++) | |||||
{ | { | ||||
break; | |||||
if (!string.IsNullOrEmpty(recipe.Powder[i].Powder_Name)) | |||||
{ | |||||
WindSendData.Add(new WindSendRawMaterial() | |||||
{ | |||||
RawMaterialName = recipe.Powder[i].Powder_Name, | |||||
RawMaterialWeight = recipe.Powder[i].Powder_Weight | |||||
}); | |||||
} | |||||
else | |||||
{ | |||||
break; | |||||
} | |||||
} | } | ||||
} | |||||
for (int i = 0; i < GVL_SmallStation.Max_PowderSotckBinNum; i++) | |||||
{ | |||||
if (!string.IsNullOrEmpty(recipe.Powder[i].Powder_Name)) | |||||
{ | |||||
WindSendData.Add(new WindSendRawMaterial() | |||||
App.Current.Dispatcher.Invoke(() => { | |||||
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData() | |||||
{ | { | ||||
RawMaterialName = recipe.Powder[i].Powder_Name, | |||||
RawMaterialWeight = recipe.Powder[i].Powder_Weight | |||||
RecipeName = recipe.RecipeName, | |||||
RecipeCode = recipe.RecipeCode, | |||||
RawMaterial = RawMaterials, | |||||
TrayCode = recipe.StockCode, | |||||
WindSend = WindSendData | |||||
}); | }); | ||||
} | |||||
else | |||||
{ | |||||
break; | |||||
} | |||||
}); | |||||
} | } | ||||
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData() | |||||
{ | |||||
RecipeName = recipe.RecipeName, | |||||
RecipeCode = recipe.RecipeCode, | |||||
RawMaterial = RawMaterials, | |||||
TrayCode = recipe.TrayCode, | |||||
WindSend = WindSendData | |||||
}); | |||||
} | } | ||||
} | } | ||||
}), "SiemensRecipeRecive", true); | }), "SiemensRecipeRecive", true); | ||||
ActionManage.GetInstance.CancelRegister("SiemensRecipeFinish"); | |||||
ActionManage.GetInstance.Register(new Action<object>((res) => | |||||
{ | |||||
if (SiemensDevice.IsConnected) | |||||
{ | |||||
if (res != null && res is RemoteRecipeData recipe) | |||||
{ | |||||
RecipeFinishInfo.Order_No = recipe.RecipeCode; | |||||
RecipeFinishInfo.Product_Code = recipe.RecipeName; | |||||
RecipeFinishInfo.Job_No = (short)recipe.TrayCode; | |||||
for (int i = 0; i < recipe.RawMaterial.Count; i++) | |||||
{ | |||||
RecipeFinishInfo.Material[i] = new UDT1(); | |||||
RecipeFinishInfo.Material[i].Material_Name = recipe.RawMaterial.ElementAt(i).RawMaterialName; | |||||
RecipeFinishInfo.Material[i].Material_BarrelNum = recipe.RawMaterial.ElementAt(i).RawMaterialBarrelNum; | |||||
RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = recipe.RawMaterial.ElementAt(i).Laying_Off_Weight; | |||||
} | |||||
for (int i = 0; i < recipe.WindSend.Count; i++) | |||||
{ | |||||
RecipeFinishInfo.Powder[i] = new UDT2(); | |||||
} | |||||
if (GVL_SmallStation.SiemensSendRecipeStatus == 6) | |||||
{ | |||||
GVL_SmallStation.SiemensSendRecipeStatus = 7; | |||||
RecipeFinishInfo.Ask_For_Finish = true; | |||||
SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261); | |||||
} | |||||
} | |||||
} | |||||
}), "SiemensRecipeFinish", true); | |||||
ActionManage.GetInstance.CancelRegister("WindSendDosingFinish"); | ActionManage.GetInstance.CancelRegister("WindSendDosingFinish"); | ||||
ActionManage.GetInstance.Register(new Action(() => | ActionManage.GetInstance.Register(new Action(() => | ||||
{ | { | ||||
@@ -644,7 +679,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||||
GVL_SmallStation.GetInstance.HeartBeatToPlc = !GVL_SmallStation.GetInstance.HeartBeatToPlc; | GVL_SmallStation.GetInstance.HeartBeatToPlc = !GVL_SmallStation.GetInstance.HeartBeatToPlc; | ||||
HKDevice.HK_PLC_S7.Write("DB4.DBX0.0", GVL_SmallStation.GetInstance.HeartBeatToPlc); | HKDevice.HK_PLC_S7.Write("DB4.DBX0.0", GVL_SmallStation.GetInstance.HeartBeatToPlc); | ||||
GVL_SmallStation.GetInstance.HeartBeatFromPlc = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX0.0"); | GVL_SmallStation.GetInstance.HeartBeatFromPlc = HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX0.0"); | ||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -661,14 +695,66 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||||
{ | { | ||||
if (!(RecipeQueue.Contains(data.RecipeCode))) | if (!(RecipeQueue.Contains(data.RecipeCode))) | ||||
{ | { | ||||
RecipeQueue.Enqueue(data.RecipeCode); | |||||
if (SiemensDevice.XL_Status is XL_Status_DB status) | |||||
{ | |||||
if (GVL_SmallStation.SiemensSendRecipeStatus == 3) | |||||
{ | |||||
GVL_SmallStation.SiemensSendRecipeStatus = 4; | |||||
SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode,10); | |||||
SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0",true); | |||||
} | |||||
if (GVL_SmallStation.SiemensSendRecipeStatus == 4) | |||||
{ | |||||
if (SiemensDevice.XL_Status.Dosing_Confirm) | |||||
{ | |||||
GVL_SmallStation.SiemensSendRecipeStatus = 5; | |||||
SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10); | |||||
SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false); | |||||
} | |||||
} | |||||
if (GVL_SmallStation.SiemensSendRecipeStatus == 5) | |||||
{ | |||||
if (SiemensDevice.XL_Status.Dosing_Confirm == false) | |||||
{ | |||||
GVL_SmallStation.SiemensSendRecipeStatus = 6; | |||||
RecipeQueue.Enqueue(data.RecipeCode); | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } | ||||
else if(data.TrayCode == 2) | |||||
else if (data.TrayCode == 2) | |||||
{ | { | ||||
if (!(RecipeQueueTray2.Contains(data.RecipeCode))) | if (!(RecipeQueueTray2.Contains(data.RecipeCode))) | ||||
{ | { | ||||
RecipeQueueTray2.Enqueue(data.RecipeCode); | |||||
if (SiemensDevice.XL_Status is XL_Status_DB status) | |||||
{ | |||||
if (GVL_SmallStation.SiemensSendRecipeStatus == 3) | |||||
{ | |||||
GVL_SmallStation.SiemensSendRecipeStatus = 4; | |||||
SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10); | |||||
SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true); | |||||
} | |||||
if (GVL_SmallStation.SiemensSendRecipeStatus == 4) | |||||
{ | |||||
if (SiemensDevice.XL_Status.Dosing_Confirm) | |||||
{ | |||||
GVL_SmallStation.SiemensSendRecipeStatus = 5; | |||||
SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10); | |||||
SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false); | |||||
} | |||||
} | |||||
if (GVL_SmallStation.SiemensSendRecipeStatus == 5) | |||||
{ | |||||
if (SiemensDevice.XL_Status.Dosing_Confirm == false) | |||||
{ | |||||
GVL_SmallStation.SiemensSendRecipeStatus = 0; | |||||
RecipeQueueTray2.Enqueue(data.RecipeCode); | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -851,23 +937,39 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||||
} | } | ||||
} | } | ||||
if (RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1")) && (GVL_SmallStation.GetInstance.WindSendDosingFinish || !GVL_SmallStation.GetInstance.IsUseWindSend)) | |||||
if ((RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1")) && (GVL_SmallStation.GetInstance.WindSendDosingFinish || !GVL_SmallStation.GetInstance.IsUseWindSend)) || GVL_SmallStation.GetInstance.RecipeStatusID == 5) | |||||
{ | { | ||||
var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code); | var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code); | ||||
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成"); | MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成"); | ||||
RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode; | |||||
RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName; | |||||
for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) | |||||
{ | |||||
RecipeFinishInfo.Material[i] = new UDT1(); | |||||
RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; | |||||
RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; | |||||
RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; | |||||
} | |||||
if (SiemensDevice.IsConnected) | if (SiemensDevice.IsConnected) | ||||
{ | { | ||||
RecipeFinishInfo.Ask_For_Finish = true; | |||||
SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261); | |||||
RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode; | |||||
RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName; | |||||
RecipeFinishInfo.Job_No = (short)trayCode; | |||||
for (int i = 0; i < 20; i++) | |||||
{ | |||||
RecipeFinishInfo.Material[i] = new UDT1(); | |||||
} | |||||
for (int i = 0; i < 10; i++) | |||||
{ | |||||
RecipeFinishInfo.Powder[i] = new UDT2(); | |||||
} | |||||
for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) | |||||
{ | |||||
RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; | |||||
RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; | |||||
RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; | |||||
} | |||||
for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++) | |||||
{ | |||||
} | |||||
if (GVL_SmallStation.SiemensSendRecipeStatus == 6) | |||||
{ | |||||
GVL_SmallStation.SiemensSendRecipeStatus = 7; | |||||
RecipeFinishInfo.Ask_For_Finish = true; | |||||
SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261); | |||||
} | |||||
} | } | ||||
App.Current.Dispatcher.Invoke(() => | App.Current.Dispatcher.Invoke(() => | ||||
{ | { | ||||
@@ -1079,5 +1181,23 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||||
} | } | ||||
} | } | ||||
} | } | ||||
private void testData() | |||||
{ | |||||
RawMaterialsNamePos.Add("A10", 1); | |||||
RawMaterialsNamePos.Add("A20", 2); | |||||
RawMaterialsNamePos.Add("A30", 3); | |||||
RawMaterialsNamePos.Add("A40", 4); | |||||
RawMaterialsNamePos.Add("A50", 5); | |||||
RawMaterialsNamePos.Add("A60", 6); | |||||
RawMaterialsNamePos.Add("A70", 7); | |||||
RawMaterialsNamePos.Add("A80", 8); | |||||
RawMaterialsNamePos.Add("A90", 9); | |||||
RawMaterialsNamePos.Add("A100", 10); | |||||
RawMaterialsNamePos.Add("A110", 11); | |||||
RawMaterialsNamePos.Add("A120", 12); | |||||
RawMaterialsNamePos.Add("A130", 13); | |||||
RawMaterialsNamePos.Add("A140", 14); | |||||
RawMaterialsNamePos.Add("A150", 15); | |||||
} | |||||
} | } | ||||
} | } |
@@ -14,34 +14,79 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | |||||
{ | { | ||||
public SiemensHelper Siemens_PLC_S7 = new SiemensHelper(); | public SiemensHelper Siemens_PLC_S7 = new SiemensHelper(); | ||||
public bool IsConnected => Siemens_PLC_S7.IsConnected; | public bool IsConnected => Siemens_PLC_S7.IsConnected; | ||||
public XL_Status_DB XL_Status = new XL_Status_DB(); | |||||
bool test; | |||||
public void Init() | public void Init() | ||||
{ | { | ||||
if (IsConnected) | if (IsConnected) | ||||
{ | { | ||||
ThreadManage.GetInstance().StartLong(new Action(() => | |||||
ThreadManage.GetInstance().StartLong(new Action(() => | |||||
{ | { | ||||
var Start = this.Siemens_PLC_S7.ReadClass<XL_Start_DB>(2201); | var Start = this.Siemens_PLC_S7.ReadClass<XL_Start_DB>(2201); | ||||
var Status = this.Siemens_PLC_S7.ReadClass<XL_Status_DB>(2231); | var Status = this.Siemens_PLC_S7.ReadClass<XL_Status_DB>(2231); | ||||
var Finish = this.Siemens_PLC_S7.ReadClass<XL_Finish_DB>(2261); | var Finish = this.Siemens_PLC_S7.ReadClass<XL_Finish_DB>(2261); | ||||
var DataColl = this.Siemens_PLC_S7.ReadClass<XL_DataColl_DB>(2291); | var DataColl = this.Siemens_PLC_S7.ReadClass<XL_DataColl_DB>(2291); | ||||
if (Start != null && Start.Order_Request == false && GVL_SmallStation.IsAllowSiemensSendRecipe) | |||||
if (test) | |||||
{ | { | ||||
Start.Order_Request = true; | |||||
this.Siemens_PLC_S7.WriteClass<XL_Start_DB>(Start, 1); | |||||
for (int i = 0; i < XL_Status.Powder.Length; i++) { | |||||
XL_Status.Powder.ElementAt(i).Powder_Name = ""+i; | |||||
} | |||||
Siemens_PLC_S7.WriteClass<XL_Status_DB>(XL_Status, 2231); | |||||
} | } | ||||
if (Start != null && RTrig.GetInstance("RecipeTrig").Start(Start.Order_Request_ACK)) | |||||
if (Start != null && Start is XL_Start_DB st) | |||||
{ | { | ||||
ActionManage.GetInstance.Send("SiemensRecipeRecive", Start); | |||||
Start.Order_Request_ACK = false; | |||||
this.Siemens_PLC_S7.WriteClass<XL_Start_DB>(Start, 1); | |||||
if (RTrig.GetInstance("DB2201.DBX450.0").Start(GVL_SmallStation.IsAllowSiemensSendRecipe) && GVL_SmallStation.SiemensSendRecipeStatus == 0) | |||||
{ | |||||
GVL_SmallStation.SiemensSendRecipeStatus = 1; | |||||
this.Siemens_PLC_S7.Write("DB2201.DBX450.0", true); | |||||
} | |||||
if (RTrig.GetInstance("Order_Request_ACK").Start(Start.Order_Request_ACK) && GVL_SmallStation.SiemensSendRecipeStatus == 1) | |||||
{ | |||||
if (!string.IsNullOrEmpty(st.RecipeCode)) | |||||
{ | |||||
GVL_SmallStation.SiemensSendRecipeStatus = 2; | |||||
ActionManage.GetInstance.Send("SiemensRecipeRecive", st); | |||||
this.Siemens_PLC_S7.Write("DB2201.DBX450.0", false); | |||||
} | |||||
} | |||||
if (TTrig.GetInstance("Order_Request_ACK_").Start(Start.Order_Request_ACK) && GVL_SmallStation.SiemensSendRecipeStatus == 2) | |||||
{ | |||||
GVL_SmallStation.IsAllowSiemensSendRecipe = false; | |||||
GVL_SmallStation.SiemensSendRecipeStatus = 3; | |||||
//需要等待请求信号复位才能认为接收配方完成 | |||||
} | |||||
} | } | ||||
if (Status != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(Status.AgvRequestPut)) | |||||
if (Finish != null && Finish is XL_Finish_DB FinishData) | |||||
{ | { | ||||
ActionManage.GetInstance.Send("AGV放货架到位",Status); | |||||
Status.AgvRequestPut = false; | |||||
this.Siemens_PLC_S7.WriteClass<XL_Status_DB>(Status, 2); | |||||
if (RTrig.GetInstance("Ask_For_Finish_PLC").Start(FinishData.Ask_For_Finish_PLC) && GVL_SmallStation.SiemensSendRecipeStatus == 7) | |||||
{ | |||||
FinishData.Order_No = ""; | |||||
FinishData.Product_Code = ""; | |||||
FinishData.Job_No = 0; | |||||
for (int i = 0; i < 20; i++) | |||||
{ | |||||
FinishData.Material[i] = new UDT1(); | |||||
} | |||||
for (int i = 0; i < 10; i++) | |||||
{ | |||||
FinishData.Powder[i] = new UDT2(); | |||||
} | |||||
GVL_SmallStation.SiemensSendRecipeStatus = 0; | |||||
FinishData.Ask_For_Finish = false; | |||||
FinishData.DosingTime = 0; | |||||
this.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(FinishData, 2261); | |||||
} | |||||
} | |||||
if (Status != null && Status is XL_Status_DB state) | |||||
{ | |||||
XL_Status = state; | |||||
if (RTrig.GetInstance("Allow_AGV_Put[0]").Start(Status.AgvRequestPut)) | |||||
{ | |||||
ActionManage.GetInstance.Send("AGV放货架到位", Status); | |||||
Status.AgvRequestPut = false; | |||||
this.Siemens_PLC_S7.WriteClass<XL_Status_DB>(Status, 2); | |||||
} | |||||
} | } | ||||
if (Status != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(Status.AgvRequestGet)) | if (Status != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(Status.AgvRequestGet)) | ||||
{ | { | ||||
@@ -49,7 +94,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | |||||
Status.AgvRequestGet = false; | Status.AgvRequestGet = false; | ||||
this.Siemens_PLC_S7.WriteClass<XL_Status_DB>(Status, 2); | this.Siemens_PLC_S7.WriteClass<XL_Status_DB>(Status, 2); | ||||
} | } | ||||
Thread.Sleep(10); | Thread.Sleep(10); | ||||
}),"监听服务数据"); | }),"监听服务数据"); | ||||
} | } | ||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks; | |||||
namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | ||||
{ | { | ||||
internal class XL_Finish_DB | |||||
public class XL_Finish_DB | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 配料完成信号确认 | /// 配料完成信号确认 | ||||
@@ -52,7 +52,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | |||||
/// 原料名称 | /// 原料名称 | ||||
/// </summary> | /// </summary> | ||||
[Siemens(6)] | [Siemens(6)] | ||||
public string Material_Name { get; set; } | |||||
public string Material_Name { get; set; } = ""; | |||||
/// <summary> | /// <summary> | ||||
/// 原料下料重量 | /// 原料下料重量 | ||||
/// </summary> | /// </summary> | ||||
@@ -68,7 +68,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | |||||
/// 粉料仓名称 | /// 粉料仓名称 | ||||
/// </summary> | /// </summary> | ||||
[Siemens(6)] | [Siemens(6)] | ||||
public string Powder_Name { get; set; } | |||||
public string Powder_Name { get; set; } = ""; | |||||
/// <summary> | /// <summary> | ||||
/// 粉料仓重量 | /// 粉料仓重量 | ||||
/// </summary> | /// </summary> | ||||
@@ -51,7 +51,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | |||||
/// <summary> | /// <summary> | ||||
/// 原料名称 | /// 原料名称 | ||||
/// </summary> | /// </summary> | ||||
public string Material_Name { get; set; } | |||||
public string Material_Name { get; set; } = ""; | |||||
/// <summary> | /// <summary> | ||||
/// 原料重量 | /// 原料重量 | ||||
/// </summary> | /// </summary> | ||||
@@ -69,7 +69,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | |||||
/// 粉料仓名称 | /// 粉料仓名称 | ||||
/// </summary> | /// </summary> | ||||
[Siemens(6)] | [Siemens(6)] | ||||
public string Powder_Name { get; set; } | |||||
public string Powder_Name { get; set; } = ""; | |||||
/// <summary> | /// <summary> | ||||
/// 粉料仓重量 | /// 粉料仓重量 | ||||
/// </summary> | /// </summary> | ||||
@@ -78,7 +78,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens | |||||
/// 粉料名称 | /// 粉料名称 | ||||
/// </summary> | /// </summary> | ||||
[Siemens(6)] | [Siemens(6)] | ||||
public string Powder_Name { get; set; } | |||||
public string Powder_Name { get; set; } = ""; | |||||
/// <summary> | /// <summary> | ||||
/// 粉料仓剩余重量 | /// 粉料仓剩余重量 | ||||
/// </summary> | /// </summary> | ||||
@@ -379,7 +379,6 @@ namespace BPASmartClient.S7Net | |||||
{ | { | ||||
break; | break; | ||||
} | } | ||||
numBytes = SetBytesFromProperty(array.GetValue(i), bytes, numBytes, accessableProperty); | numBytes = SetBytesFromProperty(array.GetValue(i), bytes, numBytes, accessableProperty); | ||||
} | } | ||||
} | } | ||||
@@ -388,7 +387,6 @@ namespace BPASmartClient.S7Net | |||||
numBytes = SetBytesFromProperty(accessableProperty.GetValue(sourceClass, null), bytes, numBytes, accessableProperty); | numBytes = SetBytesFromProperty(accessableProperty.GetValue(sourceClass, null), bytes, numBytes, accessableProperty); | ||||
} | } | ||||
} | } | ||||
return numBytes; | return numBytes; | ||||
} | } | ||||
@@ -1,4 +1,5 @@ | |||||
using S7.Net; | using S7.Net; | ||||
using System.Text; | |||||
namespace BPASmartClient.S7Net | namespace BPASmartClient.S7Net | ||||
{ | { | ||||
@@ -89,6 +90,13 @@ namespace BPASmartClient.S7Net | |||||
} | } | ||||
} | } | ||||
public void WriteString(int db,string txt, int startAddress = 0) | |||||
{ | |||||
var temp = Encoding.ASCII.GetBytes(txt); | |||||
var bytes = S7.Net.Types.S7String.ToByteArray(txt, temp.Length); | |||||
myPlc.WriteBytes(DataType.DataBlock,db, startAddress, bytes); | |||||
} | |||||
public TResult ReadClass<TResult>(int db, int startByteAdr = 0) where TResult : class, new() | public TResult ReadClass<TResult>(int db, int startByteAdr = 0) where TResult : class, new() | ||||
{ | { | ||||
TResult sourceClass = new TResult(); | TResult sourceClass = new TResult(); | ||||