Browse Source

Morkf

样式分支
NXX 2 years ago
parent
commit
b4917ce534
10 changed files with 875 additions and 29 deletions
  1. +1
    -1
      BPASmartClient.Business/Plugin/MQTTMgr.cs
  2. +10
    -10
      BPASmartClient.Modbus/ModbusTcp.cs
  3. +8
    -0
      BPASmartClient.MorkBF/BPASmartClient.MorkBF.csproj
  4. +180
    -14
      BPASmartClient.MorkBF/Control_MorkBF.cs
  5. +291
    -1
      BPASmartClient.MorkBF/GVL_MorkBF.cs
  6. +27
    -1
      BPASmartClient.MorkBF/VIew/DebugView.xaml
  7. +242
    -0
      BPASmartClient.MorkBF/VIew/Monitor.xaml
  8. +28
    -0
      BPASmartClient.MorkBF/VIew/Monitor.xaml.cs
  9. +63
    -2
      BPASmartClient.MorkBF/ViewModel/DebugViewModel.cs
  10. +25
    -0
      BPASmartClient.MorkBF/ViewModel/MonitorViewModel.cs

+ 1
- 1
BPASmartClient.Business/Plugin/MQTTMgr.cs View File

@@ -64,7 +64,7 @@ namespace BPASmartClient.Business
string deviceId = deviceConfig[0].deviceModels[0].DeviceId;
clientId = Plugin.GetInstance().GetPlugin<ConfigMgr>().ClientId;
//MQTT 初始化
mqttProxy.Connect(MqttServerAccount.UserName, MqttServerAccount.Password, MqttServerConfig.Host, MqttServerConfig.Port, "ClientId:" + clientId + "DeviceId:" + deviceId + Guid.NewGuid().ToString());
mqttProxy.Connect(MqttServerAccount.UserName, MqttServerAccount.Password, MqttServerConfig.Host, MqttServerConfig.Port, "ClientId:" + clientId + "DeviceId:" + deviceId + Guid.NewGuid().ToString());

