Browse Source

吉香居代码更新

master
pengliangyang 1 year ago
parent
commit
ac682702c2
23 changed files with 504 additions and 61 deletions
  1. +1
    -3
      BPASmartClient.JXJFoodBigStation/App.config
  2. +2
    -0
      BPASmartClient.JXJFoodBigStation/App.xaml.cs
  3. +1
    -1
      BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs
  4. +14
    -2
      BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
  5. +1
    -1
      BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs
  6. +9
    -1
      BPASmartClient.JXJFoodSmallStation/App.xaml.cs
  7. +4
    -0
      BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj
  8. +2
    -0
      BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs
  9. +3
    -2
      BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs
  10. +18
    -0
      BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcManualComm.cs
  11. +81
    -25
      BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
  12. +16
    -9
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs
  13. +0
    -1
      BPASmartClient.JXJFoodSmallStation/View/HardwareStatusView.xaml
  14. +173
    -0
      BPASmartClient.JXJFoodSmallStation/View/ManualCommView.xaml
  15. +29
    -0
      BPASmartClient.JXJFoodSmallStation/View/ManualCommView.xaml.cs
  16. +32
    -5
      BPASmartClient.JXJFoodSmallStation/View/ManualControlView.xaml
  17. +8
    -0
      BPASmartClient.JXJFoodSmallStation/ViewModel/DeviceListViewModel.cs
  18. +5
    -0
      BPASmartClient.JXJFoodSmallStation/ViewModel/HardwareStatusViewModel.cs
  19. +53
    -0
      BPASmartClient.JXJFoodSmallStation/ViewModel/ManualCommViewModel.cs
  20. +29
    -6
      BPASmartClient.JXJFoodSmallStation/ViewModel/ManualControlViewModel.cs
  21. +1
    -1
      BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs
  22. +1
    -1
      BPASmartClient.Modbus/ModbusTcp.cs
  23. +21
    -3
      BPASmartClient.S7Net/SiemensHelper.cs

+ 1
- 3
BPASmartClient.JXJFoodBigStation/App.config View File

@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="HKPlc_IP" value="192.168.0.20"/>
<add key="HKPlc_Port" value="502"/>
<add key="HKPlc_IP" value="107.107.2.17"/>
<add key="Siemens_IP" value="192.168.0.30"/>
<add key="Siemens_Port" value="502"/>
</appSettings>
</configuration>

+ 2
- 0
BPASmartClient.JXJFoodBigStation/App.xaml.cs View File

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

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

}


+ 1
- 1
BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs View File

@@ -39,6 +39,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// <summary>
/// 是否处于手动下发配方
/// </summary>
public bool IsAllowManual { get; set; }
public bool IsAllowManual { get; set; } = true;
}
}

+ 14
- 2
BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs View File

@@ -91,11 +91,12 @@ 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)
{
HKDevice.Init();
MessageLog.GetInstance.ShowRunLog("海科plc连接成功");
}
if (SiemensDevice.IsConnected)
{
@@ -106,11 +107,22 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{

}
ActionManage.GetInstance.CancelRegister("ManualSendRecipe");
ActionManage.GetInstance.Register(new Action<Object>((o) =>
{
if (o !=null && o is RecipeData a)
{
Json<LocalRecipeDataColl>.Data.Recipes.Add(a);
}
}), "ManualSendRecipe", true);
RecipeQueue.Clear();


//Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
ThreadManage.GetInstance().StartLong(new Action(() =>
{
ReadPLCDeviceInfo();
//ReadPLCDeviceInfo();
ReceviceData();
RecipeInfoToHKPLC();
Thread.Sleep(10);


+ 1
- 1
BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs View File

@@ -38,7 +38,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
//配方下发逻辑
var res = Recipes.FirstOrDefault(p => p.RecipeName == recipeName);
if (res != null)
ActionManage.GetInstance.Send("手动下发本地配方", res);
ActionManage.GetInstance.Send("ManualSendRecipe", res);
}
});
}


+ 9
- 1
BPASmartClient.JXJFoodSmallStation/App.xaml.cs View File

