Commit 780c96d8 authored by 潘栩锋's avatar 潘栩锋 🚴

1. 全部使用 mahapp.metro.iconpacks.material

2. PLC 报警配置,添加 XXX PLC连接断开, XXX可自定义
parent 4d71a26f
......@@ -230,7 +230,7 @@
<Resource Include="Images\background.jpg" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MahApps.Metro.IconPacks">
<PackageReference Include="MahApps.Metro.IconPacks.Material">
<Version>3.2.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Expression.Drawing">
......
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace Misc
{
public class IPEndPointJsonConverter : JsonConverter
{
//
/// <summary>
/// 是否开启自定义反序列化,值为true时,反序列化时会走ReadJson方法,值为false时,不走ReadJson方法,而是默认的反序列化
/// </summary>
public override bool CanRead => true;
/// <summary>
/// 是否开启自定义序列化,值为true时,序列化时会走WriteJson方法,值为false时,不走WriteJson方法,而是默认的序列化
/// </summary>
public override bool CanWrite => true;
/// <summary>
/// 判断是否为IPEndPoint类型
/// </summary>
/// <param name="objectType"></param>
/// <returns></returns>
public override bool CanConvert(Type objectType)
{
return typeof(IPEndPoint) == objectType;
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
bool isNullable = IsNullableType(objectType);
Type t = isNullable ? Nullable.GetUnderlyingType(objectType) : objectType;
if (reader.TokenType == JsonToken.Null)
{
if (!IsNullableType(objectType))
{
throw new Exception(string.Format("不能转换null value to {0}.", objectType));
}
return null;
}
try
{
if (reader.TokenType == JsonToken.String)
{
string epText = reader.Value.ToString();
return Misc.StringConverter.ToIPEndPoint(epText);
}
}
catch (Exception ex)
{
throw new Exception(string.Format("Error converting value {0} to type '{1}'", reader.Value, objectType));
}
throw new Exception(string.Format("Unexpected token {0} when parsing enum", reader.TokenType));
}
public bool IsNullableType(Type t)
{
if (t == null)
{
throw new ArgumentNullException("t");
}
return (t.BaseType.FullName == "System.ValueType" && t.GetGenericTypeDefinition() == typeof(Nullable<>));
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (value == null)
{
writer.WriteNull();
return;
}
IPEndPoint ep = (IPEndPoint)value;
writer.WriteValue(ep.ToString());
}
}
}
......@@ -82,6 +82,7 @@
<Compile Include="DATARANGE.cs" />
<Compile Include="Enumerable.cs" />
<Compile Include="IgnoreAttribute.cs" />
<Compile Include="IPEndPointJsonConverter.cs" />
<Compile Include="IsErrorAttribute.cs" />
<Compile Include="PropertiesManager.cs" />
<Compile Include="PropertyBinding.cs" />
......
using System;
using Misc;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
......@@ -13,6 +15,7 @@ namespace FLY.Modbus
{
public class PLCDevice
{
[JsonConverter(typeof(IPEndPointJsonConverter))]
public IPEndPoint EP { get; set; }
}
......
......@@ -118,6 +118,6 @@ namespace FLY.OBJComponents.Common
/// <summary>
/// PLC连接断开
/// </summary>
public static ERRNO ERRNO_PLC_DISCONNECTED = new ERRNO() { Code = 255, Descrption = "收卷 PLC连接断开" };
public static ERRNO ERRNO_PLC_DISCONNECTED = new ERRNO() { Code = 255, Descrption = "PLC连接断开" };
}
}
......@@ -16,7 +16,7 @@ namespace FLY.OBJComponents.Server
#region 延时推送 MARKNO
const int MARKNO_DELAY_ISCONNECTED = 4;
#endregion
string plcName;
/// <summary>
/// 需要设置
/// </summary>
......@@ -25,10 +25,11 @@ namespace FLY.OBJComponents.Server
/// 报警系统
/// </summary>
WarningSystem mWarning;
public ErrorConf(IPLCProxySystemService PLCos, WarningSystem mWarning)
public ErrorConf(IPLCProxySystemService PLCos, WarningSystem mWarning, string plcName)
{
this.PLCos = PLCos;
this.mWarning = mWarning;
this.plcName = plcName;
}
#region 报警
......@@ -129,7 +130,7 @@ namespace FLY.OBJComponents.Server
ERRNO errno = PlcErrNos.ERRNO_PLC_DISCONNECTED;
byte errcode = errno.Code;
string description = errno.Descrption;
string description = $"{plcName} "+errno.Descrption;
mWarning.Add(errcode, description, state);
});
}, TimeSpan.FromSeconds(3), true, false, this, MARKNO_DELAY_ISCONNECTED, true);
......
......@@ -572,7 +572,7 @@
<PackageReference Include="MahApps.Metro">
<Version>2.0.0-alpha0316</Version>
</PackageReference>
<PackageReference Include="MahApps.Metro.IconPacks">
<PackageReference Include="MahApps.Metro.IconPacks.Material">
<Version>3.2.0</Version>
</PackageReference>
<PackageReference Include="MvvmLight">
......
......@@ -53,7 +53,7 @@
<StackPanel Orientation="Vertical">
<Grid Style="{StaticResource GridStyle_ButtonShadow}">
<Ellipse Style="{StaticResource backPackStyle}" Fill="White"/>
<iconPacks:PackIconMaterialDesign Kind="Clear" Style="{StaticResource iconPackStyle}" Foreground="#FFEE3232"/>
<iconPacks:PackIconMaterial Kind="Close" Style="{StaticResource iconPackStyle}" Foreground="#FFEE3232"/>
</Grid>
<TextBlock Text="清空" Style="{StaticResource titlePackStyle}"/>
</StackPanel>
......
......@@ -55,7 +55,7 @@
<StackPanel Orientation="Vertical">
<Grid Style="{StaticResource GridStyle_ButtonShadow}">
<Ellipse Style="{StaticResource backPackStyle}" Fill="{StaticResource Color_theme_static}" />
<iconPacks:PackIconFontAwesome Kind="InfoSolid" Style="{StaticResource iconPackStyle}" Foreground="White"/>
<iconPacks:PackIconMaterial Kind="AlphaI" Style="{StaticResource iconPackStyle}" Foreground="White"/>
</Grid>
<TextBlock Text="IO信息" Style="{StaticResource titlePackStyle}"/>
</StackPanel>
......@@ -82,7 +82,7 @@
<StackPanel Orientation="Vertical">
<Grid Style="{StaticResource GridStyle_ButtonShadow}">
<Ellipse Style="{StaticResource backPackStyle}" Fill="#FFEE3232" />
<iconPacks:PackIconModern Kind="Reset" Style="{StaticResource iconPackStyle}" Foreground="White"/>
<iconPacks:PackIconMaterial Kind="TrayRemove" Style="{StaticResource iconPackStyle}" Foreground="White"/>
</Grid>
<TextBlock Text="复位" Style="{StaticResource titlePackStyle}"/>
</StackPanel>
......@@ -95,7 +95,7 @@
<StackPanel Orientation="Vertical">
<Grid Style="{StaticResource GridStyle_ButtonShadow}">
<Ellipse Style="{StaticResource backPackStyle}" Fill="White"/>
<iconPacks:PackIconOcticons Kind="Mute" Style="{StaticResource iconPackStyle}" Foreground="#FFEE3232" />
<iconPacks:PackIconMaterial Kind="VolumeMute" Style="{StaticResource iconPackStyle}" Foreground="#FFEE3232" />
</Grid>
<TextBlock Text="消音" Style="{StaticResource titlePackStyle}"/>
</StackPanel>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment