浏览代码

吉香居代码更新

master
pengliangyang 2 年前
父节点
当前提交
cef3957d9d
共有 16 个文件被更改,包括 306 次插入404 次删除
  1. +1
    -1
      BPASmartClient.JXJFoodBigStation/App.config
  2. +1
    -2
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs
  3. +8
    -4
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs
  4. +1
    -1
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs
  5. +108
    -288
      BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
  6. +39
    -0
      BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_DataColl_DB.cs
  7. +23
    -12
      BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs
  8. +19
    -16
      BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs
  9. +25
    -41
      BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs
  10. +9
    -8
      BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs
  11. +2
    -4
      BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
  12. +1
    -0
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs
  13. +39
    -0
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_DataColl_DB.cs
  14. +12
    -8
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs
  15. +4
    -4
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs
  16. +14
    -15
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs

+ 1
- 1
BPASmartClient.JXJFoodBigStation/App.config 查看文件

@@ -2,6 +2,6 @@
<configuration>
<appSettings>
<add key="HKPlc_IP" value="107.107.2.17"/>
<add key="Siemens_IP" value="192.168.0.30"/>
<add key="Siemens_IP" value="107.107.2.200"/>
</appSettings>
</configuration>

+ 1
- 2
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs 查看文件

@@ -79,7 +79,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
public float Bareel1Bin13SetWeight { get; set; }
public float Bareel1Bin14SetWeight { get; set; }


public float Bareel2Bin1SetWeight { get; set; }
public float Bareel2Bin2SetWeight { get; set; }
public float Bareel2Bin3SetWeight { get; set; }
@@ -94,7 +93,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
public float Bareel2Bin12SetWeight { get; set; }
public float Bareel2Bin13SetWeight { get; set; }
public float Bareel2Bin14SetWeight { get; set; }

public float Bareel4Bin1SetWeight { get; set; }
public float Bareel4Bin2SetWeight { get; set; }
@@ -110,6 +108,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
public float Bareel4Bin12SetWeight { get; set; }
public float Bareel4Bin13SetWeight { get; set; }
public float Bareel4Bin14SetWeight { get; set; }

public float Bareel5Bin1SetWeight { get; set; }
public float Bareel5Bin2SetWeight { get; set; }
public float Bareel5Bin3SetWeight { get; set; }


+ 8
- 4
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs 查看文件

@@ -17,7 +17,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
public bool IsConnected => HK_PLC_S7.IsConnected;
public DB_Write PlcWrite = new DB_Write();
public DB_Read PlcRead = new DB_Read();
public StockBinName StockBinName = new StockBinName();
public void Init()
{
if (IsConnected)
@@ -26,11 +26,15 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
HK_PLC_S7.WriteClass<DB_Write>(PlcWrite, 99);
var res1 = HK_PLC_S7.ReadClass<DB_Read>(98);
var res2 = HK_PLC_S7.ReadClass<Test1>(97);
var res2 = HK_PLC_S7.ReadClass<StockBinName>(97);
if (res1 != null && res1 is DB_Read data1)
{
PlcRead = data1;
}
if (res2 != null && res2 is StockBinName data2)
{
StockBinName = data2;
}
Thread.Sleep(10);
}),"信号收发处理");
}
@@ -264,7 +268,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
}
else
{
MessageLog.GetInstance.ShowRunLog($"桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}");
MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}");
switch (barrel)
{
case 1:
@@ -470,7 +474,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
default:
break;
}
}
}
}
}
}


BPASmartClient.JXJFoodBigStation/Model/HK_PLC/Test1.cs → BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs 查看文件

