|
- using BPA.Helper;
- using BPASmartClient.Modbus;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using BPASmartClient.S7Net;
- using System.Threading;
- using BPASmartClient.JXJFoodSmallStation.Model.WindSend;
- using BPASmartClient.CustomResource.UserControls.MessageShow;
- using BPASmartClient.CustomResource.UserControls;
-
- namespace BPASmartClient.JXJFoodSmallStation.Model
- {
- public class WindSendDeviceStatus
- {
- public SiemensHelper Siemens_PLC_S7 = new SiemensHelper();
- public bool IsConnected => Siemens_PLC_S7.IsConnected;
- public bool test;
- public void Init()
- {
- TaskManage.GetInstance.StartLong(new Action(() =>
- {
- if (IsConnected)
- {
- var res0 = this.Siemens_PLC_S7.ReadClass<WindSend_Write>(95);
- if (res0 != null && res0 is WindSend_Write WriteData)
- {
- GVL_SmallStation.GetInstance.WindSendDB95 = WriteData;
- }
- var res1 = this.Siemens_PLC_S7.ReadClass<WindSend_Read>(94);
- if (res1 != null && res1 is WindSend_Read readData)
- {
- GVL_SmallStation.GetInstance.WindSendDB94 = readData;
- GVL_SmallStation.GetInstance.WindSendAllowAGVPutGet = readData.HoodLiftInPlace;
- Siemens_PLC_S7.Write<bool>("DB95.DBX38.2", GVL_SmallStation.GetInstance.Station1HaveTray);//工站1有托盘
- switch (GVL_SmallStation.GetInstance.WindSendDosingStatus)
- {
- case 0:
- if (res1.IsAllowIssue)
- {
- GVL_SmallStation.GetInstance.WindSendDosingStatus = 1;
- }
- break;
- case 2:
- if (res1.RecipeReceiveFinish)
- {
- Siemens_PLC_S7.Write<bool>("DB95.DBX38.0", false);
- GVL_SmallStation.GetInstance.WindSendDosingStatus = 3;
- }
- break;
- case 3:
- if (readData.CurrentCompleteSign)
- {
- Siemens_PLC_S7.Write("DB95.DBX38.1", true);
- GVL_SmallStation.GetInstance.WindSendDosingStatus = 4;
- }
- break;
- case 4:
- if (!readData.CurrentCompleteSign)
- {
- Siemens_PLC_S7.Write("DB95.DBX38.1", false);
- GVL_SmallStation.GetInstance.WindSendDosingStatus = 5;
- }
- break;
- case 5:
- if (readData.HoodLiftInPlace && readData.DisChargeComple)
- {
- GVL_SmallStation.GetInstance.WindSendDosingComple = true;
- GVL_SmallStation.GetInstance.WindSendDosingStatus = 0;
- }
- break;
- //case 5:
- // if (TTrig.GetInstance("HoodLiftInPlaceSign").Start(readData.HoodLiftInPlace))
- // {
- // GVL_SmallStation.GetInstance.WindSendDosingStatus = 6;
- // }
- // break;
- //case 6:
- // if (RTrig.GetInstance("HoodLiftInPlaceSign").Start(readData.HoodLiftInPlace))
- // {
- // GVL_SmallStation.GetInstance.WindSendDosingStatus = 7;
- // }
- // break;
- //case 7:
- // GVL_SmallStation.GetInstance.WindSendDosingComple = true;
- // GVL_SmallStation.GetInstance.WindSendDosingStatus = 0;
- // break;
- default:
- break;
- }
-
- }
- //测试
- /*var res = this.Siemens_PLC_S7.ReadClass<WindSend_Write>(95);
- if (res != null && res is WindSend_Write write)
- {
- if (res1.SystemRunStatus == 1 && test)
- {
- test = false;
- write.RawMaterial1_SetWeight = 1.5f;
- write.RawMaterial2_SetWeight = 1.5f;
- write.RawMaterial3_SetWeight = 1.5f;
- write.RawMaterial4_SetWeight = 1.5f;
- write.RawMaterial5_SetWeight = 1.5f;
- write.TargetRecipeCode = "qwe123";
- write.Station1HaveSign = true;
- write.IsAllowDosing = true;
- Siemens_PLC_S7.WriteClass<WindSend_Write>(write, 95);
- }
- if (res1.RecipeReceiveFinish)
- {
- write.IsAllowDosing = false;
- Siemens_PLC_S7.WriteClass<WindSend_Write>(write, 95);
- }
- }
- if (res1 != null && res1 is WindSend_Read read)
- {
- if (RTrig.GetInstance("CurrentCompleteSign").Start(read.CurrentCompleteSign))
- {
- Siemens_PLC_S7.Write("DB95.DBX38.1", true);
- }
- if (TTrig.GetInstance("CurrentCompleteSign").Start(read.CurrentCompleteSign))
- {
- Siemens_PLC_S7.Write("DB95.DBX38.1", false);
- }
- }*/
- /*if (RTrig.GetInstance("CurrentCompleteSign").Start(res.CurrentCompleteSign))
- {
- ActionManage.GetInstance.Send("WindSendDosingFinish");
- }
- float weightAlarmStockBin1 = Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(0).LowerLimitWeight + Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(0).LowerLimitWeightOffset;
- float weightAlarmStockBin2 = Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(1).LowerLimitWeight + Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(1).LowerLimitWeightOffset;
- float weightAlarmStockBin3 = Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(2).LowerLimitWeight + Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(2).LowerLimitWeightOffset;
- float weightAlarmStockBin4 = Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(3).LowerLimitWeight + Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(3).LowerLimitWeightOffset;
- float weightAlarmStockBin5 = Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(4).LowerLimitWeight + Json<WindSendDevicePar>.Data.WindSendPar.ElementAt(4).LowerLimitWeightOffset;
- if (res.RawMaterial1_StockBinWeight < weightAlarmStockBin1)
- {
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"料仓1缺料!");
- }
- if (res.RawMaterial2_StockBinWeight < weightAlarmStockBin2)
- {
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"料仓2缺料!");
- }
- if (res.RawMaterial3_StockBinWeight < weightAlarmStockBin3)
- {
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"料仓3缺料!");
- }
- if (res.RawMaterial4_StockBinWeight < weightAlarmStockBin4)
- {
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"料仓4缺料!");
- }
- if (res.RawMaterial5_StockBinWeight < weightAlarmStockBin5)
- {
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"料仓5缺料!");
- }
- Thread.Sleep(10);*/
- }
- Thread.Sleep(10);
- }),"监听粉料数据",true);
-
- }
- }
- }
|