Commit c48ddd92 authored by 潘栩锋's avatar 潘栩锋 🚴

IBC, 称重 参数设置界面添加密码, 都添加 Desp 的 attribute, 用于 PLC写入记录

parent 9eecefea
......@@ -200,6 +200,10 @@
<Project>{a539505d-9ac0-426b-a9a0-197df50598b0}</Project>
<Name>OBJComponents</Name>
</ProjectReference>
<ProjectReference Include="..\..\thick_public\Project.FLY.Thick.Base\FLY.Thick.Base.UI\FLY.Thick.Base.UI.csproj">
<Project>{ec84265e-4196-4834-8ac0-81956777c5e9}</Project>
<Name>FLY.Thick.Base.UI</Name>
</ProjectReference>
<ProjectReference Include="..\..\thick_public\Project.FLY.UI.Module\FLY.UI.Module\FLY.UI.Module.csproj">
<Project>{4df79671-e814-49bd-864d-8257d6c6e072}</Project>
<Name>FLY.UI.Module</Name>
......
......@@ -32,8 +32,11 @@ namespace FLY.IBC.UI.Client
private void button_system_Click(object sender, RoutedEventArgs e)
{
Page_System p = new Page_System();
NavigationService.Navigate(p);
if (ThickTcpUiInWindow.Window_Password.Authorize(1))
{
Page_System p = new Page_System();
NavigationService.Navigate(p);
}
}
private void button_error_Click(object sender, RoutedEventArgs e)
......
......@@ -329,6 +329,10 @@
<Project>{a539505d-9ac0-426b-a9a0-197df50598b0}</Project>
<Name>OBJComponents</Name>
</ProjectReference>
<ProjectReference Include="..\..\thick_public\Project.FLY.Thick.Base\FLY.Thick.Base.UI\FLY.Thick.Base.UI.csproj">
<Project>{ec84265e-4196-4834-8ac0-81956777c5e9}</Project>
<Name>FLY.Thick.Base.UI</Name>
</ProjectReference>
<ProjectReference Include="..\..\thick_public\Project.FLY.Thick.Base\FLY.Thick.Base\FLY.Thick.Base.csproj">
<Project>{91a1aafe-a528-4c2e-a48a-9259e780255a}</Project>
<Name>FLY.Thick.Base</Name>
......
......@@ -35,22 +35,31 @@ namespace FLY.Weight.UI.Client
private void button_ingredient_Click(object sender, RoutedEventArgs e)
{
Page_Ingredient p = new Page_Ingredient();
if (ThickTcpUiInWindow.Window_Password.Authorize(1))
{
Page_Ingredient p = new Page_Ingredient();
NavigationService.Navigate(p);
NavigationService.Navigate(p);
}
}
private void button_screw_Click(object sender, RoutedEventArgs e)
{
Page_Screw p = new Page_Screw();
if (ThickTcpUiInWindow.Window_Password.Authorize(1))
{
Page_Screw p = new Page_Screw();
NavigationService.Navigate(p);
NavigationService.Navigate(p);
}
}
private void button_hopper_Click(object sender, RoutedEventArgs e)
{
Page_Hopper p = new Page_Hopper();
NavigationService.Navigate(p);
if (ThickTcpUiInWindow.Window_Password.Authorize(1))
{
Page_Hopper p = new Page_Hopper();
NavigationService.Navigate(p);
}
}
private void button_error_Click(object sender, RoutedEventArgs e)
......@@ -61,8 +70,11 @@ namespace FLY.Weight.UI.Client
private void button_thickness_Click(object sender, RoutedEventArgs e)
{
Page_Thickness p = new Page_Thickness();
NavigationService.Navigate(p);
if (ThickTcpUiInWindow.Window_Password.Authorize(1))
{
Page_Thickness p = new Page_Thickness();
NavigationService.Navigate(p);
}
}
private void button_rollmixtable_Click(object sender, RoutedEventArgs e)
......
......@@ -34,6 +34,9 @@
<target xsi:type="File" name="f_error" fileName="${basedir}/logs/error/${shortdate}.log"
layout="${longdate} ${logger} ${uppercase:${level}} ${message} ${onexception:inner=${newline} *****Error***** ${newline} ${exception:format=ToString}}"
archiveAboveSize="1048576" encoding="utf-8"/>
<target xsi:type="File" name="plcWrite" fileName="${basedir}/logs/plcWrite/${shortdate}.log"
layout="${longdate} ${message}"
archiveAboveSize="1048576" encoding="utf-8"/>
</targets>
<rules>
......@@ -45,6 +48,7 @@
-->
<!--<logger name="FObjSysOfClient" minlevel="Debug" writeTo="f_debug" />-->
<!--name 可以用匹配-->
<logger name="FLY.OBJComponents.Server.PLCProxySystem" minlevel="Info" writeTo="plcWrite" />
<logger name="*" minlevel="Error" writeTo="f_error" />
</rules>
</nlog>
......
......@@ -8,115 +8,20 @@ namespace FLY.Weight.Common
{
public static class ERRNOs
{
public static byte TYPE = 10;
static ERRNOs()
{
ERRNO_PLC_DISCONNECTED = new ERRNO() { Code = 255, Descrption = "称重 PLC连接断开" };
WEIGHT_ERRNO_LACK1 = new ERRNO() { Code = 0, Descrption = "No.1料仓缺料报警" };
WEIGHT_ERRNO_LACK2 = new ERRNO() { Code = 1, Descrption = "No.2料仓缺料报警" };
WEIGHT_ERRNO_LACK3 = new ERRNO() { Code = 2, Descrption = "No.3料仓缺料报警" };
WEIGHT_ERRNO_LACK4 = new ERRNO() { Code = 3, Descrption = "No.4料仓缺料报警" };
WEIGHT_ERRNO_LACK5 = new ERRNO() { Code = 4, Descrption = "No.5料仓缺料报警" };
WEIGHT_ERRNO_LACK6 = new ERRNO() { Code = 5, Descrption = "No.6料仓缺料报警" };
WEIGHT_ERRNO_ADD1 = new ERRNO() { Code = 10, Descrption = "No.1料斗加料异常" };
WEIGHT_ERRNO_ADD2 = new ERRNO() { Code = 11, Descrption = "No.2料斗加料异常" };
WEIGHT_ERRNO_ADD3 = new ERRNO() { Code = 12, Descrption = "No.3料斗加料异常" };
WEIGHT_ERRNO_ADD4 = new ERRNO() { Code = 13, Descrption = "No.4料斗加料异常" };
WEIGHT_ERRNO_ADD5 = new ERRNO() { Code = 14, Descrption = "No.5料斗加料异常" };
WEIGHT_ERRNO_ADD6 = new ERRNO() { Code = 15, Descrption = "No.6料斗加料异常" };
WEIGHT_ERRNO_SCREWLACK = new ERRNO() { Code = 20, Descrption = "螺杆缺料报警" };
WEIGHT_ERRNO_SCREWFLOW = new ERRNO() { Code = 21, Descrption = "螺杆流量超偏差报警" };
WEIGHT_ERRNO_BLENDER = new ERRNO() { Code = 22, Descrption = "搅拌电机故障" };
WEIGHT_ERRNO_SCRAM = new ERRNO() { Code = 23, Descrption = "急停开启" };
WEIGHT_ERRNO_BLENDER2 = new ERRNO() { Code = 24, Descrption = "搅拌电机急停开启" };
WEIGHT_ERRNO_BLENDER3 = new ERRNO() { Code = 25, Descrption = "搅拌电机未启动" };
ERRNO_PLC_REG = new ERRNO() { Code = 0, Descrption = "通过 PLC寄存器 触发的报警信息" };
}
/// <summary>
/// PLC连接断开
/// </summary>
public static ERRNO ERRNO_PLC_DISCONNECTED;
#region 单层报警类型
/// <summary>
/// No.1料仓缺料报警
/// </summary>
public static ERRNO WEIGHT_ERRNO_LACK1;
/// <summary>
/// No.2料仓缺料报警
/// </summary>
public static ERRNO WEIGHT_ERRNO_LACK2;
/// <summary>
/// No.3料仓缺料报警
/// </summary>
public static ERRNO WEIGHT_ERRNO_LACK3;
/// <summary>
/// No.4料仓缺料报警
/// </summary>
public static ERRNO WEIGHT_ERRNO_LACK4;
/// <summary>
/// No.5料仓缺料报警
/// </summary>
public static ERRNO WEIGHT_ERRNO_LACK5;
/// <summary>
/// No.6料仓缺料报警
/// </summary>
public static ERRNO WEIGHT_ERRNO_LACK6;
/// <summary>
/// No.1料斗加料异常
/// </summary>
public static ERRNO WEIGHT_ERRNO_ADD1;
/// <summary>
/// No.2料斗加料异常
/// </summary>
public static ERRNO WEIGHT_ERRNO_ADD2;
/// <summary>
/// No.3料斗加料异常
/// </summary>
public static ERRNO WEIGHT_ERRNO_ADD3;
/// <summary>
/// No.4料斗加料异常
/// 通过 PLC寄存器 触发的报警信息
/// </summary>
public static ERRNO WEIGHT_ERRNO_ADD4;
/// <summary>
/// No.5料斗加料异常
/// </summary>
public static ERRNO WEIGHT_ERRNO_ADD5;
/// <summary>
/// No.6料斗加料异常
/// </summary>
public static ERRNO WEIGHT_ERRNO_ADD6;
/// <summary>
/// 螺杆缺料报警
/// </summary>
public static ERRNO WEIGHT_ERRNO_SCREWLACK;
/// <summary>
/// 螺杆流量超偏差报警
/// </summary>
public static ERRNO WEIGHT_ERRNO_SCREWFLOW;
/// <summary>
/// 搅拌电机故障
/// </summary>
public static ERRNO WEIGHT_ERRNO_BLENDER;
/// <summary>
/// 急停开启
/// </summary>
public static ERRNO WEIGHT_ERRNO_SCRAM;
public static ERRNO ERRNO_PLC_REG;
/// <summary>
/// 搅拌电机急停开启
/// </summary>
public static ERRNO WEIGHT_ERRNO_BLENDER2;
/// <summary>
/// 搅拌电机未启动
/// </summary>
public static ERRNO WEIGHT_ERRNO_BLENDER3;
#endregion
}
}
......@@ -12,122 +12,146 @@ namespace FLY.Weight.Common
/// <summary>
/// 总流量设定
/// </summary>
public float TotalFlowSetting { get; set; }
[Description("总流量设定")]
public float TotalFlowSetting{ get; set; }
/// <summary>
/// 总流量显示
/// </summary>
public float TotalFlow { get; set; }
[Description("总流量显示")]
public float TotalFlow{ get; set; }
/// <summary>
/// 总产量
/// </summary>
public float TotalProduction { get; set; }
[Description("总产量")]
public float TotalProduction{ get; set; }
/// <summary>
/// 码轮周长mm
/// </summary>
public float WheelPerimeter { get; set; }
[Description("码轮周长mm")]
public float WheelPerimeter{ get; set; }
/// <summary>
/// 码轮脉冲
/// </summary>
public float WheelPulse { get; set; }
[Description("码轮脉冲")]
public float WheelPulse{ get; set; }
/// <summary>
/// 平均密度
/// </summary>
public float Density { get; set; }
[Description("平均密度")]
public float Density{ get; set; }
/// <summary>
/// 边料不回收
/// </summary>
public bool IsRimNoRecycle { get; set; }
[Description("边料不回收")]
public bool IsRimNoRecycle{ get; set; }
/// <summary>
/// 边料kg/h
/// </summary>
public float RimCharge { get; set; }
[Description("边料kg/h")]
public float RimCharge{ get; set; }
/// <summary>
/// 厚度um
/// </summary>
public float Thickness { get; set; }
[Description("厚度um")]
public float Thickness{ get; set; }
/// <summary>
/// 当前线速度m/min
/// </summary>
public float CurrentVelocity { get; set; }
[Description("当前线速度m/min")]
public float CurrentVelocity{ get; set; }
/// <summary>
/// 当前线速度设置m/min
/// </summary>
public float CurrentVelocitySet { get; set; }
[Description("当前线速度设置m/min")]
public float CurrentVelocitySet{ get; set; }
/// <summary>
/// 吹膜宽度mm
/// </summary>
public float TotalFilmWidth { get; set; }
[Description("吹膜宽度mm")]
public float TotalFilmWidth{ get; set; }
/// <summary>
/// 切边mm
/// </summary>
public float RimWidth { get; set; }
[Description("切边mm")]
public float RimWidth{ get; set; }
/// <summary>
/// 收卷宽度mm
/// </summary>
public float ActFilmWidth { get; set; }
[Description("收卷宽度mm")]
public float ActFilmWidth{ get; set; }
/// <summary>
/// 设定厚度um
/// </summary>
public float SetThickness { get; set; }
[Description("设定厚度um")]
public float SetThickness{ get; set; }
/// <summary>
/// 理论速度m/min
/// </summary>
public float TargetVelocity { get; set; }
[Description("理论速度m/min")]
public float TargetVelocity{ get; set; }
/// <summary>
/// 内收卷当前m
/// </summary>
public float ACurrentLen { get; set; }
[Description("内收卷当前m")]
public float ACurrentLen{ get; set; }
/// <summary>
/// 内收卷当前kg
/// </summary>
public float ACurrent { get; set; }
[Description("内收卷当前kg")]
public float ACurrent{ get; set; }
/// <summary>
/// 内收卷上卷kg
/// </summary>
public float ALast { get; set; }
[Description("内收卷上卷kg")]
public float ALast{ get; set; }
/// <summary>
/// 外收卷当前m
/// </summary>
public float BCurrentLen { get; set; }
[Description("外收卷当前m")]
public float BCurrentLen{ get; set; }
/// <summary>
/// 外收卷当前kg
/// </summary>
public float BCurrent { get; set; }
[Description("外收卷当前kg")]
public float BCurrent{ get; set; }
/// <summary>
/// 外收卷上卷kg
/// </summary>
public float BLast { get; set; }
[Description("外收卷上卷kg")]
public float BLast{ get; set; }
/// <summary>
/// 内收卷清零
/// </summary>
public bool AClear { get; set; }
[Description("内收卷清零")]
public bool AClear{ get; set; }
/// <summary>
/// 外收卷清零
/// </summary>
public bool BClear { get; set; }
[Description("外收卷清零")]
public bool BClear{ get; set; }
#endregion
public event PropertyChangedEventHandler PropertyChanged;
......
......@@ -17,6 +17,7 @@ using FLY.OBJComponents.Common;
using FObjBase;
using System.Collections.ObjectModel;
using FLY.Weight.Server.Model;
using Misc;
namespace FLY.Weight.Server
{
......@@ -468,47 +469,45 @@ namespace FLY.Weight.Server
#region 报警
class ErrorAction
{
public Dictionary<string, ERRNO> error_property;
public delegate void ErrorHandler(ref byte errcode, ref string msg,object state);
public ErrorHandler action;
public List<string> error_property;
public object state;
public delegate void ErrorHandler(ref string msg, object state);
public ErrorHandler action;
}
Dictionary<INotifyPropertyChanged, ErrorAction> obj_error = new Dictionary<INotifyPropertyChanged, ErrorAction>();
void InitError()
{
Dictionary<string, ERRNO> error_property = new Dictionary<string, ERRNO>();
error_property = new Dictionary<string, ERRNO>();
error_property.Add("IsErrorOfLack_1", ERRNOs.WEIGHT_ERRNO_LACK1);
error_property.Add("IsErrorOfLack_2", ERRNOs.WEIGHT_ERRNO_LACK2);
error_property.Add("IsErrorOfLack_3", ERRNOs.WEIGHT_ERRNO_LACK3);
error_property.Add("IsErrorOfLack_4", ERRNOs.WEIGHT_ERRNO_LACK4);
error_property.Add("IsErrorOfLack_5", ERRNOs.WEIGHT_ERRNO_LACK5);
error_property.Add("IsErrorOfLack_6", ERRNOs.WEIGHT_ERRNO_LACK6);
error_property.Add("IsErrorOfAdd_1", ERRNOs.WEIGHT_ERRNO_ADD1);
error_property.Add("IsErrorOfAdd_2", ERRNOs.WEIGHT_ERRNO_ADD2);
error_property.Add("IsErrorOfAdd_3", ERRNOs.WEIGHT_ERRNO_ADD3);
error_property.Add("IsErrorOfAdd_4", ERRNOs.WEIGHT_ERRNO_ADD4);
error_property.Add("IsErrorOfAdd_5", ERRNOs.WEIGHT_ERRNO_ADD5);
error_property.Add("IsErrorOfAdd_6", ERRNOs.WEIGHT_ERRNO_ADD6);
error_property.Add("IsErrorOfScrewLack", ERRNOs.WEIGHT_ERRNO_SCREWLACK);
error_property.Add("IsErrorOfScrewFlow", ERRNOs.WEIGHT_ERRNO_SCREWFLOW);
error_property.Add("IsErrorOfBlender", ERRNOs.WEIGHT_ERRNO_BLENDER);
error_property.Add("IsErrorOfScram", ERRNOs.WEIGHT_ERRNO_SCRAM);
error_property.Add("IsErrorOfBlender2", ERRNOs.WEIGHT_ERRNO_BLENDER2);
error_property.Add("IsErrorOfBlender3", ERRNOs.WEIGHT_ERRNO_BLENDER3);
//反射找出全部是报警的property
List<string> error_weightc_property = new List<string>();
foreach (var propertyInfo in typeof(WeighterC).GetProperties())
{
if (propertyInfo.GetCustomAttributes(typeof(IsErrorAttribute), false).Count() > 0)
{
error_weightc_property.Add(propertyInfo.Name);
}
}
List<string> error_accessory_property = new List<string>();
foreach (var propertyInfo in typeof(WeighterAccessory).GetProperties())
{
if (propertyInfo.GetCustomAttributes(typeof(IsErrorAttribute), false).Count() > 0)
{
error_accessory_property.Add(propertyInfo.Name);
}
}
for (int i = 0; i < Items.Count(); i++)
{
obj_error.Add(Items[i], new ErrorAction()
{
error_property = error_property,
error_property = error_weightc_property,
state = i,
action = (ref byte code, ref string description, object state) =>
action = (ref string description, object state) =>
{
int idx = (int)state;
description = Items[idx].Number + "层 "+ description;
code += (byte)(idx*25);
},
});
......@@ -524,7 +523,7 @@ namespace FLY.Weight.Server
foreach (var kv in obj_error)
{
string objname = PLCos.ObjNames.First(_kv => _kv.Value == kv.Key).Key;
PLCos.SetPlan(objname, kv.Value.error_property.Keys.ToArray(), 0);
PLCos.SetPlan(objname, kv.Value.error_property.ToArray(), 0);
}
......@@ -552,21 +551,26 @@ namespace FLY.Weight.Server
{
ErrorAction errorAction = obj_error[sender as INotifyPropertyChanged];
if (errorAction.error_property.ContainsKey(e.PropertyName))
if (errorAction.error_property.Contains(e.PropertyName))
{
bool b = (bool)Misc.PropertiesManager.GetValue(sender, e.PropertyName);
//获取描述
var type = sender.GetType();
var property = type.GetProperty(e.PropertyName);
bool b = (bool)property.GetValue(type);
//肯定有,没有就让它出错!!!
string desp = (property.GetCustomAttributes(typeof(DescriptionAttribute), false).First() as DescriptionAttribute).Description;
bool offIsError = (property.GetCustomAttributes(typeof(IsErrorAttribute), false).First() as IsErrorAttribute).OffIsError;
ERRNO errno = errorAction.error_property[e.PropertyName];
ERR_STATE state;
if (!errno.OffIsError)
state = b ? ERR_STATE.ON : ERR_STATE.OFF;
else
if (offIsError)
state = !b ? ERR_STATE.ON : ERR_STATE.OFF;
else
state = b ? ERR_STATE.ON : ERR_STATE.OFF;
byte errcode = errno.Code;
string description = errno.Descrption;
byte errcode = ERRNOs.ERRNO_PLC_REG.Code;
string description = desp;
errorAction.action?.Invoke(ref errcode, ref description, errorAction.state);
errorAction.action?.Invoke(ref description, errorAction.state);
mWarning.Add(errcode, description, state);
}
......
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