@@ -125,11 +125,19 @@ namespace BPASmartClient.JXJFoodSmallStation
ObservableCollection<SubMenumodel> ManualControl = new ObservableCollection<SubMenumodel>();
ManualControl.Add(new SubMenumodel()
{
SubMenuName = "手动控制",
SubMenuName = "手动控制硬件",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
AssemblyName = "BPASmartClient.JXJFoodSmallStation",
ToggleWindowPath = "View.ManualControlView"
});
ManualControl.Add(new SubMenumodel()
{
SubMenuName = "手动控制信号",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
AssemblyName = "BPASmartClient.JXJFoodSmallStation",
ToggleWindowPath = "View.ManualCommView"

});

MenuManage.GetInstance.menuModels.Add(new MenuModel()
{


+ 4
- 0
BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj View File

@@ -26,6 +26,10 @@
<Page Update="View\DeviceListView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="View\ManualCommView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="View\SiemensRecipeReceiveView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>


+ 2
- 0
BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs View File

@@ -14,6 +14,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
private volatile static GVL_SmallStation SmallStation;
public static GVL_SmallStation GetInstance => SmallStation ?? (SmallStation = new GVL_SmallStation());
private GVL_SmallStation() { }
public bool HeartBeatToPlc { get; set; } = false;
public bool HeartBeatFromPlc { get; set; } = false;
/// <summary>
/// 是否允许西门子下发配方
/// </summary>


+ 3
- 2
BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs View File

@@ -19,14 +19,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
{
if (IsConnected)
{
ThreadManage.GetInstance().StartLong(new Action(() =>
/*ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (!IsConnected)
{
MessageLog.GetInstance.ShowRunLog("海科PLC断开连接");
}
Thread.Sleep(10);
}),"信号收发处理");
}),"信号收发处理");*/
}
}
/// <summary>


+ 18
- 0
BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcManualComm.cs View File

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

namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
{
public class PlcManualComm
{
public int SerialNum { get; set;}
public string Address { get; set; }
public string Describe { get; set; }
public string NowValue { get; set; }
public string SetValue { get; set; }

}
}

+ 81
- 25
BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs View File

@@ -106,57 +106,88 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
Json<RemoteRecipeDataColl>.Data.Recipes.Add(recipe);
}
}), "LocalSimulationRecipeIssue", true);
string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"];
string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
string WindSend_PLC_IP = ConfigurationManager.AppSettings["WindSend_IP"];
try
{
//HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP);
HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_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)
{
HKDevice.Init();
MessageLog.GetInstance.ShowUserLog("海科plc连接成功,并初始化完成");
MessageLog.GetInstance.ShowRunLog("海科plc连接成功,并初始化完成");
}
if (SiemensDevice.IsConnected)
{
SiemensDevice.Init();
MessageLog.GetInstance.ShowUserLog("西门子plc连接成功,并初始化完成");
MessageLog.GetInstance.ShowRunLog("西门子plc连接成功,并初始化完成");
}
if (WindSendDevice.IsConnected)
{
WindSendDevice.Init();
MessageLog.GetInstance.ShowUserLog("风送plc连接成功,并初始化完成");
MessageLog.GetInstance.ShowRunLog("风送plc连接成功,并初始化完成");
}
}
catch(Exception ex)
{
}
ActionManage.GetInstance.CancelRegister("SystemStart");
ActionManage.GetInstance.Register(new Action(() =>
{
HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.0", true);
}), "SystemStart", true);
ActionManage.GetInstance.CancelRegister("SystemStop");
ActionManage.GetInstance.Register(new Action(() =>
{
HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.0", false);
}), "SystemStop", true);
ActionManage.GetInstance.CancelRegister("SystemPause");
ActionManage.GetInstance.Register(new Action(() =>
{
HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.2", true);
}), "SystemPause", true);
ActionManage.GetInstance.CancelRegister("SystemReset");
ActionManage.GetInstance.Register(new Action(() =>
{
HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.2", false);
}), "SystemReset", true);