ThreadManage.GetInstance().Start(() =>
{


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

@@ -118,7 +118,15 @@ namespace BPASmartClient.Modbus
if (address.Length > 0)
{
address = address.Trim();
if (address.ToUpper().Contains("M") && address.Length >= 4)
if (address.ToUpper().Contains("GM") && address.Length >= 3)
{
var res = address.Remove(0, 2);
if (res != null && res.Length > 0)
{
return int.Parse(res) + 4096;
}
}
else if (address.ToUpper().Contains("M") && address.Length >= 4)
{
var res = address.Substring(1).Split('.');
if (res != null && res.Length == 2)
@@ -132,15 +140,7 @@ namespace BPASmartClient.Modbus
}
}
}
else if (address.ToUpper().Contains("GM") && address.Length >= 3)
{
var res = address.Remove(0,2);
if (res != null && res.Length > 0)
{
return int.Parse(res) + 4096;
}
}

else if (address.ToUpper().Contains("GI") && address.Length >= 3)
{
var res = address.Remove(0, 2);


+ 8
- 0
BPASmartClient.MorkBF/BPASmartClient.MorkBF.csproj View File

@@ -11,7 +11,15 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmartClient.Business\BPASmartClient.Business.csproj" />
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" />
</ItemGroup>

<ItemGroup>
<Page Update="VIew\Monitor.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
</ItemGroup>

</Project>

+ 180
- 14
BPASmartClient.MorkBF/Control_MorkBF.cs View File

@@ -3,6 +3,7 @@ using BPASmartClient.Device;
using BPASmartClient.EventBus;
using BPASmartClient.Helper;
using BPASmartClient.Model;
using BPASmartClient.MorkBF.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -21,8 +22,8 @@ namespace BPASmartClient.MorkBF

public override void DoMain()
{

MonitorViewModel.DeviceId = DeviceId;
CommandRegist();//调试
ServerInit();
DataParse();//数据解析
@@ -115,7 +116,7 @@ namespace BPASmartClient.MorkBF
ActionManage.GetInstance.Register(RobotProgramStart, "RobotProgramStart");//程序启动
ActionManage.GetInstance.Register(Robot_Pot1AllowInMaterail, "Robot_Pot1AllowInMaterail");//1号炒锅允许机器人投料
ActionManage.GetInstance.Register(Robot_Pot1OutFoodInSlowDown, "Robot_Pot1OutFoodInSlowDown");//1号炒锅出餐倒料到减速位
ActionManage.GetInstance.Register(Robot_Pot1OutFoodInSlowDown, "Robot_Pot1OutFoodInSlowDown");//1号炒锅出餐倒料完成
ActionManage.GetInstance.Register(Robot_Pot1OutFood, "Robot_Pot1OutFoodInSlowDown");//1号炒锅出餐倒料完成
ActionManage.GetInstance.Register(Robot_Pot2AllowInMaterail, "Robot_Pot2AllowInMaterail");//2号炒锅允许机器人投料
ActionManage.GetInstance.Register(Robot_Pot2OutFoodInSlowDown, "Robot_Pot2OutFoodInSlowDown");//2号炒锅出餐倒料到减速位
ActionManage.GetInstance.Register(Robot_Pot2OutFood, "Robot_Pot2OutFood");//2号炒锅出餐倒料完成
@@ -163,7 +164,122 @@ namespace BPASmartClient.MorkBF

public override void ReadData()
{
GetStatus("M20.0",new Action<object>((o)=>
{
if (o == null) return;
if(o is bool[] values&&values.Length == 19)
{
morkBF.FirePot1_InitCompleted = values[0];
morkBF.FirePot1_IsAuto = values[1];
morkBF.FirePot1_Emergencystop = values[2];
morkBF.FirePot1_MealTubExist = values[3];
morkBF.FirePot1_VegetablesTub1Exist = values[4];
morkBF.FirePot1_VegetablesTub2Exist = values[5];
morkBF.FirePot1_Seasoning1Exist = values[6];
morkBF.FirePot1_Seasoning2Exist = values[7];
morkBF.FirePot1_Accessories1Exist = values[8];
morkBF.FirePot1_Accessories2Exist = values[9];
morkBF.FirePot1_OutFoodTubExist = values[10];
morkBF.FirePot1_OnOrigin = values[11];
morkBF.FirePot1_FirePosition1 = values[12];
morkBF.FirePot1_FirePosition2 = values[13];
morkBF.FirePot1_FirePosition3 = values[14];
morkBF.FirePot1_FirePosition4 = values[15];
morkBF.FirePot1_PotOnOutFoodPosition = values[16];
morkBF.FirePot1_PotOnIntoFoodPosition = values[17];
morkBF.FirePot1_PotOnCleanPosition = values[18];

}
}),0);

GetStatus("VW120", new Action<object>((o) =>
{
if (o == null) return;
if (o is int[] values&&values.Length == 2)
{
morkBF.FirePot1_Temperature = values[0];
morkBF.FirePot1_Pulse = values[1];

}
}), 0);

GetStatus("M25.0", new Action<object>((o) =>
{
if (o == null) return;
if (o is bool[] values&& values.Length == 19)
{
morkBF.FirePot2_InitCompleted = values[0];
morkBF.FirePot2_IsAuto = values[1];
morkBF.FirePot2_Emergencystop = values[2];
morkBF.FirePot2_MealTubExist = values[3];
morkBF.FirePot2_VegetablesTub1Exist = values[4];
morkBF.FirePot2_VegetablesTub2Exist = values[5];
morkBF.FirePot2_Seasoning1Exist = values[6];
morkBF.FirePot2_Seasoning2Exist = values[7];
morkBF.FirePot2_Accessories1Exist = values[8];
morkBF.FirePot2_Accessories2Exist = values[9];
morkBF.FirePot2_OutFoodTubExist = values[10];
morkBF.FirePot2_OnOrigin = values[11];
morkBF.FirePot2_FirePosition1 = values[12];
morkBF.FirePot2_FirePosition2 = values[13];
morkBF.FirePot2_FirePosition3 = values[14];
morkBF.FirePot2_FirePosition4 = values[15];
morkBF.FirePot2_PotOnOutFoodPosition = values[16];
morkBF.FirePot2_PotOnIntoFoodPosition = values[17];
morkBF.FirePot2_PotOnCleanPosition = values[18];

}
}), 0);

GetStatus("VW150", new Action<object>((o) =>
{
if (o == null) return;
if (o is int[] values&& values.Length == 2)
{
morkBF.FirePot2_Temperature = values[0];
morkBF.FirePot2_Pulse = values[1];

}
}), 0);
GetStatus("GM500", new Action<object>((o) =>
{
if (o == null) return;
if (o is bool[] values && values.Length == 7)
{
morkBF.Robot_FirePot1OutMeal = values[0];
morkBF.Robot_FirePot1OutVegetables1 = values[1];
morkBF.Robot_FirePot1OutVegetables2 = values[2];
morkBF.Robot_FirePot1OutSeasoning = values[3];
morkBF.Robot_FirePot1OutAccessories = values[4];
morkBF.Robot_ArriveFirePot1 = values[5];
morkBF.Robot_FirePot1OutFoodComplete = values[6];

}
}), 1);
GetStatus("GM510", new Action<object>((o) =>
{
if (o == null) return;
if (o is bool[] values && values.Length == 7)
{
morkBF.Robot_FirePot2OutMeal = values[0];
morkBF.Robot_FirePot2OutVegetables1 = values[1];
morkBF.Robot_FirePot2OutVegetables2 = values[2];
morkBF.Robot_FirePot2OutSeasoning = values[3];
morkBF.Robot_FirePot2OutAccessories = values[4];
morkBF.Robot_ArriveFirePot2 = values[5];
morkBF.Robot_FirePot2OutFoodComplete = values[6];

}
}), 1);
GetStatus("GI5", new Action<object>((o) =>
{
if (o == null) return;
if (o is int[] values && values.Length == 1)
{
morkBF.Robot_ActionCallback = values[0];
}
}), 1);

}

public override void ResetProgram()
@@ -182,11 +298,32 @@ namespace BPASmartClient.MorkBF
}

/// <summary>
/// 获取炒锅PLC的所有状态
/// </summary>
/// <param name="key"></param>
/// <param name="action"></param>
/// <param name="num">炒锅编号</param>
private void GetStatus(string key, Action<object> action, int num)
{
if (dicPort2peripheralStatus.ContainsKey(num))
{
if (dicPort2peripheralStatus[num].ContainsKey(key))
{
action((object)dicPort2peripheralStatus[num][key]);//获取PLC指定地址的状态值
}
}
}

#region 控制
private void FirePot_Write(string address, object value, int i = 0)
{
WriteControlExact(address, value, i);
}
private void Robot_Write(string address, object value, int i = 1)
{
WriteControlExact(address, value, i);
}
#region 炒锅1

/// <summary>
@@ -251,6 +388,7 @@ namespace BPASmartClient.MorkBF
}
}
#endregion