@@ -7,7 +7,7 @@ using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
internal class Test1
public class StockBinName
{
[Siemens(6)]
public string RawMaterialName1 { get; set; }

+ 108
- 288
BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs 查看文件

@@ -48,27 +48,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public ConcurrentQueue<string> RecipeQueue4 = new ConcurrentQueue<string>();
public ConcurrentQueue<string> RecipeQueue5 = new ConcurrentQueue<string>();
/// <summary>
/// AGV到达工站队列
/// </summary>
public ConcurrentQueue<string> AGVToWorkStationQueue = new ConcurrentQueue<string>();
/// <summary>
/// 接收原料数据
/// </summary>
public RecipeRawMaterial RawMaterial;
public void Init()
{
RawMaterialsNamePos.Add("1", 1);
RawMaterialsNamePos.Add("2", 2);
RawMaterialsNamePos.Add("3", 3);
RawMaterialsNamePos.Add("4", 4);
RawMaterialsNamePos.Add("5", 5);
RawMaterialsNamePos.Add("6", 6);
RawMaterialsNamePos.Add("7", 7);
RawMaterialsNamePos.Add("8", 8);
RawMaterialsNamePos.Add("9", 9);
RawMaterialsNamePos.Add("10", 10);
RawMaterialsNamePos.Add("11", 11);
RawMaterialsNamePos.Add("12", 12);
ActionManage.GetInstance.Register(new Action<object>((res) =>
{
ObservableCollection<RawMaterial> RawMaterials = new ObservableCollection<RawMaterial>();
@@ -87,7 +71,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
RawMaterialBarrelNum = recipe.Material[i].Material_BarrelNum,
RawMaterialWeight = recipe.Material[i].Material_Weight,
RawMaterialLocation = (int)RawMaterialsNamePos[recipe.Material[i].Material_Name]
});
});
}
else
{
@@ -99,7 +83,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
RecipeName = recipe.RecipeName,
RecipeCode = recipe.RecipeCode,
RawMaterial = RawMaterials,
TrayCode = recipe.TrayCode
//TrayCode = recipe.Order_No,
});
}
}
@@ -108,7 +92,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
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);
if (HKDevice.IsConnected)
{
@@ -138,136 +122,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model
item.RawMaterialLocation = Convert.ToInt32(item.RawMaterialName);
}
}
MessageNotify.GetInstance.ShowAlarmLog("海科plc连接失败");
}
}), "ManualSendRecipe", true);
RecipeQueue1.Clear();


//Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
ThreadManage.GetInstance().StartLong(new Action(() =>
{
//ReadPLCDeviceInfo();
ReceviceData();
RecipeInfoToHKPLC();
Thread.Sleep(10);
}), "流程处理", true);
ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (HKDevice.IsConnected && SiemensDevice.IsConnected)
{
AgvGetInOut();
}
Thread.Sleep(10);
}), "AGV进站送取货", true);
ThreadManage.GetInstance().StartLong(new Action(() =>
{
ReadSiemensCommData();
ReadHKPLCCommData();
Thread.Sleep(10);
}), "读取西门子和海科PLC的数据", true);
}
/// <summary>
/// AGV送货
/// </summary>
/// <param name="bitNum"></param>
private void AGV_Delivery(int bitNum)
{
if ((ReadSiemens("M4002." + bitNum) is bool) && BigStation.AgvDeliveryPosition == 0)
{
BigStation.AgvDeliveryPosition = 1;
WriteHKPLC("M4002." + bitNum, true);
WriteSiemens("M4002." + bitNum, false);
}
else if (ReadHK("M5002." + bitNum) is bool && BigStation.AgvDeliveryPosition == 1)
{
BigStation.AgvDeliveryPosition = 2;
WriteSiemens("M5002." + bitNum, true);
WriteHKPLC("M5002." + bitNum, false);
}
else if (ReadSiemens("M4004." + bitNum) is bool && BigStation.AgvDeliveryPosition == 2)
{
BigStation.AgvDeliveryPosition = 3;
WriteHKPLC("M4004." + bitNum, true);
WriteSiemens("M4004." + bitNum, false);
}
else if (ReadHK("M5004." + bitNum) is bool && BigStation.AgvDeliveryPosition == 3)
{
BigStation.AgvDeliveryPosition = 4;
WriteSiemens("M5004." + bitNum, true);
WriteHKPLC("M5004." + bitNum, false);
}
else if (ReadSiemens("M4005." + bitNum) is bool && BigStation.AgvDeliveryPosition == 4)
{
BigStation.AgvDeliveryPosition = 5;
WriteHKPLC("M4005." + bitNum, true);
WriteSiemens("M4005." + bitNum, false);
}
else if (ReadHK("M5005." + bitNum) is bool && BigStation.AgvDeliveryPosition == 5)
{
WriteSiemens("M5005." + bitNum, true);
WriteHKPLC("M5005." + bitNum, false);
}
}
/// <summary>
/// AGV取货
/// </summary>
/// <param name="bitNum"></param>
private void AGV_Pick(int bitNum)
{
if (ReadSiemens("M4003" + bitNum) is bool && BigStation.AgvPickUpPosition == 0)
{
BigStation.AgvPickUpPosition = 1;
WriteHKPLC("M4003." + bitNum, true);
WriteSiemens("M4003." + bitNum, false);
}
if (ReadHK("M5003" + bitNum) is bool && BigStation.AgvPickUpPosition == 1)
{
BigStation.AgvPickUpPosition = 2;
WriteSiemens("M5003" + bitNum, true);
WriteHKPLC("M5003" + bitNum, false);
}
if (ReadSiemens("M4006." + bitNum) is bool && BigStation.AgvPickUpPosition == 2)
{
BigStation.AgvPickUpPosition = 3;
WriteHKPLC("M4006." + bitNum, true);
WriteSiemens("M4006." + bitNum, false);
}
if (ReadHK("M5006." + bitNum) is bool && BigStation.AgvPickUpPosition == 3)
{
WriteSiemens("M5006." + bitNum, true);
WriteHKPLC("M5006." + bitNum, false);
}
}
/// <summary>
/// AGV进站送货
/// </summary>
private void AgvGetInOut()
{
//获取工位上是否有小车
SiemensDevice.Siemens_PLC_S7.Write<bool>(SiemensCommAddress.StationIsExistCar, (bool)
HKDevice.HK_PLC_S7.Read<bool>("M4007.0"));
//检测AGV到站信号
if (AGVToWorkStationQueue.Count > 0)
{
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == AGVToWorkStationQueue.ElementAt(0));
int TrayLocation = RemoteRecipes.ElementAt(index).TrayCode;//根据配方编号,找到托盘的ID 托盘ID1-6
string RecipeCode = (string)RemoteRecipes.ElementAt(index).RecipeCode;
if (TrayLocation > 0 && TrayLocation < 7)
{
AGV_Delivery(TrayLocation - 1);
if (BigStation.AgvDeliveryPosition == 5)
{
BigStation.AgvDeliveryPosition = 0;
}
AGV_Pick(TrayLocation - 1);
if (BigStation.AgvPickUpPosition == 3)
{
BigStation.AgvPickUpPosition = 0;
AGVToWorkStationQueue.TryDequeue(out RecipeCode);
}
}
}
}
private void ReceviceData()
{
@@ -318,6 +182,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model
RecipeQueue4.Clear();
RecipeQueue5.Clear();
BigStation.Recipe1DosingStatus = 0;
BigStation.Recipe2DosingStatus = 0;
BigStation.Recipe3DosingStatus = 0;
BigStation.Recipe4DosingStatus = 0;
BigStation.Recipe5DosingStatus = 0;
}
}
private void RecipeInfoToHKPLC()
@@ -333,23 +201,20 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
HKDevice.StockBinPar(RemoteRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe1IssuedFinish = true;
//HKDevice.HK_PLC_S7.Write<bool>("DB98.DBX0.1", false);//复位允许下发配方1信号
BigStation.Recipe1DosingStatus = 1;
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe1 && BigStation.Recipe1DosingStatus == 1)
{
BigStation.Recipe1DosingStatus = 2;
HKDevice.PlcWrite.Recipe1IssuedFinish = false;
HKDevice.PlcWrite.RecipeCode = 0;
HKDevice.PlcWrite.TrayCode = 0;
WeightReset();
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成");
}
if (BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish)
{
BigStation.Recipe1DosingStatus = 3;
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
if (HKDevice.PlcRead.Recipe1TrayCode == 1)
{
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
@@ -425,7 +290,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 3);
}
//HKDevice.HK_PLC_S7.Write<bool>("DB98.DBX1.1",false);
RecipeQueue1.TryDequeue(out code);
IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下
if (!BigStation.IsAllowManual)
@@ -453,21 +317,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model
HKDevice.StockBinPar(RemoteRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe2IssuedFinish = true;
BigStation.Recipe2DosingStatus = 1;
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe2 && BigStation.Recipe2DosingStatus == 1)
{
BigStation.Recipe2DosingStatus = 2;
HKDevice.PlcWrite.Recipe2IssuedFinish = false;
HKDevice.PlcWrite.RecipeCode = 0;
HKDevice.PlcWrite.TrayCode = 0;
WeightReset();
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
}
if (BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish)
{
BigStation.Recipe2DosingStatus = 3;
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
if (HKDevice.PlcRead.Recipe2TrayCode > 0)
{
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
@@ -529,7 +391,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
}
}

