Browse Source

变量管理器调整修改

样式分支
pry 2 years ago
parent
commit
9ab8234a89
56 changed files with 1820 additions and 1705 deletions
  1. +15
    -4
      BPASmart.VariableManager/App.xaml
  2. +76
    -1
      BPASmart.VariableManager/App.xaml.cs
  3. +31
    -0
      BPASmart.VariableManager/Converter/DataTableRedundantConverter.cs
  4. +34
    -0
      BPASmart.VariableManager/Converter/DeviceVisibleConverter.cs
  5. +2
    -14
      BPASmart.VariableManager/Converter/IsEnableConvert.cs
  6. +12
    -0
      BPASmart.VariableManager/Interfaces/ICommunicationDevice.cs
  7. +11
    -14
      BPASmart.VariableManager/Models/AlarmSet.cs
  8. +21
    -21
      BPASmart.VariableManager/Models/AnalogAlarmInfo.cs
  9. +15
    -17
      BPASmart.VariableManager/Models/AnalogAlarmModel.cs
  10. +30
    -30
      BPASmart.VariableManager/Models/CommDeviceModel/ModbusRtu.cs
  11. +2
    -2
      BPASmart.VariableManager/Models/CommDeviceModel/ModbusTcp.cs
  12. +17
    -15
      BPASmart.VariableManager/Models/CommDeviceModel/Siemens.cs
  13. +13
    -15
      BPASmart.VariableManager/Models/CommunicationModel.cs
  14. +2
    -1
      BPASmart.VariableManager/Models/CommunicationPar.cs
  15. +5
    -0
      BPASmart.VariableManager/Models/DelegationNotifi.cs
  16. +5
    -0
      BPASmart.VariableManager/Models/DeviceManagment.cs
  17. +6
    -18
      BPASmart.VariableManager/Models/DiscreteAlarmInfo.cs
  18. +51
    -46
      BPASmart.VariableManager/Models/PropBindInfo.cs
  19. +12
    -0
      BPASmart.VariableManager/Models/VarTableModel.cs
  20. +28
    -13
      BPASmart.VariableManager/Models/VariableInfo.cs
  21. BIN
     
  22. +71
    -41
      BPASmart.VariableManager/ViewModels/CommunicationSetViewModel.cs
  23. +0
    -130
      BPASmart.VariableManager/ViewModels/MainViewModel.cs
  24. +11
    -3
      BPASmart.VariableManager/ViewModels/NewDeviceViewModel.cs
  25. +115
    -21
      BPASmart.VariableManager/ViewModels/VariableConfig.cs
  26. +93
    -114
      BPASmart.VariableManager/Views/CommunicationSetView.xaml
  27. +3
    -0
      BPASmart.VariableManager/Views/CommunicationSetView.xaml.cs
  28. +0
    -558
      BPASmart.VariableManager/Views/MainView.xaml
  29. +0
    -41
      BPASmart.VariableManager/Views/MainView.xaml.cs
  30. +29
    -29
      BPASmart.VariableManager/Views/NewDeviceView.xaml
  31. +2
    -2
      BPASmart.VariableManager/Views/NewDeviceView.xaml.cs
  32. +515
    -371
      BPASmart.VariableManager/Views/VariableConfig.xaml
  33. +16
    -4
      BPASmart.VariableManager/Views/VariableConfig.xaml.cs
  34. +2
    -0
      BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
  35. BIN
     
  36. +5
    -3
      BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs
  37. +5
    -5
      BPASmartClient.CustomResource/Pages/View/MainView.xaml
  38. +3
    -4
      BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs
  39. +44
    -30
      BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs
  40. +175
    -0
      BPASmartClient.CustomResource/RecDictionarys/RecButtonStyle.xaml
  41. +10
    -1
      BPASmartClient.CustomResource/RecDictionarys/RecCheckBox.xaml
  42. +3
    -1
      BPASmartClient.CustomResource/RecDictionarys/RecComboBox.xaml
  43. +11
    -0
      BPASmartClient.CustomResource/UserControls/TitleTextBlock.xaml
  44. +1
    -0
      BPASmartClient.CustomResource/UserControls/TitleTextBlock.xaml.cs
  45. +126
    -0
      BPASmartClient.Helper/ActionManage.cs
  46. +27
    -16
      BPASmartClient.MorkS/View/Debug.xaml
  47. +37
    -1
      DosingSystem/Model/DeviceInquire.cs
  48. +3
    -3
      DosingSystem/View/DeviceListView.xaml
  49. +1
    -1
      DosingSystem/View/HardwareStatusView.xaml
  50. +4
    -4
      DosingSystem/View/RecipeControlView.xaml
  51. +0
    -1
      DosingSystem/View/RecipeSettingsView.xaml.cs
  52. +6
    -2
      DosingSystem/ViewModel/ManualControlViewModel.cs
  53. +26
    -24
      DosingSystem/ViewModel/RecipeControlViewModel.cs
  54. +6
    -7
      FryPot_DosingSystem/App.xaml.cs
  55. +76
    -76
      FryPot_DosingSystem/Control/DosingLogicControl.cs
  56. +6
    -1
      FryPot_DosingSystem/View/RecipeSetView.xaml.cs

+ 15
- 4
BPASmart.VariableManager/App.xaml View File

@@ -2,8 +2,9 @@
x:Class="BPASmart.VariableManager.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:BPASmart.VariableManager"
StartupUri="../Views/MainView.xaml">
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>
@@ -19,13 +20,23 @@
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecButtonStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/TextBoxStyle.xaml" />

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

<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" />


+ 76
- 1
BPASmart.VariableManager/App.xaml.cs View File

@@ -1,5 +1,11 @@
using System;
using BPASmart.VariableManager.Models;
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;
@@ -13,5 +19,74 @@ namespace BPASmart.VariableManager
/// </summary>
public partial class App : Application
{
public static Window MainWindow;
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
MenuInit();
MainView mv = new MainView();
mv.WindowState = WindowState.Normal;
MainWindow = mv;
mv.Show();
}

private void MenuInit()
{
Json<CommunicationPar>.Read();

#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 = "&#xe603;",
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");

Json<CommunicationPar>.Data.CommunicationDevices?.ToList()?.ForEach(item =>
{
RecipeManage.Add(AddSubMenuModel(item.DeviceName));
});

MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
MainMenuIcon = "&#xe62d;",
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,
};
}

}

}

+ 31
- 0
BPASmart.VariableManager/Converter/DataTableRedundantConverter.cs View File

@@ -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();
}
}
}

+ 34
- 0
BPASmart.VariableManager/Converter/DeviceVisibleConverter.cs View File

@@ -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;
using System.Windows.Data;
using BPASmart.VariableManager.Models;

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)
{
if (type.Name == 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();
}
}
}

+ 2
- 14
BPASmart.VariableManager/Converter/IsEnableConvert.cs View File

@@ -12,23 +12,11 @@ namespace BPASmart.VariableManager.Converter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool returnValue = false;
if (value != null)
{
switch (value.ToString())
{
case "无":
returnValue = false;
break;
case "离散量报警":
case "模拟量报警":
returnValue = true;
break;
default:
break;
}
return value.ToString().Length > 0;
}
return returnValue;
return false;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)


+ 12
- 0
BPASmart.VariableManager/Interfaces/ICommunicationDevice.cs View File

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

namespace BPASmart.VariableManager
{
public interface ICommunicationDevice
{
}
}

+ 11
- 14
BPASmart.VariableManager/Models/AlarmSet.cs View File

@@ -10,8 +10,7 @@ using System.Threading.Tasks;

namespace BPASmart.VariableManager.Models
{
[Table(nameof(AlarmSet))]
public class AlarmSet
public class AlarmSet : NoticeBase
{
public AlarmSet()
{
@@ -26,8 +25,11 @@ namespace BPASmart.VariableManager.Models
}
}

[Key]
public int Id { get; set; }
/// <summary>
/// 报警标签
/// </summary>
public string AlarmTag { get { return _mAlarmTag; } set { _mAlarmTag = value; OnPropertyChanged(); } }
private string _mAlarmTag = string.Empty;

/// <summary>
/// 模拟量报警信息
@@ -37,17 +39,12 @@ namespace BPASmart.VariableManager.Models
/// <summary>
/// 离散量报警信息
/// </summary>
public DiscreteAlarmInfo DiscreteAlarmInfoSet { get; set; } = new DiscreteAlarmInfo();
public DiscreteAlarmInfo DiscreteAlarmInfoSet { get { return _mDiscreteAlarmInfoSet; } set { _mDiscreteAlarmInfoSet = value; OnPropertyChanged(); } }
private DiscreteAlarmInfo _mDiscreteAlarmInfoSet = new DiscreteAlarmInfo();




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

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

+ 21
- 21
BPASmart.VariableManager/Models/AnalogAlarmInfo.cs View File

@@ -14,30 +14,30 @@ namespace BPASmart.VariableManager.Models
[Table(nameof(AnalogAlarmInfo))]
public class AnalogAlarmInfo
{
[Key]
public int Id { get; set; }
//[Key]
//public int Id { get; set; }

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

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

public AlarmSet AlarmSet { get; set; }
//public AlarmSet AlarmSet { get; set; }

}
}

+ 15
- 17
BPASmart.VariableManager/Models/AnalogAlarmModel.cs View File

@@ -12,45 +12,43 @@ namespace BPASmart.VariableManager.Models
/// <summary>
/// 模拟量报警模块
/// </summary>
public class AnalogAlarmModel
public class AnalogAlarmModel : NoticeBase
{
[Key]
public int Id { get; set; }

/// <summary>
/// 设定报警值
/// </summary>
public int AlarmValue { get; set; } = 0;
public int AlarmValue { get { return _mAlarmValue; } set { _mAlarmValue = value; OnPropertyChanged(); } }
private int _mAlarmValue = 0;


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


/// <summary>
/// 报警信息
/// </summary>
public string AlarmInfo { get; set; }
public string AlarmInfo { get { return _mAlarmInfo; } set { _mAlarmInfo = value; OnPropertyChanged(); } }
private string _mAlarmInfo = string.Empty;


/// <summary>
/// 报警标签
/// </summary>
public string AlarmTag { get; set; }
public string AlarmTag { get { return _mAlarmTag; } set { _mAlarmTag = value; OnPropertyChanged(); } }
private string _mAlarmTag = string.Empty;

/// <summary>
/// 排序标签
/// </summary>
public EAnalogAlarmType SortTag { get; set; }
public EAnalogAlarmType SortTag { get { return _mSortTag; } set { _mSortTag = value; OnPropertyChanged(); } }
private EAnalogAlarmType _mSortTag;


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

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

BPASmart.VariableManager/Models/ModbusRtu.cs → BPASmart.VariableManager/Models/CommDeviceModel/ModbusRtu.cs View File

@@ -10,17 +10,17 @@ using System.Windows;

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

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

/// <summary>
/// 串口端口
@@ -53,36 +53,36 @@ namespace BPASmart.VariableManager.Models
public string Parity { get; set; }


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

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

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

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


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


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

BPASmart.VariableManager/Models/ModbusTcp.cs → BPASmart.VariableManager/Models/CommDeviceModel/ModbusTcp.cs View File

@@ -7,12 +7,12 @@ using System.Windows;

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

/// <summary>
/// IP地址

BPASmart.VariableManager/Models/Siemens.cs → BPASmart.VariableManager/Models/CommDeviceModel/Siemens.cs View File

@@ -9,17 +9,17 @@ using System.Windows;

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

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

/// <summary>
/// IP地址
@@ -46,17 +46,19 @@ namespace BPASmart.VariableManager.Models
/// </summary>
public string PlcType { get; set; }

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

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


}


}