#region 炒锅2
/// <summary>
/// 炒锅2设定加热挡位
@@ -315,6 +453,7 @@ namespace BPASmartClient.MorkBF
}

#endregion

#region 炒锅通用
/// <summary>
/// 炒锅复位
@@ -548,61 +687,88 @@ namespace BPASmartClient.MorkBF
}
}
#endregion

#region 机器人
/// <summary>
/// 机器人启动
/// </summary>
private void RobotStart()
{
Robot_Write("GM600",true);
}
/// <summary>
/// 机器人停止
/// </summary>
private void RobotStop()
{
Robot_Write("GM601", true);
}
/// <summary>
/// 机器人复位
/// </summary>
private void RobotReset()
{
Robot_Write("GM602", true);
}
/// <summary>
/// 机器人程序重启
/// </summary>
private void RobotProgramStart()
{
Robot_Write("GM603", true);
}
/// <summary>
/// 1号炒锅允许机器人投料(炒锅在投料位给出)
/// </summary>
private void Robot_Pot1AllowInMaterail()
{
Robot_Write("GM520", true);
}
/// <summary>
/// 1号炒锅出餐倒料到减速位
/// </summary>
private void Robot_Pot1OutFoodInSlowDown()
{

Robot_Write("GM621", true);
}
/// <summary>
/// 1号炒锅出餐倒料完成
/// </summary>
private void Robot_Pot1OutFood()
{
Robot_Write("GM522", true);
}
/// <summary>
/// 2号炒锅允许机器人投料(炒锅在投料位给出)
/// </summary>
private void Robot_Pot2AllowInMaterail()
{

Robot_Write("GM530", true);
}
/// <summary>
/// 2号炒锅出餐倒料到减速位。开始倒菜
/// </summary>
private void Robot_Pot2OutFoodInSlowDown()
{

Robot_Write("GM531", true);
}
/// <summary>
/// 2号炒锅出餐倒料完成
/// </summary>
private void Robot_Pot2OutFood()
{

Robot_Write("GM532", true);
}
private void RobotActionStart()
/// <summary>
///
/// </summary>
private void RobotActionStart(object o)
{

if (o == null) return;
if(o is int value)
{
Robot_Write("GI0",value);
}
}
#endregion



+ 291
- 1
BPASmartClient.MorkBF/GVL_MorkBF.cs View File

@@ -1,4 +1,5 @@
using BPASmartClient.MorkBF.Model;
using BPASmartClient.Device;
using BPASmartClient.MorkBF.Model;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -27,6 +28,295 @@ namespace BPASmartClient.MorkBF
/// </summary>
public bool FirePan2_Busy = false;

