@@ -0,0 +1,43 @@ | |||
<Application | |||
x:Class="BPASmart.DataServer.App" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters;assembly=BPASmartClient.CustomResource" | |||
xmlns:local="clr-namespace:BPASmart.DataServer"> | |||
<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" /> | |||
<!--<locaCon:DataTableRedundantConverter x:Key="tabConvert" /> | |||
<locaCon:TextDisplayConvert x:Key="textDisplayConvert" /> | |||
<locaCon:DiscreteAlarmConvert x:Key="discreteAlarmConvert" /> | |||
<locaCon:AnalogAlarmConvert x:Key="analogAlarmConvert" /> | |||
<locaCon:IsEnableConvert x:Key="IsEnableConvert" />--> | |||
<SolidColorBrush x:Key="PoupTextblockColor" Color="#009dff" /> | |||
<SolidColorBrush x:Key="tabColor" Color="#FF2AB2E7" /> | |||
<SolidColorBrush x:Key="bordColor" Color="#332AB2E7" /> | |||
</ResourceDictionary> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
</Application.Resources> | |||
</Application> |
@@ -0,0 +1,94 @@ | |||
using BPASmartClient.CustomResource.Pages.Enums; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.CustomResource.Pages.View; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Model; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Configuration; | |||
using System.Data; | |||
using System.Linq; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using BPASmart.Server; | |||
using BPASmartClient.CustomResource.Pages.ViewModel; | |||
namespace BPASmart.DataServer | |||
{ | |||
/// <summary> | |||
/// Interaction logic for App.xaml | |||
/// </summary> | |||
public partial class App : Application | |||
{ | |||
public static Window MainWindow; | |||
protected override void OnStartup(StartupEventArgs e) | |||
{ | |||
base.OnStartup(e); | |||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; | |||
MenuInit(); | |||
MainView mv = new MainView(); | |||
mv.WindowState = WindowState.Normal; | |||
MainWindow = mv; | |||
mv.Show(); | |||
BPASmart.Server.Main.GetInstance.Init(); | |||
} | |||
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) | |||
{ | |||
//数据服务中心异常退出后自动重启 | |||
} | |||
protected override void OnExit(ExitEventArgs e) | |||
{ | |||
base.OnExit(e); | |||
} | |||
private void MenuInit() | |||
{ | |||
#region 消息中心 | |||
ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>(); | |||
InfoLog.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "消息日志", | |||
AssemblyName = "BPASmartClient.CustomResource", | |||
ToggleWindowPath = "Pages.View.DebugLogView", | |||
SubMenuVisibility = Visibility.Visible, | |||
}); | |||
MenuManage.GetInstance.menuModels.Add(new MenuModel() | |||
{ | |||
MainMenuIcon = "", | |||
MainMenuName = "消息中心", | |||
Alias = "Device Management", | |||
subMenumodels = InfoLog, | |||
}); | |||
#endregion | |||
} | |||
private SubMenumodel AddSubMenuModel(string s) | |||
{ | |||
return new SubMenumodel() | |||
{ | |||
SubMenuName = s, | |||
AssemblyName = "BPASmart.VariableManager", | |||
ToggleWindowPath = "Views.VariableConfig", | |||
SubMenuVisibility = Visibility.Visible, | |||
}; | |||
} | |||
private void DataSave() | |||
{ | |||
} | |||
private void DataRead() | |||
{ | |||
Json<CommunicationPar>.Read(); | |||
} | |||
} | |||
} |
@@ -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) | |||
)] |
@@ -0,0 +1,15 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<OutputType>WinExe</OutputType> | |||
<TargetFramework>net6.0-windows</TargetFramework> | |||
<Nullable>enable</Nullable> | |||
<UseWPF>true</UseWPF> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmart.Server\BPASmart.Server.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,36 @@ | |||
using BPASmart.Model; | |||
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.Model | |||
{ | |||
public class AlarmSet : NoticeBase | |||
{ | |||
/// <summary> | |||
/// 报警标签 | |||
/// </summary> | |||
public string AlarmTag { get { return _mAlarmTag; } set { _mAlarmTag = value; OnPropertyChanged(); } } | |||
private string _mAlarmTag = string.Empty; | |||
public EAlarmType AlarmType { get { return _mAlarmType; } set { _mAlarmType = value; OnPropertyChanged(); } } | |||
private EAlarmType _mAlarmType; | |||
/// <summary> | |||
/// 模拟量报警信息 | |||
/// </summary> | |||
public ObservableCollection<AnalogAlarmModel> AnalogAlarmModels { get; set; } = new ObservableCollection<AnalogAlarmModel>(); | |||
/// <summary> | |||
/// 离散量报警信息 | |||
/// </summary> | |||
public DiscreteAlarmInfo DiscreteAlarmInfoSet { get { return _mDiscreteAlarmInfoSet; } set { _mDiscreteAlarmInfoSet = value; OnPropertyChanged(); } } | |||
private DiscreteAlarmInfo _mDiscreteAlarmInfoSet = new DiscreteAlarmInfo(); | |||
} | |||
} |
@@ -0,0 +1,54 @@ | |||
using BPASmart.Model; | |||
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.Model | |||
{ | |||
/// <summary> | |||
/// 模拟量报警模块 | |||
/// </summary> | |||
public class AnalogAlarmModel : NoticeBase | |||
{ | |||
/// <summary> | |||
/// 设定报警值 | |||
/// </summary> | |||
public int AlarmValue { get { return _mAlarmValue; } set { _mAlarmValue = value; OnPropertyChanged(); } } | |||
private int _mAlarmValue = 0; | |||
/// <summary> | |||
/// 是否启用该报警 | |||
/// </summary> | |||
public bool IsEnable { get { return _mIsEnable; } set { _mIsEnable = value; OnPropertyChanged(); } } | |||
private bool _mIsEnable; | |||
/// <summary> | |||
/// 报警信息 | |||
/// </summary> | |||
public string AlarmInfo { get { return _mAlarmInfo; } set { _mAlarmInfo = value; OnPropertyChanged(); } } | |||
private string _mAlarmInfo = string.Empty; | |||
/// <summary> | |||
/// 报警标签 | |||
/// </summary> | |||
public string AlarmTag { get { return _mAlarmTag; } set { _mAlarmTag = value; OnPropertyChanged(); } } | |||
private string _mAlarmTag = string.Empty; | |||
/// <summary> | |||
/// 排序标签 | |||
/// </summary> | |||
public EAnalogAlarmType SortTag { get { return _mSortTag; } set { _mSortTag = value; OnPropertyChanged(); } } | |||
private EAnalogAlarmType _mSortTag; | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<ImplicitUsings>enable</ImplicitUsings> | |||
<Nullable>enable</Nullable> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" /> | |||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | |||
<PackageReference Include="System.IO.Ports" Version="6.0.0" /> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,66 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
public class AddressConvert | |||
{ | |||
private volatile static AddressConvert _Instance; | |||
public static AddressConvert GetInstance => _Instance ?? (_Instance = new AddressConvert()); | |||
private AddressConvert() { } | |||
public string PlcConverter(ICommunicationDevice device, string Address) | |||
{ | |||
string address = string.Empty; | |||
//if (Address != null && int.TryParse(Address, out int result)) return result; | |||
if (device != null && Address != null && Address.Length > 0) | |||
{ | |||
switch (device) | |||
{ | |||
case Invoance _tempInvoance: | |||
if (Address.ToUpper().Contains("LW") && Address.Length >= 3) | |||
{ | |||
var res = Address.Substring(2); | |||
if (res != null && int.TryParse(res, out int LwAddress)) return LwAddress.ToString(); | |||
} | |||
break; | |||
case kinco _tempKinco: | |||
if (Address.ToUpper().Contains("M") && Address.Length >= 4) | |||
{ | |||
var res = Address.Substring(1).Split('.'); | |||
if (res != null && res.Length == 2) | |||
{ | |||
if (int.TryParse(res[0], out int firstAddress) && int.TryParse(res[1], out int ExitAddress)) | |||
{ | |||
if (ExitAddress >= 0 && ExitAddress <= 7) | |||
{ | |||
return ((firstAddress * 8) + 320 + ExitAddress).ToString(); | |||
} | |||
} | |||
} | |||
} | |||
else if ((Address.ToUpper().Contains("VW") || Address.ToUpper().Contains("VD")) && Address.Length >= 3) | |||
{ | |||
var res = Address.Substring(2); | |||
if (res != null && int.TryParse(res, out int tempAddress)) return ((tempAddress / 2) + 100).ToString(); | |||
} | |||
break; | |||
case KincoOneMachine _tempKincoOneMachine: | |||
if (Address.ToUpper().Contains("D") && Address.Length >= 2) | |||
{ | |||
var res = Address.Substring(1); | |||
if (res != null && int.TryParse(res, out int LwAddress)) return LwAddress.ToString(); | |||
} | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
return address; | |||
} | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
/// <summary> | |||
/// 汇川PLC | |||
/// </summary> | |||
public class Invoance : ModbusTcp | |||
{ | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
/// <summary> | |||
/// 步科一体机 | |||
/// </summary> | |||
public class KincoOneMachine : ModbusTcp | |||
{ | |||
} | |||
} |
@@ -0,0 +1,47 @@ | |||
using BPASmart.Model; | |||
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.Model | |||
{ | |||
public class ModbusRtu : ICommunicationDevice | |||
{ | |||
/// <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; } | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
namespace BPASmart.Model | |||
{ | |||
public class ModbusTcp : ICommunicationDevice | |||
{ | |||
/// <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; | |||
} | |||
} |
@@ -0,0 +1,43 @@ | |||
using BPASmart.Model; | |||
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.Model | |||
{ | |||
public class Siemens : ICommunicationDevice | |||
{ | |||
/// <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; } | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
/// <summary> | |||
/// 步科PLC | |||
/// </summary> | |||
public class kinco : ModbusTcp | |||
{ | |||
} | |||
} |
@@ -0,0 +1,48 @@ | |||
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.Model | |||
{ | |||
public class CommunicationModel : NoticeBase | |||
{ | |||
/// <summary> | |||
/// 通讯设备 | |||
/// </summary> | |||
[JsonProperty(TypeNameHandling = TypeNameHandling.Auto)] | |||
public ICommunicationDevice CommDevice { get { return _mCommDevice; } set { _mCommDevice = value; OnPropertyChanged(); } } | |||
private ICommunicationDevice _mCommDevice; | |||
/// <summary> | |||
/// 是否激活 | |||
/// </summary> | |||
public bool IsActive { get { return _mIsActive; } set { _mIsActive = value; OnPropertyChanged(); } } | |||
private bool _mIsActive = true; | |||
/// <summary> | |||
/// 新增设备名称 | |||
/// </summary> | |||
public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } } | |||
private string _mDeviceName; | |||
/// <summary> | |||
/// 通讯模块名称 | |||
/// </summary> | |||
public string ModelName { get { return _mModelName; } set { _mModelName = value; OnPropertyChanged(); } } | |||
private string _mModelName; | |||
/// <summary> | |||
/// 变量表数据 | |||
/// </summary> | |||
public ObservableCollection<VariableInfo> VarTableModels { get; set; } = new ObservableCollection<VariableInfo>(); | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Collections.ObjectModel; | |||
namespace BPASmart.Model | |||
{ | |||
public class CommunicationPar | |||
{ | |||
public ObservableCollection<CommunicationModel> CommunicationDevices { get; set; } = new ObservableCollection<CommunicationModel>(); | |||
} | |||
} |
@@ -0,0 +1,41 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
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; } | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
public class DeviceManagermentResult | |||
{ | |||
public string DeviceType { get; set; } | |||
public string DeviceName { get; set; } | |||
} | |||
} |
@@ -0,0 +1,30 @@ | |||
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.Model; | |||
namespace BPASmart.Model | |||
{ | |||
/// <summary> | |||
/// 离散量报警信息 | |||
/// </summary> | |||
public class DiscreteAlarmInfo : NoticeBase | |||
{ | |||
/// <summary> | |||
/// 沿报警(上升沿,下降沿) | |||
/// </summary> | |||
public string TrigAlarm { get { return _mTrigAlarm; } set { _mTrigAlarm = value; OnPropertyChanged(); } } | |||
private string _mTrigAlarm = string.Empty; | |||
/// <summary> | |||
/// 报警信息 | |||
/// </summary> | |||
public string AlarmInfo { get { return _mAlarmInfo; } set { _mAlarmInfo = value; OnPropertyChanged(); } } | |||
private string _mAlarmInfo = string.Empty; | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
public enum DisplayFormat | |||
{ | |||
二进制, | |||
十进制, | |||
十六进制, | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
/// <summary> | |||
/// 报警类型 | |||
/// </summary> | |||
public enum EAlarmType | |||
{ | |||
/// <summary> | |||
/// 无报警 | |||
/// </summary> | |||
无 = 1, | |||
/// <summary> | |||
/// 模拟量报警 | |||
/// </summary> | |||
模拟量报警 = 2, | |||
/// <summary> | |||
/// 离散量报警 | |||
/// </summary> | |||
离散量报警 = 3 | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
/// <summary> | |||
/// 沿触发类型枚举 | |||
/// </summary> | |||
public enum EAlongTriggerType | |||
{ | |||
/// <summary> | |||
/// 下降沿触发 | |||
/// </summary> | |||
下降沿 = 1, | |||
/// <summary> | |||
/// 上升沿触发 | |||
/// </summary> | |||
上升沿 = 2 | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
/// <summary> | |||
/// 模拟量报警类型 | |||
/// </summary> | |||
public enum EAnalogAlarmType | |||
{ | |||
高高报警 = 1, | |||
高报警 = 2, | |||
低报警 = 3, | |||
低低报警 = 4, | |||
} | |||
} |
@@ -0,0 +1,22 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
/// <summary> | |||
/// 数据类型枚举 | |||
/// </summary> | |||
public enum EDataType | |||
{ | |||
Bool = 1, | |||
Byte = 2, | |||
Int = 3, | |||
Word = 4, | |||
Dint = 5, | |||
Dword = 6, | |||
Float = 7 | |||
} | |||
} |
@@ -0,0 +1,16 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
public enum EDeviceType | |||
{ | |||
Siemens, | |||
ModbusRtu, | |||
ModbusTcp, | |||
SerialPort, | |||
} | |||
} |
@@ -0,0 +1,39 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
/// <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 | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
public enum EParity | |||
{ | |||
无, | |||
奇校验, | |||
偶校验 | |||
} | |||
} |
@@ -0,0 +1,16 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
public enum ESiemensPlcType | |||
{ | |||
S1200, | |||
S1500, | |||
S300_400, | |||
S200_Smart | |||
} | |||
} |
@@ -0,0 +1,12 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
public interface ICommunicationDevice | |||
{ | |||
} | |||
} |
@@ -0,0 +1,13 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
public interface IServer | |||
{ | |||
void Init(); | |||
} | |||
} |
@@ -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.Model | |||
{ | |||
public class NoticeBase : ObservableObject | |||
{ | |||
} | |||
} |
@@ -0,0 +1,13 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
public class PublishInfo | |||
{ | |||
public List<PublishModel> PublishModels { get; set; } = new List<PublishModel>(); | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
public class PublishModel | |||
{ | |||
public string DeviceName { get; set; } | |||
public string RealAddress { get; set; } | |||
public string Value { get; set; } | |||
public EDataType DataType { get; set; } | |||
public int Sleep { get; set; } | |||
} | |||
} |
@@ -0,0 +1,17 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
public class ReadDataModel | |||
{ | |||
public ushort StartAddress { get; set; } | |||
public ushort Length { get; set; } | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
public class ReeisDataModel | |||
{ | |||
public string VarName { get; set; } | |||
public string VarVaule { get; set; } | |||
} | |||
} |
@@ -0,0 +1,151 @@ | |||
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.Model; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Newtonsoft.Json; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using System.Reflection; | |||
namespace BPASmart.Model | |||
{ | |||
public class VariableInfo : AlarmSet | |||
{ | |||
private ICommunicationDevice DeviceType; | |||
public VariableInfo(params object[] s) | |||
{ | |||
if (s != null && s.Length >= 0) | |||
{ | |||
DeviceType = s[0] as ICommunicationDevice; | |||
} | |||
CancelCommand = new RelayCommand(() => { IsOpen = false; }); | |||
ConfirmCommand = new RelayCommand(() => { IsOpen = false; }); | |||
} | |||
public int ID { get { return _mID; } set { _mID = value; OnPropertyChanged(); } } | |||
private int _mID; | |||
/// <summary> | |||
/// 变量名 | |||
/// </summary> | |||
public string VarName | |||
{ | |||
get { return _mVarName.Trim()?.Replace(" ", ""); } | |||
set | |||
{ | |||
_mVarName = value; | |||
OnPropertyChanged(); | |||
DelegationNotifi.GetInstance.VarNameChanged?.Invoke(_mID); | |||
} | |||
} | |||
private string _mVarName = string.Empty; | |||
/// <summary> | |||
/// 地址 | |||
/// </summary> | |||
public string Address | |||
{ | |||
get { return _mAddress.Trim()?.Replace(" ", "").ToUpper(); } | |||
set | |||
{ | |||
_mAddress = value; | |||
OnPropertyChanged(); | |||
string address = AddressConvert.GetInstance.PlcConverter(DeviceType, value); | |||
if (address.Length > 0) RealAddress = address; | |||
} | |||
} | |||
private string _mAddress = string.Empty; | |||
/// <summary> | |||
/// 实际地址 | |||
/// </summary> | |||
public string RealAddress { get; set; } | |||
/// <summary> | |||
/// 数据类型 | |||
/// </summary> | |||
public string DataType { get { return _mDataType; } set { _mDataType = value; OnPropertyChanged(); } } | |||
private string _mDataType = string.Empty; | |||
/// <summary> | |||
/// 是否启用报警 | |||
/// </summary> | |||
public bool IsEnableAlarm { get { return _mIsEnableAlarm; } set { _mIsEnableAlarm = value; OnPropertyChanged(); } } | |||
private bool _mIsEnableAlarm; | |||
/// <summary> | |||
/// 是否显示报警设置框 | |||
/// </summary> | |||
public bool IsOpen | |||
{ | |||
get { return _mIsOpen; } | |||
set | |||
{ | |||
_mIsOpen = value; | |||
OnPropertyChanged(); | |||
if (value) | |||
{ | |||
if (DataType != "Bool") | |||
{ | |||
AlarmType = EAlarmType.模拟量报警; | |||
if (AnalogAlarmModels == null || AnalogAlarmModels.Count <= 0) | |||
{ | |||
AnalogAlarmModels.Clear(); | |||
foreach (var item in Enum.GetNames(typeof(EAnalogAlarmType))) | |||
{ | |||
if (AnalogAlarmModels.FirstOrDefault(p => p.AlarmTag == item) == null) | |||
{ | |||
AnalogAlarmModels.Add(new AnalogAlarmModel() | |||
{ | |||
AlarmTag = item, | |||
SortTag = (EAnalogAlarmType)Enum.Parse(typeof(EAnalogAlarmType), item) | |||
}); | |||
} | |||
} | |||
} | |||
} | |||
else | |||
{ | |||
AlarmType = EAlarmType.离散量报警; | |||
} | |||
} | |||
} | |||
} | |||
private bool _mIsOpen; | |||
/// <summary> | |||
/// 当前值 | |||
/// </summary> | |||
[Newtonsoft.Json.JsonIgnore] | |||
public string CurrentValue { get { return _mCurrentValue; } set { _mCurrentValue = value; OnPropertyChanged(); } } | |||
private string _mCurrentValue = string.Empty; | |||
/// <summary> | |||
/// 验证是否OK | |||
/// </summary> | |||
public bool IsRedundant { get { return _mIsRedundant; } set { _mIsRedundant = value; OnPropertyChanged(); } } | |||
private bool _mIsRedundant; | |||
/// <summary> | |||
/// 报警设置框取消操作 | |||
/// </summary> | |||
[Newtonsoft.Json.JsonIgnore] | |||
public RelayCommand CancelCommand { get; set; } | |||
/// <summary> | |||
/// 报警设置框确认按钮 | |||
/// </summary> | |||
[Newtonsoft.Json.JsonIgnore] | |||
public RelayCommand ConfirmCommand { get; set; } | |||
} | |||
} |
@@ -0,0 +1,20 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<ImplicitUsings>enable</ImplicitUsings> | |||
<Nullable>enable</Nullable> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Communication" Version="1.0.10" /> | |||
<PackageReference Include="BPA.Helper" Version="1.0.6" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmart.Model\BPASmart.Model.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Message\BPASmartClient.Message.csproj" /> | |||
<ProjectReference Include="..\Communication\Communication.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,263 @@ | |||
using BPASmart.Model; | |||
using BPA.Helper; | |||
using BPA.Communication; | |||
using Microsoft.EntityFrameworkCore.Metadata.Conventions; | |||
using Communication; | |||
using System.Collections.Concurrent; | |||
using Newtonsoft.Json; | |||
namespace BPASmart.Server | |||
{ | |||
internal class CommunicationServer : IServer | |||
{ | |||
ConcurrentDictionary<string, ICommunication> CommunicationDevices = new ConcurrentDictionary<string, ICommunication>(); | |||
public void Init() | |||
{ | |||
var tt = sizeof(bool); | |||
BPASmartClient.Message.MessageLog.GetInstance.ShowDebugLog("通讯模块初始化"); | |||
RedisHelper.GetInstance.ConnectAsync(); | |||
MqttInit(); | |||
Json<CommunicationPar>.Data.CommunicationDevices.ToList()?.ForEach(item => | |||
{ | |||
ThreadManage.GetInstance().Start(new Action(() => | |||
{ | |||
switch (item.CommDevice) | |||
{ | |||
case BPASmart.Model.ModbusRtu _modbusRtu: | |||
break; | |||
case BPASmart.Model.ModbusTcp _modbusTcp: | |||
BPA.Communication.ModbusTcp modbusTcpMaster = new BPA.Communication.ModbusTcp(); | |||
modbusTcpMaster.ConnectOk = new Action(() => | |||
{ | |||
if (!CommunicationDevices.ContainsKey(item.DeviceName)) | |||
CommunicationDevices.TryAdd(item.DeviceName, modbusTcpMaster); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
GetReadDataModels(item).ToList()?.ForEach(temp => | |||
{ | |||
switch (temp.Key) | |||
{ | |||
case EDataType.Bool: | |||
temp.Value?.ForEach(value => | |||
{ | |||
var res = modbusTcpMaster.ReadBool(value.StartAddress.ToString(), value.Length); | |||
SetValue(res.Content, item.DeviceName, value, 1); | |||
}); | |||
break; | |||
case EDataType.Byte: | |||
break; | |||
case EDataType.Int: | |||
break; | |||
case EDataType.Word: | |||
temp.Value?.ForEach(value => | |||
{ | |||
var res = modbusTcpMaster.ReadUshort(value.StartAddress.ToString(), value.Length); | |||
SetValue(res.Content, item.DeviceName, value, 1); | |||
}); | |||
break; | |||
case EDataType.Dint: | |||
break; | |||
case EDataType.Dword: | |||
temp.Value?.ForEach(value => | |||
{ | |||
var res = modbusTcpMaster.ReadUint(value.StartAddress.ToString(), value.Length); | |||
SetValue(res.Content, item.DeviceName, value, 2); | |||
}); | |||
break; | |||
case EDataType.Float: | |||
temp.Value?.ForEach(value => | |||
{ | |||
var res = modbusTcpMaster.ReadFloat(value.StartAddress.ToString(), value.Length); | |||
SetValue(res.Content, item.DeviceName, value, 2); | |||
}); | |||
break; | |||
default: | |||
break; | |||
} | |||
}); | |||
Thread.Sleep(100); | |||
}), $"{item.DeviceName} 设备数据采集"); | |||
var DeviceModel = item; | |||
}); | |||
modbusTcpMaster.IsReconnect = true; | |||
modbusTcpMaster.ModbusTcpConnect(_modbusTcp.IP, _modbusTcp.PortNum); | |||
break; | |||
case BPASmart.Model.Siemens _siemens: | |||
break; | |||
default: | |||
break; | |||
} | |||
}), $"{item.DeviceName} 初始化连接"); | |||
}); | |||
} | |||
ConcurrentQueue<string> msg = new ConcurrentQueue<string>(); | |||
private void MqttInit() | |||
{ | |||
MqttHelper mqttHelper = new MqttHelper(); | |||
mqttHelper.Connect("admin", "fengyoufu067101!@#", "124.222.238.75", 61613, $"分布式上位机:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); | |||
mqttHelper.ConnectOk = new Action(() => | |||
{ | |||
mqttHelper.Subscrib("DistributedHostComputer/Control"); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
while (msg.Count > 0) | |||
{ | |||
DeviceControl(); | |||
} | |||
Thread.Sleep(100); | |||
}), "MQTT 消息监听"); | |||
}); | |||
mqttHelper.MessageRecive = new Action<string>((s) => | |||
{ | |||
msg.Enqueue(s); | |||
}); | |||
} | |||
private void DeviceControl() | |||
{ | |||
if (msg.TryDequeue(out string s)) | |||
{ | |||
var res = JsonConvert.DeserializeObject<PublishInfo>(s); | |||
if (res != null) | |||
{ | |||
res.PublishModels.ForEach(item => | |||
{ | |||
if (CommunicationDevices.ContainsKey(item.DeviceName)) | |||
{ | |||
switch (item.DataType) | |||
{ | |||
case EDataType.Bool: | |||
CommunicationDevices[item.DeviceName].Write(item.RealAddress, Convert.ToBoolean(item.Value)); | |||
break; | |||
case EDataType.Byte: | |||
CommunicationDevices[item.DeviceName].Write(item.RealAddress, Convert.ToByte(item.Value)); | |||
break; | |||
case EDataType.Int: | |||
CommunicationDevices[item.DeviceName].Write(item.RealAddress, Convert.ToInt16(item.Value)); | |||
break; | |||
case EDataType.Word: | |||
CommunicationDevices[item.DeviceName].Write(item.RealAddress, Convert.ToUInt16(item.Value)); | |||
break; | |||
case EDataType.Dint: | |||
CommunicationDevices[item.DeviceName].Write(item.RealAddress, Convert.ToInt32(item.Value)); | |||
break; | |||
case EDataType.Dword: | |||
CommunicationDevices[item.DeviceName].Write(item.RealAddress, Convert.ToUInt32(item.Value)); | |||
break; | |||
case EDataType.Float: | |||
CommunicationDevices[item.DeviceName].Write(item.RealAddress, Convert.ToSingle(item.Value)); | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
}); | |||
} | |||
} | |||
} | |||
private void SetValue<TArray>(TArray[] arrays, string DeviceName, ReadDataModel readDataModel, ushort by) | |||
{ | |||
if (arrays != null) | |||
{ | |||
int index = Array.FindIndex(Json<CommunicationPar>.Data.CommunicationDevices.ToArray(), p => p.DeviceName == DeviceName);//获取设备所在集合位置 | |||
if (index >= 0 && index < Json<CommunicationPar>.Data.CommunicationDevices.Count) | |||
{ | |||
var tempArray = Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(index).VarTableModels.ToArray(); | |||
for (int i = 0; i < arrays.Length; i++) | |||
{ | |||
int varIndex = Array.FindIndex(tempArray, p => p.RealAddress == (readDataModel.StartAddress + (i * by)).ToString()); | |||
if (varIndex >= 0 && varIndex < tempArray.Length) | |||
{ | |||
Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(index).VarTableModels.ElementAt(varIndex).CurrentValue = arrays[i].ToString(); | |||
} | |||
} | |||
var Devicename = Json<CommunicationPar>.Data.CommunicationDevices[index].DeviceName; | |||
List<ReeisDataModel> reeisDataModels = new List<ReeisDataModel>(); | |||
Json<CommunicationPar>.Data.CommunicationDevices[index].VarTableModels.ToList().ForEach(tempVar => | |||
{ | |||
if (tempVar.VarName.Length > 0) | |||
{ | |||
reeisDataModels.Add(new ReeisDataModel() | |||
{ | |||
VarName = tempVar.VarName, | |||
VarVaule = tempVar.CurrentValue | |||
}); | |||
} | |||
}); | |||
RedisHelper.GetInstance.SetValue($"{Devicename}", reeisDataModels); | |||
} | |||
} | |||
} | |||
private Dictionary<EDataType, List<ReadDataModel>> GetReadDataModels(CommunicationModel communicationModel) | |||
{ | |||
Dictionary<EDataType, List<ReadDataModel>> readDataModels = new Dictionary<EDataType, List<ReadDataModel>>(); | |||
communicationModel.VarTableModels.GroupBy(p => p.DataType)?.ToList()?.ForEach(tempVar => | |||
{ | |||
if (tempVar.Key != null && tempVar.Key.Length > 0) | |||
{ | |||
//int address = tempVar.Min(p => p.RealAddress); | |||
EDataType dataType = (EDataType)Enum.Parse(typeof(EDataType), tempVar.Key); | |||
switch (dataType) | |||
{ | |||
case EDataType.Bool: | |||
case EDataType.Byte: | |||
case EDataType.Int: | |||
case EDataType.Word: | |||
if (!readDataModels.ContainsKey(dataType)) readDataModels.TryAdd(dataType, GetDataGroup(tempVar)); | |||
break; | |||
case EDataType.Dint: | |||
case EDataType.Dword: | |||
case EDataType.Float: | |||
if (!readDataModels.ContainsKey(dataType)) readDataModels.TryAdd(dataType, GetDataGroup(tempVar, 2)); | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
}); | |||
return readDataModels; | |||
} | |||
private List<ReadDataModel> GetDataGroup(IGrouping<string, VariableInfo> variableInfos, int by = 1) | |||
{ | |||
List<ReadDataModel> ReturnValue = new List<ReadDataModel>(); | |||
var res = variableInfos?.OrderBy(p => p.RealAddress).ToList(); | |||
List<int> RealAddresss = new List<int>(); | |||
variableInfos.ToList()?.ForEach(item => { if (int.TryParse(item.RealAddress, out int add)) RealAddresss.Add(add); }); | |||
int count = 0; | |||
if (res != null) | |||
{ | |||
//int address = variableInfos.Min(p => p.RealAddress); | |||
int address = RealAddresss.Min(); | |||
int startAddress = address; | |||
for (int i = 0; i < res.Count; i++) | |||
{ | |||
if (int.TryParse(res.ElementAt(i).RealAddress, out int TempAddress)) | |||
{ | |||
if (TempAddress == address) | |||
{ | |||
count++; | |||
address += by; | |||
} | |||
else | |||
{ | |||
ReturnValue.Add(new ReadDataModel() { StartAddress = (ushort)startAddress, Length = (ushort)count }); | |||
count = 1; | |||
address = TempAddress + by; | |||
startAddress = TempAddress; | |||
} | |||
} | |||
} | |||
ReturnValue.Add(new ReadDataModel() { StartAddress = (ushort)startAddress, Length = (ushort)count }); | |||
} | |||
return ReturnValue; | |||
} | |||
} | |||
} |
@@ -0,0 +1,31 @@ | |||
using BPA.Helper; | |||
using BPASmart.Model; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Reflection; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Server | |||
{ | |||
public class Main | |||
{ | |||
private volatile static Main _Instance; | |||
public static Main GetInstance => _Instance ?? (_Instance = new Main()); | |||
private Main() { } | |||
public void Init() | |||
{ | |||
Json<CommunicationPar>.Read(); | |||
Assembly.GetExecutingAssembly().GetTypes()?.ToList()?.ForEach(item => | |||
{ | |||
if (item.GetInterfaces().Contains(typeof(IServer))) | |||
{ | |||
(Activator.CreateInstance(item) as IServer)?.Init(); | |||
} | |||
}); | |||
} | |||
} | |||
} |
@@ -0,0 +1,49 @@ | |||
<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:con="clr-namespace:BPASmartClient.CustomResource.Converters;assembly=BPASmartClient.CustomResource" | |||
xmlns:locaCon="clr-namespace:BPASmart.VariableManager.Converter" | |||
xmlns:local="clr-namespace:BPASmart.VariableManager"> | |||
<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" /> | |||
<locaCon:DataTableRedundantConverter x:Key="tabConvert" /> | |||
<locaCon:TextDisplayConvert x:Key="textDisplayConvert" /> | |||
<locaCon:DiscreteAlarmConvert x:Key="discreteAlarmConvert" /> | |||
<locaCon:AnalogAlarmConvert x:Key="analogAlarmConvert" /> | |||
<locaCon:IsEnableConvert x:Key="IsEnableConvert" /> | |||
<SolidColorBrush x:Key="PoupTextblockColor" Color="#009dff" /> | |||
<SolidColorBrush x:Key="tabColor" Color="#FF2AB2E7" /> | |||
<SolidColorBrush x:Key="bordColor" Color="#332AB2E7" /> | |||
</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> |
@@ -0,0 +1,125 @@ | |||
using BPASmartClient.CustomResource.Pages.Enums; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.CustomResource.Pages.View; | |||
using BPASmartClient.Helper; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Configuration; | |||
using System.Data; | |||
using System.Linq; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using BPASmart.Model; | |||
namespace BPASmart.VariableManager | |||
{ | |||
/// <summary> | |||
/// Interaction logic for App.xaml | |||
/// </summary> | |||
public partial class App : Application | |||
{ | |||
public static Window MainWindow; | |||
protected override void OnStartup(StartupEventArgs e) | |||
{ | |||
base.OnStartup(e); | |||
DataRead(); | |||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; | |||
MenuInit(); | |||
MainView mv = new MainView(); | |||
mv.WindowState = WindowState.Normal; | |||
MainWindow = mv; | |||
mv.Show(); | |||
} | |||
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) | |||
{ | |||
DataSave(); | |||
} | |||
protected override void OnExit(ExitEventArgs e) | |||
{ | |||
base.OnExit(e); | |||
DataSave(); | |||
} | |||
private void MenuInit() | |||
{ | |||
#region 设备管理 | |||
ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>(); | |||
DeviceMonitor.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "设备管理", | |||
AssemblyName = "BPASmart.VariableManager", | |||
ToggleWindowPath = "Views.CommunicationSetView", | |||
SubMenuVisibility = Visibility.Visible, | |||
}); | |||
MenuManage.GetInstance.menuModels.Add(new MenuModel() | |||
{ | |||
MainMenuIcon = "", | |||
MainMenuName = "设备管理", | |||
Alias = "Device Management", | |||
subMenumodels = DeviceMonitor, | |||
}); | |||
#endregion | |||
#region 变量管理,根据创建的通讯设备自动生成子菜单 | |||
ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>(); | |||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||
{ | |||
RecipeManage.Add(AddSubMenuModel(o.ToString())); | |||
}), "AddCommunicationDevice"); | |||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||
{ | |||
if (o != null && o is CommunicationModel menumodel) | |||
{ | |||
var res = RecipeManage.FirstOrDefault(p => p.SubMenuName == menumodel.DeviceName); | |||
if (res != null) RecipeManage.Remove(res); | |||
} | |||
}), "RemoveCommunicationDevice"); | |||
Json<CommunicationPar>.Data.CommunicationDevices?.ToList()?.ForEach(item => | |||
{ | |||
RecipeManage.Add(AddSubMenuModel(item.DeviceName)); | |||
}); | |||
MenuManage.GetInstance.menuModels.Add(new MenuModel() | |||
{ | |||
MainMenuIcon = "", | |||
MainMenuName = "变量管理", | |||
Alias = "Recipe Management", | |||
subMenumodels = RecipeManage, | |||
}); | |||
#endregion | |||
} | |||
private SubMenumodel AddSubMenuModel(string s) | |||
{ | |||
return new SubMenumodel() | |||
{ | |||
SubMenuName = s, | |||
AssemblyName = "BPASmart.VariableManager", | |||
ToggleWindowPath = "Views.VariableConfig", | |||
SubMenuVisibility = Visibility.Visible, | |||
}; | |||
} | |||
private void DataSave() | |||
{ | |||
Json<CommunicationPar>.Save(); | |||
} | |||
private void DataRead() | |||
{ | |||
Json<CommunicationPar>.Read(); | |||
} | |||
} | |||
} |
@@ -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) | |||
)] |
@@ -0,0 +1,54 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<OutputType>WinExe</OutputType> | |||
<TargetFramework>net6.0-windows</TargetFramework> | |||
<Nullable>enable</Nullable> | |||
<UseWPF>true</UseWPF> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<Compile Remove="Servers\**" /> | |||
<EmbeddedResource Remove="Servers\**" /> | |||
<None Remove="Servers\**" /> | |||
<Page Remove="Servers\**" /> | |||
</ItemGroup> | |||
<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> | |||
<PackageReference Include="BPA.Communication" Version="1.0.10" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmart.Model\BPASmart.Model.csproj" /> | |||
<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> |
@@ -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.Model; | |||
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(); | |||
} | |||
} | |||
} |
@@ -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(); | |||
} | |||
} | |||
} |
@@ -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 BPASmart.VariableManager.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(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,36 @@ | |||
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; | |||
using BPASmart.Model; | |||
namespace BPASmart.VariableManager.Converter | |||
{ | |||
public class DeviceVisibleConverter : IValueConverter | |||
{ | |||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
Type type = value?.GetType(); | |||
if (type != null && parameter != null) | |||
{ | |||
string typeName = type.BaseType.Name == "Object" ? type.Name : type.BaseType.Name; | |||
if (typeName == parameter.ToString()) | |||
return Visibility.Visible; | |||
else | |||
return Visibility.Collapsed; | |||
} | |||
return default; | |||
} | |||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
throw new NotImplementedException(); | |||
} | |||
} | |||
} |
@@ -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(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,27 @@ | |||
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) | |||
{ | |||
if (value != null) | |||
{ | |||
return value.ToString().Length > 0; | |||
} | |||
return false; | |||
} | |||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
throw new NotImplementedException(); | |||
} | |||
} | |||
} |
@@ -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(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,128 @@ | |||
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.Model; | |||
//using BPASmartClient.Model; | |||
using System.IO.Ports; | |||
using System.IO; | |||
using System.Reflection; | |||
namespace BPASmart.VariableManager.ViewModels | |||
{ | |||
public class CommunicationSetViewModel : ObservableObject | |||
{ | |||
public CommunicationSetViewModel() | |||
{ | |||
Json<CommunicationPar>.Read(); | |||
communicationDevices = Json<CommunicationPar>.Data.CommunicationDevices; | |||
DataListInit(); | |||
NewConnectCommand = new RelayCommand(() => { NewConnect(); }); | |||
RemoveDeviceCommand = new RelayCommand<object>(RemoveDevice); | |||
SaveConnectSetCommand = new RelayCommand(() => { Json<CommunicationPar>.Save(); }); | |||
DelegationNotifi.GetInstance.AddDeviceVerify = new Func<DeviceManagermentResult, bool>((p) => | |||
{ | |||
return Json<CommunicationPar>.Data.CommunicationDevices.FirstOrDefault(s => s.DeviceName == p.DeviceName) == null; | |||
}); | |||
} | |||
public ObservableCollection<CommunicationModel> communicationDevices { get; set; } //= new ObservableCollection<CommunicationModel>(); | |||
public RelayCommand NewConnectCommand { get; set; } | |||
public RelayCommand SaveConnectSetCommand { get; set; } | |||
public RelayCommand<object> RemoveDeviceCommand { get; set; } | |||
/// <summary> | |||
/// 创建新连接 | |||
/// </summary> | |||
private void NewConnect() | |||
{ | |||
NewDeviceView deviceManagermentSetView = new NewDeviceView(); | |||
var result = deviceManagermentSetView.ShowDialog(); | |||
var ResultTag = (DeviceManagermentResult)deviceManagermentSetView.Tag; | |||
if (ResultTag != null) | |||
{ | |||
if ((bool)result) | |||
{ | |||
var obj = communicationDevices.FirstOrDefault(p => p.DeviceName == ResultTag.DeviceName); | |||
if (obj == null) | |||
{ | |||
CommunicationModel communicationObj = new CommunicationModel(); | |||
Type type = Assembly.Load("BPASmart.Model").GetType($"BPASmart.Model.{ResultTag.DeviceType}"); | |||
//Type type = Assembly.Load("BPASmart.VariableManager").GetType($"BPASmart.VariableManager.Models.{ResultTag.DeviceType}"); | |||
var res = Activator.CreateInstance(type) as ICommunicationDevice; | |||
communicationObj.DeviceName = ResultTag.DeviceName; | |||
communicationObj.CommDevice = res; | |||
communicationObj.ModelName = type.Name; | |||
Json<CommunicationPar>.Data.CommunicationDevices.Add(communicationObj); | |||
ActionManage.GetInstance.Send("AddCommunicationDevice", ResultTag.DeviceName); | |||
} | |||
} | |||
} | |||
deviceManagermentSetView = null; | |||
} | |||
private void RemoveDevice(object o) | |||
{ | |||
var result = Json<CommunicationPar>.Data.CommunicationDevices.FirstOrDefault(p => p.DeviceName == o.ToString()); | |||
if (result != null) | |||
{ | |||
Json<CommunicationPar>.Data.CommunicationDevices.Remove(result); | |||
ActionManage.GetInstance.Send("RemoveCommunicationDevice", result); | |||
} | |||
} | |||
#region 列表集合 | |||
/// <summary> | |||
/// 端口号列表 | |||
/// </summary> | |||
public static ObservableCollection<string> Ports { get; set; } = new ObservableCollection<string>(); | |||
/// <summary> | |||
/// 波特率列表 | |||
/// </summary> | |||
public static ObservableCollection<int> BaudRates { get; set; } = new ObservableCollection<int>(); | |||
/// <summary> | |||
/// 奇偶校验列表 | |||
/// </summary> | |||
public static ObservableCollection<string> Paritys { get; set; } = new ObservableCollection<string>(); | |||
/// <summary> | |||
/// 西门子 PLC 设备类型 | |||
/// </summary> | |||
public ObservableCollection<string> PlcTypes { get; set; } = new ObservableCollection<string>(); | |||
private void DataListInit() | |||
{ | |||
Ports.Clear(); | |||
System.IO.Ports.SerialPort.GetPortNames().ToList().ForEach((item) => { Ports.Add(item); }); | |||
BaudRates.Clear(); | |||
int[] rb = new int[] { 110, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 43000, 57600, 76800, 115200 }; | |||
rb.ToList().ForEach((item) => { BaudRates.Add(item); }); | |||
Paritys.Clear(); | |||
Enum.GetNames(typeof(Parity)).ToList().ForEach((item) => { Paritys.Add(item); }); | |||
PlcTypes.Clear(); | |||
foreach (var item in Enum.GetNames(typeof(ESiemensPlcType))) | |||
{ | |||
PlcTypes.Add(item.Substring(1)); | |||
} | |||
} | |||
#endregion | |||
} | |||
} |
@@ -0,0 +1,76 @@ | |||
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.Model; | |||
using System.Reflection; | |||
namespace BPASmart.VariableManager.ViewModels | |||
{ | |||
public class NewDeviceViewModel : ObservableObject | |||
{ | |||
public NewDeviceViewModel() | |||
{ | |||
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(); | |||
var assembly = Assembly.GetAssembly(typeof(ICommunicationDevice))?.GetTypes()?.ToList(); | |||
assembly?.ForEach(item => | |||
{ | |||
if (item.GetInterfaces().Contains(typeof(ICommunicationDevice))) | |||
{ | |||
DeviceType.Add(item.Name); | |||
} | |||
}); | |||
} | |||
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; | |||
} | |||
} |
@@ -0,0 +1,406 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using BPASmart.Model; | |||
using System.Diagnostics; | |||
using Microsoft.EntityFrameworkCore; | |||
using BPASmartClient.Helper; | |||
using System.Text.Json.Serialization; | |||
using Microsoft.EntityFrameworkCore.Metadata.Internal; | |||
using Ubiety.Dns.Core.Records; | |||
using System.Windows; | |||
using BPA.Communication; | |||
using System.Threading; | |||
namespace BPASmart.VariableManager.ViewModels | |||
{ | |||
public class VariableConfigViewModel : NoticeBase | |||
{ | |||
private int varialeInfosIndex = -1; | |||
ICommunicationDevice DeviceType; | |||
public VariableConfigViewModel(string o) | |||
{ | |||
DataInit(o); | |||
VarNameChanged(); | |||
StartMotionCommand = new RelayCommand(() => | |||
{ | |||
switch (ButtonContext) | |||
{ | |||
case "开始监控": | |||
TabName = "当前值"; | |||
CurrentVisibility = Visibility.Visible; | |||
RemoveButVisiblity = Visibility.Collapsed; | |||
ButtonContext = "停止监控"; | |||
IsEnable = false; | |||
Motion(); | |||
break; | |||
case "停止监控": | |||
TabName = "操作"; | |||
CurrentVisibility = Visibility.Collapsed; | |||
RemoveButVisiblity = Visibility.Visible; | |||
ButtonContext = "开始监控"; | |||
IsEnable = true; | |||
ThreadManage.GetInstance().StopTask($"{DeviceType} 初始化连接"); | |||
ThreadManage.GetInstance().StopTask($"{DeviceType} 设备数据采集"); | |||
break; | |||
default: | |||
break; | |||
} | |||
}); | |||
RemoveCommand = new RelayCommand<object>((o) => | |||
{ | |||
if (o != null && o is VariableInfo variable) | |||
{ | |||
varialeInfos.Remove(variable); | |||
} | |||
for (int i = 0; i < varialeInfos.Count; i++) | |||
{ | |||
varialeInfos.ElementAt(i).ID = i + 1; | |||
} | |||
}); | |||
} | |||
private void DataInit(string o) | |||
{ | |||
varialeInfosIndex = Array.FindIndex(Json<CommunicationPar>.Data.CommunicationDevices.ToArray(), p => p.DeviceName == o); | |||
if (varialeInfosIndex >= 0 && varialeInfosIndex < Json<CommunicationPar>.Data.CommunicationDevices.Count) | |||
{ | |||
DeviceType = Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(varialeInfosIndex).CommDevice; | |||
varialeInfos = Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(varialeInfosIndex).VarTableModels; | |||
if (varialeInfos.Count <= 0) AddRow(); | |||
} | |||
ComboBoxItemInit(); | |||
ActionManage.GetInstance.Register(new Action<object[]>((p) => | |||
{ | |||
if (p != null && p.Length == 2) | |||
{ | |||
NameWidth = Convert.ToDouble(p[0]); | |||
AddressWidth = Convert.ToDouble(p[1]); | |||
} | |||
}), "TabGridSizeChanged"); | |||
} | |||
private void VarNameChanged() | |||
{ | |||
DelegationNotifi.GetInstance.VarNameChanged = new Action<int>((p) => | |||
{ | |||
var result = varialeInfos.GroupBy(P => P.VarName).ToList(); | |||
if (result != null && result.Count < varialeInfos.Count) | |||
{ | |||
result.ForEach(x => | |||
{ | |||
if (x.Key.Length > 0) | |||
{ | |||
if (x.Count() > 1) | |||
{ | |||
x.ToList().ForEach(item => | |||
{ | |||
int index = Array.FindIndex(varialeInfos.ToArray(), p => p.VarName == item.VarName && p.ID == item.ID); | |||
if (index >= 0 && index < varialeInfos.Count) | |||
{ | |||
varialeInfos.ElementAt(index).IsRedundant = true; | |||
} | |||
}); | |||
} | |||
else if (x.Count() == 1) | |||
{ | |||
int index = Array.FindIndex(varialeInfos.ToArray(), p => p.VarName == x.ElementAt(0).VarName && p.ID == x.ElementAt(0).ID); | |||
if (index >= 0 && index < varialeInfos.Count) | |||
{ | |||
varialeInfos.ElementAt(index).IsRedundant = false; | |||
} | |||
} | |||
} | |||
}); | |||
} | |||
else | |||
{ | |||
for (int i = 0; i < varialeInfos.Count; i++) | |||
{ | |||
varialeInfos.ElementAt(i).IsRedundant = false; | |||
} | |||
} | |||
if ((p - 1) >= 0) | |||
{ | |||
if (varialeInfos?.Count >= p) | |||
{ | |||
if (varialeInfos.ElementAt(p - 1).VarName?.Length > 0) | |||
{ | |||
if (varialeInfos.Count == p) AddRow(); | |||
} | |||
} | |||
} | |||
}); | |||
} | |||
private void Motion() | |||
{ | |||
ThreadManage.GetInstance().Start(new Action(() => | |||
{ | |||
switch (DeviceType) | |||
{ | |||
case BPASmart.Model.ModbusRtu _modbusRtu: | |||
break; | |||
case BPASmart.Model.ModbusTcp _modbusTcp: | |||
BPA.Communication.ModbusTcp modbusTcpMaster = new BPA.Communication.ModbusTcp(); | |||
modbusTcpMaster.ConnectOk = new Action(() => | |||
{ | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
GetReadDataModels().ToList()?.ForEach(temp => | |||
{ | |||
switch (temp.Key) | |||
{ | |||
case EDataType.Bool: | |||
temp.Value?.ForEach(value => | |||
{ | |||
var res = modbusTcpMaster.ReadCoils(value.StartAddress, value.Length); | |||
SetValue(res, value, 1); | |||
}); | |||
break; | |||
case EDataType.Byte: | |||
break; | |||
case EDataType.Int: | |||
break; | |||
case EDataType.Word: | |||
temp.Value?.ForEach(value => | |||
{ | |||
var res = modbusTcpMaster.ReadHoldingRegisters(value.StartAddress, value.Length); | |||
SetValue(res, value, 1); | |||
}); | |||
break; | |||
case EDataType.Dint: | |||
break; | |||
case EDataType.Dword: | |||
temp.Value?.ForEach(value => | |||
{ | |||
var res = modbusTcpMaster.ReadHoldingRegisters(value.StartAddress, value.Length); | |||
SetValue(res, value, 2); | |||
}); | |||
break; | |||
case EDataType.Float: | |||
temp.Value?.ForEach(value => | |||
{ | |||
var res = modbusTcpMaster.ReadHoldingRegisters(value.StartAddress, value.Length); | |||
SetValue(res, value, 2); | |||
}); | |||
break; | |||
default: | |||
break; | |||
} | |||
}); | |||
Thread.Sleep(100); | |||
}), $"{DeviceType} 设备数据采集"); | |||
//var DeviceModel = item; | |||
}); | |||
modbusTcpMaster.IsReconnect = true; | |||
modbusTcpMaster.ModbusTcpConnect(_modbusTcp.IP, _modbusTcp.PortNum); | |||
break; | |||
case BPASmart.Model.Siemens _siemens: | |||
break; | |||
default: | |||
break; | |||
} | |||
}), $"{DeviceType} 初始化连接"); | |||
} | |||
/// <summary> | |||
/// 添加行 | |||
/// </summary> | |||
private void AddRow() | |||
{ | |||
App.Current.Dispatcher.Invoke(new Action(() => | |||
{ | |||
if (varialeInfosIndex >= 0 && varialeInfosIndex < Json<CommunicationPar>.Data.CommunicationDevices.Count) | |||
{ | |||
varialeInfos.Add(new VariableInfo(DeviceType) { ID = varialeInfos.Count + 1 }); | |||
} | |||
})); | |||
} | |||
#region 属性 | |||
public double NameWidth { get { return _mNameWidth; } set { _mNameWidth = value; OnPropertyChanged(); } } | |||
public static double _mNameWidth; | |||
public double AddressWidth { get { return _mAddressWidth; } set { _mAddressWidth = value; OnPropertyChanged(); } } | |||
private static double _mAddressWidth; | |||
public string TabName { get { return _mTabName; } set { _mTabName = value; OnPropertyChanged(); } } | |||
private static string _mTabName = "操作"; | |||
public string ButtonContext { get { return _mButtonContext; } set { _mButtonContext = value; OnPropertyChanged(); } } | |||
private static string _mButtonContext = "开始监控"; | |||
public Visibility CurrentVisibility { get { return _mCurrentVisibility; } set { _mCurrentVisibility = value; OnPropertyChanged(); } } | |||
private static Visibility _mCurrentVisibility = Visibility.Collapsed; | |||
public Visibility RemoveButVisiblity { get { return _mRemoveButVisiblity; } set { _mRemoveButVisiblity = value; OnPropertyChanged(); } } | |||
private static Visibility _mRemoveButVisiblity = Visibility.Visible; | |||
public bool IsEnable { get { return _mIsEnable; } set { _mIsEnable = value; OnPropertyChanged(); } } | |||
private bool _mIsEnable = true; | |||
#endregion | |||
#region 数据列表 | |||
/// <summary> | |||
/// 数据类型下拉列表 | |||
/// </summary> | |||
public ObservableCollection<string> dataType { get; set; } = new ObservableCollection<string>(); | |||
/// <summary> | |||
/// 报警设置窗离散量报警类型 | |||
/// </summary> | |||
public ObservableCollection<string> PopupDiscreteAlarmType { get; set; } = new ObservableCollection<string>(); | |||
/// <summary> | |||
/// 变量信息 | |||
/// </summary> | |||
public ObservableCollection<VariableInfo> varialeInfos { get; set; } | |||
#endregion | |||
#region Command | |||
public RelayCommand SaveCommand { get; set; } | |||
public RelayCommand StartMotionCommand { get; set; } | |||
public RelayCommand<object> RemoveCommand { get; set; } | |||
#endregion | |||
private void SetValue<TArray>(TArray[] arrays, ReadDataModel readDataModel, ushort by) | |||
{ | |||
for (int i = 0; i < arrays.Length; i++) | |||
{ | |||
int varIndex = Array.FindIndex(varialeInfos.ToArray(), p => p.RealAddress == (readDataModel.StartAddress + (i * by)).ToString()); | |||
if (varIndex >= 0 && varIndex < varialeInfos.Count) | |||
{ | |||
varialeInfos.ElementAt(varIndex).CurrentValue = arrays[i].ToString(); | |||
} | |||
} | |||
} | |||
private Dictionary<EDataType, List<ReadDataModel>> GetReadDataModels() | |||
{ | |||
Dictionary<EDataType, List<ReadDataModel>> readDataModels = new Dictionary<EDataType, List<ReadDataModel>>(); | |||
varialeInfos.GroupBy(p => p.DataType)?.ToList()?.ForEach(tempVar => | |||
{ | |||
if (tempVar.Key != null && tempVar.Key.Length > 0) | |||
{ | |||
//int address = tempVar.Min(p => p.RealAddress); | |||
EDataType dataType = (EDataType)Enum.Parse(typeof(EDataType), tempVar.Key); | |||
switch (dataType) | |||
{ | |||
case EDataType.Bool: | |||
case EDataType.Byte: | |||
case EDataType.Int: | |||
case EDataType.Word: | |||
if (!readDataModels.ContainsKey(dataType)) readDataModels.TryAdd(dataType, GetDataGroup(tempVar)); | |||
break; | |||
case EDataType.Dint: | |||
case EDataType.Dword: | |||
case EDataType.Float: | |||
if (!readDataModels.ContainsKey(dataType)) readDataModels.TryAdd(dataType, GetDataGroup(tempVar, 2)); | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
}); | |||
return readDataModels; | |||
} | |||
private List<ReadDataModel> GetDataGroup(IGrouping<string, VariableInfo> variableInfos, int by = 1) | |||
{ | |||
//List<ReadDataModel> ReturnValue = new List<ReadDataModel>(); | |||
//var res = variableInfos?.OrderBy(p => p.RealAddress).ToList(); | |||
//int count = 0; | |||
//if (res != null) | |||
//{ | |||
// int address = variableInfos.Min(p => p.RealAddress); | |||
// int startAddress = address; | |||
// for (int i = 0; i < res.Count; i++) | |||
// { | |||
// if (res.ElementAt(i).RealAddress == address) | |||
// { | |||
// count++; | |||
// address += by; | |||
// } | |||
// else | |||
// { | |||
// ReturnValue.Add(new ReadDataModel() { StartAddress = (ushort)startAddress, Length = (ushort)count }); | |||
// count = 1; | |||
// address = res.ElementAt(i).RealAddress + by; | |||
// startAddress = res.ElementAt(i).RealAddress; | |||
// } | |||
// } | |||
// ReturnValue.Add(new ReadDataModel() { StartAddress = (ushort)startAddress, Length = (ushort)count }); | |||
//} | |||
//return ReturnValue; | |||
List<ReadDataModel> ReturnValue = new List<ReadDataModel>(); | |||
var res = variableInfos?.OrderBy(p => p.RealAddress).ToList(); | |||
List<int> RealAddresss = new List<int>(); | |||
variableInfos.ToList()?.ForEach(item => { if (int.TryParse(item.RealAddress, out int add)) RealAddresss.Add(add); }); | |||
int count = 0; | |||
if (res != null) | |||
{ | |||
int address = RealAddresss.Min(); | |||
int startAddress = address; | |||
for (int i = 0; i < res.Count; i++) | |||
{ | |||
if (int.TryParse(res.ElementAt(i).RealAddress, out int TempAddress)) | |||
{ | |||
if (TempAddress == address) | |||
{ | |||
count++; | |||
address += by; | |||
} | |||
else | |||
{ | |||
ReturnValue.Add(new ReadDataModel() { StartAddress = (ushort)startAddress, Length = (ushort)count }); | |||
count = 1; | |||
address = TempAddress + by; | |||
startAddress = TempAddress; | |||
} | |||
} | |||
} | |||
ReturnValue.Add(new ReadDataModel() { StartAddress = (ushort)startAddress, Length = (ushort)count }); | |||
} | |||
return ReturnValue; | |||
} | |||
/// <summary> | |||
/// 下拉列表初始化 | |||
/// </summary> | |||
private void ComboBoxItemInit() | |||
{ | |||
dataType.Clear(); | |||
PopupDiscreteAlarmType.Clear(); | |||
string[] DataTypeNames = Enum.GetNames(typeof(EDataType)); | |||
foreach (var item in DataTypeNames) { dataType.Add(item); } | |||
string[] PopupAlarmTypes = Enum.GetNames(typeof(EAlongTriggerType)); | |||
foreach (var item in PopupAlarmTypes) { PopupDiscreteAlarmType.Add(item); } | |||
} | |||
} | |||
} |
@@ -0,0 +1,491 @@ | |||
<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:con="clr-namespace:BPASmart.VariableManager.Converter" | |||
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:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
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> | |||
<con:DeviceVisibleConverter x:Key="DeviceVisibleConverter" /> | |||
<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 /> | |||
</Grid.RowDefinitions> | |||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> | |||
<pry:IcoButton | |||
Grid.Column="3" | |||
Width="140" | |||
Margin="0,0,20,0" | |||
HorizontalAlignment="Left" | |||
Command="{Binding NewConnectCommand}" | |||
Content="新建连接" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
IcoText="" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
<pry:IcoButton | |||
Grid.Column="3" | |||
Width="140" | |||
Margin="0,0,20,0" | |||
HorizontalAlignment="Left" | |||
Command="{Binding SaveConnectSetCommand}" | |||
Content="保存连接" | |||
FontSize="17" | |||
Foreground="Aqua" | |||
IcoText="" | |||
IsEnabled="True" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
</StackPanel> | |||
<ScrollViewer | |||
Name="sv" | |||
Grid.Row="1" | |||
Margin="0,10,0,0" | |||
HorizontalScrollBarVisibility="Hidden" | |||
VerticalScrollBarVisibility="Hidden"> | |||
<ItemsControl ItemsSource="{Binding communicationDevices}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<Grid | |||
Name="cy" | |||
Height="180" | |||
Margin="0,0,0,30"> | |||
<!--<Grid.Background> | |||
<ImageBrush ImageSource="/Resources/Images/边框1.png" /> | |||
</Grid.Background>--> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<!--#region 标题显示及操作--> | |||
<Grid Height="30" Margin="0,0,0,0"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.5*" /> | |||
<ColumnDefinition Width="0.3*" /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<pry:TitleTextBlock Margin="2,2,0,0" /> | |||
<StackPanel | |||
Margin="5" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<TextBlock | |||
Margin="0,0,10,0" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="Aqua" | |||
Text="{Binding DeviceName}" /> | |||
<TextBlock | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="Yellow" | |||
Text="[" /> | |||
<TextBlock | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="Yellow" | |||
Text="{Binding ModelName}" /> | |||
<TextBlock | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="Yellow" | |||
Text="]" /> | |||
</StackPanel> | |||
</Grid> | |||
<!--#endregion--> | |||
<!--#region 西门子设备--> | |||
<Grid Grid.Row="1" Visibility="{Binding CommDevice, Converter={StaticResource DeviceVisibleConverter}, ConverterParameter=Siemens}"> | |||
<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 CommDevice.IP}" /> | |||
<TextBlock | |||
Grid.Column="2" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="端口号:" /> | |||
<TextBox | |||
Grid.Column="3" | |||
Margin="0,0,20,0" | |||
Style="{StaticResource TextBoxStyle}" | |||
Text="{Binding CommDevice.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 DataContext.PlcTypes, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
SelectedIndex="0" | |||
Style="{StaticResource ComboBoxStyle}" | |||
Text="{Binding CommDevice.PlcType}" /> | |||
<Button | |||
Grid.Column="7" | |||
Height="30" | |||
Margin="0,0,10,0" | |||
Command="{Binding DataContext.RemoveDeviceCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding DeviceName}" | |||
Content="删除" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="#FFDE7889" | |||
Template="{StaticResource RemoveButtonTemplate}" /> | |||
<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 CommDevice.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 CommDevice.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="1" Visibility="{Binding CommDevice, Converter={StaticResource DeviceVisibleConverter}, ConverterParameter=ModbusTcp}"> | |||
<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 CommDevice.IP}" /> | |||
<TextBlock | |||
Grid.Column="2" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="端口号:" /> | |||
<TextBox | |||
Grid.Column="3" | |||
Margin="0,0,20,0" | |||
Style="{StaticResource TextBoxStyle}" | |||
Text="{Binding CommDevice.PortNum}" /> | |||
<TextBlock | |||
Grid.Column="4" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="站号:" /> | |||
<TextBox | |||
Grid.Column="5" | |||
Margin="0,0,20,0" | |||
Style="{StaticResource TextBoxStyle}" | |||
Text="{Binding CommDevice.StationNo}" /> | |||
<Button | |||
Grid.Column="7" | |||
Height="30" | |||
Margin="0,0,10,0" | |||
Command="{Binding DataContext.RemoveDeviceCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding DeviceName}" | |||
Content="删除" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="#FFDE7889" | |||
Template="{StaticResource RemoveButtonTemplate}" /> | |||
<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="1" Visibility="{Binding CommDevice, Converter={StaticResource DeviceVisibleConverter}, ConverterParameter=ModbusRtu}"> | |||
<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="True" | |||
ItemsSource="{Binding DataContext.Ports, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
SelectedIndex="0" | |||
Style="{StaticResource ComboBoxStyle}" | |||
Text="{Binding CommDevice.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 DataContext.BaudRates, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
SelectedIndex="6" | |||
Style="{StaticResource ComboBoxStyle}" | |||
Text="{Binding CommDevice.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 DataContext.Paritys, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
SelectedIndex="0" | |||
Style="{StaticResource ComboBoxStyle}" | |||
Text="{Binding CommDevice.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 CommDevice.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 CommDevice.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 CommDevice.StationNo}" /> | |||
<Button | |||
Grid.Column="7" | |||
Height="30" | |||
Margin="0,0,10,0" | |||
Command="{Binding DataContext.RemoveDeviceCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding DeviceName}" | |||
Content="删除" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="#FFDE7889" | |||
Template="{StaticResource RemoveButtonTemplate}" /> | |||
<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> |
@@ -0,0 +1,36 @@ | |||
using BPASmart.Model; | |||
using BPASmartClient.Helper; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Controls; | |||
using System.Windows.Data; | |||
using System.Windows.Documents; | |||
using System.Windows.Input; | |||
using System.Windows.Media; | |||
using System.Windows.Media.Imaging; | |||
using System.Windows.Navigation; | |||
using System.Windows.Shapes; | |||
namespace BPASmart.VariableManager.Views | |||
{ | |||
/// <summary> | |||
/// CommunicationSetView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class CommunicationSetView : UserControl | |||
{ | |||
public CommunicationSetView() | |||
{ | |||
InitializeComponent(); | |||
this.Unloaded += CommunicationSetView_Unloaded; | |||
} | |||
private void CommunicationSetView_Unloaded(object sender, RoutedEventArgs e) | |||
{ | |||
Json<CommunicationPar>.Save(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,196 @@ | |||
<Window | |||
x:Class="BPASmart.VariableManager.Views.NewDeviceView" | |||
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="NewDeviceView" | |||
Width="400" | |||
Height="275" | |||
AllowsTransparency="True" | |||
Background="{x:Null}" | |||
Opacity="0.8" | |||
Topmost="false" | |||
WindowStartupLocation="CenterScreen" | |||
WindowStyle="None" | |||
mc:Ignorable="d"> | |||
<Window.DataContext> | |||
<vm:NewDeviceViewModel /> | |||
</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="" | |||
Style="{StaticResource TitleBarStyle}" | |||
Visibility="Hidden" /> | |||
<Button | |||
Name="ButMax" | |||
Content="" | |||
Style="{StaticResource TitleBarStyle}" | |||
Visibility="Hidden" /> | |||
<Button | |||
Name="ButClose" | |||
Content="" | |||
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> |
@@ -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.Model; | |||
namespace BPASmart.VariableManager.Views | |||
{ | |||
/// <summary> | |||
/// DeviceManagermentSetView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class NewDeviceView : Window | |||
{ | |||
public NewDeviceView() | |||
{ | |||
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(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,608 @@ | |||
<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:con="clr-namespace:BPASmart.VariableManager.Converter" | |||
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:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:BPASmart.VariableManager.ViewModels" | |||
d:DesignHeight="600" | |||
d:DesignWidth="1200" | |||
mc:Ignorable="d"> | |||
<!--<UserControl.DataContext> | |||
<vm:VariableConfig /> | |||
</UserControl.DataContext>--> | |||
<UserControl.Resources> | |||
<Style x:Key="TextBoxStyle" TargetType="TextBox"> | |||
<Setter Property="FontFamily" Value="楷体" /> | |||
<Setter Property="FontSize" Value="22" /> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Width" Value="188" /> | |||
<Setter Property="Padding" Value="6,0,0,0" /> | |||
<Setter Property="Height" Value="37" /> | |||
<Setter Property="BorderThickness" Value="0" /> | |||
<Setter Property="Foreground" Value="{StaticResource PoupTextblockColor}" /> | |||
<Setter Property="BorderBrush" Value="{StaticResource PoupTextblockColor}" /> | |||
<Setter Property="CaretBrush" Value="{StaticResource PoupTextblockColor}" /> | |||
<Setter Property="VerticalAlignment" Value="Center" /> | |||
<Setter Property="Background"> | |||
<Setter.Value> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/textBox.png" Stretch="Fill" /> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<Style x:Key="TextBlockStyle" TargetType="TextBlock"> | |||
<Setter Property="FontFamily" Value="楷体" /> | |||
<Setter Property="FontSize" Value="18" /> | |||
<Setter Property="Foreground" Value="{StaticResource PoupTextblockColor}" /> | |||
<Setter Property="VerticalAlignment" Value="Center" /> | |||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||
</Style> | |||
<Style x:Key="RowRadioButtonStyle" TargetType="{x:Type RadioButton}"> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type RadioButton}"> | |||
<Border | |||
x:Name="NvaBor" | |||
Background="Transparent" | |||
BorderBrush="#FF2AB2E7" | |||
BorderThickness="0"> | |||
<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="#22ffffff" /> | |||
<Setter TargetName="NvaBor" Property="BorderThickness" Value="0" /> | |||
</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> | |||
<Style x:Key="InputTextboxStyle" TargetType="TextBox"> | |||
<Setter Property="Margin" Value="0,0,0,0" /> | |||
<Setter Property="Padding" Value="5,0,5,0" /> | |||
<Setter Property="BorderThickness" Value="0" /> | |||
<Setter Property="HorizontalAlignment" Value="Left" /> | |||
<Setter Property="Height" Value="40" /> | |||
<Setter Property="CaretBrush" Value="{StaticResource TitleBorderColor}" /> | |||
<Setter Property="Foreground" Value="{StaticResource TitleBorderColor}" /> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="FontSize" Value="14" /> | |||
<Setter Property="Background" Value="Transparent" /> | |||
<Setter Property="VerticalAlignment" Value="Center" /> | |||
</Style> | |||
<Style x:Key="ControlButtonStyle" TargetType="Button"> | |||
<Setter Property="Margin" Value="0" /> | |||
<Setter Property="FontSize" Value="18" /> | |||
<Setter Property="Foreground" Value="#FFF53F62" /> | |||
<Setter Property="FontWeight" Value="SemiBold" /> | |||
<Setter Property="FontFamily" Value="楷体" /> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="Button"> | |||
<Border | |||
Name="TitleBarBr" | |||
BorderBrush="#00c2f4" | |||
BorderThickness="0" | |||
CornerRadius="0" | |||
Opacity="0.8"> | |||
<ContentPresenter | |||
Margin="{TemplateBinding Margin}" | |||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | |||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> | |||
<Border.Background> | |||
<ImageBrush | |||
ImageSource="/BPASmartClient.CustomResource;component/Image/组合边框1.1.png" | |||
Opacity="0.8" | |||
Stretch="Fill" /> | |||
</Border.Background> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="TitleBarBr" Property="Opacity" Value="1" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<Style x:Key="TitleTextblockStyle" TargetType="TextBlock"> | |||
<Setter Property="FontSize" Value="16" /> | |||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||
<Setter Property="VerticalAlignment" Value="Center" /> | |||
<Setter Property="Foreground" Value="{StaticResource tabColor}" /> | |||
<Setter Property="FontFamily" Value="楷体" /> | |||
<Setter Property="FontWeight" Value="SemiBold" /> | |||
</Style> | |||
</UserControl.Resources> | |||
<Grid Margin="10" SizeChanged="TabGrid_SizeChanged"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> | |||
<Button | |||
Width="150" | |||
Height="40" | |||
Margin="10,0,10,0" | |||
Command="{Binding StartMotionCommand}" | |||
Content="{Binding ButtonContext}" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
<Button | |||
Width="150" | |||
Height="40" | |||
Margin="10,0,10,0" | |||
Command="{Binding SaveCommand}" | |||
Content="保存参数" | |||
FontSize="20" | |||
Style="{StaticResource ImageButtonStyle}" /> | |||
</StackPanel> | |||
<!--#region 表格标题栏设置--> | |||
<Grid | |||
Name="TabGrid" | |||
Grid.Row="1" | |||
Margin="0,10,0,0" | |||
Background="#ff0C255F"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.2*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.4*" /> | |||
<ColumnDefinition Width="0.3*" /> | |||
<ColumnDefinition Width="0.2*" /> | |||
<ColumnDefinition Width="0.2*" /> | |||
<ColumnDefinition Width="0.2*" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
Style="{StaticResource TitleTextblockStyle}" | |||
Text="ID" /> | |||
<Grid Grid.Column="1"> | |||
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="名称" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="2" | |||
Style="{StaticResource TitleTextblockStyle}" | |||
Text="地址" /> | |||
<Grid Grid.Column="3"> | |||
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="数据类型" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<Grid Grid.Column="4"> | |||
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="报警" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="5" | |||
Style="{StaticResource TitleTextblockStyle}" | |||
Text="报警配置" /> | |||
<Grid Grid.Column="6"> | |||
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="{Binding TabName}" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<Border | |||
Grid.ColumnSpan="8" | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<!--#endregion--> | |||
<Grid Grid.Row="2"> | |||
<ScrollViewer IsEnabled="{Binding IsEnable}" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"> | |||
<ItemsControl ItemsSource="{Binding varialeInfos}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<Grid Name="gr" Height="30"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.2*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.4*" /> | |||
<ColumnDefinition Width="0.3*" /> | |||
<ColumnDefinition Width="0.2*" /> | |||
<ColumnDefinition Width="0.2*" /> | |||
<ColumnDefinition Width="0.2*" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="14" | |||
Foreground="{Binding IsRedundant, Converter={StaticResource tabConvert}}" | |||
Text="{Binding ID}" /> | |||
<Grid Grid.Column="1"> | |||
<TextBox | |||
Width="{Binding DataContext.NameWidth, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
Foreground="{Binding IsRedundant, Converter={StaticResource tabConvert}}" | |||
Style="{StaticResource InputTextboxStyle}" | |||
Text="{Binding VarName}" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<TextBox | |||
Grid.Column="2" | |||
Width="{Binding DataContext.AddressWidth, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
Foreground="{Binding IsRedundant, Converter={StaticResource tabConvert}}" | |||
Style="{StaticResource InputTextboxStyle}" | |||
Text="{Binding Address}" /> | |||
<Grid Grid.Column="3"> | |||
<ComboBox | |||
Name="cb" | |||
VerticalAlignment="Center" | |||
BorderBrush="Transparent" | |||
BorderThickness="1" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
IsEnabled="{Binding DataContext.IsEnable,RelativeSource={RelativeSource AncestorType=ItemsControl,Mode=FindAncestor}}" | |||
Foreground="{Binding IsRedundant, Converter={StaticResource tabConvert}}" | |||
IsEditable="False" | |||
ItemsSource="{Binding DataContext.dataType, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
SelectedValue="{Binding DataType}" | |||
Style="{StaticResource ComboBoxStyle}" | |||
Text="{Binding DataType}" /> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<CheckBox | |||
Grid.Column="4" | |||
Margin="0,6" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="#009dff" | |||
FontSize="16" | |||
Foreground="{Binding IsRedundant, Converter={StaticResource tabConvert}}" | |||
IsChecked="{Binding IsEnableAlarm}" | |||
IsEnabled="{Binding ElementName=cb, Path=Text, Converter={StaticResource IsEnableConvert}}" | |||
Template="{StaticResource CbTemplate}" /> | |||
<!-- Content="{Binding IsEnableAlarm, Converter={StaticResource textDisplayConvert}}" --> | |||
<!--<TextBox | |||
Grid.Column="4" | |||
Foreground="{Binding IsRedundant, Converter={StaticResource tabConvert}}" | |||
Style="{StaticResource InputTextboxStyle}" | |||
Text="{Binding SlowAcceleration}" />--> | |||
<Grid Grid.Column="5"> | |||
<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="/Resources/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="#009dff" | |||
BorderThickness="1" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="#009dff" | |||
IsEditable="False" | |||
ItemsSource="{Binding DataContext.PopupDiscreteAlarmType, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
SelectedIndex="1" | |||
Style="{StaticResource ComboBoxStyle}" | |||
Text="{Binding 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" | |||
Style="{StaticResource TextBoxStyle}" | |||
Text="{Binding 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 AnalogAlarmModels}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<Grid Margin="0,0,0,8"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<Border | |||
Grid.RowSpan="2" | |||
Grid.ColumnSpan="3" | |||
BorderBrush="#55009dff" | |||
BorderThickness="0,0,0,1" /> | |||
<CheckBox | |||
Margin="5,5,0,0" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
Background="#009dff" | |||
Content="{Binding AlarmTag}" | |||
FontSize="14" | |||
Foreground="#009dff" | |||
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" | |||
Width="230" | |||
Height="35" | |||
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 | |||
Height="40" | |||
Margin="10,5,10,10" | |||
Command="{Binding CancelCommand}" | |||
Content="取消" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
FontWeight="DemiBold" | |||
Foreground="#009dff" | |||
Style="{StaticResource FGImageButtonStyle}" /> | |||
<Button | |||
Grid.Column="1" | |||
Height="40" | |||
Margin="10,5,10,10" | |||
Command="{Binding ConfirmCommand}" | |||
Content="确认" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
FontWeight="DemiBold" | |||
Foreground="#009dff" | |||
Style="{StaticResource FGImageButtonStyle}" /> | |||
</Grid> | |||
<!--#endregion--> | |||
</Grid> | |||
</Border> | |||
</Popup> | |||
<Border | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,0" | |||
Cursor="SizeWE" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="6" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
FontSize="14" | |||
Foreground="{Binding IsRedundant, Converter={StaticResource tabConvert}}" | |||
Text="{Binding CurrentValue}" | |||
Visibility="{Binding DataContext.CurrentVisibility, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" /> | |||
<Button | |||
Grid.Column="6" | |||
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding}" | |||
Content="删除" | |||
FontSize="16" | |||
Style="{StaticResource ControlButtonStyle}" | |||
Visibility="{Binding DataContext.RemoveButVisiblity, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" /> | |||
<Border | |||
Grid.ColumnSpan="7" | |||
BorderBrush="{StaticResource bordColor}" | |||
BorderThickness="1,0,1,1" /> | |||
</Grid> | |||
<DataTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" /> | |||
</Trigger> | |||
</DataTemplate.Triggers> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</ScrollViewer> | |||
</Grid> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,67 @@ | |||
using BPASmart.Model; | |||
using BPASmart.VariableManager.ViewModels; | |||
using BPASmartClient.Helper; | |||
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; | |||
this.Unloaded += VariableConfig_Unloaded; | |||
} | |||
private void VariableConfig_Unloaded(object sender, RoutedEventArgs e) | |||
{ | |||
Json<CommunicationPar>.Save(); | |||
} | |||
private void VariableConfig_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) | |||
{ | |||
var obj = (VariableConfig)sender; | |||
if (!obj.IsVisible) | |||
{ | |||
DelegationNotifi.GetInstance.VariableSave?.Invoke(); | |||
DelegationNotifi.GetInstance.VariableSave = null; | |||
DelegationNotifi.GetInstance.VarNameChanged = null; | |||
} | |||
else | |||
{ | |||
this.DataContext = new VariableConfigViewModel(this.Name); | |||
} | |||
} | |||
private void TabGrid_SizeChanged(object sender, SizeChangedEventArgs e) | |||
{ | |||
var res = TabGrid.ColumnDefinitions; | |||
if (res != null && res.Count >= 3) | |||
{ | |||
object[] widths = new object[] { 0, 0 }; | |||
widths[0] = res.ElementAt(1).ActualWidth; | |||
widths[1] = res.ElementAt(2).ActualWidth; | |||
ActionManage.GetInstance.Send("TabGridSizeChanged", widths); | |||
} | |||
} | |||
} | |||
} |
@@ -2,6 +2,8 @@ | |||
using Microsoft.AspNetCore.Mvc; | |||
using Microsoft.AspNetCore.SignalR; | |||
using Newtonsoft.Json; | |||
using System.Diagnostics; | |||
using System.Text; | |||
namespace BPASmartClient.AgvApi.Controllers | |||
{ | |||
@@ -9,31 +11,44 @@ namespace BPASmartClient.AgvApi.Controllers | |||
[Route("apicallback/quicktron/[Controller]")] | |||
public class robotjobController : ControllerBase | |||
{ | |||
/// <summary> | |||
/// 搬运任务状态上报 | |||
/// </summary> | |||
/// <param name="sign"></param> | |||
/// <returns></returns> | |||
[HttpPost("report")] | |||
public string report(string sign) | |||
public async Task<string> report() | |||
{ | |||
if (sign != null) | |||
//if (sign != null) | |||
//{ | |||
try | |||
{ | |||
try | |||
using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8)) | |||
{ | |||
var res = JsonConvert.DeserializeObject<AGVToUpSystem>(sign); | |||
if (res != null) | |||
string body = await reader.ReadToEndAsync(); | |||
AGVToUpSystem s = JsonConvert.DeserializeObject<AGVToUpSystem>(body); | |||
if (s != null) | |||
{ | |||
Factory.GetInstance.SendReport(res); | |||
Factory.GetInstance.SendReport(s); | |||
return "SUCCESS"; | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
return ex.ToString(); | |||
} | |||
} | |||
//var res = JsonConvert.DeserializeObject<AGVToUpSystem>(sign); | |||
//if (res != null) | |||
//{ | |||
// Factory.GetInstance.SendReport(res); | |||
// return "SUCCESS"; | |||
//} | |||
} | |||
catch (Exception ex) | |||
{ | |||
return ex.ToString(); | |||
} | |||
// } | |||
return "Error"; | |||
} | |||
@@ -43,25 +58,29 @@ namespace BPASmartClient.AgvApi.Controllers | |||
/// <param name="sign"></param> | |||
/// <returns></returns> | |||
[HttpPost("upstreamrequest")] | |||
public string upstreamrequest(string sign) | |||
public async Task<string> upstreamrequest() | |||
{ | |||
if (sign != null) | |||
//if (sign != null) | |||
//{ | |||
try | |||
{ | |||
try | |||
using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8)) | |||
{ | |||
var res = JsonConvert.DeserializeObject<Upstreamrequest>(sign); | |||
string body = await reader.ReadToEndAsync(); | |||
var res = JsonConvert.DeserializeObject<Upstreamrequest>(body); | |||
if (res != null) | |||
{ | |||
Factory.GetInstance.SendUpstreamrequest(sign); | |||
Factory.GetInstance.SendUpstreamrequest(res); | |||
return "SUCCESS"; | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
return ex.ToString(); | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
return ex.ToString(); | |||
} | |||
// } | |||
return "Error"; | |||
} | |||
@@ -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 }; | |||
@@ -1,11 +1,23 @@ | |||
<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> | |||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.0" /> | |||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.3.0" /> | |||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | |||
<PackageReference Include="ServiceStack.Redis" Version="6.3.0" /> | |||
<PackageReference Include="StackExchange.Redis" Version="2.6.66" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.MessageName\BPASmartClient.MessageName.csproj" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Reference Include="Antlr3.Runtime"> | |||
<HintPath>DLL\Antlr3.Runtime.dll</HintPath> | |||
@@ -0,0 +1,137 @@ | |||
using Microsoft.CodeAnalysis; | |||
using Microsoft.CodeAnalysis.CSharp; | |||
using Microsoft.CodeAnalysis.Emit; | |||
using Microsoft.CSharp; | |||
using System; | |||
using System.CodeDom.Compiler; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Reflection; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Compiler | |||
{ | |||
/// <summary> | |||
/// C#编译器 | |||
/// </summary> | |||
public class CSharpConfig | |||
{ | |||
#region 单例模式 | |||
public static CSharpConfig Instance = null; | |||
public static CSharpConfig GetInstance() | |||
{ | |||
if (Instance == null) | |||
{ | |||
Instance = new CSharpConfig(); | |||
} | |||
return Instance; | |||
} | |||
#endregion | |||
public CSharpConfig() | |||
{ | |||
} | |||
public object RunCSharp(string code,object[] objValue,string error = "") | |||
{ | |||
object strretu = string.Empty; | |||
try | |||
{ | |||
string funName = "main"; | |||
StringBuilder builder = new StringBuilder(); | |||
builder.Append("namespace YF \n{\n class CSharpConfigRun\n"); | |||
builder.Append(" {\n"); | |||
builder.Append(code); | |||
builder.Append(" }\n}\n"); | |||
SyntaxTree tree = CSharpSyntaxTree.ParseText(builder.ToString()); | |||
var compilation = | |||
CSharpCompilation.Create("YF") | |||
.AddReferences( | |||
MetadataReference.CreateFromFile( | |||
typeof(object).Assembly.Location) | |||
) | |||
.AddSyntaxTrees(tree) | |||
.WithOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); | |||
EmitResult emitResult; | |||
byte[] dllBytes; | |||
using (var stream = new MemoryStream()) | |||
{ | |||
emitResult = compilation.Emit(stream); | |||
dllBytes = stream.ToArray(); | |||
} | |||
if (emitResult.Success) | |||
{ | |||
// Assembly assembly = Assembly.LoadFrom("d:\\test.dll"); | |||
Assembly assembly = Assembly.Load(dllBytes); | |||
var obj = assembly.CreateInstance("YF.CSharpConfigRun"); | |||
var method = obj.GetType().GetMethod("main",new Type[] { typeof(string) }); | |||
strretu = method.Invoke(obj,objValue); | |||
} | |||
//var providerOptions = new Dictionary<string,string>(); | |||
//providerOptions.Add("CompilerVersion","v4.0"); | |||
//CSharpCodeProvider compiler = new CSharpCodeProvider(providerOptions); | |||
//string output = Path.GetTempFileName(); | |||
//var cp = new CompilerParameters() { GenerateInMemory = true,OutputAssembly = output }; | |||
//cp.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location); | |||
//cp.ReferencedAssemblies.Add("Microsoft.CSharp.dll"); | |||
//cp.ReferencedAssemblies.Add("System.Core.dll"); | |||
//cp.ReferencedAssemblies.Add("Newtonsoft.Json.dll"); //添加引用 | |||
//cp.ReferencedAssemblies.Add("System.dll"); | |||
//cp.GenerateExecutable = false; | |||
//cp.EmbeddedResources.Clear(); | |||
//cp.LinkedResources.Clear(); | |||
//cp.Win32Resource = null; | |||
//cp.TreatWarningsAsErrors = false; | |||
//cp.WarningLevel = 4; | |||
//cp.TempFiles.KeepFiles = false; | |||
//CompilerResults cr = compiler.CompileAssemblyFromSource(cp,builder.ToString()); | |||
// 1.ICodeComplier | |||
// CSharpCodeProvider complier = new CSharpCodeProvider(); | |||
// // 2.CompilerParameters | |||
// CompilerParameters cp = new CompilerParameters(); | |||
// cp.ReferencedAssemblies.Add("System.dll"); //添加引用 | |||
//// cp.ReferencedAssemblies.Add("Newtonsoft.Json.dll"); //添加引用 | |||
// cp.GenerateExecutable = false; | |||
// cp.GenerateInMemory = true; | |||
// // 3.CompilerResults | |||
// CompilerResults cr = complier.CompileAssemblyFromSource(cp,builder.ToString()); | |||
//if (cr.Errors.HasErrors) | |||
//{ | |||
// foreach (CompilerError err in cr.Errors) | |||
// { | |||
// error += err.ErrorText + "\r\n"; | |||
// } | |||
//} | |||
//else | |||
//{ | |||
// // 通过反射,调用HelloWorld的实例 | |||
// Assembly objAssembly = cr.CompiledAssembly; | |||
// object objClass = objAssembly.CreateInstance("CSharpConfigRun"); | |||
// MethodInfo objFun = objClass.GetType().GetMethod(funName); | |||
// strretu = objFun.Invoke(objClass,objValue); | |||
//} | |||
} | |||
catch (Exception ex) | |||
{ | |||
error += ex.Message; | |||
} | |||
return strretu; | |||
} | |||
} | |||
} |
@@ -0,0 +1,68 @@ | |||
using Newtonsoft.Json; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Compiler | |||
{ | |||
public class FJson<T> where T : class, new() | |||
{ | |||
private static string path | |||
{ | |||
get | |||
{ | |||
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"AccessFile\\JSON")); | |||
return AppDomain.CurrentDomain.BaseDirectory + "AccessFile\\JSON\\" + typeof(T).Name + ".json"; | |||
} | |||
} | |||
public static T Data | |||
{ | |||
get; | |||
set; | |||
} = new T(); | |||
public static void Save() | |||
{ | |||
string contents = JsonConvert.SerializeObject(Data); | |||
File.WriteAllText(path,contents); | |||
} | |||
public static void Read() | |||
{ | |||
if (File.Exists(path)) | |||
{ | |||
T val = JsonConvert.DeserializeObject<T>(File.ReadAllText(path)); | |||
if (val != null) | |||
{ | |||
Data = val; | |||
} | |||
} | |||
} | |||
public static void SaveInterface() | |||
{ | |||
JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings(); | |||
jsonSerializerSettings.TypeNameHandling = TypeNameHandling.Objects; | |||
string contents = JsonConvert.SerializeObject(Data,Formatting.Indented,jsonSerializerSettings); | |||
File.WriteAllText(path,contents); | |||
} | |||
public static void ReadInterface() | |||
{ | |||
if (File.Exists(path)) | |||
{ | |||
JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings(); | |||
jsonSerializerSettings.TypeNameHandling = TypeNameHandling.Objects; | |||
T val = JsonConvert.DeserializeObject<T>(File.ReadAllText(path),jsonSerializerSettings); | |||
if (val != null) | |||
{ | |||
Data = val; | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,170 @@ | |||
using StackExchange.Redis; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Compiler | |||
{ | |||
public class FRedisClient | |||
{ | |||
#region 单例模式 | |||
//private static FRedisClient instance = null; | |||
//public static FRedisClient Instance() | |||
//{ | |||
// if (instance == null) instance = new FRedisClient(); | |||
// return instance; | |||
//} | |||
#endregion | |||
#region 变量 | |||
/// <summary> | |||
/// IP地址 | |||
/// </summary> | |||
public string redisconnection = "124.222.238.75:16000,password=123456"; | |||
/// <summary> | |||
/// redis 连接状态 | |||
/// </summary> | |||
public ConnectionMultiplexer _connection = null; | |||
/// <summary> | |||
/// 数据存储位置 | |||
/// </summary> | |||
public IDatabase _database = null; | |||
/// <summary> | |||
/// 通道建立连接 | |||
/// </summary> | |||
public ISubscriber subscibe = null; | |||
#endregion | |||
#region 外部访问 | |||
/// <summary> | |||
/// 委托出去 | |||
/// </summary> | |||
public Action<string,string> LogMeaage = null; | |||
#endregion | |||
public void Connect() | |||
{ | |||
_connection = ConnectionMultiplexer.Connect(ConfigurationOptions.Parse(redisconnection)); | |||
_database = _connection.GetDatabase(0);//默认使用db0 | |||
subscibe = _connection.GetSubscriber(); | |||
} | |||
public void Connect(string connection) | |||
{ | |||
_connection = ConnectionMultiplexer.Connect(ConfigurationOptions.Parse(connection)); | |||
if (connection.Contains("defaultDatabase=")) | |||
{ | |||
string[] str=connection.Split(','); | |||
string stro = str.ToList().Find(s => s.Contains("defaultDatabase=")); | |||
int dbi = 0; | |||
try | |||
{ | |||
dbi=int.Parse(stro.Replace("defaultDatabase=","")); | |||
} | |||
catch (Exception ex) | |||
{ | |||
throw; | |||
} | |||
_database = _connection.GetDatabase(dbi);//默认使用db0 | |||
} | |||
else | |||
{ | |||
_database = _connection.GetDatabase();//默认使用db0 | |||
} | |||
subscibe = _connection.GetSubscriber(); | |||
} | |||
/// <summary> | |||
/// 获取设备列表 | |||
/// </summary> | |||
/// <returns></returns> | |||
public Dictionary<string,string> GetKeys() | |||
{ | |||
Dictionary<string,string> keys = new Dictionary<string,string>(); | |||
foreach (var endPoint in _connection.GetEndPoints()) | |||
{ | |||
//获取指定服务器 | |||
var server = _connection.GetServer(endPoint); | |||
//在指定服务器上使用 keys 或者 scan 命令来遍历key | |||
foreach (var key in server.Keys(0,"设备列表:*")) | |||
{ | |||
//获取key对于的值 | |||
var val = _database.StringGet(key); | |||
Console.WriteLine($"key: {key}, value: {val}"); | |||
keys[key] = val; | |||
} | |||
} | |||
return keys; | |||
} | |||
/// <summary> | |||
/// 订阅通道消息 | |||
/// </summary> | |||
public void SubscribeChanne(string channelname) | |||
{ | |||
if (subscibe == null) return; | |||
subscibe.Subscribe(channelname,(channel,message) => | |||
{ | |||
MessageLog(channel,message); | |||
}); | |||
} | |||
/// <summary> | |||
/// 发布通道消息 | |||
/// </summary> | |||
public void PublishChanne(string channelname,string value) | |||
{ | |||
if (subscibe == null) return; | |||
subscibe.Publish(channelname,value); | |||
} | |||
/// <summary> | |||
/// 获取 key 值 | |||
/// </summary> | |||
public RedisValue RedisGet(string key,string hashField = "") | |||
{ | |||
if (_database == null) return new RedisValue(); | |||
RedisValue result; | |||
if (string.IsNullOrEmpty(hashField)) | |||
{ | |||
result = _database.StringGet(key); | |||
} | |||
else | |||
{ | |||
result = _database.HashGet(key,hashField); | |||
} | |||
return result; | |||
//MessageLog(key,result); | |||
} | |||
/// <summary> | |||
/// 设置 redis 的值 | |||
/// </summary> | |||
public bool RedisSet(string key,string hashField,string value) | |||
{ | |||
bool result; | |||
if (string.IsNullOrEmpty(hashField)) | |||
{ | |||
result = _database.StringSet(key,value); | |||
} | |||
else | |||
{ | |||
result = _database.HashSet(key,hashField,value); | |||
} | |||
return result; | |||
} | |||
/// <summary> | |||
/// 消息打印 | |||
/// </summary> | |||
private void MessageLog(string key,string msg) | |||
{ | |||
if (LogMeaage != null) | |||
{ | |||
LogMeaage.Invoke(key,msg); | |||
} | |||
} | |||
} | |||
} |
@@ -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> | |||
event EventHandler PropertyChange; //声明一个事件 | |||
} | |||
} |
@@ -0,0 +1,69 @@ | |||
using ServiceStack.Redis; | |||
using System.Diagnostics; | |||
namespace BPASmartClient.Compiler | |||
{ | |||
public class RedisHelper | |||
{ | |||
private volatile static RedisHelper _Instance; | |||
public static RedisHelper GetInstance => _Instance ?? (_Instance = new RedisHelper()); | |||
private RedisHelper() { } | |||
RedisClient client; | |||
public async Task<bool> ConnectAsync(string redisconnection) | |||
{ | |||
return await Task.Factory.StartNew(new Func<bool>(() => | |||
{ | |||
if (client == null) | |||
{ | |||
//"124.222.238.75:16000,password=123456"; | |||
client = new RedisClient("124.222.238.75",16000,"123456",1); | |||
client.ConnectTimeout = 5000; | |||
Stopwatch sw = new Stopwatch(); | |||
sw.Start(); | |||
while (!client.IsSocketConnected()) | |||
{ | |||
if (sw.ElapsedMilliseconds >= client.ConnectTimeout) break; | |||
Thread.Sleep(1000); | |||
} | |||
string status = client.IsSocketConnected() ? "成功" : "失败"; | |||
} | |||
return client.IsSocketConnected(); | |||
})); | |||
} | |||
/// <summary> | |||
/// 清除所有redis 数据 | |||
/// </summary> | |||
public void FlushDb() | |||
{ | |||
client?.FlushDb(); | |||
} | |||
/// <summary> | |||
/// 设置值 | |||
/// </summary> | |||
/// <typeparam name="TValue"></typeparam> | |||
/// <param name="key"></param> | |||
/// <param name="value"></param> | |||
public void SetValue<TValue>(string key,TValue value) | |||
{ | |||
var res = client?.Set<TValue>(key,value); | |||
} | |||
/// <summary> | |||
/// 获取值 | |||
/// </summary> | |||
/// <typeparam name="TResult"></typeparam> | |||
/// <param name="key"></param> | |||
/// <returns></returns> | |||
public TResult GetValue<TResult>(string key) | |||
{ | |||
if (client == null) return default(TResult); | |||
return client.Get<TResult>(key); | |||
} | |||
} | |||
} |
@@ -93,6 +93,7 @@ | |||
<None Remove="Image\光柱.png" /> | |||
<None Remove="Image\内部.png" /> | |||
<None Remove="Image\功能列表.png" /> | |||
<None Remove="Image\发光按钮.png" /> | |||
<None Remove="Image\告警.png" /> | |||
<None Remove="Image\告警\Wifi_NO.ico" /> | |||
<None Remove="Image\告警\Wifi_NO.png" /> | |||
@@ -115,6 +116,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" /> | |||
@@ -302,6 +304,7 @@ | |||
<Resource Include="Image\产品制作.png" /> | |||
<Resource Include="Image\光柱.png" /> | |||
<Resource Include="Image\功能列表.png" /> | |||
<Resource Include="Image\发光按钮.png" /> | |||
<Resource Include="Image\告警\Wifi_NO.png" /> | |||
<Resource Include="Image\告警\Wifi_OK.png" /> | |||
<Resource Include="Image\告警\严重告警.png" /> | |||
@@ -309,6 +312,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" /> | |||
@@ -1,5 +1,5 @@ | |||
using BPASmartClient.Helper; | |||
//using BPASmartClient.Message; | |||
using BPASmartClient.CustomResource.Pages.ViewModel; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Model; | |||
using System; | |||
using System.Collections.Concurrent; | |||
@@ -12,7 +12,7 @@ using System.Windows; | |||
namespace BPASmartClient.CustomResource.Pages.Model | |||
{ | |||
public class AlarmHelper<AlarmT> where AlarmT : class, new() | |||
{ | |||
public static ObservableCollection<Alarm> Alarms { get; set; } = new ObservableCollection<Alarm>(); | |||
@@ -27,6 +27,7 @@ namespace BPASmartClient.CustomResource.Pages.Model | |||
public static void Init() | |||
{ | |||
AlarmViewModel.AlarmInfos = Alarms; | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
foreach (var item in Alarm.GetType().GetProperties()) | |||
@@ -46,6 +47,15 @@ namespace BPASmartClient.CustomResource.Pages.Model | |||
} | |||
//public static void AnalogAlarm(dynamic Trigger, string info, dynamic HH = null, dynamic H = 0, dynamic L = 0, dynamic LL = 0) | |||
//{ | |||
//} | |||
/// <summary> | |||
/// 沿报警检测 | |||
/// </summary> | |||
@@ -83,7 +93,7 @@ namespace BPASmartClient.CustomResource.Pages.Model | |||
Value = value.ToString(), | |||
Time = DateTime.Now.ToString("HH:mm:ss"), | |||
}; | |||
var res = Sqlite<Alarm>.GetInstance.Base.Add(tempAlarm); | |||
Sqlite<Alarm>.GetInstance.Save(); | |||
@@ -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); | |||
} | |||
} | |||
} |
@@ -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 | |||
{ | |||
} | |||
} |
@@ -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; | |||
} | |||
} | |||
} |
@@ -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 | |||
{ | |||
} | |||
} |
@@ -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); | |||
// } | |||
//} | |||
} |
@@ -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; } | |||
} | |||
} |
@@ -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*" /> | |||
@@ -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="自动化产线上位机控制系统软件 V1.0" /> | |||
</StackPanel> | |||
@@ -404,18 +404,18 @@ | |||
HorizontalAlignment="Right" | |||
Columns="3"> | |||
<Button | |||
Visibility="Hidden" | |||
IsEnabled="False" | |||
Name="ButMin" | |||
Content="" | |||
Style="{StaticResource TitleBarStyle}" /> | |||
<Button | |||
Visibility="Hidden" | |||
IsEnabled="False" | |||
Style="{StaticResource TitleBarStyle}" | |||
Visibility="Hidden" /> | |||
<Button | |||
Name="ButMax" | |||
Content="" | |||
FontSize="22" | |||
Style="{StaticResource TitleBarStyle}" /> | |||
IsEnabled="False" | |||
Style="{StaticResource TitleBarStyle}" | |||
Visibility="Hidden" /> | |||
<Button | |||
Name="ButClose" | |||
Content="" | |||
@@ -446,8 +446,7 @@ | |||
Grid.Row="1" | |||
Margin="10" | |||
HorizontalScrollBarVisibility="Hidden" | |||
VerticalScrollBarVisibility="Hidden" | |||
> | |||
VerticalScrollBarVisibility="Hidden"> | |||
<ItemsControl ItemsSource="{Binding menuModels}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
@@ -485,7 +484,7 @@ | |||
<DataTemplate> | |||
<RadioButton | |||
Command="{Binding DataContext.NavChangedCommand, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}" | |||
CommandParameter="{Binding ToggleWindowPath}" | |||
CommandParameter="{Binding}" | |||
Content="{Binding SubMenuName}" | |||
GroupName="All" | |||
Style="{StaticResource RadioMiniButtonStyle}" | |||
@@ -513,21 +512,20 @@ | |||
</Grid.Background> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="80" /> | |||
<RowDefinition Height="0.1*" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> | |||
<CheckBox | |||
Style="{StaticResource checkBoxStyle}" | |||
Margin="5,0,5,0" | |||
Content="开机启动" | |||
IsChecked="{Binding AutoStart}" /> | |||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> | |||
<CheckBox | |||
Style="{StaticResource checkBoxStyle}" | |||
Margin="5,0,5,0" | |||
Content="设备初始化" | |||
IsChecked="{Binding Status}" | |||
/> | |||
Margin="5,0,8,0" | |||
Content="开机启动" | |||
IsChecked="{Binding AutoStart}" | |||
Style="{StaticResource checkBoxStyle}" /> | |||
<!--<CheckBox | |||
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--> | |||
@@ -1,14 +1,12 @@ | |||
<UserControl x:Class="BPASmartClient.CustomResource.Pages.View.PermissionConfigurationView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.CustomResource.Pages.View" | |||
Width="800" | |||
Height="450" | |||
mc:Ignorable="d"> | |||
<Grid> | |||
</Grid> | |||
<UserControl | |||
x:Class="BPASmartClient.CustomResource.Pages.View.PermissionConfigurationView" | |||
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" | |||
Width="800" | |||
Height="450" | |||
mc:Ignorable="d"> | |||
<Grid /> | |||
</UserControl> |
@@ -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> |
@@ -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(); | |||
} | |||
} | |||
} |
@@ -1,12 +1,12 @@ | |||
<UserControl x:Class="BPASmartClient.CustomResource.Pages.View.RecipeQueueView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.CustomResource.Pages.View" | |||
mc:Ignorable="d" | |||
d:DesignHeight="450" d:DesignWidth="800"> | |||
<Grid> | |||
</Grid> | |||
<UserControl | |||
x:Class="BPASmartClient.CustomResource.Pages.View.RecipeQueueView" | |||
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" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<Grid /> | |||
</UserControl> |
@@ -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> |
@@ -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(); | |||
} | |||
} | |||
} |
@@ -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 | |||
@@ -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" | |||
@@ -385,7 +385,7 @@ | |||
<Button.Content> | |||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> | |||
<TextBlock x:Name="t1" Width="auto" Height="auto" FontFamily="../../Fonts/font/#iconfont" Text="" VerticalAlignment="Center" FontSize="18" Margin="0,0,6,0"/> | |||
<TextBlock x:Name="t2" Width="auto" Height="auto" Text="添加账号" FontSize="17" VerticalAlignment="Center"/> | |||
<TextBlock x:Name="t2" Width="auto" Height="auto" Text="添加用户" FontSize="17" VerticalAlignment="Center"/> | |||
</StackPanel> | |||
</Button.Content> | |||