Browse Source

冲突解决

样式分支
pry 2 years ago
parent
commit
6a43d58a38
59 changed files with 2190 additions and 637 deletions
  1. +0
    -8
      BPASmartClient.JXJFoodBigStation/App.xaml.cs
  2. +2
    -1
      BPASmartClient.JXJFoodBigStation/Model/DeviceCurrentStatus.cs
  3. +9
    -1
      BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs
  4. +4
    -4
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs
  5. +14
    -0
      BPASmartClient.JXJFoodBigStation/Model/LocalRecipeDataColl.cs
  6. +114
    -59
      BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
  7. +7
    -1
      BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialModel.cs
  8. +2
    -2
      BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeModel.cs
  9. +39
    -0
      BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs
  10. +51
    -0
      BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs
  11. +60
    -0
      BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs
  12. +2
    -2
      BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs
  13. +12
    -0
      BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeRawMaterial.cs
  14. +51
    -33
      BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs
  15. +8
    -8
      BPASmartClient.JXJFoodBigStation/Model/TestData.cs
  16. +192
    -8
      BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml
  17. +224
    -1
      BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml.cs
  18. +6
    -4
      BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml
  19. +5
    -4
      BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml
  20. +2
    -1
      BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml
  21. +43
    -0
      BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs
  22. +8
    -7
      BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs
  23. +41
    -42
      BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs
  24. +1
    -1
      BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs
  25. +2
    -6
      BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs
  26. +47
    -2
      BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs
  27. +91
    -193
      BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
  28. +35
    -3
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs
  29. +0
    -2
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs
  30. +5
    -0
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs
  31. +2
    -2
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs
  32. +10
    -4
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs
  33. +27
    -33
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs
  34. +39
    -0
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs
  35. +52
    -0
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs
  36. +60
    -0
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs
  37. +8
    -8
      BPASmartClient.JXJFoodSmallStation/Model/TestData.cs
  38. +2
    -2
      BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs
  39. +3
    -3
      BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs
  40. +0
    -2
      BPASmartClient.MinimalistUI/MainWindow.xaml
  41. BIN
     
  42. +20
    -17
      BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs
  43. +9
    -9
      BPASmartClient.SCADAControl/CustomerControls/TheMQTT.xaml.cs
  44. +2
    -2
      BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs
  45. +6
    -3
      BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs
  46. +13
    -10
      BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs
  47. +19
    -16
      BPASmartClient.SCADAControl/CustomerControls/TheToggleButton.xaml.cs
  48. +1
    -1
      BeDesignerSCADA/Common/PropertyHelper.cs
  49. +0
    -3
      BeDesignerSCADA/Controls/CanvasPanel.cs
  50. +294
    -0
      BeDesignerSCADA/Controls/MainCanvasPanel.xaml
  51. +359
    -0
      BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs
  52. +0
    -5
      BeDesignerSCADA/Controls/RunCanvas.xaml.cs
  53. +13
    -0
      BeDesignerSCADA/MainTest.xaml
  54. +30
    -0
      BeDesignerSCADA/MainTest.xaml.cs
  55. +12
    -10
      BeDesignerSCADA/MainWindow.xaml
  56. +26
    -27
      BeDesignerSCADA/MainWindow.xaml.cs
  57. +14
    -14
      BeDesignerSCADA/Themes/Styles.xaml
  58. +91
    -73
      BeDesignerSCADA/ViewModel/MainViewModel.cs
  59. +1
    -0
      WPFDemo/WPFDemo.csproj

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

@@ -51,7 +51,6 @@ namespace BPASmartClient.JXJFoodBigStation

private void MenuInit()
{

#region 配方管理菜单
ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
RecipeManage.Add(new SubMenumodel()
@@ -123,13 +122,6 @@ namespace BPASmartClient.JXJFoodBigStation
#region 硬件设备监控
ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "料仓管理",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
AssemblyName = "BPASmartClient.JXJFoodBigStation",
ToggleWindowPath = "View.DeviceManageView"
});
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "设备状态",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },


+ 2
- 1
BPASmartClient.JXJFoodBigStation/Model/DeviceCurrentStatus.cs View File

@@ -21,7 +21,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } }
private string _mDeviceName;


public int DeviceNum { get { return _mDeviceNum; } set { _mDeviceNum = value; OnPropertyChanged(); } }
private int _mDeviceNum;

}
}

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

@@ -11,7 +11,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
public class GVL_BigStation
{
/// <summary>
/// 往输送带下发配方完成
/// </summary>
@@ -32,5 +31,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// 记录AGV进站取货的指令顺序
/// </summary>
public int AgvPickUpPosition { get; set; }

/// <summary>
/// 配方配料的状态 0:无意义 ,1:plc允许下发配方 2:上位机下发配方 3:plc接收到配方(配料中) 4:配料完成
/// </summary>
public int RecipeDosingStatus { get; set; }
/// <summary>
/// 是否处于手动下发配方
/// </summary>
public bool IsAllowManual { get; set; }
}
}

+ 4
- 4
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs View File

@@ -61,13 +61,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
/// </summary>
/// <param name="BarrelNum">单个桶的编号</param>
/// <param name="StockBinLocation">单个桶对应的料仓位置</param>
public void StockBinPar(ushort[] Num, ushort[] Location,ushort[] Weight)
public void StockBinPar(short[] Num, short[] Location,short[] Weight)
{
if (IsConnected)
{
HK_PLC_S7.Write(HKPlcCommAddress.BarrelNumToPLC, Num);
HK_PLC_S7.Write(HKPlcCommAddress.StockBinLocationToPLC, Location);
HK_PLC_S7.Write(HKPlcCommAddress.WeightToPLC, Weight);
HK_PLC_S7.Write<short[]>(HKPlcCommAddress.BarrelNumToPLC, Num);
HK_PLC_S7.Write<short[]>(HKPlcCommAddress.StockBinLocationToPLC, Location);
HK_PLC_S7.Write<short[]>(HKPlcCommAddress.WeightToPLC, Weight);
}
}
}


+ 14
- 0
BPASmartClient.JXJFoodBigStation/Model/LocalRecipeDataColl.cs View File

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

namespace BPASmartClient.JXJFoodBigStation.Model
{
public class LocalRecipeDataColl
{
public ObservableCollection<RemoteRecipeData> Recipes { get; set; } = new ObservableCollection<RemoteRecipeData>();
}
}

+ 114
- 59
BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs View File

@@ -35,73 +35,57 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// </summary>
public ObservableCollection<RemoteRecipeData> IssuedComplete = new ObservableCollection<RemoteRecipeData>();
/// <summary>
/// 原料的名称和料仓的位置对应
/// </summary>
public Dictionary<string, short> RawMaterialsNamePos = new Dictionary<string, short>();
/// <summary>
/// 配方队列
/// </summary>
public ConcurrentQueue<long> RecipeQueue = new ConcurrentQueue<long>();
public ConcurrentQueue<string> RecipeQueue = new ConcurrentQueue<string>();
/// <summary>
/// AGV到达工站队列
/// </summary>
public ConcurrentQueue<int> AGVToWorkStationQueue = new ConcurrentQueue<int>();
public ConcurrentQueue<string> AGVToWorkStationQueue = new ConcurrentQueue<string>();
/// <summary>
/// 接收原料数据
/// </summary>
public RecipeRawMaterial RawMaterial;
public void Init()
{
ActionManage.GetInstance.Register(new Action(() =>
ActionManage.GetInstance.Register(new Action<DL_Start_DB>((res) =>
{
if (SiemensDevice.IsConnected)
{
var res = SiemensDevice.Siemens_PLC_S7.Read<string>(SiemensCommAddress.RecipeName);
var res1 = SiemensDevice.Siemens_PLC_S7.Read<uint>(SiemensCommAddress.RecipeID);
var res2 = SiemensDevice.Siemens_PLC_S7.ReadClass<RecipeRawMaterial>(0, 0);
if ((res != null && res is string recipeName) && (res1 != null && res1 is uint recipeID))
if (res != null)
{
int index = Array.FindIndex(Json<RemoteRecipeDataColl>.Data.Recipes.ToArray(), p => p.RecipeCode == recipeID);
if (index == -1)
RawMaterials.Clear();
for (int i = 0; i < 15; i++)
{
RawMaterials.Clear();
for (int i = 0; i < 15; i++)
if (RawMaterialsNamePos.ContainsKey(res.Material[i].Material_Name))
{
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
RawMaterialBarrelNum = res2.RawMaterialBarrelNum[i],
RawMaterialLocation = res2.RawMaterialLocation[i],
RawMaterialWeight = res2.RawMaterialWeight[i]
RawMaterialName = res.Material[i].Material_Name,
RawMaterialBarrelNum = res.Material[i].Material_BarrelNum,
RawMaterialWeight = res.Material[i].Material_Weight,
RawMaterialLocation = (int)RawMaterialsNamePos[res.Material[i].Material_Name]
});
}
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
else
{
RecipeName = recipeName,
RecipeCode = recipeID,
RawMaterial = RawMaterials
});
//报警,配方的原料名称下发和设备不一致
}
}
else
Json<LocalRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
{
MessageLog.GetInstance.AlarmLog("配方列表中存在该配方ID");
}
RecipeName = res.RecipeName,
RecipeCode = res.RecipeCode,
RawMaterial = RawMaterials,
TrayCode = res.TrayCode
});
}
}
}), "西门子下发配方", true);
ActionManage.GetInstance.Register(new Action(() =>
{
if (SiemensDevice.IsConnected)
{
var res = SiemensDevice.Siemens_PLC_S7.Read<int>(SiemensCommAddress.TrayLocationNum);
var res1 = SiemensDevice.Siemens_PLC_S7.Read<int>(SiemensCommAddress.RecipeID);
if (res != null && res is int TrayLocation && res1 != null && res1 is int recipeId)
{
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == recipeId);
if (index >= 0 && index < RemoteRecipes.Count)
{
RemoteRecipes.ElementAt(index).TrayCode = TrayLocation;
MessageLog.GetInstance.RunLog($"接收到AGV进站信号=>配方编码:{recipeId} 、托盘位置:{TrayLocation}");
AGVToWorkStationQueue.Enqueue(recipeId);
}
}
}
}), "AGV到位信号", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"];
string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
try
@@ -122,7 +106,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model

}
RecipeQueue.Clear();
Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
//Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
ThreadManage.GetInstance().StartLong(new Action(() =>
{
ReceviceData();
@@ -136,12 +120,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model
AgvGetInOut();
}
Thread.Sleep(10);

}), "AGV进站送取货", true);
ThreadManage.GetInstance().StartLong(new Action(() =>
{
ReadSiemensCommData();
ReadHKPLCCommData();
Thread.Sleep(10);
}), "读取西门子和海科PLC的数据", true);
}
/// <summary>
@@ -223,13 +207,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
//获取工位上是否有小车
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool)
HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.StationIsExistCar));
HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.StationIsExistTray));
//检测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
int RecipeCode = (int)RemoteRecipes.ElementAt(index).RecipeCode;
string RecipeCode = (string)RemoteRecipes.ElementAt(index).RecipeCode;
if (TrayLocation > 0 && TrayLocation < 7)
{
AGV_Delivery(TrayLocation - 1);
@@ -249,7 +233,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
private void ReceviceData()
{
RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
if (!BigStation.IsAllowManual && RemoteRecipes.Count == 0)//一个配方执行完成后,再获取配方数据
{
RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
}
else if (BigStation.IsAllowManual && RemoteRecipes.Count == 0)
{
RemoteRecipes = Json<LocalRecipeDataColl>.Data.Recipes;
}
if (RemoteRecipes.Count > 0)
{
foreach (var data in RemoteRecipes)
@@ -259,9 +250,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
}
}
ushort[] BarrelNum = new ushort[15];
ushort[] Location = new ushort[15];
ushort[] Weight = new ushort[15];
short[] BarrelNum = new short[15];
short[] Location = new short[15];
short[] Weight = new short[15];
private void RecipeInfoToHKPLC()
{
if (RecipeQueue.Count > 0)
@@ -269,26 +260,77 @@ namespace BPASmartClient.JXJFoodBigStation.Model
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0));
if (index >= 0 && index <= RemoteRecipes.Count)
{
long code = RemoteRecipes.ElementAt(index).RecipeCode;
if (HKDevice.HK_PLC_S7.Read<bool>("M5001.0") is bool)//配方1是否允许下发配发
string code = RemoteRecipes.ElementAt(index).RecipeCode;
if (HKDevice.HK_PLC_S7.Read<bool>("M5001.0") && BigStation.RecipeDosingStatus == 0)//配方1是否允许下发配发
{
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}允许下发");
BigStation.RecipeDosingStatus = 1;
for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
{
BarrelNum[i] = (ushort)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
Location[i] = (ushort)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialLocation;
Weight[i] = (ushort)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialWeight;
BarrelNum[i] = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
Location[i] = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialLocation;
Weight[i] = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialWeight;
}
HKDevice.StockBinPar(BarrelNum, Location, Weight);
HKDevice.HK_PLC_S7.Write("M4001.0", 1);//配发下发完成,to plc
HKDevice.HK_PLC_S7.Write("M5001.0", 0);//复位允许下发配方1信号
//BigStation.IssueRecipeFinish = true;
BigStation.RecipeDosingStatus = 2;
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
}
if (HKDevice.HK_PLC_S7.Read<bool>("M5001.4") && BigStation.RecipeDosingStatus == 2)
{
BigStation.RecipeDosingStatus = 3;
HKDevice.HK_PLC_S7.Write("M5001.4", 0);//复位允许下发配方1信号
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
}
if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.RecipeDosingFinish) is bool))
if (BigStation.RecipeDosingStatus == 3)
{
HKDevice.RecipeDosingFinishReset();
RecipeQueue.TryDequeue(out code);
IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下
Json<RemoteRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
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);
if (a >= 0)
{
int barrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(a).RawMaterialBarrelNum;
string address = "MD" + 5060 + i * 4 + (barrelNum - 1) * 48;
float 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;
float weight = HKDevice.HK_PLC_S7.Read<float>(address);
}
}
}
}
if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.RecipeDosingFinish)) || true)
{
BigStation.RecipeDosingStatus = 4;
MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
HKDevice.RecipeDosingFinishReset();
RecipeQueue.TryDequeue(out code);
IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下
if (!BigStation.IsAllowManual)
{
Json<RemoteRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
}
else
{
Json<LocalRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
}
BigStation.RecipeDosingStatus = 0;
}
}
}
}
@@ -399,5 +441,18 @@ namespace BPASmartClient.JXJFoodBigStation.Model
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);
}
}
}
}

+ 7
- 1
BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialModel.cs View File

@@ -28,11 +28,17 @@ namespace BPASmartClient.JXJFoodBigStation.Model
private double _mRawMaterialWeight;

/// <summary>
/// 原料对应料仓的位置/名称
/// 原料对应料仓的位置
/// </summary>
public int RawMaterialLocation { get { return _mRawMaterialLocation; } set { _mRawMaterialLocation = value; OnPropertyChanged(); } }
private int _mRawMaterialLocation;
/// <summary>
/// 原料名称
/// </summary>
public string RawMaterialName { get { return _rawMaterNmae; } set { _rawMaterNmae = value;OnPropertyChanged(); } }

private string _rawMaterNmae;

/// <summary>


+ 2
- 2
BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeModel.cs View File

@@ -34,8 +34,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// <summary>
/// 配方编码
/// </summary>
public long RecipeCode { get { return _mRecipCode; } set { _mRecipCode = value; OnPropertyChanged(); } }
private long _mRecipCode;
public string RecipeCode { get { return _mRecipCode; } set { _mRecipCode = value; OnPropertyChanged(); } }
private string _mRecipCode;