#region 炒锅1读取数据
/// <summary>
/// 炒锅1锅低温度
/// </summary>
[VariableMonitor("炒锅1锅低温度", "VW120","160")]
public int FirePot1_Temperature;
/// <summary>
/// 炒锅1脉冲值
/// </summary>
[VariableMonitor("炒锅1脉冲值", "VW122", "161")]
public int FirePot1_Pulse;
/// <summary>
/// 炒锅1初始化完成
/// </summary>
[VariableMonitor("炒锅1初始化完成", "M20.0", "480")]
public bool FirePot1_InitCompleted = false;

/// <summary>
/// 炒锅1手动自动模式
/// </summary>
[VariableMonitor("炒锅1手动自动模式", "M20.1", "481")]
public bool FirePot1_IsAuto;
/// <summary>
/// 炒锅1急停
/// </summary>
[VariableMonitor("炒锅1急停", "M20.2", "482")]
public bool FirePot1_Emergencystop;
/// <summary>
/// 1#炒锅荤菜盆有无检测
/// </summary>
[VariableMonitor("1#炒锅1锅低温度", "M20.3", "483")]
public bool FirePot1_MealTubExist;
/// <summary>
/// 1#炒锅素菜盆1有无检测
/// </summary>
[VariableMonitor("炒锅素菜盆1有无检测", "M20.4", "484")]
public bool FirePot1_VegetablesTub1Exist;
/// <summary>
/// 1#炒锅素菜盆2有无检测
/// </summary>
[VariableMonitor("1#炒锅素菜盆2有无检测", "M20.5", "485")]
public bool FirePot1_VegetablesTub2Exist;
/// <summary>
/// 1#炒锅调料盆1有无检测
/// </summary>
[VariableMonitor("1#炒锅调料盆1有无检测", "M20.6", "486")]
public bool FirePot1_Seasoning1Exist;
/// <summary>
/// 1#炒锅调料盆2有无检测
/// </summary>
[VariableMonitor("1#炒锅调料盆2有无检测", "M20.7", "487")]
public bool FirePot1_Seasoning2Exist;
/// <summary>
/// 1#炒锅辅料盆1有无检测
/// </summary>
[VariableMonitor("1#炒锅辅料盆1有无检测", "M21.0", "488")]
public bool FirePot1_Accessories1Exist;
/// <summary>
/// 1#炒锅辅料盆2有无检测
/// </summary>
[VariableMonitor("1#炒锅辅料盆2有无检测", "M21.1", "489")]
public bool FirePot1_Accessories2Exist;
/// <summary>
/// 1#炒锅出餐空盆有无检测
/// </summary>
[VariableMonitor("1#炒锅出餐空盆有无检测", "M21.2", "490")]
public bool FirePot1_OutFoodTubExist;
/// <summary>
/// 1#炒锅在原点反馈
/// </summary>
[VariableMonitor("1#炒锅在原点反馈", "M21.3", "491")]
public bool FirePot1_OnOrigin;
/// <summary>
/// 1#炒制位置1反馈
/// </summary>
[VariableMonitor("1#炒制位置1反馈", "M21.4", "492")]
public bool FirePot1_FirePosition1;
/// <summary>
/// 1#炒制位置2反馈
/// </summary>
[VariableMonitor("1#炒制位置2反馈", "M21.5", "493")]
public bool FirePot1_FirePosition2;
/// <summary>
/// 1#炒制位置3反馈
/// </summary>
[VariableMonitor("1#炒制位置3反馈", "M21.6", "494")]
public bool FirePot1_FirePosition3;
/// <summary>
/// 1#炒制位置4反馈
/// </summary>
[VariableMonitor("1#炒制位置4反馈", "M21.7", "495")]
public bool FirePot1_FirePosition4;
/// <summary>
/// 1#炒锅在出餐倒料位置反馈
/// </summary>
[VariableMonitor("1#炒锅在出餐倒料位置反馈", "M22.0", "496")]
public bool FirePot1_PotOnOutFoodPosition;
/// <summary>
/// 1#炒锅在投料位置反馈、
/// </summary>
[VariableMonitor("1#炒锅在投料位置反馈", "M22.1", "497")]
public bool FirePot1_PotOnIntoFoodPosition;
/// <summary>
/// 1#炒锅在洗锅位置反馈
/// </summary>
[VariableMonitor("1#炒锅在洗锅位置反馈", "M22.2", "498")]
public bool FirePot1_PotOnCleanPosition;
#endregion

