|
- using BPASmartClient.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()
- {
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- if (IsConnected)
- {
- var res1 = this.Siemens_PLC_S7.ReadClass<WindSend_Read>(94);
- if (res1 != null && res1 is WindSend_Read readData)
- {
- GVL_SmallStation.WindSendAllowAGVPutGet = readData.HoodLiftInPlace;
- Siemens_PLC_S7.Write<bool>("DB95.DBX38.2", GVL_SmallStation.Station1HaveTray);//工站1有托盘
- if (res1.RecipeReceiveFinish)
- {
- Siemens_PLC_S7.Write<bool>("DB95.DBX38.0", false);
- }
- if (RTrig.GetInstance("CurrentCompleteSign").Start(readData.CurrentCompleteSign))
- {
- GVL_SmallStation.WindSendDosingComple = true;
- Siemens_PLC_S7.Write("DB95.DBX38.1", true);
- }
- if (TTrig.GetInstance("CurrentCompleteSign").Start(readData.CurrentCompleteSign))
- {
- Siemens_PLC_S7.Write("DB95.DBX38.1", false);
- }
- }
- //测试
- /*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);*/
- }
- }),"监听粉料数据",true);
-
- }
- }
- }
|