taoye il y a 2 ans
Parent
révision
284ba7ced7
100 fichiers modifiés avec 5286 ajouts et 334 suppressions
  1. +38
    -0
      BPASmart.VariableManager/App.xaml
  2. +17
    -0
      BPASmart.VariableManager/App.xaml.cs
  3. +10
    -0
      BPASmart.VariableManager/AssemblyInfo.cs
  4. +51
    -0
      BPASmart.VariableManager/BPASmart.VariableManager.csproj
  5. +37
    -0
      BPASmart.VariableManager/Converter/AlarmTypeTextConvert.cs
  6. +31
    -0
      BPASmart.VariableManager/Converter/AnalogAlarmConvert.cs
  7. +31
    -0
      BPASmart.VariableManager/Converter/DiscreteAlarmConvert.cs
  8. +39
    -0
      BPASmart.VariableManager/Converter/IsEnableConvert.cs
  9. +34
    -0
      BPASmart.VariableManager/Converter/TextDisplayConvert.cs
  10. +15
    -0
      BPASmart.VariableManager/Enums/DisplayFormat.cs
  11. +29
    -0
      BPASmart.VariableManager/Enums/EAlarmType.cs
  12. +24
    -0
      BPASmart.VariableManager/Enums/EAlongTriggerType.cs
  13. +19
    -0
      BPASmart.VariableManager/Enums/EAnalogAlarmType.cs
  14. +22
    -0
      BPASmart.VariableManager/Enums/EDataType.cs
  15. +16
    -0
      BPASmart.VariableManager/Enums/EDeviceType.cs
  16. +39
    -0
      BPASmart.VariableManager/Enums/EOperatorType.cs
  17. +15
    -0
      BPASmart.VariableManager/Enums/EParity.cs
  18. +16
    -0
      BPASmart.VariableManager/Enums/ESiemensPlcType.cs
  19. +53
    -0
      BPASmart.VariableManager/Models/AlarmSet.cs
  20. +43
    -0
      BPASmart.VariableManager/Models/AnalogAlarmInfo.cs
  21. +56
    -0
      BPASmart.VariableManager/Models/AnalogAlarmModel.cs
  22. +44
    -0
      BPASmart.VariableManager/Models/CommunicationModel.cs
  23. +13
    -0
      BPASmart.VariableManager/Models/CommunicationPar.cs
  24. +52
    -0
      BPASmart.VariableManager/Models/CommunicationSet.cs
  25. +41
    -0
      BPASmart.VariableManager/Models/DelegationNotifi.cs
  26. +14
    -0
      BPASmart.VariableManager/Models/DeviceManagermentResult.cs
  27. +22
    -0
      BPASmart.VariableManager/Models/DeviceManagment.cs
  28. +42
    -0
      BPASmart.VariableManager/Models/DiscreteAlarmInfo.cs
  29. +26
    -0
      BPASmart.VariableManager/Models/DynamicMenu.cs
  30. +88
    -0
      BPASmart.VariableManager/Models/ModbusRtu.cs
  31. +33
    -0
      BPASmart.VariableManager/Models/ModbusTcp.cs
  32. +15
    -0
      BPASmart.VariableManager/Models/NoticeBase.cs
  33. +75
    -0
      BPASmart.VariableManager/Models/PropBindInfo.cs
  34. +62
    -0
      BPASmart.VariableManager/Models/Siemens.cs
  35. +44
    -0
      BPASmart.VariableManager/Models/VarMonitorPropInfo.cs
  36. +74
    -0
      BPASmart.VariableManager/Models/VariableInfo.cs
  37. BIN
     
  38. BIN
     
  39. BIN
     
  40. BIN
     
  41. BIN
     
  42. BIN
     
  43. BIN
     
  44. BIN
     
  45. BIN
     
  46. BIN
     
  47. BIN
     
  48. +104
    -0
      BPASmart.VariableManager/ViewModels/CommunicationSetViewModel.cs
  49. +69
    -0
      BPASmart.VariableManager/ViewModels/DeviceManagermentSetViewModel.cs
  50. +130
    -0
      BPASmart.VariableManager/ViewModels/MainViewModel.cs
  51. +116
    -0
      BPASmart.VariableManager/ViewModels/VariableConfig.cs
  52. +75
    -0
      BPASmart.VariableManager/ViewModels/VariableMonitorViewModel.cs
  53. +486
    -0
      BPASmart.VariableManager/Views/CommunicationSetView.xaml
  54. +28
    -0
      BPASmart.VariableManager/Views/CommunicationSetView.xaml.cs
  55. +196
    -0
      BPASmart.VariableManager/Views/DeviceManagermentSetView.xaml
  56. +63
    -0
      BPASmart.VariableManager/Views/DeviceManagermentSetView.xaml.cs
  57. +558
    -0
      BPASmart.VariableManager/Views/MainView.xaml
  58. +41
    -0
      BPASmart.VariableManager/Views/MainView.xaml.cs
  59. +451
    -0
      BPASmart.VariableManager/Views/VariableConfig.xaml
  60. +45
    -0
      BPASmart.VariableManager/Views/VariableConfig.xaml.cs
  61. +284
    -0
      BPASmart.VariableManager/Views/VariableMonitorView.xaml
  62. +28
    -0
      BPASmart.VariableManager/Views/VariableMonitorView.xaml.cs
  63. +2
    -1
      BPASmartClient.Business/Plugin/ConfigMgr.cs
  64. +6
    -2
      BPASmartClient.Compiler/BPASmartClient.Compiler.csproj
  65. +7
    -1
      BPASmartClient.Compiler/IExecutable.cs
  66. +2
    -0
      BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
  67. BIN
     
  68. +43
    -0
      BPASmartClient.CustomResource/Pages/Model/DataGridColumnAttribute.cs
  69. +12
    -0
      BPASmartClient.CustomResource/Pages/Model/DoNotAutoGenerateDataGridColumnAttribute.cs
  70. +84
    -0
      BPASmartClient.CustomResource/Pages/Model/ProductionDataHelper.cs
  71. +15
    -0
      BPASmartClient.CustomResource/Pages/Model/ReportBase.cs
  72. +53
    -0
      BPASmartClient.CustomResource/Pages/Model/ReportHelper.cs
  73. +79
    -0
      BPASmartClient.CustomResource/Pages/Model/ReportTestModel.cs
  74. +5
    -5
      BPASmartClient.CustomResource/Pages/View/AlarmView.xaml
  75. +51
    -49
      BPASmartClient.CustomResource/Pages/View/MainView.xaml
  76. +42
    -0
      BPASmartClient.CustomResource/Pages/View/ProductionDataView.xaml
  77. +28
    -0
      BPASmartClient.CustomResource/Pages/View/ProductionDataView.xaml.cs
  78. +47
    -0
      BPASmartClient.CustomResource/Pages/View/ReportView.xaml
  79. +28
    -0
      BPASmartClient.CustomResource/Pages/View/ReportView.xaml.cs
  80. +4
    -5
      BPASmartClient.CustomResource/Pages/View/RunLogView.xaml
  81. +9
    -9
      BPASmartClient.CustomResource/Pages/View/UserLogView.xaml
  82. +2
    -2
      BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs
  83. +19
    -0
      BPASmartClient.CustomResource/Pages/ViewModel/ProductionDataViewModel.cs
  84. +63
    -0
      BPASmartClient.CustomResource/Pages/ViewModel/ReportViewModel.cs
  85. +76
    -0
      BPASmartClient.CustomResource/UserControls/DataGridEx.cs
  86. +13
    -0
      BPASmartClient.Helper/DataRecord.cs
  87. +3
    -17
      BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs
  88. +130
    -117
      BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
  89. +9
    -4
      BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs
  90. +34
    -9
      BPASmartClient.JXJFoodSmallStation/App.xaml.cs
  91. +27
    -0
      BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj
  92. +31
    -0
      BPASmartClient.JXJFoodSmallStation/Model/Converter/DataTableRedundantConverter.cs
  93. +68
    -0
      BPASmartClient.JXJFoodSmallStation/Model/Converter/RunStatusConvert.cs
  94. +135
    -46
      BPASmartClient.JXJFoodSmallStation/Model/DeviceInquire.cs
  95. +6
    -5
      BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
  96. +48
    -0
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/AlarmInfo.cs
  97. +57
    -61
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs
  98. +4
    -1
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceCurrentStatus.cs
  99. +15
    -0
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs
  100. +75
    -0
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceParModel.cs

+ 38
- 0
BPASmart.VariableManager/App.xaml Voir le fichier

@@ -0,0 +1,38 @@
<Application
x:Class="BPASmart.VariableManager.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:BPASmart.VariableManager"
StartupUri="../Views/MainView.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>

<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecCheckBox.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecTitleBarButton.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/GlobalStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecComboBox.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecIcoButtonStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecToggleButton.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/BeveledRadioButtonStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/DatePickeerDictionary.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecButtonStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/TextBoxStyle.xaml" />

<!--<ResourceDictionary>
<con:ColorConverter x:Key="ColorConverter" />
<con:TextConverter x:Key="TextConverter" />
<con:VisibleTypeConverter x:Key="VisibleTypeConverter" />
<con:StatusConverter x:Key="StatusConverter" />
<con:StringToIconConverter x:Key="StringToIconConverter" />
</ResourceDictionary>-->

<!--<ResourceDictionary>
<ImageBrush x:Key="hbl" ImageSource="/BPASmartClient.CustomResource;component/Image/HBL.png" />
<ImageBrush x:Key="dbxt" ImageSource="/BPASmartClient.CustomResource;component/Image/顶部线条.png" />
</ResourceDictionary>-->

</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

+ 17
- 0
BPASmart.VariableManager/App.xaml.cs Voir le fichier

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace BPASmart.VariableManager
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

+ 10
- 0
BPASmart.VariableManager/AssemblyInfo.cs Voir le fichier

@@ -0,0 +1,10 @@
using System.Windows;

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

+ 51
- 0
BPASmart.VariableManager/BPASmart.VariableManager.csproj Voir le fichier

@@ -0,0 +1,51 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>

<ItemGroup>
<None Remove="Resources\Fonts\iconfont.ttf" />
<None Remove="Resources\Images\HBL.png" />
<None Remove="Resources\Images\leftback.png" />
<None Remove="Resources\Images\leftImage.png" />
<None Remove="Resources\Images\leftImageSub.png" />
<None Remove="Resources\Images\topImage.png" />
<None Remove="Resources\Images\WindowImages.png" />
<None Remove="Resources\Images\激光线条.png" />
<None Remove="Resources\Images\边框1.png" />
<None Remove="Resources\Images\边角.png" />
<None Remove="Resources\Images\阴影边框.png" />
</ItemGroup>

<ItemGroup>
<Folder Include="Servers\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />
<PackageReference Include="System.IO.Ports" Version="6.0.0" />
</ItemGroup>

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

<ItemGroup>
<Resource Include="Resources\Fonts\iconfont.ttf" />
<Resource Include="Resources\Images\HBL.png" />
<Resource Include="Resources\Images\leftback.png" />
<Resource Include="Resources\Images\leftImage.png" />
<Resource Include="Resources\Images\leftImageSub.png" />
<Resource Include="Resources\Images\topImage.png" />
<Resource Include="Resources\Images\WindowImages.png" />
<Resource Include="Resources\Images\激光线条.png" />
<Resource Include="Resources\Images\边框1.png" />
<Resource Include="Resources\Images\边角.png" />
<Resource Include="Resources\Images\阴影边框.png" />
</ItemGroup>

</Project>

+ 37
- 0
BPASmart.VariableManager/Converter/AlarmTypeTextConvert.cs Voir le fichier

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using BPASmart.VariableManager.Enums;
namespace BPASmart.VariableManager.Converter
{
/// <summary>
/// 报警类型文本转换
/// </summary>
public class AlarmTypeTextConvert : IValueConverter
{
//当值从绑定源传播给绑定目标时,调用方法Convert,绑定源是控件的数据,绑定目标是后台值
//界面传递给后台数据
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null)
{
if (value.ToString() == "Bool")
return EAlarmType.离散量报警.ToString();
else
return EAlarmType.模拟量报警.ToString();
}
return EAlarmType.无.ToString();
}

//当值从绑定目标传播给绑定源时,调用此方法ConvertBack
//从后台数据传递给界面
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value.ToString();
}
}
}

+ 31
- 0
BPASmart.VariableManager/Converter/AnalogAlarmConvert.cs Voir le fichier

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace BPASmart.VariableManager.Converter
{
/// <summary>
/// 模拟量报警显示转换
/// </summary>
public class AnalogAlarmConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null)
{
return value.ToString() != "Bool" ? Visibility.Visible : Visibility.Collapsed;
}
return Visibility.Visible;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

+ 31
- 0
BPASmart.VariableManager/Converter/DiscreteAlarmConvert.cs Voir le fichier

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace BPASmart.VariableManager.Converter
{
/// <summary>
/// 离散量报警显示转换
/// </summary>
public class DiscreteAlarmConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null)
{
return value.ToString() == "Bool" ? Visibility.Visible : Visibility.Collapsed;
}
return Visibility.Visible;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

+ 39
- 0
BPASmart.VariableManager/Converter/IsEnableConvert.cs Voir le fichier

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

namespace BPASmart.VariableManager.Converter
{
public class IsEnableConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool returnValue = false;
if (value != null)
{
switch (value.ToString())
{
case "无":
returnValue = false;
break;
case "离散量报警":
case "模拟量报警":
returnValue = true;
break;
default:
break;
}
}
return returnValue;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

+ 34
- 0
BPASmart.VariableManager/Converter/TextDisplayConvert.cs Voir le fichier

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace BPASmart.VariableManager.Converter
{
public class TextDisplayConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null && bool.TryParse(value.ToString(), out bool result))
{
if (result)
{
return "取消报警";
}
else
{
return "启用报警";
}
}
return "启用报警";
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

+ 15
- 0
BPASmart.VariableManager/Enums/DisplayFormat.cs Voir le fichier

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

namespace BPASmart.VariableManager.Enums
{
internal enum DisplayFormat
{
二进制,
十进制,
十六进制,
}
}

+ 29
- 0
BPASmart.VariableManager/Enums/EAlarmType.cs Voir le fichier

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

namespace BPASmart.VariableManager.Enums
{
/// <summary>
/// 报警类型
/// </summary>
public enum EAlarmType
{
/// <summary>
/// 无报警
/// </summary>
无 = 1,

/// <summary>
/// 模拟量报警
/// </summary>
模拟量报警 = 2,

/// <summary>
/// 离散量报警
/// </summary>
离散量报警 = 3
}
}

+ 24
- 0
BPASmart.VariableManager/Enums/EAlongTriggerType.cs Voir le fichier

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

namespace BPASmart.VariableManager.Enums
{
/// <summary>
/// 沿触发类型枚举
/// </summary>
public enum EAlongTriggerType
{
/// <summary>
/// 下降沿触发
/// </summary>
下降沿 = 1,
/// <summary>
/// 上升沿触发
/// </summary>
上升沿 = 2
}

}

+ 19
- 0
BPASmart.VariableManager/Enums/EAnalogAlarmType.cs Voir le fichier

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

namespace BPASmart.VariableManager.Enums
{
/// <summary>
/// 模拟量报警类型
/// </summary>
public enum EAnalogAlarmType
{
高高报警 = 1,
高报警 = 2,
低报警 = 3,
低低报警 = 4,
}
}

+ 22
- 0
BPASmart.VariableManager/Enums/EDataType.cs Voir le fichier

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

namespace BPASmart.VariableManager.Enums
{
/// <summary>
/// 数据类型枚举
/// </summary>
public enum EDataType
{
Bool = 1,
Byte = 2,
Int = 3,
Word = 4,
Dint = 5,
Dword = 6,
Float = 7
}
}

+ 16
- 0
BPASmart.VariableManager/Enums/EDeviceType.cs Voir le fichier

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

namespace BPASmart.VariableManager.Enums
{
public enum EDeviceType
{
Siemens,
ModbusRtu,
ModbusTcp,
SerialPort,
}
}

+ 39
- 0
BPASmart.VariableManager/Enums/EOperatorType.cs Voir le fichier

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

namespace BPASmart.VariableManager.Enums
{
/// <summary>
/// 判断操作符枚举
/// </summary>
public enum EOperatorType
{
/// <summary>
/// 大于
/// </summary>
P_GT = 1,
/// <summary>
/// 大于等于
/// </summary>
P_GE = 2,
/// <summary>
/// 等于
/// </summary>
P_EQ = 3,
/// <summary>
/// 不等于
/// </summary>
P_NE = 4,
/// <summary>
/// 小于
/// </summary>
P_LT = 5,
/// <summary>
/// 小于等于
/// </summary>
P_LE = 6
}
}

+ 15
- 0
BPASmart.VariableManager/Enums/EParity.cs Voir le fichier

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

namespace BPASmart.VariableManager.Enums
{
public enum EParity
{
无,
奇校验,
偶校验
}
}

+ 16
- 0
BPASmart.VariableManager/Enums/ESiemensPlcType.cs Voir le fichier

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

namespace BPASmart.VariableManager.Enums
{
public enum ESiemensPlcType
{
S1200,
S1500,
S300_400,
S200_Smart
}
}

+ 53
- 0
BPASmart.VariableManager/Models/AlarmSet.cs Voir le fichier

@@ -0,0 +1,53 @@
using BPASmart.VariableManager.Enums;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmart.VariableManager.Models
{
[Table(nameof(AlarmSet))]
public class AlarmSet
{
public AlarmSet()
{
AnalogAlarmModels.Clear();
foreach (var item in Enum.GetNames(typeof(EAnalogAlarmType)))
{
AnalogAlarmModels.Add(new AnalogAlarmModel()
{
AlarmTag = item,
SortTag = (EAnalogAlarmType)Enum.Parse(typeof(EAnalogAlarmType), item)
});
}
}

[Key]
public int Id { get; set; }

/// <summary>
/// 模拟量报警信息
/// </summary>
public ObservableCollection<AnalogAlarmModel> AnalogAlarmModels { get; set; } = new ObservableCollection<AnalogAlarmModel>();

/// <summary>
/// 离散量报警信息
/// </summary>
public DiscreteAlarmInfo DiscreteAlarmInfoSet { get; set; } = new DiscreteAlarmInfo();

/// <summary>
/// 设置外键
/// </summary>
[ForeignKey("VariableInfoId")]
public int VariableInfoId { get; set; }

/// <summary>
/// 设置导航属性
/// </summary>
public VariableInfo VariableInfo { get; set; }
}
}

+ 43
- 0
BPASmart.VariableManager/Models/AnalogAlarmInfo.cs Voir le fichier

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmart.VariableManager.Models
{
/// <summary>
/// 模拟量报警信息
/// </summary>
[Table(nameof(AnalogAlarmInfo))]
public class AnalogAlarmInfo
{
[Key]
public int Id { get; set; }

/// <summary>
/// 高高报警
/// </summary>
public AnalogAlarmModel Condition_HIHI_Value { get; set; } = new AnalogAlarmModel();
/// <summary>
/// 高报警
/// </summary>
public AnalogAlarmModel Condition_HI_Value { get; set; } = new AnalogAlarmModel();
/// <summary>
/// 低低报警
/// </summary>
public AnalogAlarmModel Condition_LOLO_Value { get; set; } = new AnalogAlarmModel();
/// <summary>
/// 低报警
/// </summary>
public AnalogAlarmModel Condition_LO_Value { get; set; } = new AnalogAlarmModel();

[ForeignKey("AlarmSetId")]
public int AlarmSetId { get; set; }

public AlarmSet AlarmSet { get; set; }

}
}

+ 56
- 0
BPASmart.VariableManager/Models/AnalogAlarmModel.cs Voir le fichier

@@ -0,0 +1,56 @@
using BPASmart.VariableManager.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmart.VariableManager.Models
{
/// <summary>
/// 模拟量报警模块
/// </summary>
public class AnalogAlarmModel
{
[Key]
public int Id { get; set; }

/// <summary>
/// 设定报警值
/// </summary>
public int AlarmValue { get; set; } = 0;

/// <summary>
/// 是否启用该报警
/// </summary>
public bool IsEnable { get; set; }

/// <summary>
/// 报警信息
/// </summary>
public string AlarmInfo { get; set; }

/// <summary>
/// 报警标签
/// </summary>
public string AlarmTag { get; set; }

/// <summary>
/// 排序标签
/// </summary>
public EAnalogAlarmType SortTag { get; set; }

/// <summary>
/// 设置外键
/// </summary>
[ForeignKey("AlarmSetId")]
public int AlarmSetId { get; set; }

/// <summary>
/// 设置导航属性
/// </summary>
public AlarmSet AlarmSet { get; set; }
}
}

+ 44
- 0
BPASmart.VariableManager/Models/CommunicationModel.cs Voir le fichier

@@ -0,0 +1,44 @@
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmart.VariableManager.Models
{
public class CommunicationModel : NoticeBase
{
public CommunicationModel()
{
RemoveCommand = new RelayCommand<object>((o) => { if (RemoveAction != null) RemoveAction(o); });
}

public Action<object> RemoveAction { get; set; }

public Siemens CommSiemens { get { return _mCommSiemens; } set { _mCommSiemens = value; OnPropertyChanged(); } }
private Siemens _mCommSiemens = new Siemens();

public ModbusTcp CommModbusTcp { get { return _mCommModbusTcp; } set { _mCommModbusTcp = value; OnPropertyChanged(); } }
private ModbusTcp _mCommModbusTcp = new ModbusTcp();

public ModbusRtu CommModbusRtu { get { return _mCommModbusRtu; } set { _mCommModbusRtu = value; OnPropertyChanged(); } }
private ModbusRtu _mCommModbusRtu = new ModbusRtu();

/// <summary>
/// 是否激活
/// </summary>
public bool IsActive { get { return _mIsActive; } set { _mIsActive = value; OnPropertyChanged(); } }
private bool _mIsActive;


/// <summary>
/// 新增设备名称
/// </summary>
public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } }
private string _mDeviceName;


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

+ 13
- 0
BPASmart.VariableManager/Models/CommunicationPar.cs Voir le fichier

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

namespace BPASmart.VariableManager.Models
{
internal class CommunicationPar
{
public List<CommunicationModel> communicationSets = new List<CommunicationModel>();
}
}

+ 52
- 0
BPASmart.VariableManager/Models/CommunicationSet.cs Voir le fichier

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;
using BPASmart.VariableManager.Enums;
using System.IO.Ports;
using Microsoft.Toolkit.Mvvm.Input;
using BPASmart.VariableManager.Models;

namespace BPASmart.VariableManager.Models
{
public class CommunicationSet : ObservableObject
{

public CommunicationSet()
{
RemoveCommand = new RelayCommand<object>((o) => { if (RemoveAction != null) RemoveAction(o); });
}

public Action<object> RemoveAction { get; set; }

public Siemens CommSiemens { get { return _mCommSiemens; } set { _mCommSiemens = value; OnPropertyChanged(); } }
private Siemens _mCommSiemens = new Siemens();

public ModbusTcp CommModbusTcp { get { return _mCommModbusTcp; } set { _mCommModbusTcp = value; OnPropertyChanged(); } }
private ModbusTcp _mCommModbusTcp = new ModbusTcp();

public ModbusRtu CommModbusRtu { get { return _mCommModbusRtu; } set { _mCommModbusRtu = value; OnPropertyChanged(); } }
private ModbusRtu _mCommModbusRtu = new ModbusRtu();

/// <summary>
/// 是否激活
/// </summary>
public bool IsActive { get { return _mIsActive; } set { _mIsActive = value; OnPropertyChanged(); } }
private bool _mIsActive;


/// <summary>
/// 新增设备名称
/// </summary>
public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } }
private string _mDeviceName;


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

}
}