+ 13
- 15
BPASmart.VariableManager/Models/CommunicationModel.cs View File

@@ -1,6 +1,8 @@
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;
@@ -9,27 +11,20 @@ namespace BPASmart.VariableManager.Models
{
public class CommunicationModel : NoticeBase
{
public CommunicationModel()
{
RemoveCommand = new RelayCommand<object>((o) => { if (RemoveAction != null) RemoveAction(o); });
}

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

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

public ModbusTcp CommModbusTcp { get { return _mCommModbusTcp; } set { _mCommModbusTcp = value; OnPropertyChanged(); } }
private ModbusTcp _mCommModbusTcp = new ModbusTcp();
/// <summary>
/// 通讯设备
/// </summary>
[JsonProperty(TypeNameHandling = TypeNameHandling.Auto)]
public ICommunicationDevice CommDevice { get { return _mCommDevice; } set { _mCommDevice = value; OnPropertyChanged(); } }
private ICommunicationDevice _mCommDevice;

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

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


/// <summary>
@@ -38,7 +33,10 @@ namespace BPASmart.VariableManager.Models
public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } }
private string _mDeviceName;

/// <summary>
/// 变量表数据
/// </summary>
public ObservableCollection<VariableInfo> VarTableModels { get; set; } = new ObservableCollection<VariableInfo>();

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

+ 2
- 1
BPASmart.VariableManager/Models/CommunicationPar.cs View File

@@ -3,11 +3,12 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;

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

+ 5
- 0
BPASmart.VariableManager/Models/DelegationNotifi.cs View File

@@ -37,5 +37,10 @@ namespace BPASmart.VariableManager.Models
/// </summary>
public Action<int> VarNameChanged { get; set; }

/// <summary>
/// 页面名称
/// </summary>
public Action<string> PageName { get; set; }

}
}

+ 5
- 0
BPASmart.VariableManager/Models/DeviceManagment.cs View File

@@ -16,6 +16,11 @@ namespace BPASmart.VariableManager.Models
public string CommandParameter { get { return _mCommandParameter; } set { _mCommandParameter = value; OnPropertyChanged(); } }
private string _mCommandParameter;


public string DeviceIco { get { return _mDeviceIco; } set { _mDeviceIco = value; OnPropertyChanged(); } }
private string _mDeviceIco;


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

}


+ 6
- 18
BPASmart.VariableManager/Models/DiscreteAlarmInfo.cs View File

@@ -10,33 +10,21 @@ using BPASmart.VariableManager.Enums;
namespace BPASmart.VariableManager.Models
{
/// <summary>
/// 布尔量报警信息
/// 离散量报警信息
/// </summary>
[Table(nameof(DiscreteAlarmInfo))]
public class DiscreteAlarmInfo
public class DiscreteAlarmInfo : NoticeBase
{
[Key]
public int Id { get; set; }

/// <summary>
/// 沿报警(上升沿,下降沿)
/// </summary>
public string TrigAlarm { get; set; }
public string TrigAlarm { get { return _mTrigAlarm; } set { _mTrigAlarm = value; OnPropertyChanged(); } }
private string _mTrigAlarm = string.Empty;

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

/// <summary>
/// 设置外键
/// </summary>
[ForeignKey("AlarmSetId")]
public int AlarmSetId { get; set; }
public string AlarmInfo { get { return _mAlarmInfo; } set { _mAlarmInfo = value; OnPropertyChanged(); } }
private string _mAlarmInfo = string.Empty;

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

+ 51
- 46
BPASmart.VariableManager/Models/PropBindInfo.cs View File

@@ -15,61 +15,66 @@ namespace BPASmart.VariableManager.Models
/// </summary>
public class PropBindInfo : VariableInfo
{
public PropBindInfo()
{
ComboBoxItemInit();
CancelCommand = new RelayCommand(() => { IsOpen = false; });
ConfirmCommand = new RelayCommand(() => { IsOpen = false; });
}
//public PropBindInfo()
//{
// ComboBoxItemInit();
// //CancelCommand = new RelayCommand(() => { IsOpen = false; });
// //ConfirmCommand = new RelayCommand(() => { IsOpen = false; });
//}

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

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

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

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

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

/// <summary>
/// 报警设置框确认按钮
/// </summary>
public RelayCommand ConfirmCommand { get; set; }
//public bool IsRedundant { get { return _mIsRedundant; } set { _mIsRedundant = value; OnPropertyChanged(); } }
//private bool _mIsRedundant;


/// <summary>
/// 下拉列表初始化
/// </summary>
private void ComboBoxItemInit()
{
dataType.Clear();
alarmType.Clear();
PopupDiscreteAlarmType.Clear();
string[] DataTypeNames = Enum.GetNames(typeof(EDataType));
foreach (var item in DataTypeNames) { dataType.Add(item); }
///// <summary>
///// 报警设置框取消操作
///// </summary>
//public RelayCommand CancelCommand { get; set; }

string[] AlarmTypeNames = Enum.GetNames(typeof(EAlarmType));
foreach (var item in AlarmTypeNames) { alarmType.Add(item); }
///// <summary>
///// 报警设置框确认按钮
///// </summary>
//public RelayCommand ConfirmCommand { get; set; }

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

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

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

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

+ 12
- 0
BPASmart.VariableManager/Models/VarTableModel.cs View File

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

namespace BPASmart.VariableManager.Models
{
public class VarTableModel : NoticeBase
{
}
}

+ 28
- 13
BPASmart.VariableManager/Models/VariableInfo.cs View File

@@ -9,17 +9,12 @@ using BPASmart.VariableManager.Models;
using BPASmart.VariableManager.Enums;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Newtonsoft.Json;
using System.Collections.ObjectModel;

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

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

@@ -33,23 +28,22 @@ namespace BPASmart.VariableManager.Models
{
_mVarName = value;
OnPropertyChanged();
if (DelegationNotifi.GetInstance.VarNameChanged != null)
DelegationNotifi.GetInstance.VarNameChanged(_mID);
DelegationNotifi.GetInstance.VarNameChanged?.Invoke(_mID);
}
}
private string _mVarName;
private string _mVarName = string.Empty;

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

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

/// <summary>
/// 是否启用报警
@@ -61,7 +55,13 @@ namespace BPASmart.VariableManager.Models
/// 当前值
/// </summary>
public string CurrentValue { get { return _mCurrentValue; } set { _mCurrentValue = value; OnPropertyChanged(); } }
private string _mCurrentValue;
private string _mCurrentValue = string.Empty;

/// <summary>
/// 验证是否OK
/// </summary>
public bool IsRedundant { get { return _mIsRedundant; } set { _mIsRedundant = value; OnPropertyChanged(); } }
private bool _mIsRedundant;

/// <summary>
/// 报警设置信息
@@ -69,6 +69,21 @@ namespace BPASmart.VariableManager.Models
public AlarmSet AlarmSetProp { get { return _mAlarmSetProp; } set { _mAlarmSetProp = value; OnPropertyChanged(); } }
private AlarmSet _mAlarmSetProp = new AlarmSet();

/// <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;


//public ObservableCollection<AnalogAlarmModel> AnalogAlarmModels { get; set; } = new ObservableCollection<AnalogAlarmModel>();


}
}

BIN
View File


+ 71
- 41
BPASmart.VariableManager/ViewModels/CommunicationSetViewModel.cs View File

@@ -11,6 +11,10 @@ using System.Windows;
using BPASmartClient.Helper;
using BPASmart.VariableManager.Models;
using BPASmart.VariableManager.Enums;
//using BPASmartClient.Model;
using System.IO.Ports;
using System.IO;
using System.Reflection;

namespace BPASmart.VariableManager.ViewModels
{
@@ -18,73 +22,57 @@ namespace BPASmart.VariableManager.ViewModels
{
public CommunicationSetViewModel()
{
Json<CommunicationPar>.Read();
communicationDevices = Json<CommunicationPar>.Data.CommunicationDevices;
DataListInit();
NewConnectCommand = new RelayCommand(() => { NewConnect(); });
SaveConnectSetCommand = new RelayCommand(() =>
{
Json<CommunicationPar>.Data.communicationSets.Clear();
foreach (var item in communicationSets)
{
item.RemoveAction = null;
Json<CommunicationPar>.Data.communicationSets.Add(item);
}
Json<CommunicationPar>.Save();
});
RemoveDeviceCommand = new RelayCommand<object>(RemoveDevice);
SaveConnectSetCommand = new RelayCommand(() => { Json<CommunicationPar>.Save(); });

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

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

public ObservableCollection<CommunicationModel> communicationSets { get; set; } = new ObservableCollection<CommunicationModel>();
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()
{
DeviceManagermentSetView deviceManagermentSetView = new DeviceManagermentSetView();
NewDeviceView deviceManagermentSetView = new NewDeviceView();
var result = deviceManagermentSetView.ShowDialog();
var ResultTag = (DeviceManagermentResult)deviceManagermentSetView.Tag;
if (ResultTag != null)
{
if ((bool)result)
{
var obj = communicationSets.FirstOrDefault(p => p.DeviceName == ResultTag.DeviceName);
var obj = communicationDevices.FirstOrDefault(p => p.DeviceName == ResultTag.DeviceName);
if (obj == null)
{
CommunicationModel communicationObj = new CommunicationModel();
EDeviceType eDeviceType = (EDeviceType)Enum.Parse(typeof(EDeviceType), ResultTag.DeviceType);
switch (eDeviceType)
{
case EDeviceType.Siemens:
communicationObj.CommSiemens.SiemensVisible = Visibility.Visible;
break;
case EDeviceType.ModbusRtu:
communicationObj.CommModbusRtu.ModbusRtuVisible = Visibility.Visible;
break;
case EDeviceType.ModbusTcp:
communicationObj.CommModbusTcp.ModbusTcpVisible = Visibility.Visible;
break;
case EDeviceType.SerialPort:
break;
default:
break;
}

Type type = Assembly.Load("BPASmart.VariableManager").GetType($"BPASmart.VariableManager.Models.{ResultTag.DeviceType}");
var res = Activator.CreateInstance(type) as ICommunicationDevice;
communicationObj.DeviceName = ResultTag.DeviceName;
communicationObj.RemoveAction = RemoveDevice;
communicationSets.Add(communicationObj);
communicationObj.CommDevice = res;
Json<CommunicationPar>.Data.CommunicationDevices.Add(communicationObj);
ActionManage.GetInstance.Send("AddCommunicationDevice", ResultTag.DeviceName);
}
}
}
@@ -93,12 +81,54 @@ namespace BPASmart.VariableManager.ViewModels

private void RemoveDevice(object o)
{
var result = communicationSets.FirstOrDefault(p => p.DeviceName == o.ToString());
var result = Json<CommunicationPar>.Data.CommunicationDevices.FirstOrDefault(p => p.DeviceName == o.ToString());
if (result != null)
{
communicationSets.Remove(result);
Json<CommunicationPar>.Data.CommunicationDevices.Remove(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
- 130
BPASmart.VariableManager/ViewModels/MainViewModel.cs View File

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

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

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

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

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

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

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

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

}

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

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

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

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

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

}
#endregion

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

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

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

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

BPASmart.VariableManager/ViewModels/DeviceManagermentSetViewModel.cs → BPASmart.VariableManager/ViewModels/NewDeviceViewModel.cs View File

@@ -11,12 +11,13 @@ using Microsoft.Toolkit.Mvvm.Messaging;
using System.Diagnostics;
using BPASmart.VariableManager.Models;
using BPASmart.VariableManager.Enums;
using System.Reflection;

namespace BPASmart.VariableManager.ViewModels
{
public class DeviceManagermentSetViewModel : ObservableObject
public class NewDeviceViewModel : ObservableObject
{
public DeviceManagermentSetViewModel()
public NewDeviceViewModel()
{
Init();
CancelCommand = new RelayCommand(() =>
@@ -52,7 +53,14 @@ namespace BPASmart.VariableManager.ViewModels
private void Init()
{
DeviceType.Clear();
foreach (var item in Enum.GetNames(typeof(EDeviceType))) { DeviceType.Add(item); }
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(); } }

+ 115
- 21
BPASmart.VariableManager/ViewModels/VariableConfig.cs View File

@@ -10,13 +10,29 @@ using Microsoft.Toolkit.Mvvm.Input;
using BPASmart.VariableManager.Models;
using System.Diagnostics;
using Microsoft.EntityFrameworkCore;
using BPASmartClient.Helper;
using System.Text.Json.Serialization;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Ubiety.Dns.Core.Records;

namespace BPASmart.VariableManager.ViewModels
{
internal class VariableConfig : ObservableObject
public class VariableConfig : NoticeBase
{
private int varialeInfosIndex = -1;
public VariableConfig()
{
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");


DelegationNotifi.GetInstance.VariableSave = new Action(() => { SaveDataAsync(); });

DelegationNotifi.GetInstance.VarNameChanged = new Action<int>((p) =>
@@ -35,7 +51,24 @@ namespace BPASmart.VariableManager.ViewModels
}
}
});

DelegationNotifi.GetInstance.PageName = new Action<string>((o) =>
{
int index = Array.FindIndex(Json<CommunicationPar>.Data.CommunicationDevices.ToArray(), p => p.DeviceName == o);
varialeInfosIndex = index;
if (index >= 0 && index < Json<CommunicationPar>.Data.CommunicationDevices.Count)
{
varialeInfos = Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(index).VarTableModels;
if (varialeInfos.Count <= 0) AddRow();
//varialeInfos.Add(new VariableInfo());
}
});


GetLocalDataAsync();

CancelCommand = new RelayCommand(() => { IsOpen = false; });
ConfirmCommand = new RelayCommand(() => { IsOpen = false; });
}

/// <summary>
@@ -73,22 +106,6 @@ namespace BPASmart.VariableManager.ViewModels
/// <returns></returns>
private Task<bool> SaveDataAsync()
{
//SqlHelper<VariableInfo>.GetInstance.DbObj.RemoveRange(SqlHelper<VariableInfo>.GetInstance.DbObj.ToArray());
//foreach (var item in varialeInfos)
//{
// SqlHelper<VariableInfo>.GetInstance.Add(new VariableInfo()
// {
// ID = item.ID,
// VarName = item.VarName,
// Address = item.Address,
// DataType = item.DataType,
// IsEnableAlarm = item.IsEnableAlarm,
// CurrentValue = item.CurrentValue,
// AlarmSetProp = item.AlarmSetProp,

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

@@ -99,18 +116,95 @@ namespace BPASmart.VariableManager.ViewModels
{
App.Current.Dispatcher.Invoke(new Action(() =>
{
varialeInfos.Add(new PropBindInfo()
if (varialeInfosIndex >= 0 && varialeInfosIndex < Json<CommunicationPar>.Data.CommunicationDevices.Count)
{
ID = varialeInfos.Count + 1,
});
Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(varialeInfosIndex).VarTableModels.Add(new PropBindInfo()
{
ID = Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(varialeInfosIndex).VarTableModels.Count + 1,
});
}
//aaaa.Add(new aaa());
}));

}

#region 属性
public double NameWidth { get { return _mNameWidth; } set { _mNameWidth = value; OnPropertyChanged(); } }
public double _mNameWidth;

public double AddressWidth { get { return _mAddressWidth; } set { _mAddressWidth = value; OnPropertyChanged(); } }
private double _mAddressWidth;

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

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

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

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

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

public ObservableCollection<aaa> aaaa { get; set; } = new ObservableCollection<aaa>();
#endregion

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

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

public RelayCommand SaveCommand { get; set; }

public RelayCommand StartMotionCommand { get; set; }
#endregion


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

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

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

}

public class aaa
{

}
}

+ 93
- 114
BPASmart.VariableManager/Views/CommunicationSetView.xaml View File

@@ -2,9 +2,11 @@
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"
@@ -15,60 +17,35 @@
</UserControl.DataContext>

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

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

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

</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
<!--<ResourceDictionary 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">
@@ -78,64 +55,60 @@
</Grid.RowDefinitions>

<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button

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

<Button
FontSize="16"
Foreground="Aqua"
IcoText="&#xe626;"
Style="{StaticResource IcoButtonStyle}" />

<pry:IcoButton
Grid.Column="3"
Width="140"
Margin="0,0,20,0"
HorizontalAlignment="Left"
Command="{Binding SaveConnectSetCommand}"
Content="保存"
FontFamily="楷体"
FontSize="18"
Template="{StaticResource SaveButtonTemp}">
<Button.Foreground>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="#FFBB662A" />
<GradientStop Offset="1" Color="White" />
</LinearGradientBrush>
</Button.Foreground>
</Button>
Content="保存连接"
FontSize="17"
Foreground="Aqua"
IcoText="&#xe635;"
IsEnabled="True"
Style="{StaticResource IcoButtonStyle}" />
</StackPanel>

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

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

<!--<pry:TitleTextBlock />-->
<pry:TitleTextBlock Margin="2,2,0,0" />

<TextBlock
Margin="5"
@@ -149,7 +122,7 @@
<!--#endregion-->

<!--#region 西门子设备-->
<Grid Grid.Row="1" Visibility="{Binding CommSiemens.SiemensVisible}">
<Grid Grid.Row="1" Visibility="{Binding CommDevice, Converter={StaticResource DeviceVisibleConverter}, ConverterParameter=Siemens}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
@@ -176,7 +149,7 @@
Grid.Column="1"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommSiemens.IP}" />
Text="{Binding CommDevice.IP}" />

<TextBlock
Grid.Column="2"
@@ -186,7 +159,7 @@
Grid.Column="3"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommSiemens.PortNum}" />
Text="{Binding CommDevice.PortNum}" />

<TextBlock
Grid.Column="4"
@@ -202,20 +175,22 @@
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
ItemsSource="{Binding CommSiemens.PlcTypes}"
ItemsSource="{Binding DataContext.PlcTypes, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
SelectedIndex="0"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding CommSiemens.PlcType}" />
Text="{Binding CommDevice.PlcType}" />

<Button
Grid.Column="7"
Command="{Binding RemoveCommand}"
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 ButtonTemplate}" />
Template="{StaticResource RemoveButtonTemplate}" />

<TextBlock
Grid.Row="2"
@@ -226,7 +201,7 @@
Grid.Column="1"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommSiemens.Rack}" />
Text="{Binding CommDevice.Rack}" />

<TextBlock
Grid.Row="2"
@@ -238,7 +213,7 @@
Grid.Column="3"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommSiemens.Slot}" />
Text="{Binding CommDevice.Slot}" />