#region 炒锅2读取数据
/// <summary>
/// 炒锅2锅低温度
/// </summary>
[VariableMonitor("炒锅2锅低温度", "VW150", "175")]
public int FirePot2_Temperature;
/// <summary>
/// 炒锅2脉冲值
/// </summary>
[VariableMonitor("炒锅2脉冲值", "VW152", "176")]
public int FirePot2_Pulse;
/// <summary>
/// 炒锅2初始化完成
/// </summary>
[VariableMonitor("炒锅2初始化完成", "M25.0", "520")]
public bool FirePot2_InitCompleted = false;

/// <summary>
/// 炒锅2手动自动模式
/// </summary>
[VariableMonitor("炒锅2手动自动模式", "M25.1", "521")]
public bool FirePot2_IsAuto;
/// <summary>
/// 炒锅2急停
/// </summary>
[VariableMonitor("炒锅2急停", "M25.2", "522")]
public bool FirePot2_Emergencystop;
/// <summary>
/// 2#炒锅荤菜盆有无检测
/// </summary>
[VariableMonitor("2#炒锅荤菜盆有无检测", "M25.3", "523")]
public bool FirePot2_MealTubExist;
/// <summary>
/// 2#炒锅素菜盆1有无检测
/// </summary>
[VariableMonitor("2#炒锅素菜盆1有无检测", "M25.4", "524")]
public bool FirePot2_VegetablesTub1Exist;
/// <summary>
/// 2#炒锅素菜盆2有无检测
/// </summary>
[VariableMonitor("2#炒锅素菜盆2有无检测", "M25.5", "525")]
public bool FirePot2_VegetablesTub2Exist;
/// <summary>
/// 2#炒锅调料盆1有无检测
/// </summary>
[VariableMonitor("2#炒锅调料盆1有无检测", "M25.6", "526")]
public bool FirePot2_Seasoning1Exist;
/// <summary>
/// 2#炒锅调料盆2有无检测
/// </summary>
[VariableMonitor("2#炒锅调料盆2有无检测", "M25.7", "527")]
public bool FirePot2_Seasoning2Exist;
/// <summary>
/// 2#炒锅辅料盆1有无检测
/// </summary>
[VariableMonitor("2#炒锅1锅低温度", "M26.0", "528")]
public bool FirePot2_Accessories1Exist;
/// <summary>
/// 2#炒锅辅料盆2有无检测
/// </summary>
[VariableMonitor("2#炒锅辅料盆2有无检测", "M26.1", "529")]
public bool FirePot2_Accessories2Exist;
/// <summary>
/// 2#炒锅出餐空盆有无检测
/// </summary>
[VariableMonitor("2#炒锅出餐空盆有无检测", "M26.2", "530")]
public bool FirePot2_OutFoodTubExist;
/// <summary>
/// 2#炒锅在原点反馈
/// </summary>
[VariableMonitor("2#炒锅在原点反馈", "M26.3", "531")]
public bool FirePot2_OnOrigin;
/// <summary>
/// 2#炒制位置1反馈
/// </summary>
[VariableMonitor("2#炒制位置1反馈", "M26.4", "532")]
public bool FirePot2_FirePosition1;
/// <summary>
/// 2#炒制位置2反馈
/// </summary>
[VariableMonitor("2#炒制位置2反馈", "M26.5", "533")]
public bool FirePot2_FirePosition2;
/// <summary>
/// 2#炒制位置3反馈
/// </summary>
[VariableMonitor("2#炒制位置3反馈", "M26.6", "534")]
public bool FirePot2_FirePosition3;
/// <summary>
/// 2#炒制位置4反馈
/// </summary>
[VariableMonitor("2#炒制位置4反馈", "M26.7", "535")]
public bool FirePot2_FirePosition4;
/// <summary>
/// 2#炒锅在出餐倒料位置反馈
/// </summary>
[VariableMonitor("2#炒锅在出餐倒料位置反馈", "M27.0", "536")]
public bool FirePot2_PotOnOutFoodPosition;
/// <summary>
/// 2#炒锅在投料位置反馈、
/// </summary>
[VariableMonitor("2#炒锅在投料位置反馈", "M27.1", "537")]
public bool FirePot2_PotOnIntoFoodPosition;
/// <summary>
/// 2#炒锅在洗锅位置反馈
/// </summary>
[VariableMonitor("2#炒锅在洗锅位置反馈", "M27.2", "538")]
public bool FirePot2_PotOnCleanPosition;
#endregion