+ 41
- 0
BPASmart.VariableManager/Models/DelegationNotifi.cs Voir le fichier

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

namespace BPASmart.VariableManager.Models
{
public class DelegationNotifi
{
private volatile static DelegationNotifi _Instance;
public static DelegationNotifi GetInstance => _Instance ?? (_Instance = new DelegationNotifi());
private DelegationNotifi() { }

/// <summary>
/// 新增设备时的数据验证
/// </summary>
public Func<DeviceManagermentResult, bool> AddDeviceVerify { get; set; }

/// <summary>
/// 取消按钮通知
/// </summary>
public Action<DeviceManagermentResult> Cancel { get; set; }

/// <summary>
/// 确认按钮通知
/// </summary>
public Action<DeviceManagermentResult> Confirm { get; set; }

/// <summary>
/// 变量保存通知
/// </summary>
public Action VariableSave { get; set; }

/// <summary>
/// 变量名更改通知
/// </summary>
public Action<int> VarNameChanged { get; set; }

}
}

+ 14
- 0
BPASmart.VariableManager/Models/DeviceManagermentResult.cs Voir le fichier

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

namespace BPASmart.VariableManager.Models
{
public class DeviceManagermentResult
{
public string DeviceType { get; set; }
public string DeviceName { get; set; }
}
}

+ 22
- 0
BPASmart.VariableManager/Models/DeviceManagment.cs Voir le fichier

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;

namespace BPASmart.VariableManager.Models
{
public class DeviceManagment : ObservableObject
{
public string Content { get { return _mContent; } set { _mContent = value; OnPropertyChanged(); } }
private string _mContent;

public string CommandParameter { get { return _mCommandParameter; } set { _mCommandParameter = value; OnPropertyChanged(); } }
private string _mCommandParameter;

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

}
}

+ 42
- 0
BPASmart.VariableManager/Models/DiscreteAlarmInfo.cs Voir le fichier

@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmart.VariableManager.Enums;

namespace BPASmart.VariableManager.Models
{
/// <summary>
/// 布尔量报警信息
/// </summary>
[Table(nameof(DiscreteAlarmInfo))]
public class DiscreteAlarmInfo
{
[Key]
public int Id { get; set; }

/// <summary>
/// 沿报警(上升沿,下降沿)
/// </summary>
public string TrigAlarm { get; set; }

/// <summary>
/// 报警信息
/// </summary>
public string AlarmInfo { get; set; }

/// <summary>
/// 设置外键
/// </summary>
[ForeignKey("AlarmSetId")]
public int AlarmSetId { get; set; }

/// <summary>
/// 设置导航属性
/// </summary>
public AlarmSet AlarmSet { get; set; }
}
}

+ 26
- 0
BPASmart.VariableManager/Models/DynamicMenu.cs Voir le fichier

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

namespace BPASmart.VariableManager.Models
{
public class DynamicMenu
{
/// <summary>
/// 通讯设备菜单管理
/// </summary>
public List<DeviceManagment> CommunDeviceManagments { get; set; } = new List<DeviceManagment>();

/// <summary>
/// 变量菜单管理
/// </summary>
public List<DeviceManagment> VariableManagments { get; set; } = new List<DeviceManagment>();

/// <summary>
/// 变量监控菜单管理
/// </summary>
public List<DeviceManagment> VariableMonitors { get; set; } = new List<DeviceManagment>();
}
}

+ 88
- 0
BPASmart.VariableManager/Models/ModbusRtu.cs Voir le fichier

@@ -0,0 +1,88 @@
using BPASmart.VariableManager.Enums;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace BPASmart.VariableManager.Models
{
public class ModbusRtu
{
public ModbusRtu()
{
Init();
}

/// <summary>
/// 显示/隐藏设置
/// </summary>
public Visibility ModbusRtuVisible { get; set; } = Visibility.Collapsed;

/// <summary>
/// 串口端口
/// </summary>
public string ComSerialPort { get; set; }

/// <summary>
/// 波特率,110,300--115200(从300开始乘以2,直到结果等于115200)
/// </summary>
public string BaudRate { get; set; } = "9600";

/// <summary>
/// 数据位,默认为 8
/// </summary>
public int DataBit { get; set; } = 8;

/// <summary>
/// 停止位,默认为 1
/// </summary>
public int StopBit { get; set; } = 1;

/// <summary>
/// 站号,默认为 1
/// </summary>
public int StationNo { get; set; } = 1;

/// <summary>
/// 奇偶校验,无,奇校验,偶校验
/// </summary>
public string Parity { get; set; }


public ObservableCollection<string> Ports { get; set; } = new ObservableCollection<string>();

public ObservableCollection<string> BaudRates { get; set; } = new ObservableCollection<string>();

public ObservableCollection<string> Paritys { get; set; } = new ObservableCollection<string>();

private void Init()
{
Ports.Clear();
foreach (var item in SerialPort.GetPortNames())
{
Ports.Add(item);
}


BaudRates.Clear();
BaudRates.Add("110");
int initValue = 300;
for (int i = 0; i < 17; i++)
{
BaudRates.Add(initValue.ToString());
initValue *= 2;
}


Paritys.Clear();
foreach (var item in Enum.GetNames(typeof(EParity)))
{
Paritys.Add(item);
}
}
}
}

+ 33
- 0
BPASmart.VariableManager/Models/ModbusTcp.cs Voir le fichier

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

namespace BPASmart.VariableManager.Models
{
public class ModbusTcp
{
/// <summary>
/// 显示/隐藏设置
/// </summary>
public Visibility ModbusTcpVisible { get; set; } = Visibility.Collapsed;

/// <summary>
/// IP地址
/// </summary>
public string IP { get; set; } = "192.168.0.1";

/// <summary>
/// 端口号,默认 502
/// </summary>
public int PortNum { get; set; } = 502;

/// <summary>
/// 站号,默认为 1
/// </summary>
public int StationNo { get; set; } = 1;

}
}

+ 15
- 0
BPASmart.VariableManager/Models/NoticeBase.cs Voir le fichier

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System.Collections.ObjectModel;

namespace BPASmart.VariableManager
{
public class NoticeBase : ObservableObject
{
}
}

+ 75
- 0
BPASmart.VariableManager/Models/PropBindInfo.cs Voir le fichier

@@ -0,0 +1,75 @@
using BPASmart.VariableManager.Enums;
using Microsoft.Toolkit.Mvvm.Input;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmart.VariableManager.Models
{
/// <summary>
/// 属性绑定信息
/// </summary>
public class PropBindInfo : VariableInfo
{
public PropBindInfo()
{
ComboBoxItemInit();
CancelCommand = new RelayCommand(() => { IsOpen = false; });
ConfirmCommand = new RelayCommand(() => { IsOpen = false; });
}

/// <summary>
/// 数据类型下拉列表
/// </summary>
public ObservableCollection<string> dataType { get; set; } = new ObservableCollection<string>();

/// <summary>
/// 报警类型下拉列表
/// </summary>
public ObservableCollection<string> alarmType { get; set; } = new ObservableCollection<string>();

/// <summary>
/// 报警设置窗离散量报警类型
/// </summary>
public ObservableCollection<string> PopupDiscreteAlarmType { get; set; } = new ObservableCollection<string>();

/// <summary>
/// 是否显示报警设置框
/// </summary>
public bool IsOpen { get { return _mIsOpen; } set { _mIsOpen = value; OnPropertyChanged(); } }
private bool _mIsOpen;

/// <summary>
/// 报警设置框取消操作
/// </summary>
public RelayCommand CancelCommand { get; set; }

/// <summary>
/// 报警设置框确认按钮
/// </summary>
public RelayCommand ConfirmCommand { get; set; }


/// <summary>
/// 下拉列表初始化
/// </summary>
private void ComboBoxItemInit()
{
dataType.Clear();
alarmType.Clear();
PopupDiscreteAlarmType.Clear();
string[] DataTypeNames = Enum.GetNames(typeof(EDataType));
foreach (var item in DataTypeNames) { dataType.Add(item); }

string[] AlarmTypeNames = Enum.GetNames(typeof(EAlarmType));
foreach (var item in AlarmTypeNames) { alarmType.Add(item); }

string[] PopupAlarmTypes = Enum.GetNames(typeof(EAlongTriggerType));
foreach (var item in PopupAlarmTypes) { PopupDiscreteAlarmType.Add(item); }
}
}
}

+ 62
- 0
BPASmart.VariableManager/Models/Siemens.cs Voir le fichier

@@ -0,0 +1,62 @@
using BPASmart.VariableManager.Enums;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace BPASmart.VariableManager.Models
{
public class Siemens
{
public Siemens()
{
Init();
}

/// <summary>
/// 显示/隐藏设置
/// </summary>
public Visibility SiemensVisible { get; set; } = Visibility.Collapsed;

/// <summary>
/// IP地址
/// </summary>
public string IP { get; set; } = "192.168.0.1";

/// <summary>
/// 插槽号
/// </summary>
public int Slot { get; set; } = 0;

/// <summary>
/// 机架号
/// </summary>
public int Rack { get; set; } = 0;

/// <summary>
/// 端口号,默认 102
/// </summary>
public int PortNum { get; set; } = 102;

/// <summary>
/// PLC 类型
/// </summary>
public string PlcType { get; set; }

public ObservableCollection<string> PlcTypes { get; set; } = new ObservableCollection<string>();

private void Init()
{
PlcTypes.Clear();
foreach (var item in Enum.GetNames(typeof(ESiemensPlcType)))
{
PlcTypes.Add(item.Substring(1));
}
}


}
}

+ 44
- 0
BPASmart.VariableManager/Models/VarMonitorPropInfo.cs Voir le fichier

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmart.VariableManager.Enums;
using Microsoft.Toolkit.Mvvm.ComponentModel;


namespace BPASmart.VariableManager.Models
{
internal class VarMonitorPropInfo : VariableInfo
{
public VarMonitorPropInfo()
{
Init();
}

/// <summary>
/// 数据显示格式
/// </summary>
public string DataDisplayFormat { get { return _mDataDisplayFormat; } set { _mDataDisplayFormat = value; OnPropertyChanged(); } }
private string _mDataDisplayFormat;

/// <summary>
/// 修改值
/// </summary>
public string ModifyValue { get { return _mModifyValue; } set { _mModifyValue = value; OnPropertyChanged(); } }
private string _mModifyValue;

public ObservableCollection<string> DisplayFormat { get; set; } = new ObservableCollection<string>();

private void Init()
{
DisplayFormat.Clear();
foreach (var item in Enum.GetNames(typeof(DisplayFormat)))
{
DisplayFormat.Add(item);
}
}

}
}

+ 74
- 0
BPASmart.VariableManager/Models/VariableInfo.cs Voir le fichier

@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmart.VariableManager.Models;
using BPASmart.VariableManager.Enums;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Newtonsoft.Json;

namespace BPASmart.VariableManager.Models
{
/// <summary>
/// 变量信息
/// </summary>
[Table(nameof(VariableInfo))]
public class VariableInfo : ObservableObject
{

[Key]
public int ID { get { return _mID; } set { _mID = value; OnPropertyChanged(); } }
private int _mID;

/// <summary>
/// 变量名
/// </summary>
public string VarName
{
get { return _mVarName; }
set
{
_mVarName = value;
OnPropertyChanged();
if (DelegationNotifi.GetInstance.VarNameChanged != null)
DelegationNotifi.GetInstance.VarNameChanged(_mID);
}
}
private string _mVarName;

/// <summary>
/// 地址
/// </summary>
public string Address { get { return _mAddress; } set { _mAddress = value; OnPropertyChanged(); } }
private string _mAddress;

/// <summary>
/// 数据类型
/// </summary>
public string DataType { get { return _mDataType; } set { _mDataType = value; OnPropertyChanged(); } }
private string _mDataType;

/// <summary>
/// 是否启用报警
/// </summary>
public bool IsEnableAlarm { get { return _mIsEnableAlarm; } set { _mIsEnableAlarm = value; OnPropertyChanged(); } }
private bool _mIsEnableAlarm;

/// <summary>
/// 当前值
/// </summary>
public string CurrentValue { get { return _mCurrentValue; } set { _mCurrentValue = value; OnPropertyChanged(); } }
private string _mCurrentValue;

/// <summary>
/// 报警设置信息
/// </summary>
public AlarmSet AlarmSetProp { get { return _mAlarmSetProp; } set { _mAlarmSetProp = value; OnPropertyChanged(); } }
private AlarmSet _mAlarmSetProp = new AlarmSet();


}
}












+ 104
- 0
BPASmart.VariableManager/ViewModels/CommunicationSetViewModel.cs Voir le fichier

@@ -0,0 +1,104 @@
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 Microsoft.Toolkit.Mvvm.Input;
using BPASmart.VariableManager.Views;
using System.Windows;
using BPASmartClient.Helper;
using BPASmart.VariableManager.Models;
using BPASmart.VariableManager.Enums;

namespace BPASmart.VariableManager.ViewModels
{
public class CommunicationSetViewModel : ObservableObject
{
public CommunicationSetViewModel()
{
NewConnectCommand = new RelayCommand(() => { NewConnect(); });
SaveConnectSetCommand = new RelayCommand(() =>
{
Json<CommunicationPar>.Data.communicationSets.Clear();
foreach (var item in communicationSets)
{
item.RemoveAction = null;
Json<CommunicationPar>.Data.communicationSets.Add(item);
}
Json<CommunicationPar>.Save();
});

Json<CommunicationPar>.Read();
foreach (var item in Json<CommunicationPar>.Data.communicationSets)
{
item.RemoveAction = RemoveDevice;
communicationSets.Add(item);
}

DelegationNotifi.GetInstance.AddDeviceVerify = new Func<DeviceManagermentResult, bool>((p) =>
{
return communicationSets.FirstOrDefault(s => s.DeviceName == p.DeviceName) == null;
});
}

public ObservableCollection<CommunicationModel> communicationSets { get; set; } = new ObservableCollection<CommunicationModel>();

public RelayCommand NewConnectCommand { get; set; }

public RelayCommand SaveConnectSetCommand { get; set; }

/// <summary>
/// 创建新连接
/// </summary>
private void NewConnect()
{
DeviceManagermentSetView deviceManagermentSetView = new DeviceManagermentSetView();
var result = deviceManagermentSetView.ShowDialog();
var ResultTag = (DeviceManagermentResult)deviceManagermentSetView.Tag;
if (ResultTag != null)
{
if ((bool)result)
{
var obj = communicationSets.FirstOrDefault(p => p.DeviceName == ResultTag.DeviceName);
if (obj == null)
{
CommunicationModel communicationObj = new CommunicationModel();
EDeviceType eDeviceType = (EDeviceType)Enum.Parse(typeof(EDeviceType), ResultTag.DeviceType);
switch (eDeviceType)
{
case EDeviceType.Siemens:
communicationObj.CommSiemens.SiemensVisible = Visibility.Visible;
break;
case EDeviceType.ModbusRtu:
communicationObj.CommModbusRtu.ModbusRtuVisible = Visibility.Visible;
break;
case EDeviceType.ModbusTcp:
communicationObj.CommModbusTcp.ModbusTcpVisible = Visibility.Visible;
break;
case EDeviceType.SerialPort:
break;
default:
break;
}
communicationObj.DeviceName = ResultTag.DeviceName;
communicationObj.RemoveAction = RemoveDevice;
communicationSets.Add(communicationObj);
}
}
}
deviceManagermentSetView = null;
}

private void RemoveDevice(object o)
{
var result = communicationSets.FirstOrDefault(p => p.DeviceName == o.ToString());
if (result != null)
{
communicationSets.Remove(result);
}
}

}
}

