Files

991 lines
35 KiB
C#
Raw Permalink Normal View History

2026-08-04 18:36:40 +08:00
using HML;
using JinYuan.DAL;
using JinYuan.Helper;
using JinYuan.MES;
using JinYuan.MES.Models;
using JinYuan.Models;
using JinYuan.VirtualDataLibrary.Utlis;
using MiniExcelLibs;
using PLC;
using PLC.PLCAlarm;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using System.Xml.Linq;
namespace JinYuan.VirtualDataLibrary
{
public class CommonMethods
{
public static readonly object SyncRoot = new object();
/// <summary>
/// 本地数据库
/// </summary>
2026-08-31 13:54:07 +08:00
public static SQLSugarService db = new SQLSugarService();
2026-08-04 18:36:40 +08:00
/// <summary>
/// 远程服务段数据库
/// </summary>
public static ISugarHelper dbServer = new SQLSugarService();
/// <summary>
/// 全局的PLC链接
/// </summary>
public static List<PlcReadWriteBase> plcDevices;
/// <summary>
/// plc状态
/// </summary>
public static readonly Dictionary<PlcReadWriteBase, Dictionary<string, object>> plcStatuses = new Dictionary<PlcReadWriteBase, Dictionary<string, object>>();
/// <summary>
/// 报警
/// </summary>
public static AlarmManager alarmManager = new AlarmManager();
/// <summary>
/// MES接口
/// </summary>
public static IMes hbgMes = new MesDataProcess();
/// <summary>
/// 参数
/// </summary>
public static ProductModelParam parRange = new ProductModelParam();
/// <summary>
/// 全局钩子
/// </summary>
public static ScanerHook listener = new ScanerHook();
/// <summary>
/// 创建个全局焊接功率队列数据存储
/// </summary>
public static List<Queue<double>> QWeldingPowerData = new List<Queue<double>>();
/// <summary>
/// 创建个全局入壳推力队列数据存储
/// </summary>
public static List<Queue<double>> QPlanenessData = new List<Queue<double>>();
/// <summary>
/// 创建全局的登录对象
/// </summary>
public static SysAdmin currentAdmin = null;
/// <summary>
/// 创建全局的登录对象
/// </summary>
public static List<NgCodeEntity> listNgCodeEntity = new List<NgCodeEntity>();
/// <summary>
/// 登录是否成功
/// </summary>
public static bool IsLoginOk = false;
//创建一个全局的配置对象
public static SysConfig sysConfig = new SysConfig();
public static int InvadTime;
/// <summary>
/// 智能电表
/// </summary>
public static List<ElectricEnergy> listElectricEnergy = new List<ElectricEnergy>();
/// <summary>
/// 电能表
/// </summary>
public static EnergyMeterHelper energyMeter = new EnergyMeterHelper();
/// <summary>
///是否开启刷新
/// </summary>
public static bool isRefreshTimerWeeding = false;
/// <summary>
/// SQL语句
/// </summary>
public static DBSQL dBSQL { get; } = new DBSQL();
public static M_DBCtrl m_DBCtrl { get; } = new M_DBCtrl();
/// <summary>
/// MES配置文件类
/// </summary>
public static MesConfig mesConfig = new MesConfig();
/// <summary>
/// 打印模板配置文件类
/// </summary>
public static BTWConfig btwConfig = new BTWConfig();
///创建一个全局的连接状态
public static bool connectState = false;
/// <summary>
/// 滴答次数
/// </summary>
public static int tickCount = 0;
/// <summary>
/// QIEHUAN
/// </summary>
public static int tickHomeCount = 0;
/// <summary>
/// 报警信息
/// </summary>
public static string SlideAlarmText = "当前无报警";
/// <summary>
/// 退出
/// </summary>
public static bool IsExit = false;
/// <summary>
/// 是否登出账户
/// </summary>
public static bool LoginOut = false;
/// <summary>
/// 是否上传MES
/// </summary>
public static bool IsUpMes { get; set; }
/// <summary>
/// 是否运行
/// </summary>
public static bool IsRun { get; set; } = false;
/// <summary>
/// 上一次设备状态
/// </summary>
public static int DeviceStatus = 0;
/// <summary>
/// 上一次Guid
/// </summary>
public static string DeviceGuid = "";
/// <summary>
///第一次读取
/// </summary>
public static bool IsFirst = false;
/// <summary>
/// 焊接功率波形图显示条数
/// </summary>
public static int ChatLineCount = 3;
/// <summary>
/// 员工号
/// </summary>
public static string strWorker { get; set; }
/// <summary>
/// 是否开启智能电表
/// </summary>
public static bool IsStartZNDB { get; set; } = false;
/// <summary>
/// 白夜班
/// </summary>
public static string strClass { get; set; } = "白班";
/// <summary>
/// 时间变更
/// </summary>
public static string ChangeClassTime { get; set; } = "20:30:00";
/// <summary>
/// 设备状态
/// </summary>
public static List<bool> Statues { get; set; }
/// <summary>
/// 服务器链接状态
/// </summary>
public static bool EMCStatues { get; set; }
#region 小时产能
/// <summary>
/// 上个时间点的总数
/// </summary>
public static int LastTotalNum { get; set; } = 0;
/// <summary>
/// 上个时间点良品数
/// </summary>
public static int LastOkNum { get; set; } = 0;
/// <summary>
/// 上一次重置计数的时间
/// </summary>
public static string LastResetTime { get; set; }
/// <summary>
/// 上一次的小时
/// </summary>
public static int LastHour { get; set; }
#endregion
/// <summary>
///
/// </summary>
public static List<Group> ListOmronGroups { get; set; }
/// <summary>
/// 12小时产能
/// </summary>
public static List<Chart12HourData> Lst_Prod12HourData = new List<Chart12HourData>();
/// <summary>
/// 不良选项(检测项不良)
/// </summary>
public static List<ChartDataType> Lst_DefectTypeQty = new List<ChartDataType>();
/// <summary>
/// PLC报警前10项
/// </summary>
public static List<ChartDataType> Lst_AlarmTop10_Qty = new List<ChartDataType>();
/// <summary>
/// 参数项设置
/// </summary>
public static List<ParamList> paramlists { get; set; }
/// <summary>
/// 线程控制
/// </summary>
public static ManualResetEvent ResetEventRecv = new ManualResetEvent(true);
#region 计数项
/// <summary>
/// 生产总数
/// </summary>
public static float TotalQty = 0;
public static float ProOKQty = 0;
public static float Ppm = 0;
public static double JiaDL = 0.0;
public static List<float> AntiDustAirSpeed = new List<float>();
/// <summary>
/// PLC开机/运行时间
/// </summary>
public static List<int> PlcOpenAndRunTime = new List<int>();
/// <summary>
/// PLC开机/运行时间地址
/// </summary>
public static List<string> PlcOpenAndRunTimeAdress = new List<string> { "D50", "D52", "D54", "D56", "D58", "D60" };
public static int ProdGaoRFIDNgQty = 0;//高托杯 绑定卷心码
public static int ProdDiRFIDNgQty = 0;//低托杯 绑定钢壳码
public static int ProdGangKeRFIDNgQty = 0;//钢壳托杯 绑定出站钢壳码
public static int ProdJuanBarNgQty = 0;
public static int ProdGangKeBarNgQty = 0;
public static int ProdRuKeTuiliNgQty = 0;
public static int ProdCCDNgQty = 0;
public static int ProdMesOutNGQty = 0;
#endregion
#region 配置信息
/// <summary>
/// 错误日志路径
/// </summary>
public static string strErrorLogspath = "D:\\APILog\\Logs\\ErrorLogs";
public static string strSystemLogspath = "D:\\APILog\\Logs\\SystemLogs";
public static string strAlarmLogspath = "D:\\APILog\\Logs\\AlarmLogs";
public static string strsqlLogspath = "";
/// <summary>
/// 删除路径
/// </summary>
public static string strDeletepath = "";
/// <summary>
/// 能耗保存路径
/// </summary>
public static string strWattrMeterpath = "D:\\APILog\\Logs\\智能电表数据";
/// <summary>
/// MES路径日志
/// </summary>
public static string strMesLogspath = "D:\\APILog\\Logs\\MesLogs";
/// <summary>
/// 主界面下列表绑定数据
/// </summary>
public static DropDownListPlusItemCollection DropDownItemList = new DropDownListPlusItemCollection();
/// <summary>
/// 设备状态信息路径
/// </summary>
public static string strDeviceStatusPath = System.Windows.Forms.Application.StartupPath + "\\Config\\DeviceStatus.cfg";
/// <summary>
/// PLC读取寄存器配置文件路径
/// </summary>
public static string ConfigPath = Path.Combine(System.Windows.Forms.Application.StartupPath, "ini\\PlcConfig.ini");
/// <summary>
/// 系统程序配置文件路径
/// </summary>
//public static string iniFilePath = Path.Combine(System.Windows.Forms.Application.StartupPath, "ini\\Configure.ini");
public static string xmlFilePath = Path.Combine(System.Windows.Forms.Application.StartupPath, "Config\\Configure.xml");
/// <summary>
/// 配置文件字典
/// </summary>
public static Dictionary<string, Dictionary<string, string>> Configxml = new Dictionary<string, Dictionary<string, string>>();
#region 读取配置文件
// 读取 XML 配置文件
public static Dictionary<string, Dictionary<string, string>> ReadXmlConfig(string filePath)
{
var config = new Dictionary<string, Dictionary<string, string>>();
if (!File.Exists(filePath))
{
MessageBox.Show($"配置文件不存在:{filePath}\n请检查Config文件夹是否存在,且包含Configure.xml文件");
return config;
}
XDocument xmlDoc = XDocument.Load(filePath);
foreach (var sectionElement in xmlDoc.Root.Elements())
{
string sectionName = sectionElement.Name.LocalName;
config[sectionName] = new Dictionary<string, string>();
foreach (var keyElement in sectionElement.Elements())
{
string key = keyElement.Name.LocalName;
string value = keyElement.Value;
config[sectionName][key] = value;
}
}
return config;
}
// 获取配置值
public static string GetConfigValue(Dictionary<string, Dictionary<string, string>> config, string section, string key, string defaultValue)
{
if (config.ContainsKey(section) && config[section].ContainsKey(key))
{
return config[section][key];
}
return defaultValue;
}
// 写入 XML 文件
public static void WriteXmlFile(Dictionary<string, Dictionary<string, string>> config, string filePath)
{
XDocument xmlDoc = new XDocument(new XElement("Configuration"));
foreach (var section in config)
{
var sectionElement = new XElement(section.Key);
foreach (var keyValue in section.Value)
{
sectionElement.Add(new XElement(keyValue.Key, keyValue.Value));
}
xmlDoc.Root.Add(sectionElement);
}
xmlDoc.Save(filePath);
}
/// <summary>
/// 单个配置数据保存
/// </summary>
/// <param name="INFO"></param>
/// <param name="Type"></param>
/// <param name="value"></param>
public static void UpdateConfig(string INFO, string Type, string value)
{
// 更新 Configxml 中的 SteelshellCount
CommonMethods.Configxml[INFO][Type] = value;
// 将更新后的 Configxml 写入文件
CommonMethods.WriteXmlFile(CommonMethods.Configxml, CommonMethods.xmlFilePath);
}
/// <summary>
///读取配置文件
/// </summary>
public static SysConfig GetSysConfig()
{
try
{
// 读取配置项
string line_gongwei = GetConfigValue(Configxml, "CONFIG_INFO", "EquipNo", "1-1");
// 安全拆分EquipNo
string[] gongweis = !string.IsNullOrWhiteSpace(line_gongwei) ? line_gongwei.Split('-') : new string[0];
// 安全获取LineNo
string lineNo = gongweis.Length >= 1 && !string.IsNullOrWhiteSpace(gongweis[0]) ? gongweis[0].Trim() : "1";
// 安全获取StationNo
string stationNo = gongweis.Length >= 2 && !string.IsNullOrWhiteSpace(gongweis[1]) ? gongweis[1].Trim() : "1";
#region 系统配置文件
return sysConfig = new SysConfig
{
AutoStart = Convert.ToBoolean(GetConfigValue(Configxml, "CONFIG_INFO", "AutoStart", "true")),
AutoLogin = Convert.ToBoolean(GetConfigValue(Configxml, "CONFIG_INFO", "AutoLogin", "true")),
AutoLock = Convert.ToBoolean(GetConfigValue(Configxml, "CONFIG_INFO", "AutoLockScreen", "false")),
LockPeriod = Convert.ToInt32(GetConfigValue(Configxml, "CONFIG_INFO", "LockIntervalTime", "0")),
AutoQieHuanM = Convert.ToBoolean(GetConfigValue(Configxml, "CONFIG_INFO", "AutoSwitchMonitor", "false")),
QieHuanMPeriod = Convert.ToInt32(GetConfigValue(Configxml, "CONFIG_INFO", "SwitchMonitorInterval", "0")),
ShowSeriesCount = Convert.ToInt32(GetConfigValue(Configxml, "CONFIG_INFO", "CurveDisplayCount", "0")),
SwipeCardMode = Convert.ToBoolean(GetConfigValue(Configxml, "CONFIG_INFO", "EnableCardMode", "false")),
MesModeSwitching = Convert.ToBoolean(GetConfigValue(Configxml, "CONFIG_INFO", "MESModeSwitch", "false")),
FinishSwitching = Convert.ToBoolean(GetConfigValue(Configxml, "CONFIG_INFO", "FinishSwitch", "false")),
GetMesParam = Convert.ToBoolean(GetConfigValue(Configxml, "CONFIG_INFO", "FetchMESParams", "false")),
SaveThreadTime = Convert.ToBoolean(GetConfigValue(Configxml, "CONFIG_INFO", "SaveThreadTimeLog", "false")),
IsDebugMode = Convert.ToBoolean(GetConfigValue(Configxml, "CONFIG_INFO", "IsDebugMode", "true")),
WuLiu = Convert.ToBoolean(GetConfigValue(Configxml, "CONFIG_INFO", "WuLiu", "false")),
GongWei = string.IsNullOrWhiteSpace(line_gongwei) ? "1-1" : line_gongwei,
LineNo = lineNo,
StationNo = stationNo
};
#endregion
}
catch (Exception)
{
return sysConfig = null;
}
}
/// <summary>
/// 获取MES配置文件
/// </summary>
public static MesConfig GetMesConfig()
{
try
{
#region MES配置文件
return mesConfig = new MesConfig
{
siteCode = GetConfigValue(Configxml, "MES_CONFIG", "SiteCode", "57M"),
lineCode = GetConfigValue(Configxml, "MES_CONFIG", "LineCode", "PW-571"),
equipNum = GetConfigValue(Configxml, "MES_CONFIG", "EquipNum", "571VIM01"),
CustomerPartNum = GetConfigValue(Configxml, "MES_CONFIG", "CustomerPartNum", "491VIM01"),
MESURLAddressIP = GetConfigValue(Configxml, "MES_CONFIG", "MESIp", "10.100.111.81"),
MESURLAddressPort = GetConfigValue(Configxml, "MES_CONFIG", "MESPort", "80"),
EmployeeAuthCheck = GetConfigValue(Configxml, "MES_CONFIG", "EmployeeAuthCheck", "571VIM01"),
DeviceParamRequest = GetConfigValue(Configxml, "MES_CONFIG", "DeviceParamRequest", "571VIM01"),
DeviceParamChange = GetConfigValue(Configxml, "MES_CONFIG", "DeviceParamChange", "491581VIM01VIM01"),
DeviceAlarm = GetConfigValue(Configxml, "MES_CONFIG", "DeviceAlarm", "581VIM01"),
DeviceStatus = GetConfigValue(Configxml, "MES_CONFIG", "DeviceStatus", "581VIM01"),
EnergyConsumption = GetConfigValue(Configxml, "MES_CONFIG", "EnergyConsumption", "581VIM01"),
Anemometer = GetConfigValue(Configxml, "MES_CONFIG", "Anemometer", "581VIM01"),
queryTrayUrl = GetConfigValue(Configxml, "MES_CONFIG", "QueryTrayUrl", ""),
queryGradeUrl = GetConfigValue(Configxml, "MES_CONFIG", "QueryGradeUrl", ""),
upResultParamUrl = GetConfigValue(Configxml, "MES_CONFIG", "UpResultParamUrl", ""),
packLoadUrl = GetConfigValue(Configxml, "MES_CONFIG", "PackLoadUrl", ""),
finishedPackUrl = GetConfigValue(Configxml, "MES_CONFIG", "finishedPackUrl", ""),
unbindTrayUrl = GetConfigValue(Configxml, "MES_CONFIG", "unBindTrayUrl", ""),
packLayers = int.Parse(GetConfigValue(Configxml, "MES_CONFIG", "PackLayers", "4")),
rowsPerLayer = int.Parse(GetConfigValue(Configxml, "MES_CONFIG", "RowsPerLayer", "5")),
colsPerLayer = int.Parse(GetConfigValue(Configxml, "MES_CONFIG", "ColsPerLayer", "12")),
};
#endregion
}
catch (Exception)
{
return mesConfig = null;
}
}
public static List<FDConfig> fdConfigs;
public static FDConfig curFdConfig; //垛位分档信息
public static List<FDConfigMapping> FDConfigMappings { get; set; } = new List<FDConfigMapping>();
public static FDConfigMapping CurrentFDConfig { get; set; }
public static void LoadFDConfig()
{
FDConfig fdconfig = null;
string FdConfigFilePath = CommonMethods.FdConfigFilePath; //Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config/FdConfig.xlsx");
if (File.Exists(FdConfigFilePath))
{
using (var stream = File.OpenRead(FdConfigFilePath))
{
var devices = MiniExcel.Query<FDConfig>(stream).ToList();
CommonMethods.fdConfigs = devices.Select(device => new FDConfig
{
FdNum = device.FdNum,
Grade1 = device.Grade1,
Grade2 = device.Grade2,
Grade3 = device.Grade3,
IsFDActive = device.IsFDActive,
}).ToList();
CommonMethods.curFdConfig = CommonMethods.fdConfigs[CommonMethods.fdConfigs.Count - 1];
}
}
}
/// <summary>
/// 加载分档配置
/// </summary>
public static void LoadFDConfigMappings()
{
try
{
string fdConfigPath = CommonMethods.FdConfigMappingPath;//Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config", "fd_config.xlsx");
if (File.Exists(fdConfigPath))
{
FDConfigMappings = MiniExcel.Query<FDConfigMapping>(fdConfigPath).ToList();
}
else
{
FDConfigMappings = new List<FDConfigMapping>();
}
}
catch (Exception ex)
{
LogHelper.Instance.WriteError($"加载分档配置失败:{ex.Message}", "SysErrorLog");
FDConfigMappings = new List<FDConfigMapping>();
}
}
/// <summary>
/// 根据机架号获取分档配置
/// </summary>
public static string GetFDConfigByStation(int stationNo)
{
if (stationNo == 1)
return curFdConfig.Grade1;
else if(stationNo == 2)
return curFdConfig.Grade2;
else if (stationNo == 3)
return curFdConfig.Grade3;
return "";
}
/// <summary>
/// 将电池等级转换成下发PLC的等级编号
/// </summary>
/// <param name="strGrade"></param>
/// <returns></returns>
public static int GetGradeNo(string strGrade)
{
if (string.IsNullOrEmpty(strGrade)) return 99;
if (strGrade == "NG" || strGrade == "拦截")
return 99;
if (strGrade == "不设置")
return 90;
var config = FDConfigMappings?.FirstOrDefault(x => x.FDName == strGrade);
return config != null ? (short)config.FDNum : 99;
}
public static List<string> FDGradeTypes = new List<string>();
public static void LoadFDGradeTypes()
{
try
{
string fdConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config", "FdConfigMapping.xlsx");
if (File.Exists(fdConfigPath))
{
var configs = MiniExcel.Query<FDConfigMapping>(fdConfigPath).ToList();
var types = configs.Select(x => x.FDName).Distinct().ToList();
// 确保包含 "不设置" 和 "NG"
if (!types.Contains("不设置"))
types.Insert(0, "不设置");
if (!types.Contains("NG"))
types.Add("NG");
FDGradeTypes = types;
}
else
{
FDGradeTypes = new List<string> { "不设置", "NG" };
}
}
catch (Exception ex)
{
Console.WriteLine($"LoadFDGradeTypes error: {ex.Message}");
FDGradeTypes = new List<string> { "不设置", "NG" };
}
}
public static List<string> GetValidGrades()
{
List<string> grades = new List<string>();
if (curFdConfig != null)
{
if (curFdConfig.Grade1 != null && curFdConfig.Grade1 != "NG" && curFdConfig.Grade1 != "不设置")
{
grades.Add(curFdConfig.Grade1);
}
if (curFdConfig.Grade2 != null && curFdConfig.Grade2 != "NG" && curFdConfig.Grade2 != "不设置")
{
grades.Add(curFdConfig.Grade2);
}
if (curFdConfig.Grade3 != null && curFdConfig.Grade3 != "NG" && curFdConfig.Grade3 != "不设置")
{
grades.Add(curFdConfig.Grade3);
}
grades = grades.Distinct().ToList();
}
return grades;
}
/// <summary>
/// 获取BTW配置文件
/// </summary>
public static BTWConfig GetBtwConfig()
{
try
{
#region 打印模板路径配置文件
return btwConfig = new BTWConfig
{
containerBTWPath = GetConfigValue(Configxml, "BTW_CONFIG", "ContainerBTWPath", ""),
printerName = GetConfigValue(Configxml, "BTW_CONFIG", "PrinterName", ""),
};
#endregion
}
catch (Exception)
{
return btwConfig = null;
}
}
#endregion
public static string deviceConfigPath = Application.StartupPath + "\\Config\\Device.xlsx";
public static string groupConfigPath = Application.StartupPath + "\\Config\\Group.xlsx";
public static string variableConfigPath = Application.StartupPath + "\\Config\\Variable.xlsx";
public static string FdConfigFilePath = Application.StartupPath + "\\Config\\FdConfig.xlsx";
public static string FdConfigMappingPath = Application.StartupPath + "\\Config\\FdConfigMapping.xlsx";
#region 保存配置文件
/// <summary>
/// 保存启动自动登录
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool SaveAutoStart(bool value)
{
Configxml["CONFIG_INFO"]["AutoStart"] = value.ToString(); // 修改自动登录为 True
WriteXmlFile(Configxml, xmlFilePath);
return true;
}
/// <summary>
/// 保存开机自动启动
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool SaveAutoLogin(bool value)
{
Configxml["CONFIG_INFO"]["AutoLogin"] = value.ToString();
WriteXmlFile(Configxml, xmlFilePath);
return true;
}
/// <summary>
/// 保存无操作自动锁屏
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool SaveAutoLock(bool value)
{
Configxml["CONFIG_INFO"]["AutoLockScreen"] = value.ToString();
WriteXmlFile(Configxml, xmlFilePath);
return true;
}
/// <summary>
/// 保存锁屏间隔时间
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool SaveLockPeriod(int value)
{
Configxml["CONFIG_INFO"]["LockIntervalTime"] = value.ToString();
WriteXmlFile(Configxml, xmlFilePath);
return true;
}
/// <summary>
/// 保存无操作自动切换监控界面
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool SaveAutoQieHuanM(bool value)
{
Configxml["CONFIG_INFO"]["AutoSwitchMonitor"] = value.ToString();
WriteXmlFile(Configxml, xmlFilePath);
return true;
}
/// <summary>
/// 保存无操作自动切换监控界面
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool SaveIsDebug(bool value)
{
Configxml["CONFIG_INFO"]["IsDebugMode"] = value.ToString();
WriteXmlFile(Configxml, xmlFilePath);
return true;
}
/// <summary>
/// 保存物流线分拣
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool SaveWuLiu(bool value)
{
Configxml["CONFIG_INFO"]["WuLiu"] = value.ToString();
WriteXmlFile(Configxml, xmlFilePath);
return true;
}
/// <summary>
/// 保存切换监控界面间隔时间
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool SaveQieHuanMPeriod(int value)
{
Configxml["CONFIG_INFO"]["SwitchMonitorInterval"] = value.ToString();
WriteXmlFile(Configxml, xmlFilePath);
return true;
}
/// <summary>
/// 保存曲线显示数量
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool SaveShowSeriesCount(int value)
{
Configxml["CONFIG_INFO"]["CurveDisplayCount"] = value.ToString();
WriteXmlFile(Configxml, xmlFilePath);
return true;
}
/// <summary>
/// 开启刷卡模式
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool SaveSwipeCardMode(bool value)
{
Configxml["CONFIG_INFO"]["EnableCardMode"] = value.ToString();
WriteXmlFile(Configxml, xmlFilePath);
return true;
}
/// <summary>
/// MES/非MES模式
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool SaveOpenMesModel(bool value)
{
Configxml["CONFIG_INFO"]["MESModeSwitch"] = value.ToString();
WriteXmlFile(Configxml, xmlFilePath);
return true;
}
/// <summary>
/// 成品/半成品切换
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool SaveFinishSwitch(bool value)
{
Configxml["CONFIG_INFO"]["FinishSwitch"] = value.ToString();
WriteXmlFile(Configxml, xmlFilePath);
return true;
}
/// <summary>
/// 保存机架号
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool SaveEquipNo(string value)
{
Configxml["CONFIG_INFO"]["EquipNo"] = value.ToString();
WriteXmlFile(Configxml, xmlFilePath);
return true;
}
/// <summary>
/// 获取MES参数
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool SaveGetMesParam(bool value)
{
Configxml["CONFIG_INFO"]["FetchMESParams"] = value.ToString();
WriteXmlFile(Configxml, xmlFilePath);
return true;
}
/// <summary>
/// 保存线程耗时操作
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool SaveSaveThreadTime(bool value)
{
Configxml["CONFIG_INFO"]["SaveThreadTimeLog"] = value.ToString();
WriteXmlFile(Configxml, xmlFilePath);
return true;
}
#endregion
#endregion
#region 委托信息
//创建委托
// 数据监视委托
public static Action<int, string> AddDataMonitorDelegate;
/// <summary>
/// 系统日志
/// </summary>
public static Action<bool, string> AddLogDelegate;
/// <summary>
/// 操作日志
/// </summary>
public static Action<bool, string> AddOPLogDelegate;
/// <summary>
/// 报警日志
/// </summary>
public static Action<SysLog> AddAlarmDelegate;
/// <summary>
/// 显示报警信息
/// </summary>
public static Action<string> ShowAlarmDelegate;
/// <summary>
/// 参数更新
/// </summary>
public static Action ChangeParamDelegate;
/// <summary>
///
/// </summary>
public static Action<bool> AddHomeDelegate;
/// <summary>
/// 显示组盘信息
/// </summary>
public static Action<List<AGearEntity>> ShowFeedingDelegate;
/// <summary>
/// 显示组盘抽检信息
/// </summary>
public static Action<List<CGearEntity>> ShowReFeedingDelegate;
/// <summary>
/// 显示叠盘数据
/// </summary>
public static Action<List<BGearEntity>> ShowBlankingDelegate;
/// <summary>
/// 显示底托拉板绑定信息
/// </summary>
public static Action<List<DGearEntity>> ShowMaterialDelegate;
/// <summary>
/// 显示料框码进站信息
/// </summary>
public static Action<List<TrayEntity>> ShowTrayDataDelegate;
/// <summary>
/// 电池状态委托
/// </summary>
public static Action<int, List<BatteryEntity>> ShowBatteryStatusDelegate;
/// <summary>
/// 满层后,展示电池二维码
/// </summary>
//public static Action<List<BatteryEntity>> ShowBatteryQRCoderDelegate;
/// <summary>
/// 档位NG原因委托
/// </summary>
public static Action<List<BatteryEntity>> ShowBatteryNGRsnDelegate;
/// <summary>
/// 显示电池替换信息
/// </summary>
public static Action<List<BatteryReplace>> ShowBatteryReplaceDelegate;
/// <summary>
/// 显示卡板打印信息
/// </summary>
public static Action<List<EGearEntity>> ShowLabellingMachineDelegate;
/// <summary>
/// 数据监视委托
/// </summary>
/// <param name="type"></param>
/// <param name="info"></param>
public static void AddDataMonitorLog(int type, string info)
{
//调用委托
if (AddDataMonitorDelegate != null)
{
AddDataMonitorDelegate(type, info);
}
}
/// <summary>
/// 写入系统日志
/// </summary>
/// <param name="isError">是否为错误信息</param>
/// <param name="info">日志信息</param>
public static void AddLog(bool isError, string info)
{
//调用委托
if (AddLogDelegate != null)
{
AddLogDelegate(isError, info);
}
}
/// <summary>
/// 写入操作日志
/// </summary>
/// <param name="isError"></param>
/// <param name="info"></param>
public static void AddOPLog(bool isError, string info)
{
//调用委托
if (AddLogDelegate != null)
{
AddOPLogDelegate(isError, info);
}
}
public static void AddAlarmLog(SysLog sysLog)
{
//调用委托
if (AddAlarmDelegate != null)
{
AddAlarmDelegate(sysLog);
}
}
/// <summary>
/// 显示报警日志
/// </summary>
/// <param name="info"></param>
public static void ShowAlarmLog(string info)
{
//调用委托
if (ShowAlarmDelegate != null)
{
ShowAlarmDelegate(info);
}
}
public static void ChangeParamData()
{
//调用委托
if (ChangeParamDelegate != null)
{
ChangeParamDelegate();
}
}
#endregion
/// <summary>
/// PLC变量集合
/// KEY = VarAddress
/// </summary>
public static ConcurrentDictionary<string, PLCGroupVariable> PLCVariable = new ConcurrentDictionary<string, PLCGroupVariable>();
// 打印机
/// <summary>
/// zebra
/// </summary>
public static BartenderPrinter containerPrint;
}
}