pry il y a 2 ans
Parent
révision
1bb120ec19
40 fichiers modifiés avec 1417 ajouts et 468 suppressions
  1. +12
    -0
      BPASmart.PageLoad/BPASmart.PageLoad.csproj
  2. +7
    -14
      BPASmartClient.DATABUS/Class_DataBus.cs
  3. +1
    -1
      BPASmartClient.JXJFoodSmallStation/App.config
  4. +3
    -2
      BPASmartClient.JXJFoodSmallStation/App.xaml.cs
  5. +4
    -0
      BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj
  6. +13
    -0
      BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs
  7. +388
    -154
      BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
  8. +3
    -1
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs
  9. +1
    -1
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs
  10. +59
    -9
      BPASmartClient.JXJFoodSmallStation/View/ManualControlView.xaml
  11. +22
    -51
      BPASmartClient.JXJFoodSmallStation/View/NewRecipeView.xaml
  12. +243
    -0
      BPASmartClient.JXJFoodSmallStation/View/NewRemoteRecipeView.xaml
  13. +33
    -0
      BPASmartClient.JXJFoodSmallStation/View/NewRemoteRecipeView.xaml.cs
  14. +0
    -1
      BPASmartClient.JXJFoodSmallStation/View/RecipeInfosView.xaml.cs
  15. +37
    -8
      BPASmartClient.JXJFoodSmallStation/View/RecipeReceiveView.xaml
  16. +30
    -2
      BPASmartClient.JXJFoodSmallStation/ViewModel/ManualControlViewModel.cs
  17. +94
    -0
      BPASmartClient.JXJFoodSmallStation/ViewModel/NewRemoteRecipeViewModel.cs
  18. +2
    -0
      BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs
  19. +35
    -19
      BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs
  20. +16
    -0
      BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj
  21. +3
    -7
      BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs
  22. +8
    -20
      BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs
  23. +3
    -7
      BPASmartClient.SCADAControl/CustomerControls/TheButton.xaml.cs
  24. +3
    -5
      BPASmartClient.SCADAControl/CustomerControls/TheDataGrid.xaml.cs
  25. +3
    -54
      BPASmartClient.SCADAControl/CustomerControls/TheListBox.xaml.cs
  26. +66
    -11
      BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs
  27. +15
    -9
      BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs
  28. +22
    -16
      BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs
  29. +8
    -38
      BPASmartClient.SCADAControl/CustomerControls/TheToggleButton.xaml.cs
  30. BIN
     
  31. BIN
     
  32. BIN
     
  33. BIN
     
  34. +249
    -0
      BPASmartClient.SCADAControl/Themes/Generic.xaml
  35. +5
    -3
      BeDesignerSCADA/Controls/MainCanvasPanel.xaml
  36. +0
    -3
      BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs
  37. +0
    -10
      BeDesignerSCADA/MainWindow.xaml
  38. +12
    -1
      BeDesignerSCADA/View/ChildEditWindow.xaml.cs
  39. +10
    -14
      BeDesignerSCADA/View/PropertyBindingWindow.xaml
  40. +7
    -7
      BeDesignerSCADA/ViewModel/MainViewModel.cs

+ 12
- 0
BPASmart.PageLoad/BPASmart.PageLoad.csproj Voir le fichier

@@ -27,6 +27,18 @@
<ProjectReference Include="..\BPASmartClient.SCADAControl\BPASmartClient.SCADAControl.csproj" />
</ItemGroup>

<ItemGroup>
<Reference Include="Antlr3.Runtime">
<HintPath>..\BPASmartClient.SCADAControl\DLL\Antlr3.Runtime.dll</HintPath>
</Reference>
<Reference Include="BPASmartClient.Compiler">
<HintPath>..\BPASmartClient.SCADAControl\DLL\BPASmartClient.Compiler.dll</HintPath>
</Reference>
<Reference Include="Unvell.ReoScript">
<HintPath>..\BPASmartClient.SCADAControl\DLL\Unvell.ReoScript.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup>
<Resource Include="Images\fyf.ico" />
</ItemGroup>


+ 7
- 14
BPASmartClient.DATABUS/Class_DataBus.cs Voir le fichier

@@ -26,9 +26,14 @@ namespace BPASmartClient.DATABUS

#region 实时数据->大数据量
/// <summary>
/// 设备数据
/// 缓存Redis数据
/// </summary>
public ConcurrentDictionary<string, Dictionary<string,DeviceDataModel>> Dic_DeviceData = new ConcurrentDictionary<string,Dictionary<string,DeviceDataModel>>();
public ConcurrentDictionary<string, Dictionary<string, object>> Dic_RedisData = new ConcurrentDictionary<string, Dictionary<string, object>>();
/// <summary>
/// 缓存Redis数据相关类型
/// </summary>
public ConcurrentDictionary<string, Dictionary<string, string>> Dic_RedisDataType = new ConcurrentDictionary<string, Dictionary<string, string>>();

/// <summary>
/// API数据
/// </summary>
@@ -36,19 +41,7 @@ namespace BPASmartClient.DATABUS
#endregion

#region 配置数据


//Json<CommunicationPar>.Read();
#endregion
}


public class DeviceDataModel
{
public string VarName { get; set; }
public string VarVaule { get; set; }
public string DataType { get; set; }
}

}

+ 1
- 1
BPASmartClient.JXJFoodSmallStation/App.config Voir le fichier

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="HKPlc_IP" value="192.168.2.10"/>
<add key="HKPlc_IP" value="192.168.0.15"/>
<add key="Siemens_IP" value="192.168.0.30"/>
</appSettings>
</configuration>

+ 3
- 2
BPASmartClient.JXJFoodSmallStation/App.xaml.cs Voir le fichier

@@ -58,7 +58,7 @@ namespace BPASmartClient.JXJFoodSmallStation
ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "本地配方管理",
SubMenuName = "味魔方配方管理",
SubMenuPermission = new Permission[] { Permission.管理员 },
AssemblyName = "BPASmartClient.JXJFoodSmallStation",
ToggleWindowPath = "View.RecipeSettingsView"
@@ -66,7 +66,7 @@ namespace BPASmartClient.JXJFoodSmallStation

RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "本地配方下发",
SubMenuName = "味魔方配方下发",
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员 },
AssemblyName = "BPASmartClient.JXJFoodSmallStation",
ToggleWindowPath = "View.RecipeControlView"
@@ -241,6 +241,7 @@ namespace BPASmartClient.JXJFoodSmallStation
{
Config.GetInstance.Init();
Json<LocaPar>.Read();
Json<DevicePar>.Read();
}

}


+ 4
- 0
BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj Voir le fichier

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


+ 13
- 0
BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs Voir le fichier

@@ -21,6 +21,19 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
/// </summary>
public int RecipeStatusID { get; set; } = 0;

/// <summary>
/// Tray1的柔性味魔方配料标志(下发配方时,若柔性味魔方的状态=3,复位该状态)
/// </summary>
public bool DosingTray1 { get; set; } = true;//默认为true,初始时,判断柔性味魔方的状态。
/// <summary>
/// Tray2的柔性味魔方配料标志
/// </summary>
public bool DosingTray2 { get; set; } = true;
/// <summary>
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
/// </summary>
public int RecipeStatusIDTray2 { get; set; } = 0;
/// <summary>
/// 往输送带下发配方完成
/// </summary>


+ 388
- 154
BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs Voir le fichier

@@ -34,6 +34,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// 配方队列
/// </summary>
public ConcurrentQueue<string> RecipeQueue = new ConcurrentQueue<string>();
public ConcurrentQueue<string> RecipeQueueTray2 = new ConcurrentQueue<string>();