ActionManage.GetInstance.CancelRegister("SystemAutoMode");
ActionManage.GetInstance.Register(new Action(() =>
{
HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.1", false);
}), "SystemAutoMode", true);
ActionManage.GetInstance.CancelRegister("SystemDebugMode");
ActionManage.GetInstance.Register(new Action(() =>
{
HKDevice.HK_PLC_S7.Write<bool>("DB44.DBX0.1", true);
}), "SystemDebugMode", true);
RecipeQueue.Clear();
//Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
ThreadManage.GetInstance().StartLong(new Action(() =>
{
HeartHKPlc();
ReceviceData();
RecipeInfoToHKPLC();
Thread.Sleep(10);
}), "西门子配发下发流程处理", true);
ThreadManage.GetInstance().StartLong(new Action(() =>
/* ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (SiemensDevice.IsConnected && HKDevice.IsConnected)
{
/*AgvGetInDelivery();
AgvGetInPickUp();*/
*//*AgvGetInDelivery();
AgvGetInPickUp();*//*
}
Thread.Sleep(10);
}), "AGV进站送取货", true);
}), "AGV进站送取货", true);*/
ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (HKDevice.IsConnected)
{
GetStatus();
//GetStatus();
ManualOpen();
ManualClose();
}
@@ -172,15 +203,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
for (int i = 0; i < 7; i++)
{
GVL_SmallStation.GetInstance.Cylinder_JackInfo[i + 8] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX0." + i);
}
}/*
ActionManage.GetInstance.Register(new Action(() =>
{
HKDevice.HK_PLC_S7.Write<bool>("M10.0", true);
}), "ManualEStop", true);

ActionManage.GetInstance.Register(new Action(() =>
{
HKDevice.HK_PLC_S7.Write<bool>("M10.0", false);
}), "ManualEReset", true);
}), "ManualEReset", true);*/
}
private void ManualOpen()
{
@@ -580,9 +612,19 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
break;
}
}
/// <summary>
/// 将配方添加到配方队列中
/// </summary>
private void HeartHKPlc()
{
if (HKDevice.IsConnected)
{
GVL_SmallStation.GetInstance.HeartBeatToPlc = !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");

}
}
/// <summary>
/// 将配方添加到配方队列中
/// </summary>
private void ReceviceData()
{
RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
@@ -674,7 +716,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
GVL_SmallStation.GetInstance.RecipeStatusID = 2;
MessageLog.GetInstance.ShowRunLog($"托盘1,{ recipeName}plc端 配方接收完成");
}
if (GVL_SmallStation.GetInstance.RecipeStatusID == 2)
if (GVL_SmallStation.GetInstance.RecipeStatusID == 2)
{
if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0")))
{
@@ -760,16 +802,23 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
MessageLog.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成");
int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.CutWeightFeedback;
string info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
MessageLog.GetInstance.ShowRunLog(info);
bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
if (info)
{
MessageLog.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送成功");
}
else
{
MessageLog.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送失败");
}
if (i >= 1 && i <= 8)
{
string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true);
string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
MessageLog.GetInstance.ShowRunLog(commInfo);
}
else if (i >= 9 && i <= 15)
{
string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true);
string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
MessageLog.GetInstance.ShowRunLog(commInfo1);
}
GVL_SmallStation.GetInstance.DosingTray1 = false;
@@ -884,7 +933,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
if (res > 0 && res is float loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeightW;
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 0)
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
@@ -923,16 +972,23 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
MessageLog.GetInstance.ShowRunLog($"柔性味魔方,托盘2,配方:{recipeName},{i}号仓,配料完成");
int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.CutWeightFeedback;
string info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
MessageLog.GetInstance.ShowRunLog(info);
bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
if (info)
{
MessageLog.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送成功");
}
else
{
MessageLog.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送失败");
}
if (i >= 1 && i <= 8)
{
string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true);
string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
MessageLog.GetInstance.ShowRunLog(commInfo);
}
else if (i >= 9 && i <= 15)
{
string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true);
string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
MessageLog.GetInstance.ShowRunLog(commInfo1);
}
GVL_SmallStation.GetInstance.DosingTray2 = false;


+ 16
- 9
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs View File

@@ -45,7 +45,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
TopDeviceCurrentStatuses.ElementAt(TopIndex).DeviceNum = DeviceLists.ElementAt(i).Value.deviceStatus.DeviceNum;
TopDeviceCurrentStatuses.ElementAt(TopIndex).RunStatus = DeviceLists.ElementAt(i).Value.deviceStatus.RunStatus;
}