FinishData.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
FinishData.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
@@ -539,11 +400,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model
FinishData.Material[i].Material_BarrelNum = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
FinishData.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
}

}
if (SiemensDevice.IsConnected)
{
SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 3);
MessageNotify.GetInstance.ShowRunLog($"配方配料完成,将信号反馈给西门子");
}
RecipeQueue2.TryDequeue(out code);
IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下
@@ -556,7 +417,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model
Json<LocalRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
}
BigStation.Recipe2DosingStatus = 0;
}
}
}
@@ -572,20 +432,18 @@ namespace BPASmartClient.JXJFoodBigStation.Model
HKDevice.StockBinPar(RemoteRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe3IssuedFinish = true;
BigStation.Recipe3DosingStatus = 1;
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe3 && BigStation.Recipe3DosingStatus == 1)
{
BigStation.Recipe3DosingStatus = 2;
HKDevice.PlcWrite.RecipeCode = 0;
HKDevice.PlcWrite.TrayCode = 0;
WeightReset();
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
}
if (HKDevice.PlcRead.Recipe3DosingFinish && BigStation.Recipe3DosingStatus == 2)
{
BigStation.Recipe3DosingStatus = 3;
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
if (HKDevice.PlcRead.Recipe3TrayCode > 0)
{
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
@@ -691,21 +549,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model
HKDevice.StockBinPar(RemoteRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe4IssuedFinish = true;
BigStation.Recipe4DosingStatus = 1;
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe4 && BigStation.Recipe4DosingStatus == 1)
{
BigStation.Recipe4DosingStatus = 2;
HKDevice.PlcWrite.Recipe4IssuedFinish = false;
HKDevice.PlcWrite.RecipeCode = 0;
HKDevice.PlcWrite.TrayCode = 0;
WeightReset();
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
}
if (BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish)
{
BigStation.Recipe4DosingStatus = 3;
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
if (HKDevice.PlcRead.Recipe4TrayCode > 0)
{
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
@@ -799,128 +655,15 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
}
}
public ConcurrentDictionary<string, Object> ReadHKPLCData = new ConcurrentDictionary<string, object>();
public ConcurrentDictionary<string, Object> ReadSiemensData = new ConcurrentDictionary<string, object>();


private void ReadSiemensCommData()
{
if (SiemensDevice.IsConnected)
{
GetSiemensStatus("", new Action<object>((obj) =>
{
if (obj is bool[] bools && bools.Length > 0)
{

}
}));
}
}
private void ReadHKPLCCommData()
{
if (HKDevice.IsConnected)
{
GetHKStatus("", new Action<object>((obj) =>
{
if (obj is bool[] bools && bools.Length > 0)
{

}
}));
}
}
private void GetHKStatus(string key, Action<object> action)
{
if (ReadHKPLCData.ContainsKey(key))
{
if (ReadHKPLCData[key] != null)
{
action?.Invoke(ReadHKPLCData[key]);
}
}
}
private void GetSiemensStatus(string key, Action<object> action)
{

if (ReadSiemensData.ContainsKey(key))
{
if (ReadSiemensData[key] != null)
{
action?.Invoke(ReadSiemensData[key]);
}
}
}
private void WriteSiemens(string Address, object Value)
{
if (SiemensDevice.IsConnected)
{
SiemensDevice.Siemens_PLC_S7.Write<object>(Address, Value);
}
}
private void WriteHKPLC(string Address, object Value)
{
HKDevice.HK_PLC_S7.Write<object>(Address, Value);
}
private object ReadSiemens(string Address)
{
if (SiemensDevice.IsConnected)
{
return SiemensDevice.Siemens_PLC_S7.Read<object>(Address);
}
else
{
return null;
}
}
private bool[] ReadBoolsSiemens(int address, int count)
{
if (SiemensDevice.IsConnected)
{
return SiemensDevice.Siemens_PLC_S7.ReadBools(address, count);
}
else
{
return null;
}
}
private object ReadHK(string Address)
{
if (HKDevice.IsConnected)
{
return HKDevice.HK_PLC_S7.Read<object>(Address);
}
else
{
return null;
}
}
private bool[] ReadBoolsHK(int address, int count)
{
if (HKDevice.IsConnected)
{
return HKDevice.HK_PLC_S7.ReadBools(address, count);
}
else
{
return null;
}
}
/// <summary>
/// 获取料仓的原料名称和原料位置
/// 下发配方的数据复位
/// </summary>
private void ReadPLCDeviceInfo()
{
/*for (int i = 0; i < 12; i++)
{
string RawMaterialName = HKDevice.HK_PLC_S7.Read<string>("");
short RawMaterialLocation = HKDevice.HK_PLC_S7.Read<short>("");
if (RawMaterialsNamePos.ContainsKey(RawMaterialName))
RawMaterialsNamePos.Add(RawMaterialName, RawMaterialLocation);
}*/
}
private void WeightReset()
private void StockBinParReset()
{

HKDevice.PlcWrite.RecipeCode = 0;
HKDevice.PlcWrite.TrayCode = 0;

HKDevice.PlcWrite.Bareel1Bin1SetWeight = 0;
HKDevice.PlcWrite.Bareel1Bin2SetWeight = 0;
HKDevice.PlcWrite.Bareel1Bin3SetWeight = 0;
@@ -982,5 +725,82 @@ namespace BPASmartClient.JXJFoodBigStation.Model
HKDevice.PlcWrite.Bareel5Bin13SetWeight = 0;
HKDevice.PlcWrite.Bareel5Bin14SetWeight = 0;
}
private void testData()
{
RawMaterialsNamePos.Clear();
if (!HKDevice.IsConnected)
{
HKDevice.StockBinName.RawMaterialName1 = "1";
HKDevice.StockBinName.RawMaterialName2 = "2";
HKDevice.StockBinName.RawMaterialName3 = "3";
HKDevice.StockBinName.RawMaterialName4 = "4";
HKDevice.StockBinName.RawMaterialName5 = "5";
HKDevice.StockBinName.RawMaterialName6 = "6";
HKDevice.StockBinName.RawMaterialName7 = "7";
HKDevice.StockBinName.RawMaterialName8 = "8";
HKDevice.StockBinName.RawMaterialName9 = "9";
HKDevice.StockBinName.RawMaterialName10 = "10";
HKDevice.StockBinName.RawMaterialName11 = "11";
HKDevice.StockBinName.RawMaterialName12 = "12";
HKDevice.StockBinName.RawMaterialName13 = "13";
HKDevice.StockBinName.RawMaterialName14 = "14";
}
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName1))
{
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName1, 1);
}
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName2))
{
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName2, 2);
}
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName3))
{
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName3, 3);
}
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName4))
{
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName4, 4);
}
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName5))
{
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName5, 5);
}
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName6))
{
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName6, 6);
}
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName7))
{
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName7, 7);
}
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName8))
{
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName8, 8);
}
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName9))
{
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName9, 9);
}
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName10))
{
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName10, 10);
}
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName11))
{
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName11, 11);
}
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName12))
{
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName12, 12);
}
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName13))
{
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName13, 13);
}
if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName14))
{
RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName14, 14);
}
}
}
}

