Commit 441a1a7e authored by 潘栩锋's avatar 潘栩锋 🚴

把V8的服务器多国语言部分,复制过来

parent 221b90d1
......@@ -115,8 +115,12 @@ namespace FLY.OBJComponents.Common
/// </summary>
public struct ERRNO
{
public UInt16 Code;
public string Descrption;
public int Code;
public string Description;
public override string ToString()
{
return $"[{Code}] {Description}";
}
}
public class PlcErrNos
......@@ -126,6 +130,6 @@ namespace FLY.OBJComponents.Common
/// <summary>
/// PLC连接断开
/// </summary>
public ERRNO ERRNO_PLC_DISCONNECTED = new ERRNO() { Code = 65535, Descrption = "PLC连接断开" };
public ERRNO ERRNO_PLC_DISCONNECTED = new ERRNO() { Code = 65535, Description = "PLC连接断开" };
}
}
......@@ -59,7 +59,7 @@ namespace FLY.OBJComponents.Server
//初始化 PLC连接断开的描述列表
int plcCnt = PLCos.PLCs.Count();
int errCode = plcErrCodeBegin;
string descrption = PlcErrNos.Instance.ERRNO_PLC_DISCONNECTED.Descrption;
string descrption = PlcErrNos.Instance.ERRNO_PLC_DISCONNECTED.Description;
for (int i = 0; i < plcCnt; i++)
{
plcDisconnectedErrMsgs.Add(new PlcDisconnectedErrMsg()
......
......@@ -86,7 +86,7 @@ namespace FLY.OBJComponents.Server
public void Add(ERRNO errno,bool canReset = true)
{
Add(errno.Code, errno.Descrption,canReset:canReset);
Add(errno.Code, errno.Description,canReset:canReset);
}
public void Remove(ERRNO errno)
{
......
using FLY.OBJComponents.IService;
using MultiLayout.UiModule;
using MultiLayout.UiModule;
using Misc;
using System;
using System.Collections.Generic;
......@@ -11,6 +11,7 @@ using System.Threading.Tasks;
using FLY.Thick.Base.UI;
using Unity;
using FLY.Thick.Base.Common;
using System.Windows;
namespace FLY.Thick.Base.UI.OnInit
{
......@@ -31,13 +32,13 @@ namespace FLY.Thick.Base.UI.OnInit
IUnityContainer container;
bool enableScanErrBigTip;
int warningTipId=-1;
int warningTipId = -1;
public int Level { get; }
public OnInitError(
IUnityContainer container,
ParamDictionary paramDictionary,
FLY.OBJComponents.IService.IWarningSystem2Service warningService,
int lv = 1)
ParamDictionary paramDictionary,
IWarningSystem2Service warningService,
int lv = 1)
{
Level = lv;
this.container = container;
......@@ -55,18 +56,19 @@ namespace FLY.Thick.Base.UI.OnInit
}
private void WarningService_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(warningService.ReasonList)) {
if (e.PropertyName == nameof(warningService.ReasonList))
{
if (!enableScanErrBigTip)
return;
FObjBase.PollModule.Current.Poll_JustOnce(
new FObjBase.PollModule.PollHandler(delegate ()
{
List<int> errCodes = new List<int> { ERRNOs.Instance.SCAN_ERRNO_OVERCTRL.Code, ERRNOs.Instance.SCAN_ERRNO_OVERTOL.Code };
List<int> errCodes = new List<int> { ERRNOs.Instance.ERRNO_OVERCTRL.Code, ERRNOs.Instance.ERRNO_OVERTOL.Code };
var record = warningService.ReasonList;
if (record == null)
......@@ -94,22 +96,19 @@ namespace FLY.Thick.Base.UI.OnInit
}
return;
}
int errcode = rs.First().ErrCode;
string msg = rs.First().Description;
string description = rs.First().Description;
string path = paramDictionary.GetValue<string>(ParamDistItemKeys.WarningTipPath);
string msg = description;
//报警!!!!!!!!
//记录打开的报警提示框Id,用于以后关闭
warningTipId = FLY.ControlLibrary.Window_WarningTip.Show(
$"编码={errcode}",
msg,
TimeSpan.MaxValue,
warningTipId = FLY.ControlLibrary.Window_WarningTip.Show(null, msg, TimeSpan.MaxValue,
path,
warningService.Reset
);
}), this, MARKNO_WARNING_RING);
}
}
......
......@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
namespace FLY.Thick.Base.Common
{
......@@ -13,28 +14,84 @@ namespace FLY.Thick.Base.Common
{
public static ERRNOs Instance { get; } = new ERRNOs();
public ERRNO BASE_ERRNO_ONBOOT = new ERRNO() { Code = 250, Descrption = "系统启动" };
public ERRNO BASE_ERRNO_RINGTEST = new ERRNO() { Code = 1, Descrption = "报警测试" };
public ERRNO BASE_ERRNO_AD_MIN = new ERRNO() { Code = 2, Descrption = "AD值太小" };
public ERRNO BASE_ERRNO_AD_MAX = new ERRNO() { Code = 3, Descrption = "AD值太大" };
public ERRNO BASE_ERRNO_EMERGENCY = new ERRNO() { Code = 4, Descrption = "急停" };
public ERRNO BASE_ERRNO_LIMIT = new ERRNO() { Code = 5, Descrption = "限位" };
public ERRNO BASE_ERRNO_FLYAD7DISCONNECTED = new ERRNO() { Code = 6, Descrption = "AD盒连接断开" };
public ERRNO BASE_ERRNO_LICENSE_TIP = new ERRNO() { Code = 7, Descrption = "授权将要过期" };
public ERRNO BASE_ERRNO_LICENSE = new ERRNO() { Code = 8, Descrption = "授权限制" };
public ERRNO BASE_ERRNO_FILE_ERR_RESTORE = new ERRNO() { Code = 9, Descrption = "数据文件异常,恢复不成功" };
public ERRNO BASE_ERRNO_FILE_RESTORE = new ERRNO() { Code = 10, Descrption = "数据文件异常,恢复成功" };
public ERRNO SCAN_ERRNO_OVERCTRL = new ERRNO() { Code = 11, Descrption = "扫描超控制报警" };
public ERRNO SCAN_ERRNO_OVERTOL = new ERRNO() { Code = 12, Descrption = "扫描超规格报警" };
public ERRNO BASE_ERRNO_DB = new ERRNO() { Code = 13, Descrption = "数据库异常,重建" };
public ERRNO BASE_ERRNO_TIMEGRIDADV = new ERRNO() { Code = 14, Descrption = "AD卡版本太低,不能启动 [高级AD数据]" };
public ERRNO BASE_ERRNO_DB_BACKUP = new ERRNO() { Code = 15, Descrption = "已经连续开机1个月,数据库需要备份归档,请尽快重启服务器" };
public ERRNO SCAN_ERRNO_FATAL = new ERRNO() { Code = 20, Descrption = "扫描异常,致命错误 必须停止扫描" };
public ERRNO SYNC_ERRNO_FATAL = new ERRNO() { Code = 21, Descrption = "同步异常,致命错误 必须停止扫描" };
public ERRNO MEASURE_SYNC_ERRNO_FATAL = new ERRNO() { Code = 22, Descrption = "测量同步参数异常,致命错误 必须停止" };
public ERRNO SAMPLE_ERRNO_Failure = new ERRNO() { Code = 60, Descrption = "样品取样出错" };
public ERRNOs()
{
string resourceName = $"dict.StringResource.ERRNO";
var rd_errnos = (ResourceDictionary)Application.Current.FindResource(resourceName);//异常直接让它出错
Type t = this.GetType();
var fields = t.GetFields();
foreach (var field in fields)
{
if (field.Name.StartsWith("ERRNO_"))
{
var errno = (ERRNO)field.GetValue(this);
errno.Description = ToDescription(rd_errnos, field.Name);
field.SetValue(this, errno);
}
}
}
string ToDescription(ResourceDictionary rd_errnos, string errNoKey)
{
string resourceName = $"str.ERRNO.{errNoKey}";
return (string)rd_errnos[resourceName];//异常直接让它出错
}
public virtual List<ERRNO> GetAll()
{
List<ERRNO> list = new List<ERRNO>();
Type t = this.GetType();
var fields = t.GetFields();
foreach (var field in fields)
{
if (field.Name.StartsWith("ERRNO_"))
{
var errno = (ERRNO)field.GetValue(this);
list.Add(errno);
}
}
list.Sort((e0, e1) =>
{
return e0.Code.CompareTo(e1.Code);
});
return list;
}
public ERRNO ERRNO_AUTH_EXP = new ERRNO() { Code = 0, Description = "AUTH_EXP" };//"授权过期" };
public ERRNO ERRNO_FLYAD7_DC = new ERRNO() { Code = 1, Description = "FLYAD7_DC" };//"AD盒连接断开" };
public ERRNO ERRNO_AD_MIN = new ERRNO() { Code = 2, Description = "AD_MIN" };//"AD值太小" };
public ERRNO ERRNO_AD_MAX = new ERRNO() { Code = 3, Description = "AD_MAX" };//"AD值太大" };
public ERRNO ERRNO_SCRAM = new ERRNO() { Code = 4, Description = "SCRAM" };//"急停" };
public ERRNO ERRNO_LIMIT = new ERRNO() { Code = 5, Description = "LIMIT" };//"限位" };
public ERRNO ERRNO_OVERTOL = new ERRNO() { Code = 6, Description = "OVERTOL" };//"扫描超规格报警" };
public ERRNO ERRNO_SCAN_FATAL = new ERRNO() { Code = 7, Description = "SCAN_FATAL" };//"扫描动作异常" };
public ERRNO ERRNO_SAMPLE_FATAL = new ERRNO() { Code = 8, Description = "SAMPLE_FATAL" };//"采样异常" };
public ERRNO ERRNO_ALARM_TEST = new ERRNO() { Code = 9, Description = "ALARM_TEST" };//"报警测试" };
public ERRNO ERRNO_WILL_EXP = new ERRNO() { Code = 10, Description = "WILL_EXP" };//"授权将要过期" };
public ERRNO ERRNO_OVERCTRL = new ERRNO() { Code = 11, Description = "OVERCTRL" };//"扫描超控制报警" };
public ERRNO ERRNO_DB_BACKUP = new ERRNO() { Code = 12, Description = "DB_BACKUP" };//"已经连续开机1个月,数据库需要备份归档,请尽快重启服务器" };
public ERRNO ERRNO_SAMPLE_ParamErr = new ERRNO() { Code = 20, Description = "SAMPLE_ParamErr" };//"采样出错:参数异常" };
public ERRNO ERRNO_SAMPLE_ADZero = new ERRNO() { Code = 21, Description = "SAMPLE_ADZero" };//"采样出错:AD值为0" };
public ERRNO ERRNO_SAMPLE_NoData = new ERRNO() { Code = 22, Description = "SAMPLE_NoData" };//"采样出错:没有采集数据" };
public ERRNO ERRNO_SAMPLE_FilterErr = new ERRNO() { Code = 23, Description = "SAMPLE_FilterErr" };//"采样出错:滤波数据与原始数据差异大" };
public ERRNO ERRNO_SAMPLE_PercentErr = new ERRNO() { Code = 24, Description = "SAMPLE_PercentErr" };//"采样出错:样品AD与上次差异大" };
public ERRNO ERRNO_SAMPLE_CrossErr = new ERRNO() { Code = 25, Description = "SAMPLE_CrossErr" };//"采样出错:样品比值与上次差异大" };
}
......
using FLY.Thick.Base.IService;
using FlyADBase;
using FObjBase;
using System;
using System.Collections.Generic;
......@@ -20,10 +21,10 @@ namespace FLY.Thick.Base.Common
/// 6.在Gage中 调用 FlyADIODefine.SetInstance(new FlyADIODefine());
/// 7.在Gage中 注册 AD盒事件, AD盒版本修改时,FlyADIODefine.SerVersion(version);
/// </summary>
public class FlyADIODefine: IFlyAdIoDefineService
public class FlyADIODefine : IFlyAdIoDefineService
{
protected static FlyADIODefine instance;
public static void SetInstance(FlyADIODefine flyADIODefine)
public static void SetInstance(FlyADIODefine flyADIODefine)
{
instance = flyADIODefine;
}
......@@ -31,70 +32,73 @@ namespace FLY.Thick.Base.Common
/// 子类 需要 重新 把子类对象 赋值给 Instance, 确保整个环境只用一个版本的 单例
/// </summary>
public static FlyADIODefine Instance => instance;
#region 输入口
/// <summary>
/// 扫描按钮信号
/// </summary>
public int InNo_Scan { get; protected set; } = 1 - 1;
/// <summary>
/// 归零信号
/// </summary>
[Description("归零信号")]
public int InNo_Org { get; protected set; } = 2 - 1;
/// <summary>
/// 正向限位
/// </summary>
[Description("正向限位")]
public int InNo_Limit_Forw { get; protected set; } = 3 - 1;
/// <summary>
/// 反向限位
/// </summary>
[Description("反向限位")]
public int InNo_Limit_Backw { get; protected set; } = 4 - 1;
/// <summary>
/// 数据有效
/// </summary>
[Description("数据有效")]
public int InNo_DataValid { get; protected set; } = 6 - 1;
/// <summary>
/// 急停 and 手动正转
/// </summary>
[Description("急停 & 手动正转")]
public int InNo_Manual_Forw { get; protected set; } = 7 - 1;
/// <summary>
/// 急停 and 手动反转
/// </summary>
[Description("急停 & 手动反转")]
public int InNo_Manual_Backw { get; protected set; } = 8 - 1;
/// <summary>
/// 同步输入信号
/// </summary>
[Description("同步输入信号")]
public int InNo_Sync { get; protected set; } = 9 - 1;
/// <summary>
/// 辊速信号
/// </summary>
[Description("辊速信号")]
public int InNo_Roll { get; protected set; } = 11 - 1;
/// <summary>
/// 控制主轴脉冲启动计数输入, o3 接 i11;
/// i11 为 0 计数停止
/// </summary>
[Description("主轴脉冲启动计数")]
public int InNo_Pos2OnOff { get; protected set; } = 11 - 1;
/// <summary>
/// 纵向光纤信号
/// </summary>
[Description("纵向光纤信号")]
public int InNo_VSign { get; protected set; } = 12 - 1;
#endregion
#region 输出口
/// <summary>
/// 扫描动作中
/// </summary>
[Description("扫描动作中")]
public int OutNo_Scan { get; protected set; } = 1 - 1;
/// <summary>
/// 变频器反转 VF0 是松下的变频器牌子
/// </summary>
......@@ -132,37 +136,36 @@ namespace FLY.Thick.Base.Common
#endregion
private int version = 2;
/// <summary>
/// 根据AD盒的版本,设置
/// </summary>
/// <param name="version"></param>
public virtual void SerVersion(int version)
IFlyAD flyAD;
public virtual void SetFlyAD(IFlyAD _flyAD)
{
this.version = version;
if (this.version == 3)
this.flyAD = _flyAD;
Misc.BindingOperations.SetBinding(flyAD, nameof(flyAD.HardwareVersion), () =>
{
InNo_Org = 13 - 1;
InNo_Limit_Forw = 14 - 1;
InNo_Limit_Backw = 16 - 1;
if (this.flyAD.HardwareVersion < 3)
{
InNo_Org = 2 - 1;
InNo_Limit_Forw = 3 - 1;
InNo_Limit_Backw = 4 - 1;
InNo_Roll = 15 - 1;
}
else
{
InNo_Org = 2 - 1;
InNo_Limit_Forw = 3 - 1;
InNo_Limit_Backw = 4 - 1;
InNo_Roll = 11 - 1;
}
else
{
InNo_Org = 13 - 1;
InNo_Limit_Forw = 14 - 1;
InNo_Limit_Backw = 16 - 1;
InNo_Roll = 11 - 1;
}
InNo_Roll = 15 - 1;
}
});
}
/// <summary>
/// 获取输入口 属性名
/// </summary>
/// <returns></returns>
protected virtual List<string> GetInputPropertyNames()
protected virtual List<string> GetInputPropertyNames()
{
List<string> reponse = new List<string>();
Type t = this.GetType();
......@@ -201,37 +204,45 @@ namespace FLY.Thick.Base.Common
public void GetIODefine(AsyncCBHandler asyncDelegate, object asyncContext)
{
//获取全部带 Description 的属性,且名字 InNo_XXX 或 OutNo_XXX
IODefineCollection reponse = new IODefineCollection();
IODefineCollection response = new IODefineCollection();
List<IODefine> list = new List<IODefine>();
reponse.List = list;
if (version == 3)
response.List = list;
if (flyAD.HardwareVersion < 3)
{
reponse.InCount = 16;
reponse.OutCount = 8;
response.InCount = 12;
response.OutCount = 4;
}
else {
reponse.InCount = 12;
reponse.OutCount = 4;
else
{
response.InCount = 16;
response.OutCount = 8;
}
var inputPropertyNames = GetInputPropertyNames();
var outputPropertyNames = GetOutputPropertyNames();
if (flyAD.MotorType != FlyADBase.MOTORTYPE.VF0)
{
//把 变频器 接口删除
outputPropertyNames.Remove(nameof(OutNo_VF0_Forw));
outputPropertyNames.Remove(nameof(OutNo_VF0_Backw));
outputPropertyNames.Remove(nameof(OutNo_VF0_Slow));
}
if (flyAD.MotorType == FlyADBase.MOTORTYPE.VF0)
{
//变频器 模式 没有扫描状态灯
outputPropertyNames.Remove(nameof(OutNo_Scan));
}
Type t = this.GetType();
foreach (var propertyName in inputPropertyNames)
{
var property = t.GetProperty(propertyName);
var attrs = property.GetCustomAttributes(typeof(DescriptionAttribute), false);
if (attrs.Count() == 0)
{
throw new Exception($"{propertyName} 没有写 [Description]");
}
var attr = attrs.First() as DescriptionAttribute;
string desp = attr.Description;
string desp = propertyName;
var index = (int)property.GetValue(this);
var iodefine = new IODefine()
......@@ -240,6 +251,7 @@ namespace FLY.Thick.Base.Common
Index = index,
Description = desp
};
list.Add(iodefine);
}
......@@ -247,14 +259,7 @@ namespace FLY.Thick.Base.Common
{
var property = t.GetProperty(propertyName);
var attrs = property.GetCustomAttributes(typeof(DescriptionAttribute), false);
if (attrs.Count() == 0)
{
throw new Exception($"{propertyName} 没有写 [Description]");
}
var attr = attrs.First() as DescriptionAttribute;
string desp = attr.Description;
string desp = propertyName;
var index = (int)property.GetValue(this);
var iodefine = new IODefine()
......@@ -266,7 +271,7 @@ namespace FLY.Thick.Base.Common
list.Add(iodefine);
}
asyncDelegate?.Invoke(asyncContext, reponse);
asyncDelegate?.Invoke(asyncContext, response);
}
}
}
......@@ -42,6 +42,8 @@
</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
......@@ -162,6 +164,16 @@
<Folder Include="OBJ_INTERFACE\" />
<Folder Include="Server.OBJProxy\" />
</ItemGroup>
<ItemGroup>
<Page Include="Themes\StringResources\en\StringResource.ERRNO.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\StringResources\StringResource.ERRNO.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
......
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