public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
public HKDeviceStatus HKDevice = new HKDeviceStatus();
@@ -56,23 +57,24 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
ActionManage.GetInstance.Register(new Action<XL_Start_DB>((res) =>
ActionManage.GetInstance.CancelRegister("SiemensRecipeRecive");
ActionManage.GetInstance.Register(new Action<object>((res) =>
{
if (SiemensDevice.IsConnected)
{
if (res != null)
if (res != null && res is XL_Start_DB recipe)
{
RawMaterials.Clear();
for (int i = 0; i < 15; i++)
{
if (RawMaterialsNamePos.ContainsKey(res.Material[i].Material_Name))
if (RawMaterialsNamePos.ContainsKey(recipe.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]
RawMaterialName = recipe.Material[i].Material_Name,
RawMaterialBarrelNum = recipe.Material[i].Material_BarrelNum,
RawMaterialWeight = recipe.Material[i].Material_Weight,
RawMaterialLocation = (int)RawMaterialsNamePos[recipe.Material[i].Material_Name]
});
}
else
@@ -82,14 +84,14 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
{
RecipeName = res.RecipeName,
RecipeCode = res.RecipeCode,
RecipeName = recipe.RecipeName,
RecipeCode = recipe.RecipeCode,
RawMaterial = RawMaterials,
TrayCode = res.TrayCode
TrayCode = recipe.TrayCode
});
}
}
}), "西门子下发配方", true);
}), "SiemensRecipeRecive", true);
string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"];
string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
try
@@ -99,10 +101,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
if (HKDevice.IsConnected)
{
HKDevice.Init();
MessageLog.GetInstance.ShowUserLog("海科plc初始化完成");
}
if (SiemensDevice.IsConnected)
{
SiemensDevice.Init();
MessageLog.GetInstance.ShowUserLog("");
}
}
catch(Exception ex)
@@ -130,12 +134,24 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
if (HKDevice.IsConnected)
{
GetStatus();
ManualOpen();
ManualClose();
}
Thread.Sleep(10);
}), "手动操作", true);
}
private void GetStatus()
{
for (int i = 0; i < 8; i++)
{
HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX0." + i);
}
for (int i = 0; i < 8; i++)
{
HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX1." + i);
}
}
private void ManualOpen()
{
ActionManage.GetInstance.Register(new Action<object>((o) =>
@@ -148,49 +164,49 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
switch (index)
{
case 1:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.0", true);
break;
case 2:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.1", true);
break;
case 3:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.2", true);
break;
case 4:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.3", true);
break;
case 5:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.4", true);
break;
case 6:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.5", true);
break;
case 7:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.6", true);
break;
case 8:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.7", true);
break;
case 9:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX1.0", true);
break;
case 10:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX1.1", true);
break;
case 11:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX1.2", true);
break;
case 12:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX1.3", true);
break;
case 13:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX1.4", true);
break;
case 14:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX1.5", true);
break;
case 15:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX1.6", true);
break;
default:
break;
@@ -203,72 +219,87 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
switch (index)
{
case 1:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX1.7", true);
break;
case 2:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX2.0", true);
break;
case 3:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX2.1", true);
break;
case 4:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX2.2", true);
break;
case 5:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX2.3", true);
break;
case 6:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX2.4", true);
break;
case 7:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX2.5", true);
break;
case 8:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX2.6", true);
break;
case 9:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX2.7", true);
break;
case 10:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX3.0", true);
break;
case 11:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX3.1", true);
break;
case 12:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX3.2", true);
break;
case 13:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX3.3", true);
break;
case 14:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX3.4", true);
break;
case 15:
HKDevice.HK_PLC_S7.Write("", true);
HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX3.5", true);
break;
default:
break;

}
}
else if (o.ToString().Contains("托盘气缸"))
else if (o.ToString().Contains("进料桶顶升气缸"))
{
int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
switch (index)
{
case 1:
HKDevice.HK_PLC_S7.Write("", true);
break;
case 2:
HKDevice.HK_PLC_S7.Write("", true);
break;
default:
break;

}
HKDevice.HK_PLC_S7.Write("DB5.DBX3.6", true);
}
else if (o.ToString().Contains("出料桶顶升气缸1"))
{
HKDevice.HK_PLC_S7.Write("DB5.DBX3.7", true);
}
else if (o.ToString().Contains("出料桶顶升气缸2"))
{
HKDevice.HK_PLC_S7.Write("DB5.DBX4.0", true);
}
else if (o.ToString().Contains("出料桶顶升气缸3"))
{
HKDevice.HK_PLC_S7.Write("DB5.DBX4.1", true);
}
else if (o.ToString().Contains("托盘气缸1_1"))
{
HKDevice.HK_PLC_S7.Write("DB5.DBX4.2", true);
}
else if (o.ToString().Contains("托盘气缸1_2"))
{
HKDevice.HK_PLC_S7.Write("DB5.DBX4.3", true);
}
else if (o.ToString().Contains("托盘气缸2_1"))
{
HKDevice.HK_PLC_S7.Write("DB5.DBX4.4", true);
}
else if (o.ToString().Contains("托盘气缸2_2"))
{
HKDevice.HK_PLC_S7.Write("DB5.DBX4.5", true);
}

}
}), "ManualOpen", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
}
@@ -284,49 +315,49 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
switch (index)
{
case 1:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX0.0", false);
break;
case 2:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX0.1", false);
break;
case 3:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX0.2", false);
break;
case 4:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX0.3", false);
break;
case 5:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX0.4", false);
break;
case 6:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX0.5", false);
break;
case 7:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX0.6", false);
break;
case 8:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX0.7", false);
break;
case 9:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX1.0", false);
break;
case 10:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX1.1", false);
break;
case 11:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX1.2", false);
break;
case 12:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX1.3", false);
break;
case 13:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX1.4", false);
break;
case 14:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX1.5", false);
break;
case 15:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX1.6", false);
break;
default:
break;
@@ -339,70 +370,86 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
switch (index)
{
case 1:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX1.7", false);
break;
case 2:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX2.0", false);
break;
case 3:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX2.1", false);
break;
case 4:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX2.2", false);
break;
case 5:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX2.3", false);
break;
case 6:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX2.4", false);
break;
case 7:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX2.5", false);
break;
case 8:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX2.6", false);
break;
case 9:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX2.7", false);
break;
case 10:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX3.0", false);
break;
case 11:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX3.1", false);
break;
case 12:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX3.2", false);
break;
case 13:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX3.3", false);
break;
case 14:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX3.4", false);
break;
case 15:
HKDevice.HK_PLC_S7.Write("", false);
HKDevice.HK_PLC_S7.Write("DB5.DBX3.5", false);
break;
default:
break;

}
}
else if (o.ToString().Contains("托盘气缸"))
else if (o.ToString().Contains("进料桶顶升气缸"))
{
int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
switch (index)
{
case 1:
HKDevice.HK_PLC_S7.Write("", false);
break;
case 2:
HKDevice.HK_PLC_S7.Write("", false);
break;
default:
break;

}
HKDevice.HK_PLC_S7.Write("DB5.DBX3.6", false);
}
else if (o.ToString().Contains("出料桶顶升气缸1"))
{
HKDevice.HK_PLC_S7.Write("DB5.DBX3.7", false);
}
else if (o.ToString().Contains("出料桶顶升气缸2"))
{
HKDevice.HK_PLC_S7.Write("DB5.DBX4.0", false);
}
else if (o.ToString().Contains("出料桶顶升气缸3"))
{
HKDevice.HK_PLC_S7.Write("DB5.DBX4.1", false);
}
else if (o.ToString().Contains("托盘气缸1_1"))
{
HKDevice.HK_PLC_S7.Write("DB5.DBX4.2", false);
}
else if (o.ToString().Contains("托盘气缸1_2"))
{
HKDevice.HK_PLC_S7.Write("DB5.DBX4.3", false);
}
else if (o.ToString().Contains("托盘气缸2_1"))
{
HKDevice.HK_PLC_S7.Write("DB5.DBX4.4", false);
}
else if (o.ToString().Contains("托盘气缸2_2"))
{
HKDevice.HK_PLC_S7.Write("DB5.DBX4.5", false);
}

}
@@ -513,10 +560,29 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
foreach (var data in RemoteRecipes)
{
if (!(RecipeQueue.Contains(data.RecipeCode)))
RecipeQueue.Enqueue(data.RecipeCode);
if (data.TrayCode == 1)
{
if (!(RecipeQueue.Contains(data.RecipeCode)))
{
RecipeQueue.Enqueue(data.RecipeCode);
}
}
else if(data.TrayCode == 2)
{
if (!(RecipeQueueTray2.Contains(data.RecipeCode)))
{
RecipeQueueTray2.Enqueue(data.RecipeCode);
}
}
}
}
else
{
RecipeQueue.Clear();
RecipeQueueTray2.Clear();
SmallStation.RecipeStatusID = 0;
SmallStation.RecipeStatusIDTray2 = 0;
}
}
/// <summary>
/// 执行配方队列中的第一个配方
@@ -525,26 +591,23 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
if (RecipeQueue.Count > 0)
{

int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0));
if (index >= 0 && index < RemoteRecipes.Count)
{
string code = RemoteRecipes.ElementAt(index).RecipeCode;
int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
//MessageLog.GetInstance.ShowRunLog($"开始执行配方{recipeName}");
if ( true) /*trayCode == 1 &&*/
if (trayCode == 1)
{
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.5") || SmallStation.RecipeStatusID == 0)
if (SmallStation.RecipeStatusID == 0)
{
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
{
HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation);
}
HKDevice.HK_PLC_S7.Write("DB3.DBX1.5", false);
HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true);
SmallStation.RecipeStatusID = 1;
MessageLog.GetInstance.ShowRunLog($"{recipeName}配方下发完成");
MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},下发完成");
HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", true);
}
@@ -552,112 +615,126 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", false);
SmallStation.RecipeStatusID = 2;
MessageLog.GetInstance.ShowRunLog($"{recipeName}plc端 配方接收完成");
MessageLog.GetInstance.ShowRunLog($"托盘1,{ recipeName}plc端 配方接收完成");
}
if (SmallStation.RecipeStatusID == 2)
{
if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0")))
{
var res1= HKDevice.HK_PLC_S7.Read<UInt32>("DB4.DBD26");
var res = HKDevice.HK_PLC_S7.Read<UInt32>("DB3.DBD10");
if (res > 0 && res is UInt32 loc)
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD10");
MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{res}料仓,允许配料");
if (res > 0 && res is float loc)
{
//int decimalNum = Convert.ToInt32(loc.ToString().Substring(loc.ToString().IndexOf(".") + 1));
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)
if (loc_index >= 0)
{
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//根据料仓编号 启动并写入每个原料重量
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.0", false);
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//根据料仓编号 启动并写入每个原料重量
SmallStation.StockInIsWork = (int)loc;
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.0", false);
}
MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_1号桶允许配料");
SmallStation.DosingTray1 = true;
MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)loc}号仓,配料完成");
}
}
else if(RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.1")))
{
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD14");
MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{res}料仓,允许配料");
if (res > 0 && res is float loc)
{
ushort a = (ushort)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)
if (loc_index >= 0)
{
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.1", false);
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = (int)loc;
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.1", false);
}
MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_2号桶允许配料");
SmallStation.DosingTray1 = true;
MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{(int)loc}号仓,配料完成");
}
}
else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.2")))
{
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD18");
MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{res}料仓,允许配料");
if (res > 0 && res is float loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
if (loc_index >= 1 && loc_index <= 15)
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 0)
{
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.2", false);
}
MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_3号桶允许配料");
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = (int)loc;
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.2", false);
}
SmallStation.DosingTray1 = true;
MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{(int)loc}号仓,配料完成");
}
}
else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.3")))
{
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD22");
MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{res}料仓,允许配料");
if (res > 0 && res is float loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 1 && loc_index <= 15)
if (loc_index >= 0)
{
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = loc_index;
HKDevice.HK_PLC_S7.Write("DB3.DBX50.3", false);
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = (int)loc;
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.3", false);
}
MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_4号桶允许配料");
SmallStation.DosingTray1 = true;
MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{(int)loc}号仓,配料完成");
}
}
for (int i = 1; i < 16; i++)
{
if (RTrig.GetInstance("柔性味魔方配料完成").Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3))
if (SmallStation.DosingTray1) {
for (int i = 1; i < 16; i++)
{
int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.CutWeightFeedback;
DeviceInquire.GetInstance.GetDevice(i).StatusReset();
if (i >= 1 && i <= 8)
if (RTrig.GetInstance("柔性味魔方配料完成").Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3))
{
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);
MessageLog.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成");
int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.CutWeightFeedback;
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);
}
SmallStation.DosingTray1 = false;
}
}
}
if (RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1")))
{
var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
MessageLog.GetInstance.ShowRunLog($"配方{res.RecipeName}配料完成");
MessageLog.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName}配料完成");
RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
for (int i = 0; i < 16; i++)
for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
{
RecipeFinishInfo.Material[i] = new UDT1();
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;
}
SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 3);
if (SiemensDevice.IsConnected)
{
SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 3);
}
RecipeFinishInfo.Ask_For_Finish = true;
Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res);
App.Current.Dispatcher.Invoke(() =>
{
Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res);
});
RecipeQueue.TryDequeue(out code);
HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false);
SmallStation.RecipeStatusID = 0;
@@ -666,6 +743,163 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
}
if (RecipeQueueTray2.Count > 0)
{
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueueTray2.ElementAt(0));
if (index >= 0 && index < RemoteRecipes.Count)
{
string code = RemoteRecipes.ElementAt(index).RecipeCode;
int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
if (trayCode == 2)
{
if (SmallStation.RecipeStatusIDTray2 == 0)
{
MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},初始化");
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
{
HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation, 2);
}
HKDevice.HK_PLC_S7.Write("DB4.DBX1.4", true);
SmallStation.RecipeStatusIDTray2 = 1;
MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},下发完成");
HKDevice.HK_PLC_S7.Write("DB3.DBX1.4", true);
}