+ 69
- 0
BPASmart.VariableManager/ViewModels/DeviceManagermentSetViewModel.cs Voir le fichier

@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System.Collections.Concurrent;
using System.Collections.ObjectModel;
using Microsoft.Toolkit.Mvvm.Input;
using Microsoft.Toolkit.Mvvm.Messaging;
using System.Diagnostics;
using BPASmart.VariableManager.Models;
using BPASmart.VariableManager.Enums;

namespace BPASmart.VariableManager.ViewModels
{
public class DeviceManagermentSetViewModel : ObservableObject
{
public DeviceManagermentSetViewModel()
{
Init();
CancelCommand = new RelayCommand(() =>
{
if (DelegationNotifi.GetInstance.Cancel != null) DelegationNotifi.GetInstance.Cancel(devcieManagerResult);
});
ConfirmCommand = new RelayCommand(() =>
{
if (DelegationNotifi.GetInstance.AddDeviceVerify != null)
{
if (DelegationNotifi.GetInstance.AddDeviceVerify(devcieManagerResult))
{
if (DelegationNotifi.GetInstance.Confirm != null) DelegationNotifi.GetInstance.Confirm(devcieManagerResult);
}
else
{
LogInfo = $"警告:设备【{devcieManagerResult.DeviceName}】已存在,请重试";
}
}
else
{
LogInfo = $"警告:设备添加失败!";
}

});
}

public ObservableCollection<string> DeviceType { get; set; } = new ObservableCollection<string>();

public RelayCommand CancelCommand { get; set; }
public RelayCommand ConfirmCommand { get; set; }

private void Init()
{
DeviceType.Clear();
foreach (var item in Enum.GetNames(typeof(EDeviceType))) { DeviceType.Add(item); }
}

public DeviceManagermentResult devcieManagerResult { get { return _mdevcieManagerResult; } set { _mdevcieManagerResult = value; OnPropertyChanged(); } }
private DeviceManagermentResult _mdevcieManagerResult = new DeviceManagermentResult();


public string LogInfo { get { return _mLogInfo; } set { _mLogInfo = value; OnPropertyChanged(); } }
private string _mLogInfo;




}
}

+ 130
- 0
BPASmart.VariableManager/ViewModels/MainViewModel.cs Voir le fichier

@@ -0,0 +1,130 @@
using BPASmart.VariableManager.Models;
using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Markup;

namespace BPASmart.VariableManager.ViewModels
{
public class MainViewModel : NoticeBase
{
public MainViewModel()
{
DoNavChanged("MessageLogView");
DataInit();
}

private void DataInit()
{
//获取本地通讯参数
Json<CommunicationPar>.Read();

//设置【设备管理菜单】
DeviceManagments.Add(new DeviceManagment()
{
CommandParameter = "CommunicationSetView",
Content = "设备管理",
NavChangedCommand = new RelayCommand<object>(DoNavChanged)
});

//设置【变量管理菜单】
foreach (var item in Json<CommunicationPar>.Data.communicationSets)
{
string CommandParameter = string.Empty;

VariableManagments.Add(new DeviceManagment()
{
CommandParameter = "VariableConfig",
Content = item.DeviceName,
NavChangedCommand = new RelayCommand<object>(DoNavChanged)
});
}

//设置【变量监控菜单】
foreach (var item in Json<CommunicationPar>.Data.communicationSets)
{
VariableMonitors.Add(new DeviceManagment()
{
CommandParameter = "VariableMonitorView",
Content = item.DeviceName,
NavChangedCommand = new RelayCommand<object>(DoNavChanged)
});
}

//设置【报警/消息日志菜单】
MessageAlarmLog.Add(new DeviceManagment()
{
CommandParameter = "MessageLogView",
Content = "消息日志",
NavChangedCommand = new RelayCommand<object>(DoNavChanged)
});
MessageAlarmLog.Add(new DeviceManagment()
{
CommandParameter = "AlarmRecordView",
Content = "报警记录",
NavChangedCommand = new RelayCommand<object>(DoNavChanged)
});

}

/// <summary>
/// 设备管理菜单
/// </summary>
public ObservableCollection<DeviceManagment> DeviceManagments { get; set; } = new ObservableCollection<DeviceManagment>();

/// <summary>
/// 变量管理菜单
/// </summary>
public ObservableCollection<DeviceManagment> VariableManagments { get; set; } = new ObservableCollection<DeviceManagment>();

/// <summary>
/// 变量监控
/// </summary>
public ObservableCollection<DeviceManagment> VariableMonitors { get; set; } = new ObservableCollection<DeviceManagment>();

/// <summary>
/// 消息报警日志
/// </summary>
public ObservableCollection<DeviceManagment> MessageAlarmLog { get; set; } = new ObservableCollection<DeviceManagment>();

#region 导航栏界面切换
private void DoNavChanged(object obj)
{
Type type = Type.GetType($"BPASmart.VariableManager.Views.{obj.ToString()}");
if (type != null)
{
ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes);
MainContent = (FrameworkElement)cti.Invoke(null);
}

}
#endregion

#region 页面切换属性
private FrameworkElement mainContent;

public FrameworkElement MainContent
{
get { return mainContent; }
set { mainContent = value; OnPropertyChanged(); }
}
#endregion

#region 界面名称显示属性
private string _WinNameDisplay;

public string WinNameDisplay
{
get { return _WinNameDisplay; }
set { _WinNameDisplay = value; OnPropertyChanged(); }
}
#endregion
}
}

+ 116
- 0
BPASmart.VariableManager/ViewModels/VariableConfig.cs Voir le fichier

@@ -0,0 +1,116 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmart.VariableManager.Enums;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using BPASmart.VariableManager.Models;
using System.Diagnostics;
using Microsoft.EntityFrameworkCore;

namespace BPASmart.VariableManager.ViewModels
{
internal class VariableConfig : ObservableObject
{
public VariableConfig()
{
DelegationNotifi.GetInstance.VariableSave = new Action(() => { SaveDataAsync(); });

DelegationNotifi.GetInstance.VarNameChanged = new Action<int>((p) =>
{
if ((p - 1) >= 0)
{
if (varialeInfos?.Count >= p)
{
if (varialeInfos.ElementAt(p - 1).VarName != null)
{
if (varialeInfos.ElementAt(p - 1).VarName.Length > 0)
{
if (varialeInfos.Count == p) AddRow();
}
}
}
}
});
GetLocalDataAsync();
}

/// <summary>
/// 异步获取本地数据
/// </summary>
private Task<bool> GetLocalDataAsync()
{
//SqlHelper<VariableInfo>.GetInstance.Database.EnsureCreated();
////多表查询
//var DataList = SqlHelper<VariableInfo>.GetInstance.DbObj.ToList();
//App.Current.Dispatcher.Invoke(new Action(() => { varialeInfos.Clear(); }));
//foreach (var item in DataList)
//{
// PropBindInfo propBindInfo = new PropBindInfo();
// propBindInfo.ID = item.ID;
// propBindInfo.VarName = item.VarName;
// propBindInfo.Address = item.Address;
// propBindInfo.DataType = item.DataType;
// propBindInfo.IsEnableAlarm = item.IsEnableAlarm;
// propBindInfo.CurrentValue = item.CurrentValue;
// var result = item.AlarmSetProp.AnalogAlarmModels.Where(p => p.AlarmSetId == item.ID).ToList();
// result = result?.OrderBy(p => p.SortTag).ToList();
// propBindInfo.AlarmSetProp.AnalogAlarmModels.Clear();
// result?.ForEach(p => { propBindInfo.AlarmSetProp.AnalogAlarmModels.Add(p); });
// propBindInfo.AlarmSetProp.DiscreteAlarmInfoSet = item.AlarmSetProp.DiscreteAlarmInfoSet;
// App.Current?.Dispatcher.Invoke(new Action(() => { varialeInfos.Add(propBindInfo); }));
//}
//if (varialeInfos.Count <= 0) AddRow();
return Task.FromResult(true);
}

/// <summary>
/// 异步保存数据
/// </summary>
/// <returns></returns>
private Task<bool> SaveDataAsync()
{
//SqlHelper<VariableInfo>.GetInstance.DbObj.RemoveRange(SqlHelper<VariableInfo>.GetInstance.DbObj.ToArray());
//foreach (var item in varialeInfos)
//{
// SqlHelper<VariableInfo>.GetInstance.Add(new VariableInfo()
// {
// ID = item.ID,
// VarName = item.VarName,
// Address = item.Address,
// DataType = item.DataType,
// IsEnableAlarm = item.IsEnableAlarm,
// CurrentValue = item.CurrentValue,
// AlarmSetProp = item.AlarmSetProp,

// });
//}
//SqlHelper<VariableInfo>.GetInstance.Save();
return Task.FromResult(true);
}

/// <summary>
/// 添加行
/// </summary>
private void AddRow()
{
App.Current.Dispatcher.Invoke(new Action(() =>
{
varialeInfos.Add(new PropBindInfo()
{
ID = varialeInfos.Count + 1,
});
}));

}

/// <summary>
/// 变量信息
/// </summary>
public ObservableCollection<PropBindInfo> varialeInfos { get; set; } = new ObservableCollection<PropBindInfo>();

}
}

+ 75
- 0
BPASmart.VariableManager/ViewModels/VariableMonitorViewModel.cs Voir le fichier

@@ -0,0 +1,75 @@
using BPASmart.VariableManager.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmart.VariableManager.ViewModels
{
internal class VariableMonitorViewModel : ObservableObject
{
public VariableMonitorViewModel()
{
GetLocalDataAsync();
}

/// <summary>
/// 异步获取本地数据
/// </summary>
private Task<bool> GetLocalDataAsync()
{
//var DataList = SqlHelper<VariableInfo>.GetInstance.DbObj.ToList();
//App.Current.Dispatcher.Invoke(new Action(() => { varialeInfos.Clear(); }));
//foreach (var item in DataList)
//{
// if (item.VarName?.Length > 0)
// {
// VarMonitorPropInfo varMonitorPropInfo = new VarMonitorPropInfo();
// varMonitorPropInfo.ID = item.ID;
// varMonitorPropInfo.VarName = item.VarName;
// varMonitorPropInfo.Address = item.Address;
// varMonitorPropInfo.DataType = item.DataType;
// varMonitorPropInfo.DataDisplayFormat = TypeEnum.DisplayFormat.十进制.ToString();
// App.Current?.Dispatcher.Invoke(new Action(() => { varialeInfos.Add(varMonitorPropInfo); }));
// }
//}
return Task.FromResult(true);
}

/// <summary>
/// 异步保存数据
/// </summary>
/// <returns></returns>
private Task<bool> SaveDataAsync()
{
//SqlHelper<VariableInfo>.GetInstance.DbObj.RemoveRange(SqlHelper<VariableInfo>.GetInstance.DbObj.ToArray());
//foreach (var item in varialeInfos)
//{
// SqlHelper<VariableInfo>.GetInstance.Add(new VariableInfo()
// {
// ID = item.ID,
// VarName = item.VarName,
// Address = item.Address,
// DataType = item.DataType,
// IsEnableAlarm = item.IsEnableAlarm,
// CurrentValue = item.CurrentValue,
// AlarmSetProp = item.AlarmSetProp,

// });
//}
//SqlHelper<VariableInfo>.GetInstance.Save();
return Task.FromResult(true);
}

/// <summary>
/// 变量信息
/// </summary>
public ObservableCollection<VarMonitorPropInfo> varialeInfos { get; set; } = new ObservableCollection<VarMonitorPropInfo>();

}
}


+ 486
- 0
BPASmart.VariableManager/Views/CommunicationSetView.xaml Voir le fichier

@@ -0,0 +1,486 @@
<UserControl
x:Class="BPASmart.VariableManager.Views.CommunicationSetView"
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:BPASmart.VariableManager.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmart.VariableManager.ViewModels"
d:DesignHeight="450"
d:DesignWidth="1000"
mc:Ignorable="d">

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

<UserControl.Resources>
<ResourceDictionary Source="../Resource/Style/BasicStyle.xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<Style x:Key="TextBlockStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="楷体" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>

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

<Style x:Key="buttonStyle" TargetType="Button">
<Setter Property="FontFamily" Value="楷体" />
<Setter Property="FontSize" Value="20" />
<Setter Property="Foreground" Value="#FFDE7889" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid x:Name="gr">
<ContentControl
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
Foreground="{TemplateBinding Foreground}" />
<!--<pry:Quadrilateral
x:Name="poly"
Stroke="#FFDE7889"
StrokeThickness="2" />-->
</Grid>
<!--<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
-->
<!--<Setter TargetName="poly" Property="FillColor" Value="#22DE7889" />-->
<!--
</Trigger>
</ControlTemplate.Triggers>-->
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

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

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

<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button
Width="140"
Margin="0,0,20,0"
Background="#FF19B7EC"
Command="{Binding NewConnectCommand}"
Content="新建连接"
FontFamily="楷体"
FontSize="18"
Template="{StaticResource NewButtonTemp}">
<Button.Foreground>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="#FFBB662A" />
<GradientStop Offset="1" Color="White" />
</LinearGradientBrush>
</Button.Foreground>
</Button>

<Button
Width="140"
Command="{Binding SaveConnectSetCommand}"
Content="保存"
FontFamily="楷体"
FontSize="18"
Template="{StaticResource SaveButtonTemp}">
<Button.Foreground>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="#FFBB662A" />
<GradientStop Offset="1" Color="White" />
</LinearGradientBrush>
</Button.Foreground>
</Button>
</StackPanel>

<ScrollViewer
Grid.Row="1"
Margin="0,10,0,0"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding communicationSets}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="0,0,0,30">
<Grid.RowDefinitions>
<RowDefinition Height="0.1*" />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<!--#region 标题显示及操作-->
<Grid Margin="0,0,0,20">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition Width="0.3*" />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<!--<pry:TitleTextBlock />-->

<TextBlock
Margin="5"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontFamily="楷体"
FontSize="20"
Foreground="Aqua"
Text="{Binding DeviceName}" />
</Grid>
<!--#endregion-->

<!--#region 西门子设备-->
<Grid Grid.Row="1" Visibility="{Binding CommSiemens.SiemensVisible}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition Width="0.5*" />
<ColumnDefinition Width="0.2*" />
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="20" />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock
Grid.Column="0"
Style="{StaticResource TextBlockStyle}"
Text="IP地址:" />
<TextBox
Grid.Column="1"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommSiemens.IP}" />

<TextBlock
Grid.Column="2"
Style="{StaticResource TextBlockStyle}"
Text="端口号:" />
<TextBox
Grid.Column="3"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommSiemens.PortNum}" />

<TextBlock
Grid.Column="4"
Style="{StaticResource TextBlockStyle}"
Text="PLC类型:" />
<ComboBox
Grid.Column="5"
Margin="0,0,20,0"
VerticalAlignment="Center"
BorderBrush="#FF23CACA"
BorderThickness="1"
FontFamily="楷体"
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
ItemsSource="{Binding CommSiemens.PlcTypes}"
SelectedIndex="0"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding CommSiemens.PlcType}" />

<Button
Grid.Column="7"
Command="{Binding RemoveCommand}"
CommandParameter="{Binding DeviceName}"
Content="删除"
FontFamily="楷体"
FontSize="20"
Foreground="#FFDE7889"
Template="{StaticResource ButtonTemplate}" />

<TextBlock
Grid.Row="2"
Style="{StaticResource TextBlockStyle}"
Text="机架号:" />
<TextBox
Grid.Row="2"
Grid.Column="1"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommSiemens.Rack}" />

<TextBlock
Grid.Row="2"
Grid.Column="2"
Style="{StaticResource TextBlockStyle}"
Text="插槽号:" />
<TextBox
Grid.Row="2"
Grid.Column="3"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommSiemens.Slot}" />

<CheckBox
Grid.Row="2"
Grid.Column="7"
Width="100"
Height="20"
Margin="10"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Background="#FF2AB2E7"
Content="IsActive"
FontSize="16"
Foreground="#ddd"
IsChecked="{Binding IsActive}"
Template="{StaticResource CbTemplate}" />
</Grid>
</Grid>
<!--#endregion-->

<!--#region Modbus Tcp 设备-->
<Grid Grid.Row="2" Visibility="{Binding CommModbusTcp.ModbusTcpVisible}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition Width="0.5*" />
<ColumnDefinition Width="0.2*" />
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="20" />
<RowDefinition />
</Grid.RowDefinitions>


<TextBlock
Grid.Column="0"
Style="{StaticResource TextBlockStyle}"
Text="IP地址:" />
<TextBox
Grid.Column="1"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommModbusTcp.IP}" />

<TextBlock
Grid.Column="2"
Style="{StaticResource TextBlockStyle}"
Text="端口号:" />
<TextBox
Grid.Column="3"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommModbusTcp.PortNum}" />

<TextBlock
Grid.Column="4"
Style="{StaticResource TextBlockStyle}"
Text="站号:" />
<TextBox
Grid.Column="5"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommModbusTcp.StationNo}" />

<Button
Grid.Column="7"
Command="{Binding RemoveCommand}"
CommandParameter="{Binding DeviceName}"
Content="删除"
FontFamily="楷体"
FontSize="20"
Foreground="#FFDE7889"
Template="{StaticResource ButtonTemplate}" />

<CheckBox
Grid.Row="2"
Grid.Column="7"
Width="100"
Height="20"
Margin="10"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Background="#FF2AB2E7"
Content="IsActive"
FontSize="16"
Foreground="#ddd"
IsChecked="{Binding IsActive}"
Template="{StaticResource CbTemplate}" />

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

<!--#region Modbus RTU 设备-->
<Grid Grid.Row="3" Visibility="{Binding CommModbusRtu.ModbusRtuVisible}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition Width="0.5*" />
<ColumnDefinition Width="0.2*" />
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="20" />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock Style="{StaticResource TextBlockStyle}" Text="端口号:" />
<ComboBox
Grid.Column="1"
Margin="0,0,20,0"
VerticalAlignment="Center"
BorderBrush="#FF23CACA"
BorderThickness="1"
FontFamily="楷体"
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
ItemsSource="{Binding CommModbusRtu.Ports}"
SelectedIndex="0"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding CommModbusRtu.ComSerialPort}" />

<TextBlock
Grid.Column="2"
Style="{StaticResource TextBlockStyle}"
Text="波特率:" />
<ComboBox
Grid.Column="3"
Margin="0,0,20,0"
VerticalAlignment="Center"
BorderBrush="#FF23CACA"
BorderThickness="1"
FontFamily="楷体"
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
ItemsSource="{Binding CommModbusRtu.BaudRates}"
SelectedIndex="0"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding CommModbusRtu.BaudRate}" />


<TextBlock
Grid.Column="4"
Style="{StaticResource TextBlockStyle}"
Text="奇偶:" />
<ComboBox
Grid.Column="5"
Margin="0,0,20,0"
VerticalAlignment="Center"
BorderBrush="#FF23CACA"
BorderThickness="1"
FontFamily="楷体"
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
ItemsSource="{Binding CommModbusRtu.Paritys}"
SelectedIndex="0"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding CommModbusRtu.Parity}" />

<TextBlock
Grid.Row="2"
Grid.Column="0"
Style="{StaticResource TextBlockStyle}"
Text="数据位:" />
<TextBox
Grid.Row="2"
Grid.Column="1"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommModbusRtu.DataBit}" />
<TextBlock
Grid.Row="2"
Grid.Column="2"
Style="{StaticResource TextBlockStyle}"
Text="停止位:" />
<TextBox
Grid.Row="2"
Grid.Column="3"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommModbusRtu.StopBit}" />

<TextBlock
Grid.Row="2"
Grid.Column="4"
Style="{StaticResource TextBlockStyle}"
Text="站号:" />
<TextBox
Grid.Row="2"
Grid.Column="5"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommModbusRtu.StationNo}" />

<Button
Grid.Column="7"
Command="{Binding RemoveCommand}"
CommandParameter="{Binding DeviceName}"
Content="删除"
FontFamily="楷体"
FontSize="20"
Foreground="#FFDE7889"
Template="{StaticResource ButtonTemplate}" />

<CheckBox
Grid.Row="2"
Grid.Column="7"
Width="100"
Height="20"
Margin="10"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Background="#FF2AB2E7"
Content="IsActive"
FontSize="16"
Foreground="#ddd"
IsChecked="{Binding IsActive}"
Template="{StaticResource CbTemplate}" />
</Grid>
</Grid>
<!--#endregion-->

</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

</ScrollViewer>
</Grid>
</UserControl>

+ 28
- 0
BPASmart.VariableManager/Views/CommunicationSetView.xaml.cs Voir le fichier

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

namespace BPASmart.VariableManager.Views
{
/// <summary>
/// CommunicationSetView.xaml 的交互逻辑
/// </summary>
public partial class CommunicationSetView : UserControl
{
public CommunicationSetView()
{
InitializeComponent();
}
}
}

+ 196
- 0
BPASmart.VariableManager/Views/DeviceManagermentSetView.xaml Voir le fichier

@@ -0,0 +1,196 @@
<Window
x:Class="BPASmart.VariableManager.Views.DeviceManagermentSetView"
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:BPASmart.VariableManager.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmart.VariableManager.ViewModels"
Title="DeviceManagermentSetView"
Width="400"
Height="275"
AllowsTransparency="True"
Background="{x:Null}"
Opacity="0.8"
Topmost="false"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
mc:Ignorable="d">

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

<Window.Resources>
<ResourceDictionary Source="../Resource/Style/BasicStyle.xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<Style x:Key="buttonStyle" TargetType="Button">
<Setter Property="FontFamily" Value="楷体" />
<Setter Property="Width" Value="100" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Foreground" Value="Aqua" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid x:Name="gr">
<ContentControl
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
Foreground="{TemplateBinding Foreground}" />
<Polygon
x:Name="poly"
Points="0 0,80 0,100 30,20 30"
Stroke="#FF34F7F7"
StrokeThickness="2" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="poly" Property="Fill" Value="#2234F7F7" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>

<Grid Background="#103153">
<Grid.RowDefinitions>
<RowDefinition Height="35" />
<RowDefinition />
</Grid.RowDefinitions>

<!--#region 标题栏设置-->
<Border
x:Name="MoveBorder"
Height="35"
VerticalAlignment="Top"
Background="#0C2349"
BorderBrush="#55ffffff"
BorderThickness="0,0,0,1">
<StackPanel Orientation="Horizontal">
<!--<Image Margin="15,5,0,5" Source="../Resource/Images/HBL.png" />-->
<TextBlock
Name="tbTitle"
Margin="10,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="18"
Foreground="White"
Text="设备管理" />
</StackPanel>
</Border>

<UniformGrid
Width="150"
Height="30"
HorizontalAlignment="Right"
Columns="3">
<Button
Name="ButMin"
Content="&#xe664;"
Style="{StaticResource TitleBarStyle}"
Visibility="Hidden" />
<Button
Name="ButMax"
Content="&#xe65d;"
Style="{StaticResource TitleBarStyle}"
Visibility="Hidden" />
<Button
Name="ButClose"
Content="&#xe639;"
FontSize="30"
Style="{StaticResource TitleBarStyle}" />
</UniformGrid>
<!--#endregion-->

<!--#region 内容显示区-->
<Grid Grid.Row="1" Margin="20">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<TextBlock
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontFamily="楷体"
FontSize="20"
Foreground="#FF34F7F7"
Text="请选择设备类型:" />
<ComboBox
Grid.Column="1"
VerticalAlignment="Center"
BorderBrush="#FF23CACA"
BorderThickness="1"
FontFamily="楷体"
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
ItemsSource="{Binding DeviceType}"
SelectedIndex="0"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding devcieManagerResult.DeviceType}" />

<TextBlock
Grid.Row="1"
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontFamily="楷体"
FontSize="20"
Foreground="#FF34F7F7"
Text="请输入设备名称:" />
<TextBox
Grid.Row="1"
Grid.Column="1"
Margin="0,10"
VerticalAlignment="Center"
Background="Transparent"
BorderBrush="#FF23CACA"
CaretBrush="Aqua"
FontFamily="楷体"
FontSize="21"
Foreground="#ff34f7f7"
Text="{Binding devcieManagerResult.DeviceName}" />

<TextBlock
Grid.Row="2"
Grid.ColumnSpan="2"
Margin="20,0,0,0"
VerticalAlignment="Center"
FontFamily="楷体"
FontSize="16"
Foreground="#FFE2415C"
Text="{Binding LogInfo}"
TextWrapping="Wrap" />

<Button
Grid.Row="3"
Margin="20,10"
Command="{Binding CancelCommand}"
Content="取消"
Style="{StaticResource buttonStyle}" />
<Button
Grid.Row="3"
Grid.Column="1"
Margin="20,10"
Command="{Binding ConfirmCommand}"
Content="确认"
Style="{StaticResource buttonStyle}" />

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

</Grid>
</Window>

+ 63
- 0
BPASmart.VariableManager/Views/DeviceManagermentSetView.xaml.cs Voir le fichier

@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
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;
using Microsoft.Toolkit.Mvvm.Messaging;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using BPASmart.VariableManager.Models;

namespace BPASmart.VariableManager.Views
{
/// <summary>
/// DeviceManagermentSetView.xaml 的交互逻辑
/// </summary>
public partial class DeviceManagermentSetView : Window
{
public DeviceManagermentSetView()
{
InitializeComponent();
this.MoveBorder.MouseLeftButtonDown += (o, e) => { this.DragMove(); };
this.ButMin.Click += (o, e) => { this.WindowState = WindowState.Minimized; };
this.ButMax.Click += (o, e) => { this.WindowState = this.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; };
this.ButClose.Click += (o, e) => { this.DialogResult = false; };
this.MaxWidth = SystemParameters.WorkArea.Width;
this.MaxHeight = SystemParameters.WorkArea.Height;

DelegationNotifi.GetInstance.Cancel = new Action<DeviceManagermentResult>((s) =>
{
this.Tag = s;
this.DialogResult = false;
DelegationNotifi.GetInstance.Cancel = null;
this.Close();
});

DelegationNotifi.GetInstance.Confirm = new Action<DeviceManagermentResult>((s) =>
{
this.Tag = s;
this.DialogResult = true;
DelegationNotifi.GetInstance.Cancel = null;
this.Close();
});

}


private void ThisDialogResult(DeviceManagermentResult s, bool result)
{
this.Tag = s;
this.DialogResult = result;
DelegationNotifi.GetInstance.Cancel = null;
this.Close();
}
}
}

+ 558
- 0
BPASmart.VariableManager/Views/MainView.xaml Voir le fichier

@@ -0,0 +1,558 @@
<Window
x:Class="BPASmart.VariableManager.Views.MainView"
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:BPASmart.VariableManager.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmart.VariableManager.ViewModels"
Title="MainView"
Width="1200"
Height="700"
AllowsTransparency="True"
Background="{x:Null}"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
mc:Ignorable="d">

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

<Window.Resources>


<!--#region 静态资源-->
<ImageBrush x:Key="leftImage" ImageSource="/Resources/Images/leftImage.png" />
<ImageBrush x:Key="leftImageSub" ImageSource="/Resources/Images/leftImageSub.png" />
<ImageBrush x:Key="topImage" ImageSource="/Resources/Images/topImage.png" />
<!--#endregion-->

<!--#region 标题栏按钮样式-->
<Style x:Key="TitleBarStyle" TargetType="Button">
<Setter Property="Foreground" Value="White" />
<Setter Property="FontSize" Value="24" />
<Setter Property="FontFamily" Value="/Resources/Fonts/#iconfont" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Name="TitleBarBr" Background="Transparent">
<ContentPresenter
Margin="{TemplateBinding Margin}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="TitleBarBr" Property="Background" Value="#22ffffff" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--#endregion-->

<!--#region 导航栏样式-->
<Style x:Key="NavButtonStyle" TargetType="{x:Type RadioButton}">
<Setter Property="Foreground" Value="White" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Border
x:Name="NvaBor"
Background="Transparent"
BorderBrush="#55ffffff"
BorderThickness="0,0,0,1.5">
<ContentControl
Margin="10,4"
HorizontalAlignment="Center"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Content="{TemplateBinding Content}"
FontSize="16" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="NvaBor" Property="Background" Value="#865eec" />
<Setter TargetName="NvaBor" Property="BorderThickness" Value="0,0,1.5,1.5" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked" Value="false" />
<Condition Property="IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
<MultiTrigger.Setters>
<Setter TargetName="NvaBor" Property="Background" Value="#22ffffff" />
</MultiTrigger.Setters>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--#endregion-->

<!--#region 下拉列表单选按钮样式-->
<Style x:Key="RadioMiniButtonStyle" TargetType="{x:Type RadioButton}">
<Setter Property="Margin" Value="5,10,1,5" />
<Setter Property="Width" Value="160" />
<Setter Property="Height" Value="30" />
<Setter Property="FontSize" Value="14" />
<Setter Property="FontFamily" Value="粗体" />
<Setter Property="Foreground" Value="#DDD" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Background" Value="#DDD" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Grid
x:Name="templateRoot"
Background="Transparent"
SnapsToDevicePixels="True">
<Border x:Name="border2" />
<ContentPresenter
x:Name="contentPresenter"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Focusable="False"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />

</Grid>
<ControlTemplate.Triggers>
<Trigger Property="HasContent" Value="True">
<Setter Property="FocusVisualStyle">
<Setter.Value>
<Style>
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle
Margin="14,0,0,0"
SnapsToDevicePixels="True"
Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
StrokeDashArray="1 2"
StrokeThickness="1" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="Padding" Value="4,-1,0,0" />
</Trigger>
<Trigger Property="IsChecked" Value="{x:Null}" />

<Trigger Property="IsChecked" Value="true">
<Setter Property="Foreground" Value="White" />
<Setter TargetName="border2" Property="Background" Value="{StaticResource ResourceKey=leftImageSub}">
<!--<Setter.Value>
<ImageBrush ImageSource="./images/back.png" />
</Setter.Value>-->
</Setter>
</Trigger>

<Trigger Property="IsChecked" Value="false">
<Setter TargetName="border2" Property="Background" Value="#101F3F" />
<Setter Property="Foreground" Value="#4B8EC4" />
</Trigger>

<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked" Value="false" />
<Condition Property="IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
<MultiTrigger.Setters>
<Setter TargetName="border2" Property="Background" Value="#55007acc" />
</MultiTrigger.Setters>
</MultiTrigger>

</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--#endregion-->

<!--#region 下拉列表样式-->
<Style x:Key="ToggleButtonStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Height" Value="80" />
<Setter Property="HorizontalContentAlignment" Value="Right" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Padding" Value="10,10" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid>
<Border
x:Name="border2"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Background="{TemplateBinding Background}">
<ContentPresenter
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
</Grid>

<ControlTemplate.Triggers>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" Value="#FFd2e7f4" />
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="border2" Property="Background" Value="{StaticResource ResourceKey=leftImage}" />
</Trigger>
<Trigger Property="IsChecked" Value="false">
<Setter TargetName="border2" Property="Background" Value="#191E36" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="White" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style x:Key="ExpanderStyle" TargetType="{x:Type Expander}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="1" />

<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Expander}">
<DockPanel>
<ToggleButton
x:Name="HeaderSite"
Height="60"
MinWidth="0"
MinHeight="0"
Margin="1"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
DockPanel.Dock="Top"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"
FontStretch="{TemplateBinding FontStretch}"
FontStyle="{TemplateBinding FontStyle}"
FontWeight="{TemplateBinding FontWeight}"
Foreground="{TemplateBinding Foreground}"
IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource ToggleButtonStyle}" />
<ContentPresenter
x:Name="ExpandSite"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
DockPanel.Dock="Left"
Focusable="false"
Visibility="Collapsed" />
</DockPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded" Value="true">
<Setter TargetName="ExpandSite" Property="Visibility" Value="Visible" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--#endregion-->
<Style x:Key="checkBoxStyle" TargetType="CheckBox">
<Setter Property="Foreground" Value="#a2c2e8" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="FocusVisualStyle">
<Setter.Value>
<Style>
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle
Margin="1"
SnapsToDevicePixels="True"
Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
StrokeDashArray="1 2"
StrokeThickness="1" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CheckBox}">
<StackPanel
Background="Transparent"
Orientation="Horizontal"
SnapsToDevicePixels="True">
<Grid>
<Image
Width="12"
Height="14"
Source="/BPASmartClient.CustomResource;component/Image/Cb_HalfChecked.png" />
<Image
x:Name="image1"
Width="12"
Height="14"
Source="/BPASmartClient.CustomResource;component/Image/Cb_HalfChecked.png" />
</Grid>
<ContentPresenter
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="HasContent" Value="True">
<Setter Property="FocusVisualStyle">
<Setter.Value>
<Style>
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle
Margin="14,0,0,0"
SnapsToDevicePixels="True"
Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
StrokeDashArray="1 2"
StrokeThickness="1" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="Padding" Value="4,0,0,0" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="image1" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/Cb_Checked.png" />
</Trigger>
<Trigger Property="IsChecked" Value="{x:Null}">
<Setter TargetName="image1" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/Cb_HalfChecked.png" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>

<Grid Background="#103153">

<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition />
</Grid.RowDefinitions>

<!--#region 标题栏设置-->
<Border
x:Name="MoveBorder"
Height="50"
VerticalAlignment="Top"
Background="#0C2349"
BorderBrush="#55ffffff"
BorderThickness="0,0,0,1">

<StackPanel Orientation="Horizontal">
<Image Margin="15,5,0,5" Source="/Resources/Images/HBL.png" />
<TextBlock
Name="tbTitle"
Margin="20,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="18"
Foreground="White"
Text="上位机监控系统" />
</StackPanel>


</Border>

<UniformGrid
Width="150"
Height="50"
HorizontalAlignment="Right"
Columns="3">
<Button
Name="ButMin"
Content="&#xe664;"
IsEnabled="False"
Style="{StaticResource TitleBarStyle}"
Visibility="Hidden" />
<Button
Name="ButMax"
Content="&#xe65d;"
FontSize="22"
IsEnabled="False"
Style="{StaticResource TitleBarStyle}"
Visibility="Hidden" />
<Button
Name="ButClose"
Content="&#xe679;"
Foreground="Red"
Style="{StaticResource TitleBarStyle}" />
</UniformGrid>
<!--#endregion-->

<!--#region 显示区设置-->

<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<!-- 侧边栏菜单设置 -->
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<Grid>
<Border BorderBrush="#121F40" BorderThickness="1">
<Border.Background>
<ImageBrush ImageSource="/Resources/Images/leftback.png" />
</Border.Background>
</Border>

<ScrollViewer
Name="scroll"
Grid.Row="1"
Margin="10"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding menuModels}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Visibility="{Binding MainMenuVisibility}">
<Expander x:Name="E1" Style="{DynamicResource ExpanderStyle}">
<Expander.Header>
<StackPanel
Margin="10,0,0,10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock
VerticalAlignment="Center"
FontFamily="/Resources/Fonts/#iconfont"
FontSize="25"
Foreground="#ddd"
Text="{Binding MainMenuIcon, Converter={StaticResource StringToIconConverter}}" />
<StackPanel Margin="10,0,0,0" VerticalAlignment="Center">
<TextBlock
FontSize="16"
Foreground="White"
Text="{Binding MainMenuName}" />
<TextBlock
FontSize="13"
Foreground="Gray"
Text="{Binding Alias}" />
</StackPanel>
</StackPanel>
</Expander.Header>
<Expander.Content>
<StackPanel>
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding subMenumodels}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<RadioButton
Command="{Binding DataContext.NavChangedCommand, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}"
CommandParameter="{Binding ToggleWindowPath}"
Content="{Binding SubMenuName}"
GroupName="All"
Style="{StaticResource RadioMiniButtonStyle}"
Visibility="{Binding SubMenuVisibility}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</StackPanel>
</Expander.Content>
</Expander>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</ScrollViewer>
<!--#endregion-->

<!--#region 页面显示-->
<Grid Grid.Column="1">
<Grid.Background>
<ImageBrush ImageSource="/Resources/Images/WindowImages.png" />
</Grid.Background>

<Grid.RowDefinitions>
<RowDefinition Height="80" />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock
Margin="0,0,0,20"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="20"
Foreground="#1A8ADE"
Text="{Binding DisplayName}" />

<TextBlock
Margin="10,10,0,5"
HorizontalAlignment="left"
VerticalAlignment="Center"
FontSize="18"
Foreground="#1A8ADE"
Text="{Binding DateVisible}" />