<CheckBox
Grid.Row="2"
@@ -259,7 +234,7 @@
<!--#endregion-->

<!--#region Modbus Tcp 设备-->
<Grid Grid.Row="2" Visibility="{Binding CommModbusTcp.ModbusTcpVisible}">
<Grid Grid.Row="1" Visibility="{Binding CommDevice, Converter={StaticResource DeviceVisibleConverter}, ConverterParameter=ModbusTcp}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
@@ -287,7 +262,7 @@
Grid.Column="1"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommModbusTcp.IP}" />
Text="{Binding CommDevice.IP}" />

<TextBlock
Grid.Column="2"
@@ -297,7 +272,7 @@
Grid.Column="3"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommModbusTcp.PortNum}" />
Text="{Binding CommDevice.PortNum}" />

<TextBlock
Grid.Column="4"
@@ -307,17 +282,19 @@
Grid.Column="5"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommModbusTcp.StationNo}" />
Text="{Binding CommDevice.StationNo}" />

<Button
Grid.Column="7"
Command="{Binding RemoveCommand}"
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 ButtonTemplate}" />
Template="{StaticResource RemoveButtonTemplate}" />

<CheckBox
Grid.Row="2"
@@ -339,7 +316,7 @@
<!--#endregion-->

<!--#region Modbus RTU 设备-->
<Grid Grid.Row="3" Visibility="{Binding CommModbusRtu.ModbusRtuVisible}">
<Grid Grid.Row="1" Visibility="{Binding CommDevice, Converter={StaticResource DeviceVisibleConverter}, ConverterParameter=ModbusRtu}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
@@ -368,11 +345,11 @@
FontFamily="楷体"
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
ItemsSource="{Binding CommModbusRtu.Ports}"
IsEditable="True"
ItemsSource="{Binding DataContext.Ports, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
SelectedIndex="0"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding CommModbusRtu.ComSerialPort}" />
Text="{Binding CommDevice.ComSerialPort}" />

<TextBlock
Grid.Column="2"
@@ -388,10 +365,10 @@
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
ItemsSource="{Binding CommModbusRtu.BaudRates}"
SelectedIndex="0"
ItemsSource="{Binding DataContext.BaudRates, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
SelectedIndex="6"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding CommModbusRtu.BaudRate}" />
Text="{Binding CommDevice.BaudRate}" />


<TextBlock
@@ -408,10 +385,10 @@
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
ItemsSource="{Binding CommModbusRtu.Paritys}"
ItemsSource="{Binding DataContext.Paritys, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
SelectedIndex="0"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding CommModbusRtu.Parity}" />
Text="{Binding CommDevice.Parity}" />

<TextBlock
Grid.Row="2"
@@ -423,7 +400,7 @@
Grid.Column="1"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommModbusRtu.DataBit}" />
Text="{Binding CommDevice.DataBit}" />
<TextBlock
Grid.Row="2"
Grid.Column="2"
@@ -434,7 +411,7 @@
Grid.Column="3"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommModbusRtu.StopBit}" />
Text="{Binding CommDevice.StopBit}" />

<TextBlock
Grid.Row="2"
@@ -446,17 +423,19 @@
Grid.Column="5"
Margin="0,0,20,0"
Style="{StaticResource TextBoxStyle}"
Text="{Binding CommModbusRtu.StationNo}" />
Text="{Binding CommDevice.StationNo}" />

<Button
Grid.Column="7"
Command="{Binding RemoveCommand}"
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 ButtonTemplate}" />
Template="{StaticResource RemoveButtonTemplate}" />

<CheckBox
Grid.Row="2"


+ 3
- 0
BPASmart.VariableManager/Views/CommunicationSetView.xaml.cs View File

@@ -23,6 +23,9 @@ namespace BPASmart.VariableManager.Views
public CommunicationSetView()
{
InitializeComponent();

}


}
}

+ 0
- 558
BPASmart.VariableManager/Views/MainView.xaml View File

@@ -1,558 +0,0 @@
<Window
x:Class="BPASmart.VariableManager.Views.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmart.VariableManager.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmart.VariableManager.ViewModels"
Title="MainView"
Width="1200"
Height="700"
AllowsTransparency="True"
Background="{x:Null}"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
mc:Ignorable="d">

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

<Window.Resources>


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

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

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

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

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

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

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

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

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

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

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

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

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

<Grid Background="#103153">

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

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

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


</Border>

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

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

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

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

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

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

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

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

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

</Grid>

<!--#endregion-->

</Grid>


<!--#endregion-->

</Grid>


</Window>

+ 0
- 41
BPASmart.VariableManager/Views/MainView.xaml.cs View File

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

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