if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.4") && SmallStation.RecipeStatusIDTray2 == 1)
{
HKDevice.HK_PLC_S7.Write("DB3.DBX1.4", false);
SmallStation.RecipeStatusIDTray2 = 2;
MessageLog.GetInstance.ShowRunLog($"配方:{recipeName},plc端 配方接收完成");
}
if (SmallStation.RecipeStatusIDTray2 == 2)
{
if (RTrig.GetInstance("DB3.DBX50.4").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.4")))
{
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD26");
MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},1号桶,{res}料仓,允许配料");
if (res > 0 && res is float loc)
{
//int decimalNum = Convert.ToInt32(loc.ToString().Substring(loc.ToString().IndexOf(".") + 1));
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 >= 0)
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//根据料仓编号 启动并写入每个原料重量
SmallStation.StockInIsWork = (int)loc;
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.0", false);
}
SmallStation.DosingTray2 = true;
MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},1号桶,{(int)loc}号仓,配料完成");
}
}
else if (RTrig.GetInstance("DB3.DBX50.5").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.5")))
{
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD30");
MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},2号桶,{res}料仓,允许配料");
if (res > 0 && res is float loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 0)
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = (int)loc;
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.5", false);
}
SmallStation.DosingTray2 = true;
MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},2号桶,{(int)loc}号仓,配料完成");
}
}
else if (RTrig.GetInstance("DB3.DBX50.6").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.6")))
{
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD34");
MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},3号桶,{res}料仓,允许配料");
if (res > 0 && res is float loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 0)
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = (int)loc;
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.6", false);
}
SmallStation.DosingTray2 = true;
MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},3号桶,{(int)loc}号仓,配料完成");

}
}
else if (RTrig.GetInstance("DB3.DBX50.7").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.7")))
{
var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD38");
MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},4号桶,{res}料仓,允许配料");
if (res > 0 && res is float loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 0)
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = (int)loc;
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.7", false);
}
SmallStation.DosingTray2 = true;
MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},4号桶,{(int)loc}号仓,配料完成");
}
}
if (SmallStation.DosingTray2 == true)
{
for (int i = 1; i < 16; i++)
{
if (RTrig.GetInstance("柔性味魔方配料完成").Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3))
{
MessageLog.GetInstance.ShowRunLog($"柔性味魔方,托盘2,配方:{recipeName},{i}号仓,配料完成");
int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.CutWeightFeedback;
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);
}
SmallStation.DosingTray2 = false;
}
}
}
if (RTrig.GetInstance("DB3.DBX1.2").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.2")))
{
var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
MessageLog.GetInstance.ShowRunLog($"托盘2配方{res.RecipeName}配料完成");
RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
{
RecipeFinishInfo.Material[i] = new UDT1();
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;
}
RecipeFinishInfo.Ask_For_Finish = true;
if (SiemensDevice.IsConnected)
{
SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 3);
}
App.Current.Dispatcher.Invoke(() =>
{
Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res);
});
RecipeQueueTray2.TryDequeue(out code);
HKDevice.HK_PLC_S7.Write("DB3.DBX1.2", false);
SmallStation.RecipeStatusIDTray2 = 0;
}
}
}
}
}
}
}
}

+ 3
- 1
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs Voir le fichier

@@ -313,7 +313,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
AlarmHelper<AlarmInfo>.Alarm.SiloUpperLimit = deviceStatus.DeviceAlarmCode.Get16bitValue(8);
AlarmHelper<AlarmInfo>.Alarm.SiloLowerLimit = deviceStatus.DeviceAlarmCode.Get16bitValue(9);
AlarmHelper<AlarmInfo>.Alarm.EStop1 = true;
Thread.Sleep(100);
Thread.Sleep(10);
}), $"{DeviceName} 开始监听", true);
}
}
@@ -341,6 +341,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方量
modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入
MessageLog.GetInstance.ShowRunLog($"开始配料");
//配料设备参数写入
var res = Json<DevicePar>.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName);
if (res != null)
@@ -353,6 +354,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
modbusTcp.SetUint(DeviceAddress.SiloUpperLimitWeight, (uint)res.SiloUpperLimitWeight);
modbusTcp.SetUint(DeviceAddress.LowerLimitWeightOfSilo, (uint)res.LowerLimitWeightOfSilo);
modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed * 100);
MessageLog.GetInstance.ShowRunLog($"参数下发完成");
}
}
}


+ 1
- 1
BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs Voir le fichier

@@ -26,7 +26,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
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);
ActionManage.GetInstance.Send("SiemensRecipeRecive", res);
res.Ask_For_Send_Bit = false;
this.Siemens_PLC_S7.WriteClass<XL_Start_DB>(res, 1);
}


+ 59
- 9
BPASmartClient.JXJFoodSmallStation/View/ManualControlView.xaml Voir le fichier

@@ -7,8 +7,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:vm="clr-namespace:BPASmartClient.JXJFoodSmallStation.ViewModel"
d:DesignHeight="450"
d:DesignWidth="800"
d:DesignHeight="850"
d:DesignWidth="1200"
mc:Ignorable="d">

<UserControl.Resources>
@@ -54,17 +54,67 @@
</UserControl.DataContext>

<Grid Margin="8">

<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition Height="1*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<Grid
Name="jiu"
Grid.Row="0"
Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="20" />
<RowDefinition />
</Grid.RowDefinitions>
<pry:ImageBorder
Grid.RowSpan="2"
Width="{Binding ElementName=tp, Path=ActualWidth}"
Height="{Binding ElementName=tp, Path=ActualHeight}" />

<Image
Margin="2,3,0,0"
HorizontalAlignment="Left"
Source="/BPASmartClient.CustomResource;component/Image/标签.png" />
<TextBlock
Margin="10,0,0,0"
VerticalAlignment="Center"
FontSize="16"
Foreground="Aqua"
Text="总控制" />
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"></ColumnDefinition>
<ColumnDefinition Width="1*"></ColumnDefinition>
<ColumnDefinition Width="1*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
</Grid>
<RadioButton
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType={x:Type ListView}, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="启动"
Foreground="Aqua"
IsChecked="False"
Style="{StaticResource radioButtonStyle}" />
<RadioButton
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType={x:Type ListView}, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="停止"
Foreground="Aqua"
IsChecked="False"
Style="{StaticResource radioButtonStyle}" />
</Grid>

<!--#region 升降气缸-->
<Grid
Name="cy"
Grid.Row="0"
Grid.Row="1"
Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
@@ -166,7 +216,7 @@
<!--#region 阻挡气缸-->
<Grid
Name="zd"
Grid.Row="1"
Grid.Row="2"
Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
@@ -268,7 +318,7 @@
<!--#region 托盘气缸-->
<Grid
Name="tp"
Grid.Row="2"
Grid.Row="3"
Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="40" />


+ 22
- 51
BPASmartClient.JXJFoodSmallStation/View/NewRecipeView.xaml Voir le fichier