<TextBlock
Margin="0,10,50,5"
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontSize="18"
Foreground="#1A8ADE"
Text="{Binding TimeVisible}" />
<ContentControl
Grid.Row="1"
Width="auto"
Height="auto"
Content="{Binding MainContent}" />

</Grid>

<!--#endregion-->

</Grid>


<!--#endregion-->

</Grid>


</Window>

+ 41
- 0
BPASmart.VariableManager/Views/MainView.xaml.cs Voir le fichier

@@ -0,0 +1,41 @@
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 BPASmart.VariableManager.Views
{
/// <summary>
/// MainView.xaml 的交互逻辑
/// </summary>
public partial class MainView : Window
{
public MainView()
{
InitializeComponent();
this.ButMin.Click += (o, e) => { this.WindowState = WindowState.Minimized; };
//this.ButMax.Click += (o, e) => { this.WindowState = this.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; };
this.ButClose.Click += (o, e) => { this.Close(); };
this.MoveBorder.MouseLeftButtonDown += (o, e) =>
{
//if (e.ClickCount > 1)
//{
// if (this.WindowState == WindowState.Maximized)
// this.WindowState = WindowState.Normal;
// else if (this.WindowState == WindowState.Normal)
// this.WindowState = WindowState.Maximized;
//}
if (e.LeftButton == MouseButtonState.Pressed) this.DragMove();
};
}
}
}

+ 451
- 0
BPASmart.VariableManager/Views/VariableConfig.xaml Voir le fichier

@@ -0,0 +1,451 @@
<UserControl
x:Class="BPASmart.VariableManager.Views.VariableConfig"
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:BPASmart.VariableManager.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmart.VariableManager.ViewModels"
d:DesignHeight="450"
d:DesignWidth="1000"
mc:Ignorable="d">

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

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

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

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

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

<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<!--<Button
Margin="20,0,20,0"
Command="{Binding GenerateData}"
Content="添加数据" />
<Button
Margin="20,0,20,0"
Command="{Binding SaveData}"
Content="保存数据" />-->
</StackPanel>

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

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

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

<Grid Grid.Column="3">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="数据类型" />
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="1,0,1,0" />
</Grid>

<TextBlock
Grid.Column="4"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="报警类型" />

<Grid Grid.Column="5">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="是否启用报警" />
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="0,0,1,0" />
</Grid>

<TextBlock
Grid.Column="6"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="报警配置" />

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

<!--#region 表格数据显示-->
<ScrollViewer
Grid.Row="2"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding varialeInfos}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.3*" />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition Width="0.7*" />
<ColumnDefinition Width="0" />
<ColumnDefinition Width="0.7*" />
<ColumnDefinition Width="0.5*" />
</Grid.ColumnDefinitions>

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

<Grid Grid.Column="1">
<!--<TextBox
Background="Transparent"
CaretBrush="{StaticResource CursorColor}"
Foreground="{StaticResource FontColor}"
Style="{StaticResource InputTextboxStyle}"
Text="{Binding VarName}" />-->
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
</Grid>


<!--<TextBox
Grid.Column="2"
Background="Transparent"
CaretBrush="{StaticResource CursorColor}"
Foreground="{StaticResource FontColor}"
Style="{StaticResource InputTextboxStyle}"
Text="{Binding Address}" />-->

<Grid Grid.Column="3">
<ComboBox
VerticalAlignment="Center"
BorderBrush="Transparent"
BorderThickness="1"
FontFamily="楷体"
FontSize="20"
Foreground="{StaticResource FontColor}"
IsEditable="False"
ItemsSource="{Binding dataType}"
SelectedValue="{Binding DataType}"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding DataType}" />
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
</Grid>


<Grid Grid.Column="5">
<!--<CheckBox
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#ff23CACA"
Content="{Binding IsEnableAlarm, Converter={StaticResource textDisplayConvert}}"
FontSize="16"
Foreground="{StaticResource FontColor}"
IsChecked="{Binding IsEnableAlarm}"
Template="{StaticResource CbTemplate}" />-->
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="0,0,1,0" />
</Grid>

<Grid Grid.Column="6">
<Grid>
<ToggleButton
Name="tb"
Width="{Binding RelativeSource={RelativeSource AncestorType=Grid, AncestorLevel=1}, Path=ActualWidth}"
Height="{Binding RelativeSource={RelativeSource AncestorType=Grid, AncestorLevel=1}, Path=ActualHeight}"
Background="Transparent"
BorderThickness="0"
Content="编辑"
FontSize="14"
IsChecked="{Binding IsOpen}"
IsEnabled="{Binding IsEnableAlarm}"
Style="{StaticResource EditToggleButtonStyle}" />
</Grid>

<!-- 当 StaysOpen 设置为 True 时 popup失去焦点的时候不会自动关闭 -->
<Popup
AllowsTransparency="True"
Focusable="False"
IsOpen="{Binding IsOpen}"
Placement="Left"
PlacementTarget="{Binding ElementName=tb}"
StaysOpen="False">
<Border Background="#081424" ClipToBounds="True">
<Grid Margin="0">
<Grid.Background>
<ImageBrush ImageSource="../Resource/Images/边框1.png" />
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<!--#region 离散量报警设置-->
<!--<StackPanel
Grid.Row="0"
Margin="10"
Orientation="Vertical"
Visibility="{Binding DataType, Converter={StaticResource discreteAlarmConvert}}">

<Grid Margin="5">
<pry:TitleTextBlock />
<TextBlock
Margin="10,5,30,5"
Background="Transparent"
FontSize="16"
Foreground="#dd01FFFF"
Text="离散量报警设置" />
</Grid>

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<TextBlock
Margin="5"
Style="{StaticResource TextBlockStyle}"
Text="选择触发条件:" />

<ComboBox
Grid.Column="1"
Width="180"
Margin="5"
VerticalAlignment="Center"
BorderBrush="#FF23CACA"
BorderThickness="1"
FontFamily="楷体"
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
ItemsSource="{Binding PopupDiscreteAlarmType}"
SelectedIndex="1"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding AlarmSetProp.DiscreteAlarmInfoSet.TrigAlarm}" />
</Grid>

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
Margin="5"
Style="{StaticResource TextBlockStyle}"
Text="输入报警信息:" />
<TextBox
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="5"
Style="{StaticResource TextBoxStyle}"
Text="{Binding AlarmSetProp.DiscreteAlarmInfoSet.AlarmInfo}" />
</Grid>

</StackPanel>-->
<!--#endregion-->

<!--#region 模拟量报警设置-->
<!--<StackPanel
Grid.Row="1"
Margin="10"
Visibility="{Binding DataType, Converter={StaticResource analogAlarmConvert}}">

<Grid Margin="5">
<pry:TitleTextBlock />
<TextBlock
Margin="10,5,30,5"
Background="Transparent"
FontSize="16"
Foreground="#dd01FFFF"
Text="模拟量报警设置" />
</Grid>

<ItemsControl ItemsSource="{Binding AlarmSetProp.AnalogAlarmModels}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<CheckBox
Margin="5,5,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Background="#ff23CACA"
Content="{Binding AlarmTag}"
FontSize="14"
Foreground="#ff23CACA"
IsChecked="{Binding IsEnable}"
Template="{StaticResource CbTemplate}" />

<TextBlock
Grid.Column="1"
Margin="0,5,5,0"
Style="{StaticResource TextBlockStyle}"
Text="请输入报警值:" />
<TextBox
Grid.Column="2"
Width="100"
Margin="0,5,5,0"
IsEnabled="{Binding IsEnable}"
Style="{StaticResource TextBoxStyle}"
Text="{Binding AlarmValue}" />

<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="5"
Style="{StaticResource TextBlockStyle}"
Text="输入报警信息:" />
<TextBox
Grid.Row="1"
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="5"
IsEnabled="{Binding IsEnable}"
Style="{StaticResource TextBoxStyle}"
Text="{Binding AlarmInfo}" />

</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

</StackPanel>-->
<!--#endregion-->

<!--#region 按钮控制-->
<Grid Grid.Row="2" Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<!--<Button
Margin="10,5,10,10"
Command="{Binding CancelCommand}"
Content="取消"
FontFamily="楷体"
FontSize="20"
Foreground="#aa01FFFF"
Template="{StaticResource CancelButtonTemp}" />

<Button
Grid.Column="1"
Margin="10,5,10,10"
Command="{Binding ConfirmCommand}"
Content="确认"
FontFamily="楷体"
FontSize="20"
Foreground="#aa01FFFF"
Template="{StaticResource ConfirmButtonTemp}" />-->
</Grid>
<!--#endregion-->

</Grid>
</Border>
</Popup>
</Grid>

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

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


</Grid>
</UserControl>

+ 45
- 0
BPASmart.VariableManager/Views/VariableConfig.xaml.cs Voir le fichier

@@ -0,0 +1,45 @@
using BPASmart.VariableManager.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 BPASmart.VariableManager.Views
{
/// <summary>
/// VariableConfig.xaml 的交互逻辑
/// </summary>
public partial class VariableConfig : UserControl
{
public VariableConfig()
{
InitializeComponent();
this.IsVisibleChanged += VariableConfig_IsVisibleChanged;
}

private void VariableConfig_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
var obj = (VariableConfig)sender;
if (!obj.IsVisible)
{
if (DelegationNotifi.GetInstance.VariableSave != null)
{
DelegationNotifi.GetInstance.VariableSave();
}
DelegationNotifi.GetInstance.VariableSave = null;
DelegationNotifi.GetInstance.VarNameChanged = null;
}
}
}
}

+ 284
- 0
BPASmart.VariableManager/Views/VariableMonitorView.xaml Voir le fichier

@@ -0,0 +1,284 @@
<UserControl
x:Class="BPASmart.VariableManager.Views.VariableMonitorView"
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:BPASmart.VariableManager.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmart.VariableManager.ViewModels"
d:DesignHeight="450"
d:DesignWidth="1000"
mc:Ignorable="d">
<UserControl.DataContext>
<vm:VariableMonitorViewModel />
</UserControl.DataContext>

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

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

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

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

<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="35" />
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<!--<Button
Width="140"
Margin="0,0,20,0"
Background="#FF19B7EC"
Command="{Binding NewConnectCommand}"
Content="开始监控"
FontFamily="楷体"
FontSize="18"
Template="{StaticResource NewButtonTemp}">
<Button.Foreground>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="#FFBB662A" />
<GradientStop Offset="1" Color="White" />
</LinearGradientBrush>
</Button.Foreground>
</Button>-->
<!--<Button
Width="140"
Margin="0,0,20,0"
Background="#FF19B7EC"
Command="{Binding NewConnectCommand}"
Content="停止监控"
FontFamily="楷体"
FontSize="18"
Template="{StaticResource NewButtonTemp}">
<Button.Foreground>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="#FFBB662A" />
<GradientStop Offset="1" Color="White" />
</LinearGradientBrush>
</Button.Foreground>
</Button>-->
</StackPanel>

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

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

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

<Grid Grid.Column="3">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="数据类型" />
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="1,0,1,0" />
</Grid>

<Grid Grid.Column="5">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="数据显示格式" />
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="0,0,1,0" />
</Grid>

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

<TextBlock
Grid.Column="7"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="修改值" />

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

<!--#region 表格数据显示-->
<ScrollViewer
Grid.Row="2"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding varialeInfos}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.3*" />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition Width="0.7*" />
<ColumnDefinition Width="0" />
<ColumnDefinition Width="0.7*" />
<ColumnDefinition Width="0.5*" />
<ColumnDefinition Width="0.5*" />
</Grid.ColumnDefinitions>

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

<Grid Grid.Column="1">
<!--<TextBox
Background="Transparent"
CaretBrush="{StaticResource CursorColor}"
Foreground="{StaticResource FontColor}"
Style="{StaticResource InputTextboxStyle}"
Text="{Binding VarName}" />-->
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
</Grid>


<!--<TextBox
Grid.Column="2"
Background="Transparent"
CaretBrush="{StaticResource CursorColor}"
Foreground="{StaticResource FontColor}"
Style="{StaticResource InputTextboxStyle}"
Text="{Binding Address}" />-->

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

<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
</Grid>


<Grid Grid.Column="5">
<ComboBox
VerticalAlignment="Center"
BorderBrush="Transparent"
BorderThickness="1"
FontFamily="楷体"
FontSize="20"
Foreground="{StaticResource FontColor}"
IsEditable="False"
ItemsSource="{Binding DisplayFormat}"
SelectedValue="{Binding DataDisplayFormat}"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding DataDisplayFormat}" />
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="0,0,1,0" />
</Grid>

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

<!--<TextBox
Grid.Column="7"
Background="Transparent"
CaretBrush="{StaticResource CursorColor}"
Foreground="{StaticResource FontColor}"
Style="{StaticResource InputTextboxStyle}"
Text="{Binding ModifyValue}" />-->

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

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


</Grid>
</UserControl>

+ 28
- 0
BPASmart.VariableManager/Views/VariableMonitorView.xaml.cs Voir le fichier

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

namespace BPASmart.VariableManager.Views
{
/// <summary>
/// VariableMonitorView.xaml 的交互逻辑
/// </summary>
public partial class VariableMonitorView : UserControl
{
public VariableMonitorView()
{
InitializeComponent();
}
}
}

+ 2
- 1
BPASmartClient.Business/Plugin/ConfigMgr.cs Voir le fichier

@@ -51,6 +51,7 @@ namespace BPASmartClient.Business
string JsonString = File.ReadAllText(path);
deviceConfigModelJsons = JsonConvert.DeserializeObject<ObservableCollection<DeviceConfigModelJson>>(JsonString);
}
else deviceConfigModelJsons = new ObservableCollection<DeviceConfigModelJson>();
if (deviceConfigModelJsons?.Count > 0)
{
ClientId = int.Parse(deviceConfigModelJsons.ElementAt(0).ShopId);
@@ -84,7 +85,7 @@ namespace BPASmartClient.Business
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory());
configurationBuilder.AddApolloConfiguration(p =>
{
p.AppId = apoid;
p.MetaServer = apolloUri;
p.Namespaces = new List<string>() { "application", namespa };


+ 6
- 2
BPASmartClient.Compiler/BPASmartClient.Compiler.csproj Voir le fichier

@@ -1,11 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

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

<ItemGroup>
<Reference Include="Antlr3.Runtime">
<HintPath>DLL\Antlr3.Runtime.dll</HintPath>


+ 7
- 1
BPASmartClient.Compiler/IExecutable.cs Voir le fichier

@@ -1,5 +1,7 @@
using System;
using BPASmartClient.MessageName.接收消息Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -20,5 +22,9 @@ namespace BPASmartClient.Compiler
/// 控件类型
/// </summary>
string ControlType { get; }
///// <summary>
///// 消息名称
///// </summary>
//ObservableCollection<EventReceiveMessage> EventNameList { get; }
}
}

+ 2
- 0
BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj Voir le fichier

@@ -115,6 +115,7 @@
<None Remove="Image\圆角矩形 4.png" />
<None Remove="Image\圆角矩形.png" />
<None Remove="Image\外边框1.png" />
<None Remove="Image\容器边框.png" />
<None Remove="Image\容器边框2.png" />
<None Remove="Image\工艺流程.jpg" />
<None Remove="Image\工艺流程.png" />
@@ -309,6 +310,7 @@
<Resource Include="Image\告警\无告警1.png" />
<Resource Include="Image\告警\轻微告警.png" />
<Resource Include="Image\外边框1.png" />
<Resource Include="Image\容器边框.png" />
<Resource Include="Image\容器边框2.png" />
<Resource Include="Image\工艺流程.jpg" />
<Resource Include="Image\工艺流程.png" />



+ 43
- 0
BPASmartClient.CustomResource/Pages/Model/DataGridColumnAttribute.cs Voir le fichier

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

namespace BPASmartClient.CustomResource.Pages.Model
{
[AttributeUsage(AttributeTargets.Property)]
public class DataGridColumnAttribute : Attribute
{
public static readonly DataGridColumnAttribute Default = new DataGridColumnAttribute(0);

public DataGridColumnAttribute(int index)
{
DataGridColumnValue = index;
}

public virtual int DataGridColumn => DataGridColumnValue;

protected int DataGridColumnValue { get; set; }

public override bool Equals(object obj)
{
if (obj == this)
{
return true;
}

return obj is DataGridColumnAttribute other && other.DataGridColumn == DataGridColumn;
}

public override int GetHashCode()
{
return DataGridColumn.GetHashCode();
}

public override bool IsDefaultAttribute()
{
return Equals(Default);
}
}
}

+ 12
- 0
BPASmartClient.CustomResource/Pages/Model/DoNotAutoGenerateDataGridColumnAttribute.cs Voir le fichier

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

namespace BPASmartClient.CustomResource.Pages.Model
{
public class DoNotAutoGenerateDataGridColumnAttribute : Attribute
{
}
}

+ 84
- 0
BPASmartClient.CustomResource/Pages/Model/ProductionDataHelper.cs Voir le fichier

@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using System.Windows;
using System.IO;
using BPASmartClient.Helper;

namespace BPASmartClient.CustomResource.Pages.Model
{
public class ProductionDataHelper<TProductionData> where TProductionData : class, new()
{








public static string SavePath { get; set; }
private static string FileName = string.Empty;
private static string FilePath = string.Empty;
public static string Alias { get; set; } = string.Empty;
private static string _path
{
get
{
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\ProductionData\\{FilePath}"));
return $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\ProductionData\\{ FilePath}";
}
}
public static ObservableCollection<TProductionData> productionDatas { get; set; } = new ObservableCollection<TProductionData>();
//public static TProductionData Data { get; set; } = new TProductionData();
public static void Add(TProductionData production)
{
if (FilePath.Length <= 0)
{
if (Alias.Length <= 0)
FilePath = $"{DateTime.Now.ToString("yyy-MM-dd")}";
else
FilePath = $"{DateTime.Now.ToString("yyy-MM-dd")}\\{Alias}";
}
if (FileName.Length <= 0) FileName = $"{DateTime.Now.ToString("HH-mm-ss")}.pry";
Application.Current.Dispatcher.Invoke(new Action(() =>
{
productionDatas.Add(production);
}));
}

public static bool Save(string path = "")
{
DataRecord dr = new DataRecord();
if (File.Exists(path))
{
dr.Save(productionDatas, FileName);
return true;
}
if (SavePath != null && File.Exists(SavePath))
{
dr.Save(productionDatas, FileName);
return true;
}

dr.Save(productionDatas, FileName);
return true;


}

public static void End()
{
FileName = string.Empty;
FilePath = string.Empty;
Alias = string.Empty;
}


}


}

+ 15
- 0
BPASmartClient.CustomResource/Pages/Model/ReportBase.cs Voir le fichier

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using Microsoft.Toolkit.Mvvm.ComponentModel;

namespace BPASmartClient.CustomResource.Pages.Model
{
[Serializable]
public class ReportBase : ObservableObject
{
}
}

+ 53
- 0
BPASmartClient.CustomResource/Pages/Model/ReportHelper.cs Voir le fichier

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