BPASmart.VariableManager/Views/DeviceManagermentSetView.xaml → BPASmart.VariableManager/Views/NewDeviceView.xaml View File

@@ -1,12 +1,12 @@
<Window
x:Class="BPASmart.VariableManager.Views.DeviceManagermentSetView"
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="DeviceManagermentSetView"
Title="NewDeviceView"
Width="400"
Height="275"
AllowsTransparency="True"
@@ -18,45 +18,45 @@
mc:Ignorable="d">

<Window.DataContext>
<vm:DeviceManagermentSetViewModel />
<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
<!--<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
<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>
</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">

BPASmart.VariableManager/Views/DeviceManagermentSetView.xaml.cs → BPASmart.VariableManager/Views/NewDeviceView.xaml.cs View File

@@ -21,9 +21,9 @@ namespace BPASmart.VariableManager.Views
/// <summary>
/// DeviceManagermentSetView.xaml 的交互逻辑
/// </summary>
public partial class DeviceManagermentSetView : Window
public partial class NewDeviceView : Window
{
public DeviceManagermentSetView()
public NewDeviceView()
{
InitializeComponent();
this.MoveBorder.MouseLeftButtonDown += (o, e) => { this.DragMove(); };

+ 515
- 371
BPASmart.VariableManager/Views/VariableConfig.xaml View File

@@ -2,9 +2,11 @@
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="450"
d:DesignWidth="1000"
@@ -15,437 +17,579 @@
</UserControl.DataContext>

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

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

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

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

<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">
<Grid Margin="10" SizeChanged="TabGrid_SizeChanged">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>

<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<!--<Button
Margin="20,0,20,0"
Command="{Binding GenerateData}"
Content="添加数据" />
<Button
Margin="20,0,20,0"
Command="{Binding SaveData}"
Content="保存数据" />-->
Width="150"
Height="40"
Margin="10,0,10,0"
Command="{Binding AddCommand}"
Content="开始监控"
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 Grid.Row="1" Background="#dd2AB2E7">
<Grid
Name="TabGrid"
Grid.Row="1"
Margin="0,10,0,0"
Background="#ff0C255F">

<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.3*" />
<ColumnDefinition Width="0.2*" />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition Width="0.7*" />
<ColumnDefinition Width="0" />
<ColumnDefinition Width="0.7*" />
<ColumnDefinition Width="0.5*" />
<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"
FontSize="16"
Foreground="{StaticResource TitleFontColor}"
Style="{StaticResource TitleTextblockStyle}"
Text="ID" />

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

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

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

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

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

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

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

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

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

<Grid Grid.Column="1">
<!--<TextBox
Background="Transparent"
CaretBrush="{StaticResource CursorColor}"
Foreground="{StaticResource FontColor}"
Style="{StaticResource InputTextboxStyle}"
Text="{Binding VarName}" />-->
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
</Grid>
<Grid Grid.Column="6">
<TextBlock Style="{StaticResource TitleTextblockStyle}" Text="当前值" />
<Border
BorderBrush="{StaticResource bordColor}"
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>

<Border
Grid.ColumnSpan="7"
BorderBrush="{StaticResource bordColor}"
BorderThickness="1,0,1,0" />

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

<Grid Grid.Column="3">
<ComboBox
<Grid Grid.Row="2">
<ScrollViewer 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"
BorderBrush="Transparent"
BorderThickness="1"
FontFamily="楷体"
FontSize="20"
Foreground="{StaticResource FontColor}"
IsEditable="False"
ItemsSource="{Binding dataType}"
SelectedValue="{Binding DataType}"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding DataType}" />
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
</Grid>
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"
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>

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

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

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

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

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

<Grid>
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 AlarmSetProp.DiscreteAlarmInfoSet.TrigAlarm}" />
</Grid>

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

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

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

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

<ItemsControl ItemsSource="{Binding AlarmSetProp.AnalogAlarmModels}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid 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>

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

<ComboBox
Grid.Column="1"
Width="180"
Margin="5"
VerticalAlignment="Center"
BorderBrush="#FF23CACA"
BorderThickness="1"
<Button
Height="40"
Margin="10,5,10,10"
Command="{Binding DataContext.CancelCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
Content="取消"
FontFamily="楷体"
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
ItemsSource="{Binding PopupDiscreteAlarmType}"
SelectedIndex="1"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding AlarmSetProp.DiscreteAlarmInfoSet.TrigAlarm}" />
</Grid>
FontWeight="DemiBold"
Foreground="#009dff"
Style="{StaticResource FGImageButtonStyle}" />

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
Margin="5"
Style="{StaticResource TextBlockStyle}"
Text="输入报警信息:" />
<TextBox
<Button
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="5"
Style="{StaticResource TextBoxStyle}"
Text="{Binding AlarmSetProp.DiscreteAlarmInfoSet.AlarmInfo}" />
</Grid>
Height="40"
Margin="10,5,10,10"
Command="{Binding DataContext.ConfirmCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
Content="确认"
FontFamily="楷体"
FontSize="20"
FontWeight="DemiBold"
Foreground="#009dff"
Style="{StaticResource FGImageButtonStyle}" />

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

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

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

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

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

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

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

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

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

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

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

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

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

</Grid>
<!--#endregion-->
</Border>
</Popup>
<Border
BorderBrush="{StaticResource bordColor}"
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>

</Grid>
</Border>
</Popup>
</Grid>
<TextBlock
Grid.Column="6"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Transparent"
FontSize="14"
Foreground="{Binding IsRedundant, Converter={StaticResource tabConvert}}"
Text="{Binding ID}" />

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

</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
<!--#endregion-->
</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>

+ 16
- 4
BPASmart.VariableManager/Views/VariableConfig.xaml.cs View File

@@ -1,4 +1,5 @@
using BPASmart.VariableManager.Models;
using BPASmartClient.Helper;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -33,13 +34,24 @@ namespace BPASmart.VariableManager.Views
var obj = (VariableConfig)sender;
if (!obj.IsVisible)
{
if (DelegationNotifi.GetInstance.VariableSave != null)
{
DelegationNotifi.GetInstance.VariableSave();
}
DelegationNotifi.GetInstance.VariableSave?.Invoke();
DelegationNotifi.GetInstance.VariableSave = null;
DelegationNotifi.GetInstance.VarNameChanged = null;
}
else DelegationNotifi.GetInstance.PageName?.Invoke(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
- 0
BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj View File

@@ -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" />
@@ -303,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" />


BIN
View File


+ 5
- 3
BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs View File

@@ -1,4 +1,5 @@
using BPASmartClient.Helper;
using BPASmartClient.CustomResource.Pages.ViewModel;
using BPASmartClient.Helper;
//using BPASmartClient.Message;
using BPASmartClient.Model;
using System;
@@ -12,7 +13,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 +28,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())
@@ -83,7 +85,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();



+ 5
- 5
BPASmartClient.CustomResource/Pages/View/MainView.xaml View File

@@ -392,7 +392,7 @@
VerticalAlignment="Center"
FontSize="18"
Foreground="White"
Text="变量管理器" />
Text="自动化产线上位机控制系统软件 V1.0" />
</StackPanel>


@@ -484,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}"
@@ -512,7 +512,7 @@
</Grid.Background>

<Grid.RowDefinitions>
<RowDefinition Height="80" />
<RowDefinition Height="0.1*" />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
@@ -521,11 +521,11 @@
Content="开机启动"
IsChecked="{Binding AutoStart}"
Style="{StaticResource checkBoxStyle}" />
<CheckBox
<!--<CheckBox
Margin="5,0,5,0"
Content="设备初始化"
IsChecked="{Binding Status}"
Style="{StaticResource checkBoxStyle}" />
Style="{StaticResource checkBoxStyle}" />-->
</StackPanel>
<TextBlock
Margin="0,0,0,20"


+ 3
- 4
BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs View File

@@ -11,6 +11,8 @@ using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.Input;
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.Model;
using Google.Protobuf.WellKnownTypes;
using System.Threading;

namespace BPASmartClient.CustomResource.Pages.ViewModel
{
@@ -63,9 +65,6 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
return;
}
});

//AlarmInfos = MessageLog.GetInstance.alarmLogs;
AlarmInfos = AlarmHelper<AlarmInfo>.Alarms;
}

private void GetHistoryAlarm()
@@ -130,7 +129,7 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
private DateTime _mEndDateTime = DateTime.Now;


public ObservableCollection<Alarm> AlarmInfos { get; set; }
public static ObservableCollection<Alarm> AlarmInfos { get; set; }
public ObservableCollection<Alarm> HistoryAlarm { get; set; } = new ObservableCollection<Alarm>();

}


+ 44
- 30
BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs View File

@@ -25,13 +25,6 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
{
PermissionChange();
}), "PermissionChange");

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

}

private void PermissionChange()
@@ -42,7 +35,8 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
int SubIndex; SubIndex = Array.FindIndex(menuModels.ElementAt(MainIndex).subMenumodels.ToArray(), p => p.SubMenuVisibility == Visibility.Visible);
if (SubIndex >= 0 && SubIndex < menuModels.ElementAt(MainIndex).subMenumodels.Count)
{
DoNavChanged(menuModels.ElementAt(MainIndex).subMenumodels.ElementAt(SubIndex).ToggleWindowPath);
//DoNavChanged(menuModels.ElementAt(MainIndex).subMenumodels.ElementAt(SubIndex).ToggleWindowPath);
DoNavChanged(menuModels.ElementAt(MainIndex).subMenumodels.ElementAt(SubIndex));
}
}
}
@@ -52,31 +46,51 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
private void DoNavChanged(object obj)
{
ActionManage.GetInstance.Send("RecipeIsChange");
for (int i = 0; i < menuModels.Count; i++)

if (obj != null && obj is SubMenumodel menumodel)
{
var res = menuModels.ElementAt(i).subMenumodels.FirstOrDefault(p => p.ToggleWindowPath == obj.ToString());
if (res != null)
DisplayName = menumodel.SubMenuName;
var end = menumodel.AssemblyName.Substring(menumodel.AssemblyName.Length - 1);
var start = menumodel.ToggleWindowPath.Substring(0, 1);
bool isAddPoint = end != "." && start != ".";
string point = isAddPoint ? "." : "";
Type type = Assembly.Load(menumodel.AssemblyName)?.GetType($"{menumodel.AssemblyName}{point}{menumodel.ToggleWindowPath}");
ConstructorInfo cti = type?.GetConstructor(System.Type.EmptyTypes);
if (type?.BaseType.Name == "Window") ((Window)cti?.Invoke(null)).ShowDialog();
else if (type?.BaseType.Name == "UserControl")
{
DisplayName = res.SubMenuName;
var end = res.AssemblyName.Substring(res.AssemblyName.Length - 1);
var start = res.ToggleWindowPath.Substring(0, 1);
bool isAddPoint = end != "." && start != ".";
string point = isAddPoint ? "." : "";
Type type = Assembly.Load(res.AssemblyName)?.GetType($"{res.AssemblyName }{point}{ res.ToggleWindowPath}");
ConstructorInfo cti = type?.GetConstructor(System.Type.EmptyTypes);
if (type?.BaseType.Name == "Window")
{
((Window)cti?.Invoke(null)).ShowDialog();
break;
}
else if (type?.BaseType.Name == "UserControl")
{
//ConstructorInfo cti = type?.GetConstructor(System.Type.EmptyTypes);
MainContent = (FrameworkElement)cti?.Invoke(null);
break;
}
MainContent = (FrameworkElement)cti?.Invoke(null);
MainContent?.GetType()?.GetProperty("Name").SetValue(MainContent, menumodel.SubMenuName);
}
}



//for (int i = 0; i < menuModels.Count; i++)
//{
// var res = menuModels.ElementAt(i).subMenumodels.FirstOrDefault(p => p.ToggleWindowPath == obj.ToString());
// if (res != null)
// {
// DisplayName = res.SubMenuName;
// var end = res.AssemblyName.Substring(res.AssemblyName.Length - 1);
// var start = res.ToggleWindowPath.Substring(0, 1);
// bool isAddPoint = end != "." && start != ".";
// string point = isAddPoint ? "." : "";
// Type type = Assembly.Load(res.AssemblyName)?.GetType($"{res.AssemblyName}{point}{res.ToggleWindowPath}");
// ConstructorInfo cti = type?.GetConstructor(System.Type.EmptyTypes);
// if (type?.BaseType.Name == "Window")
// {
// ((Window)cti?.Invoke(null)).ShowDialog();
// break;
// }
// else if (type?.BaseType.Name == "UserControl")
// {
// //ConstructorInfo cti = type?.GetConstructor(System.Type.EmptyTypes);
// MainContent = (FrameworkElement)cti?.Invoke(null);
// break;
// }
// }
//}
}
private bool _status;
/// <summary>
@@ -102,7 +116,7 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
/// <summary>
/// 开机自启
/// </summary>
public bool AutoStart { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } }
public bool AutoStart { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } }
public RelayCommand<object> NavChangedCommand { get; set; }