@@ -87,67 +87,38 @@

<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0"

<TextBlock
Margin="10,0,0,0"
Orientation="Horizontal">
<TextBlock
Margin="0,0,0,0"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="配方名称:" />
<TextBox
Width="150"
Height="30"
Margin="0,0,0,0"
FontSize="16"
Text="{Binding RecipeName}" />
<TextBlock
Margin="0,0,10,0"
HorizontalAlignment="Right"
Background="Transparent"
FontSize="16"
Foreground="Red"
Text="{Binding ErrorInfo}" />
</StackPanel>
<StackPanel Grid.Row="1"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="请输入配方名称:" />

<TextBlock
Margin="0,0,10,0"
HorizontalAlignment="Right"
Background="Transparent"
FontSize="16"
Foreground="Red"
Text="{Binding ErrorInfo}" />

<StackPanel
Grid.Row="1"
Margin="10,0,0,0"
Orientation="Horizontal">
<TextBlock
Margin="0,0,0,0"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="配方编号:" />
<TextBox
Width="150"
Height="30"
Margin="0,0,0,0"
FontSize="16"
Text="{Binding RecipeCode}" />
<TextBlock
Margin="10,0,0,0"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="托盘编号:" />

<TextBox
Width="150"
Grid.Column="1"
Width="200"
Height="30"
Margin="0,0,0,0"
Margin="0,0,7,0"
FontSize="16"
Text="{Binding RecipeCode}" />
</StackPanel>

<StackPanel
Grid.Row="2"
Margin="10,0,0,0"
Orientation="Horizontal">
Text="{Binding RecipeName}" />

<Button
Width="148"


+ 243
- 0
BPASmartClient.JXJFoodSmallStation/View/NewRemoteRecipeView.xaml Voir le fichier

@@ -0,0 +1,243 @@
<Window
x:Class="BPASmartClient.JXJFoodSmallStation.View.NewRemoteRecipeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.JXJFoodSmallStation.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmartClient.JXJFoodSmallStation.ViewModel"
Title="NewRemoteRecipeView"
Width="700"
Height="450"
AllowsTransparency="True"
Background="{x:Null}"
Topmost="True"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
mc:Ignorable="d">

<Window.DataContext>
<vm:NewRemoteRecipeViewModel />
</Window.DataContext>

<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" />

<ResourceDictionary>
<!--#region ListBox样式-->
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="BorderBrush" Value="{x:Null}" />
<Setter Property="Foreground" Value="White" />
<Setter Property="FontSize" Value="20" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border x:Name="border" CornerRadius="8">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--#endregion-->
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>

<Border Name="br" BorderThickness="2" BorderBrush="#0CADF5">
<Border.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/bg.png" />
</Border.Background>
<Grid Margin="10">
<!--<Grid.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/bg.png" />
</Grid.Background>-->
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel VerticalAlignment="Center" Grid.Column="0" Orientation="Horizontal">
<TextBlock
Width="100"
Margin="10,0,10,0"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="配方名称:" />
<TextBox
Width="120"
Height="30"
FontSize="16"
Text="{Binding RecipeName}" />
<TextBlock
Width="100"
Margin="0,0,10,0"
HorizontalAlignment="Right"
Background="Transparent"
FontSize="16"
Foreground="Red"
Text="{Binding ErrorInfo}" />
</StackPanel>
<WrapPanel VerticalAlignment="Center" Grid.Column="1">
<TextBlock
Width="100"
Margin="10,0,10,0"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="配方编码:" />
<TextBox
Width="120"
Height="30"
FontSize="16"
Text="{Binding RecipeCode}" />
</WrapPanel>
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<WrapPanel VerticalAlignment="Center" Grid.Column="0">
<TextBlock
Width="100"
Margin="10,0,10,0"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="托盘编号:" />
<TextBox
Width="120"
Height="30"
FontSize="16"
Text="{Binding TrayNum}" />
</WrapPanel>
<WrapPanel HorizontalAlignment="Right" Orientation="Horizontal" Grid.Column="1">
<Button
Width="100"
Height="40"
Margin="5,0,5,0"
Command="{Binding AddCommand}"
Content="添加原料"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
<Button
Width="100"
Height="40"
Margin="5,0,5,0"
Command="{Binding SaveCommand}"
Content="保存配方"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
<Button
Name ="Close"
Width="100"
Height="40"
Margin="5,0,5,0"
Content="取消"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />
</WrapPanel>
</Grid>


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

<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="原料位置" HorizontalAlignment="Center" />
<Grid Grid.Column="1">
<TextBlock Text="原料桶号" HorizontalAlignment="Center" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>
<TextBlock Grid.Column="2" Text="原料重量" HorizontalAlignment="Center" />
<Grid Grid.Column="3">
<TextBlock Text="功能操作" HorizontalAlignment="Center" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>
<Border Grid.ColumnSpan="10" BorderThickness="1,0,1,0" />
</Grid>
<Grid Grid.Row="3">
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding RawMaterial}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Name="gr">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<TextBox
Grid.Column="0"
Text="{Binding RawMaterialLocation }" />

<Grid Grid.Column="1">
<TextBox
Text="{Binding RawMaterialBarrelNum}" />
<Border
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>

<TextBox
Grid.Column="2"
Text="{Binding RawMaterialWeight}" />

<Grid Grid.Column="3">
<Button
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding RawMaterialLocation}"
Content="删除"
FontSize="16" />
<Border
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>

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

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


</Grid>
</Border>
</Window>

+ 33
- 0
BPASmartClient.JXJFoodSmallStation/View/NewRemoteRecipeView.xaml.cs Voir le fichier

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

namespace BPASmartClient.JXJFoodSmallStation.View
{
/// <summary>
/// DeviceMaterialParView.xaml 的交互逻辑
/// </summary>
public partial class NewRemoteRecipeView : Window
{
public NewRemoteRecipeView()
{
InitializeComponent();
this.Close.Click += (o, e) => { this.Close(); };
this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); };
ActionManage.GetInstance.CancelRegister("CloseNewRemoteRecipeView");
ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "CloseNewRemoteRecipeView");
}
}
}

+ 0
- 1
BPASmartClient.JXJFoodSmallStation/View/RecipeInfosView.xaml.cs Voir le fichier

@@ -23,7 +23,6 @@ namespace BPASmartClient.JXJFoodSmallStation.View
public RecipeInfosView()
{
InitializeComponent();

ActionManage.GetInstance.CancelRegister("CloseRecipeInfosView");
ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "CloseRecipeInfosView");
}


+ 37
- 8
BPASmartClient.JXJFoodSmallStation/View/RecipeReceiveView.xaml Voir le fichier

@@ -49,6 +49,16 @@
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<pry:IcoButton
Width="140"
Margin="10"
HorizontalAlignment="Left"
Command="{Binding NewRecipe}"
Content="自定义配方"
FontSize="16"
Foreground="Aqua"
IcoText="&#xe626;"
Style="{StaticResource IcoButtonStyle}" />
<pry:IcoButton
Width="140"
Margin="10"
@@ -100,14 +110,33 @@
<RowDefinition Height="0.2*" />
</Grid.RowDefinitions>
<Image Source="/BPASmartClient.CustomResource;component/Image/AGV/炒锅.png" />
<TextBlock
Grid.Row="1"
Margin="2,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="#dd000000"
Text="{Binding RecipeName}" />

<WrapPanel Grid.Row="1">
<TextBlock
Margin="2,0,0,0"
Foreground="#dd000000"
Text="名称:" />
<TextBlock
Margin="2,0,0,0"
Foreground="#dd000000"
Text="{Binding RecipeName}" />
<TextBlock
Margin="5,0,0,0"
Foreground="#dd000000"
Text="编号:" />
<TextBlock
Margin="2,0,0,0"
Foreground="#dd000000"
Text="{Binding RecipeCode}" />
<TextBlock
Margin="5,0,0,0"
Foreground="#dd000000"
Text="托盘号:" />
<TextBlock
Margin="2,0,0,0"
Foreground="#dd000000"
Text="{Binding TrayCode}" />
</WrapPanel>
<Grid
Name="gr"
Grid.Row="2"


+ 30
- 2
BPASmartClient.JXJFoodSmallStation/ViewModel/ManualControlViewModel.cs Voir le fichier

@@ -31,16 +31,43 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
});
}

for (int i = 0; i < 2; i++)
for (int i = 1; i < 3; i++)
{
PalletCylinders.Add(new CylinderModel()
{
Name = $"托盘气缸 {i + 1}",
Name = $"托盘气缸1_{(i + 1)%2 +1}",
LeftTog = false,
RightTog = false,
});
}

for (int i = 1; i < 3; i++)
{
PalletCylinders.Add(new CylinderModel()
{
Name = $"托盘气缸2_{(i + 1) % 2 + 1}",
LeftTog = false,
RightTog = false,
});
}

PalletCylinders.Add(new CylinderModel()
{
Name = $"进料桶顶升气缸",
LeftTog = false,
RightTog = false,
});
for (int i = 0; i < 3; i++)
{
PalletCylinders.Add(new CylinderModel()
{
Name = $"出料桶顶升气缸{i+1}",
LeftTog = false,
RightTog = true,
});
}