#region 机器人数据读取
/// <summary>
/// 1号锅倒荤菜完成
/// </summary>
public bool Robot_FirePot1OutMeal;
/// <summary>
/// 1号炒锅倒素菜1完成
/// </summary>
public bool Robot_FirePot1OutVegetables1;
/// <summary>
/// 1号炒锅倒素菜2完成
/// </summary>
public bool Robot_FirePot1OutVegetables2;
/// <summary>
/// 1号炒锅倒调料完成
/// </summary>
public bool Robot_FirePot1OutSeasoning;
/// <summary>
/// 1号炒锅倒辅料完成
/// </summary>
public bool Robot_FirePot1OutAccessories;
/// <summary>
/// 机器人到位,请求1#炒锅倒菜
/// </summary>
public bool Robot_ArriveFirePot1;
/// <summary>
/// 1号炒锅出餐完成
/// </summary>
public bool Robot_FirePot1OutFoodComplete;





/// <summary>
/// 2号锅倒荤菜完成
/// </summary>
public bool Robot_FirePot2OutMeal;
/// <summary>
/// 2号炒锅倒素菜1完成
/// </summary>
public bool Robot_FirePot2OutVegetables1;
/// <summary>
/// 2号炒锅倒素菜2完成
/// </summary>
public bool Robot_FirePot2OutVegetables2;
/// <summary>
/// 2号炒锅倒调料完成
/// </summary>
public bool Robot_FirePot2OutSeasoning;
/// <summary>
/// 2号炒锅倒辅料完成
/// </summary>
public bool Robot_FirePot2OutAccessories;
/// <summary>
/// 机器人到位,请求1#炒锅倒菜
/// </summary>
public bool Robot_ArriveFirePot2;
/// <summary>
/// 2号炒锅出餐完成
/// </summary>
public bool Robot_FirePot2OutFoodComplete;
/// <summary>
/// 机器人动作反馈
/// </summary>
public int Robot_ActionCallback;

#endregion



public DateTime FirePan1_Date;
public DateTime FirePan2_Date;
}


+ 27
- 1
BPASmartClient.MorkBF/VIew/DebugView.xaml View File

@@ -57,7 +57,33 @@

</GroupBox>
<GroupBox Grid.Row="1" Header="炒锅2" FontSize="22">

<WrapPanel Grid.Row="1" Orientation="Horizontal">
<Button Content="复位" Width="110" Margin="10,5" Command="{Binding FirePot_ResetCommand}" CommandParameter="1"/>
<TextBlock Text="加热挡位" Margin="10,5"/>
<ComboBox Width="80" ItemsSource="{Binding FireGear}" Margin="10,5" SelectedItem="{Binding FirePot2_FireGear}"/>
<Button Content="加热档位设定" Width="110" Margin="10,5" Command="{Binding FirePot2_SetFireGearCommand}"/>
<Button Content="加热启动" Width="80" Margin="10,5" Command="{Binding FirePot2_StartFireCommand}"/>
<Button Content="加热停止" Width="80" Margin="10,5,30,5" Command="{Binding FirePot2_StopFireCommand}"/>
<TextBlock Text="搅拌挡位" Margin="10,5"/>
<ComboBox Width="80" ItemsSource="{Binding StirGear}" SelectedItem="{Binding FirePot2_StirGear}" Margin="10,5"/>
<Button Content="搅拌档位设定" Width="110" Margin="10,5" Command="{Binding FirePot2_SetStirGearCommand}"/>
<Button Content="搅拌启动" Width="80" Margin="10,5" Command="{Binding FirePot2_StartStirCommand}"/>
<Button Content="搅拌停止" Width="80" Margin="10,5,30,5" Command="{Binding FirePot2_StopStirCommand}"/>
<TextBlock Text="翻转频率" Margin="10,5"/>
<TextBox Width="80" Text="{Binding FirePot2_TurnSpeed}" Margin="10,5"/>
<Button Content="翻转频率设定" Width="110" Margin="10,5" Command="{Binding FirePot2_SetTurnSpeedCommand}"/>
<Button Content="炒锅回原点" Width="110" Margin="10,5" Command="{Binding FirePot_PotGotoOriginCommand}" CommandParameter="2"/>
<Button Content="出餐启动" Width="110" Margin="10,5" Command="{Binding FirePot_StartOutFoodCommand}" CommandParameter="2"/>
<Button Content="单独清洗" Width="110" Margin="10,5" Command="{Binding FirePot_CleanCommand}" CommandParameter="2"/>
<Button Content="抽水启动" Width="110" Margin="10,5" Command="{Binding FirePot_StartPumpWaterCommand}" CommandParameter="2"/>
<Button Content="抽油启动" Width="110" Margin="10,5" Command="{Binding FirePot_StartPumpOilCommand}" CommandParameter="2"/>
<Button Content="炒锅去炒制位置1" Width="110" Margin="10,5" Command="{Binding FirePot_PotGotoP1Command}" CommandParameter="2"/>
<Button Content="炒锅去炒制位置2" Width="110" Margin="10,5" Command="{Binding FirePot_PotGotoP2Command}" CommandParameter="2"/>
<Button Content="炒锅去炒制位置3" Width="110" Margin="10,5" Command="{Binding FirePot_PotGotoP3Command}" CommandParameter="2"/>
<Button Content="炒锅去炒制位置4" Width="110" Margin="10,5" Command="{Binding FirePot_PotGotoP4Command}" CommandParameter="2"/>
<Button Content="炒锅去出餐倒料位置" Width="140" Margin="10,5" Command="{Binding FirePot_PotGotoOutFoodPositiongCommand}" CommandParameter="2"/>
<Button Content="炒锅去投料位置" Width="110" Margin="10,5" Command="{Binding FirePot_PotGotoInFoodPositionCommand}" CommandParameter="2"/>
</WrapPanel>
</GroupBox>
<GroupBox Grid.Row="3" Header="机器人" FontSize="22">
<WrapPanel Orientation="Horizontal">