if (BottomIndex >= 0 && BottomIndex < BottomDeviceCurrentStatuses.Count)
{
BottomDeviceCurrentStatuses.ElementAt(BottomIndex).Weight = DeviceLists.ElementAt(i).Value.deviceStatus.WeightFeedback;
@@ -296,6 +295,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model

public void Init(string DeviceName)
{
modbusTcp.Show += new Action<string>((s) =>
{
if (s != null) MessageLog.GetInstance.ShowRunLog(s);
});

modbusTcp.ShowEx += new Action<string>((s) =>
{
if (s != null) MessageLog.GetInstance.ShowRunLog(s);
});
this.DeviceName = DeviceName;
AlarmHelper<AlarmInfo>.Init();
if (modbusTcp.Connected)
@@ -309,11 +317,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
// if (ushortValue.Length >= 1) deviceStatus.RunStatus = ushortValue[0];
//}
deviceStatus.RunStatus = (ushort)this.modbusTcp.ReadShort(DeviceAddress.RunStatus); //获取设备运行状态
deviceStatus.WeightFeedback = (float)this.modbusTcp.GetUint(DeviceAddress.WeightFeedback);//获取设备料仓剩余重量
deviceStatus.WeightFeedback = (Int16)this.modbusTcp.GetUint(DeviceAddress.WeightFeedback);//获取设备料仓剩余重量
deviceStatus.NowWeightFeedback = (float)this.modbusTcp.GetUint(DeviceAddress.CutWeightFeedback);//获取下料重量
deviceStatus.DeviceNum = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceNum);//获取设备编号
deviceStatus.DeviceAlarmCode = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceAlarmCode);//获取设备故障编码

AlarmHelper<AlarmInfo>.Alarm.EStop1 = deviceStatus.DeviceAlarmCode.Get16bitValue(1);
AlarmHelper<AlarmInfo>.Alarm.Servo = deviceStatus.DeviceAlarmCode.Get16bitValue(2);
AlarmHelper<AlarmInfo>.Alarm.Inverter = deviceStatus.DeviceAlarmCode.Get16bitValue(3);
@@ -332,7 +339,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
this.modbusTcp.SetString(DeviceAddress.DeviceName, name);
}

public string StatusReset()
public bool StatusReset()
{
return this.modbusTcp.Write(DeviceAddress.FinfishStatus, (ushort)1);
//var res = modbusTcp.Read(DeviceAddress.RunStatus);
@@ -348,14 +355,14 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
if (modbusTcp.Connected)
{
modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方量
string returnValue = modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入
if (returnValue.Substring(0, 2) == "成功")
bool returnValue = modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入
if (returnValue)
{
MessageLog.GetInstance.ShowRunLog("发送成功" + returnValue);
MessageLog.GetInstance.ShowRunLog($"发送成功" + DeviceAddress.Start);
}
else
{
MessageLog.GetInstance.ShowRunLog("发送失败" + returnValue);
MessageLog.GetInstance.ShowRunLog($"发送失败" + DeviceAddress.Start);
}
//配料设备参数写入
var res = Json<DevicePar>.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName);
@@ -369,7 +376,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
modbusTcp.SetUint(DeviceAddress.SiloUpperLimitWeight, (uint)res.SiloUpperLimitWeight);
modbusTcp.SetUint(DeviceAddress.LowerLimitWeightOfSilo, (uint)res.LowerLimitWeightOfSilo);
modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed * 100);
MessageLog.GetInstance.ShowRunLog($"参数下发完成");
MessageLog.GetInstance.ShowRunLog($"{res.MaterialName},参数下发完成");
}
}
}


+ 0
- 1
BPASmartClient.JXJFoodSmallStation/View/HardwareStatusView.xaml View File

@@ -107,7 +107,6 @@
Text="{Binding RunStatus}" />

</StackPanel>

<Image
Grid.RowSpan="2"
Source="/BPASmartClient.CustomResource;component/Image/光柱.png"


+ 173
- 0
BPASmartClient.JXJFoodSmallStation/View/ManualCommView.xaml View File