+ 39
- 0
BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_DataColl_DB.cs 查看文件

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

namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
public class DL_DataColl_DB
{
[Siemens(16)]
public string RecipeCode { get; set; }
[Siemens(16)]
public string RecipeName { get; set; }
public bool var1 { get; set; }
public bool var2 { get; set; }

public bool var3 { get; set; }

public bool var4 { get; set; }

public bool var5 { get; set; }

public bool var6 { get; set; }

public bool var7 { get; set; }

public bool var8 { get; set; }

public bool var9 { get; set; }
public short Mode { get; set; }

public bool[] Alarm { get; set; } = new bool[24];
public int Reserved1 { get; set; }
public int Reserved2 { get; set; }

}
}

+ 23
- 12
BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs 查看文件

@@ -1,4 +1,5 @@
using System;
using BPASmartClient.S7Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -8,32 +9,42 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
internal class DL_Finish_DB
{

/// <summary>
/// 配料完成信号确认
/// </summary>
public bool Ask_For_Finish_PLC { get; set; }

public short[] StandbyFinish { get; set; } = new short[4];
[Siemens(16)]
/// <summary>
/// 生产工单编码
/// </summary>
public string Order_No;
public string Order_No{get; set; }
[Siemens(16)]
/// <summary>
/// 产品名称
/// </summary>
public string Product_Code;
public string Product_Code { get; set; }
public short job_No { get; set; }
/// <summary>
/// 原料信息
/// </summary>
public UDT1[] Material = new UDT1[20];
public UDT1[] Material { get; set; } = new UDT1[20];
public short ProcessTime { get; set; }
/// <summary>
/// 配料完成信号
/// </summary>
public bool Ask_For_Finish;
/// <summary>
/// 配料完成信号确认
/// </summary>
public bool Ask_For_Finish_PLC;
public bool Ask_For_Finish { get; set; }

public short[] StandbyFinish1 { get; set; } = new short[4];

}
public class UDT1
{
public string Material_Name;
public float Material_Laying_Off_Weight;
public short Material_BarrelNum;
[Siemens(6)]
public string Material_Name { get; set; }
public float Material_Laying_Off_Weight { get; set; }
public short Material_BarrelNum { get; set; }
}
}