public FrameworkElement MainContent { get { return _mMainContent; } set { _mMainContent = value; OnPropertyChanged(); } }


+ 175
- 0
BPASmartClient.CustomResource/RecDictionarys/RecButtonStyle.xaml View File

@@ -63,4 +63,179 @@
</Setter>
</Style>

<Style x:Key="OKImageButtonStyle" TargetType="Button">
<Setter Property="Margin" Value="10" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Height" Value="80" />
<Setter Property="Foreground" Value="#00c2f4" />
<Setter Property="FontFamily" Value="楷体" />
<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/按钮背景蓝色.png" />
</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="CancelImageButtonStyle" TargetType="Button">
<Setter Property="Margin" Value="10" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Height" Value="80" />
<Setter Property="Foreground" Value="#00c2f4" />
<Setter Property="FontFamily" Value="楷体" />
<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/按钮背景黄.png" />
</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="FGImageButtonStyle" TargetType="Button">
<Setter Property="Margin" Value="10" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Height" Value="80" />
<Setter Property="Foreground" Value="#00c2f4" />
<Setter Property="FontFamily" Value="楷体" />
<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/发光按钮.png" />
</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="RemoveImageButtonStyle" TargetType="Button">
<Setter Property="Margin" Value="10" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Height" Value="80" />
<Setter Property="Foreground" Value="#00c2f4" />
<Setter Property="FontFamily" Value="楷体" />
<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" />
</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>

<!--#region 移除按钮样式-->
<ControlTemplate x:Key="RemoveButtonTemplate" TargetType="Button">
<Border
x:Name="br"
Background="Transparent"
BorderBrush="#FFDE7889"
BorderThickness="2"
CornerRadius="0">
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="/BPASmartClient.CustomResource;component/Fonts/#iconfont"
FontSize="20"
Text="&#xe68e;" />
<ContentControl
Margin="10,0,5,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
Foreground="{TemplateBinding Foreground}" />
</StackPanel>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="br" Property="Background" Value="#22DE7889" />
</Trigger>

<Trigger Property="IsPressed" Value="true">
<Setter TargetName="br" Property="Background" Value="#22DE7889" />
</Trigger>

</ControlTemplate.Triggers>
</ControlTemplate>
<!--#endregion-->

</ResourceDictionary>

+ 10
- 1
BPASmartClient.CustomResource/RecDictionarys/RecCheckBox.xaml View File

@@ -1,6 +1,9 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTemplate x:Key="CbTemplate" TargetType="{x:Type CheckBox}">
<Grid Background="Transparent">
<Grid
Name="gr"
Background="Transparent"
Opacity="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition />
@@ -68,6 +71,12 @@
</Trigger.EnterActions>
</Trigger>

<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="gr" Property="Opacity" Value="0.5" />
</Trigger>



<!--<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="cb" Property="HorizontalAlignment" Value="Center" />
</Trigger>-->


+ 3
- 1
BPASmartClient.CustomResource/RecDictionarys/RecComboBox.xaml View File

@@ -26,7 +26,7 @@
VerticalAlignment="Center"
FontFamily="../Fonts/#iconfont"
FontSize="14"
Foreground="#FF23CACA"
Foreground="#ff23CACA"
Text="&#xe64d;" />
<!--<Path
x:Name="Arrow"
@@ -147,7 +147,9 @@
VerticalAlignment="Center"
Background="Transparent"
BorderThickness="0"
CaretBrush="{TemplateBinding Foreground}"
Focusable="True"
Foreground="{TemplateBinding Foreground}"
IsReadOnly="{TemplateBinding IsReadOnly}"
Visibility="Hidden" />



+ 11
- 0
BPASmartClient.CustomResource/UserControls/TitleTextBlock.xaml View File

@@ -14,6 +14,14 @@
Width="auto"
Height="auto"
SizeChanged="Canvas_SizeChanged">
<!--<Polygon x:Name="poly1">
<Polygon.Fill>
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
<GradientStop Color="Red" />
<GradientStop Offset="1" Color="#55ff0000" />
</LinearGradientBrush>
</Polygon.Fill>
</Polygon>-->
<Polygon x:Name="poly">
<Polygon.Fill>
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
@@ -22,6 +30,9 @@
</LinearGradientBrush>
</Polygon.Fill>
</Polygon>



</Canvas>
</Grid>
</UserControl>

+ 1
- 0
BPASmartClient.CustomResource/UserControls/TitleTextBlock.xaml.cs View File

@@ -33,6 +33,7 @@ namespace BPASmartClient.CustomResource.UserControls
points.Add(new Point(e.NewSize.Width, e.NewSize.Height));
points.Add(new Point(0, e.NewSize.Height));
this.poly.Points = points;
//this.poly1.Points = points;
}
}
}

+ 126
- 0
BPASmartClient.Helper/ActionManage.cs View File

@@ -4,6 +4,10 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Concurrent;
using System.Reflection.Metadata;
using System.Threading;
using System.Reflection;
using BPASmartClient.Message;

namespace BPASmartClient.Helper
{
@@ -43,6 +47,14 @@ namespace BPASmartClient.Helper
if (actions.ContainsKey(key)) actions[key].ActionPar.Invoke(par, Callback);
}

public async void SendAsync(string key, object par, Action Callback = null)
{
await Task.Run(new Action(() =>
{
if (actions.ContainsKey(key)) actions[key].ActionPar.Invoke(par, Callback);
}));
}

/// <summary>
/// 执行注册过的委托
/// </summary>
@@ -55,6 +67,14 @@ namespace BPASmartClient.Helper
if (actions.ContainsKey(key)) actions[key].ActionPars.Invokes(par, Callback);
}

public async void SendAsync(string key, object[] par, Action Callback = null)
{
await Task.Run(new Action(() =>
{
if (actions.ContainsKey(key)) actions[key].ActionPars.Invokes(par, Callback);
}));
}

/// <summary>
/// 执行注册过的委托
/// </summary>
@@ -66,6 +86,14 @@ namespace BPASmartClient.Helper
if (actions.ContainsKey(key)) actions[key].ActionBus?.Invoke(Callback);
}

public async void SendAsync(string key, Action Callback = null)
{
await Task.Run(new Action(() =>
{
if (actions.ContainsKey(key)) actions[key].ActionBus?.Invoke(Callback);
}));
}

public object SendResult(string key, object par = null)
{
lock (SendLock)
@@ -81,6 +109,23 @@ namespace BPASmartClient.Helper
return default;
}

public async Task<object> SendResultAsync(string key, object par = null)
{
return await Task.Run(new Func<object>(() =>
{
if (actions.ContainsKey(key))
if (par == null)
{
return actions[key].FuncObj?.Invoke();
}
else
{
return actions[key].FuncPar?.Invoke(par);
}
return default;
}));
}

/// <summary>
/// 根据 Key 注册需要执行的委托
/// </summary>
@@ -125,6 +170,87 @@ namespace BPASmartClient.Helper

}

public async void RegisterAsync<T>(T action, string key, bool IsAutoCancelRegister = false)
{
await Task.Run(new Action(() =>
{
if (action != null)
{
if (IsAutoCancelRegister && actions.ContainsKey(key)) actions.TryRemove(key, out Delegation d);
try
{
if (!actions.ContainsKey(key))
{
if (action is Action actionBus)
actions.TryAdd(key, new Delegation() { ActionBus = actionBus });

if (action is Action<object> actionObj)
actions.TryAdd(key, new Delegation() { ActionPar = actionObj });

if (action is Action<object[]> actionObjs)
actions.TryAdd(key, new Delegation() { ActionPars = actionObjs });

if (action is Func<object> funcObj)
actions.TryAdd(key, new Delegation() { FuncObj = funcObj });

if (action is Func<object, object> puncPar)
actions.TryAdd(key, new Delegation() { FuncPar = puncPar });
}
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx(ex.ToString());
}

}
}));
}

#region 升级版本

//private static ConcurrentDictionary<string, meth> MethodS = new ConcurrentDictionary<string, MethodBase>();
//public void Register1<TPar>(Action<TPar> action, string key, bool IsAutoCancelRegister = false)
//{
// MethodS.TryAdd("aa",new Action(() => { }));
// lock (RegisterLock)
// {
// if (action != null)
// {
// if (IsAutoCancelRegister && actions.ContainsKey(key)) actions.TryRemove(key, out Delegation d);
// try
// {
// if (!actions.ContainsKey(key))
// {
// if (action is Action actionBus)
// actions.TryAdd(key, new Delegation() { ActionBus = actionBus });

// if (action is Action<TPar> actionObj)
// actions.TryAdd(key, new Delegation() { ActionPar = actionObj });

// if (action is Action<object[]> actionObjs)
// actions.TryAdd(key, new Delegation() { ActionPars = actionObjs });

// if (action is Func<object> funcObj)
// actions.TryAdd(key, new Delegation() { FuncObj = funcObj });

// if (action is Func<object, object> puncPar)
// actions.TryAdd(key, new Delegation() { FuncPar = puncPar });
// }
// }
// catch (Exception ex)
// {
// Message.MessageLog.GetInstance.ShowDebugLog(ex.ToString());
// }

// }
// }

//}

#endregion



}




+ 27
- 16
BPASmartClient.MorkS/View/Debug.xaml View File

@@ -26,13 +26,13 @@
<Setter Property="CaretBrush" Value="Aqua" />
</Style>
<Style x:Key="CheckBox" TargetType="CheckBox">
<Setter Property="Foreground" Value="Aqua"/>
<Setter Property="FontSize" Value="16"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Margin" Value="10,0"/>
<Setter Property="IsChecked" Value="False"/>
<Setter Property="Foreground" Value="Aqua" />
<Setter Property="FontSize" Value="16" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="Margin" Value="10,0" />
<Setter Property="IsChecked" Value="False" />
</Style>
</UserControl.Resources>

@@ -49,7 +49,11 @@
Foreground="{StaticResource TitleBorderColor}"
Text="面条位置:" />
<TextBox Style="{StaticResource TextboxStyle}" Text="{Binding NoodleLoc}" />
<CheckBox Content="随机面条位置" Style="{StaticResource CheckBox}" IsChecked="{Binding IsNoodPositon}" Background="White"/>
<CheckBox
Background="White"
Content="随机面条位置"
IsChecked="{Binding IsNoodPositon}"
Style="{StaticResource CheckBox}" />