@@ -0,0 +1,173 @@
<UserControl
x:Class="BPASmartClient.JXJFoodSmallStation.View.ManualCommView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.JXJFoodSmallStation.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:vm="clr-namespace:BPASmartClient.JXJFoodSmallStation.ViewModel"
d:DesignHeight="850"
d:DesignWidth="1200"
mc:Ignorable="d">

<UserControl.DataContext>
<vm:ManualCommViewModel />
</UserControl.DataContext>

<UserControl.Resources>
<Style x:Key="radioButtonStyle" TargetType="RadioButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Grid Name="gr" Opacity="0.8">
<ContentControl
Margin="{TemplateBinding Margin}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Content="{TemplateBinding Content}"
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding Foreground}" />
<Image
Name="image"
Source="/BPASmartClient.CustomResource;component/Image/边框线.png"
Stretch="Fill" />

</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="False">
<Setter TargetName="image" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/边框线.png" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="image" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/透明背景.png" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="gr" Property="Opacity" Value="1" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>

<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>
<!--#region 表格标题栏设置-->
<Grid
Grid.Row="0"
Margin="0,10,0,0"
Background="#ff0C255F">

<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<TextBlock Text="序号" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Aqua"/>
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>
<TextBlock Grid.Column="1" Text="地址" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Aqua" />
<Grid Grid.Column="2">
<TextBlock Text="描述" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Aqua" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>
<TextBlock Grid.Column="3" Text="当前值" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Aqua" />
<Grid Grid.Column="4">
<TextBlock Text="设定值" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Aqua" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>
<TextBlock Grid.Column="5" Text="功能操作" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Aqua" />
<Border Grid.ColumnSpan="10" BorderThickness="1,0,1,0" />
</Grid>
<Grid Grid.Row="1">
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" >
<ItemsControl ItemsSource="{Binding PlcInfo}" Foreground="Aqua">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Name="gr" >
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding SerialNum}" />
<Border
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>
<TextBlock
Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding Address }" />

<Grid Grid.Column="2">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding Describe}" />
<Border
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>

<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
Grid.Column="3"
Text="{Binding NowValue}" />
<Grid Grid.Column="4">
<TextBox
Text="{Binding SetValue}" />
<Border
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>
<Grid Grid.Column="5">
<pry:IcoButton
Command="{Binding EStopCommand}"
Grid.Column="0"
Margin="40,5,40,5"
Content="设置"
FontSize="20"
Foreground="Aqua"
Style="{StaticResource IcoButtonStyle}" />
<Border
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>

<Border
Grid.ColumnSpan="10"
BorderThickness="1,0,1,1" />

</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Grid>
</UserControl>

+ 29
- 0
BPASmartClient.JXJFoodSmallStation/View/ManualCommView.xaml.cs View File

@@ -0,0 +1,29 @@
using BPASmartClient.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPASmartClient.JXJFoodSmallStation.View
{
/// <summary>
/// DeviceMaterialParView.xaml 的交互逻辑
/// </summary>
public partial class ManualCommView : UserControl
{
public ManualCommView()
{
InitializeComponent();
}
}
}

+ 32
- 5
BPASmartClient.JXJFoodSmallStation/View/ManualControlView.xaml View File