+ 19
- 16
BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs 查看文件

@@ -1,4 +1,5 @@
using System;
using BPASmartClient.S7Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -8,44 +9,46 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
internal class DL_Start_DB
{
[Siemens(16)]
/// <summary>
/// 配方编码
/// </summary>
public string RecipeCode;
public string RecipeCode { get; set; }
[Siemens(16)]
/// <summary>
/// 配发名称
/// </summary>
public string RecipeName;
public string RecipeName { get; set; }
public short Order_No { get; set; }
public short Pallet_No { get; set; }
/// <summary>
/// 物料信息
/// </summary>
public UDT[] Material = new UDT[20];
/// <summary>
/// 托盘编号
/// </summary>
public int TrayCode;
public UDT[] Material { get; set; } = new UDT[20];
public bool Order_Type { get; set; }
public bool Order_Request_Ack { get; set; }
public short[] Standby { get; set; } = new short[4];
/// <summary>
/// 配方发送请求
/// </summary>
public bool Ask_For_Send_Bit;
/// <summary>
/// 上位机确认配方接收完成
/// </summary>
public bool Ack_Ask_For_Send_Bit;
public bool Ask_For_Send_Bit { get; set; }
public short[] Standby1 { get; set; } = new short[4];
}
public class UDT
{
[Siemens(6)]
/// <summary>
/// 原料名称
/// </summary>
public string Material_Name;
public string Material_Name { get; set; }
/// <summary>
/// 原料重量
/// </summary>
public float Material_Weight;
public float Material_Weight { get; set; }
/// <summary>
/// 原料桶号
/// </summary>
public short Material_BarrelNum;
public short Material_BarrelNum { get; set; }
}
}

+ 25
- 41
BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs 查看文件

@@ -1,4 +1,5 @@
using System;
using BPASmartClient.S7Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -8,53 +9,36 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
internal class DL_Status_DB
{
/// <summary>
/// 生产工单
/// </summary>
public string RecipeCode;
/// <summary>
/// 配料开始
/// </summary>
public bool Dosing_Start;
public bool Dosing_Start { get; set; }
/// <summary>
/// 配料开始确认
/// </summary>
public bool Dosing_Confirm;
/// <summary>
/// 托盘占位情况
/// </summary>
public bool[] Pallet_Position_Occ = new bool[16];
/// <summary>
/// 工位允许放货架
/// </summary>
public bool[] Allow_AGV_Put = new bool[16];
/// <summary>
/// 工位允许取货架
/// </summary>
public bool[] Allow_AGV_Get = new bool[16];
/// <summary>
/// AGV请求放货架
/// </summary>
public bool[] AGV_Request_Put = new bool[16];
/// <summary>
/// AGV请求取货架
/// </summary>
public bool[] AGV_Request_Get = new bool[16];
/// <summary>
/// AGV放托盘完成
/// </summary>
public bool[] AGV_Put_Done = new bool[16];
/// <summary>
/// 托盘号
/// </summary>
public short[] Pan_No = new short[16];
/// <summary>
/// 配料时间
/// </summary>
public int DosingTime;
public bool Dosing_Confirm { get; set; }
public bool Dosing_Cancel { get; set; }
public bool Dosing_Cancel2 { get; set; }

public bool Dosing_Cancel3 { get; set; }

public short a { get; set; }
public short[] Standby { get; set; } = new short[3];
[Siemens(16)]
/// <summary>
/// 备用
/// 生产工单
/// </summary>
public byte Reserve;
public string RecipeCode { get; set; }
public bool Dosing_Cancel4 { get; set; }

public bool Dosing_Cancel5 { get; set; }

public bool Dosing_Cancel6 { get; set; }

public bool Dosing_Cancel7 { get; set; }

public short Dosing_Cancel8 { get; set; }

public short[] Standby2 { get; set; } = new short[4];
}
}

