diff --git a/.gitignore b/.gitignore
index 3040aa0..103109f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -44,3 +44,9 @@
/JinYuan.Models/.vs/JinYuan.Models.csproj.dtbcache.json
/JinYuan.VirtualDataLibrary/.vs/JinYuan.VirtualDataLibrary.csproj.dtbcache.json
/LargeSquareOne/.vs/LargeSquareOne.csproj.dtbcache.json
+/LargeSquareOne/bin/Debug - 副本
+/LargeSquareOne/bin/Debug -22/Config/表格
+/LargeSquareOne/bin/Debug -22/Log
+/LargeSquareOne/bin/Debug -22/Logs
+/LargeSquareOne/bin/Debug -22/设备状态改变日志
+/LargeSquareOne/bin/Debug -22
diff --git a/JinYuan.Models/SysConfig/ChallengeCode.cs b/JinYuan.Models/SysConfig/ChallengeCode.cs
new file mode 100644
index 0000000..3cfd130
--- /dev/null
+++ b/JinYuan.Models/SysConfig/ChallengeCode.cs
@@ -0,0 +1,21 @@
+using System;
+
+namespace JinYuan.Models
+{
+ public class Challenge
+ {
+
+ ///
+ /// 挑战件条码
+ ///
+ public String ChallengeBarCode { get; set; }
+ ///
+ /// 电芯信息
+ ///
+ public String CodeMessage { get; set; }
+ ///
+ /// 焊前/焊后CCD
+ ///
+ public String WeldingCCD { get; set; }
+ }
+}
diff --git a/JinYuan.Models/SysConfig/ChannelConfig.cs b/JinYuan.Models/SysConfig/ChannelConfig.cs
new file mode 100644
index 0000000..7a46ddc
--- /dev/null
+++ b/JinYuan.Models/SysConfig/ChannelConfig.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JinYuan.Models.SysConfig
+{
+ public class ChannelConfig
+ {
+ public List Channels { get; set; } = new List();
+ }
+
+ public class Channel
+ {
+ public int ChannelId { get; set; }
+ public int DefaultValue { get; set; }
+ public List Gears { get; set; } = new List();
+ }
+}
diff --git a/JinYuan.Models/SysConfig/Device.cs b/JinYuan.Models/SysConfig/Device.cs
new file mode 100644
index 0000000..ca60ec0
--- /dev/null
+++ b/JinYuan.Models/SysConfig/Device.cs
@@ -0,0 +1,317 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Threading;
+
+namespace JinYuan.Models
+{
+ ///
+ /// 通信设备实体类
+ ///
+ public class Device
+ {
+ ///
+ /// IP地址
+ ///
+ public string IPAddress { get; set; }
+ ///
+ /// 端口
+ ///
+ public int Port { get; set; }
+
+ ///
+ /// PLC类型
+ ///
+ public string PLCType { get; set; }
+ ///
+ /// 当前设备的连接状态
+ ///
+
+ public bool IsConnected { get; set; }
+
+ ///
+ /// 是否是首次连接
+ ///
+
+ public bool IsFirstConnect { get; set; } = true;
+
+ ///
+ /// 重连周期
+ ///
+
+ public int ReConnectTime { get; set; } = 2000;
+
+ ///
+ /// 休眠时间
+ ///
+
+ public int SleepTime { get; set; } = 10;
+
+ ///
+ /// 大小端
+ ///
+ [JsonIgnore]
+ public int DataFormat { get; set; } = 0;
+ ///
+ /// 出错次数
+ ///
+ public int ErrorTimes { get; set; }
+
+ ///
+ /// 容错次数
+ ///
+ public int AllowErrorTimes { get; set; } = 3;
+
+ ///
+ /// 多线程取消源标志位
+ ///
+ public CancellationTokenSource Cts { get; set; }
+
+ ///
+ /// 计时器
+ ///
+
+ public Stopwatch Stopwatch { get; set; }
+
+ ///
+ /// 所有归档变量的集合
+ ///
+
+ public List StoreVarList { get; set; } = new List();
+
+ ///
+ /// 按工位读取
+ ///
+
+ public List WorkVarList { get; set; } = new List();
+ ///
+ /// 通信组集合
+ ///
+ public List GroupList { get; set; } = new List();
+ ///
+ /// 所有变量的集合
+ ///
+ public List VarList { get; set; } = new List();
+
+ ///
+ /// 所有变量名称与值的集合
+ ///
+ public Dictionary CurrentValue { get; set; } = new Dictionary();
+
+ ///
+ /// 定义报警触发和消除事件
+ ///
+ public event Action AlarmTrigEvent;
+
+ ///
+ /// 变量初始化
+ ///
+ public void Init()
+ {
+ foreach (var gp in GroupList)
+ {
+
+ if (gp.IsTiggerRead)
+ {
+ WorkVarList.Add(gp);
+ }
+ foreach (var variable in gp.VarList)
+ {
+ if (!gp.IsTiggerRead)
+ {
+ VarList.Add(variable);
+
+
+ if (CurrentValue.ContainsKey(variable.VarName))
+ {
+ CurrentValue[variable.VarName] = "NA";
+ }
+ else
+ {
+ CurrentValue.Add(variable.VarName, "NA");
+ }
+ }
+
+ }
+ }
+ }
+
+
+
+
+ ///
+ /// 索引器,通过键名获取到数据
+ ///
+ ///
+ ///
+ [JsonIgnore]
+ public object this[string key]
+ {
+ get
+ {
+ if (CurrentValue.ContainsKey(key))
+ {
+ return CurrentValue[key];
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ ///
+ /// 实时更新
+ ///
+ ///
+ public void Update(Variable variable)
+ {
+ //更新处理
+ if (CurrentValue.ContainsKey(variable.VarName))
+ {
+ CurrentValue[variable.VarName] = variable.VarValue;
+ }
+ else
+ {
+ CurrentValue.Add(variable.VarName, variable.VarValue);
+ }
+
+ //报警处理
+ if (variable.HighAlarmEnable || variable.LowAlarmEnable)
+ {
+ float compareValue = 0.0f;
+
+ if (variable.DataType.ToLower() == "bool")
+ {
+ compareValue = Convert.ToBoolean(variable.VarValue) ? 1.0f : 0.0f;
+ }
+ else
+ {
+ compareValue = Convert.ToSingle(variable.VarValue);
+ }
+
+ int compareResult = 0;
+ //高报警时,触发事件
+ if (variable.HighAlarmEnable)
+ {
+ compareResult = Compare(compareValue, variable.HighAlarmValue, variable.HighAlarmCacheValue, true);
+
+ if (compareResult != 0)
+ {
+ //通过事件做通知
+
+ OnAlarmAckEvent(variable, new AlarmEventArgs()
+ {
+ Name = variable.VarName,
+ CurrentValue = variable.VarValue.ToString(),
+ SetValue = variable.HighAlarmValue.ToString(),
+ AlarmNote = variable.HighAlarmNote,
+ IsTrigger = compareResult == 1
+ });
+ }
+
+ variable.HighAlarmCacheValue = compareValue;
+ }
+ else
+ {
+ compareResult = Compare(compareValue, variable.LowAlarmValue, variable.LowAlarmCacheValue, false);
+
+ if (compareResult != 0)
+ {
+ //通过事件做通知
+
+ OnAlarmAckEvent(variable, new AlarmEventArgs()
+ {
+ Name = variable.VarName,
+ CurrentValue = variable.VarValue.ToString(),
+ SetValue = variable.LowAlarmValue.ToString(),
+ AlarmNote = variable.LowAlarmNote,
+ IsTrigger = compareResult == 1
+ });
+
+ }
+ variable.LowAlarmCacheValue = compareValue;
+ }
+ }
+ }
+
+ ///
+ /// 报警触发的事件
+ ///
+ //public event AlarmTriggerEventDelegate AlarmTriggerEvent;
+
+ ///
+ /// 触发事件
+ ///
+ ///
+ ///
+ private void OnAlarmAckEvent(object sender, AlarmEventArgs e)
+ {
+ //AlarmTriggerEvent?.Invoke(sender, e);
+ }
+
+ ///
+ /// 报警比较
+ ///
+ /// 当前值
+ /// 设置值
+ /// 缓存值
+ /// 上升沿还是下降沿
+ /// 比较结果,1表示触发,-1表示消除,0表示无变化
+ private int Compare(float current, float set, float last, bool isPositive)
+ {
+ if (isPositive)
+ {
+ if (current >= set && last < set)
+ {
+ return 1;
+ }
+ if (current < set && last >= set)
+ {
+ return -1;
+ }
+ }
+ else
+ {
+ if (current <= set && last > set)
+ {
+ return 1;
+ }
+ if (current > set && last <= set)
+ {
+ return -1;
+ }
+ }
+ return 0;
+ }
+ }
+
+ public class AlarmEventArgs : EventArgs
+ {
+ ///
+ /// 变量名称
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// 当前值
+ ///
+ public string CurrentValue { get; set; }
+
+ ///
+ /// 报警说明
+ ///
+ public string AlarmNote { get; set; }
+
+ ///
+ /// 报警设定值
+ ///
+ public string SetValue { get; set; }
+
+ ///
+ /// 是否为触发
+ ///
+ public bool IsTrigger { get; set; }
+ }
+}
diff --git a/JinYuan.Models/SysConfig/Enum.cs b/JinYuan.Models/SysConfig/Enum.cs
new file mode 100644
index 0000000..6bcc8fb
--- /dev/null
+++ b/JinYuan.Models/SysConfig/Enum.cs
@@ -0,0 +1,18 @@
+namespace JinYuan.Models
+{
+ ///
+ /// 所有窗体枚举,小于临界窗体的为固定窗体,不执行关闭
+ ///
+ public enum FormNames
+ {
+ 集中监控,
+ 数据监控,
+ 日志报警,
+ 临界窗体,
+ 数据分析,
+ 数据追溯,
+ 参数设置,
+ 系统设置,
+ 用户管理
+ }
+}
diff --git a/JinYuan.Models/SysConfig/Group.cs b/JinYuan.Models/SysConfig/Group.cs
new file mode 100644
index 0000000..c1286ed
--- /dev/null
+++ b/JinYuan.Models/SysConfig/Group.cs
@@ -0,0 +1,47 @@
+using MiniExcelLibs.Attributes;
+using System.Collections.Generic;
+
+namespace JinYuan.Models
+{
+ ///
+ /// 通信组实体类
+ ///
+ public class Group
+ {
+ ///
+ ///通信组名称
+ ///
+ public string GroupName { get; set; }
+ ///
+ /// 起始地址
+ ///
+ public string Start { get; set; }
+ ///
+ /// 长度
+ ///
+ public ushort Length { get; set; }
+ ///
+ /// 是否为触发读取
+ ///
+ public bool IsTiggerRead { get; set; }
+
+ ///
+ /// 是否需要反馈结果到PLC
+ ///
+ public bool IsFeedbackPlc { get; set; }
+
+ ///
+ /// 是否启用
+ ///
+ public bool IsActive { get; set; }
+ ///
+ /// 备注说明
+ ///
+ public string Remark { get; set; }
+ ///
+ /// 变量集合
+ ///
+ [ExcelIgnore]
+ public List VarList { get; set; }
+ }
+}
diff --git a/JinYuan.Models/SysConfig/ParamBase.cs b/JinYuan.Models/SysConfig/ParamBase.cs
new file mode 100644
index 0000000..a7261e3
--- /dev/null
+++ b/JinYuan.Models/SysConfig/ParamBase.cs
@@ -0,0 +1,33 @@
+using SqlSugar;
+
+namespace JinYuan.Models
+{
+ ///
+ ///
+ ///
+ public class ParamBase
+ {
+ ///
+ ///
+ ///
+ public ParamBase()
+ {
+ }
+
+ ///
+ /// 序号
+ ///
+ public System.Int32? fNo { get; set; }
+
+ ///
+ /// 参数名称
+ ///
+ [SugarColumn(IsPrimaryKey = true)]
+ public System.String ParaName { get; set; }
+
+ ///
+ /// 备注
+ ///
+ public System.String Remark { get; set; }
+ }
+}
diff --git a/JinYuan.Models/SysConfig/ParamList.cs b/JinYuan.Models/SysConfig/ParamList.cs
new file mode 100644
index 0000000..ef67072
--- /dev/null
+++ b/JinYuan.Models/SysConfig/ParamList.cs
@@ -0,0 +1,42 @@
+using SqlSugar;
+
+namespace JinYuan.Models
+{
+ public class ParamList
+ {
+ ///
+ ///
+ ///
+ [SugarColumn(IsPrimaryKey = true)]
+ public System.String ModelName { get; set; }
+
+ ///
+ ///
+ ///
+ [SugarColumn(IsPrimaryKey = true)]
+ public System.String ParaName { get; set; }
+
+ ///
+ ///
+ ///
+ public System.String ParaValueMin { get; set; }
+ ///
+ ///
+ ///
+ public System.String ParaValueMax { get; set; }
+ ///
+ ///
+ ///
+ public System.String Uint { get; set; }
+
+ ///
+ ///
+ ///
+ public System.String Remark { get; set; }
+
+ ///
+ ///
+ ///
+ public System.DateTime? UpdateTime { get; set; } = System.DateTime.Now;
+ }
+}
diff --git a/JinYuan.Models/SysConfig/ProductModel.cs b/JinYuan.Models/SysConfig/ProductModel.cs
new file mode 100644
index 0000000..a6aff95
--- /dev/null
+++ b/JinYuan.Models/SysConfig/ProductModel.cs
@@ -0,0 +1,21 @@
+using SqlSugar;
+
+namespace JinYuan.Models
+{
+ public class ProductModel
+ {
+ ///
+ ///
+ ///
+ [SugarColumn(IsPrimaryKey = true)]
+ public System.String ModelName { get; set; }
+ ///
+ /// 物料编码
+ ///
+ public System.String MaterialCode { get; set; }
+ ///
+ ///
+ ///
+ public System.String Remark { get; set; }
+ }
+}
diff --git a/JinYuan.Models/SysConfig/ProductModelParam.cs b/JinYuan.Models/SysConfig/ProductModelParam.cs
new file mode 100644
index 0000000..dd9a377
--- /dev/null
+++ b/JinYuan.Models/SysConfig/ProductModelParam.cs
@@ -0,0 +1,25 @@
+namespace JinYuan.Models
+{
+ ///
+ /// 产品型号参数范围
+ ///
+ public class ProductModelParam
+ {
+ ///
+ /// 入壳压力1MAX
+ ///
+ public decimal PrePressure1Max { set; get; }
+ ///
+ /// 入壳压力2MAX
+ ///
+ public decimal PrePressure2Max { set; get; }
+ ///
+ /// 入壳压力3MAX
+ ///
+ public decimal PrePressure3Max { set; get; }
+ ///
+ /// 入壳压力下限
+ ///
+
+ }
+}
diff --git a/JinYuan.Models/SysConfig/SysAdmin.cs b/JinYuan.Models/SysConfig/SysAdmin.cs
new file mode 100644
index 0000000..068c4df
--- /dev/null
+++ b/JinYuan.Models/SysConfig/SysAdmin.cs
@@ -0,0 +1,24 @@
+using SqlSugar;
+
+namespace JinYuan.Models
+{
+ ///
+ /// 登录实体类型
+ ///
+ public class SysAdmin
+ {
+ [SugarColumn(IsPrimaryKey = true, IsIgnore = true)]
+ public int LoginId { get; set; }
+ public string LoginName { get; set; }
+ public string LoginPwd { get; set; }
+ public string LoginUid { get; set; }
+ public string LoginLevel { get; set; }
+ public bool SystemLog { get; set; }
+ public bool CpkData { get; set; }
+ public bool HistoryData { get; set; }
+ public bool ParamSet { get; set; }
+ public bool SystemSet { get; set; }
+ public bool UserManage { get; set; }
+
+ }
+}
diff --git a/JinYuan.Models/SysConfig/SysConfig.cs b/JinYuan.Models/SysConfig/SysConfig.cs
new file mode 100644
index 0000000..fa68ba4
--- /dev/null
+++ b/JinYuan.Models/SysConfig/SysConfig.cs
@@ -0,0 +1,63 @@
+namespace JinYuan.Models.SysConfig
+{
+ public class SysConfig
+ {
+ ///
+ /// 开机自动启动
+ ///
+ public bool AutoStart { get; set; }
+ ///
+ ///启动自动登录
+ ///
+ public bool AutoLogin { get; set; }
+ ///
+ ///无操作自动锁屏
+ ///
+ public bool AutoLock { get; set; }
+ ///
+ ///锁屏间隙时间,单位是分钟
+ ///
+ public int LockPeriod { get; set; }
+
+ ///
+ ///无操作自动锁屏
+ ///
+ public bool AutoQieHuanM { get; set; }
+ ///
+ ///锁屏间隙时间,单位是分钟
+ ///
+ public int QieHuanMPeriod { get; set; }
+
+
+ ///
+ ///曲线显示数量
+ ///
+ public int ShowSeriesCount { get; set; }
+ ///
+ /// 开启刷卡模式
+ ///
+ public bool SwipeCardMode { get; set; }
+ ///
+ /// MES/非MES模式切换
+ ///
+ public bool MesModeSwitching { get; set; }
+ ///
+ /// 切屏
+ ///
+ public bool ScreenCutting { get; set; }
+ ///
+ /// 获取MES参数
+ ///
+ public bool GetMesParam { get; set; }
+ ///
+ /// 切换强制OK模式
+ ///
+ public bool OKSwitching { get; set; }
+ ///
+ /// 线程耗时日志保存
+ ///
+ public bool SaveThreadTime { get; set; }
+
+
+ }
+}
diff --git a/JinYuan.Models/SysConfig/SysLog.cs b/JinYuan.Models/SysConfig/SysLog.cs
new file mode 100644
index 0000000..d1c82d1
--- /dev/null
+++ b/JinYuan.Models/SysConfig/SysLog.cs
@@ -0,0 +1,38 @@
+namespace JinYuan.Models
+{
+ public class SysLog
+ {
+ ///
+ /// 插入时间
+ ///
+ public string InsertTime { get; set; }
+ ///
+ /// 报警类型
+ ///
+ public string LogType { get; set; }
+ ///
+ /// 日志信息
+ ///
+ public string Note { get; set; }
+ ///
+ /// 操作人员
+ ///
+ public string Operater { get; set; }
+ ///
+ /// 变量名称
+ ///
+ public string VarName { get; set; }
+ ///
+ /// 报警设置值
+ ///
+ public string AlarmSet { get; set; }
+ ///
+ /// 报警值
+ ///
+ public string AlarmValue { get; set; }
+ ///
+ /// 报警类型
+ ///
+ public string AlarmType { get; set; }
+ }
+}
diff --git a/JinYuan.Models/SysConfig/Variable.cs b/JinYuan.Models/SysConfig/Variable.cs
new file mode 100644
index 0000000..3bdcb52
--- /dev/null
+++ b/JinYuan.Models/SysConfig/Variable.cs
@@ -0,0 +1,103 @@
+using MiniExcelLibs.Attributes;
+
+namespace JinYuan.Models
+{
+ ///
+ /// 变量属性类
+ ///
+ public class Variable
+ {
+ ///
+ /// 变量名称
+ ///
+ public string VarName { get; set; }
+
+ ///
+ /// 变量地址
+ ///
+ public string VarAddress { get; set; }
+ ///
+ /// 起始索引
+ ///
+ public string Start { get; set; }
+ ///
+ /// 数据类型
+ ///
+ public string DataType { get; set; }
+ ///
+ /// 偏移或长度
+ ///
+ public int OffsetOrLenght { get; set; }
+ ///
+ /// 所属通信组名称
+ ///
+ public string GroupName { get; set; }
+ ///
+ /// 备注说明
+ ///
+ public string Remark { get; set; }
+ ///
+ /// 是否上升沿报警
+ ///
+ public bool PosAlarm { get; set; }
+ ///
+ /// 是否下降沿报警
+ ///
+ public bool NegAlarm { get; set; }
+ ///
+ /// 转换系数
+ ///
+ public float Scale { get; set; } = 1.0f;
+ ///
+ /// 偏移值
+ ///
+ public float Offset { get; set; } = 0.0f;
+
+ ///
+ /// 变量的值
+ ///
+ [ExcelIgnore]
+ public object VarValue { get; set; }
+
+ ///
+ /// 高报警启用
+ ///
+ public bool HighAlarmEnable { get; set; }
+
+ ///
+ /// 高报警设定值
+ ///
+ public float HighAlarmValue { get; set; }
+
+ ///
+ /// 高报警说明
+ ///
+ public string HighAlarmNote { get; set; }
+
+ ///
+ /// 高报警缓存值
+ ///
+ [ExcelIgnore]
+ public float HighAlarmCacheValue { get; set; }
+ ///
+ /// 低报警启用
+ ///
+ public bool LowAlarmEnable { get; set; }
+
+ ///
+ /// 低报警设定值
+ ///
+ public float LowAlarmValue { get; set; }
+
+ ///
+ /// 低报警说明
+ ///
+ public string LowAlarmNote { get; set; }
+
+ ///
+ /// 低报警缓存值
+ ///
+ [ExcelIgnore]
+ public float LowAlarmCacheValue { get; set; }
+ }
+}