@@ -101,19 +101,37 @@
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<pry:IcoButton
Command="{Binding EStopCommand}"
Command="{Binding SystemStartCommand}"
Grid.Column="0"
Margin="15"
Content="急停"
Margin="5,30"
Content="启动"
FontSize="40"
Foreground="Aqua"
Style="{StaticResource IcoButtonStyle}" />
<pry:IcoButton
Command="{Binding EResetCommand}"
Command="{Binding SystemStopCommand}"
Grid.Column="1"
Margin="15"
Margin="5,30"
Content="停止"
FontSize="40"
Foreground="Aqua"
Style="{StaticResource IcoButtonStyle}" />
<pry:IcoButton
Command="{Binding SystemPauseCommand}"
Grid.Column="2"
Margin="5,30"
Content="暂停"
FontSize="40"
Foreground="Aqua"
Style="{StaticResource IcoButtonStyle}" />
<pry:IcoButton
Command="{Binding SystemResetCommand}"
Grid.Column="3"
Margin="5,30"
Content="复位"
FontSize="40"
Foreground="Aqua"
@@ -171,6 +189,7 @@
Grid.Row="1"
Grid.Column="0"
Command="{Binding StartCommand}"
CommandParameter="{Binding }"
Content="启动"
FontSize="16"
Foreground="Aqua"
@@ -180,6 +199,7 @@
Grid.Column="1"
Margin="10"
Command="{Binding CloseCommand}"
CommandParameter="{Binding }"
Content="停止"
FontSize="16"
Foreground="Aqua"
@@ -215,6 +235,7 @@
Grid.Column="1"
Margin="10"
Command="{Binding StopCommand}"
CommandParameter="{Binding }"
Content="停止"
FontSize="16"
Foreground="Aqua"
@@ -236,6 +257,7 @@
Grid.Row="1"
Grid.Column="0"
Command="{Binding StartCommand}"
CommandParameter="{Binding }"
Content="启动"
FontSize="16"
Foreground="Aqua"
@@ -245,6 +267,7 @@
Grid.Column="1"
Margin="10"
Command="{Binding CloseCommand}"
CommandParameter="{Binding }"
Content="停止"
FontSize="16"
Foreground="Aqua"
@@ -268,6 +291,7 @@
Grid.Row="1"
Grid.Column="0"
Command="{Binding StartCommand}"
CommandParameter="{Binding }"
Content="启动"
FontSize="16"
Foreground="Aqua"
@@ -277,6 +301,7 @@
Grid.Column="1"
Margin="10"
Command="{Binding CloseCommand}"
CommandParameter="{Binding }"
Content="停止"
FontSize="16"
Foreground="Aqua"
@@ -298,6 +323,7 @@
Grid.Row="1"
Grid.Column="0"
Command="{Binding StartCommand}"
CommandParameter="{Binding }"
Content="启动"
FontSize="16"
Foreground="Aqua"
@@ -307,6 +333,7 @@
Grid.Column="1"
Margin="10"
Command="{Binding CloseCommand}"
CommandParameter="{Binding }"
Content="停止"
FontSize="16"
Foreground="Aqua"


+ 8
- 0
BPASmartClient.JXJFoodSmallStation/ViewModel/DeviceListViewModel.cs View File

@@ -28,6 +28,11 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
}
});
devices = DeviceInquire.GetInstance.devices;
foreach (var device in devices)
{
device.Serial = Convert.ToInt32(device.DeviceName.Substring(1, device.DeviceName.Length - 1)) / 10;
}
devices = new ObservableCollection<Devices>(devices.OrderBy(item => item.Serial));
}

public RelayCommand<object> ChangeNameCommand { get; set; }
@@ -38,6 +43,9 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel

public class Devices : ObservableObject
{
public int Serial { get { return _mSerial; } set { _mSerial = value; OnPropertyChanged(); } }
private int _mSerial;

public string IpAddress { get { return _mIpAddress; } set { _mIpAddress = value; OnPropertyChanged(); } }
private string _mIpAddress;



+ 5
- 0
BPASmartClient.JXJFoodSmallStation/ViewModel/HardwareStatusViewModel.cs View File

@@ -18,7 +18,12 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
public HardwareStatusViewModel()
{
TopDeviceCurrentStatuses = DeviceInquire.GetInstance.TopDeviceCurrentStatuses;

BottomDeviceCurrentStatuses = DeviceInquire.GetInstance.BottomDeviceCurrentStatuses;

TopDeviceCurrentStatuses = new ObservableCollection<DeviceCurrentStatus>(TopDeviceCurrentStatuses.OrderByDescending(item => item.DeviceNum));

BottomDeviceCurrentStatuses = new ObservableCollection<DeviceCurrentStatus>(BottomDeviceCurrentStatuses.OrderBy(item => item.DeviceNum));
}

public ObservableCollection<DeviceCurrentStatus> TopDeviceCurrentStatuses { get; set; }


+ 53
- 0
BPASmartClient.JXJFoodSmallStation/ViewModel/ManualCommViewModel.cs View File

@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;
using BPASmartClient.JXJFoodSmallStation.Model;
using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.Input;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.CustomResource.UserControls;
using System.Diagnostics;
using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC;

namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
public class ManualCommViewModel : ObservableObject
{
public ManualCommViewModel()
{
for (int i = 0; i < 8; i++)
{
if (i < 4)
{
PlcInfo.Add(new PlcManualComm()
{
SerialNum = PlcInfo.Count + 1,
Address = "DB3.DBD" + (10 + 4 * i),
Describe = $"托盘1_{i + 1}#桶位置反馈",
});
}
else
{
PlcInfo.Add(new PlcManualComm()
{
SerialNum = PlcInfo.Count + 1,
Address = "DB3.DBD" + (10 + 4 * i),
Describe = $"托盘2_{i-3}#桶位置反馈",
});
}
}
}
public ObservableCollection<PlcManualComm> PlcInfo { get; set; } = new ObservableCollection<PlcManualComm>();

public RelayCommand<object> SetParCommand { get; set; }

public RelayCommand Connect { get; set; }

}
}