/// <summary>
/// 托盘编号


+ 39
- 0
BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs View File

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

namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
internal class DL_Finish_DB
{
/// <summary>
/// 生产工单编码
/// </summary>
public string Order_No;
/// <summary>
/// 产品名称
/// </summary>
public string Product_Code;
/// <summary>
/// 原料信息
/// </summary>
public UDT1[] Material = new UDT1[20];
/// <summary>
/// 配料完成信号
/// </summary>
public bool Ask_For_Finish;
/// <summary>
/// 配料完成信号确认
/// </summary>
public bool Ask_For_Finish_PLC;

}
public class UDT1
{
public string Material_Name;
public float Material_Laying_Off_Weight;
public short Material_BarrelNum;
}
}

+ 51
- 0
BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs View File

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

namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
internal class DL_Start_DB
{
/// <summary>
/// 配方编码
/// </summary>
public string RecipeCode;
/// <summary>
/// 配发名称
/// </summary>
public string RecipeName;
/// <summary>
/// 物料信息
/// </summary>
public UDT[] Material = new UDT[20];
/// <summary>
/// 托盘编号
/// </summary>
public int TrayCode;
/// <summary>
/// 配方发送请求
/// </summary>
public bool Ask_For_Send_Bit;
/// <summary>
/// 上位机确认配方接收完成
/// </summary>
public bool Ack_Ask_For_Send_Bit;
}
public class UDT
{
/// <summary>
/// 原料名称
/// </summary>
public string Material_Name;
/// <summary>
/// 原料重量
/// </summary>
public float Material_Weight;
/// <summary>
/// 原料桶号
/// </summary>
public short Material_BarrelNum;
}
}

+ 60
- 0
BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs View File

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

namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
internal class DL_Status_DB
{
/// <summary>
/// 生产工单
/// </summary>
public string Order_No;
/// <summary>
/// 配料开始
/// </summary>
public bool Dosing_Start;
/// <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;
/// <summary>
/// 备用
/// </summary>
public byte Reserve;
}
}

+ 2
- 2
BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs View File

@@ -20,8 +20,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// <summary>
/// 配方ID
/// </summary>
public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } }
private long _mRecipeCode;
public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; } }
private string _mRecipeCode;
/// <summary>
/// 托盘编号


+ 12
- 0
BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeRawMaterial.cs View File

@@ -12,6 +12,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model
private int _mIp;
public int DeviceIp { get { return _mIp; } set { _mIp = value; }}

/// <summary>
/// 原料名称
/// </summary>
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } }
private string _mRawMaterialName;

/// <summary>
/// 原料对应的桶号
/// </summary>
@@ -24,6 +30,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public double RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } }
private double _mRawMaterialWeight;

/// <summary>
/// 实际的下料中重量
/// </summary>
public float Laying_Off_Weight { get { return _mLaying_Off_Weight; } set { _mLaying_Off_Weight = value; } }
private float _mLaying_Off_Weight;

/// <summary>
/// 原料对应料仓的位置
/// </summary>


+ 51
- 33
BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs View File

@@ -6,6 +6,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.S7Net;
using System.Threading;

namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
@@ -14,51 +15,68 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
public SiemensHelper Siemens_PLC_S7 = new SiemensHelper();
public bool IsConnected => Siemens_PLC_S7.IsConnected;

/// <summary>
/// 配方接收信号复位
/// </summary>
public void RecipeSignReset()
{
this.Siemens_PLC_S7.Write(SiemensCommAddress.RecipeState, (ushort)0);
}
/// <summary>
/// AGV到位信号复位
/// </summary>
public void AgvSignReset()
{
this.Siemens_PLC_S7.Write(SiemensCommAddress.StateSign, (ushort)0);
}
public void Init()
{
if (IsConnected)
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
var res = this.Siemens_PLC_S7.Read<bool>(SiemensCommAddress.RecipeState);
if (res != null && RTrig.GetInstance("RecipeTrig").Start(res is bool SignTrig))
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))
{
ActionManage.GetInstance.Send("西门子下发配方", res);
res.Ask_For_Send_Bit = false;
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]))
{
ActionManage.GetInstance.Send("AGV到工位1信号", res1);
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]))
{
ActionManage.GetInstance.Send("AGV到工位2信号", res1);
res1.Allow_AGV_Put[1] = false;
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
}
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[2]").Start(res1.Allow_AGV_Put[2]))
{
ActionManage.GetInstance.Send("AGV到工位3信号", res1);
res1.Allow_AGV_Put[2] = false;
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
}
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[3]").Start(res1.Allow_AGV_Put[3]))
{
ActionManage.GetInstance.Send("AGV到工位4信号", res1);
res1.Allow_AGV_Put[3] = false;
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
}
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[4]").Start(res1.Allow_AGV_Put[4]))
{
ActionManage.GetInstance.Send("西门子下发配方");
RecipeSignReset();
ActionManage.GetInstance.Send("AGV到工位5信号", res1);
res1.Allow_AGV_Put[4] = false;
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
}
var AgvState = this.Siemens_PLC_S7.Read<bool>(SiemensCommAddress.StateSign);
if (AgvState != null && RTrig.GetInstance("AgvTrig").Start(res is bool AgvSignTrig))
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[5]").Start(res1.Allow_AGV_Put[5]))
{
ActionManage.GetInstance.Send("AGV到位信号");
AgvSignReset();
ActionManage.GetInstance.Send("AGV到工位6信号", res1);
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("配料完成信号确认完成");
res2.Ask_For_Finish_PLC = false;
this.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(res2, 3);
}
Thread.Sleep(10);
}), "监听服务数据");
}
}
/// <summary>
/// 配方配料完成信号
/// </summary>
/// <param name="TrayLocation"></param>
/// <param name="recipeID"></param>
private void DosingFinsih(int TrayLocation, int recipeID)
{
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayLocationNumToSiemens, TrayLocation);
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayStateToSiemens, 1);
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayRecipeIDToSiemens, recipeID);
}
}
}

+ 8
- 8
BPASmartClient.JXJFoodBigStation/Model/TestData.cs View File

@@ -18,19 +18,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public TestData()
{
string recipeName = "配方1";
long recipeCode = 10001;
string recipeCode = "10001";
int Traycode = 1;

double RawmaterialWeight = 10;
int RawMaterialbarrelNum = 1;
short RawMaterialbarrelNum = 1;
int RawMaterialLocation = 5;

double RawmaterialWeight1 = 20;
int RawMaterialbarrelNum1 = 2;
short RawMaterialbarrelNum1 = 2;
int RawMaterialLocation1 = 7;

double RawmaterialWeight2 = 30;
int RawMaterialbarrelNum2 = 3;
short RawMaterialbarrelNum2 = 3;
int RawMaterialLocation2 = 9;
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
@@ -64,19 +64,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model

RawMaterials.Clear();
string recipeName_2 = "配方2";
long recipeCode_2 = 20001;
string recipeCode_2 = "20001";
int Traycode_2 = 3;

double RawmaterialWeight_2 = 10;
int RawMaterialbarrelNum_2 = 1;
short RawMaterialbarrelNum_2 = 1;
int RawMaterialLocation_2 = 5;

double RawmaterialWeight1_2 = 20;
int RawMaterialbarrelNum1_2 = 2;
short RawMaterialbarrelNum1_2 = 2;
int RawMaterialLocation1_2 = 7;

double RawmaterialWeight2_2 = 30;
int RawMaterialbarrelNum2_2 = 3;
short RawMaterialbarrelNum2_2 = 3;
int RawMaterialLocation2_2 = 9;
RawMaterials.Add(new RemoteRecipeRawMaterial()
{


+ 192
- 8
BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml View File

@@ -15,7 +15,59 @@
<UserControl.DataContext>
<vm:HardwareStatusViewModel />
</UserControl.DataContext>

<UserControl.Resources>
<PathGeometry x:Key="move" Figures="M 0,0 L 0,20"/>
<Storyboard x:Key="Open" >
<DoubleAnimationUsingPath Duration="0:0:1" PathGeometry="{StaticResource move}" RepeatBehavior="Forever" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(Y)" Source="Y"></DoubleAnimationUsingPath>
</Storyboard>
<SolidColorBrush x:Key="ListBox.Static.Background" Color="#FFFFFFFF"/>
<SolidColorBrush x:Key="ListBox.Static.Border" Color="#FFABADB3"/>
<SolidColorBrush x:Key="ListBox.Disabled.Background" Color="#FFFFFFFF"/>
<SolidColorBrush x:Key="ListBox.Disabled.Border" Color="#FFD9D9D9"/>
<Style x:Key="ListViewStyle1" TargetType="{x:Type ListView}">
<Setter Property="Background" Value="{StaticResource ListBox.Static.Background}"/>
<Setter Property="BorderBrush" Value="{StaticResource ListBox.Static.Border}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
<Setter Property="ScrollViewer.PanningMode" Value="Both"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListView}">
<Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="1" SnapsToDevicePixels="true">
<ScrollViewer Focusable="false" Padding="{TemplateBinding Padding}">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</ScrollViewer>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="Bd" Value="{StaticResource ListBox.Disabled.Background}"/>
<Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource ListBox.Disabled.Border}"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsGrouping" Value="true"/>
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
</MultiTrigger.Conditions>
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<!--<UserControl.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard Storyboard="{StaticResource Open}"></BeginStoryboard>
</EventTrigger>
</UserControl.Triggers>-->
<!--<Grid>

<ListView
@@ -308,7 +360,8 @@

<!--#region 顶部料仓-->
<Grid Name="TopGrid">
<ListView
<ListView Style="{DynamicResource ListViewStyle1}"
x:Name="FListView"
Height="{Binding ElementName=TopGrid, Path=ActualHeight}"
VerticalAlignment="Center"
Background="Transparent"
@@ -333,6 +386,7 @@
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<!--<RowDefinition Height="0.1*"/>-->
</Grid.RowDefinitions>

<TextBlock
@@ -342,6 +396,32 @@
FontSize="25"
Foreground="#ffccd61f"
Text="{Binding DeviceName}" />
<StackPanel
Grid.RowSpan="2"
Panel.ZIndex="1"
Margin="55,100,0,0"
HorizontalAlignment="Center">

<Path x:Name="path" Tag="{Binding DeviceName}" Visibility="Collapsed" Data="M -15,8 L 17,17 C 17,17 19,18 17,19 L 17,19 L -15,28 C -15,28 -17,28.2 -16,26 L -16,26 L -5,18 L -16,10 C -16,10 -17,8.5 -15,8 Z">
<Path.RenderTransform>
<TransformGroup>
<RotateTransform Angle="90"/>
<TranslateTransform Y="0"/>
</TransformGroup>
</Path.RenderTransform>
<Path.Fill>
<LinearGradientBrush>
<LinearGradientBrush.RelativeTransform>
<RotateTransform Angle="-15"/>
</LinearGradientBrush.RelativeTransform>
<GradientStop Color="LightGreen" Offset="0"/>
<GradientStop Color="LightSeaGreen" Offset="0.6"/>
</LinearGradientBrush>
</Path.Fill>
</Path>
</StackPanel>



<StackPanel
Grid.Row="1"
@@ -357,8 +437,9 @@
FontSize="20"
Foreground="#FF0084FF"
Text=" kg" />
</StackPanel>

<StackPanel
Grid.Row="1"
@@ -369,7 +450,6 @@
FontSize="20"
Foreground="#FF0084FF"
Text="{Binding DeviceNum}" />

<TextBlock
FontSize="20"
Foreground="#FF0084FF"
@@ -381,6 +461,45 @@
Source="/BPASmartClient.CustomResource;component/Image/光柱.png"
Stretch="Fill" />

<!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="2">
<pry:IcoButton
Width="80"
Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="5,0,10,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#112AB2E7"
BorderThickness="0"
Command="{Binding DataContext.StartCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}"
CommandParameter="{Binding DeviceName}"
Tag="{Binding DeviceName}"
Content="启动"
EnterBackground="#222AB2E7"
Foreground="#FF2AB2E7"
IcoText="&#xe636;"
Style="{StaticResource IcoButtonStyle}"
/>
<pry:IcoButton
Width="80"
Height="{Binding ElementName=gr, Path=ActualHeight}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#11F53F62"
BorderThickness="0"
Command="{Binding DataContext.StopCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}"
CommandParameter="{Binding DeviceName}"
Tag="{Binding DeviceName}"
Content="停止"
EnterBackground="#22F53F62"
Foreground="#FFF53F62"
IcoText="&#xe68e;"
Style="{StaticResource IcoButtonStyle}" />
</StackPanel>-->

</Grid>
</Border>
</DataTemplate>
@@ -396,7 +515,7 @@
Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="10,0,30,0"
ConveyorBeltWidth="70"
Direction="1"
Direction="2"
StrokeBrush="#00BEFA"
StrokeDashArray="1.5 1.5"
StrokeFillBrush="#00BEFA"
@@ -406,6 +525,8 @@
<!--#region 底部料仓-->
<Grid Grid.Row="2">
<ListView
Style="{DynamicResource ListViewStyle1}"
x:Name="buttonListView"
VerticalAlignment="Top"
Background="Transparent"
BorderThickness="0"
@@ -426,8 +547,9 @@
<Border Margin="5" Background="Transparent">
<Grid Height="220">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition/>
<RowDefinition/>
<!--<RowDefinition Height="0.1*"/>-->
</Grid.RowDefinitions>

<TextBlock
@@ -437,7 +559,30 @@
FontSize="25"
Foreground="#ffccd61f"
Text="{Binding DeviceName}" />

<StackPanel
Grid.RowSpan="2"
Panel.ZIndex="1"
Margin="55,100,0,0"
HorizontalAlignment="Center">

<Path x:Name="path1" Tag="{Binding DeviceName}" Visibility="Collapsed" Data="M -15,8 L 17,17 C 17,17 19,18 17,19 L 17,19 L -15,28 C -15,28 -17,28.2 -16,26 L -16,26 L -5,18 L -16,10 C -16,10 -17,8.5 -15,8 Z">
<Path.RenderTransform>
<TransformGroup>
<RotateTransform Angle="90"/>
<TranslateTransform Y="0"/>
</TransformGroup>
</Path.RenderTransform>
<Path.Fill>
<LinearGradientBrush>
<LinearGradientBrush.RelativeTransform>
<RotateTransform Angle="-15"/>
</LinearGradientBrush.RelativeTransform>
<GradientStop Color="LightGreen" Offset="0"/>
<GradientStop Color="LightSeaGreen" Offset="0.5"/>
</LinearGradientBrush>
</Path.Fill>
</Path>
</StackPanel>
<StackPanel
Grid.Row="1"
Margin="0,25,0,0"
@@ -475,6 +620,45 @@
Grid.RowSpan="2"
Source="/BPASmartClient.CustomResource;component/Image/光柱.png"
Stretch="Fill" />
<!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="2">
<pry:IcoButton
Width="80"
Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="5,0,10,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#112AB2E7"
BorderThickness="0"
Command="{Binding DataContext.StartCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}"
CommandParameter="{Binding DeviceName}"
Tag="{Binding DeviceName}"
Content="启动"
EnterBackground="#222AB2E7"
Foreground="#FF2AB2E7"
IcoText="&#xe636;"
Style="{StaticResource IcoButtonStyle}"
/>
<pry:IcoButton
Width="80"
Height="{Binding ElementName=gr, Path=ActualHeight}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#11F53F62"
BorderThickness="0"
Command="{Binding DataContext.StopCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}"
CommandParameter="{Binding DeviceName}"
Tag="{Binding DeviceName}"
Content="停止"
EnterBackground="#22F53F62"
Foreground="#FFF53F62"
IcoText="&#xe68e;"
Style="{StaticResource IcoButtonStyle}" />
</StackPanel>-->


</Grid>
</Border>


+ 224
- 1
BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml.cs View File

@@ -1,4 +1,6 @@
using System;
using BPASmartClient.CustomResource.UserControls;
using BPASmartClient.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -9,6 +11,7 @@ using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
@@ -20,11 +23,231 @@ namespace BPASmartClient.JXJFoodBigStation.View
/// </summary>
public partial class HardwareStatusView : UserControl
{
Storyboard storyboard;
public HardwareStatusView()
{
InitializeComponent();
storyboard = Resources["Open"] as Storyboard;
ActionManage.GetInstance.CancelRegister("StartTopDevice");
ActionManage.GetInstance.CancelRegister("StopTopDevice");
ActionManage.GetInstance.CancelRegister("StartBottomDevice");
ActionManage.GetInstance.CancelRegister("StopBottomDevice");
ActionManage.GetInstance.Register(new Action<object>((deviceName) => {
foreach (var item in this.FListView.Items)
{
var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag.ToString() == deviceName.ToString()&& storyboard != null)
{
pt.Visibility = Visibility.Visible;
pt.BeginStoryboard(storyboard);
}

}
}

}),"StartTopDevice" );

ActionManage.GetInstance.Register(new Action<object>((deviceName) => {
foreach (var item in this.FListView.Items)
{
var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag.ToString() == deviceName.ToString())

pt.Visibility = Visibility.Collapsed;
}
}

}), "StopTopDevice");