+ 9
- 8
BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs 查看文件

@@ -21,21 +21,22 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
var res = this.Siemens_PLC_S7.ReadClass<DL_Start_DB>(1);
var res1 = this.Siemens_PLC_S7.ReadClass<DL_Status_DB>(2);
var res2 = this.Siemens_PLC_S7.ReadClass<DL_Finish_DB>(3);
if (res != null && RTrig.GetInstance("RecipeTrig").Start(res.Ask_For_Send_Bit))
var res = this.Siemens_PLC_S7.ReadClass<DL_Start_DB>(2301);
var res1 = this.Siemens_PLC_S7.ReadClass<DL_Status_DB>(2331);
var res2 = this.Siemens_PLC_S7.ReadClass<DL_Finish_DB>(2361);
var res3 = this.Siemens_PLC_S7.ReadClass<DL_DataColl_DB>(2391);
/*if (res != null && RTrig.GetInstance("RecipeTrig").Start(res.Ask_For_Send_Bit))
{
ActionManage.GetInstance.Send("SiemensSendRecipe", res);
res.Ask_For_Send_Bit = false;//接受配方信号复位
res.Ack_Ask_For_Send_Bit = true;//配方接受完成
//res.Ack_Ask_For_Send_Bit = true;//配方接受完成
this.Siemens_PLC_S7.WriteClass<DL_Start_DB>(res, 1);
}

if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(res1.Allow_AGV_Put[0]))
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(res1.))
{
ActionManage.GetInstance.Send("AGVToStation1Sign", res1);
res1.Allow_AGV_Put[0] = false;
//res1.Allow_AGV_Put[0] = false;
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
}
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(res1.Allow_AGV_Put[1]))
@@ -68,7 +69,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
res1.Allow_AGV_Put[5] = false;
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
}
*/
if (res2 != null && res2.Ask_For_Finish_PLC)
{
ActionManage.GetInstance.Send("配料完成信号确认完成");


+ 2
- 4
BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs 查看文件

@@ -80,7 +80,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
else
{
MessageNotify.GetInstance.AlarmLog("配方名称与本地不符合");
//MessageNotify.GetInstance.AlarmLog("配方名称与本地不符合");
}
}
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
@@ -112,7 +112,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
try
{
//HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, 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);
//WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200,WindSend_PLC_IP);
if (HKDevice.IsConnected)
{
@@ -272,7 +272,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
break;
default:
break;

}
}
else if (o.ToString().Contains("阻挡气缸"))
@@ -327,7 +326,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
break;
default:
break;

}
}
else if (o.ToString().Contains("进料桶顶升气缸"))


+ 1
- 0
BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs 查看文件