Open = new RelayCommand<object>((o) =>
{
ActionManage.GetInstance.Send("ManualOpen", o);
@@ -68,6 +95,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
/// </summary>
public ObservableCollection<CylinderModel> PalletCylinders { get; set; } = new ObservableCollection<CylinderModel>();


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

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


+ 94
- 0
BPASmartClient.JXJFoodSmallStation/ViewModel/NewRemoteRecipeViewModel.cs Voir le fichier

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

namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
public class NewRemoteRecipeViewModel : ObservableObject
{
public NewRemoteRecipeViewModel()
{
RemoveCommand = new RelayCommand<object>((o) =>
{
var res = RawMaterial.FirstOrDefault(p => p.RawMaterialLocation == (int)o);
if (res != null) RawMaterial.Remove(res);
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"{o.ToString()}:原料删除成功!");
});

AddCommand = new RelayCommand(() =>
{
RawMaterial.Add(new RemoteRecipeRawMaterial()
{
RawMaterialLocation= RawMaterial.Count +1
});
});
SaveCommand = new RelayCommand(() =>
{
ObservableCollection<RemoteRecipeRawMaterial> RawMaterials = new ObservableCollection<RemoteRecipeRawMaterial>();
if (RawMaterial == null || RawMaterial.Count <= 0)
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"没有可保存的参数!");
return;
}

for (int i = 0; i < RawMaterial.Count; i++)
{
if (RawMaterial.Where(p => p.RawMaterialLocation == RawMaterial.ElementAt(i).RawMaterialLocation)?.ToList()?.Count >= 2)
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "错误", $"原料位置冲突,请检查后重试!");
return;
}
}
foreach (var item in RawMaterial)
{
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
RawMaterialLocation = item.RawMaterialLocation,
RawMaterialBarrelNum = item.RawMaterialBarrelNum,
RawMaterialWeight = item.RawMaterialWeight,
});
}
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
{
RecipeName = RecipeName,
RecipeCode = RecipeCode,
TrayCode = TrayNum,
RawMaterial = RawMaterials,
});
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"自定义配方添加完成!");
ActionManage.GetInstance.Send("CloseNewRemoteRecipeView");
});
}
public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } }
private string _mRecipeCode = string.Empty;

public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } }
private string _mRecipeName = string.Empty;

public int TrayNum { get { return _mTrayNum; } set { _mTrayNum = value; OnPropertyChanged(); } }
private int _mTrayNum = 0;

public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } }
private string _mErrorInfo;

public ObservableCollection<RemoteRecipeRawMaterial> RawMaterial { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>();

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

public RelayCommand AddCommand { get; set; }
public RelayCommand SaveCommand { get; set; }

}
}

+ 2
- 0
BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs Voir le fichier

@@ -16,6 +16,8 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
public RecipeInfosViewModel()
{

ActionManage.GetInstance.CancelRegister("RecipeInfo");
ActionManage.GetInstance.Register(new Action<object>((o) =>
{
if (o != null && o is RemoteRecipeData rm)


+ 35
- 19
BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs Voir le fichier

@@ -23,16 +23,21 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
{
public class RecipeReceiveViewModel : ObservableObject
{
ObservableCollection<RemoteRecipeRawMaterial> RawMaterials { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>();
//ObservableCollection<RemoteRecipeRawMaterial> RawMaterials { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>();
public RecipeReceiveViewModel()
{
//Json<LocaPar>.Read();
Recipes = Json<RemoteRecipeDataColl>.Data.Recipes;
NewRecipe = new RelayCommand(() =>
{
NewRemoteRecipeView NewRemoteRecipe = new NewRemoteRecipeView();
NewRemoteRecipe.ShowDialog();
});
DetailsCommand = new RelayCommand<object>((o) =>
{
if (o != null && o is string num)
{
ActionManage.GetInstance.CancelRegister("RecipeInfo");
ActionManage.GetInstance.Send("CloseRecipeInfosView");
RecipeInfosView nrv = new RecipeInfosView();
var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == num);
ActionManage.GetInstance.Send("RecipeInfo", res);
@@ -42,34 +47,46 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
});
NewSimulateRecipe = new RelayCommand(() =>
{
RawMaterials.Clear();
//RawMaterials.Clear();
ObservableCollection<RemoteRecipeRawMaterial> RawMaterials = new ObservableCollection<RemoteRecipeRawMaterial>();
string recipeName = "配方" + (Json<RemoteRecipeDataColl>.Data.Recipes.Count + 1) + "";
go:
string recipeCode = new Random().Next(1000, 9999).ToString();
foreach (var item in Recipes)
foreach (var item in Json<RemoteRecipeDataColl>.Data.Recipes)
{
if (item.RecipeCode == recipeCode)
if (item.RecipeCode == recipeCode)
{
goto go;
}
}
}
int trayCode = new Random().Next(1, 3);
for (int i = 1; i < 16; i++)
{
RawMaterials.Add(new RemoteRecipeRawMaterial()
if ( i == 7 || i == 8 || i == 15)
{
RawMaterialWeight = new Random().Next(10, 20),
RawMaterialBarrelNum = (short)new Random().Next(1, 5),
RawMaterialLocation = i,
});
}
else
{
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
RawMaterialName = "原料" + i,
RawMaterialWeight = new Random().Next(200, 300),
RawMaterialBarrelNum = (short)new Random().Next(1, 5),
RawMaterialLocation = i,
});
}
}
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
var res = Array.FindIndex(Json<RemoteRecipeDataColl>.Data.Recipes.ToArray(), p => p.RecipeCode == recipeCode);
if (res < 0)
{
RecipeName = recipeName,
RecipeCode = recipeCode,
TrayCode = trayCode,
RawMaterial = RawMaterials,
});
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
{
RecipeName = recipeName,
RecipeCode = recipeCode,
TrayCode = trayCode,
RawMaterial = RawMaterials,
});
}

});
ClearAllRecipe = new RelayCommand(() =>
@@ -77,12 +94,11 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
Json<RemoteRecipeDataColl>.Data.Recipes.Clear();
});
}

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

public RelayCommand NewSimulateRecipe { get; set; }
public RelayCommand ClearAllRecipe { get; set; }
public RelayCommand NewRecipe { get; set; }
public ObservableCollection<RemoteRecipeData> Recipes { get; set; }
}
}

+ 16
- 0
BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj Voir le fichier

@@ -26,6 +26,10 @@
<None Remove="Images\redis.png" />
<None Remove="Images\redisrun.png" />
<None Remove="Images\redisstop.png" />
<None Remove="Images\Scroll_←.png" />
<None Remove="Images\Scroll_↑.png" />
<None Remove="Images\Scroll_→.png" />
<None Remove="Images\Scroll_↓.png" />
<None Remove="Images\State0.png" />
<None Remove="Images\State1.png" />
<None Remove="Images\State11.png" />
@@ -110,6 +114,18 @@
<Resource Include="Images\redisstop.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Scroll_←.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Scroll_↑.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Scroll_→.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Scroll_↓.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\State0.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>


+ 3
- 7
BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs Voir le fichier

@@ -505,14 +505,10 @@ namespace BPASmartClient.SCADAControl.CustomerControls
string[] str= item.Value.Replace("{Binding ","").Replace("}","").Split(".");
if (str.Length > 1)
{
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0]))
if (Class_DataBus.GetInstance().Dic_RedisData.ContainsKey(str[0]))
{
Dictionary<string,DeviceDataModel> b= Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
if (b!=null && b.ContainsKey(str[1]))
{
object _value = b[str[1]].VarVaule;
this.GetType().GetProperty(item.Key).SetValue(this,_value);
}
Dictionary<string, object> b= Class_DataBus.GetInstance().Dic_RedisData[str[0]];
if (b!=null && b.ContainsKey(str[1])) this.GetType().GetProperty(item.Key).SetValue(this, b[str[1]]);
}
}
}


+ 8
- 20
BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs Voir le fichier

@@ -201,24 +201,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls
string[] str = item.Value.Replace("{Binding ","").Replace("}","").Split(".");
if (str.Length > 1)
{
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0]))
if (Class_DataBus.GetInstance().Dic_RedisData.ContainsKey(str[0]))
{
Dictionary<string,DeviceDataModel> b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
Dictionary<string,object> b = Class_DataBus.GetInstance().Dic_RedisData[str[0]];
if (b != null && b.ContainsKey(str[1]))
{
object _value = b[str[1]].VarVaule;
bool _checked = false;
try
{
_checked = bool.Parse(_value.ToString());
}
catch (Exception ex)
{
_checked = false;
}
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType);
SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = _checked.ToString(),DataType = eDataType });
this.GetType().GetProperty("IsChecked").SetValue(this,_checked);
this.GetType().GetProperty("IsChecked").SetValue(this, b[str[1]]);
}
}
}
@@ -239,13 +227,13 @@ namespace BPASmartClient.SCADAControl.CustomerControls
string[] str = item.Value.Replace("{Binding ","").Replace("}","").Split(".");
if (str.Length > 1)
{
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0]))
if (Class_DataBus.GetInstance().Dic_RedisData.ContainsKey(str[0]))//包含设备名称
{
Dictionary<string,DeviceDataModel> b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
if (b != null && b.ContainsKey(str[1]))
Dictionary<string,string> blx = Class_DataBus.GetInstance().Dic_RedisDataType[str[0]];

if (blx != null && blx.ContainsKey(str[1]))
{
object _value = b[str[1]].VarVaule;
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType);
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType), blx[str[1]]);
SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = this.IsChecked.ToString(),DataType = eDataType });
}
}


+ 3
- 7
BPASmartClient.SCADAControl/CustomerControls/TheButton.xaml.cs Voir le fichier