ActionManage.GetInstance.Register(new Action<object>((deviceName) => {
foreach (var item in this.buttonListView.Items)
{
var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path1", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag.ToString() == deviceName.ToString() && storyboard != null)
{
pt.Visibility = Visibility.Visible;
pt.BeginStoryboard(storyboard);
}

}
}

}), "StartBottomDevice");

ActionManage.GetInstance.Register(new Action<object>((deviceName) => {
foreach (var item in this.buttonListView.Items)
{
var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path1", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag.ToString() == deviceName.ToString())

pt.Visibility = Visibility.Collapsed;
}
}

}), "StopBottomDevice");

}
//顶部启动下料动画
private void IcoButton_Click(object sender, RoutedEventArgs e)
{
foreach (var item in this.FListView.Items)
{
var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag == (sender as IcoButton).Tag&&storyboard!=null)
{
pt.Visibility = Visibility.Visible;
pt.BeginStoryboard(storyboard);
}
}
}
}

//顶部停止下料动画
private void IcoButton_Click_1(object sender, RoutedEventArgs e)
{
foreach (var item in this.FListView.Items)
{
var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag == (sender as IcoButton).Tag)

pt.Visibility = Visibility.Collapsed;
}
}
}
//底部启动下料动画
private void IcoButton_Click_2(object sender, RoutedEventArgs e)
{
foreach (var item in this.buttonListView.Items)
{
var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path1", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag == (sender as IcoButton).Tag && storyboard != null)
{
pt.Visibility = Visibility.Visible;
pt.BeginStoryboard(storyboard);
}

}
}
}
//底部停止下料动画
private void IcoButton_Click_3(object sender, RoutedEventArgs e)
{
foreach (var item in this.buttonListView.Items)
{
var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path1", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag == (sender as IcoButton).Tag)

pt.Visibility = Visibility.Collapsed;
}
}
}

private childItem FindVisualChild<childItem>(DependencyObject obj)
where childItem : DependencyObject
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(obj, i);
if (child != null && child is childItem)
return (childItem)child;
else
{
childItem childOfChild = FindVisualChild<childItem>(child);
if (childOfChild != null)
return childOfChild;
}
}
return null;
}
}
}

+ 6
- 4
BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml View File

@@ -334,7 +334,7 @@
<ColumnDefinition Width="225"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<ComboBox ItemsSource="{Binding DataContext.materialNames,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" Text="{Binding RawMaterialLocation}" Margin="10,0,0,10" Width="190" FontSize="14" KeyUp="ComboBox_KeyUp" LostFocus="ComboBox_LostFocus">
<!--<ComboBox ItemsSource="{Binding DataContext.materialNames,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" Text="{Binding RawMaterialLocation}" Margin="10,0,0,10" Width="190" FontSize="14" KeyUp="ComboBox_KeyUp" LostFocus="ComboBox_LostFocus">
<ComboBox.ItemContainerStyle>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="Background" Value="White" />
@@ -342,8 +342,10 @@

</Style>
</ComboBox.ItemContainerStyle>
</ComboBox>
</ComboBox.ItemContainerStyle>-->
<!--</ComboBox>-->
<TextBox Text="{Binding RawMaterialName}" Background="Transparent" FontSize="14"
BorderBrush="#e69519" Foreground="LightGray" Width="190" Margin="10,0,0,10" ></TextBox>
<StackPanel Grid.Column="1" Orientation="Horizontal" >
<TextBox Text="{Binding RawMaterialBarrelNum}" Background="Transparent" FontSize="14"
BorderBrush="#e69519" Foreground="LightGray" Width="170" Margin="35,0,0,10" ></TextBox>
@@ -362,7 +364,7 @@
Background="Transparent"
BorderBrush="#e69519" Foreground="LightGray" HorizontalAlignment="Right"
Command="{Binding DataContext.RemoveRecipe,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}"
CommandParameter="{Binding RawMaterialLocation}"></Button>
CommandParameter="{Binding RawMaterialName}"></Button>
</Grid>
</ControlTemplate>
</RadioButton.Template>


+ 5
- 4
BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml View File

@@ -168,7 +168,7 @@
Foreground="Aqua"
IcoText="&#xe626;"
Style="{StaticResource IcoButtonStyle}" />
<pry:IcoButton
<!--<pry:IcoButton
Width="140"
Margin="10"
HorizontalAlignment="Left"
@@ -177,7 +177,7 @@
FontSize="16"
Foreground="Aqua"
IcoText="&#xe626;"
Style="{StaticResource IcoButtonStyle}" />
Style="{StaticResource IcoButtonStyle}" />-->

<pry:IcoButton
Grid.Column="3"
@@ -241,6 +241,7 @@

<TextBlock
Grid.Row="1"
FontSize="16"
Margin="5,0,0,0"
VerticalAlignment="Top"
Foreground="#FF2AB2E7"
@@ -271,13 +272,13 @@
</RadialGradientBrush>
</Border.Background>
</Border>
<TextBlock Text="{Binding RawMaterialLocation }" Foreground="#FF2AB2E7" VerticalAlignment="Center"/>
<TextBlock Text="{Binding RawMaterialName }" Foreground="#FF2AB2E7" VerticalAlignment="Center" FontSize="14" />
</StackPanel>
</Expander.Header>
<Expander.Content>
<StackPanel Margin="36,0,0,0">
<StackPanel Orientation="Horizontal">
<TextBlock Text="托盘号:" Foreground="#FF2AB2E7"/>
<TextBlock Text="托盘号:" Foreground="#FF2AB2E7"/>
<TextBlock Text="{Binding RawMaterialBarrelNum}" Foreground="#FF2AB2E7"/>
</StackPanel>
<StackPanel Orientation="Horizontal">


+ 2
- 1
BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml View File

@@ -473,6 +473,7 @@

<TextBlock
Grid.Row="1"
FontSize="16"
Margin="5,0,0,0"
VerticalAlignment="Top"
Foreground="#FF2AB2E7"
@@ -503,7 +504,7 @@
</RadialGradientBrush>
</Border.Background>
</Border>
<TextBlock Text="{Binding RawMaterialLocation }" Foreground="#FF2AB2E7" VerticalAlignment="Center"/>
<TextBlock Text="{Binding RawMaterialName }" Foreground="#FF2AB2E7" VerticalAlignment="Center" FontSize="14"/>
</StackPanel>
</Expander.Header>
<Expander.Content>


+ 43
- 0
BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs View File

@@ -22,6 +22,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus()
{
DeviceName = i.ToString(),
DeviceNum=i,
RunStatus = false,
Weight = new Random().Next(0, 100)
});
@@ -31,13 +32,55 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus()
{
DeviceName = i.ToString(),
DeviceNum = i,
RunStatus = false,
Weight = new Random().Next(0, 100)
});
}

StartCommand = new RelayCommand<string>((deviceName) => {
//PLC控制

//动画
if (deviceName != null)
{
var top= TopDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName);
if (top != null)
{
ActionManage.GetInstance.Send("StartTopDevice", deviceName);
}
var bottom = BottomDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName);
if (bottom != null)
{
ActionManage.GetInstance.Send("StartBottomDevice", deviceName);
}
}
});
StopCommand = new RelayCommand<string>((deviceName) => {
//PLC控制

//动画
if (deviceName != null)
{
var top = TopDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName);
if (top != null)
{
ActionManage.GetInstance.Send("StopTopDevice", deviceName);
}
var bottom = BottomDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName);
if (bottom != null)
{
ActionManage.GetInstance.Send("StopBottomDevice", deviceName);
}
}
});
}

public ObservableCollection<DeviceCurrentStatus> TopDeviceCurrentStatuses { get; set; } = new ObservableCollection<DeviceCurrentStatus>();
public ObservableCollection<DeviceCurrentStatus> BottomDeviceCurrentStatuses { get; set; } = new ObservableCollection<DeviceCurrentStatus>();

public RelayCommand<string> StartCommand { get; set; }

public RelayCommand<string> StopCommand { get; set; }
}
}

+ 8
- 7
BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs View File

@@ -47,7 +47,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
if (name == null)
{
go:
long recipeCode = new Random().Next(10000, 99999);
string recipeCode = new Random().Next(10000, 99999).ToString();
var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == recipeCode);
if (res == null)
{
@@ -76,6 +76,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
bom.RawMaterial.Add(item);
}
bom.RecipeName = RecipeName;
bom.TrayCode = TrayCode;
Json<LocaPar>.Save();
ActionManage.GetInstance.Send("CloseRecipeInfosView");
}
@@ -88,7 +89,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
if (bom == null && rec != null)//配方名称更改
{
prop: long recipeCode = new Random().Next(10000, 99999);//配方唯一ID,后期根据实际要求更改
prop: string recipeCode = new Random().Next(10000, 99999).ToString();//配方唯一ID,后期根据实际要求更改
var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == recipeCode);
if (res == null)
{
@@ -108,9 +109,9 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
ActionManage.GetInstance.Send("CloseNewRecipeView");
});

RemoveRecipe = new RelayCommand<int>((materilaName) => {
RemoveRecipe = new RelayCommand<string>((materilaName) => {

var res= RawMaterialsInfo.FirstOrDefault(p=>p.RawMaterialLocation==materilaName);
var res= RawMaterialsInfo.FirstOrDefault(p=>p.RawMaterialName==materilaName);
if (res != null)
RawMaterialsInfo.Remove(res);
});
@@ -123,8 +124,8 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } }
private string _mRecipeName;

public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } }
private long _mRecipeCode;
public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } }
private string _mRecipeCode;

public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } }
private int _mTrayCode;
@@ -137,7 +138,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel

public RelayCommand SaveAs { get; set; }

public RelayCommand<int> RemoveRecipe { get; set; }
public RelayCommand<string> RemoveRecipe { get; set; }

public ObservableCollection<RawMaterialModel> RawMaterialsInfo { get; set; } = new ObservableCollection<RawMaterialModel>() ;
}


+ 41
- 42
BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs View File

@@ -30,7 +30,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
Recipes = Json<LocaPar>.Data.Recipes;
DetailsCommand = new RelayCommand<object>((o) =>
{
if (o != null && o is long num)
if (o != null && o is string num)
{
ActionManage.GetInstance.CancelRegister("RecipeInfo");
RecipeInfosView nrv = new RecipeInfosView();
@@ -45,51 +45,51 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
RecipeInfosView nrv = new RecipeInfosView();
nrv.ShowDialog();
});
NewSimulateRecipe = new RelayCommand(() =>
{
RawMaterials.Clear();
string recipeName = "配方" + (Json<LocaPar>.Data.Recipes.Count + 1) + "";
go:
long recipeCode = new Random().Next(10000, 99999);
foreach (var item in Recipes)
{
if (item.RecipeCode == recipeCode)
{
goto go;
}
}
int trayCode = new Random().Next(1,6);
for (int i = 1; i < 13; i++)
{
int a = new Random().Next(1, 5);
if (a == 3)
{
a = 1;
}
RawMaterials.Add(new RawMaterialModel()
{
RawMaterialWeight = new Random().Next(10, 1000),
RawMaterialBarrelNum = a,
RawMaterialLocation = i,
});
}
Json<LocaPar>.Data.Recipes.Add(new RecipeModel()
{
RecipeName = recipeName,
RecipeCode = recipeCode,
TrayCode = trayCode,
RawMaterial = RawMaterials,
});
});
//模拟配方
//NewSimulateRecipe = new RelayCommand(() =>
//{
// RawMaterials.Clear();
// string recipeName = "配方" + (Json<LocaPar>.Data.Recipes.Count + 1) + "";
//go:
// string recipeCode = new Random().Next(10000, 99999).ToString();
// foreach (var item in Recipes)
// {
// if (item.RecipeCode == recipeCode)
// {
// goto go;
// }
// }
// int trayCode = new Random().Next(1,6);
// for (int i = 1; i < 13; i++)
// {
// int a = new Random().Next(1, 5);
// if (a == 3)
// {
// a = 1;
// }
// RawMaterials.Add(new RawMaterialModel()
// {
// RawMaterialWeight = new Random().Next(10, 1000),
// RawMaterialBarrelNum = a,
// RawMaterialLocation = i,
// });
// }
// Json<LocaPar>.Data.Recipes.Add(new RecipeModel()
// {
// RecipeName = recipeName,
// RecipeCode = recipeCode,
// TrayCode = trayCode,
// RawMaterial = RawMaterials,
// });
// Json<LocaPar>.Save();
//});
ClearAllRecipe = new RelayCommand(() =>
{
Json<LocaPar>.Data.Recipes.Clear();
Json<LocaPar>.Save();
});

RemoveCommand = new RelayCommand<long>((recipeCode) => {
RemoveCommand = new RelayCommand<string>((recipeCode) => {

var res = Recipes.FirstOrDefault(p=>p.RecipeCode==recipeCode);
if(res!=null)
@@ -102,13 +102,12 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
}

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

public RelayCommand NewSimulateRecipe { get; set; }
public RelayCommand ClearAllRecipe { get; set; }

public RelayCommand NewRecipe { get; set; }

public RelayCommand<long> RemoveCommand { get; set; }
public RelayCommand<string> RemoveCommand { get; set; }

public ObservableCollection<RecipeModel> Recipes { get; set; } = new ObservableCollection<RecipeModel>();
}


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

@@ -14,7 +14,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
internal class RecipeSendDownViewModel:ObservableObject
{

public static ObservableCollection<RecipeModel> Recipes { get; set; } = Json<LocaPar>.Data.Recipes;
public ObservableCollection<RecipeModel> Recipes { get; set; } = Json<LocaPar>.Data.Recipes;
/// <summary>
/// 当前正在制作的配方
/// </summary>


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

@@ -18,13 +18,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
public bool IssueRecipeFinishStation1 { get; set; } = false;
/// <summary>
/// 托盘1配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
/// </summary>
public int RecipeStatusIDTray1 { get; set; } = 0;
/// <summary>
/// 托盘2配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
/// </summary>
public int RecipeStatusIDTray2 { get; set; } = 0;
public int RecipeStatusID { get; set; } = 0;
/// <summary>
/// 往输送带下发配方完成
/// </summary>


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

@@ -65,8 +65,53 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
{
if (IsConnected)
{
HK_PLC_S7.Write(HKPlcCommAddress.BarrelNumToPLC, BarrelNum);
HK_PLC_S7.Write(HKPlcCommAddress.StockBinLocationToPLC, StockBinLocation);
if (BarrelNum >= 1 && BarrelNum <= 4 && StockBinLocation >= 1 && StockBinLocation <= 15)
{
if (BarrelNum == 1)
{
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX10." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX11." + (StockBinLocation - 9), true);
}
}
else if (BarrelNum == 2)
{
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX12." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX13." + (StockBinLocation - 9), true);
}
}
else if (BarrelNum == 3)
{
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX14." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX15." + (StockBinLocation - 9), true);
}
}
else if (BarrelNum == 4)
{
if (StockBinLocation >= 1 && StockBinLocation <= 8)
{
HK_PLC_S7.Write<bool>("DB4.DBX16." + (StockBinLocation - 1), true);
}
else if (StockBinLocation >= 9 && StockBinLocation <= 15)
{
HK_PLC_S7.Write<bool>("DB4.DBX17." + (StockBinLocation - 9), true);
}
}
}
}
}
}