</StackPanel>

@@ -59,8 +63,17 @@
Foreground="{StaticResource TitleBorderColor}"
Text="面碗位置:" />
<TextBox Style="{StaticResource TextboxStyle}" Text="{Binding BowlLoc}" />
<CheckBox Content="随机面碗位置" Style="{StaticResource CheckBox}" IsChecked="{Binding IsBowPositon}" Background="White"/>
<CheckBox Content="启用本地模拟功能" Style="{StaticResource CheckBox}" IsChecked="{Binding LocalSimOrder}" Background="White" Command="{Binding EnableLacalSimOrder}"/>
<CheckBox
Background="White"
Content="随机面碗位置"
IsChecked="{Binding IsBowPositon}"
Style="{StaticResource CheckBox}" />
<CheckBox
Background="White"
Command="{Binding EnableLacalSimOrder}"
Content="启用本地模拟功能"
IsChecked="{Binding LocalSimOrder}"
Style="{StaticResource CheckBox}" />
</StackPanel>

<StackPanel Orientation="Horizontal">
@@ -71,8 +84,7 @@
Command="{Binding SimOrderRandomCommand}"
Content="启动随机模拟订单"
Style="{StaticResource ButtonStyle}"
Visibility="{Binding VisibilitySimOrder}"
/>
Visibility="{Binding VisibilitySimOrder}" />
<Button
Grid.Row="0"
Width="170"
@@ -80,16 +92,15 @@
Command="{Binding SimOrderRandomCloseCommand}"
Content="关闭随机模拟订单"
Style="{StaticResource ButtonStyle}"
Visibility="{Binding VisibilitySimOrder}"
/>
Visibility="{Binding VisibilitySimOrder}" />
<Button
Grid.Row="0"
Width="130"
HorizontalAlignment="Left"
Command="{Binding SimOrderCommand}"
Content="模拟订单"
Style="{StaticResource ButtonStyle}"
Visibility="{Binding VisibilitySimOrder}"/>
Style="{StaticResource ButtonStyle}"
Visibility="{Binding VisibilitySimOrder}" />
<Button
Grid.Row="0"
Width="120"


+ 37
- 1
DosingSystem/Model/DeviceInquire.cs View File

@@ -61,8 +61,44 @@ namespace BPASmartClient.DosingSystem.Model
}), "设备状态监听");
}

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

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

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

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

public void Init()
{
//TestData();
IpAddressLines();
DeviceDataInit();
ThreadManage.GetInstance().StartLong(new Action(() =>
@@ -273,7 +309,7 @@ namespace BPASmartClient.DosingSystem.Model
AlarmHelper<AlarmInfo>.Alarm.EStop2 = deviceStatus.DeviceAlarmCode.Get16bitValue(7);
AlarmHelper<AlarmInfo>.Alarm.SiloUpperLimit = deviceStatus.DeviceAlarmCode.Get16bitValue(8);
AlarmHelper<AlarmInfo>.Alarm.SiloLowerLimit = deviceStatus.DeviceAlarmCode.Get16bitValue(9);
Thread.Sleep(100);
}), $"{DeviceName} 开始监听", true);
}


+ 3
- 3
DosingSystem/View/DeviceListView.xaml View File

@@ -68,7 +68,7 @@
<DataTemplate>
<Border
Name="ShadowElement"
Width="200"
Width="180"
Height="150"
Margin="10"
VerticalAlignment="Top"
@@ -77,10 +77,10 @@
ClipToBounds="True"
CornerRadius="0">
<Border.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/蓝色背景.png" />
<ImageBrush Stretch="Fill" ImageSource="/BPASmartClient.CustomResource;component/Image/蓝色背景.png" />
</Border.Background>

<Grid Margin="20,0,20,0">
<Grid Margin="20 0">

<!--<Grid.RowDefinitions>
<RowDefinition />


+ 1
- 1
DosingSystem/View/HardwareStatusView.xaml View File

@@ -111,7 +111,7 @@
Grid.Row="1"
Width="{Binding ElementName=gr, Path=ActualWidth}"
Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="10,0,400,0"
Margin="10,0,30,0"
ConveyorBeltWidth="70"
Direction="0"
StrokeBrush="#00BEFA"


+ 4
- 4
DosingSystem/View/RecipeControlView.xaml View File

@@ -780,8 +780,8 @@
</TreeView>-->

<!-- 等待和已完成 -->
<TreeView
<TreeView
x:Name="repiceList"
HorizontalAlignment="Stretch"
Background="Transparent"
@@ -790,8 +790,8 @@
ItemsSource="{Binding UserTreeWait}"
ScrollViewer.VerticalScrollBarVisibility="Visible" />


</Grid>
</Border>


+ 0
- 1
DosingSystem/View/RecipeSettingsView.xaml.cs View File

@@ -24,7 +24,6 @@ namespace BPASmartClient.DosingSystem.View
public RecipeSettingsView()
{
InitializeComponent();
//SetAlignment();
}

//public static void SetAlignment()


+ 6
- 2
DosingSystem/ViewModel/ManualControlViewModel.cs View File

@@ -42,13 +42,17 @@ namespace BPASmartClient.DosingSystem.ViewModel

Open = new RelayCommand<object>((o) =>
{

int index = Array.FindIndex(cylinderModels.ToArray(), p => p.Name == o.ToString());
cylinderModels.ElementAt(index).LeftTog = true;
cylinderModels.ElementAt(index).RightTog = false;
});


Close = new RelayCommand<object>((o) =>
{

int index = Array.FindIndex(cylinderModels.ToArray(), p => p.Name == o.ToString());
cylinderModels.ElementAt(index).LeftTog = false;
cylinderModels.ElementAt(index).RightTog = true;
});
}



+ 26
- 24
DosingSystem/ViewModel/RecipeControlViewModel.cs View File

@@ -34,7 +34,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
Recipes.ElementAt(index).IsEnable = false;
}
MessageLog.GetInstance.ShowUserLog($"下发工单 { Recipes.ElementAt(index).RecipeName}");
MessageLog.GetInstance.ShowUserLog($"下发工单 {Recipes.ElementAt(index).RecipeName}");
devices.Enqueue(deviceName);
var res = Recipes.FirstOrDefault(p => p.RecipeName == deviceName);
UserTreeWait.Add(new RecipeModel { RecipeName = deviceName, RawMaterials = res.RawMaterials });
@@ -58,7 +58,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
Recipes.ElementAt(index).Are.Reset();
Recipes.ElementAt(index).IsEnable = false;
App.Current.Dispatcher.Invoke(new Action(() =>
App.Current.Dispatcher.Invoke(new Action(() =>
{
recipeProcesses.Clear();
UserTreeWait.RemoveAt(0);
@@ -67,7 +67,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
foreach (var item in Recipes.ElementAt(index).RawMaterials)
{
DeviceInquire.GetInstance.GetDevice(item.DeviceIp)?.Start(item.RawMaterialWeight);//启动并写入每个原料重量
App.Current.Dispatcher.Invoke(new Action(() =>
{
recipeProcesses.Add(new RawMaterialModel()
@@ -79,14 +79,15 @@ namespace BPASmartClient.DosingSystem.ViewModel
});
}));
}
Recipes.ElementAt(index).Are.WaitOne();//阻塞,直到当前配方完成
devices.TryDequeue(out string deviceName);
devices.TryDequeue(out string deviceName);
App.Current.Dispatcher.Invoke(new Action(() =>
{
UserTreeCompelete.Add(Recipes.ElementAt(index));//当前配方完成后添加到已完成的配方列表
}));
App.Current.Dispatcher.Invoke(new Action(() => {
App.Current.Dispatcher.Invoke(new Action(() =>
{
recipeProcesses.Clear();
CurrentRecipeName = string.Empty;
}));//完成后清空当前配方
@@ -117,10 +118,10 @@ namespace BPASmartClient.DosingSystem.ViewModel
}
}


var proc = recipeProcesses.Where(p=>p.RecipeStatus==3).ToList();
if (proc != null && proc.Count > 0 && proc.Count== recipeProcesses.Count)

var proc = recipeProcesses.Where(p => p.RecipeStatus == 3).ToList();
if (proc != null && proc.Count > 0 && proc.Count == recipeProcesses.Count)
{
int recipIndex = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == CurrentRecipeName);
if (recipIndex >= 0 && recipIndex < Recipes.Count)
@@ -134,8 +135,8 @@ namespace BPASmartClient.DosingSystem.ViewModel
Recipes.ElementAt(recipIndex).IsEnable = true;
Recipes.ElementAt(recipIndex).Are.Set();
}
}
}



@@ -156,30 +157,30 @@ namespace BPASmartClient.DosingSystem.ViewModel
Thread.Sleep(100);
}), "RecipeControlViewModelStatusInquire");
//测试数据
/* RawMaterialModel rawMaterial_1 = new RawMaterialModel { RawMaterialName = "香料_1" };
RawMaterialModel rawMaterial_2 = new RawMaterialModel { RawMaterialName = "香料_2" };
RawMaterialModel rawMaterial_3 = new RawMaterialModel { RawMaterialName = "香料_3" };
RawMaterialModel rawMaterial_4 = new RawMaterialModel { RawMaterialName = "香料_4" };
ObservableCollection<RawMaterialModel> rawMaterials = new ObservableCollection<RawMaterialModel> { rawMaterial_1, rawMaterial_2, rawMaterial_3, rawMaterial_4 };
UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料1", RawMaterials = rawMaterials });
UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料2", RawMaterials = rawMaterials });*/
/* RawMaterialModel rawMaterial_1 = new RawMaterialModel { RawMaterialName = "香料_1" };
RawMaterialModel rawMaterial_2 = new RawMaterialModel { RawMaterialName = "香料_2" };
RawMaterialModel rawMaterial_3 = new RawMaterialModel { RawMaterialName = "香料_3" };
RawMaterialModel rawMaterial_4 = new RawMaterialModel { RawMaterialName = "香料_4" };
ObservableCollection<RawMaterialModel> rawMaterials = new ObservableCollection<RawMaterialModel> { rawMaterial_1, rawMaterial_2, rawMaterial_3, rawMaterial_4 };
UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料1", RawMaterials = rawMaterials });
UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料2", RawMaterials = rawMaterials });*/

}

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

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

public static ObservableCollection<RecipeModel> Recipes { get; set; } = Json<LocaPar>.Data.Recipes;

public string CurrentRecipeName { get { return _RecipeName; }set { _RecipeName = value; OnPropertyChanged(); } }
public string CurrentRecipeName { get { return _RecipeName; } set { _RecipeName = value; OnPropertyChanged(); } }
private static string _RecipeName;

/// <summary>
/// 当前正在制作的配方
/// </summary>