+ 242
- 0
BPASmartClient.MorkBF/VIew/Monitor.xaml View File

@@ -0,0 +1,242 @@
<UserControl
x:Class="BPASmartClient.MorkBF.View.Monitor"
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.MorkBF.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmartClient.MorkBF.ViewModel"
Name="监控画面"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">

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

<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<!--<convert:TextDisplayConvert x:Key="textDisplayConvert" />
<convert:IsEnableConvert x:Key="isEnableConvert" />
<convert:AnalogAlarmConvert x:Key="analogAlarmConvert" />
<convert:DiscreteAlarmConvert x:Key="discreteAlarmConvert" />
<convert:AlarmTypeTextConvert x:Key="alarmTypeTextConvert" />-->
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" />
<SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="TitleFontColor" Color="#ddd" />
<SolidColorBrush x:Key="CursorColor" Color="Aqua" />
<SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" />

<Style x:Key="TextBlockStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="楷体" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>

<Style x:Key="TextBoxStyle" TargetType="TextBox">
<Setter Property="FontFamily" Value="楷体" />
<Setter Property="FontSize" Value="22" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" />
<Setter Property="BorderBrush" Value="#FF23CACA" />
<Setter Property="CaretBrush" Value="Aqua" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>

</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>

<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
</Grid.RowDefinitions>

<!--#region 表格标题栏设置-->
<Grid Background="#dd2AB2E7">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.3*" />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition Width="0.7*" />
<ColumnDefinition Width="0.7*" />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="ID" />

<Grid Grid.Column="1">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="变量名" />
<Border
BorderBrush="{StaticResource TitleBorderColor}"
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>

<TextBlock
Grid.Column="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="PLC 地址" />


<Grid Grid.Column="3">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="注释" />
<Border
BorderBrush="{StaticResource TitleBorderColor}"
BorderThickness="1,0,0,0"
Cursor="SizeWE" />
</Grid>



<Grid Grid.Column="4">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="Modbus TCP 地址" />
<Border
BorderBrush="{StaticResource TitleBorderColor}"
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>

<TextBlock
Grid.Column="5"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="当前值" />

</Grid>
<!--#endregion-->

<!--#region 表格数据显示-->
<ScrollViewer
Grid.Row="1"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding variableMonitors}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid x:Name="gr" Height="30">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.3*" />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition Width="0.7*" />
<ColumnDefinition Width="0.7*" />
</Grid.ColumnDefinitions>

<TextBlock
Grid.Column="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Transparent"
FontSize="14"
Foreground="{StaticResource FontColor}"
Text="{Binding Id}" />

<Grid Grid.Column="1">
<TextBlock
Margin="5,0,0,0"
VerticalAlignment="Center"
Background="Transparent"
FontSize="14"
Foreground="{StaticResource FontColor}"
Text="{Binding VarName}" />
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
</Grid>


<TextBlock
Grid.Column="2"
Margin="5,0,0,0"
VerticalAlignment="Center"
Background="Transparent"
FontSize="14"
Foreground="{StaticResource FontColor}"
Text="{Binding PLCAddress}" />

<Grid Grid.Column="3">
<TextBlock
Margin="5,0,0,0"
VerticalAlignment="Center"
Background="Transparent"
FontSize="14"
Foreground="{StaticResource FontColor}"
Text="{Binding Notes}" />
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,0,0" />
</Grid>