+ 91
- 193
BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs View File

@@ -27,69 +27,71 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// </summary>
public ObservableCollection<RemoteRecipeData> RemoteRecipes = new ObservableCollection<RemoteRecipeData>();
/// <summary>
/// 托盘1 配方队列
/// 原料的名称和料仓的位置对应
/// </summary>
public ConcurrentQueue<long> RecipeTray1Queue = new ConcurrentQueue<long>();
public Dictionary<string, short> RawMaterialsNamePos = new Dictionary<string, short>();
/// <summary>
/// 托盘2 配方队列
/// 配方队列
/// </summary>
public ConcurrentQueue<long> RecipeTray2Queue = new ConcurrentQueue<long>();
public ConcurrentQueue<string> RecipeQueue = new ConcurrentQueue<string>();

public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
public HKDeviceStatus HKDevice = new HKDeviceStatus();
GVL_SmallStation SmallStation = new GVL_SmallStation();
XL_Finish_DB RecipeFinishInfo = new XL_Finish_DB();
/// <summary>
/// 接收原料数据
/// </summary>
public RecipeRawMaterial RawMaterial;
public void Init()
{
ActionManage.GetInstance.Register(new Action(() =>
for (int i = 0; i < 16; i++)
{
if (DeviceInquire.GetInstance.GetDevice(i).DeviceName != null)
{
if (!RawMaterialsNamePos.ContainsKey(DeviceInquire.GetInstance.GetDevice(i).DeviceName))
{
RawMaterialsNamePos.Add(DeviceInquire.GetInstance.GetDevice(i).DeviceName, (short)DeviceInquire.GetInstance.GetDevice(i).deviceStatus.DeviceNum);
}
}
}
ActionManage.GetInstance.Register(new Action<XL_Start_DB>((res) =>
{
if (SiemensDevice.IsConnected)
{
var res = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeName);
var res1 = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeID);
int res2 = SiemensDevice.Siemens_PLC_S7.ReadClass(RawMaterial, 0, 0);
if ((res != null && res is string recipeName) &&
(res1 != null && res1 is uint recipeID) &&
(res2 > 0))
if (res != null)
{
RawMaterials.Clear();
for (int i = 0; i < 15; i++)
{
RawMaterials.Add(new RemoteRecipeRawMaterial()
if (RawMaterialsNamePos.ContainsKey(res.Material[i].Material_Name))
{
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
RawMaterialName = res.Material[i].Material_Name,
RawMaterialBarrelNum = res.Material[i].Material_BarrelNum,
RawMaterialWeight = res.Material[i].Material_Weight,
RawMaterialLocation = (int)RawMaterialsNamePos[res.Material[i].Material_Name]
});
}
else
{
RawMaterialBarrelNum = RawMaterial.RawMaterialBarrelNum[i],
RawMaterialLocation = RawMaterial.RawMaterialLocation[i],
RawMaterialWeight = RawMaterial.RawMaterialWeight[i]
});
//报警,配方的原料名称下发和设备不一致
}
}
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
{
RecipeName = recipeName,
RecipeCode = recipeID,
RawMaterial = RawMaterials
RecipeName = res.RecipeName,
RecipeCode = res.RecipeCode,
RawMaterial = RawMaterials,
TrayCode = res.TrayCode
});
}
}
}), "西门子下发配方", true);
ActionManage.GetInstance.Register(new Action(() =>
{
if (SiemensDevice.IsConnected)
{
var res = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.TrayLocationNum);
var res1 = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeID);
if (res != null && res is int TrayLocation && res1 != null && res1 is int recipeId)
{
int index = Array.FindIndex(Json<RemoteRecipeDataColl>.Data.Recipes.ToArray(), p => p.RecipeCode == recipeId);
if (index >= 0 && index < Json<RemoteRecipeDataColl>.Data.Recipes.Count)
{
Json<RemoteRecipeDataColl>.Data.Recipes.ElementAt(index).TrayCode = TrayLocation;
}
}
}
}), "AGV到位信号", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"];
string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
try
@@ -109,7 +111,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
}
RecipeTray1Queue.Clear();
RecipeQueue.Clear();
//Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
ThreadManage.GetInstance().StartLong(new Action(() =>
{
@@ -416,42 +418,42 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
switch (SmallStation.AgvDeliveryPosition)
{
case 0:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVApply) is bool))
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.DeliveryAGVApply) is bool))
{
SmallStation.AgvDeliveryPosition = 1;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApply, true);
}
break;
case 1:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApply) is bool))
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.DeliveryAGVIsApply)))
{
SmallStation.AgvDeliveryPosition = 2;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApply, true);
}
break;
case 2:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVApplyJack) is bool))
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.DeliveryAGVApplyJack) is bool))
{
SmallStation.AgvDeliveryPosition = 3;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApplyJack, true);
}
break;
case 3:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApplyJack) is bool))
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.DeliveryAGVIsApplyJack)))
{
SmallStation.AgvDeliveryPosition = 4;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApplyJack, true);
}
break;
case 4:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVFinsih) is bool))
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.DeliveryAGVFinsih) is bool))
{
SmallStation.AgvDeliveryPosition = 5;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVFinsih, true);
}
break;
case 5:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationHaveCargo) is bool))
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.StationHaveCargo)))
{
SmallStation.AgvDeliveryPosition = 0;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationHaveCargo, true);
@@ -462,7 +464,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
//获取工位上是否有小车
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool)
HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationIsExistTray));
HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.StationIsExistTray));
}
/// <summary>
/// AGV进站取货
@@ -472,28 +474,28 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
switch (SmallStation.AgvPickUpPosition)
{
case 0:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.PickAGVApply) is bool))
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<bool>(SiemensCommAddress.PickAGVApply)))
{
SmallStation.AgvPickUpPosition = 1;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.PickAGVApply, true);
}
break;
case 1:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.PickAGVIsApply) is bool))
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.PickAGVIsApply)))
{
SmallStation.AgvPickUpPosition = 2;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVIsApply, true);
}
break;
case 2:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.PickCargoAGVFinish) is bool))
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.PickCargoAGVFinish) is bool))
{
SmallStation.AgvPickUpPosition = 3;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.PickCargoAGVFinish, true);
}
break;
case 3:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.PickAGVFinish) is bool))
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.PickAGVFinish)))
{
SmallStation.AgvPickUpPosition = 0;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVFinish, true);
@@ -503,6 +505,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
break;
}
}
/// <summary>
/// 将配方添加到配方队列中
/// </summary>
private void ReceviceData()
{
RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
@@ -510,31 +515,26 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
foreach (var data in RemoteRecipes)
{
if (data.TrayCode == 1)
{
if (!(RecipeTray1Queue.Contains(data.RecipeCode)))
RecipeTray1Queue.Enqueue(data.RecipeCode);
}
else if (data.TrayCode == 2)
{
if (!(RecipeTray2Queue.Contains(data.RecipeCode)))
RecipeTray2Queue.Enqueue(data.RecipeCode);
}
if (!(RecipeQueue.Contains(data.RecipeCode)))
RecipeQueue.Enqueue(data.RecipeCode);
}
}
}
/// <summary>
/// 执行配方队列中的第一个配方
/// </summary>
private void RecipeInfoToHKPLC()
{
if (RecipeTray1Queue.Count > 0)
if (RecipeQueue.Count > 0)
{
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeTray1Queue.ElementAt(0));
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0));
if (index >= 0 && index < RemoteRecipes.Count)
{
long code = RemoteRecipes.ElementAt(index).RecipeCode;
string code = RemoteRecipes.ElementAt(index).RecipeCode;
int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
if (trayCode == 1 && SmallStation.RecipeStatusIDTray1 == 0)
if (trayCode == 1 && SmallStation.RecipeStatusID == 0)
{
if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.5") is bool && SmallStation.RecipeStatusIDTray1 == 0)
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.5") && SmallStation.RecipeStatusID == 0)
{
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
{
@@ -542,18 +542,18 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
HKDevice.HK_PLC_S7.Write("DB3.DBX1.5", false);
HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true);
SmallStation.RecipeStatusIDTray1 = 1;
SmallStation.RecipeStatusID = 1;
}
if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.3") is bool && SmallStation.RecipeStatusIDTray1 == 1)
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.3") && SmallStation.RecipeStatusID == 1)
{
HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", false);
SmallStation.RecipeStatusIDTray1 = 2;
SmallStation.RecipeStatusID = 2;
}
if (SmallStation.RecipeStatusIDTray1 == 2)
if (SmallStation.RecipeStatusID == 2)
{
if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.0") is bool)
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0"))
{
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD10");
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD10");
if (res != null && res is float loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
@@ -566,9 +566,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
}
else if(HKDevice.HK_PLC_S7.Read("DB3.DBX50.1") is bool)
else if(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.1"))
{
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD14");
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD14");
if (res != null && res is float loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
@@ -581,9 +581,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
}
else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.2") is bool)
else if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.2"))
{
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD18");
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD18");
if (res != null && res is float loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
@@ -596,9 +596,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
}
else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.3") is bool)
else if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.3"))
{
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD22");
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD22");
if (res != null && res is float loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
@@ -615,10 +615,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3)
{
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;
DeviceInquire.GetInstance.GetDevice(i).StatusReset();
if (i >= 1 && i <= 8)
{
HKDevice.HK_PLC_S7.Write("DB4.DBX30."+ (i-1), true);
HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true);
}
else if (i >= 9 && i <= 15)
{
@@ -626,131 +628,27 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
}
if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.1") is bool)
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1"))
{
var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
MessageLog.GetInstance.ShowRunLog($"托盘1 配方{res.RecipeName}配料完成");
Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res);
RecipeTray1Queue.TryDequeue(out code);
HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false);
SmallStation.RecipeStatusIDTray1 = 0;
}
}
}
}
}
if (RecipeTray2Queue.Count > 0)
{
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeTray2Queue.ElementAt(0));
if (index >= 0 && index < RemoteRecipes.Count)
{
long code = RemoteRecipes.ElementAt(index).RecipeCode;
int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
if (trayCode == 2 && SmallStation.RecipeStatusIDTray2 == 0)
{
if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.6") is bool && SmallStation.RecipeStatusIDTray2 == 0)
{
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
{
HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation);
}
HKDevice.HK_PLC_S7.Write("DB3.DBX1.6", false);
HKDevice.HK_PLC_S7.Write("DB4.DBX1.4", true);
SmallStation.RecipeStatusIDTray2 = 1;
}
if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.4") is bool && SmallStation.RecipeStatusIDTray2 == 1)
{
HKDevice.HK_PLC_S7.Write("DB3.DBX1.4", false);
SmallStation.RecipeStatusIDTray2 = 2;
}
if (SmallStation.RecipeStatusIDTray2 == 2)
{
if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.4") is bool)
{
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD26");
if (res != null && 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).RawMaterialWeight;
if (loc_index >= 1 && loc_index <= 15)
{
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//根据料仓编号 启动并写入每个原料重量
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.4", false);
}
}
}
else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.5") is bool)
{
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD30");
if (res != null && 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).RawMaterialWeight;
if (loc_index >= 1 && loc_index <= 15)
{
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.5", false);
}
}
}
else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.6") is bool)
{
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD34");
if (res != null && 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).RawMaterialWeight;
if (loc_index >= 1 && loc_index <= 15)
{
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.6", false);
}
}
}
else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.7") is bool)
{
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD38");
if (res != null && 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).RawMaterialWeight;
if (loc_index >= 1 && loc_index <= 15)
{
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.7", false);
}
}
}
for (int i = 1; i < 16; i++)
{
if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3)
MessageLog.GetInstance.ShowRunLog($"配方{res.RecipeName}配料完成");
RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
for (int i = 0; i < 16; i++)
{
DeviceInquire.GetInstance.GetDevice(i).StatusReset();
if (i >= 1 && i <= 8)
{
HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true);
}
else if (i >= 9 && i <= 15)
{
HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true);
}
RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
}
}
if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.2") is bool)
{
var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
MessageLog.GetInstance.ShowRunLog($"托盘2 配方{res.RecipeName}配料完成");
SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 3);
RecipeFinishInfo.Ask_For_Finish = true;
Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res);
RecipeTray1Queue.TryDequeue(out code);
HKDevice.HK_PLC_S7.Write("DB3.DBX1.2", false);
SmallStation.RecipeStatusIDTray2 = 0;
RecipeQueue.TryDequeue(out code);
HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false);
SmallStation.RecipeStatusID = 0;
}
}
}
}
}
}
}


+ 35
- 3
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs View File

@@ -60,9 +60,43 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
Thread.Sleep(200);
}), "设备状态监听");
}
private void TestData()
{
for (int i = 0; i < 8; i++)
{
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus()
{
DeviceName = $"测试设备{i + 1}",
DeviceNum = i + 1,
Weight = new Random().Next(100, 10000) / 100.0
});

devices.Add(new Devices()
{
DeviceName = $"测试设备{i + 1}",
IpAddress = $"192.168.1.{i + 1}",
});
}

for (int i = 8; i < 16; i++)
{
BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus()
{
DeviceName = $"测试设备{i + 1}",
DeviceNum = i + 1,
Weight = new Random().Next(100, 10000) / 100.0
});

devices.Add(new Devices()
{
DeviceName = $"测试设备{i + 1}",
IpAddress = $"192.168.1.{i + 1}",
});
}
}
public void Init()
{
TestData();
IpAddressLines();
DeviceDataInit();
ThreadManage.GetInstance().StartLong(new Action(() =>
@@ -266,11 +300,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
//{
// if (ushortValue.Length >= 1) deviceStatus.RunStatus = ushortValue[0];
//}


this.DeviceName = modbusTcp.GetString(DeviceAddress.DeviceName, 20).Trim()?.Replace(" ", "");
deviceStatus.RunStatus = (ushort)this.modbusTcp.ReadShort(DeviceAddress.RunStatus); //获取设备运行状态
deviceStatus.WeightFeedback = (float)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);//获取设备故障编码



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

@@ -12,7 +12,5 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
public class LocaPar
{
public ObservableCollection<RecipeModel> Recipes { get; set; } = new ObservableCollection<RecipeModel>();

}
}

+ 5
- 0
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs View File

@@ -22,6 +22,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// </summary>
public float WeightFeedback { get; set; }

/// <summary>
/// 当前出料重量反馈
/// </summary>
public float NowWeightFeedback { get; set; }

/// <summary>
/// 上限反馈
/// </summary>


+ 2
- 2
BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs View File

@@ -18,8 +18,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// <summary>
/// 配方ID
/// </summary>
public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; } }
private long _mRecipeCode;
public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; } }
private string _mRecipeCode;
/// <summary>
/// 托盘编号