@@ -121,14 +121,10 @@ namespace BPASmartClient.SCADAControl.CustomerControls
string[] str = item.Value.Replace("{Binding ","").Replace("}","").Split(".");
if (str.Length > 1)
{
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0]))
if (Class_DataBus.GetInstance().Dic_RedisData.ContainsKey(str[0]))
{
Dictionary<string,DeviceDataModel> b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
if (b != null && b.ContainsKey(str[1]))
{
object _value = b[str[1]].VarVaule;
this.GetType().GetProperty(item.Key).SetValue(this,_value);
}
Dictionary<string, object> b = Class_DataBus.GetInstance().Dic_RedisData[str[0]];
if (b != null && b.ContainsKey(str[1])) this.GetType().GetProperty(item.Key).SetValue(this, b[str[1]]);
}
}
}


+ 3
- 5
BPASmartClient.SCADAControl/CustomerControls/TheDataGrid.xaml.cs Voir le fichier

@@ -128,13 +128,11 @@ namespace BPASmartClient.SCADAControl.CustomerControls
string[] str = DataSouceInformation.Replace("{Binding ", "").Replace("}", "").Split(".");
if (str.Length > 1)
{
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0]))
if (Class_DataBus.GetInstance().Dic_RedisData.ContainsKey(str[0]))
{
Dictionary<string, DeviceDataModel> b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
Dictionary<string, object> b = Class_DataBus.GetInstance().Dic_RedisData[str[0]];
if (b != null && b.ContainsKey(str[1]))
{
FDataSouce = b[str[1]].VarVaule;
}
FDataSouce = b[str[1]].ToString();
}
}
}


+ 3
- 54
BPASmartClient.SCADAControl/CustomerControls/TheListBox.xaml.cs Voir le fichier

@@ -126,26 +126,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls
}
public static readonly DependencyProperty CodeProperty =
DependencyProperty.Register("Code", typeof(string), typeof(TheListBox), new PropertyMetadata(_code));
//[Category("数据绑定")]
//public bool IsRun
//{
// get { return (bool)GetValue(RunProperty); }
// set { SetValue(RunProperty, value); }
//}
//public static readonly DependencyProperty RunProperty =
// DependencyProperty.Register("IsRun", typeof(bool), typeof(TheListBox), new PropertyMetadata(false, new PropertyChangedCallback(onIsRunChanged)));
//private static void onIsRunChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as TheListBox)?.IsRunRefresh();
public void IsRunRefresh()
{
////测试运行
//if (IsRun)
// IsExecuteState = true;
//else
//{
// IsExecuteState = false;
// Dispose();
//}
}
[Category("数据绑定")]
public string GenerateData
{
@@ -163,18 +143,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
Dictionary<string, object> keys = JsonConvert.DeserializeObject<Dictionary<string, object>>(GenerateData);
ItemsString = JsonConvert.DeserializeObject<ObservableCollection<object>>(keys["data"].ToString());


//ItemsString = JsonConvert.DeserializeObject<DataSouceModel>(GenerateData);
// 运行时进行项目绑定

//this.ItemsSource = ListToDataTable(obj2).DefaultView;

// 运行时进行项目绑定
//Binding binding = new Binding();
//binding.RelativeSource = new RelativeSource() { Mode = RelativeSourceMode.Self };
//binding.Path = new PropertyPath("ItemsString");
//SetBinding(ItemsSourceProperty,binding);
}
catch (Exception ex)
{
@@ -250,22 +218,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls

public void XmlToFrameworkElement()
{
StackPanel stackPanel = new StackPanel() { Width = 600, Height = 30, Orientation = Orientation.Horizontal };
Button button = new Button();
button.Name = "button1";
Binding bindingButton = new Binding("alarmTime");
button.SetBinding(Button.ContentProperty, bindingButton);
stackPanel.Children.Add(button);

TextBlock textBlock = new TextBlock();
textBlock.Name = "text1";
Binding bindingtextBlock = new Binding("alarmMessage");
textBlock.SetBinding(TextBlock.TextProperty, bindingtextBlock);
stackPanel.Children.Add(textBlock);
FrameworkElementToXml(stackPanel);



var template = (DataTemplate)XamlReader.Parse(@"
<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
@@ -283,7 +235,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
timer.Stop();
FDataSouce = "";
//if (IsRun) IsRun = false;
GenerateDataRefresh();
}

@@ -305,13 +256,11 @@ namespace BPASmartClient.SCADAControl.CustomerControls
string[] str = DataSouceInformation.Replace("{Binding ", "").Replace("}", "").Split(".");
if (str.Length > 1)
{
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0]))
if (Class_DataBus.GetInstance().Dic_RedisData.ContainsKey(str[0]))
{
Dictionary<string, DeviceDataModel> b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
Dictionary<string, object> b = Class_DataBus.GetInstance().Dic_RedisData[str[0]];
if (b != null && b.ContainsKey(str[1]))
{
FDataSouce = b[str[1]].VarVaule;
}
FDataSouce = b[str[1]].ToString();
}
}
}


+ 66
- 11
BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs Voir le fichier

@@ -163,26 +163,34 @@ namespace BPASmartClient.SCADAControl.CustomerControls
if (!string.IsNullOrEmpty(DeviceName))
{
RedisValue obj = fRedisClient.RedisGet(DeviceName);
List<DeviceDataModel> str = JsonConvert.DeserializeObject<List<DeviceDataModel>>(obj.ToString());
Dictionary<string,DeviceDataModel> keys = new Dictionary<string,DeviceDataModel>();
str?.ForEach(par =>
List<ReeisDataModel> str = JsonConvert.DeserializeObject<List<ReeisDataModel>>(obj.ToString());
Dictionary<string, object> keyValues = new Dictionary<string, object>();
Dictionary<string, string> keyValuesType = new Dictionary<string, string>();
str?.ForEach(jon =>
{
keys[par.VarName] = par;
keyValues[jon.VarName] = GetValuesType(jon.DataType, jon.VarVaule);
keyValuesType[jon.VarName] = jon.DataType.ToString();
});
Class_DataBus.GetInstance().Dic_DeviceData[DeviceName] = keys;
Class_DataBus.GetInstance().Dic_RedisData[DeviceName] = keyValues;
Class_DataBus.GetInstance().Dic_RedisDataType[DeviceName] = keyValuesType;
if (PropertyChange != null) PropertyChange(this,null);
}
else
{
fRedisClient.GetKeys()?.ToList().ForEach(par => {

List<DeviceDataModel> str = JsonConvert.DeserializeObject<List<DeviceDataModel>>(par.Value);
Dictionary<string,DeviceDataModel> keys = new Dictionary<string,DeviceDataModel>();
str?.ForEach(par =>
//所有变量集合
//PublishInfo
List<ReeisDataModel> str = JsonConvert.DeserializeObject<List<ReeisDataModel>>(par.Value);
Dictionary<string,object> keyValues = new Dictionary<string,object>();
Dictionary<string, string> keyValuesType = new Dictionary<string, string>();
str?.ForEach(jon =>
{
keys[par.VarName] = par;
keyValues[jon.VarName] = GetValuesType(jon.DataType, jon.VarVaule);
keyValuesType[jon.VarName] = jon.DataType.ToString();
});
Class_DataBus.GetInstance().Dic_DeviceData[par.Key] = keys;
Class_DataBus.GetInstance().Dic_RedisData[par.Key] = keyValues;
Class_DataBus.GetInstance().Dic_RedisDataType[par.Key] = keyValuesType;
});
if (PropertyChange != null) PropertyChange(this,null);
}
@@ -194,6 +202,53 @@ namespace BPASmartClient.SCADAControl.CustomerControls
}
}

/// <summary>
/// 根据变量获取变量实际值
/// </summary>
/// <param name="eData"></param>
/// <param name="Value"></param>
/// <returns></returns>
public object GetValuesType(EDataType eData,string Value)
{
try
{
if (!string.IsNullOrEmpty(Value))
{
switch (eData)
{
case EDataType.Bool:
return Convert.ToBoolean(Value);
break;
case EDataType.Byte:
return Convert.ToByte(Value);
break;
case EDataType.Int:
return Convert.ToInt16(Value);
break;
case EDataType.Word:
return Convert.ToUInt16(Value);
break;
case EDataType.Dint:
return Convert.ToInt32(Value);
break;
case EDataType.Dword:
return Convert.ToUInt32(Value);
break;
case EDataType.Float:
return Convert.ToSingle(Value);
break;
default:
break;
}
}
return null;
}
catch (Exception ex)
{
return null;
}
}

public void Start() => timer.Start();
public void Stop() => timer.Stop();



+ 15
- 9
BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs Voir le fichier

@@ -33,8 +33,18 @@ namespace BPASmartClient.SCADAControl.CustomerControls
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml", UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
Height = 30;
Width = 80;
this.Loaded += TheTextBlock_Loaded;
}

private void TheTextBlock_Loaded(object sender, RoutedEventArgs e)
{
if (this.ActualWidth <= 0)
{
Text = "文本";
Height = 30;
Width = 80;
FontSize = 16;
}
}

public string ControlType => "控件";
@@ -111,14 +121,10 @@ namespace BPASmartClient.SCADAControl.CustomerControls
string[] str = item.Value.Replace("{Binding ","").Replace("}","").Split(".");
if (str.Length > 1)
{
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0]))
if (Class_DataBus.GetInstance().Dic_RedisData.ContainsKey(str[0]))
{
Dictionary<string,DeviceDataModel> b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
if (b != null && b.ContainsKey(str[1]))
{
object _value = b[str[1]].VarVaule;
this.GetType().GetProperty(item.Key).SetValue(this,_value);
}
Dictionary<string, object> b = Class_DataBus.GetInstance().Dic_RedisData[str[0]];
if (b != null && b.ContainsKey(str[1])) this.GetType().GetProperty(item.Key).SetValue(this, b[str[1]]);
}
}
}