namespace BPASmartClient.CustomResource.Pages.Model
{
public class ReportHelper
{
public ObservableCollection<ReportBase> Reports { get; set; } = new ObservableCollection<ReportBase>();

public void Add(ReportBase report)
{
Reports.Add(report);
}

public void Save(string name)
{
DataRecord record = new DataRecord();
record.Save(Reports, name);
}

public void Dispos()
{
Reports.Clear();
}

public ObservableCollection<ReportBase> GetData(string path)
{
DataRecord record = new DataRecord();
return record.Read<ObservableCollection<ReportBase>>(path);
}
}

//public class ReportHelper
//{

// private volatile static ReportHelper _Instance;
// public static ReportHelper GetInstance => _Instance ?? (_Instance = new ReportHelper());
// private ReportHelper() { }

// public object GetData(string path)
// {
// DataRecord record = new DataRecord();
// return record.Read<object>(path);
// }

//}
}

+ 79
- 0
BPASmartClient.CustomResource/Pages/Model/ReportTestModel.cs Voir le fichier

@@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;

namespace BPASmartClient.CustomResource.Pages.Model
{
[Serializable]
public class ReportTestModel : ReportBase
{
//[DataGridColumn(0)]//设置列的索引
//[DisplayName("整数")]//设置设备名称
//public int data1 { get { return _mdata1; } set { _mdata1 = value; OnPropertyChanged(); } }
//private int _mdata1;


//[DataGridColumn(1)]
//[DisplayName("字节")]
//public byte data2 { get { return _mdata2; } set { _mdata2 = value; OnPropertyChanged(); } }
//private byte _mdata2;


//[DataGridColumn(2)]
//[DisplayName("布尔")]
//public bool data3 { get { return _mdata3; } set { _mdata3 = value; OnPropertyChanged(); } }
//private bool _mdata3;


//[DataGridColumn(3)]
//[DisplayName("字符串")]
//public string data4 { get { return _mdata4; } set { _mdata4 = value; OnPropertyChanged(); } }
//private string _mdata4;


//[DataGridColumn(4)]
//[DisplayName("浮点数")]
//public float data5 { get { return _mdata5; } set { _mdata5 = value; OnPropertyChanged(); } }
//private float _mdata5;


//[DataGridColumn(5)]
//[DisplayName("无符号整数")]
//public ushort data6 { get { return _mdata6; } set { _mdata6 = value; OnPropertyChanged(); } }
//private ushort _mdata6;

[DataGridColumn(0)]//设置列的索引
[DisplayName("整数")]//设置设备名称
public int data1 { get; set; }


[DataGridColumn(1)]
[DisplayName("字节")]
public byte data2 { get; set; }


[DataGridColumn(2)]
[DisplayName("布尔")]
public bool data3 { get; set; }


[DataGridColumn(3)]
[DisplayName("字符串")]
public string data4 { get; set; }


[DataGridColumn(4)]
[DisplayName("浮点数")]
public float data5 { get; set; }


[DataGridColumn(5)]
[DisplayName("无符号整数")]
public ushort data6 { get; set; }

}
}

+ 5
- 5
BPASmartClient.CustomResource/Pages/View/AlarmView.xaml Voir le fichier

@@ -23,11 +23,11 @@
<convert:AnalogAlarmConvert x:Key="analogAlarmConvert" />
<convert:DiscreteAlarmConvert x:Key="discreteAlarmConvert" />
<convert:AlarmTypeTextConvert x:Key="alarmTypeTextConvert" />-->
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" />
<SolidColorBrush x:Key="BorderSolid" Color="#332AB2E7" />
<SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="TitleFontColor" Color="White" />
<SolidColorBrush x:Key="TitleFontColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="CursorColor" Color="Aqua" />
<SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="TitleBorderColor" Color="#332AB2E7" />

<Style x:Key="TextBlockStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="楷体" />
@@ -51,7 +51,7 @@
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="Red" />
<Setter Property="Foreground" Value="#FFF53F62" />
<Setter Property="FontSize" Value="14" />
</Style>

@@ -157,7 +157,7 @@
</StackPanel>

<!--#region 表格标题栏设置-->
<Grid Grid.Row="1" Background="#FF19B7EC">
<Grid Grid.Row="1" Background="#ff0C255F">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.3*" />
<ColumnDefinition Width="0.7*" />


+ 51
- 49
BPASmartClient.CustomResource/Pages/View/MainView.xaml Voir le fichier

@@ -9,9 +9,9 @@
Title="MainView"
Width="1200"
Height="700"
Topmost="False"
AllowsTransparency="True"
Background="{x:Null}"
Topmost="False"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
mc:Ignorable="d">
@@ -291,11 +291,11 @@
<Setter.Value>
<ControlTemplate>
<Rectangle
Margin="1"
SnapsToDevicePixels="True"
Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
StrokeDashArray="1 2"
StrokeThickness="1" />
Margin="1"
SnapsToDevicePixels="True"
Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
StrokeDashArray="1 2"
StrokeThickness="1" />
</ControlTemplate>
</Setter.Value>
</Setter>
@@ -306,28 +306,28 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type CheckBox}">
<StackPanel
Background="Transparent"
Orientation="Horizontal"
SnapsToDevicePixels="True">
Background="Transparent"
Orientation="Horizontal"
SnapsToDevicePixels="True">
<Grid>
<Image
Width="12"
Height="14"
Source="/BPASmartClient.CustomResource;component/Image/Cb_HalfChecked.png" />
Width="12"
Height="14"
Source="/BPASmartClient.CustomResource;component/Image/Cb_HalfChecked.png" />
<Image
x:Name="image1"
Width="12"
Height="14"
Source="/BPASmartClient.CustomResource;component/Image/Cb_HalfChecked.png" />
x:Name="image1"
Width="12"
Height="14"
Source="/BPASmartClient.CustomResource;component/Image/Cb_HalfChecked.png" />
</Grid>
<ContentPresenter
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="HasContent" Value="True">
@@ -338,11 +338,11 @@
<Setter.Value>
<ControlTemplate>
<Rectangle
Margin="14,0,0,0"
SnapsToDevicePixels="True"
Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
StrokeDashArray="1 2"
StrokeThickness="1" />
Margin="14,0,0,0"
SnapsToDevicePixels="True"
Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
StrokeDashArray="1 2"
StrokeThickness="1" />
</ControlTemplate>
</Setter.Value>
</Setter>
@@ -392,7 +392,7 @@
VerticalAlignment="Center"
FontSize="18"
Foreground="White"
Text="上位机监控系统" />
Text="变量管理器" />
</StackPanel>


@@ -404,18 +404,18 @@
HorizontalAlignment="Right"
Columns="3">
<Button
Visibility="Hidden"
IsEnabled="False"
Name="ButMin"
Content="&#xe664;"
Style="{StaticResource TitleBarStyle}" />
<Button
Visibility="Hidden"
IsEnabled="False"
Style="{StaticResource TitleBarStyle}"
Visibility="Hidden" />
<Button
Name="ButMax"
Content="&#xe65d;"
FontSize="22"
Style="{StaticResource TitleBarStyle}" />
IsEnabled="False"
Style="{StaticResource TitleBarStyle}"
Visibility="Hidden" />
<Button
Name="ButClose"
Content="&#xe679;"
@@ -446,8 +446,7 @@
Grid.Row="1"
Margin="10"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden"
>
VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding menuModels}">
<ItemsControl.ItemTemplate>
<DataTemplate>
@@ -516,18 +515,17 @@
<RowDefinition Height="80" />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<CheckBox
Style="{StaticResource checkBoxStyle}"
Margin="5,0,5,0"
Content="开机启动"
IsChecked="{Binding AutoStart}" />
Margin="5,0,5,0"
Content="开机启动"
IsChecked="{Binding AutoStart}"
Style="{StaticResource checkBoxStyle}" />
<CheckBox
Style="{StaticResource checkBoxStyle}"
Margin="5,0,5,0"
Content="设备初始化"
IsChecked="{Binding Status}"
/>
Margin="5,0,5,0"
Content="设备初始化"
IsChecked="{Binding Status}"
Style="{StaticResource checkBoxStyle}" />
</StackPanel>
<TextBlock
Margin="0,0,0,20"
@@ -552,8 +550,12 @@
FontSize="18"
Foreground="#1A8ADE"
Text="{Binding TimeVisible}" />
<ContentControl Grid.Row="1" Width="auto" Height="auto" Content="{Binding MainContent}" />
<ContentControl
Grid.Row="1"
Width="auto"
Height="auto"
Content="{Binding MainContent}" />

</Grid>

<!--#endregion-->


+ 42
- 0
BPASmartClient.CustomResource/Pages/View/ProductionDataView.xaml Voir le fichier

@@ -0,0 +1,42 @@
<UserControl
x:Class="BPASmartClient.CustomResource.Pages.View.ProductionDataView"
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.CustomResource.Pages.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmartClient.CustomResource.Pages.ViewModel"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>



<Grid>
<StackPanel Orientation="Horizontal">
<TextBlock
VerticalAlignment="Center"
Foreground="White"
Text="请输入开始时间:" />
<DatePicker VerticalAlignment="Center" />
<TextBlock
VerticalAlignment="Center"
Foreground="White"
Text="请输入结束时间:" />
<DatePicker VerticalAlignment="Center" />
<Button Margin="5,0,5,0" Content="查询" />
<Button Content="导入数据文件" />
</StackPanel>
</Grid>

<Grid Grid.Row="1">
<DataGrid ItemsSource="{Binding}" />
</Grid>

</Grid>
</UserControl>

+ 28
- 0
BPASmartClient.CustomResource/Pages/View/ProductionDataView.xaml.cs Voir le fichier

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

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

+ 47
- 0
BPASmartClient.CustomResource/Pages/View/ReportView.xaml Voir le fichier

@@ -0,0 +1,47 @@
<UserControl
x:Class="BPASmartClient.CustomResource.Pages.View.ReportView"
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.CustomResource.Pages.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls"
xmlns:vm="clr-namespace:BPASmartClient.CustomResource.Pages.ViewModel"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">

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

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>

<StackPanel Orientation="Horizontal">
<Button
Width="70"
Margin="5,0"
Command="{Binding AddCommand}"
Content="添加数据" />
<Button
Width="70"
Margin="5,0"
Command="{Binding SaveCommand}"
Content="保存数据" />
<Button
Width="70"
Margin="5,0"
Command="{Binding ReadCommand}"
Content="获取数据" />
</StackPanel>

<Grid Grid.Row="1">
<pry:DataGridEx ItemsSource="{Binding ReportData}" />
</Grid>

</Grid>
</UserControl>

+ 28
- 0
BPASmartClient.CustomResource/Pages/View/ReportView.xaml.cs Voir le fichier

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

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

+ 4
- 5
BPASmartClient.CustomResource/Pages/View/RunLogView.xaml Voir le fichier

@@ -25,9 +25,9 @@
<convert:AlarmTypeTextConvert x:Key="alarmTypeTextConvert" />-->
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" />
<SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="TitleFontColor" Color="White" />
<SolidColorBrush x:Key="TitleFontColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="CursorColor" Color="Aqua" />
<SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="TitleBorderColor" Color="#332AB2E7" />

<Style x:Key="TextBlockStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="楷体" />
@@ -158,7 +158,7 @@
</StackPanel>

<!--#region 表格标题栏设置-->
<Grid Grid.Row="1" Background="#FF19B7EC">
<Grid Grid.Row="1" Background="#ff0C255F">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.7*" />
<ColumnDefinition Width="0.7*" />
@@ -261,8 +261,7 @@
<TextBlock
Grid.Column="2"
Style="{StaticResource DataTextBlockStyle}"
Text="{Binding RunLogInfo}"
/>
Text="{Binding RunLogInfo}" />

<!--<Grid Grid.Column="3">
<TextBlock


+ 9
- 9
BPASmartClient.CustomResource/Pages/View/UserLogView.xaml Voir le fichier

@@ -24,11 +24,11 @@
<convert:AnalogAlarmConvert x:Key="analogAlarmConvert" />
<convert:DiscreteAlarmConvert x:Key="discreteAlarmConvert" />
<convert:AlarmTypeTextConvert x:Key="alarmTypeTextConvert" />-->
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" />
<SolidColorBrush x:Key="BorderSolid" Color="#332AB2E7" />
<SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="TitleFontColor" Color="White" />
<SolidColorBrush x:Key="TitleFontColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="CursorColor" Color="Aqua" />
<SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" />
<SolidColorBrush x:Key="TitleBorderColor" Color="#332AB2E7" />

<Style x:Key="TextBlockStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="楷体" />
@@ -240,7 +240,7 @@
</StackPanel>

<!--#region 表格标题栏设置-->
<Grid Grid.Row="1" Background="#FF19B7EC">
<Grid Grid.Row="1" Background="#ff0C255F">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.3*" />
<ColumnDefinition Width="0.3*" />
@@ -256,7 +256,7 @@
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="日期" />
<Grid Grid.Column="1">
<TextBlock
HorizontalAlignment="Center"
@@ -264,13 +264,13 @@
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="时间" />
<Border
BorderBrush="{StaticResource TitleBorderColor}"
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>

<TextBlock
Grid.Column="2"
@@ -279,7 +279,7 @@
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="操作权限" />

<Grid Grid.Column="3">
<TextBlock
@@ -288,7 +288,7 @@
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Text="用户名" />
<Border
BorderBrush="{StaticResource TitleBorderColor}"
BorderThickness="1,0,1,0"


+ 2
- 2
BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs Voir le fichier

@@ -27,10 +27,10 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
}), "PermissionChange");

//测试用
Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "营养强化剂", DeviceIp = "192.168.1.111", RawMaterialSource = 1 });
/* Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "营养强化剂", DeviceIp = "192.168.1.111", RawMaterialSource = 1 });
Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "甜味剂", DeviceIp = "192.168.1.112", RawMaterialSource = 1 });
Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "抗氧化剂", DeviceIp = "192.168.1.113", RawMaterialSource = 1 });
Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "食用香料", DeviceIp = "192.168.1.114", RawMaterialSource = 1 });
Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "食用香料", DeviceIp = "192.168.1.114", RawMaterialSource = 1 });*/

}



+ 19
- 0
BPASmartClient.CustomResource/Pages/ViewModel/ProductionDataViewModel.cs Voir le fichier

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;

namespace BPASmartClient.CustomResource.Pages.ViewModel
{
public class ProductionDataViewModel : ObservableObject
{
public ProductionDataViewModel()
{

}


}
}

+ 63
- 0
BPASmartClient.CustomResource/Pages/ViewModel/ReportViewModel.cs Voir le fichier

@@ -0,0 +1,63 @@
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.CustomResource.Pages.Model;
using Microsoft.Toolkit.Mvvm.Input;
using System.Diagnostics;
using System.IO;

namespace BPASmartClient.CustomResource.Pages.ViewModel
{
public class ReportViewModel
{
ReportHelper reportHelper = new ReportHelper();
public ReportViewModel()
{
AddCommand = new RelayCommand(() =>
{
for (int i = 0; i < 30; i++)
{
ReportData.Add(new ReportTestModel()
{
data1 = new Random().Next(1000, 2000),
data2 = (byte)new Random().Next(0, 240),
data3 = Convert.ToBoolean(new Random().Next(0, 1)),
data4 = new Random().Next(3000, 4000).ToString(),
data5 = (float)new Random().NextDouble() * 100,
data6 = (ushort)new Random().Next(5000, 6000)
});
}
//ReportData = reportHelper.Reports;
});

SaveCommand = new RelayCommand(() =>
{
reportHelper.Save($"aa.pry");
});

ReadCommand = new RelayCommand(() =>
{
ReportData.Clear();
var res = reportHelper.GetData($"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\ProductionData\\aa.pry");
if (res != null)
{
foreach (var item in res)
{
ReportData.Add(item);
}
}
});

}

public ObservableCollection<ReportBase> ReportData { get; set; } = new ObservableCollection<ReportBase>();

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

+ 76
- 0
BPASmartClient.CustomResource/UserControls/DataGridEx.cs Voir le fichier

@@ -0,0 +1,76 @@
using BPASmartClient.CustomResource.Pages.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace BPASmartClient.CustomResource.UserControls
{
public class DataGridEx : DataGrid
{
private List<ColumnAndOrder> _columnAndOrderList = new List<ColumnAndOrder>();

public DataGridEx()
{
AutoGeneratingColumn += DataGridEx_AutoGeneratingColumn;
AutoGeneratedColumns += DataGridEx_AutoGeneratedColumns;
}

private void DataGridEx_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
{

e.Cancel = true;//将创建过程标记为已取消,以阻止DataGrid将生成的列对象加入到列集合中.

//从Attribute中读取显示名称.
var displayName = ((System.ComponentModel.MemberDescriptor)e.PropertyDescriptor).DisplayName;
if (!string.IsNullOrWhiteSpace(displayName))
{
e.Column.Header = displayName;
}

//从Attribute中读取顺序,以及是否自动生成列的标识.
var attributes = ((System.ComponentModel.MemberDescriptor)e.PropertyDescriptor).Attributes;
var order = 0;
foreach (Attribute attribute in attributes)
{
if (attribute is DataGridColumnAttribute orderAttribute)
{
order = orderAttribute.DataGridColumn;
}
else if (attribute is DoNotAutoGenerateDataGridColumnAttribute)
{
//发现 DoNotAutoGenerateDataGridColumnAttribute 时,丢弃已生成的列
return;
}
}

//将创建的列及顺序保存
_columnAndOrderList.Add(new ColumnAndOrder(order, e.Column));
}

private void DataGridEx_AutoGeneratedColumns(object sender, EventArgs e)
{
//按顺序将所有列加入到Columns集合中
foreach (var columnAndOrder in _columnAndOrderList.OrderBy(v => v.Order))
{
Columns.Add(columnAndOrder.DataGridColumn);
}
_columnAndOrderList = null;
}

private class ColumnAndOrder
{
public ColumnAndOrder(int order, DataGridColumn dataGridColumn)
{
Order = order;
DataGridColumn = dataGridColumn;
}

public int Order { get; }

public DataGridColumn DataGridColumn { get; }
}
}
}

+ 13
- 0
BPASmartClient.Helper/DataRecord.cs Voir le fichier

@@ -30,6 +30,19 @@ namespace BPASmartClient.Helper
return default;
}

public object Read(string filepath)
{
if (File.Exists(filepath))
{
FileStream fs = new FileStream(filepath, FileMode.Open);
BinaryFormatter bf = new BinaryFormatter();
var res = bf.Deserialize(fs);
fs.Close();
return res;
}
return default;
}

/// <summary>
/// 保存序列化文件
/// </summary>


+ 3
- 17
BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs Voir le fichier

@@ -11,18 +11,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
public class GVL_BigStation
{
/// <summary>
/// 配方数据
/// </summary>
public ObservableCollection<RemoteRecipeData> RemoteRecipes = new ObservableCollection<RemoteRecipeData>();
/// <summary>
/// 配方数据
/// </summary>
public ObservableCollection<RemoteRecipeData> IssuedComplete = new ObservableCollection<RemoteRecipeData>();
/// <summary>
/// 配方队列
/// </summary>
public ConcurrentQueue<long> RecipeQueue = new ConcurrentQueue<long>();
/// <summary>
/// 往输送带下发配方完成
/// </summary>
@@ -38,13 +27,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// <summary>
/// 记录AGV进站送货的指令顺序
/// </summary>
public int[] AgvDeliveryPosition { get; set; }= new int[6];
public int AgvDeliveryPosition { get; set; }
/// <summary>
/// 记录AGV进站取货的指令顺序
/// </summary>
public int[] AgvPickUpPosition { get; set; } = new int[6];

public ConcurrentQueue<int> AGVToWorkStationQueue = new ConcurrentQueue<int>();

public int AgvPickUpPosition { get; set; }
}
}

