Преглед на файлове

大料站程序更新

master
pengliangyang преди 2 години
родител
ревизия
5a9f7a35ee
променени са 8 файла, в които са добавени 250 реда и са изтрити 53 реда
  1. +1
    -2
      BPASmartClient.JXJFoodBigStation/App.xaml.cs
  2. +4
    -0
      BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj
  3. +12
    -0
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Read.cs
  4. +146
    -0
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs
  5. +37
    -19
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs
  6. +30
    -0
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/Test1.cs
  7. +19
    -31
      BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
  8. +1
    -1
      BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs

+ 1
- 2
BPASmartClient.JXJFoodBigStation/App.xaml.cs Целия файл

@@ -46,7 +46,6 @@ namespace BPASmartClient.JXJFoodBigStation
{
base.OnExit(e);
MessageLog.GetInstance.LogSave();
Json<LocalRecipeDataColl>.Save();
ThreadManage.GetInstance().Dispose();
}

@@ -170,7 +169,7 @@ namespace BPASmartClient.JXJFoodBigStation
{
//Config.GetInstance.Init();
//Json<LocaPar>.Read();
Json<LocalRecipeDataColl>.Read();
Json<LocalRecipe>.Read();
}

}


+ 4
- 0
BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj Целия файл

@@ -7,6 +7,10 @@
<UseWPF>true</UseWPF>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.Communication" Version="1.0.19" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" />
<ProjectReference Include="..\BPASmartClient.Modbus\BPASmartClient.Modbus.csproj" />


+ 12
- 0
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Read.cs Целия файл

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

namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
internal class DB_Read
{
}
}

+ 146
- 0
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs Целия файл

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

namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
public class DB_Write
{
/// <summary>
/// 上位机 到 PLC的心跳
/// </summary>
public bool HeartBeat { get; set; }
/// <summary>
/// 配方锁定(暂时不使用)
/// </summary>
public bool RecipeLock { get; set; }
/// <summary>
/// 配方清零
/// </summary>
public bool RecipeReset { get; set; }
/// <summary>
/// 配方1下发完成
/// </summary>
public bool Recipe1IssuedFinish { get; set; }
/// <summary>
/// 配方2下发完成
/// </summary>
public bool Recipe2IssuedFinish { get; set; }
/// <summary>
/// 配方3下发完成
/// </summary>
public bool Recipe3IssuedFinish { get; set; }
/// <summary>
/// 配方4下发完成
/// </summary>
public bool Recipe4IssuedFinish { get; set; }
/// <summary>
/// AGV在托盘1到位
/// </summary>
public bool Tray1InPlace { get; set; }
/// <summary>
/// AGV在托盘2到位
/// </summary>
public bool Tray2InPlace { get; set; }
/// <summary>
/// AGV在托盘3到位
/// </summary>
public bool Tray3InPlace { get; set; }
/// <summary>
/// AGV在托盘4到位
/// </summary>
public bool Tray4InPlace { get; set; }
/// <summary>
/// AGV在托盘5到位
/// </summary>
public bool Tray5InPlace { get; set; }
/// <summary>
/// 配方编码
/// </summary>
public bool RecipeCode { get; set; }
/// <summary>
/// 托盘编码
/// </summary>
public bool TrayCode { get; set; }
public bool Bareel1Bin1SetWeight { get; set; }
public bool Bareel1Bin2SetWeight { get; set; }
public bool Bareel1Bin3SetWeight { get; set; }
public bool Bareel1Bin4SetWeight { get; set; }
public bool Bareel1Bin5SetWeight { get; set; }
public bool Bareel1Bin6SetWeight { get; set; }
public bool Bareel1Bin7SetWeight { get; set; }
public bool Bareel1Bin8SetWeight { get; set; }
public bool Bareel1Bin9SetWeight { get; set; }
public bool Bareel1Bin10SetWeight { get; set; }
public bool Bareel1Bin11SetWeight { get; set; }
public bool Bareel1Bin12SetWeight { get; set; }
public bool Bareel1Bin13SetWeight { get; set; }
public bool Bareel1Bin14SetWeight { get; set; }


public bool Bareel2Bin1SetWeight { get; set; }
public bool Bareel2Bin2SetWeight { get; set; }
public bool Bareel2Bin3SetWeight { get; set; }
public bool Bareel2Bin4SetWeight { get; set; }
public bool Bareel2Bin5SetWeight { get; set; }
public bool Bareel2Bin6SetWeight { get; set; }
public bool Bareel2Bin7SetWeight { get; set; }
public bool Bareel2Bin8SetWeight { get; set; }
public bool Bareel2Bin9SetWeight { get; set; }
public bool Bareel2Bin10SetWeight { get; set; }
public bool Bareel2Bin11SetWeight { get; set; }
public bool Bareel2Bin12SetWeight { get; set; }
public bool Bareel2Bin13SetWeight { get; set; }
public bool Bareel2Bin14SetWeight { get; set; }



public bool Bareel3Bin1SetWeight { get; set; }
public bool Bareel3Bin2SetWeight { get; set; }
public bool Bareel3Bin3SetWeight { get; set; }
public bool Bareel3Bin4SetWeight { get; set; }
public bool Bareel3Bin5SetWeight { get; set; }
public bool Bareel3Bin6SetWeight { get; set; }
public bool Bareel3Bin7SetWeight { get; set; }
public bool Bareel3Bin8SetWeight { get; set; }
public bool Bareel3Bin9SetWeight { get; set; }
public bool Bareel3Bin10SetWeight { get; set; }
public bool Bareel3Bin11SetWeight { get; set; }
public bool Bareel3Bin12SetWeight { get; set; }
public bool Bareel3Bin13SetWeight { get; set; }
public bool Bareel3Bin14SetWeight { get; set; }

public bool Bareel4Bin1SetWeight { get; set; }
public bool Bareel4Bin2SetWeight { get; set; }
public bool Bareel4Bin3SetWeight { get; set; }
public bool Bareel4Bin4SetWeight { get; set; }
public bool Bareel4Bin5SetWeight { get; set; }
public bool Bareel4Bin6SetWeight { get; set; }
public bool Bareel4Bin7SetWeight { get; set; }
public bool Bareel4Bin8SetWeight { get; set; }
public bool Bareel4Bin9SetWeight { get; set; }
public bool Bareel4Bin10SetWeight { get; set; }
public bool Bareel4Bin11SetWeight { get; set; }
public bool Bareel4Bin12SetWeight { get; set; }
public bool Bareel4Bin13SetWeight { get; set; }
public bool Bareel4Bin14SetWeight { get; set; }

public bool Bareel5Bin1SetWeight { get; set; }
public bool Bareel5Bin2SetWeight { get; set; }
public bool Bareel5Bin3SetWeight { get; set; }
public bool Bareel5Bin4SetWeight { get; set; }
public bool Bareel5Bin5SetWeight { get; set; }
public bool Bareel5Bin6SetWeight { get; set; }
public bool Bareel5Bin7SetWeight { get; set; }
public bool Bareel5Bin8SetWeight { get; set; }
public bool Bareel5Bin9SetWeight { get; set; }
public bool Bareel5Bin10SetWeight { get; set; }
public bool Bareel5Bin11SetWeight { get; set; }
public bool Bareel5Bin12SetWeight { get; set; }
public bool Bareel5Bin13SetWeight { get; set; }
public bool Bareel5Bin14SetWeight { get; set; }
}
}