+ 22
- 16
BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs Voir le fichier

@@ -37,12 +37,23 @@ namespace BPASmartClient.SCADAControl.CustomerControls
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
Height = 30;
Width = 80;
FontSize = 16;
this.KeyDown += TheTextBox_KeyDown;
this.TextChanged += TheTextBox_TextChanged;
this.Loaded += TheTextBox_Loaded;
}

private void TheTextBox_Loaded(object sender, RoutedEventArgs e)
{
if (this.ActualWidth <= 10)
{
Text = "文本框";
Height = 30;
Width = 80;
FontSize = 16;
}
}

bool isRun=false;
private void TheTextBox_KeyDown(object sender,KeyEventArgs e)
{
@@ -60,14 +71,13 @@ namespace BPASmartClient.SCADAControl.CustomerControls
string[] str = item.Value.Replace("{Binding ","").Replace("}","").Split(".");
if (str.Length > 1)
{
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0]))
if (Class_DataBus.GetInstance().Dic_RedisData.ContainsKey(str[0]))
{
Dictionary<string,DeviceDataModel> b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
if (b != null && b.ContainsKey(str[1]))
Dictionary<string, string> blx = Class_DataBus.GetInstance().Dic_RedisDataType[str[0]];
if (blx != null && blx.ContainsKey(str[1]))
{
object _value = b[str[1]].VarVaule;
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType);
SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = Text,DataType = eDataType });
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType), blx[str[1]]);
SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0], VarName = str[1], Value = Text, DataType = eDataType });
}
}
}
@@ -169,14 +179,10 @@ namespace BPASmartClient.SCADAControl.CustomerControls
string[] str = item.Value.Replace("{Binding ","").Replace("}","").Split(".");
if (str.Length > 1)
{
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0]))
if (Class_DataBus.GetInstance().Dic_RedisData.ContainsKey(str[0]))
{
Dictionary<string,DeviceDataModel> b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
if (b != null && b.ContainsKey(str[1]))
{
object _value = b[str[1]].VarVaule;
this.GetType().GetProperty(item.Key).SetValue(this,_value);
}
Dictionary<string, object> b = Class_DataBus.GetInstance().Dic_RedisData[str[0]];
if (b != null && b.ContainsKey(str[1])) this.GetType().GetProperty(item.Key).SetValue(this, b[str[1]].ToString());
}
}
}


+ 8
- 38
BPASmartClient.SCADAControl/CustomerControls/TheToggleButton.xaml.cs Voir le fichier

@@ -134,8 +134,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls
timer.Start();
}
Click += TheToggleButton_Click;
Checked += TheCheckBox_Checked;
Unchecked += TheCheckBox_Unchecked;
}


@@ -155,26 +153,10 @@ namespace BPASmartClient.SCADAControl.CustomerControls
string[] str = item.Value.Replace("{Binding ","").Replace("}","").Split(".");
if (str.Length > 1)
{
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0]))
if (Class_DataBus.GetInstance().Dic_RedisData.ContainsKey(str[0]))
{
Dictionary<string,DeviceDataModel> b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
if (b != null && b.ContainsKey(str[1]))
{
object _value = b[str[1]].VarVaule;
bool _checked = false;
try
{
_checked = bool.Parse(_value.ToString());
}
catch (Exception ex)
{
_checked = false;
}
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType);
SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = _checked.ToString(),DataType = eDataType });
this.GetType().GetProperty("IsChecked").SetValue(this,_checked);
}
Dictionary<string, object> b = Class_DataBus.GetInstance().Dic_RedisData[str[0]];
if (b != null && b.ContainsKey(str[1])) this.GetType().GetProperty("IsChecked").SetValue(this, b[str[1]]);
}
}
}
@@ -194,14 +176,13 @@ namespace BPASmartClient.SCADAControl.CustomerControls
string[] str = item.Value.Replace("{Binding ","").Replace("}","").Split(".");
if (str.Length > 1)
{
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0]))
if (Class_DataBus.GetInstance().Dic_RedisData.ContainsKey(str[0]))
{
Dictionary<string,DeviceDataModel> b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
if (b != null && b.ContainsKey(str[1]))
Dictionary<string, string> blx = Class_DataBus.GetInstance().Dic_RedisDataType[str[0]];
if (blx != null && blx.ContainsKey(str[1]))
{
object _value = b[str[1]].VarVaule;
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType),b[str[1]].DataType);
SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0],VarName = str[1],Value = "False",DataType = eDataType });
EDataType eDataType = (EDataType)Enum.Parse(typeof(EDataType), blx[str[1]]);
SendText = JsonConvert.SerializeObject(new PublishModel { DeviceName = str[0], VarName = str[1], Value = IsChecked.ToString(), DataType = eDataType });
}
}
}
@@ -210,16 +191,5 @@ namespace BPASmartClient.SCADAControl.CustomerControls
else Config.GetInstance().RunJsScipt(UnCheckedExec);
timer.Start();
}


private void TheCheckBox_Unchecked(object sender, RoutedEventArgs e)
{
}

private void TheCheckBox_Checked(object sender, RoutedEventArgs e)
{

}
}
}





+ 249
- 0
BPASmartClient.SCADAControl/Themes/Generic.xaml Voir le fichier

@@ -1,6 +1,7 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
xmlns:Themes1="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic"
xmlns:con="clr-namespace:BPASmartClient.SCADAControl.Converters"
xmlns:ctrl="clr-namespace:BPASmartClient.SCADAControl.CustomerControls"
@@ -2044,4 +2045,252 @@
</Setter.Value>
</Setter>
</Style>

<!--#region ScrollBar-->
<Style x:Key="UpScrollBarButton" TargetType="{x:Type RepeatButton}">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Focusable" Value="false" />
<Setter Property="IsTabStop" Value="false" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Image
Width="8"
Height="5"
Source="../Images/Scroll_↑.png" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="DownScrollBarButton" TargetType="{x:Type RepeatButton}">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Focusable" Value="false" />
<Setter Property="IsTabStop" Value="false" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Image
Width="8"
Height="5"
Source="../Images/Scroll_↓.png" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="LeftScrollBarButton" TargetType="{x:Type RepeatButton}">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Focusable" Value="false" />
<Setter Property="IsTabStop" Value="false" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Image
Width="5"
Height="8"
Source="../Images/Scroll_←.png" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="RightScrollBarButton" TargetType="{x:Type RepeatButton}">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Focusable" Value="false" />
<Setter Property="IsTabStop" Value="false" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Image
Width="5"
Height="8"
Source="../Images/Scroll_→.png" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="VerticalScrollBarPageButton" TargetType="{x:Type RepeatButton}">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Focusable" Value="false" />
<Setter Property="IsTabStop" Value="false" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Rectangle
Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
Fill="{TemplateBinding Background}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="IsTabStop" Value="false" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Border
x:Name="bd1"
Margin="2,2,2,2"
Background="#00c2f4"
CornerRadius="3"
Cursor="Hand"
Opacity="1"
SnapsToDevicePixels="true" />
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="bd1" Property="Margin" Value="-1,-1,-1,-1" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<LinearGradientBrush x:Key="HorizontalScrollBarBackground" StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="#E1E1E1" />
<GradientStop Offset="0.20" Color="#EDEDED" />
<GradientStop Offset="0.80" Color="#EDEDED" />
<GradientStop Offset="1" Color="#E3E3E3" />
</LinearGradientBrush>
<Style x:Key="HorizontalScrollBarPageButton" TargetType="{x:Type RepeatButton}">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Focusable" Value="false" />
<Setter Property="IsTabStop" Value="false" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Rectangle
Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
Fill="{TemplateBinding Background}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type ScrollBar}">
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="../Images/biogebj.png" Opacity="0.2" />
</Setter.Value>
</Setter>
<Setter Property="Stylus.IsPressAndHoldEnabled" Value="false" />
<Setter Property="Stylus.IsFlicksEnabled" Value="false" />
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
<Setter Property="Opacity" Value="1" />
<Setter Property="MinWidth" Value="3" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ScrollBar}">
<Border
Width="10"
Margin="0,0,0,0"
Background="{TemplateBinding Background}"
CornerRadius="2"
Opacity="{TemplateBinding Opacity}">
<Grid x:Name="Bg" SnapsToDevicePixels="true">
<Grid.RowDefinitions>
<RowDefinition MaxHeight="{DynamicResource {x:Static SystemParameters.VerticalScrollBarButtonHeightKey}}" />
<RowDefinition Height="*" />
<RowDefinition MaxHeight="{DynamicResource {x:Static SystemParameters.VerticalScrollBarButtonHeightKey}}" />
</Grid.RowDefinitions>
<RepeatButton
Themes:ScrollChrome.ScrollGlyph="UpArrow"
Command="{x:Static ScrollBar.LineUpCommand}"
IsEnabled="{TemplateBinding IsMouseOver}"
Style="{StaticResource UpScrollBarButton}" />
<Track
x:Name="PART_Track"
Grid.Row="1"
IsDirectionReversed="true"
IsEnabled="{TemplateBinding IsMouseOver}">
<Track.DecreaseRepeatButton>
<RepeatButton Command="{x:Static ScrollBar.PageUpCommand}" Style="{StaticResource VerticalScrollBarPageButton}" />
</Track.DecreaseRepeatButton>