+ 130
- 117
BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs Voir le fichier

@@ -25,6 +25,23 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
public HKDeviceStatus HKDevice = new HKDeviceStatus();
GVL_BigStation BigStation = new GVL_BigStation();

/// <summary>
/// 配方数据
/// </summary>
public ObservableCollection<RemoteRecipeData> RemoteRecipes = new ObservableCollection<RemoteRecipeData>();
/// <summary>
/// 配方数据
/// </summary>
public ObservableCollection<RemoteRecipeData> IssuedComplete = new ObservableCollection<RemoteRecipeData>();
/// <summary>
/// 配方队列
/// </summary>
public ConcurrentQueue<long> RecipeQueue = new ConcurrentQueue<long>();
/// <summary>
/// AGV到达工站队列
/// </summary>
public ConcurrentQueue<int> AGVToWorkStationQueue = new ConcurrentQueue<int>();
/// <summary>
/// 接收原料数据
/// </summary>
@@ -38,9 +55,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
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 && res is string recipeName) && (res1 != null && res1 is uint recipeID) && (res2 > 0))
{
int index = Array.FindIndex(Json<RemoteRecipeDataColl>.Data.Recipes.ToArray(), p => p.RecipeCode == recipeID);
if (index == -1)
@@ -77,12 +92,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model
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)
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == recipeId);
if (index >= 0 && index < RemoteRecipes.Count)
{
Json<RemoteRecipeDataColl>.Data.Recipes.ElementAt(index).TrayCode = TrayLocation;
RemoteRecipes.ElementAt(index).TrayCode = TrayLocation;
MessageLog.GetInstance.RunLog($"接收到AGV进站信号=>配方编码:{recipeId} 、托盘位置:{TrayLocation}");
BigStation.AGVToWorkStationQueue.Enqueue(recipeId);
AGVToWorkStationQueue.Enqueue(recipeId);
}
}
}
@@ -106,7 +121,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
}
BigStation.RecipeQueue.Clear();
RecipeQueue.Clear();
Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
ThreadManage.GetInstance().StartLong(new Action(() =>
{
@@ -117,8 +132,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
ThreadManage.GetInstance().StartLong(new Action(() => {
if (HKDevice.IsConnected && SiemensDevice.IsConnected)
{
AgvGetInDelivery();
//AgvGetInPickUp();
AgvGetInOut();
}
Thread.Sleep(10);

@@ -126,123 +140,120 @@ namespace BPASmartClient.JXJFoodBigStation.Model
ThreadManage.GetInstance().StartLong(new Action(() => {
ReadSiemensCommData();
ReadHKPLCCommData();
}), "AGV进站送取货", true);
}), "读取西门子和海科PLC的数据", true);
}
/// <summary>
/// AGV进站送货
/// AGV送货
/// </summary>
private void AgvGetInDelivery()
/// <param name="bitNum"></param>
private void AGV_Delivery(int bitNum)
{
//检测AGV到站信号
if (BigStation.AGVToWorkStationQueue.Count > 0)
if ((ReadSiemens("M4002."+ bitNum) is bool) && BigStation.AgvDeliveryPosition == 0)
{
int index = BigStation.AGVToWorkStationQueue.ElementAt(0);

BigStation.AgvDeliveryPosition = 1;
WriteHKPLC("M4002."+ bitNum, true);
WriteSiemens("M4002."+ bitNum, false);
}
for (int i = 0; i < 6; i++)
else if (ReadHK("M5002."+ bitNum) is bool && BigStation.AgvDeliveryPosition == 1)
{
switch (BigStation.AgvDeliveryPosition[i])
{
case 0:
if (true)
{
BigStation.AgvDeliveryPosition[i] = 1;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApply, true);
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVApply,false);
}
break;
case 1:
if (HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApply) is bool)
{
BigStation.AgvDeliveryPosition[i] = 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))
{
BigStation.AgvDeliveryPosition[i] = 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))
{
BigStation.AgvDeliveryPosition[i] = 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))
{
BigStation.AgvDeliveryPosition[i] = 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))
{
BigStation.AgvDeliveryPosition[i] = 0;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationHaveCargo, true);
}
break;
default:
break;
}
//获取工位上是否有小车
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool)
HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationIsExistCar));
BigStation.AgvDeliveryPosition = 2;
WriteSiemens("M5002."+ bitNum, true);
WriteHKPLC("M5002."+ bitNum, false);
}
else if (ReadSiemens("M4004."+ bitNum) is bool && BigStation.AgvDeliveryPosition == 2)
{
BigStation.AgvDeliveryPosition = 3;
WriteHKPLC("M4004."+ bitNum, true);
WriteSiemens("M4004."+ bitNum, false);
}
else if (ReadHK("M5004."+ bitNum) is bool && BigStation.AgvDeliveryPosition == 3)
{
BigStation.AgvDeliveryPosition = 4;
WriteSiemens("M5004."+ bitNum, true);
WriteHKPLC("M5004."+ bitNum, false);
}
else if (ReadSiemens("M4005."+ bitNum) is bool && BigStation.AgvDeliveryPosition == 4)
{
BigStation.AgvDeliveryPosition = 5;
WriteHKPLC("M4005."+ bitNum, true);
WriteSiemens("M4005."+ bitNum, false);
}
else if (ReadHK("M5005."+ bitNum) is bool && BigStation.AgvDeliveryPosition == 5)
{
WriteSiemens("M5005."+ bitNum, true);
WriteHKPLC("M5005."+ bitNum, false);
}
}
/// <summary>
/// AGV进站取货
/// AGV取货
/// </summary>
private void AgvGetInPickUp()
/// <param name="bitNum"></param>
private void AGV_Pick(int bitNum)
{
/*switch (BigStation.AgvPickUpPosition)
if (ReadSiemens("M4003"+ bitNum) is bool && BigStation.AgvPickUpPosition == 0)
{
case 0:
if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.PickAGVApply) is bool))
{
BigStation.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))
{
BigStation.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))
BigStation.AgvPickUpPosition = 1;
WriteHKPLC("M4003" + bitNum, true);
WriteSiemens("M4003" + bitNum, false);
}
if (ReadHK("M5003" + bitNum) is bool && BigStation.AgvPickUpPosition == 1)
{
BigStation.AgvPickUpPosition = 2;
WriteSiemens("M5003" + bitNum, true);
WriteHKPLC("M5003" + bitNum,false);
}
if (ReadSiemens("M4006" + bitNum) is bool && BigStation.AgvPickUpPosition == 2)
{
BigStation.AgvPickUpPosition = 3;
WriteHKPLC("M4006" + bitNum, true);
WriteSiemens("M4006" + bitNum, false);
}
if (ReadHK("M5006" + bitNum) is bool && BigStation.AgvPickUpPosition == 3)
{
WriteSiemens("M5006" + bitNum, true);
WriteHKPLC("M5006" + bitNum, false);
}
}
/// <summary>
/// AGV进站送货
/// </summary>
private void AgvGetInOut()
{
//获取工位上是否有小车
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool)
HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationIsExistCar));
//检测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 recipe = (int)RemoteRecipes.ElementAt(index).RecipeCode;
if (TrayLocation > 0 && TrayLocation < 7)
{
AGV_Delivery(TrayLocation - 1);
if (BigStation.AgvDeliveryPosition == 5)
{
BigStation.AgvPickUpPosition = 3;
HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.PickCargoAGVFinish, true);
BigStation.AgvDeliveryPosition = 0;
AGVToWorkStationQueue.TryDequeue(out recipe);
}
break;
case 3:
if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.PickAGVFinish) is bool))
AGV_Pick(TrayLocation - 1);
if (BigStation.AgvPickUpPosition == 3)
{
BigStation.AgvPickUpPosition = 0;
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVFinish, true);
AGVToWorkStationQueue.TryDequeue(out recipe);
}
break;
default:
break;
}*/
}
}
}
private void ReceviceData()
{
BigStation.RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
if (Json<RemoteRecipeDataColl>.Data.Recipes.Count > 0)
RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
if (RemoteRecipes.Count > 0)
{
foreach (var data in Json<RemoteRecipeDataColl>.Data.Recipes)
foreach (var data in RemoteRecipes)
{
if(!(BigStation.RecipeQueue.Contains(data.RecipeCode)))
BigStation.RecipeQueue.Enqueue(data.RecipeCode);
if(!(RecipeQueue.Contains(data.RecipeCode)))
RecipeQueue.Enqueue(data.RecipeCode);
}
}
}
@@ -251,19 +262,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model
ushort[] Weight = new ushort[15];
private void RecipeInfoToHKPLC()
{
if (BigStation.RecipeQueue.Count > 0)
if (RecipeQueue.Count > 0)
{
int index = Array.FindIndex(BigStation.RemoteRecipes.ToArray(), p => p.RecipeCode == BigStation.RecipeQueue.ElementAt(0));
if (index >= 0 && index <= BigStation.RemoteRecipes.Count)
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0));
if (index >= 0 && index <= RemoteRecipes.Count)
{
long code = BigStation.RemoteRecipes.ElementAt(index).RecipeCode;
long code = RemoteRecipes.ElementAt(index).RecipeCode;
if (HKDevice.HK_PLC_S7.Read("M5001.0") is bool)//配方1是否允许下发配发
{
for (int i = 0; i < BigStation.RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
{
BarrelNum[i] = (ushort)BigStation.RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
Location[i] = (ushort)BigStation.RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialLocation;
Weight[i] = (ushort)BigStation.RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialWeight;
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;
}
HKDevice.StockBinPar(BarrelNum, Location, Weight);
HKDevice.HK_PLC_S7.Write("M4001.0", 1);//配发下发完成,to plc
@@ -273,9 +284,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model
if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.RecipeDosingFinish) is bool))
{
HKDevice.RecipeDosingFinishReset();
BigStation.RecipeQueue.TryDequeue(out code);

BigStation.IssuedComplete.Add(BigStation.RemoteRecipes.ElementAt(index));//将该配方添加到下
RecipeQueue.TryDequeue(out code);
IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下
Json<RemoteRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
}
}
@@ -289,8 +299,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
GetSiemensStatus("", new Action<object>((obj) =>
{
if (obj is bool[] bools && bools.Length > 0)
{
}
}));
}
}
@@ -298,6 +310,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
if (HKDevice.IsConnected)
{

}
}
private void GetHKStatus(string key,Action<object> action)


+ 9
- 4
BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs Voir le fichier

@@ -45,7 +45,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
RawMaterials.Clear();
string recipeName = "配方" + (Json<RemoteRecipeDataColl>.Data.Recipes.Count + 1) + "";
go:
long recipeCode = new Random().Next(1000, 9999);
long recipeCode = new Random().Next(10000, 99999);
foreach (var item in Recipes)
{
if (item.RecipeCode == recipeCode)
@@ -53,13 +53,18 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
goto go;
}
}
int trayCode = new Random().Next(1, 3);
for (int i = 1; i < 16; i++)
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 RemoteRecipeRawMaterial()
{
RawMaterialWeight = new Random().Next(10, 1000),
RawMaterialBarrelNum = new Random().Next(1, 3),
RawMaterialBarrelNum = a,
RawMaterialLocation = i,
});
}


+ 34
- 9
BPASmartClient.JXJFoodSmallStation/App.xaml.cs Voir le fichier

@@ -56,21 +56,21 @@ namespace BPASmartClient.JXJFoodSmallStation

#region 配方管理菜单
ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
/*RecipeManage.Add(new SubMenumodel()
RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "本地配方管理",
SubMenuPermission = new Permission[] { Permission.管理员 },
AssemblyName = "BPASmartClient.JXJFoodSmallStation",
ToggleWindowPath = "View.RecipeSettingsView"
});*/
});

/*RecipeManage.Add(new SubMenumodel()
RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "本地配方下发",
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员 },
AssemblyName = "BPASmartClient.JXJFoodSmallStation",
ToggleWindowPath = "View.RecipeControlView"
});*/
});
RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "服务配方管理",
@@ -87,6 +87,24 @@ namespace BPASmartClient.JXJFoodSmallStation
});
#endregion

#region 参数设置
ObservableCollection<SubMenumodel> ParSet = new ObservableCollection<SubMenumodel>();
ParSet.Add(new SubMenumodel()
{
SubMenuName = "原料参数设置",
SubMenuPermission = new Permission[] { Permission.管理员 },
AssemblyName = "BPASmartClient.JXJFoodSmallStation",
ToggleWindowPath = "View.DeviceMaterialParView"
});
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
MainMenuIcon = "&#xe62d;",
MainMenuName = "参数设置",
Alias = "Parameter Set",
subMenumodels = ParSet,
});
#endregion

#region 消息日志
ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>();
InfoLog.Add(new SubMenumodel()
@@ -174,14 +192,21 @@ namespace BPASmartClient.JXJFoodSmallStation
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.PasswordChangeView"
});

/* UserManager.Add(new SubMenumodel()
UserManager.Add(new SubMenumodel()
{
SubMenuName = "NFC登录设置",
SubMenuName = "用户管理",
SubMenuPermission = new Permission[] { Permission.管理员 },
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.NfcSetView"
});*/
ToggleWindowPath = "Pages.View.UserManagerView"
});

/* UserManager.Add(new SubMenumodel()
{
SubMenuName = "NFC登录设置",
SubMenuPermission = new Permission[] { Permission.管理员 },
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.NfcSetView"
});*/

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


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

@@ -19,4 +19,31 @@
<ProjectReference Include="..\BPASmartClient.S7Net\BPASmartClient.S7Net.csproj" />
</ItemGroup>

<ItemGroup>
<Page Update="View\ChangeDeviceNameView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="View\DeviceListView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="View\DeviceMaterialParView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="View\HardwareStatusView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="View\NewMaterialView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="View\NewRecipeView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="View\RecipeControlView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="View\RecipeSettingsView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
</ItemGroup>

</Project>

+ 31
- 0
BPASmartClient.JXJFoodSmallStation/Model/Converter/DataTableRedundantConverter.cs Voir le fichier

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace BPASmartClient.JXJFoodSmallStation.Converter
{
public class DataTableRedundantConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null && value is bool bit)
{
if (bit)
return new SolidColorBrush(Color.FromArgb(255, 245, 63, 98));
else
return new SolidColorBrush(Color.FromArgb(255, 42, 178, 231));
}
return default;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

+ 68
- 0
BPASmartClient.JXJFoodSmallStation/Model/Converter/RunStatusConvert.cs Voir le fichier

@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace BPASmartClient.JXJFoodSmallStation.Converter
{
public class RunStatusConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is ushort tempValue)
{
if (tempValue == 1) return "等待配料";
if (tempValue == 2) return "配料中";
if (tempValue == 3) return "配料完成";
}
return "等待配料";
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}

public class EnbleConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is ushort tempValue)
{
if (tempValue == 0) return true;
if (tempValue == 1) return false;
}
return true;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}

public class IntToSourceConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is ushort tempValue)
{
if (tempValue == 0) return "本地原料";
if (tempValue == 1) return "设备原料";

}
return "未知";
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}

}

+ 135
- 46
BPASmartClient.JXJFoodSmallStation/Model/DeviceInquire.cs Voir le fichier

@@ -12,6 +12,8 @@ using System.Threading;
using System.Threading.Tasks;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.CustomResource.Pages.Model;
using System.Collections.ObjectModel;
using BPASmartClient.Model;

namespace BPASmartClient.JXJFoodSmallStation.Model
{
@@ -27,10 +29,46 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
List<string> InvalidIP = new List<string>();//无效 IP 集合
List<string> IPLists = new List<string>();//启动 Ping 任务IP集合
ConcurrentQueue<string> IPQueues = new ConcurrentQueue<string>();//pincomplete 完成队列
ConcurrentDictionary<int, DeviceStatus> DeviceLocation = new ConcurrentDictionary<int, DeviceStatus>();

public ObservableCollection<DeviceCurrentStatus> TopDeviceCurrentStatuses { get; set; } = new ObservableCollection<DeviceCurrentStatus>();
public ObservableCollection<DeviceCurrentStatus> BottomDeviceCurrentStatuses { get; set; } = new ObservableCollection<DeviceCurrentStatus>();
public ObservableCollection<Devices> devices { get; set; } = new ObservableCollection<Devices>();
private void DeviceDataInit()
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
for (int i = 0; i < DeviceLists.Count; i++)
{
string deviceName = DeviceLists.ElementAt(i).Value.DeviceName;
int TopIndex = Array.FindIndex(TopDeviceCurrentStatuses.ToArray(), p => p.DeviceName == deviceName);
int BottomIndex = Array.FindIndex(BottomDeviceCurrentStatuses.ToArray(), p => p.DeviceName == deviceName);
if (TopIndex >= 0 && TopIndex < TopDeviceCurrentStatuses.Count)
{
TopDeviceCurrentStatuses.ElementAt(TopIndex).Weight = DeviceLists.ElementAt(i).Value.deviceStatus.WeightFeedback;
TopDeviceCurrentStatuses.ElementAt(TopIndex).DeviceNum = DeviceLists.ElementAt(i).Value.deviceStatus.DeviceNum;
}

if (BottomIndex >= 0 && BottomIndex < BottomDeviceCurrentStatuses.Count)
{
BottomDeviceCurrentStatuses.ElementAt(BottomIndex).Weight = DeviceLists.ElementAt(i).Value.deviceStatus.WeightFeedback;
BottomDeviceCurrentStatuses.ElementAt(BottomIndex).DeviceNum = DeviceLists.ElementAt(i).Value.deviceStatus.DeviceNum;
}

int deviceIndex = Array.FindIndex(devices.ToArray(), p => p.IpAddress == DeviceLists.ElementAt(i).Key);
if (deviceIndex >= 0 && deviceIndex < devices.Count)
{
devices.ElementAt(i).DeviceName = DeviceLists.ElementAt(i).Value.DeviceName;
}
}
Thread.Sleep(200);
}), "设备状态监听");
}

public void Init()
{
devices.Add(new Devices() { DeviceName = "测试", IpAddress = "192.168.0.1" });
IpAddressLines();
DeviceDataInit();
ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (IPQueues.Count >= IPLists.Count)
@@ -54,14 +92,14 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
return new DeviceStatus();
}