public static ObservableCollection<RawMaterialModel> recipeProcesses { get; set; } = new ObservableCollection<RawMaterialModel>();
public static ObservableCollection<RawMaterialModel> recipeProcesses { get; set; } = new ObservableCollection<RawMaterialModel>();
/// <summary>
/// 等待制作的配方
/// </summary>
@@ -193,15 +194,16 @@ namespace BPASmartClient.DosingSystem.ViewModel
private void ChangeRecipeState(object o)
{
if (o == null) return;
if(o is string id)
if (o is string id)
{
var res = recipeProcesses.FirstOrDefault(p => p.RawMaterialId == id);
if (res != null)
{
if(res.RecipeStatus == 3)
if (res.RecipeStatus == 3)
{
res.RecipeStatus = 1;
}else
}
else
{
res.RecipeStatus = 3;
}


+ 6
- 7
FryPot_DosingSystem/App.xaml.cs View File

@@ -32,7 +32,7 @@ namespace FryPot_DosingSystem
SystemHelper.GetInstance.CreateDesktopShortcut();
MenuInite();
LoginDataInite();
MainView mv = new MainView();
LoginView lv = new LoginView();
var res = lv.ShowDialog();
@@ -60,10 +60,9 @@ namespace FryPot_DosingSystem
//});
//本地服务连接


}


protected override void OnExit(ExitEventArgs e)
{
@@ -107,7 +106,7 @@ namespace FryPot_DosingSystem
InfoLog.Add(new SubMenumodel()
{
SubMenuName = "操作日志",
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员,Permission.观察员 },
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.观察员 },
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.UserLogView"
});
@@ -186,7 +185,7 @@ namespace FryPot_DosingSystem
AssemblyName = "FryPot_DosingSystem",
ToggleWindowPath = "View.AgvView"
});
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
MainMenuIcon = "&#xe603;",
@@ -202,7 +201,7 @@ namespace FryPot_DosingSystem
UserManager.Add(new SubMenumodel()
{
SubMenuName = "用户登录",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员,Permission.观察员,Permission.操作员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员, Permission.观察员, Permission.操作员 },
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.SubPagLoginView"
});
@@ -245,7 +244,7 @@ namespace FryPot_DosingSystem
SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
AssemblyName = "FryPot_DosingSystem",
ToggleWindowPath = "View.DebugView"
});
});
#endregion
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{


+ 76
- 76
FryPot_DosingSystem/Control/DosingLogicControl.cs View File

@@ -141,13 +141,13 @@ namespace FryPot_DosingSystem.Control
string LFourrobotJobId = string.Empty;//线体4当前上游系统任务号,全局唯一 从炒锅1、4到线体4路径
string LFiverobotJobId = string.Empty; //从炒锅2、5到线体4路径
string LSixrobotJobId = string.Empty; //从炒锅3到线体4路径
List<string> LSevenrobotJobId =new List<string>(); //从线体1到清洗台路径
List<string> LSevenrobotJobId = new List<string>(); //从线体1到清洗台路径
List<string> LEightrobotJobId = new List<string>();//从线体2到清洗台路径
List<string> LNinerobotJobId = new List<string>(); //从线体3到清洗台路径
List<string> LTenrobotJobId = new List<string>(); //从清洗台到线体4路径

Dictionary<string, int> agvCode = new Dictionary<string, int>() { { "1",1 }, { "2",2 }, { "3",3 }, { "4",4 } };//agv小车的编号对AGV动画小车编号
Dictionary<string, int> agvCode = new Dictionary<string, int>() { { "1", 1 }, { "2", 2 }, { "3", 3 }, { "4", 4 } };//agv小车的编号对AGV动画小车编号

public int CleanNum = 0;//当前清洗台桶数

@@ -732,13 +732,13 @@ namespace FryPot_DosingSystem.Control
if (objData.robotJobId == LFourrobotJobId && objData.command == "LOAD")//同一任务号且处于上料阶段,AGV请求上料
{
globalVar.agvArriveUpLoad = true;//AGV到达上料位置
}
if (objData.robotJobId == LFourrobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段
{
globalVar.rollerLineOne.agvArriveLineFour = true;//AGV到达下料位置
// AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start);
// AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start);
}

if (objData.robotJobId == LFiverobotJobId && objData.command == "LOAD")
@@ -749,8 +749,8 @@ namespace FryPot_DosingSystem.Control
if (objData.robotJobId == LFiverobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段
{
globalVar.rollerLineTwo.agvArriveLineFour = true;//AGV到达下料位置
}

if (objData.robotJobId == LSixrobotJobId && objData.command == "LOAD")
@@ -761,33 +761,33 @@ namespace FryPot_DosingSystem.Control
if (objData.robotJobId == LSixrobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段
{
globalVar.rollerLineThree.agvArriveLineFour = true;//AGV到达下料位置
}
#endregion
#region 线体123到清洗台请求上下料
if (LSevenrobotJobId.FirstOrDefault(p=>p==objData.robotJobId)!=null && objData.command == "LOAD")//同一任务号且处于上料阶段,AGV请求上料
if (LSevenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.command == "LOAD")//同一任务号且处于上料阶段,AGV请求上料
{
globalVar.agvArriveLineOneLoadEmptyRoller = true;//AGV到达上料位置

}
if (LSevenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.command == "UNLOAD")//同一任务号且处于下料阶段
{
globalVar.rollerLineOne.agvArriveCleanUnLoad = true;//AGV到达下料位置
}

if ( LEightrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.command == "LOAD")
if (LEightrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.command == "LOAD")
{
globalVar.agvArriveLineTwoLoadEmptyRoller = true;//AGV到达上料位置

}
if ( LEightrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.command == "UNLOAD")//同一任务号且处于下料阶段
if (LEightrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.command == "UNLOAD")//同一任务号且处于下料阶段
{
globalVar.rollerLineTwo.agvArriveCleanUnLoad = true;//AGV到达下料位置

}

@@ -798,22 +798,22 @@ namespace FryPot_DosingSystem.Control
}
if (LNinerobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.command == "UNLOAD")//同一任务号且处于下料阶段
{
globalVar.rollerLineThree.agvArriveCleanUnLoad = true;//AGV到达下料位置
}
#endregion
#region 清洗台到线体4请求上下料
if (LTenrobotJobId.FirstOrDefault(p=>p==objData.robotJobId)!=null && objData.command == "LOAD")
if (LTenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.command == "LOAD")
{
globalVar.agvArriveCleanLoad = true;//agv到达清洗台上料位置
}
if (LTenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.command == "UNLOAD")
{
globalVar.agvArriveLineFour = true;//agv到达线体4下料位置
}
#endregion
}
@@ -848,7 +848,7 @@ namespace FryPot_DosingSystem.Control
{
//日志
}
//线体1任务上报
if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LOnerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料点上料完成,这里指线体上料
{
@@ -909,7 +909,7 @@ namespace FryPot_DosingSystem.Control
if (objData.state == "DONE" && objData.robotJobId == LOnerobotJobId && objData.jobData.targetPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指线体到炒锅下料
{
AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode],CartMotionTrajectory.hj);
AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hj);
AgvViewModel.GetInstance().Set小车停止(agvCode[objData.jobData.agvCode]);
AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
}
@@ -934,8 +934,8 @@ namespace FryPot_DosingSystem.Control




#region 炒锅空桶上下料任务信息回报
//线体1任务上报
@@ -996,27 +996,27 @@ namespace FryPot_DosingSystem.Control
{
AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start);
AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
}
//线体2任务上报
if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LFiverobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指炒锅空桶下料
{
AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start);
AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
}
//线体3任务上报
if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LSixrobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指炒锅空桶下料
{
AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start);
AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
}
//线体1任务上报
if (objData.state == "DONE" && objData.robotJobId == LFourrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指炒锅空桶下料
{
MessageLog.GetInstance.ShowRunLog("1号线炒锅空桶在4号线卸桶完成");
if (globalVar.LFourRollerNum >= 8)
{
AgvViewModel.GetInstance().Set滚筒线上数量(4, "8");
@@ -1034,7 +1034,7 @@ namespace FryPot_DosingSystem.Control
if (objData.state == "DONE" && objData.robotJobId == LFiverobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指炒锅空桶下料
{
MessageLog.GetInstance.ShowRunLog("2号线炒锅空桶在4号线卸桶完成");
if (globalVar.LFourRollerNum >= 8)
{
AgvViewModel.GetInstance().Set滚筒线上数量(4, "8");
@@ -1051,7 +1051,7 @@ namespace FryPot_DosingSystem.Control
if (objData.state == "DONE" && objData.robotJobId == LSixrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指炒锅空桶下料
{
MessageLog.GetInstance.ShowRunLog("3号线炒锅空桶在4号线卸桶完成");
if (globalVar.LFourRollerNum >= 8)
{
AgvViewModel.GetInstance().Set滚筒线上数量(4, "8");
@@ -1097,7 +1097,7 @@ namespace FryPot_DosingSystem.Control
}


if (objData.state == "DONE" && LSevenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指从线体1到清戏台空桶下料
if (objData.state == "DONE" && LSevenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指从线体1到清戏台空桶下料
{
LSevenrobotJobId.Remove(objData.robotJobId);
MessageLog.GetInstance.ShowRunLog("线体【1】空桶在清洗台卸桶完成");
@@ -1106,7 +1106,7 @@ namespace FryPot_DosingSystem.Control
AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
AgvViewModel.GetInstance().SetCleanRollerNum(++CleanNum);
}
if (objData.state == "DONE" && LEightrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指从线体2到清戏台空桶下料
if (objData.state == "DONE" && LEightrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指从线体2到清戏台空桶下料
{
LEightrobotJobId.Remove(objData.robotJobId);
MessageLog.GetInstance.ShowRunLog("线体【2】空桶在清洗台卸桶完成");
@@ -1126,21 +1126,21 @@ namespace FryPot_DosingSystem.Control
}
#endregion
#region 清洗台到线体4
if (objData.state == "ROLLER_LOAD_FINISH" && LTenrobotJobId.FirstOrDefault(p=>p==objData.robotJobId)!=null && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料位置上料完成,指清戏台空桶到上料
if (objData.state == "ROLLER_LOAD_FINISH" && LTenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料位置上料完成,指清戏台空桶到上料
{
MessageLog.GetInstance.ShowRunLog("清洗台空桶装载完成");
AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.OnllYes);
AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hs_4);//去四号空桶线
AgvViewModel.GetInstance().SetCleanRollerNum(--CleanNum);
}
if (objData.state == "ROLLER_UNLOAD_DOING" && LTenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.targetPointCode == "")//指定下料点正在下料,指清洗台空桶到线体4下料
{
AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start);
}

if (objData.state == "DONE"&& LTenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指清戏台空桶到线体4下料
if (objData.state == "DONE" && LTenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指清戏台空桶到线体4下料
{
LTenrobotJobId.Remove(objData.robotJobId);
MessageLog.GetInstance.ShowRunLog("【4】号线空桶回桶完成");
@@ -1324,17 +1324,17 @@ namespace FryPot_DosingSystem.Control
{
ThreadManage.GetInstance().StopTask("滚筒线2空桶清洗任务线程", new Action(() =>
{
globalVar.rollerLineTwo.StationEight = 0;
globalVar.rollerLineTwo.EmptyRollerNums.Clear();
globalVar.rollerLineTwo.EmptyRollerNums.Add(208);
globalVar.rollerLineTwo.IsEpmtyBefore = false;
//globalVar.rollerLineTwo.CanRun = true;

globalVar.agvArriveLineFour = false;
globalVar.agvArriveCleanLoad = false;
globalVar.rollerLineTwo.agvArriveCleanUnLoad = false;
globalVar.agvArriveLineTwoLoadEmptyRoller = false;
globalVar.agvArriveLineTwoLoadCom = false;
@@ -1347,7 +1347,7 @@ namespace FryPot_DosingSystem.Control
{
ThreadManage.GetInstance().StopTask("滚筒线3空桶清洗任务线程", new Action(() =>
{

globalVar.rollerLineThree.StationEight = 0;
globalVar.rollerLineThree.EmptyRollerNums.Clear();
@@ -1427,7 +1427,7 @@ namespace FryPot_DosingSystem.Control
globalVar.fryPotFour.InputMaterialRollerRunningSingle = data[3];
globalVar.fryPotFive.InputMaterialRollerRunningSingle = data[4];

AlarmHelper<AlarmInfo>.Alarm.FryPotOneRollerRunning= data[0];
AlarmHelper<AlarmInfo>.Alarm.FryPotOneRollerRunning = data[0];
AlarmHelper<AlarmInfo>.Alarm.FryPotTwoRollerRunning = data[1];
AlarmHelper<AlarmInfo>.Alarm.FryPotThreeRollerRunning = data[2];
AlarmHelper<AlarmInfo>.Alarm.FryPotFourRollerRunning = data[3];
@@ -1568,7 +1568,7 @@ namespace FryPot_DosingSystem.Control
FryPotMonitorManage.GetInstance.fryFive.OilCapacity = globalVar.fryPotFive.OilCapacity;
FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy += globalVar.fryPotFive.OilCapacity;
}
//炒锅状态实时显示
FryPotStatusDisplay();
RollerLineStatusDisplay();
@@ -1645,7 +1645,7 @@ namespace FryPot_DosingSystem.Control
using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryOneRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
{
writeStream.Position = writeStream.Length;
PotOneStatus p1 = new PotOneStatus { Temperature = FryPotMonitorManage.GetInstance.fryOne.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryOne.HotPower, Speed = FryPotMonitorManage.GetInstance.fryOne.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryOne.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryOne.TotalProduct, RecipeName = fryOneRecipe,Time = DateTime.Now.ToShortDateString() };
PotOneStatus p1 = new PotOneStatus { Temperature = FryPotMonitorManage.GetInstance.fryOne.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryOne.HotPower, Speed = FryPotMonitorManage.GetInstance.fryOne.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryOne.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryOne.TotalProduct, RecipeName = fryOneRecipe, Time = DateTime.Now.ToShortDateString() };
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(writeStream, p1);

@@ -2149,9 +2149,9 @@ namespace FryPot_DosingSystem.Control

//下发AGV去空桶线洗桶任务
e: string id = Guid.NewGuid().ToString("N");
if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id)!=null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
goto e;
string info = AGVHelper.GetInstance.AgvLeaveLOneToClean(id);//1号线到洗桶处
LSevenrobotJobId.Add(id);
Thread.Sleep(500);
@@ -2166,7 +2166,7 @@ namespace FryPot_DosingSystem.Control
AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
}
}
}

/// <summary>
@@ -2174,7 +2174,7 @@ namespace FryPot_DosingSystem.Control
/// </summary>
private void AgvFromLineTwoToCleanPlate()
{
// 线体2到清洗台
if (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 0)//输送线无故障
{
@@ -2202,8 +2202,8 @@ namespace FryPot_DosingSystem.Control
AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
}
}
}
/// <summary>
/// 线体3到清洗台
@@ -2255,7 +2255,7 @@ namespace FryPot_DosingSystem.Control
MessageLog.GetInstance.ShowRunLog("警告:清洗台空桶下料就位信号已发送,进桶滚筒未运行!!");
}
}
}

/// <summary>
@@ -2263,7 +2263,7 @@ namespace FryPot_DosingSystem.Control
/// </summary>
private void AgvArriveCleanPlateFromLineTwo()
{
if (globalVar.rollerLineTwo.agvArriveCleanUnLoad)
{
globalVar.rollerLineTwo.agvArriveCleanUnLoad = false;
@@ -2276,7 +2276,7 @@ namespace FryPot_DosingSystem.Control
MessageLog.GetInstance.ShowRunLog("警告:清洗台空桶下料就位信号已发送,进桶滚筒未运行!!");
}
}

}
/// <summary>
@@ -2284,7 +2284,7 @@ namespace FryPot_DosingSystem.Control
/// </summary>
private void AgvArriveCleanPlateFromLineThree()
{
if (globalVar.rollerLineThree.agvArriveCleanUnLoad)
{
globalVar.rollerLineThree.agvArriveCleanUnLoad = false;
@@ -2825,7 +2825,7 @@ namespace FryPot_DosingSystem.Control
{
Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_4.workflows.Add(new WorkflowModel { id = globalVar.LOneCurrentCookingStep, Name = OutputMaterialQuene.ElementAt(0).materialType.MaterialName, isBool = IsBool.Yes }); }));
}
//炒锅滚筒进料运行到位处理
FryPotOneOrFourInputMaterialRollerOperate();
AgvFromFryPotOneOrFourToClean();//上游下发搬运任务给AGV
@@ -2885,7 +2885,7 @@ namespace FryPot_DosingSystem.Control

Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_5.workflows.Add(new WorkflowModel { id = globalVar.LTwoCurrentCookingStep, Name = LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialName, isBool = IsBool.Yes }); }));
}
//炒锅滚筒进料运行到位处理
FryPotTwoOrFiveInputMaterialRollerOperate();
AgvFromFryPotTwoOrFiveToClean();//上游下发搬运任务给AGV
@@ -2921,7 +2921,7 @@ namespace FryPot_DosingSystem.Control
{

Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.workflows.Add(new WorkflowModel { id = globalVar.LThreeCurrentCookingStep, Name = LThreeOutputMaterialQuene.ElementAt(0).materialType.MaterialName, isBool = IsBool.Yes }); }));
//炒锅滚筒进料运行到位处理
FryPotThreeInputMaterialRollerOperate();
AgvFromFryPotThreeToClean();//上游下发搬运任务给AGV
@@ -3062,7 +3062,7 @@ namespace FryPot_DosingSystem.Control
//}
globalVar.LTwoagvFryPotEmptyRollerArrive = false;
globalVar.LTwoInOrOutputLock = false;
MessageLog.GetInstance.ShowRunLog($"AGV在【{globalVar.LTwoFryPotSerial}】号炒锅将空桶回收到4号滚筒线");
//AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅
globalVar.AllowAgvToLineTwoLoadRoller = true;
@@ -3108,7 +3108,7 @@ namespace FryPot_DosingSystem.Control
//AgvViewModel.GetInstance().Set小车运动(3, CartMotionTrajectory.hs_3);
globalVar.LThreeagvFryPotEmptyRollerArrive = false;
globalVar.LThreeInOrOutputLock = false;
MessageLog.GetInstance.ShowRunLog($"AGV在【{globalVar.LThreeFryPotSerial}】号炒锅将空桶回收到4号滚筒线");
//AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅
globalVar.AllowAgvToLineThreeLoadRoller = true;
@@ -3139,7 +3139,7 @@ namespace FryPot_DosingSystem.Control
MessageLog.GetInstance.ShowRunLog("AGV从清洗台到达【4】号回收线体,准备卸桶");
// MessageLog.GetInstance.ShowRunLog("卸桶完成");
}
}

public void EmptyRollerToLinFourFromPot()
@@ -3175,7 +3175,7 @@ namespace FryPot_DosingSystem.Control
//public void EmptyRollerToLinFourFromLineOne()
//{

// if (globalVar.rollerLineOne.agvArriveLineFour)//agv到达线体4下料位置
// {
// globalVar.rollerLineOne.agvArriveLineFour = false;
@@ -3184,7 +3184,7 @@ namespace FryPot_DosingSystem.Control
// MessageLog.GetInstance.ShowRunLog("AGV从1号线体对应炒锅到达【4】号回收线体,准备卸桶");
// // MessageLog.GetInstance.ShowRunLog("卸桶完成");
// }

//}

@@ -3201,7 +3201,7 @@ namespace FryPot_DosingSystem.Control
// MessageLog.GetInstance.ShowRunLog("AGV从2号线体对应炒锅到达【4】号回收线体,准备卸桶");
// // MessageLog.GetInstance.ShowRunLog("卸桶完成");
// }
//}
///// <summary>
///// 线体3对应炒锅到4号线体下料
@@ -3517,7 +3517,7 @@ namespace FryPot_DosingSystem.Control
{
case 1:
erp: string id = Guid.NewGuid().ToString("N");//上游唯一ID
if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p=>p==id)!=null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
{
goto erp;
}
@@ -3597,7 +3597,7 @@ namespace FryPot_DosingSystem.Control
if (InputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
{
MessageLog.GetInstance.ShowRunLog($"AGV正在装载{materialInfo.materialType.MaterialLoc}号料桶");
globalVar.LOneCurrentCookingStep++;
OutputMaterialQuene.Enqueue(materialInfo);
globalVar.agvArriveUpLoad = false;
@@ -3633,7 +3633,7 @@ namespace FryPot_DosingSystem.Control
DeviceOperate.GetInstance.WritePlcData("D1052", 1);//agv到达线体1上料位置信号下发plc
MessageLog.GetInstance.ShowRunLog($"AGV正在装载【{emptyRollerNum}】号空料桶");

globalVar.agvArriveLineOneLoadEmptyRoller = false;
//原料到位,agv到位,agv自行运料到清洗处
}
@@ -3674,7 +3674,7 @@ namespace FryPot_DosingSystem.Control
if (LTwoInputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
{
MessageLog.GetInstance.ShowRunLog($"AGV正在装载{materialInfo.materialType.MaterialLoc}号料桶");
globalVar.LTwoCurrentCookingStep++;
LTwoOutputMaterialQuene.Enqueue(materialInfo);
globalVar.agvArriveLTwoUpLoad = false;
@@ -3711,8 +3711,8 @@ namespace FryPot_DosingSystem.Control
MessageLog.GetInstance.ShowRunLog("AGV到达【2】号滚筒线装桶位置");
DeviceOperate.GetInstance.WritePlcData("D1053", 1);//agv到达线体2上料位置信号下发plc
MessageLog.GetInstance.ShowRunLog($"AGV正在装载【{emptyRollerNum}】号空料桶");
globalVar.agvArriveLineTwoLoadEmptyRoller = false;

//原料到位,agv到位,agv自行运料到清洗处
@@ -3754,7 +3754,7 @@ namespace FryPot_DosingSystem.Control
if (LThreeInputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
{
MessageLog.GetInstance.ShowRunLog($"AGV正在装载{materialInfo.materialType.MaterialLoc}号料桶");
globalVar.LThreeCurrentCookingStep++;
LThreeOutputMaterialQuene.Enqueue(materialInfo);
globalVar.agvArriveLThreeUpLoad = false;
@@ -3791,8 +3791,8 @@ namespace FryPot_DosingSystem.Control
MessageLog.GetInstance.ShowRunLog("AGV到达【3】号滚筒线装桶位置");
DeviceOperate.GetInstance.WritePlcData("D1054", 1);//agv到达线体3上料位置信号下发plc
MessageLog.GetInstance.ShowRunLog($"AGV正在装载【{emptyRollerNum}】号空料桶");
globalVar.agvArriveLineThreeLoadEmptyRoller = false;
// globalVar.rollerLineThree.IsEpmtyBefore = false;

@@ -3850,7 +3850,7 @@ namespace FryPot_DosingSystem.Control
{
if (errorCode == "SUCCESS")
{
MessageLog.GetInstance.ShowRunLog($"AGV去{num}号滚筒线装桶");
}
else if (errorCode == "Analysis Error")
@@ -3871,7 +3871,7 @@ namespace FryPot_DosingSystem.Control
{
if (errorCode == "SUCCESS")
{
MessageLog.GetInstance.ShowRunLog($"AGV去{num}号滚筒线卸桶");
}
else if (errorCode == "Analysis Error")


+ 6
- 1
FryPot_DosingSystem/View/RecipeSetView.xaml.cs View File

@@ -24,7 +24,12 @@ namespace FryPot_DosingSystem.View
public RecipeSetView()
{
InitializeComponent();
this.Unloaded += RecipeSetView_Unloaded;
}

private void RecipeSetView_Unloaded(object sender, RoutedEventArgs e)
{

}
}
}

Loading…
Cancel
Save