+ 10
- 4
BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs View File

@@ -11,13 +11,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
public int DeviceIp { get { return _mIp; } set { _mIp = value; }}
private int _mIp;

public int RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } }
private int _mRawMaterialName;
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } }
private string _mRawMaterialName;
/// <summary>
/// 原料对应的桶号
/// </summary>
public int RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; } }
private int _mRawMaterialBarrelNum;
public short RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; } }
private short _mRawMaterialBarrelNum;

/// <summary>
/// 需要原料重量
@@ -25,6 +25,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
public double RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; } }
private double _mRawMaterialWeight;

/// <summary>
/// 实际的下料中重量
/// </summary>
public float Laying_Off_Weight { get { return _mLaying_Off_Weight; } set { _mLaying_Off_Weight = value; } }
private float _mLaying_Off_Weight;

/// <summary>
/// 原料对应料仓的位置
/// </summary>


+ 27
- 33
BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs View File

@@ -6,6 +6,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.S7Net;
using System.Threading;

namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
{
@@ -14,51 +15,44 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
public SiemensHelper Siemens_PLC_S7 = new SiemensHelper();
public bool IsConnected => Siemens_PLC_S7.IsConnected;

/// <summary>
/// 配方接收信号复位
/// </summary>
public void RecipeSignReset()
{
this.Siemens_PLC_S7.Write(SiemensCommAddress.RecipeState, (ushort)0);
}
/// <summary>
/// AGV到位信号复位
/// </summary>
public void AgvSignReset()
{
this.Siemens_PLC_S7.Write(SiemensCommAddress.StateSign, (ushort)0);
}
public void Init()
{
if (IsConnected)
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
var res = this.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeState);
if (res != null && RTrig.GetInstance("RecipeTrig").Start(res is bool SignTrig))
var res = this.Siemens_PLC_S7.ReadClass<XL_Start_DB>(1);
var res1 = this.Siemens_PLC_S7.ReadClass<XL_Status_DB>(2);
var res2 = this.Siemens_PLC_S7.ReadClass<XL_Finish_DB>(3);
if (res != null && RTrig.GetInstance("RecipeTrig").Start(res.Ask_For_Send_Bit))
{
ActionManage.GetInstance.Send("西门子下发配方",res);
res.Ask_For_Send_Bit = false;
this.Siemens_PLC_S7.WriteClass<XL_Start_DB>(res, 1);
}
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(res1.Allow_AGV_Put[0]))
{
ActionManage.GetInstance.Send("西门子下发配方");
RecipeSignReset();
ActionManage.GetInstance.Send("AGV到工位1信号",res1);
res1.Allow_AGV_Put[0] = false;
this.Siemens_PLC_S7.WriteClass<XL_Status_DB>(res1, 2);
}
var AgvState = this.Siemens_PLC_S7.Read(SiemensCommAddress.StateSign);
if (AgvState != null && RTrig.GetInstance("AgvTrig").Start(res is bool AgvSignTrig))
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(res1.Allow_AGV_Put[1]))
{
ActionManage.GetInstance.Send("AGV到位信号");
AgvSignReset();
ActionManage.GetInstance.Send("AGV到工位2信号",res1);
res1.Allow_AGV_Put[1] = false;
this.Siemens_PLC_S7.WriteClass<XL_Status_DB>(res1, 2);
}

if (res2 != null && res2.Ask_For_Finish_PLC)
{
ActionManage.GetInstance.Send("配料完成信号确认完成");
res2.Ask_For_Finish_PLC = false;
this.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(res2, 3);
}
Thread.Sleep(10);
}),"监听服务数据");
}
}
/// <summary>
/// 配方配料完成信号
/// </summary>
/// <param name="TrayLocation"></param>
/// <param name="recipeID"></param>
private void DosingFinsih(int TrayLocation,int recipeID)
{
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayLocationNumToSiemens, TrayLocation);
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayStateToSiemens, 1);
this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayRecipeIDToSiemens, recipeID);
}
}
}

+ 39
- 0
BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs View File

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

namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
{
internal class XL_Finish_DB
{
/// <summary>
/// 生产工单编码
/// </summary>
public string Order_No;
/// <summary>
/// 产品名称
/// </summary>
public string Product_Code;
/// <summary>
/// 原料信息
/// </summary>
public UDT1[] Material = new UDT1[20];
/// <summary>
/// 配料完成信号
/// </summary>
public bool Ask_For_Finish;
/// <summary>
/// 配料完成信号确认
/// </summary>
public bool Ask_For_Finish_PLC;

}
public class UDT1
{
public string Material_Name;
public float Material_Laying_Off_Weight;
public short Material_BarrelNum;
}
}

+ 52
- 0
BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs View File

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

namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
{
internal class XL_Start_DB
{
/// <summary>
/// 配方编码
/// </summary>
public string RecipeCode;
/// <summary>
/// 配发名称
/// </summary>
public string RecipeName;
/// <summary>
/// 物料信息
/// </summary>
public UDT[] Material = new UDT[20];
/// <summary>
/// 托盘编号
/// </summary>
public int TrayCode;
/// <summary>
/// 配方发送请求
/// </summary>
public bool Ask_For_Send_Bit;
/// <summary>
/// 上位机确认配方接收完成
/// </summary>
public bool Ack_Ask_For_Send_Bit;

}
public class UDT
{
/// <summary>
/// 原料名称
/// </summary>
public string Material_Name;
/// <summary>
/// 原料重量
/// </summary>
public float Material_Weight;
/// <summary>
/// 原料桶号
/// </summary>
public short Material_BarrelNum;
}
}

+ 60
- 0
BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs View File

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

namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
{
internal class XL_Status_DB
{
/// <summary>
/// 生产工单
/// </summary>
public string Order_No;
/// <summary>
/// 配料开始
/// </summary>
public bool Dosing_Start;
/// <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;
/// <summary>
/// 备用
/// </summary>
public byte Reserve;
}
}

+ 8
- 8
BPASmartClient.JXJFoodSmallStation/Model/TestData.cs View File

@@ -18,19 +18,19 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
public TestData()
{
string recipeName = "配方1";
long recipeCode = 10001;
string recipeCode = "10001";
int Traycode = 1;

double RawmaterialWeight = 10;
int RawMaterialbarrelNum = 1;
short RawMaterialbarrelNum = 1;
int RawMaterialLocation = 5;

double RawmaterialWeight1 = 20;
int RawMaterialbarrelNum1 = 2;
short RawMaterialbarrelNum1 = 2;
int RawMaterialLocation1 = 7;

double RawmaterialWeight2 = 30;
int RawMaterialbarrelNum2 = 3;
short RawMaterialbarrelNum2 = 3;
int RawMaterialLocation2 = 9;
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
@@ -64,19 +64,19 @@ namespace BPASmartClient.JXJFoodSmallStation.Model

RawMaterials.Clear();
string recipeName_2 = "配方2";
long recipeCode_2 = 20001;
string recipeCode_2 = "20001";
int Traycode_2 = 3;

double RawmaterialWeight_2 = 10;
int RawMaterialbarrelNum_2 = 1;
short RawMaterialbarrelNum_2 = 1;
int RawMaterialLocation_2 = 5;

double RawmaterialWeight1_2 = 20;
int RawMaterialbarrelNum1_2 = 2;
short RawMaterialbarrelNum1_2 = 2;
int RawMaterialLocation1_2 = 7;

double RawmaterialWeight2_2 = 30;
int RawMaterialbarrelNum2_2 = 3;
short RawMaterialbarrelNum2_2 = 3;
int RawMaterialLocation2_2 = 9;
RawMaterials.Add(new RemoteRecipeRawMaterial()
{


+ 2
- 2
BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs View File

@@ -42,8 +42,8 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } }
private string _mRecipeName;

public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } }
private long _mRecipeCode;
public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } }
private string _mRecipeCode;

public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } }
private int _mTrayCode;


+ 3
- 3
BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs View File

@@ -30,7 +30,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
Recipes = Json<RemoteRecipeDataColl>.Data.Recipes;
DetailsCommand = new RelayCommand<object>((o) =>
{
if (o != null && o is long num)
if (o != null && o is string num)
{
ActionManage.GetInstance.CancelRegister("RecipeInfo");
RecipeInfosView nrv = new RecipeInfosView();
@@ -45,7 +45,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
RawMaterials.Clear();
string recipeName = "配方" + (Json<RemoteRecipeDataColl>.Data.Recipes.Count + 1) + "";
go:
long recipeCode = new Random().Next(1000, 9999);
string recipeCode = new Random().Next(1000, 9999).ToString();
foreach (var item in Recipes)
{
if (item.RecipeCode == recipeCode)
@@ -59,7 +59,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
RawMaterialWeight = new Random().Next(10, 1000),
RawMaterialBarrelNum = new Random().Next(1, 3),
RawMaterialBarrelNum = (short)new Random().Next(1, 3),
RawMaterialLocation = i,
});
}


+ 0
- 2
BPASmartClient.MinimalistUI/MainWindow.xaml View File

@@ -14,7 +14,5 @@
<ImageBrush ImageSource="/Images/bj.png"/>
</Grid.Background>
<ctrl:RunCanvas x:Name="runCanvas"/>

<ctrl:HBLControl></ctrl:HBLControl>
</Grid>
</Window>

BIN
View File


+ 20
- 17
BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs View File

@@ -45,22 +45,22 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(SwitchButton), new FrameworkPropertyMetadata(typeof(SwitchButton)));
}
[Category("事件")]
public string Value
[Category("事件")]
public string BindingIsChecked
{
get { return (string)GetValue(ValueProperty); }
set { SetValue(ValueProperty,value); }
get { return (string)GetValue(BingIsCheckedProperty); }
set { SetValue(BingIsCheckedProperty, value); }
}
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value",typeof(string),typeof(SwitchButton),new PropertyMetadata(string.Empty));
public static readonly DependencyProperty BingIsCheckedProperty =
DependencyProperty.Register("BindingIsChecked", typeof(string),typeof(SwitchButton),new PropertyMetadata(string.Empty));
[Category("事件")]
public string Text
public string SendText
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty,value); }
get { return (string)GetValue(SendTextProperty); }
set { SetValue(SendTextProperty, value); }
}
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text",typeof(string),typeof(SwitchButton),new PropertyMetadata(string.Empty));
public static readonly DependencyProperty SendTextProperty =
DependencyProperty.Register("SendText", typeof(string),typeof(SwitchButton),new PropertyMetadata(string.Empty));

/// <summary>
/// 不勾选时执行代码
@@ -92,7 +92,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
set { SetValue(TimeCountProperty,value); }
}
public static readonly DependencyProperty TimeCountProperty =
DependencyProperty.Register("TimeCount",typeof(int),typeof(SwitchButton),new PropertyMetadata(5));
DependencyProperty.Register("TimeCount",typeof(int),typeof(SwitchButton),new PropertyMetadata(100));
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
@@ -175,9 +175,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls
propertyBing[propertyInfo.Name] = propName.ToString();
}
}
timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
timer.Start();
if (propertyBing.Count > 0)
{
timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
timer.Start();
}
this.Click += SwitchButton_Click;
}

@@ -214,7 +217,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
_checked = false;
}
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType);
Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = _checked.ToString(),DataType = eDataType });
SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = _checked.ToString(),DataType = eDataType });
this.GetType().GetProperty("IsChecked").SetValue(this,_checked);
}
}
@@ -243,7 +246,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
object _value = b[str[1]].VarVaule;
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType);
Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = this.IsChecked.ToString(),DataType = eDataType });
SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = this.IsChecked.ToString(),DataType = eDataType });
}
}
}


+ 9
- 9
BPASmartClient.SCADAControl/CustomerControls/TheMQTT.xaml.cs View File

@@ -140,7 +140,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
Direction = 2;
}
}
timer.Interval = TimeSpan.FromSeconds(TimeCount);
timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick;
timer.Start();

@@ -189,13 +189,13 @@ namespace BPASmartClient.SCADAControl.CustomerControls

#region 属性
[Category("事件")]
public string Value
public string SendText
{
get { return (string)GetValue(ValueProperty); }
set { SetValue(ValueProperty,value); }
get { return (string)GetValue(SendTextProperty); }
set { SetValue(SendTextProperty, value); }
}
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value",typeof(string),typeof(TheMQTT),new PropertyMetadata(string.Empty,new PropertyChangedCallback(OnValuePropertyChanged)));
public static readonly DependencyProperty SendTextProperty =
DependencyProperty.Register("SendText", typeof(string),typeof(TheMQTT),new PropertyMetadata(string.Empty,new PropertyChangedCallback(OnValuePropertyChanged)));
private static void OnValuePropertyChanged(DependencyObject d,DependencyPropertyChangedEventArgs e)
{
(d as TheMQTT)?.RefreshMQTT();
@@ -203,9 +203,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public void RefreshMQTT()
{
PublishInfo publishInfo = new PublishInfo();
if (!string.IsNullOrEmpty(Value))
if (!string.IsNullOrEmpty(SendText))
{
publishInfo.PublishModels.Add(JsonConvert.DeserializeObject<PublishModel>(Value));
publishInfo.PublishModels.Add(JsonConvert.DeserializeObject<PublishModel>(SendText));
if (mQTT.client != null && mQTT.client.IsConnected)
mQTT.MqttPublishAsync("DistributedHostComputer/Control",JsonConvert.SerializeObject(publishInfo));
}
@@ -278,7 +278,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
set { SetValue(TimeCountProperty,value); }
}
public static readonly DependencyProperty TimeCountProperty =
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheMQTT),new PropertyMetadata(5));
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheMQTT),new PropertyMetadata(1000));
[Category("数据绑定-数据来源")]
public string DataSouceInformation
{


+ 2
- 2
BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs View File

@@ -130,7 +130,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
Direction = 2;
}
}
timer.Interval = TimeSpan.FromSeconds(TimeCount);
timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick;
timer.Start();

@@ -271,7 +271,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
set { SetValue(TimeCountProperty,value); }
}
public static readonly DependencyProperty TimeCountProperty =
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheRedis),new PropertyMetadata(5));
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheRedis),new PropertyMetadata(100));
[Category("数据绑定-数据来源")]
public string DataSouceInformation
{


+ 6
- 3
BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs View File

@@ -87,9 +87,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls
}
}

timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
timer.Start();
if (propertyBing.Count > 0)
{
timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
timer.Start();
}
}
/// <summary>
/// 属性刷新事件


+ 13
- 10
BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs View File