public DeviceStatus GetDeviceObject(int location)
public List<DeviceStatus> GetDevice()
{
if (location >= 1 && location <= 15)
List<DeviceStatus> deviceStatuses = new List<DeviceStatus>();
foreach (var device in DeviceLists)
{
var res = DeviceLists.Values.FirstOrDefault(p => p.RawMaterialLocation == location);
if (res != null) return res;
deviceStatuses.Add(device.Value);
}
return new DeviceStatus();
return deviceStatuses;
}

private void IpAddressLines()
@@ -96,20 +134,27 @@ namespace BPASmartClient.JXJFoodSmallStation.Model

DS.modbusTcp.ConnectOk = new Action(() =>
{
string DeviceName = DS.modbusTcp.GetString(DeviceAddress.DeviceName, 20);//读取设备名称
int rawMaterialLocation = DS.modbusTcp.GetAddress(DeviceAddress.Location);
string DeviceName = DS.modbusTcp.GetString(DeviceAddress.DeviceName, 20).Trim()?.Replace(" ", "");//读取设备名称
if (DeviceName.Length > 0)
{
DeviceLists.TryAdd(ip, DS);
DeviceLists[ip].Init(DeviceName, rawMaterialLocation);
DeviceLists[ip].Init(DeviceName);
DeviceLists[ip].modbusTcp.IsReconnect = false;
App.Current.Dispatcher.Invoke(new Action(() =>
{
DeviceListViewModel.devices.Add(new Devices()
{
DeviceName = DeviceName,
IpAddress = ip
});//加入连接的(有名称的)设备列表
//DeviceListViewModel.devices.Add(new Devices()
//{
// DeviceName = DeviceName,
// IpAddress = ip
//});//加入连接的(有名称的)设备列表

devices.Add(new Devices() { DeviceName = DeviceName, IpAddress = ip });

if (TopDeviceCurrentStatuses.Count <= 8)
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName });
else
BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName });


for (int i = 0; i < Json<LocaPar>.Data.Recipes.Count; i++)
{
@@ -118,12 +163,21 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
if (Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp == ip)
{
Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).RawMaterialName = DeviceName;
Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).RawMateriaLocation = rawMaterialLocation;
}
}
}
if (!NewRecipeViewModel.RawMaterialNames.Contains(DeviceName))
NewRecipeViewModel.RawMaterialNames.Add(DeviceName);
if (Global.DeviceRawMaterials.Count > 0)
{
if (Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == DeviceName) == null)
{
Global.DeviceRawMaterials.Add(new RawMaterialModel() { RawMaterialName = DeviceName, DeviceIp = ip, RawMaterialSource = 1 });
}
}
else
{
Global.DeviceRawMaterials.Add(new RawMaterialModel() { RawMaterialName = DeviceName, DeviceIp = ip, RawMaterialSource = 1 });
}

}));
}
else
@@ -141,14 +195,25 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
DS.modbusTcp.Disconnect = new Action(() =>
{
if (InvalidIP.Contains(ip)) InvalidIP.Remove(ip);
var res = DeviceListViewModel.devices.FirstOrDefault(P => P.IpAddress == ip);
if (res != null && DeviceListViewModel.devices.Contains(res))
//var res = DeviceListViewModel.devices.FirstOrDefault(P => P.IpAddress == ip);
var res = devices.FirstOrDefault(P => P.IpAddress == ip);
//if (res != null && DeviceListViewModel.devices.Contains(res))
if (res != null && devices.Contains(res))
{
App.Current.Dispatcher.Invoke(new Action(() =>
{
DeviceListViewModel.devices.Remove(res);
if (NewRecipeViewModel.RawMaterialNames.Contains(res.DeviceName))
NewRecipeViewModel.RawMaterialNames.Remove(res.DeviceName);
//DeviceListViewModel.devices.Remove(res);
devices.Remove(res);
var item = Global.DeviceRawMaterials.FirstOrDefault(P => P.RawMaterialName == res.DeviceName);
if (item != null) Global.DeviceRawMaterials.Remove(item);

var topRes = TopDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == res.DeviceName);
var bottomRes = BottomDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == res.DeviceName);
if (topRes != null) TopDeviceCurrentStatuses.Remove(topRes);
if (bottomRes != null) BottomDeviceCurrentStatuses.Remove(bottomRes);
}));
}

if (DeviceLists.ContainsKey(ip)) DeviceLists[ip].Dispose();
});

@@ -166,35 +231,51 @@ namespace BPASmartClient.JXJFoodSmallStation.Model

public class DeviceStatus
{

#region 对象属性声明
public string DeviceName = String.Empty;
public string IpAddress => modbusTcp.IPAdress;
public bool IsConnected => modbusTcp.Connected;
public int RawMaterialLocation { get; set; }

/// <summary>
/// 设备状态
/// </summary>
public RawMaterialDeviceStatus deviceStatus { get; set; } = new RawMaterialDeviceStatus();



public ModbusTcp modbusTcp = new ModbusTcp();

public bool IsConnected => modbusTcp.Connected;
#endregion
public void Init(string DeviceName,int rawMaterialLocation)

public void Init(string DeviceName)
{
this.DeviceName = DeviceName;
this.RawMaterialLocation = rawMaterialLocation;
AlarmHelper<AlarmInfo>.Init();
if (modbusTcp.Connected)
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
//获取设备运行状态
var res = this.modbusTcp.Read(DeviceAddress.RunStatus);
if (res != null && res is ushort[] ushortValue)
{
if (ushortValue.Length >= 1) deviceStatus.RunStatus = ushortValue[0];
}
//获取设备料仓剩余重量
deviceStatus.WeightFeedback = this.modbusTcp.GetUint(DeviceAddress.WeightFeedback);
deviceStatus.CutWeightFeedback = this.modbusTcp.GetUint(DeviceAddress.CutWeightFeedback);
deviceStatus.RawMaterialType =(ushort) this.modbusTcp.GetUint(DeviceAddress.RawMaterialType);
//var res = this.modbusTcp.Read(DeviceAddress.RunStatus);
//if (res != null && res is ushort[] ushortValue)
//{
// 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.DeviceNum = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceNum);//获取设备编号
deviceStatus.DeviceAlarmCode = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceAlarmCode);//获取设备故障编码

AlarmHelper<AlarmInfo>.Alarm.EStop1 = deviceStatus.DeviceAlarmCode.Get16bitValue(1);
AlarmHelper<AlarmInfo>.Alarm.Servo = deviceStatus.DeviceAlarmCode.Get16bitValue(2);
AlarmHelper<AlarmInfo>.Alarm.Inverter = deviceStatus.DeviceAlarmCode.Get16bitValue(3);
AlarmHelper<AlarmInfo>.Alarm.EStop2 = deviceStatus.DeviceAlarmCode.Get16bitValue(7);
AlarmHelper<AlarmInfo>.Alarm.SiloUpperLimit = deviceStatus.DeviceAlarmCode.Get16bitValue(8);
AlarmHelper<AlarmInfo>.Alarm.SiloLowerLimit = deviceStatus.DeviceAlarmCode.Get16bitValue(9);
Thread.Sleep(100);
}), $"{DeviceName} 开始监听", true);
}
@@ -205,28 +286,36 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
this.modbusTcp.Write(DeviceAddress.DeviceName, new ushort[20]);
this.modbusTcp.SetString(DeviceAddress.DeviceName, name);
}

public void StatusReset()
{
this.modbusTcp.Write(DeviceAddress.RunStatus, (ushort)0);//OutRawMaterialFinish复位出料完成信号
}
public void OutRawMaterialReset()
{
this.modbusTcp.Write(DeviceAddress.OutRawMaterialFinish, (ushort)0);
this.modbusTcp.Write(DeviceAddress.RunStatus, (ushort)0);
}

public void Dispose()
{
ThreadManage.GetInstance().StopTask($"{DeviceName} 开始监听");
}
/// <summary>
/// 设置出料重量,触发出料信号
/// </summary>
/// <param name="Value"></param>
public void Start(uint Value)

public void Start(float Value)
{
if (modbusTcp.Connected)
{
modbusTcp.SetUint(DeviceAddress.WeightSet, Value);//写入配方量
modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方量
modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入
//配料设备参数写入
var res = Json<DevicePar>.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName);
if (res != null)
{
modbusTcp.SetReal(DeviceAddress.SlowlyAddWeight, res.SlowlyAddWeight);
modbusTcp.SetReal(DeviceAddress.PreCloseValveWeight, res.PreCloseValveWeight);
modbusTcp.SetUint(DeviceAddress.RapidAcceleration, (uint)res.RapidAcceleration);
modbusTcp.SetUint(DeviceAddress.SlowAcceleration, (uint)res.SlowAcceleration);
modbusTcp.SetUint(DeviceAddress.ServoManualSpeed, (uint)res.ServoManualSpeed);
modbusTcp.SetUint(DeviceAddress.SiloUpperLimitWeight, (uint)res.SiloUpperLimitWeight);
modbusTcp.SetUint(DeviceAddress.LowerLimitWeightOfSilo, (uint)res.LowerLimitWeightOfSilo);
modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed);
}
}
}
}


+ 6
- 5
BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs Voir le fichier

@@ -97,14 +97,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
SmallStation.RecipeQueue.Clear();
Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
//Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
ThreadManage.GetInstance().StartLong(new Action(() =>
{
ReceviceData();
RecipeInfoToHKPLC();
Thread.Sleep(10);
}), "流程处理", true);
ThreadManage.GetInstance().StartLong(new Action(() => {
ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (SiemensDevice.IsConnected && HKDevice.IsConnected)
{
AgvGetInDelivery();
@@ -246,13 +247,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
double weight = SmallStation.RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
if (loc_index >= 1 && loc_index <= 15)
{
DeviceInquire.GetInstance.GetDeviceObject(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
//DeviceInquire.GetInstance.GetDeviceObject(loc_index)?.Start((uint)weight);//启动并写入每个原料重量
SmallStation.StockInIsWork = loc_index;
HKDevice.StockStateSignReset();
}
}
}
if (RTrig.GetInstance("OutRawMaterialFinish").Start(DeviceInquire.GetInstance.GetDeviceObject(SmallStation.StockInIsWork).modbusTcp.Read(DeviceAddress.OutRawMaterialFinish) is bool))
/*if (RTrig.GetInstance("OutRawMaterialFinish").Start(DeviceInquire.GetInstance.GetDeviceObject(SmallStation.StockInIsWork).modbusTcp.Read(DeviceAddress.OutRawMaterialFinish) is bool))
{
HKDevice.SingleDosing((uint)SmallStation.StockInIsWork);
DeviceInquire.GetInstance.GetDeviceObject(SmallStation.StockInIsWork).OutRawMaterialReset();
@@ -262,7 +263,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
HKDevice.RecipeDosingFinishReset();
SmallStation.RecipeQueue.TryDequeue(out code);
Json<RemoteRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
}
}*/
}
}
}


+ 48
- 0
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/AlarmInfo.cs Voir le fichier

@@ -0,0 +1,48 @@
using BPASmartClient.CustomResource.Pages.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodSmallStation.Model
{
public class AlarmInfo
{
/// <summary>
/// 1#急停
/// </summary>
[Alarm("1#急停")]
public bool EStop1 { get; set; }

/// <summary>
/// 伺服故障
/// </summary>
[Alarm("伺服故障")]
public bool Servo { get; set; }

/// <summary>
/// 变频器故障
/// </summary>
[Alarm("变频器故障")]
public bool Inverter { get; set; }

/// <summary>
/// 2#急停
/// </summary>
[Alarm("2#急停")]
public bool EStop2 { get; set; }

/// <summary>
/// 料仓上限
/// </summary>
[Alarm("料仓上限")]
public bool SiloUpperLimit { get; set; }

/// <summary>
/// 料仓下限
/// </summary>
[Alarm("料仓下限")]
public bool SiloLowerLimit { get; set; }
}
}

+ 57
- 61
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs Voir le fichier

@@ -8,95 +8,91 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
public class DeviceAddress
{
#region 源地址
///// <summary>
///// 设备名称起始地址
///// </summary>
//public static string DeviceName { get; set; } = "LW0";

///// <summary>
///// 料仓重量反馈起始地址
///// </summary>
//public static string WeightFeedback { get; set; } = "LW52";//LW204
/// <summary>
/// 设备名称起始地址
/// </summary>
public static string DeviceName { get; set; } = "LW0";

///// <summary>
///// 重量设置地址
///// </summary>
//public static string WeightSet { get; set; } = "LW21";//LW200
/// <summary>
/// 料仓重量反馈起始地址
/// </summary>
public static string WeightFeedback { get; set; } = "LW52";

///// <summary>
///// 启动信号地址
///// </summary>
//public static string Start { get; set; } = "LW20";//LW210
/// <summary>
/// 重量设置地址
/// </summary>
public static string WeightSet { get; set; } = "LW21";

///// <summary>
///// 下料重量反馈地址
///// </summary>
//public static string CutWeightFeedback { get; set; } = "LW54";//LW202
/// <summary>
/// 启动信号地址
/// </summary>
public static string Start { get; set; } = "LW20";

///// <summary>
///// 设备运行状态地址
///// </summary>
//public static string RunStatus { get; set; } = "LW55";//LW206
/// <summary>
/// 下料重量反馈地址
/// </summary>
public static string CutWeightFeedback { get; set; } = "LW54";

///// <summary>
///// 料仓的位置
///// </summary>
//public static string Location { get; set; } = "LW53";
#endregion
/// <summary>
/// 设备编号
/// </summary>
public static string DeviceNum { get; set; } = "LW57";

#region 上位机下发
/// <summary>
/// 原料出料重量
/// 设备故障编码
/// </summary>
public static string WeightSet { get; set; } = "LW11";
public static string DeviceAlarmCode { get; set; } = "LW51";

/// <summary>
/// 启动开始配料
/// 原料设备类型
/// 1:膏体,2:液体,3:粉体
/// </summary>
public static string Start { get; set; } = "LW12";
#endregion
#region 上位机读取
public static string MaterialDeviceType { get; set; } = "LW56";

/// <summary>
/// 设备运行状态地址
/// </summary>
public static string RunStatus { get; set; } = "LW50";
public static string RunStatus { get; set; } = "LW60";

/// <summary>
/// 报警字
/// 慢加重量
/// </summary>
public static string AlarmInfo { get; set; } = "LW51";
public static string SlowlyAddWeight { get; set; } = "LW23";

/// <summary>
/// 原料名称
/// 提前关阀重量
/// </summary>
public static string DeviceName { get; set; } = "LW52";
public static string PreCloseValveWeight { get; set; } = "LW25";

/// <summary>
/// 料仓的位置
/// 快加速度
/// </summary>
public static string Location { get; set; } = "LW53";
public static string RapidAcceleration { get; set; } = "LW27";

/// <summary>
/// 原料类型
/// 慢加速度
/// </summary>
public static string RawMaterialType { get; set; } = "LW54";
public static string SlowAcceleration { get; set; } = "LW29";

/// <summary>
/// 出料完成信号
/// 伺服手动速度
/// </summary>
public static string OutRawMaterialFinish { get; set; } = "LW55";
public static string ServoManualSpeed { get; set; } = "LW31";

/// <summary>
/// 料仓重量反馈起始地址
/// 料仓上限重量
/// </summary>
public static string WeightFeedback { get; set; } = "LW56";
public static string SiloUpperLimitWeight { get; set; } = "LW33";

/// <summary>
/// 料重量反馈地址
/// 料仓下限重量
/// </summary>
public static string CutWeightFeedback { get; set; } = "LW57";
#endregion



public static string LowerLimitWeightOfSilo { get; set; } = "LW35";

/// <summary>
/// 搅拌速度
/// </summary>
public static string StirringSpeed { get; set; } = "LW37";
}




BPASmartClient.JXJFoodSmallStation/Model/DeviceCurrentStatus.cs → BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceCurrentStatus.cs Voir le fichier

@@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;

namespace BPASmartClient.JXJFoodSmallStation.Model
namespace BPASmartClient.JXJFoodSmallStation
{
public class DeviceCurrentStatus : ObservableObject
{
@@ -18,6 +18,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
private bool _mRunStatus;


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

public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } }
private string _mDeviceName;


+ 15
- 0
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs Voir le fichier

@@ -0,0 +1,15 @@
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;

namespace BPASmartClient.JXJFoodSmallStation
{
public class DevicePar
{
public ObservableCollection<DeviceParModel> deviceParModels { get; set; } = new ObservableCollection<DeviceParModel>();
}
}

+ 75
- 0
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceParModel.cs Voir le fichier

@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;

namespace BPASmartClient.JXJFoodSmallStation
{
public class DeviceParModel : ObservableObject
{
/// <summary>
/// 原料名称
/// </summary>
public string MaterialName { get { return _mMaterialName; } set { _mMaterialName = value; OnPropertyChanged(); } }
private string _mMaterialName = string.Empty;

/// <summary>
/// 慢加重量
/// </summary>
public float SlowlyAddWeight { get { return _mSlowlyAddWeight; } set { _mSlowlyAddWeight = value; OnPropertyChanged(); } }
private float _mSlowlyAddWeight;

/// <summary>
/// 提前关阀重量
/// </summary>
public float PreCloseValveWeight { get { return _mPreCloseValveWeight; } set { _mPreCloseValveWeight = value; OnPropertyChanged(); } }
private float _mPreCloseValveWeight;

/// <summary>
/// 快加速度
/// </summary>
public int RapidAcceleration { get { return _mRapidAcceleration; } set { _mRapidAcceleration = value; OnPropertyChanged(); } }
private int _mRapidAcceleration;

/// <summary>
/// 慢加速度
/// </summary>
public int SlowAcceleration { get { return _mSlowAcceleration; } set { _mSlowAcceleration = value; OnPropertyChanged(); } }
private int _mSlowAcceleration;

/// <summary>
/// 伺服手动速度
/// </summary>
public int ServoManualSpeed { get { return _mServoManualSpeed; } set { _mServoManualSpeed = value; OnPropertyChanged(); } }
private int _mServoManualSpeed;

/// <summary>
/// 料仓上限重量
/// </summary>
public int SiloUpperLimitWeight { get { return _mSiloUpperLimitWeight; } set { _mSiloUpperLimitWeight = value; OnPropertyChanged(); } }
private int _mSiloUpperLimitWeight;

/// <summary>
/// 料仓下限重量
/// </summary>
public int LowerLimitWeightOfSilo { get { return _mLowerLimitWeightOfSilo; } set { _mLowerLimitWeightOfSilo = value; OnPropertyChanged(); } }
private int _mLowerLimitWeightOfSilo;

/// <summary>
/// 搅拌速度
/// </summary>
public int StirringSpeed { get { return _mStirringSpeed; } set { _mStirringSpeed = value; OnPropertyChanged(); } }
private int _mStirringSpeed;

/// <summary>
/// 是否重复
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public bool IsRedundant { get { return _mIsRedundant; } set { _mIsRedundant = value; OnPropertyChanged(); } }
private bool _mIsRedundant;


}
}

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff

Chargement…
Annuler
Enregistrer