<Grid Grid.Column="4">
<TextBlock
Margin="5,0,0,0"
VerticalAlignment="Center"
Background="Transparent"
FontSize="14"
Foreground="{StaticResource FontColor}"
Text="{Binding ModbusTcpAddress}" />
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
</Grid>

<TextBlock
Grid.Column="5"
Margin="5,0,0,0"
VerticalAlignment="Center"
Background="Transparent"
FontSize="14"
Foreground="{StaticResource FontColor}"
Text="{Binding CurrentValue}" />

<Border
Grid.ColumnSpan="8"
BorderBrush="{StaticResource BorderSolid}"
BorderThickness="1" />

</Grid>

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

</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
<!--#endregion-->


</Grid>

</UserControl>

+ 28
- 0
BPASmartClient.MorkBF/VIew/Monitor.xaml.cs View File

@@ -0,0 +1,28 @@
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.MorkBF.View
{
/// <summary>
/// Monitor.xaml 的交互逻辑
/// </summary>
public partial class Monitor : UserControl
{
public Monitor()
{
InitializeComponent();
}
}
}

+ 63
- 2
BPASmartClient.MorkBF/ViewModel/DebugViewModel.cs View File

@@ -33,8 +33,10 @@ namespace BPASmartClient.MorkBF.ViewModel
private int _firePot2_StirGear = 0;
[ObservableProperty]
private int _firePot1_TurnSpeed;
[ObservableProperty]
private int _firePot2_TurnSpeed;
#region 炒锅1
/// <summary>
/// 设定加热挡位
/// </summary>
@@ -93,8 +95,67 @@ namespace BPASmartClient.MorkBF.ViewModel
ActionManage.GetInstance.Send("FirePot1_SetTurnSpeed",new List<int> { FirePot1_TurnSpeed});
}
#endregion

#region 炒锅2
/// <summary>
/// 设定加热挡位
/// </summary>
[RelayCommand]
private void FirePot2_SetFireGear()
{
ActionManage.GetInstance.Send("FirePot2_SetFireGear", new List<int> { FirePot2_FireGear });
}
/// <summary>
/// 加热启动
/// </summary>
[RelayCommand]
private void FirePot2_StartFire()
{
ActionManage.GetInstance.Send("FirePot2_StartFire", true);
}
/// <summary>
/// 关闭加热
/// </summary>
[RelayCommand]
private void FirePot2_StopFire()
{
ActionManage.GetInstance.Send("FirePot2_StopFire", false);
}
/// <summary>
/// 设定搅拌挡位
/// </summary>
[RelayCommand]
private void FirePot2_SetStirGear()
{
ActionManage.GetInstance.Send("FirePot2_SetStirGear", new List<int> { FirePot2_StirGear });
}
/// <summary>
/// 搅拌启动
/// </summary>
[RelayCommand]
private void FirePot2_StartStir()
{
ActionManage.GetInstance.Send("FirePot2_StartStir", true);
}
/// <summary>
/// 搅拌停止
/// </summary>
[RelayCommand]
private void FirePot2_StopStir()
{
ActionManage.GetInstance.Send("FirePot1_StopStir", false);
}
/// <summary>
/// 翻转频率设定
/// </summary>
[RelayCommand]
private void FirePot2_SetTurnSpeed()
{
if (FirePot1_TurnSpeed > 800) FirePot1_TurnSpeed = 800;
ActionManage.GetInstance.Send("FirePot2_SetTurnSpeed", new List<int> { FirePot2_TurnSpeed });
}
#endregion

#region 炒锅通用
/// <summary>
/// 复位
@@ -304,7 +365,7 @@ namespace BPASmartClient.MorkBF.ViewModel
[RelayCommand]
private void RobotActionStart()
{
ActionManage.GetInstance.Send("RobotProgramStart",new List<int> {RobotAction });
ActionManage.GetInstance.Send("RobotProgramStart",RobotAction );
}

#endregion


+ 25
- 0
BPASmartClient.MorkBF/ViewModel/MonitorViewModel.cs View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.Business;
using BPASmartClient.Device;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;

namespace BPASmartClient.MorkBF.ViewModel
{
public class MonitorViewModel : ObservableObject
{
public MonitorViewModel()
{

}

public static int DeviceId { get; set; }

public ObservableCollection<VariableMonitor> variableMonitors { get; set; } = Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices()?.FirstOrDefault(p => p.DeviceId == DeviceId)?.variableMonitors;

}
}

Loading…
Cancel
Save