@@ -67,7 +67,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
object _value = b[str[1]].VarVaule;
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType);
ChangedText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = Text,DataType = eDataType });
SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = Text,DataType = eDataType });
}
}
}
@@ -109,13 +109,13 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public static readonly DependencyProperty ValueChangedExecuteProperty =
DependencyProperty.Register("ValueChangedExecute",typeof(string),typeof(TheTextBox),new PropertyMetadata(string.Empty));
[Category("事件")]
public string ChangedText
public string SendText
{
get { return (string)GetValue(ChaTextProperty); }
set { SetValue(ChaTextProperty,value); }
get { return (string)GetValue(SendTextProperty); }
set { SetValue(SendTextProperty, value); }
}
public static readonly DependencyProperty ChaTextProperty =
DependencyProperty.Register("ChangedText",typeof(string),typeof(TheTextBox),new PropertyMetadata(string.Empty));
public static readonly DependencyProperty SendTextProperty =
DependencyProperty.Register("SendText", typeof(string),typeof(TheTextBox),new PropertyMetadata(string.Empty));
[Category("数据绑定-数据来源")]
public int TimeCount
{
@@ -123,7 +123,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
set { SetValue(TimeCountProperty,value); }
}
public static readonly DependencyProperty TimeCountProperty =
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheTextBox),new PropertyMetadata(5));
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheTextBox),new PropertyMetadata(100));
public event EventHandler PropertyChange; //声明一个事件
/// <summary>
/// 属性刷新器
@@ -147,9 +147,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls
propertyBing[propertyInfo.Name] = propName.ToString();
}
}
timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
timer.Start();
if (propertyBing.Count > 0)
{
timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
timer.Start();
}
}
/// <summary>
/// 属性刷新事件


+ 19
- 16
BPASmartClient.SCADAControl/CustomerControls/TheToggleButton.xaml.cs View File

@@ -62,21 +62,21 @@ namespace BPASmartClient.SCADAControl.CustomerControls
}
}
[Category("事件")]
public string Value
public string BindingIsChecked
{
get { return (string)GetValue(ValueProperty); }
set { SetValue(ValueProperty,value); }
get { return (string)GetValue(BindingIsCheckedProperty); }
set { SetValue(BindingIsCheckedProperty, value); }
}
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value",typeof(string),typeof(TheToggleButton),new PropertyMetadata(string.Empty));
public static readonly DependencyProperty BindingIsCheckedProperty =
DependencyProperty.Register("BindingIsChecked", typeof(string),typeof(TheToggleButton),new PropertyMetadata(string.Empty));
[Category("事件")]
public string Text
public string SendText
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty,value); }
get { return (string)GetValue(SendTextProperty); }
set { SetValue(SendTextProperty, value); }
}
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text",typeof(string),typeof(TheToggleButton),new PropertyMetadata(string.Empty));
public static readonly DependencyProperty SendTextProperty =
DependencyProperty.Register("SendText", typeof(string),typeof(TheToggleButton),new PropertyMetadata(string.Empty));
/// <summary>
/// 不勾选时执行代码
/// </summary>
@@ -107,7 +107,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
set { SetValue(TimeCountProperty,value); }
}
public static readonly DependencyProperty TimeCountProperty =
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheToggleButton),new PropertyMetadata(5));
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheToggleButton),new PropertyMetadata(100));
/// <summary>
/// 属性刷新器
/// </summary>
@@ -127,9 +127,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls
propertyBing[propertyInfo.Name] = propName.ToString();
}
}
timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
timer.Start();
if (propertyBing.Count > 0)
{
timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
timer.Start();
}
Click += TheToggleButton_Click;
Checked += TheCheckBox_Checked;
Unchecked += TheCheckBox_Unchecked;
@@ -168,7 +171,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
_checked = false;
}
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType);
Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = _checked.ToString(),DataType = eDataType });
SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = _checked.ToString(),DataType = eDataType });
this.GetType().GetProperty("IsChecked").SetValue(this,_checked);
}
@@ -198,7 +201,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
object _value = b[str[1]].VarVaule;
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType);
Text = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = "False",DataType = eDataType });
SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = "False",DataType = eDataType });
}
}
}


+ 1
- 1
BeDesignerSCADA/Common/PropertyHelper.cs View File

@@ -14,7 +14,7 @@ namespace BeDesignerSCADA.Common
{
public static string[] ableProperties = new string[]
{ "IsChecked", "Value", "CurValue", "StatusValue", "NumberValue", "Text",
"Direction","RefreshData","ChangedText","Content"
"Direction","RefreshData","ChangedText","Content","SendText"
};
public static List<ControlName> GetCustomerControlProperty(List<FrameworkElement> selectItems)
{


+ 0
- 3
BeDesignerSCADA/Controls/CanvasPanel.cs View File

@@ -35,9 +35,6 @@ namespace BeDesignerSCADA.Controls
SetTopLayerCommand = new RelayCommand(SetTopLayer);
SetBottomLayerCommand = new RelayCommand(SetBottomLayer);
SelectedItems = new ObservableCollection<FrameworkElement>();
//ResourceDictionary resourceDictionary = new ResourceDictionary();
//Application.LoadComponent(resourceDictionary, new Uri("/BeDesignerSCADA;component/Themes/Styles.xaml", UriKind.Relative));
//ContextMenu = resourceDictionary.FindName("CanvasRightMenu") as ContextMenu;
ContextMenu=Application.Current.Resources["CanvasRightMenu"] as ContextMenu;
KeyDown += CanvasPanel_KeyDown;
}


+ 294
- 0
BeDesignerSCADA/Controls/MainCanvasPanel.xaml View File

@@ -0,0 +1,294 @@
<UserControl x:Class="BeDesignerSCADA.Controls.MainCanvasPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BeDesignerSCADA.Controls"
xmlns:s="clr-namespace:BeDesignerSCADA.Converters"
xmlns:icon="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:avae="http://icsharpcode.net/sharpdevelop/avalonedit"
xmlns:ctl="clr-namespace:BeDesignerSCADA.Controls"
xmlns:mypro="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
d:DesignHeight="900" d:DesignWidth="1400">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" />
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid x:Name="grid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="240"/>
<ColumnDefinition/>
<ColumnDefinition Width="350"/>
</Grid.ColumnDefinitions>
<!--左侧选择区域-->
<Grid Background="White" >
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Margin="4">
<ListBox x:Name="CtlList" Background="Transparent" ItemTemplate="{DynamicResource ToolBoxStyle}" BorderThickness="0" PreviewMouseMove="CtlList_PreviewMouseMove">
</ListBox>
</Border>
</Grid>



<!--中间控制区域-->
<DockPanel Grid.Column="1">
<!--按钮控制-->
<DockPanel LastChildFill="False" DockPanel.Dock="Top" Height="24" Margin="4 4 4 0">
<Button Margin="0" Width="24" Padding="0" Click="AglinLeftBtn_Click" ToolTip="左对齐">
<icon:PackIconModern Kind="AlignLeft"/>
</Button>
<Button Margin="4 0 0 0" Width="24" Padding="0" Click="AglinRightBtn_Click" ToolTip="右对齐">
<icon:PackIconModern Kind="AlignRight"/>
</Button>
<Button Margin="4 0 0 0" Width="24" Padding="0" Click="AglinCenterBtn_Click" ToolTip="中心对齐">
<icon:PackIconModern Kind="AlignCenter"/>
</Button>
<Button Margin="4 0 0 0" Width="24" Padding="0" Click="AglinTopBtn_Click" ToolTip="上对齐">
<icon:PackIconModern Kind="BorderTop"/>
</Button>
<Button Margin="4 0 0 0" Width="24" Padding="0" Click="AglinBottomBtn_Click" ToolTip="下对齐">
<icon:PackIconModern Kind="BorderBottom"/>
</Button>
<Button Margin="16 0 0 0" Width="24" Padding="0" Click="HorizontalLayoutBtn_Click" ToolTip="水平分布">
<icon:PackIconModern Kind="BorderHorizontal"/>
</Button>
<Button Margin="4 0 0 0" Width="24" Padding="0" Click="VerticalLayoutBtn_Click" ToolTip="垂直分布">
<icon:PackIconModern Kind="BorderVertical"/>
</Button>

<ToggleButton IsChecked="{Binding UseAutoAlignment, ElementName=cav, Mode=TwoWay}" ToolTip="使用对齐网格" Margin="4 0 0 0" Width="24" Padding="0">
<icon:PackIconModern Kind="CellAlign"/>
</ToggleButton>

<Button Margin="16 0 0 0" Width="24" Padding="0" ToolTip="复制" Command="{Binding ElementName=cav, Path=CopySelectItemsCommand}">
<icon:PackIconModern Kind="PageCopy"/>
</Button>
<Button Margin="4 0 0 0" Width="24" Padding="0" ToolTip="粘贴" Command="{Binding ElementName=cav, Path=PasteSelectItemsCommand}">
<icon:PackIconModern Kind="ClipboardPaste"/>
</Button>
<Button Margin="4 0 0 0" Width="24" Padding="0" ToolTip="删除" Command="{Binding ElementName=cav, Path=DeleteSelectItemsCommand}">
<icon:PackIconModern Kind="Delete"/>
</Button>

<Button x:Name="RunBtn" Margin="16 0 0 0" Padding="0" Click="RunBtn_Click" Command="{Binding RunUiCommand}">
<Button.Style>
<Style TargetType="Button">
<Setter Property="Tag" Value="运行"/>
<Setter Property="Content">
<Setter.Value>
<StackPanel Orientation="Horizontal" Margin="8 0">
<icon:PackIconModern Kind="ControlPlay" VerticalAlignment="Center" Foreground="#28B60F" Width="8"/>
<TextBlock Text="运行" Margin="4 0" VerticalAlignment="Center"/>
</StackPanel>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding IsRunning}" Value="True">
<Setter Property="Tag" Value="停止"/>
<Setter Property="Content">
<Setter.Value>
<StackPanel Orientation="Horizontal" Margin="8 0">
<icon:PackIconModern Kind="ControlStop" VerticalAlignment="Center" Foreground="#B60F0F" Width="8"/>
<TextBlock Text="停止" Margin="4 0" VerticalAlignment="Center"/>
</StackPanel>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>

<Button x:Name="SaveBtn" Margin="16 0 0 0" Padding="0" Click="SaveBtn_Click">
<StackPanel Orientation="Horizontal" Margin="8 0">
<icon:PackIconModern Kind="Save" VerticalAlignment="Center" Width="12"/>
<TextBlock Text="保存" Margin="4 0" VerticalAlignment="Center"/>
</StackPanel>
</Button>

<Button x:Name="LoadBtn" Margin="4 0 0 0" Padding="0" Click="LoadBtn_Click">
<StackPanel Orientation="Horizontal" Margin="8 0">
<icon:PackIconModern Kind="DiskDownload" VerticalAlignment="Center" Width="14"/>
<TextBlock Text="加载" Margin="4 0" VerticalAlignment="Center"/>
</StackPanel>
</Button>

<Button x:Name="MNBtn" Margin="4 0 0 0" Padding="0" Click="MNBtn_Click">
<StackPanel Orientation="Horizontal" Margin="8 0">
<icon:PackIconModern Kind="MessageSend" VerticalAlignment="Center" Width="14"/>
<TextBlock Text="模拟消息" Margin="4 0" VerticalAlignment="Center"/>
</StackPanel>
</Button>

<ToggleButton x:Name="showCode" Click="showCode_Click" DockPanel.Dock="Right" Margin="4 0 0 0" Padding="4 0">
<icon:Material Kind="FileCode"/>
</ToggleButton>

<Slider DockPanel.Dock="Right" Width="100" Maximum="16" Minimum="1" Margin="4 0 0 0"
HorizontalContentAlignment="Center" Value="{Binding ElementName=cav,Path=GridPxiel}" ></Slider>
<TextBlock DockPanel.Dock="Right" Text="对齐:" VerticalAlignment="Center" Margin="16 0 0 0"/>

</DockPanel>

<!--中间画布-->
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Margin="4">
<Border.Background>
<ImageBrush ImageSource="/Images/bj.png" Stretch="UniformToFill"/>
</Border.Background>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>

<ctl:CanvasPanel x:Name="cav" Visibility="{Binding CanvasPanelVisibility}" SelectedItem="{Binding CanSelectedItem,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" AllowDrop="True" RenderTransformOrigin="0.5,0.5" ClipToBounds="True" UseLayoutRounding="True" Focusable="True" SnapsToDevicePixels="True">
<ctl:CanvasPanel.Background>
<VisualBrush TileMode="Tile" Viewport="0,0,20,20" ViewportUnits="Absolute">
<VisualBrush.Visual>
<Rectangle Width="20" Height="20" StrokeDashArray="4,2" StrokeThickness="0.5" Stroke="#CBCBCB">
<Rectangle.Style>
<Style TargetType="{x:Type Rectangle}">
<Style.Triggers>
<DataTrigger Binding="{Binding UseAutoAlignment, RelativeSource={RelativeSource AncestorType={x:Type ctl:CanvasPanel}, Mode=FindAncestor}}" Value="True">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding UseAutoAlignment, RelativeSource={RelativeSource AncestorType={x:Type ctl:CanvasPanel}, Mode=FindAncestor}}" Value="False">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Rectangle.Style>
</Rectangle>
</VisualBrush.Visual>
</VisualBrush>
</ctl:CanvasPanel.Background>

<ctl:CanvasPanel.RenderTransform>
<TransformGroup>
<TranslateTransform x:Name="CanvasTranslate"/>
</TransformGroup>
</ctl:CanvasPanel.RenderTransform>
</ctl:CanvasPanel>

<ctl:RunCanvas x:Name="runCanvas" Visibility="{Binding RunCanvasVisibility}" />

<avae:TextEditor x:Name="codeEditor" ShowLineNumbers="True" Padding="4" WordWrap="True" IsReadOnly="True" SyntaxHighlighting="XML" BorderThickness="1 0 0 0" BorderBrush="{StaticResource ControlBorderBrush}" Grid.Column="1" Width="480" Visibility="{Binding ElementName=showCode, Path=IsChecked, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"/>
</Grid>
</Border>
</DockPanel>

<GridSplitter HorizontalAlignment="Right" Grid.Column="1" VerticalAlignment="Stretch" Width="5" Background="Transparent"/>

<!--右侧属性栏-->
<Grid Grid.Column="2">
<TabControl SelectedIndex="0">
<TabItem Header="控制协议">
<mypro:PropertyGrid x:Name="kzxy" SelectedObject="{Binding PropeObject}"
Margin="10" ShowAdvancedOptions="True" ShowDescriptionByTooltip="True"
FontSize="14" ShowTitle="False" ShowSortOptions="False" ShowSearchBox="False"
CategoryGroupHeaderTemplate="{DynamicResource Category}">
<mypro:PropertyGrid.EditorDefinitions>
<!--EditorTemplateDefinition可添加多个-->
<!--要修改编辑模板的属性的名称-->
<mypro:EditorTemplateDefinition TargetProperties="点击事件,值改变事件,定时触发,勾选事件,取消勾选事件" >
<mypro:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<!--此处可自由发挥-->
<Grid>
<!-- Command生效: DataTemplate的DataContext指代不明确,需要改为父类的DataContext。 参数Value表示原对象-->
<!--Command="{Binding Path=DataContext.PropeSetCommand ,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=xctk:PropertyGrid}}"-->
<!--DataContext="{Binding DataContext, ElementName=window}" Command="{Binding PropeSetCommand}" CommandParameter="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"-->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" x:Name="key"/>
<ColumnDefinition Width="35"/>
</Grid.ColumnDefinitions>
<TextBox Width="{Binding Width, ElementName=key}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap"></TextBox>
<ToggleButton Grid.Column="1" Height="25" Content="编辑" Width="30" HorizontalAlignment="Left" Click="ToggleButton_Click"></ToggleButton>
</Grid>
</DataTemplate>
</mypro:EditorTemplateDefinition.EditingTemplate>
</mypro:EditorTemplateDefinition>

<mypro:EditorTemplateDefinition TargetProperties="代码过滤脚本" >
<mypro:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<!--此处可自由发挥-->
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<TextBox Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" AcceptsReturn="True" TextWrapping="Wrap"></TextBox>
</ScrollViewer>
</DataTemplate>
</mypro:EditorTemplateDefinition.EditingTemplate>
</mypro:EditorTemplateDefinition>