<Track.IncreaseRepeatButton>
<RepeatButton Command="{x:Static ScrollBar.PageDownCommand}" Style="{StaticResource VerticalScrollBarPageButton}" />
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb Themes:ScrollChrome.ScrollGlyph="VerticalGripper" Style="{StaticResource ScrollBarThumb}" />
</Track.Thumb>
</Track>
<RepeatButton
Grid.Row="2"
Themes:ScrollChrome.ScrollGlyph="DownArrow"
Command="{x:Static ScrollBar.LineDownCommand}"
IsEnabled="{TemplateBinding IsMouseOver}"
Style="{StaticResource DownScrollBarButton}" />
</Grid>
</Border>

</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="Orientation" Value="Horizontal">

<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ScrollBar}">
<Border
Height="10"
Margin="0,0,0,0"
Background="{TemplateBinding Background}"
CornerRadius="2"
Opacity="{TemplateBinding Opacity}">
<Grid
x:Name="Bg"
Background="{TemplateBinding Background}"
SnapsToDevicePixels="true">
<Grid.ColumnDefinitions>
<ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}" />
<ColumnDefinition Width="*" />
<ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}" />
</Grid.ColumnDefinitions>
<RepeatButton
Themes:ScrollChrome.ScrollGlyph="LeftArrow"
Command="{x:Static ScrollBar.LineLeftCommand}"
IsEnabled="{TemplateBinding IsMouseOver}"
Style="{StaticResource LeftScrollBarButton}" />
<Track
x:Name="PART_Track"
Grid.Column="1"
IsEnabled="{TemplateBinding IsMouseOver}">
<Track.DecreaseRepeatButton>
<RepeatButton Command="{x:Static ScrollBar.PageLeftCommand}" Style="{StaticResource HorizontalScrollBarPageButton}" />
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton Command="{x:Static ScrollBar.PageRightCommand}" Style="{StaticResource HorizontalScrollBarPageButton}" />
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb Themes:ScrollChrome.ScrollGlyph="HorizontalGripper" Style="{StaticResource ScrollBarThumb}" />
</Track.Thumb>
</Track>
<RepeatButton
Grid.Column="2"
Themes:ScrollChrome.ScrollGlyph="RightArrow"
Command="{x:Static ScrollBar.LineRightCommand}"
IsEnabled="{TemplateBinding IsMouseOver}"
Style="{StaticResource RightScrollBarButton}" />
</Grid>
</Border>

</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
<LinearGradientBrush x:Key="VerticalScrollBarBackground" StartPoint="0,0" EndPoint="1,0">
<GradientStop Offset="0" Color="#E1E1E1" />
<GradientStop Offset="0.20" Color="#EDEDED" />
<GradientStop Offset="0.80" Color="#EDEDED" />
<GradientStop Offset="1" Color="#E3E3E3" />
</LinearGradientBrush>
<!--#endregion-->
</ResourceDictionary>

+ 5
- 3
BeDesignerSCADA/Controls/MainCanvasPanel.xaml Voir le fichier

@@ -30,7 +30,7 @@

<!--左侧选择区域-->
<Grid >
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Background="White" Margin="4">
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Background="Transparent" Margin="4">
<ListBox x:Name="CtlList" Background="Transparent" ItemTemplate="{DynamicResource ToolBoxStyle}" BorderThickness="0" PreviewMouseMove="CtlList_PreviewMouseMove">
</ListBox>
</Border>
@@ -405,8 +405,10 @@
<ColumnDefinition Width="40"/>
</Grid.ColumnDefinitions>
<TextBox Grid.Row="2" x:Name="wenben" Padding="5" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap"></TextBox>
<ToggleButton Grid.Column="1" Height="20" Content="清除" Width="30" Margin="5,0,5,0" HorizontalAlignment="Left" Click="ClearBingToggleButton_Click"></ToggleButton>
<ToggleButton Grid.Column="1" Height="20" Content="绑定" Width="30" Margin="5,0,5,0" HorizontalAlignment="Left" Click="BingToggleButton_Click"></ToggleButton>
<StackPanel Grid.Column="1">
<ToggleButton Grid.Column="1" Height="20" Content="绑定" Width="30" Margin="5,0,5,0" HorizontalAlignment="Left" Click="BingToggleButton_Click"></ToggleButton>
<ToggleButton Height="20" Content="解绑" Width="30" Margin="5,2,5,0" HorizontalAlignment="Right" Click="ClearBingToggleButton_Click"></ToggleButton>
</StackPanel>
</Grid>
</Grid>
</DataTemplate>


+ 0
- 3
BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs Voir le fichier

@@ -241,7 +241,6 @@ namespace BeDesignerSCADA.Controls
}
return frameworks;
}

/// <summary>
/// 保存文件
/// </summary>
@@ -573,8 +572,6 @@ namespace BeDesignerSCADA.Controls
}
communication?.CommunicationDevices?.ToList().ForEach(x => { viewModel.DevNameList.Add(x.DeviceName); });
}


#endregion




+ 0
- 10
BeDesignerSCADA/MainWindow.xaml Voir le fichier

@@ -12,16 +12,6 @@
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
Title="黑菠萝科技-[组态软件1.0]" Height="900" Width="1400" Icon="/Images/ico.ico" >

<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" />
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>

<Border x:Name="grid">
</Border>
</Window>

+ 12
- 1
BeDesignerSCADA/View/ChildEditWindow.xaml.cs Voir le fichier

@@ -51,10 +51,21 @@ namespace BeDesignerSCADA.View

if (Instance.IsOk)
{
Canvas grid =new Canvas();
Canvas grid = new Canvas();
List<FrameworkElement> children = new List<FrameworkElement>();
foreach (FrameworkElement item in (Instance.main.Child as MainCanvasPanel).cav.Children)
{
children.Add(item);
}

double gd = children==null || children.Count<=0?60: children.Max((FrameworkElement x) => Canvas.GetTop(x) + x.ActualHeight);
double wd = children == null || children.Count <= 0 ? 100 : children.Max((FrameworkElement x) => Canvas.GetLeft(x) + x.ActualWidth);
grid.Width = wd;
grid.Height = gd+5;
(Instance.main.Child as MainCanvasPanel).GetChildren()?.ForEach(child => {
grid.Children.Add(child);
});
return FrameworkElementToXml(grid);
}
else


+ 10
- 14
BeDesignerSCADA/View/PropertyBindingWindow.xaml Voir le fichier

@@ -20,22 +20,18 @@
</Grid.RowDefinitions>
<TextBlock FontSize="20" Margin="10,10,0,0">属性绑定器</TextBlock>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<Grid>
<TextBlock x:Name="ProperpName" FontSize="16" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center">
属性名称
</TextBlock>
</Grid>
<Grid Grid.Column="1">
<ComboBox x:Name="BindingName" Grid.Column="1" IsEditable="True" ></ComboBox>
</Grid>
<StackPanel>
<StackPanel Margin="10,0,0,10" Orientation="Horizontal">
<TextBlock Foreground="Green" FontSize="16" Text="当前设置属性名称为:" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock x:Name="ProperpName" Foreground="Red" FontSize="14" Text="属性名称" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
<ComboBox x:Name="BindingName" Margin="10,0,10,0" Height="24" Grid.Column="1" IsEditable="True" ></ComboBox>

</StackPanel>
</Grid>

<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Width="80" Height="30" Content="清除绑定" x:Name="ClearBtn" Click="ClearBtn_Click" Margin="0,0,10,0"/>
<StackPanel Grid.Row="2" Margin="0,0,16,10" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Width="120" Height="30" Content="解除所有绑定" x:Name="ClearBtn" Click="ClearBtn_Click" Margin="0,0,10,0"/>
<Button Width="80" Height="30" Content="取消" x:Name="CancelBtn" Click="CancelBtn_Click" IsCancel="True"/>
<Button Width="80" Height="30" Content="确认" x:Name="ConfirmBtn" Margin="8 0 4 0" Click="ConfirmBtn_Click"/>
</StackPanel>


+ 7
- 7
BeDesignerSCADA/ViewModel/MainViewModel.cs Voir le fichier

@@ -297,13 +297,13 @@ namespace BeDesignerSCADA.ViewModel
/// <param name="e"></param>
private void Executable_PropertyChange(object? sender,EventArgs e)
{
System.Windows.Controls.Control content = CanSelectedItem as System.Windows.Controls.Control;
System.Reflection.PropertyInfo info = content.GetType().GetProperty("GenerateData");
var propName = info?.GetValue(content,null);
PropeObject.GetType().GetProperty("数据结果").SetValue(PropeObject,propName);
DevNameList = new System.Collections.ObjectModel.ObservableCollection<string>();
DevValueList = new System.Collections.ObjectModel.ObservableCollection<string>();
Class_DataBus.GetInstance().Dic_DeviceData.Keys?.ToList().ForEach(key => { DevNameList.Add(key); });
//System.Windows.Controls.Control content = CanSelectedItem as System.Windows.Controls.Control;
//System.Reflection.PropertyInfo info = content.GetType().GetProperty("GenerateData");
//var propName = info?.GetValue(content,null);
//PropeObject.GetType().GetProperty("数据结果").SetValue(PropeObject,propName);
//DevNameList = new System.Collections.ObjectModel.ObservableCollection<string>();
//DevValueList = new System.Collections.ObjectModel.ObservableCollection<string>();
//Class_DataBus.GetInstance().Dic_DeviceData.Keys?.ToList().ForEach(key => { DevNameList.Add(key); });
}
/// <summary>
/// 修改属性后


Chargement…
Annuler
Enregistrer