+ 37
- 19
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs Целия файл

@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BPASmartClient.CustomResource.Pages.Model;
using System.Threading.Tasks;
using BPASmartClient.S7Net;

@@ -19,7 +20,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
//var res1 = HK_PLC_S7.ReadClass<DB_Write>(99);
//var res1 = HK_PLC_S7.Read<String>("DB46.DBX10.0");
var res = HK_PLC_S7.ReadClass<Test1>(46);
int a = 1;
}),"信号收发处理");
}
}
@@ -32,31 +36,45 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
if (recipe != null)
{
string recipecode = "MW4040";
string recipeTrayCode = "MW4042";
short recipecode1 = Convert.ToInt16(recipe.RecipeCode);
HK_PLC_S7.Write<short>(recipecode, recipecode1);
HK_PLC_S7.Write<short>(recipeTrayCode, (short)recipe.TrayCode);
for (int barrel = 1; barrel < 6; barrel++)
{
for (int loc = 1; loc < 13; loc++)
if (barrel != 3)
{
int index = Array.FindIndex(recipe.RawMaterial.ToArray(), p => p.RawMaterialBarrelNum == barrel && p.RawMaterialLocation == loc);
if (barrel >= 3)//PLC没有3号桶的重量位置,故4,5号桶地址向前偏移48个位置
for (int loc = 1; loc < 13; loc++)
{
if (index != -1)
int index = Array.FindIndex(recipe.RawMaterial.ToArray(), p => p.RawMaterialBarrelNum == barrel && p.RawMaterialLocation == loc);
if (barrel >= 3)//PLC没有3号桶的重量位置,故4,5号桶地址向前偏移48个位置
{
HK_PLC_S7.Write<float>("MD" + 4120 + (loc - 1) * 4 + (barrel - 1 - 1) * 48, recipe.RawMaterial.ElementAt(index).RawMaterialWeight);
if (index != -1)
{
string address = "MD" + (4120 + (loc - 1) * 4 + (barrel - 1 - 1) * 48);
HK_PLC_S7.Write<float>(address, recipe.RawMaterial.ElementAt(index).RawMaterialWeight);
MessageLog.GetInstance.ShowRunLog($"配方数据下发完成,地址:{address},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}");
}
else//不存在的原料信息,重量写0
{
string address = "MD" + (4120 + (loc - 1) * 4 + (barrel - 1 - 1) * 48);
HK_PLC_S7.Write<float>(address, 0);
}
}
else//不存在的原料信息,重量写0
else
{
HK_PLC_S7.Write<float>("MD" + 4120 + (loc - 1) * 4 + (barrel - 1 - 1) * 48, 0);
}
}
else
{
if (index != -1)
{
HK_PLC_S7.Write<float>("MD" + 4120 + (loc - 1) * 4 + (barrel - 1) * 48, recipe.RawMaterial.ElementAt(index).RawMaterialWeight);
}
else//不存在的原料信息,重量写0
{
HK_PLC_S7.Write<float>("MD" + 4120 + (loc - 1) * 4 + (barrel - 1) * 48, 0);
if (index != -1)
{
string address = "MD" + (4120 + (loc - 1) * 4 + (barrel - 1) * 48);
HK_PLC_S7.Write<float>(address, recipe.RawMaterial.ElementAt(index).RawMaterialWeight);
MessageLog.GetInstance.ShowRunLog($"配方数据下发完成,地址:{address},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}");
}
else//不存在的原料信息,重量写0
{
string address = "MD" + (4120 + (loc - 1) * 4 + (barrel - 1) * 48);
HK_PLC_S7.Write<float>(address, 0);
}
}
}
}


+ 30
- 0
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/Test1.cs Целия файл

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

namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
internal class Test1
{
public string[] name1 { get; set; } = new string[8];
public string[] name2 { get; set; }=new string[8];
/*public string name3 { get; set; }
public string name4 { get; set; }
public string name5 { get; set; }
public string name6 { get; set; }
public string name7 { get; set; }
public string name8 { get; set; }
public string name9 { get; set; }
public string name10 { get; set; }
public string name11 { get; set; }
public string name12 { get; set; }
public string name13 { get; set; }
public string name14 { get; set; }
public string name15 { get; set; }
public string name16 { get; set; }
public string name17 { get; set; }
public string name18 { get; set; }*/
}
}

+ 19
- 31
BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs Целия файл

@@ -52,6 +52,18 @@ namespace BPASmartClient.JXJFoodBigStation.Model
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>();
@@ -114,6 +126,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model
if (o !=null && o is RecipeData a)
{
Json<LocalRecipeDataColl>.Data.Recipes.Add(a);
foreach (var item in Json<LocalRecipeDataColl>.Data.Recipes.ElementAt(0).RawMaterial)
{
item.RawMaterialLocation = Convert.ToInt32(item.RawMaterialName);
}
}
}), "ManualSendRecipe", true);
RecipeQueue.Clear();
@@ -293,35 +309,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
if (BigStation.RecipeDosingStatus == 2)
{
for (int i = 0; i < 12; i++)
{
if (i >= 0 && i < 8)
{
if (HKDevice.HK_PLC_S7.Read<bool>("M5008." + (i)))//根据配料完成信号,
{
int a = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == (i+1));
if (a >= 0)
{
int barrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(a).RawMaterialBarrelNum;
string address = "MD" + 5060 + i * 4 + (barrelNum - 1) * 48;
RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(a).Laying_Off_Weight = HKDevice.HK_PLC_S7.Read<float>(address);//料仓配料完成后的出料重量
}
}
}
else
{
if (HKDevice.HK_PLC_S7.Read<bool>("M5009." + (i - 8)))
{
int a = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
if (a >= 0)
{
int barrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(a).RawMaterialBarrelNum;
string address = "MD" + 5060 + i * 4 + (barrelNum - 1) * 48;
RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(a).Laying_Off_Weight = HKDevice.HK_PLC_S7.Read<float>(address);
}
}
}
}
if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read<bool>("M5007.0")))
{
BigStation.RecipeDosingStatus = 3;
@@ -454,13 +441,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// </summary>
private void ReadPLCDeviceInfo()
{
for (int i = 0; i < 12; i++)
/*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);
}
}*/
}
}
}

+ 1
- 1
BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs Целия файл

@@ -47,7 +47,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
if (name == null)
{
go:
string recipeCode = new Random().Next(10000, 99999).ToString();
string recipeCode = new Random().Next(10000, 32767).ToString();
var res = Json<LocalRecipe>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == recipeCode);
if (res == null)
{


Зареждане…
Отказ
Запис