<mypro:EditorTemplateDefinition TargetProperties="设备解析变量" >
<mypro:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<!--此处可自由发挥-->
<Grid>
<ComboBox Grid.Column="1" Height="25" Width="{Binding Width, ElementName=com}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevValueList}"
></ComboBox>
</Grid>
</DataTemplate>
</mypro:EditorTemplateDefinition.EditingTemplate>
</mypro:EditorTemplateDefinition>

<mypro:EditorTemplateDefinition TargetProperties="设备名称" >
<mypro:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<!--此处可自由发挥-->
<Grid>
<ComboBox Grid.Column="1" Height="25" Width="{Binding Width, ElementName=com}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevNameList}"
></ComboBox>
</Grid>
</DataTemplate>
</mypro:EditorTemplateDefinition.EditingTemplate>
</mypro:EditorTemplateDefinition>

<mypro:EditorTemplateDefinition TargetProperties="文本,文本1,标题,变量,勾选状态" >
<mypro:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<!--此处可自由发挥-->
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid Margin="0,5,0,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40" />
<ColumnDefinition Width="*" x:Name="key"/>
<ColumnDefinition Width="*" x:Name="Text"/>
</Grid.ColumnDefinitions>
<TextBlock>绑定:</TextBlock>
<ComboBox x:Name="namebox" DropDownOpened="namebox_DropDownOpened" Grid.Column="1" Height="25" IsTextSearchEnabled="True" IsEditable="True" Tag="{Binding Text, ElementName=valuebox}" Width="{Binding Width, ElementName=key}" TextBoxBase.TextChanged="ComboBoxName_TextChanged"
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevNameList}">
</ComboBox>
<ComboBox x:Name="valuebox" DropDownOpened="valuebox_DropDownOpened" Grid.Column="2" Height="25" IsTextSearchEnabled="True" IsEditable="True" Tag="{Binding Text, ElementName=namebox}" Width="{Binding Width, ElementName=Text}" TextBoxBase.TextChanged="ComboBoxValue_TextChanged"
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevValueList}"/>
</Grid>
<TextBox Grid.Row="2" x:Name="wenben" Width="{Binding Width, ElementName=Text}" Padding="5" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap"></TextBox>

</Grid>
</DataTemplate>
</mypro:EditorTemplateDefinition.EditingTemplate>
</mypro:EditorTemplateDefinition>
</mypro:PropertyGrid.EditorDefinitions>
</mypro:PropertyGrid>
</TabItem>
<TabItem Header="控件样式">
<mypro:PropertyGrid x:Name="dsdsdsd"
Margin="10" ShowAdvancedOptions="True" ShowDescriptionByTooltip="True"
FontSize="14" ShowTitle="False" ShowSortOptions="False" ShowSearchBox="False"
CategoryGroupHeaderTemplate="{DynamicResource Category}" SelectedObject="{Binding SelectedItem,ElementName=cav,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
</TabItem>
</TabControl>
</Grid>
</Grid>
</UserControl>

+ 359
- 0
BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs View File

@@ -0,0 +1,359 @@
using BeDesignerSCADA.ViewModel;
using BeDesignerSCADA.ViewModel;
using BPASmart.Model;
using BPASmartClient.Compiler;
using BPASmartClient.DATABUS;
using BPASmartClient.MessageName;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BeDesignerSCADA.Controls
{
/// <summary>
/// MainCanvasPanel.xaml 的交互逻辑
/// </summary>
public partial class MainCanvasPanel : System.Windows.Controls.UserControl
{
/// <summary>
/// 布局文件路径
/// </summary>
public string Path=string.Empty;
MainViewModel viewModel = new MainViewModel();
public MainCanvasPanel(string _Path)
{
InitializeComponent();
Path= _Path;
this.DataContext = viewModel;
viewModel.Loaded(cav, runCanvas);
//控件加载
Assembly assembly = Assembly.LoadFile($"{System.AppDomain.CurrentDomain.BaseDirectory}\\BPASmartClient.SCADAControl.dll"); //Assembly.GetExecutingAssembly();
var controls = assembly.GetTypes().Where(t => t.GetInterface("IExecutable") != null).OrderBy(o => o.Name);
CtlList.ItemsSource = controls;
//读取文件
FileRead(_Path);
}
public MainCanvasPanel()
{
InitializeComponent();
this.DataContext = viewModel;
viewModel.Loaded(cav, runCanvas);
//控件加载
Assembly assembly = Assembly.LoadFile($"{System.AppDomain.CurrentDomain.BaseDirectory}\\BPASmartClient.SCADAControl.dll"); //Assembly.GetExecutingAssembly();
var controls = assembly.GetTypes().Where(t => t.GetInterface("IExecutable") != null).OrderBy(o => o.Name);
CtlList.ItemsSource = controls;
}

#region 位置调整
/// <summary>
/// 左对齐
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void AglinLeftBtn_Click(object sender, RoutedEventArgs e)
{
cav.AlignLeft();
}
/// <summary>
/// 底部对齐
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void AglinBottomBtn_Click(object sender, RoutedEventArgs e)
{
cav.AlignBottom();
}
/// <summary>
/// 顶部对齐
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void AglinTopBtn_Click(object sender, RoutedEventArgs e)
{
cav.AlignTop();
}
/// <summary>
/// 右对齐
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void AglinRightBtn_Click(object sender, RoutedEventArgs e)
{
cav.AlignRight();
}
/// <summary>
/// 居中
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void AglinCenterBtn_Click(object sender, RoutedEventArgs e)
{
cav.AlignCenter();
}
/// <summary>
/// 垂直分布
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void VerticalLayoutBtn_Click(object sender, RoutedEventArgs e)
{
cav.VertialLayout();
}
/// <summary>
/// 水平分布
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void HorizontalLayoutBtn_Click(object sender, RoutedEventArgs e)
{
cav.HorizontalLayout();
}
#endregion

#region 其他事件操作
/// <summary>
/// 运行
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void RunBtn_Click(object sender, RoutedEventArgs e)
{
if (sender is System.Windows.Controls.Button btn)
{
if (btn.Tag.ToString() == "运行")
{
cav.ClearSelection();
runCanvas.Run(cav.Generator());
}
else if (btn.Tag.ToString() == "停止")
{
runCanvas.Destory();
}
}
}
/// <summary>
/// 加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LoadBtn_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "布局文件|*.lay";
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
cav.Load(ofd.FileName);
}

DoubleAnimation da = new DoubleAnimation(-200, 0, new Duration(TimeSpan.FromMilliseconds(250)));
da.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
CanvasTranslate.BeginAnimation(TranslateTransform.XProperty, da);

DoubleAnimation daop = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(250)));
daop.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
cav.BeginAnimation(OpacityProperty, daop);
}
/// <summary>
/// 读取文件
/// </summary>
/// <param name="path"></param>
public void FileRead(string path)
{
try
{
if (File.Exists(path))
{
cav.Load(path);


DoubleAnimation da = new DoubleAnimation(-200, 0, new Duration(TimeSpan.FromMilliseconds(250)));
da.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
CanvasTranslate.BeginAnimation(TranslateTransform.XProperty, da);

DoubleAnimation daop = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(250)));
daop.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
cav.BeginAnimation(OpacityProperty, daop);
}
}
catch (Exception ex)
{

}
}
/// <summary>
/// 保存文件
/// </summary>
public void FileSave()
{
SaveBtn_Click(null, null);
}
/// <summary>
/// 保存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SaveBtn_Click(object sender, RoutedEventArgs e)
{
string str = cav.Save();
File.WriteAllText(Path, str, Encoding.Unicode);
}
/// <summary>
/// 模拟消息发送
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MNBtn_Click(object sender, RoutedEventArgs e)
{

}
#endregion

#region 左侧控件栏移动
/// <summary>
/// 移动到右侧
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CtlList_PreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
if (CtlList.SelectedItem != null && e.LeftButton == MouseButtonState.Pressed)
{
DragDrop.DoDragDrop(CtlList, CtlList.SelectedItem, System.Windows.DragDropEffects.Copy);
codeEditor.Text = cav.Save();
}
}
/// <summary>
/// 显示代码
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void showCode_Click(object sender, RoutedEventArgs e)
{
codeEditor.Text = cav.Save();
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ToggleButton_Click(object sender, RoutedEventArgs e)
{
try
{
if (sender is ToggleButton)
{
ToggleButton toggle = (ToggleButton)sender;
Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem;
if (propertyGridCommand != null)
{
viewModel.Edit(propertyGridCommand);
}
}
}
catch (Exception ex)
{

}
}
/// <summary>
/// 变量选择
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ComboBoxValue_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
if (sender is System.Windows.Controls.ComboBox)
{
System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender;
Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem;
if (toggle.Tag != null && !string.IsNullOrEmpty(toggle.Text))
propertyGridCommand.Value = "{" + $"Binding {toggle.Tag}.{toggle.Text}" + "}";
}
}
catch (Exception ex)
{

}
}
/// <summary>
/// 变量下拉框打开事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void valuebox_DropDownOpened(object sender, EventArgs e)
{
try
{
viewModel.DevValueList = new System.Collections.ObjectModel.ObservableCollection<string>();
if (sender is System.Windows.Controls.ComboBox)
{
System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender;
if (toggle.Tag == null) return;
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(toggle.Tag.ToString()))
{
Class_DataBus.GetInstance().Dic_DeviceData[toggle.Tag.ToString()].Keys?.ToList().ForEach(key => { viewModel.DevValueList.Add(key); });
}
}
}
catch (Exception ex)
{

}

}
/// <summary>
/// 设备名称选择
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ComboBoxName_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
if (sender is System.Windows.Controls.ComboBox)
{
System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender;
Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem;
if (toggle.Tag != null && !string.IsNullOrEmpty(toggle.Text))
propertyGridCommand.Value = "{" + $"Binding {toggle.Text}.{toggle.Tag}" + "}";
else if (!string.IsNullOrEmpty(toggle.Text))
propertyGridCommand.Value = "{" + $"Binding {toggle.Text}." + "}";

}
}
catch (Exception ex)
{

}
}
/// <summary>
/// 设备名称下拉框打开事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void namebox_DropDownOpened(object sender, EventArgs e)
{
viewModel.DevNameList = new System.Collections.ObjectModel.ObservableCollection<string>();
Class_DataBus.GetInstance().Dic_DeviceData.Keys?.ToList().ForEach(key => { viewModel.DevNameList.Add(key); });
}
#endregion
}
}

+ 0
- 5
BeDesignerSCADA/Controls/RunCanvas.xaml.cs View File

@@ -47,11 +47,6 @@ namespace BeDesignerSCADA.Controls
RootCanvas.Children.Clear();
foreach (FrameworkElement element in canvas)
{
//if (element.GetType().GetInterface("IExecutable")!=null)
//{
// element.GetType().GetProperty("IsExecuteState").SetValue(element, true);
//}

if (element is IExecutable executable)
executable.IsExecuteState = true;



+ 13
- 0
BeDesignerSCADA/MainTest.xaml View File

@@ -0,0 +1,13 @@
<Window x:Class="BeDesignerSCADA.MainTest"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BeDesignerSCADA"
xmlns:k="clr-namespace:BeDesignerSCADA.Controls"
mc:Ignorable="d"
Title="MainTest" Height="450" Width="800">
<Grid x:Name="main">
</Grid>
</Window>

+ 30
- 0
BeDesignerSCADA/MainTest.xaml.cs View File

@@ -0,0 +1,30 @@
using BeDesignerSCADA.Controls;
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.Shapes;

namespace BeDesignerSCADA
{
/// <summary>
/// MainTest.xaml 的交互逻辑
/// </summary>
public partial class MainTest : Window
{
public MainTest()
{
InitializeComponent();
MainCanvasPanel mainCanvas=new MainCanvasPanel(@"D:\fengyoufu\代码\Code\C#项目\新上位机代码\BPASmartClient.MinimalistUI\bin\Debug\net6.0-windows\LayoutFile\物料仓管理.lay");
main.Children.Add(mainCanvas);
}
}
}

+ 12
- 10
BeDesignerSCADA/MainWindow.xaml View File

@@ -28,12 +28,16 @@
<ColumnDefinition/>
<ColumnDefinition Width="350"/>
</Grid.ColumnDefinitions>
<!--<icon:PackIconMaterial x:Name="icon" Kind="LineScan" BorderThickness="1" VerticalAlignment="Stretch" Width="24" HorizontalAlignment="Stretch"/>-->
<!--左侧控件栏-->
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Margin="4">
<ListBox x:Name="CtlList" Background="Transparent" ItemTemplate="{DynamicResource ToolBoxStyle}" BorderThickness="0" PreviewMouseMove="CtlList_PreviewMouseMove">
</ListBox>
</Border>

<!--左侧选择区域-->
<Grid >
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Margin="4">
<ListBox x:Name="CtlList" Background="Transparent" ItemTemplate="{DynamicResource ToolBoxStyle}" BorderThickness="0" PreviewMouseMove="CtlList_PreviewMouseMove">
</ListBox>
</Border>
</Grid>

<!--中间控制区域-->
<DockPanel Grid.Column="1">
@@ -175,9 +179,7 @@
</ctl:CanvasPanel.RenderTransform>
</ctl:CanvasPanel>


<ctl:RunCanvas x:Name="runCanvas" Visibility="{Binding RunCanvasVisibility}" >
</ctl:RunCanvas>
<ctl:RunCanvas x:Name="runCanvas" Visibility="{Binding RunCanvasVisibility}" />

<avae:TextEditor x:Name="codeEditor" ShowLineNumbers="True" Padding="4" WordWrap="True" IsReadOnly="True" SyntaxHighlighting="XML" BorderThickness="1 0 0 0" BorderBrush="{StaticResource ControlBorderBrush}" Grid.Column="1" Width="480" Visibility="{Binding ElementName=showCode, Path=IsChecked, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"/>
</Grid>
@@ -253,7 +255,7 @@
</mypro:EditorTemplateDefinition.EditingTemplate>
</mypro:EditorTemplateDefinition>

<mypro:EditorTemplateDefinition TargetProperties="文本,文本1,标题,变量" >
<mypro:EditorTemplateDefinition TargetProperties="文本,文本1,标题,变量,勾选状态" >
<mypro:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<!--此处可自由发挥-->


+ 26
- 27
BeDesignerSCADA/MainWindow.xaml.cs View File

@@ -33,23 +33,23 @@ namespace BeDesignerSCADA
/// </summary>
public partial class MainWindow : Window
{

MainViewModel viewModel=new MainViewModel();
public MainWindow()
{
InitializeComponent();
//Loading();
this.DataContext = viewModel;
viewModel.Loaded(cav);
viewModel.Loaded(cav, runCanvas);
//控件加载
Assembly assembly = Assembly.LoadFile($"{System.AppDomain.CurrentDomain.BaseDirectory}\\BPASmartClient.SCADAControl.dll");
//Assembly assembly = Assembly.GetExecutingAssembly();
var controls = assembly.GetTypes().Where(t => t.GetInterface("IExecutable") != null);
Assembly assembly = Assembly.LoadFile($"{System.AppDomain.CurrentDomain.BaseDirectory}\\BPASmartClient.SCADAControl.dll"); //Assembly.GetExecutingAssembly();
var controls = assembly.GetTypes().Where(t => t.GetInterface("IExecutable") != null).OrderBy(o=>o.Name);
CtlList.ItemsSource = controls;
viewModel.propertyGrid = kzxy;
//LoadFile();
}

#region 加载数据中心与事件中心
/// <summary>
/// 加载数据中心
/// </summary>
public void Loading()
{
//try
@@ -132,7 +132,6 @@ namespace BeDesignerSCADA
// System.Windows.MessageBox.Show(ex.Message);
//}
}

/// <summary>
/// 加载本地文件
/// </summary>
@@ -257,7 +256,6 @@ namespace BeDesignerSCADA
}
}
}