+ 29
- 6
BPASmartClient.JXJFoodSmallStation/ViewModel/ManualControlViewModel.cs View File

@@ -78,13 +78,30 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
ActionManage.GetInstance.Send("ManualClose", o);
});
EStopCommand = new RelayCommand(() =>
SystemStartCommand = new RelayCommand(() =>
{
ActionManage.GetInstance.Send("ManualEStop");
ActionManage.GetInstance.Send("SystemStart");
});
EResetCommand = new RelayCommand(() =>
SystemStopCommand = new RelayCommand(() =>
{
ActionManage.GetInstance.Send("ManualEReset");
ActionManage.GetInstance.Send("SystemStop");
});
SystemPauseCommand = new RelayCommand(() =>
{
ActionManage.GetInstance.Send("SystemPause");
});
SystemResetCommand = new RelayCommand(() =>
{
ActionManage.GetInstance.Send("SystemReset");
});

DebugMode = new RelayCommand(() =>
{
ActionManage.GetInstance.Send("SystemDebugMode");
});
AutoMode = new RelayCommand(() =>
{
ActionManage.GetInstance.Send("SystemAutoMode");
});
}

@@ -108,8 +125,14 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel

public RelayCommand<object> Close { get; set; }

public RelayCommand EStopCommand { get; set; }
public RelayCommand EResetCommand { get; set; }
public RelayCommand SystemStartCommand { get; set; }
public RelayCommand SystemStopCommand { get; set; }
public RelayCommand SystemPauseCommand { get; set; }

public RelayCommand SystemResetCommand { get; set; }

public RelayCommand AutoMode { get; set; }
public RelayCommand DebugMode { get; set; }

}



+ 1
- 1
BPASmartClient.JXJFoodSmallStation/ViewModel/NewLocalRecipeViewModel.cs View File

@@ -37,7 +37,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
var res = RawMaterial.FirstOrDefault(p => p.RawMaterialLocation == (int)o);
if (res != null) RawMaterial.Remove(res);
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"{o.ToString()}:原料删除成功!");
//NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"{o.ToString()}:原料删除成功!");
});

AddCommand = new RelayCommand(() =>


+ 1
- 1
BPASmartClient.Modbus/ModbusTcp.cs View File

@@ -567,7 +567,7 @@ namespace BPASmartClient.Modbus
}
catch (Exception ex)
{
MessageLog.GetInstance.Show(ex.ToString());
//MessageLog.GetInstance.Show(ex.ToString());
tcpClient = null;
Connect();
}


+ 21
- 3
BPASmartClient.S7Net/SiemensHelper.cs View File

@@ -58,12 +58,30 @@ namespace BPASmartClient.S7Net
return myPlc?.Read(dataType, db, address, varType, count);
}

public string Write<TValue>(string address, TValue value)
public string Write<TValue>(string address, TValue value,int Retries = 1)
{
if (IsConnected)
{
myPlc?.Write(address, value);
return $"成功,地址:{address},值:{value}";
int count = 0;
if (Retries == 1 || Retries == 0)
{
myPlc?.Write(address, value);
return $"成功,地址:{address},值:{value}";
}
else
{
while (count < Retries)
{
count++;
myPlc?.Write(address, value);
var res = myPlc?.Read(address);
if (res != null && res.ToString() == value.ToString())
{
break;
}
}
return $"成功,发送了{count}次,地址:{address},值:{value}";
}
}
else
{


Loading…
Cancel
Save