@@ -24,6 +24,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
var res = this.Siemens_PLC_S7.ReadClass<XL_Start_DB>(2201);
var res1 = this.Siemens_PLC_S7.ReadClass<XL_Status_DB>(2231);
var res2 = this.Siemens_PLC_S7.ReadClass<XL_Finish_DB>(2261);
var res4 = this.Siemens_PLC_S7.ReadClass<XL_DataColl_DB>(2291);
if (res != null && res.Order_Request_ACK == false && GVL_SmallStation.GetInstance.IsAllowSiemensSendRecipe)
{
res.Order_Request_ACK = true;


+ 39
- 0
BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_DataColl_DB.cs 查看文件

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

namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
{
internal class XL_DataColl_DB
{
[Siemens(16)]
public string RecipeCode { get; set; }
[Siemens(16)]
public string RecipeName { get; set; }
public bool var1 { get; set; }
public bool var2 { get; set; }

public bool var3 { get; set; }

public bool var4 { get; set; }

public bool var5 { get; set; }

public bool var6 { get; set; }

public bool var7 { get; set; }

public bool var8 { get; set; }

public bool var9 { get; set; }
public short Mode { get; set; }

public bool[] Alarm { get; set; } = new bool[24];
public int Reserved1 { get; set; }
public int Reserved2 { get; set; }

}
}

+ 12
- 8
BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs 查看文件

@@ -9,33 +9,37 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
{
internal class XL_Finish_DB
{
[Siemens(6)]

/// <summary>
/// 配料完成信号确认
/// </summary>
public bool Ask_For_Finish_PLC { get; set; }
public short[] StandbyFinish { get; set; }=new short[4];

[Siemens(16)]
/// <summary>
/// 生产工单编码
/// </summary
public string Order_No { get; set; }

[Siemens(6)]
[Siemens(16)]
/// <summary>
/// 产品名称
/// </summary>
public string Product_Code { get; set; }
public short Job_No { get; set; }
public UDT2[] Powder = new UDT2[10];
public UDT2[] Powder { get; set; } = new UDT2[10];
/// <summary>
/// 原料信息
/// </summary>
public UDT1[] Material = new UDT1[20];
public UDT1[] Material { get; set; } = new UDT1[20];
public short DosingTime { get; set; }
/// <summary>
/// 配料完成信号
/// </summary>
public bool Ask_For_Finish { get; set; }
/// <summary>
/// 配料完成信号确认
/// </summary>
public bool Ask_For_Finish_PLC { get; set; }

public short[] StandbyFinish2 { get; set; } = new short[4];
}
public class UDT1
{


+ 4
- 4
BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs 查看文件

@@ -23,19 +23,19 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
public short StockCode { get; set; }
public short TrayCode { get; set; }

public UDT2Start[] Powder = new UDT2Start[10];
public UDT2Start[] Powder { get; set; } = new UDT2Start[10];
/// <summary>
/// 物料信息
/// </summary>
public UDTStart[] Material = new UDTStart[20];
public UDTStart[] Material { get; set; } = new UDTStart[20];
/// <summary>
/// plc确认配方接收完成
/// </summary>
public bool Order_Request_ACK { get; set; }
public short[] Standby = new short[4];
public short[] Standby { get; set; } = new short[4];

public bool Order_Request { get; set; }
public short[] Standby1 = new short[4];
public short[] Standby1 { get; set; } = new short[4];

}
public class UDTStart


+ 14
- 15
BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs 查看文件

@@ -7,8 +7,16 @@ using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
{
internal class XL_Status_DB
public class XL_Status_DB
{
public bool Dosing_Confirm { get; set; }
public bool Agv1 { get; set; }
public bool Agv2 { get; set; }
public bool Agv3 { get; set; }
public bool Agv4 { get; set; }
public short AgvPos { get; set; }
public short[] Standby { get; set; } = new short[3];

[Siemens(16)]
/// <summary>
/// 生产工单
@@ -18,23 +26,14 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
/// 配料开始
/// </summary>
public bool Dosing_Start { get; set; }
/// <summary>
/// 配料开始确认
/// </summary>
public bool Dosing_Confirm;
public bool Agv1 { get; set; }
public bool Agv2 { get; set; }
public bool Agv3 { get; set; }
public bool Agv4 { get; set; }
public short AgvPos { get; set; }

public UDTStatus[] Powder = new UDTStatus[10];

public bool Agv5{ get; set; }
public bool Agv5 { get; set; }
public bool Agv6 { get; set; }
public bool Agv7 { get; set; }
public int Agv8 { get; set; }

public UDTStatus[] Powder { get; set; } = new UDTStatus[10];

public short AgvUse { get; set; }
public short[] StandbyStatus { get; set; } = new short[4];
}
public class UDTStatus
{


正在加载...
取消
保存