/// <summary>
/// 加载
/// </summary>
@@ -280,7 +278,6 @@ namespace BeDesignerSCADA
daop.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
cav.BeginAnimation(OpacityProperty, daop);
}

/// <summary>
/// 保存
/// </summary>
@@ -297,7 +294,6 @@ namespace BeDesignerSCADA
File.WriteAllText(sfd.FileName, str, Encoding.Unicode);
}
}

/// <summary>
/// 模拟消息发送
/// </summary>
@@ -310,6 +306,11 @@ namespace BeDesignerSCADA
#endregion

#region 左侧控件栏移动
/// <summary>
/// 移动到右侧
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CtlList_PreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
if (CtlList.SelectedItem != null && e.LeftButton == MouseButtonState.Pressed)
@@ -318,7 +319,6 @@ namespace BeDesignerSCADA
codeEditor.Text = cav.Save();
}
}

/// <summary>
/// 显示代码
/// </summary>
@@ -328,7 +328,6 @@ namespace BeDesignerSCADA
{
codeEditor.Text = cav.Save();
}

/// <summary>
/// 编辑
/// </summary>
@@ -353,9 +352,8 @@ namespace BeDesignerSCADA

}
}

/// <summary>
/// 变量编辑
/// 变量选择
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
@@ -367,10 +365,8 @@ namespace BeDesignerSCADA
{
System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender;
Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem;
if (toggle.Tag != null)
if (toggle.Tag != null && !string.IsNullOrEmpty(toggle.Text))
propertyGridCommand.Value = "{" + $"Binding {toggle.Tag}.{toggle.Text}" + "}";
else
propertyGridCommand.Value = "{" + $"Binding {toggle.Tag}." + "}";
}
}
catch (Exception ex)
@@ -378,12 +374,16 @@ namespace BeDesignerSCADA

}
}
/// <summary>
/// 变量下拉框打开事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void valuebox_DropDownOpened(object sender,EventArgs e)
{
try
{
viewModel.DevValueList = new System.Collections.ObjectModel.ObservableCollection<string>();

if (sender is System.Windows.Controls.ComboBox)
{
System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender;
@@ -413,9 +413,9 @@ namespace BeDesignerSCADA
{
System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender;
Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem;
if(toggle.Tag!=null)
if(toggle.Tag!=null && !string.IsNullOrEmpty(toggle.Text))
propertyGridCommand.Value = "{" + $"Binding {toggle.Text}.{toggle.Tag}" + "}";
else
else if(!string.IsNullOrEmpty(toggle.Text))
propertyGridCommand.Value = "{" + $"Binding {toggle.Text}." + "}";

}
@@ -425,17 +425,16 @@ namespace BeDesignerSCADA

}
}


/// <summary>
/// 设备名称下拉框打开事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void namebox_DropDownOpened(object sender,EventArgs e)
{
viewModel.DevNameList = new System.Collections.ObjectModel.ObservableCollection<string>();
Class_DataBus.GetInstance().Dic_DeviceData.Keys?.ToList().ForEach(key => { viewModel.DevNameList.Add(key); });
}
#endregion


}


}

+ 14
- 14
BeDesignerSCADA/Themes/Styles.xaml View File

@@ -300,16 +300,16 @@
<Setter TargetName="txt" Property="Text" Value="物料仓" />
</DataTrigger>
<DataTrigger Binding="{Binding Name}" Value="NewConveyorBelt">
<Setter TargetName="icon" Property="Kind" Value="ArrowLeftRightBoldOutline" />
<Setter TargetName="txt" Property="Text" Value="滚动线" />
<Setter Property="Kind" TargetName="icon" Value="Attachment"/>
<Setter Property="Text" TargetName="txt" Value="滚动线"/>
</DataTrigger>
<DataTrigger Binding="{Binding Name}" Value="TheDataGrid">
<Setter TargetName="icon" Property="Kind" Value="LineScan" />
<Setter TargetName="txt" Property="Text" Value="表格" />
<Setter Property="Kind" TargetName="icon" Value="BorderAll"/>
<Setter Property="Text" TargetName="txt" Value="表格"/>
</DataTrigger>
<DataTrigger Binding="{Binding Name}" Value="TheListBox">
<Setter TargetName="icon" Property="Kind" Value="LineScan" />
<Setter TargetName="txt" Property="Text" Value="列表控件" />
<Setter Property="Kind" TargetName="icon" Value="ViewHeadline"/>
<Setter Property="Text" TargetName="txt" Value="列表控件"/>
</DataTrigger>

<DataTrigger Binding="{Binding Name}" Value="TheRedis">
@@ -323,23 +323,23 @@
</DataTrigger>

<DataTrigger Binding="{Binding Name}" Value="TheProgressBar">
<Setter TargetName="icon" Property="Kind" Value="LineScan" />
<Setter TargetName="txt" Property="Text" Value="进度条正常" />
<Setter Property="Kind" TargetName="icon" Value="Texture"/>
<Setter Property="Text" TargetName="txt" Value="进度条正常"/>
</DataTrigger>

<DataTrigger Binding="{Binding Name}" Value="TheRedProgressBar">
<Setter TargetName="icon" Property="Kind" Value="LineScan" />
<Setter TargetName="txt" Property="Text" Value="进度条圆形红" />
<Setter Property="Kind" TargetName="icon" Value="CircleSlice5"/>
<Setter Property="Text" TargetName="txt" Value="进度条圆形红"/>
</DataTrigger>

<DataTrigger Binding="{Binding Name}" Value="TheBlueProgressBar">
<Setter TargetName="icon" Property="Kind" Value="LineScan" />
<Setter TargetName="txt" Property="Text" Value="进度条圆形蓝" />
<Setter Property="Kind" TargetName="icon" Value="CircleSlice5"/>
<Setter Property="Text" TargetName="txt" Value="进度条圆形蓝"/>
</DataTrigger>

<DataTrigger Binding="{Binding Name}" Value="TheGreenProgressBar">
<Setter TargetName="icon" Property="Kind" Value="LineScan" />
<Setter TargetName="txt" Property="Text" Value="进度条圆形绿" />
<Setter Property="Kind" TargetName="icon" Value="CircleSlice5"/>
<Setter Property="Text" TargetName="txt" Value="进度条圆形绿"/>
</DataTrigger>

<DataTrigger Binding="{Binding Name}" Value="TheAPI">


+ 91
- 73
BeDesignerSCADA/ViewModel/MainViewModel.cs View File

@@ -38,15 +38,10 @@ namespace BeDesignerSCADA.ViewModel
{
IsRunning = !IsRunning;
});

}

#region 变量
/// <summary>
/// 设置
/// </summary>
public Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid propertyGrid = null;
/// <summary>
/// 是否正在运行状态
/// </summary>
private bool _IsRunning = false;
@@ -72,6 +67,7 @@ namespace BeDesignerSCADA.ViewModel
OnPropertyChanged("IsRunning");
}
}

/// <summary>
/// 画布是否显示
/// </summary>
@@ -144,12 +140,14 @@ namespace BeDesignerSCADA.ViewModel
if (_CanSelectedItem == value)
return;
_CanSelectedItem = value;
DataSX();
SelectedPropertyDataRefresh();
OnPropertyChanged("CanSelectedItem");
}
}


/// <summary>
/// 控制协议属性
/// </summary>
private PropertyGridCommand _pro;
public PropertyGridCommand PropeObject
{
@@ -164,6 +162,9 @@ namespace BeDesignerSCADA.ViewModel
}
}

/// <summary>
/// 设备名称集合
/// </summary>
private ObservableCollection<string> _DevNameList;
public ObservableCollection<string> DevNameList
{
@@ -177,6 +178,10 @@ namespace BeDesignerSCADA.ViewModel
OnPropertyChanged("DevNameList");
}
}

/// <summary>
/// 设备变量集合
/// </summary>
private ObservableCollection<string> _DevValueList;
public ObservableCollection<string> DevValueList
{
@@ -197,11 +202,9 @@ namespace BeDesignerSCADA.ViewModel
/// 启动或者停止
/// </summary>
public RelayCommand RunUiCommand { get; set; }

#endregion

#region 常用函数

/// <summary>
/// 显示当前xaml代码
/// </summary>
@@ -212,16 +215,24 @@ namespace BeDesignerSCADA.ViewModel
#endregion

#region 脚本编辑数据
/// <summary>
/// 当前编辑界面
/// </summary>
public CanvasPanel canvasPanel;
/// <summary>
/// 当前运行界面
/// </summary>
public RunCanvas runCanvas;
/// <summary>
/// 加载
/// </summary>
/// <param name="obj"></param>
public void Loaded(object obj)
public void Loaded(object objCan,object objRun)
{
canvasPanel = obj as CanvasPanel;
}
canvasPanel = objCan as CanvasPanel;

runCanvas = objRun as RunCanvas;
}
/// <summary>
/// 编辑
/// </summary>
@@ -246,42 +257,14 @@ namespace BeDesignerSCADA.ViewModel
#endregion

#region 属性填充
Dictionary<string,string> EventName = new Dictionary<string,string> {

{"Name","名称" },
{"Text","文本" },
{"Content","按钮文本" },
{"Title","标题" },
{"Value","变量" },
{"ClickExec","点击事件" },
{"ValueChangedExecute" , "值改变事件"},
{"TikcExecute" , "定时触发"},
{"CheckedExec" , "勾选事件"},
{"UnCheckedExec" , "取消勾选事件"},
{"EventReceiveNameList" , "接收消息集"},

//{"DataSouceType" , "数据来源类型"},
{ "TimeCount" , "定时间隔"},

{ "InterfaceMode" , "接口类型"},
{ "InterfaceParameters" , "接口参数"},

{ "DataSouceInformation" , "连接信息"},

{ "DeviceName" , "设备名称"},
{ "DeviceValuleName" , "设备解析变量"},
{"FDataSouce" , "数据源"},
{ "Code" , "代码过滤脚本"},
{ "GenerateData" , "数据结果"},
};
/// <summary>
/// 数据刷新
/// 选中属性数据刷新
/// </summary>
public void DataSX()
public void SelectedPropertyDataRefresh()
{
//属性变量
PropertyGridCommand cmd = new PropertyGridCommand();
var content = CanSelectedItem;// as System.Windows.Controls.Control;
var content = CanSelectedItem;
if (content is IExecutable executable)
executable.PropertyChange += Executable_PropertyChange;

@@ -303,7 +286,6 @@ namespace BeDesignerSCADA.ViewModel
PropeObject = null;
PropeObject = cmd;
}

/// <summary>
/// 内部属性变化通知
/// </summary>
@@ -319,7 +301,6 @@ namespace BeDesignerSCADA.ViewModel
DevValueList = new System.Collections.ObjectModel.ObservableCollection<string>();
Class_DataBus.GetInstance().Dic_DeviceData.Keys?.ToList().ForEach(key => { DevNameList.Add(key); });
}

/// <summary>
/// 修改属性后
/// </summary>
@@ -348,7 +329,6 @@ namespace BeDesignerSCADA.ViewModel
}

}

/// <summary>
/// 设置变量
/// </summary>
@@ -357,13 +337,28 @@ namespace BeDesignerSCADA.ViewModel
{
try
{
// if (CanSelectedItem is System.Windows.Controls.Control)
var content = CanSelectedItem;
if (Name == "Content" ? (content is BPASmartClient.SCADAControl.CustomerControls.TheButton) : true)
{
var content = CanSelectedItem;// as System.Windows.Controls.Control;
if (Name == "Content" ? (content is BPASmartClient.SCADAControl.CustomerControls.TheButton) : true)
System.Reflection.PropertyInfo info = content.GetType().GetProperty(Name);
if (info != null)
{
System.Reflection.PropertyInfo info = content.GetType().GetProperty(Name);
info?.SetValue(content,value,null);
if (info.ToString().Contains("Double"))
{
info?.SetValue(content, Double.Parse(value.ToString()), null);
}
else if (info.ToString().Contains("String"))
{
info?.SetValue(content, value, null);
}
else if (info.ToString().Contains("Int"))
{
info?.SetValue(content, int.Parse(value.ToString()), null);
}
else
{
info?.SetValue(content, value, null);
}
}
}
}
@@ -390,7 +385,6 @@ namespace BeDesignerSCADA.ViewModel
// FieldInfo fld = type.GetField("Browsable",BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreReturn | BindingFlags.GetProperty);
fld.SetValue(attrs[type],visible);
}

/// <summary>
/// 获取指定对象的指定成员变量
/// </summary>
@@ -472,6 +466,33 @@ namespace BeDesignerSCADA.ViewModel

}
#endregion

Dictionary<string, string> EventName = new Dictionary<string, string> {
{"Name","名称" },
{"Text","文本" },
{"Content","按钮文本" },
{"Title","标题" },
{"Value","变量" },
{"BindingIsChecked","勾选状态" },


{"ClickExec","点击事件" },
{"ValueChangedExecute" , "值改变事件"},
{"TikcExecute" , "定时触发"},
{"CheckedExec" , "勾选事件"},
{"UnCheckedExec" , "取消勾选事件"},
{"EventReceiveNameList" , "接收消息集"},

{ "TimeCount" , "定时间隔"},
{ "InterfaceMode" , "接口类型"},
{ "InterfaceParameters" , "接口参数"},
{ "DataSouceInformation" , "连接信息"},
{ "DeviceName" , "设备名称"},
{ "DeviceValuleName" , "设备解析变量"},
{"FDataSouce" , "数据源"},
{ "Code" , "代码过滤脚本"},
{ "GenerateData" , "数据结果"},
};
}


@@ -483,7 +504,8 @@ namespace BeDesignerSCADA.ViewModel
private string _标题;
private string _文本1;
private object _变量;

private string _勾选状态;
[Category("基本属性"), Description("Name"), Browsable(false), PropertyOrder(1)]
public string 名称
{
@@ -559,6 +581,22 @@ namespace BeDesignerSCADA.ViewModel
OnPropertyChanged("变量");
}
}
[Category("基本属性"), Description("BindingIsChecked"), Browsable(false), PropertyOrder(5)]
public string 勾选状态
{
get
{
return _勾选状态;
}
set
{
if (_勾选状态 == value)
return;
_勾选状态 = value;
OnPropertyChanged("勾选状态");
}
}

//[Category("基本属性"), Description("Content"), Browsable(true), PropertyOrder(2)]
//public string 内容 { get; set; }
//[Category("基本属性"), Description("Header"), Browsable(true), PropertyOrder(3)]
@@ -696,26 +734,6 @@ namespace BeDesignerSCADA.ViewModel
}
}




//private DataTypeEnum _数据来源类型;
//[Category("*数据绑定模块*"), Description("DataSouceType"), Browsable(true), PropertyOrder(1)]
//public DataTypeEnum 数据来源类型
//{
// get
// {
// return _数据来源类型;
// }
// set
// {
// if (_数据来源类型 == value)
// return;
// _数据来源类型 = value;
// OnPropertyChanged("数据来源类型");
// }
//}

private string _设备名称;
[Category("*数据绑定模块*"), Description("DeviceName"), Browsable(true), PropertyOrder(2)]
public string 设备名称


+ 1
- 0
WPFDemo/WPFDemo.csproj View File

@@ -20,6 +20,7 @@
</ItemGroup>

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



Loading…
Cancel
Save