using System; using System.Data; using StandardLibrary; using MainForm.Models; using MainForm.DbHelper; using MainForm.ClassFile.ProjectClass; namespace MainForm { /// /// 全局变量 /// public class GlobalContext { #region 变量 //消息委托和事件 public static Action Set; // 更新UI的委托方法 public static Action Save; // 保存的委托方法 public static Action Close; // 关闭的委托方法 /// /// 日志文件保存位置 /// public static string FilePath = AppDomain.CurrentDomain.BaseDirectory + "Config.ini"; public static string MainDir = @"D:\MESFile\"; public static string WorkLogDir = MainDir + @"WorkLog\"; // 运行日志 public static string PlcLogDir = MainDir + @"PLCLog\"; // plc写入日志 public static string ProcessDataDir = MainDir + @"ProcessData\"; // 加工数据日志 public static string OneCheckDataDir = MainDir + @"OneCheckData\"; // 点检数据日志 public static string SQLLogDir = MainDir + @"SQLLog\"; // sql日志 public static string DBDir = @"D:\LocalDataBase\"; public static string MESConfig = MainDir + @"MESConfig.ini"; // MES接口的配置文件 public static string MaterialVerifyLog = PlcLogDir + @"辅耗材\"; // 辅耗材上料 public static string MqttLogDir = MainDir + @"MqttLog\"; // mqtt日志 public static string MqttCallbackDir = MqttLogDir + @"Callback\"; // mqtt日志 - Callback内容 public static string MqttDeviceStateDir = MqttLogDir + @"设备状态\"; // mqtt日志 - 设备状态日志 public static string MqttInputBeginDir = MqttLogDir + @"节拍日志\"; // mqtt日志 - 节拍日志 public static string MqttOperateLogDir = MqttLogDir + @"用户操作\"; // mqtt日志 - 用户操作日志 public static string MqttAlarmLogDir = MqttLogDir + @"故障日志\"; // mqtt日志 - 故障日志日志 public static string MqttPassResultLogDir = MqttLogDir + @"过站结果\"; // mqtt日志 - 过站结果日志 public static string MqttPassDetailLogDir = MqttLogDir + @"过站明细\"; // mqtt日志 - 过站明细日志 public static string MqttFileUpLogDir = MqttLogDir + @"文件上传\"; // mqtt日志 - 文件上传日志 public static string MqttFileBackupLogDir = MqttLogDir + @"文件上传\文件备份"; // mqtt日志 - 文件上传日志 public static string MqttFileTempDir = MqttLogDir + @"文件上传\临时文件"; // mqtt日志 - 文件上传日志 public static string MqttDeviceConfigLogDir = MqttLogDir + @"装备配置\"; // mqtt日志 - 装备配置日志 public static string MqttServerPath = AppDomain.CurrentDomain.BaseDirectory + @"\ThingsMode\MqttServer.exe"; public static string MqttServerName = "MqttServer"; /// /// 点检数据文件 /// public static string CheckOneDataPath = AppDomain.CurrentDomain.BaseDirectory + "CheckOneData.ini"; // 产线及产品信息 public static string Project_Code; // 项⽬编码 public static string Factory_Code; // ⼯⼚ID public static string Process_Section_Code; // ⼯段编码 public static string LineCode; // 线体编码 public static string LineName; // 线体名称 public static string ProgramName; // 程序名 public static string WorkOrderCode; // 车间订单号 public static string BatchNumber; // 批次号(splcode) public static string Mtltmrk; // 产品型号(mtltmrk) public static string run_mode; // 生产阶段 online/offline public static string product_mode; // 运行模式 debug(调试)/tp(试产)/mp(量产) public static string FileAppId; // 文件上传 public static string FileAppKey; // 文件上传 public static string S1_work_station; // [S1] ⼯站 public static string S1_device_code; // [S1] 装备编码 public static string S1_station; // [S1] ⼯位Id public static string S2_work_station; // [S2] ⼯站 public static string S2_device_code; // [S2] 装备编码 public static string S2_station; // [S2] ⼯位Id public static string s3_1_work_station; // [S3] ⼯站 public static string s3_1_device_code; // [S3] 装备编码 public static string s3_1_station; // [S3] ⼯位Id public static string s3_2_work_station; // [S4_1] ⼯站 public static string s3_2_device_code; // [S4_1] 装备编码 public static string s3_2_station; // [S4_1] ⼯位Id public static string s4_work_station; // [S4_3] ⼯站 public static string s4_device_code; // [S4_3] 装备编码 public static string s4_station; // [S4_3] ⼯位Id public static string s5_work_station; // [S4_4] ⼯站 public static string s5_device_code; // [S4_4] 装备编码 public static string s5_station; // [S4_4] ⼯位Id public static string s6_work_station; // [S4_5] ⼯站 public static string s6_device_code; // [S4_5] 装备编码 public static string s6_station; // [S4_5] ⼯位Id public static string s7_1_work_station; // [S5] ⼯站 public static string s7_1_device_code; // [S5] 装备编码 public static string s7_1_station; // [S5] ⼯位Id public static string s7_2_work_station; // [S5] 装备编码 public static string s7_2_device_code; // [S5] ⼯位Id public static string s7_2_station; // [S5] 装备编码 public static string s8_work_station; // [S5] ⼯位Id public static string s8_device_code; // [S5] 装备编码 public static string s8_station; // [S5] ⼯位Id public static string s9_work_station; // [S5] 装备编码 public static string s9_device_code; // [S5] ⼯位Id public static string s9_station; // [S5] ⼯位Id // 设备 //public static string PCAddress="192.168.1.244"; public static bool IsUsePLC1; public static bool IsUsePLC2; public static bool IsUsePLC3; public static bool IsUsePLC4; public static bool IsUsePLC5; public static bool IsUsePLC6; public static bool IsUsePLC7; public static bool IsUsePLC8; public static bool IsUsePLC9; public static string Machine1Address; public static string Machine2Address; public static string Machine3Address; public static string Machine4Address; public static string Machine5Address; public static string Machine6Address; public static string Machine7Address; public static string Machine8Address; public static string Machine9Address; public static string PC1Address; public static string PC2Address; public static string PC3Address; public static string PC4Address; public static string PC5Address; public static string PC6Address; public static string PC7Address; public static string PC8Address; public static string PC9Address; public static int MachinePort; public static string AtlasAddressLeft; public static string AtlasAddressRight; public static int AtlasAddressPort; // TCP public static string QrCodeTCPAddress1; public static int QrCodeTCPPort1; public static string QrCodeTCPAddress2; public static int QrCodeTCPPort2; public static string QrCodeTCPAddress3; public static int QrCodeTCPPort3; public static string QrCodeTCPAddress4; public static int QrCodeTCPPort4; public static string QrCodeTCPAddress5; public static int QrCodeTCPPort5; // MES public static bool IsUseMES; // 是否 启用MES public static string MESAppId; // 应用ID;mes_test public static string MESAppKey; // API接口名称;mes public static string MESUserId; // 用户ID public static string ServerHost; // 主服务器地址 public static string StationInMESUrl; // 入站接口Url public static string StationOutMESUrl; // 出站接口Url public static string ServerIp; // 主服务器IP-解析所得 //public static string StationInMESUrl; // 入站接口Url //public static string StationOutMESUrl; // 出站接口Url public static bool IsSendStationIn; // 启用上传进站 public static bool IsSendProcessData; // 启用上传出站 public static bool IsSendCheckOneData; // 启用上传点检 public static bool IsSendWorkingData; // 启用上传状态 public static bool IsSendAlarmData; // 启用上传报警 public static bool IsSendProcessDetail; // 启用上传出站明细 public static bool IsSendTestData; // 启用上传出站测试项 public static bool IsUseMESRoute; // 启用边线MES软件 public static bool MESIsConnect; // MES是否正常连接 public static string MESLaserLPath; // 三点激光数据本地存放地址 public static string MESLaserRPath; // 三点激光数据本地存放地址 public static string UpFileUrl; // 文档库地址 public static string UpFilePath; // 本地文件路径 public static bool MESIsSendUpFile; // 启用上传文件 // IOT - MQTT public static bool IsUseIot; // 是否 启用IOT public static string MQTTServerHost; // 服务器IP public static int MQTTServerPort; // 服务器Port public static bool IsMqttSendProcessData; // 上传过站数据 public static bool IsMqttSendProcessResult; // 上传过站结果 public static bool IsMqttDeviceState; // 上传设备状态 public static bool IsMqttFaultLog; // 上传故障⽇志 public static bool IsMqttSensorData; // 上传传感器数据 public static bool IsMqttStationInputBegin; // 上传节拍⽇志 public static bool IsMqttOperateLog; // 上传操作记录 public static bool IsMqttEquiConfig; // 上传装备配置 public static bool IsMqttProcConfig; // 上传⼯艺配置 public static bool MQTTIsSendUpFile; // 启用上传出战明细 public static string MQTTAppId; // IOT应用ID public static string MQTTAppPwd; // IOT登录密码 public static int IsUsePLCNow { set; get; } = 0; // 单机模式下,存储当前在用的plcNum public static string IsUseStationName { set; get; } = ""; // 单机模式下,存储当前在用的主工站全称 public static string address; // fds地址 public static string appId; // fds应⽤识别码 public static string appKey; // fds应⽤密钥 // IOT-AGV public static bool IsUseAGV; // 是否 启用AGV public static string AGVHttpHost; // Http 服务器地址 public static string AGVHttpIp; // Http IP地址 public static string AGVMQTTHost; // MQTT IP地址 public static int AGVMQTTPort; // MQTT端口 public static string AGVMQTTDeviceCode; // MQTT设备Code public static bool AGVMQTTIsConnect; // AGV MQTT是否正常连接 // MES进出站 配置信息 public static string S1_MachineId; // 工站1 - 壳体清洁上料装备 public static string S1_StationId; // 工站1 - 壳体清洁上料装备 public static string S2_MachineId; // 工站2 - 上盖板上料装备 public static string S2_StationId; // 工站2 - 上盖板上料装备 public static string S3_MachineId; // 工站3 - 点散热胶装备 public static string S3_StationId; // 工站3 - 点散热胶装备 public static string S3_StationId_1; // 工站3 - 点散热胶装备 public static string S3_StationId_2; // 工站3 - 点散热胶装备 public static string S4_MachineId; // 工站4 - 胶线检测装备 public static string S4_StationId; // 工站4 - 胶线检测装备 public static string S5_MachineId; // 工站5 - ADD板上料组装装备 public static string S5_StationId; // 工站5 - ADD板上料组装装备 public static string S6_MachineId; // 工站6 - 组上盖板装备 public static string S6_StationId; // 工站6 - 组上盖板装备 public static string S7_MachineId; // 工站7 - 上盖板锁螺丝装备 public static string S7_StationId; // 工站7 - 上盖板锁螺丝装备 public static string S7_StationId_1; // 工站7 - 上盖板锁螺丝装备 public static string S7_StationId_2; // 工站7 - 上盖板锁螺丝装备 public static string S8_MachineId; // 工站8 - NG下料装备 public static string S8_StationId; // 工站8 - NG下料装备 public static string S9_MachineId; // 工站9 - 产品下料装备 public static string S9_StationId; // 工站9 - 产品下料装备 // 本地数据库 public static string Server; public static string User; public static string PassWord; //其它 public static string CurrentUser = ""; public static string MacStr = ""; #region 是否可连接PLC-用户手动控制用(后加) public static bool _IsCon_Funs1 = true; public static bool _IsCon_Funs2 = true; public static bool _IsCon_Funs3 = true; public static bool _IsCon_Funs4 = true; public static bool _IsCon_Funs5 = true; public static bool _IsCon_plc1Heat = true; public static bool _IsCon_plc1Alarm = true; #endregion 是否可连接PLC-用户手动控制用(后加) #endregion 变量 #region 常量 //产品常量 public const string ConstLineCode = "A1"; public const string ConstLineName = "A1产线"; public const string ConstProgramName = "A1程序名"; public const string ConstSono = " "; public const string ConstWorkOrderCode = " "; public const string ConstBatchNumber = " "; public const string ConstMtltmrk = " "; public const string ConstSupplierCode = " "; //设备常量 public const string ConstMachine1Address = "192.168.10.87"; public const string ConstMachine2Address = "192.168.2.1"; public const string ConstMachine3Address = "192.168.4.111"; public const string ConstMachine4Address = "192.168.4.1"; public const string ConstMachine5Address = "192.168.6.111"; public const string ConstMachine6Address = "192.168.6.1"; public const string ConstMachine7Address = "192.168.6.71"; public const string ConstMachine8Address = "192.168.6.81"; public const string ConstMachine9Address = "192.168.1.91"; public const string ConstPc1Address = "192.168.1.10"; public const string ConstPc2Address = "192.168.1.10"; public const string ConstPc3Address = "192.168.1.10"; public const string ConstPc4Address = "192.168.1.10"; public const string ConstPc5Address = "192.168.1.10"; public const string ConstPc6Address = "192.168.1.10"; public const string ConstPc7Address = "192.168.1.10"; public const string ConstPc8Address = "192.168.1.10"; public const string ConstPc9Address = "192.168.1.10"; public const string ConstMachinePort = "1217"; //MES常量 public const string ConstServerHost = "10.1.19.33:8080"; public const string ConstIsSend = "false"; #endregion 常量 public GlobalContext() { UpdateData(); } /// /// 更新全局变量 /// public static void UpdateData() { try { // 产线及产品信息 Project_Code = IniFile.INIGetStringValue(FilePath, "Product", "ProjectCode", ""); Factory_Code = IniFile.INIGetStringValue(FilePath, "Product", "FactoryCode", ""); Process_Section_Code = IniFile.INIGetStringValue(FilePath, "Product", "ProcessSectionCode", ""); LineCode = IniFile.INIGetStringValue(FilePath, "Product", "LineCode", ConstLineCode); LineName = IniFile.INIGetStringValue(FilePath, "Product", "LineName", ConstLineName); ProgramName = IniFile.INIGetStringValue(FilePath, "Product", "ProgramName", ConstProgramName); MESLaserLPath = IniFile.INIGetStringValue(FilePath, "MES", "MESLaserLPath", ""); MESLaserRPath = IniFile.INIGetStringValue(FilePath, "MES", "MESLaserRPath", ""); WorkOrderCode = IniFile.INIGetStringValue(FilePath, "Product", "WorkOrderCode", ConstWorkOrderCode); // 车间订单号 BatchNumber = IniFile.INIGetStringValue(FilePath, "Product", "BatchNumber", ConstBatchNumber); // 批次号(splcode) Mtltmrk = IniFile.INIGetStringValue(FilePath, "Product", "Mtltmrk", ConstMtltmrk); // 产品型号(mtltmrk) // 工位信息 S1_work_station = IniFile.INIGetStringValue(FilePath, "Station", "s1_work_station", ""); // [S1] ⼯站 S1_device_code = IniFile.INIGetStringValue(FilePath, "Station", "s1_device_code", ""); // [S1] 装备编码 S1_station = IniFile.INIGetStringValue(FilePath, "Station", "s1_station", ""); // [S1] ⼯位Id S2_work_station = IniFile.INIGetStringValue(FilePath, "Station", "s2_work_station", ""); // [S2] ⼯站 S2_device_code = IniFile.INIGetStringValue(FilePath, "Station", "s2_device_code", ""); // [S2] 装备编码 S2_station = IniFile.INIGetStringValue(FilePath, "Station", "s2_station", ""); // [S2] ⼯位Id s3_1_work_station = IniFile.INIGetStringValue(FilePath, "Station", "s3_1_work_station", ""); // [S3] ⼯站 s3_1_device_code = IniFile.INIGetStringValue(FilePath, "Station", "s3_1_device_code", ""); // [S3] 装备编码 s3_1_station = IniFile.INIGetStringValue(FilePath, "Station", "s3_1_station", ""); // [S3] ⼯位Id s3_2_work_station = IniFile.INIGetStringValue(FilePath, "Station", "s3_2_work_station", ""); // [S3] ⼯站 s3_2_device_code = IniFile.INIGetStringValue(FilePath, "Station", "s3_2_device_code", ""); // [S3] 装备编码 s3_2_station = IniFile.INIGetStringValue(FilePath, "Station", "s3_2_station", ""); // [S3] ⼯位Id s4_work_station = IniFile.INIGetStringValue(FilePath, "Station", "s4_work_station", ""); // [S4_1] ⼯站 s4_device_code = IniFile.INIGetStringValue(FilePath, "Station", "s4_device_code", ""); // [S4_1] 装备编码 s4_station = IniFile.INIGetStringValue(FilePath, "Station", "s4_station", ""); // [S4_1] ⼯位Id s5_work_station = IniFile.INIGetStringValue(FilePath, "Station", "s5_work_station", ""); // [S4_4] ⼯站 s5_device_code = IniFile.INIGetStringValue(FilePath, "Station", "s5_device_code", ""); // [S4_4] 装备编码 s5_station = IniFile.INIGetStringValue(FilePath, "Station", "s5_station", ""); // [S4_4] ⼯位Id s6_work_station = IniFile.INIGetStringValue(FilePath, "Station", "s6_work_station", ""); // [S4_5] ⼯站 s6_device_code = IniFile.INIGetStringValue(FilePath, "Station", "s6_device_code", ""); // [S4_5] 装备编码 s6_station = IniFile.INIGetStringValue(FilePath, "Station", "s6_station", ""); // [S4_5] ⼯位Id s7_1_work_station = IniFile.INIGetStringValue(FilePath, "Station", "s7_1_work_station", ""); // [S5] ⼯站 s7_1_device_code = IniFile.INIGetStringValue(FilePath, "Station", "s7_1_device_code", ""); // [S5] 装备编码 s7_1_station = IniFile.INIGetStringValue(FilePath, "Station", "s7_1_station", ""); // [S5] ⼯位Id s7_2_work_station = IniFile.INIGetStringValue(FilePath, "Station", "s7_2_work_station", ""); // [S4_5] ⼯站 s7_2_device_code = IniFile.INIGetStringValue(FilePath, "Station", "s7_2_device_code", ""); // [S4_5] 装备编码 s7_2_station = IniFile.INIGetStringValue(FilePath, "Station", "s7_2_station", ""); // [S4_5] ⼯位Id s8_work_station = IniFile.INIGetStringValue(FilePath, "Station", "s8_work_station", ""); // [S4_5] ⼯站 s8_device_code = IniFile.INIGetStringValue(FilePath, "Station", "s8_device_code", ""); // [S4_5] 装备编码 s8_station = IniFile.INIGetStringValue(FilePath, "Station", "s8_station", ""); // [S4_5] ⼯位Id s9_work_station = IniFile.INIGetStringValue(FilePath, "Station", "s9_work_station", ""); // [S4_5] ⼯站 s9_device_code = IniFile.INIGetStringValue(FilePath, "Station", "s9_device_code", ""); // [S4_5] 装备编码 s9_station = IniFile.INIGetStringValue(FilePath, "Station", "s9_station", ""); // [S4_5] ⼯位Id // 设备 IsUsePLC1 = bool.Parse(IniFile.INIGetStringValue(FilePath, "Machine", "IsUsePLC1", "false")); IsUsePLC2 = bool.Parse(IniFile.INIGetStringValue(FilePath, "Machine", "IsUsePLC2", "false")); IsUsePLC3 = bool.Parse(IniFile.INIGetStringValue(FilePath, "Machine", "IsUsePLC3", "false")); IsUsePLC4 = bool.Parse(IniFile.INIGetStringValue(FilePath, "Machine", "IsUsePLC4", "false")); IsUsePLC5 = bool.Parse(IniFile.INIGetStringValue(FilePath, "Machine", "IsUsePLC5", "false")); IsUsePLC6 = bool.Parse(IniFile.INIGetStringValue(FilePath, "Machine", "IsUsePLC6", "false")); IsUsePLC7 = bool.Parse(IniFile.INIGetStringValue(FilePath, "Machine", "IsUsePLC7", "false")); IsUsePLC8 = bool.Parse(IniFile.INIGetStringValue(FilePath, "Machine", "IsUsePLC8", "false")); IsUsePLC9 = bool.Parse(IniFile.INIGetStringValue(FilePath, "Machine", "IsUsePLC9", "false")); Machine1Address = IniFile.INIGetStringValue(FilePath, "Machine", "Machine1Address", ConstMachine1Address); Machine2Address = IniFile.INIGetStringValue(FilePath, "Machine", "Machine2Address", ConstMachine2Address); Machine3Address = IniFile.INIGetStringValue(FilePath, "Machine", "Machine3Address", ConstMachine3Address); Machine4Address = IniFile.INIGetStringValue(FilePath, "Machine", "Machine4Address", ConstMachine4Address); Machine5Address = IniFile.INIGetStringValue(FilePath, "Machine", "Machine5Address", ConstMachine5Address); Machine6Address = IniFile.INIGetStringValue(FilePath, "Machine", "Machine6Address", ConstMachine6Address); Machine7Address = IniFile.INIGetStringValue(FilePath, "Machine", "Machine7Address", ConstMachine7Address); Machine8Address = IniFile.INIGetStringValue(FilePath, "Machine", "Machine8Address", ConstMachine8Address); Machine9Address = IniFile.INIGetStringValue(FilePath, "Machine", "Machine9Address", ConstMachine9Address); PC1Address = IniFile.INIGetStringValue(FilePath, "Machine", "Pc1Address", ConstPc1Address); PC2Address = IniFile.INIGetStringValue(FilePath, "Machine", "Pc2Address", ConstPc2Address); PC3Address = IniFile.INIGetStringValue(FilePath, "Machine", "Pc3Address", ConstPc3Address); PC4Address = IniFile.INIGetStringValue(FilePath, "Machine", "Pc4Address", ConstPc4Address); PC5Address = IniFile.INIGetStringValue(FilePath, "Machine", "Pc5Address", ConstPc5Address); PC6Address = IniFile.INIGetStringValue(FilePath, "Machine", "Pc6Address", ConstPc6Address); PC7Address = IniFile.INIGetStringValue(FilePath, "Machine", "Pc7Address", ConstPc7Address); PC8Address = IniFile.INIGetStringValue(FilePath, "Machine", "Pc8Address", ConstPc8Address); PC9Address = IniFile.INIGetStringValue(FilePath, "Machine", "Pc9Address", ConstPc9Address); MachinePort = int.Parse(IniFile.INIGetStringValue(FilePath, "Machine", "MachinePort", ConstMachinePort)); AtlasAddressLeft = IniFile.INIGetStringValue(FilePath, "Machine", "AtlasAddressLeft", ""); AtlasAddressRight = IniFile.INIGetStringValue(FilePath, "Machine", "AtlasAddressRight", ""); AtlasAddressPort = int.Parse(IniFile.INIGetStringValue(FilePath, "Machine", "AtlasAddressPort", "")); QrCodeTCPAddress1 = IniFile.INIGetStringValue(FilePath, "TCP", "TCPAddress1", "127.0.0.1"); QrCodeTCPPort1 = int.Parse(IniFile.INIGetStringValue(FilePath, "TCP", "TCPPort1", "0")); QrCodeTCPAddress2 = IniFile.INIGetStringValue(FilePath, "TCP", "TCPAddress2", "127.0.0.1"); QrCodeTCPPort2 = int.Parse(IniFile.INIGetStringValue(FilePath, "TCP", "TCPPort2", "0")); QrCodeTCPAddress3 = IniFile.INIGetStringValue(FilePath, "TCP", "TCPAddress3", "127.0.0.1"); QrCodeTCPPort3 = int.Parse(IniFile.INIGetStringValue(FilePath, "TCP", "TCPPort3", "0")); QrCodeTCPAddress4 = IniFile.INIGetStringValue(FilePath, "TCP", "TCPAddress4", "127.0.0.1"); QrCodeTCPPort4 = int.Parse(IniFile.INIGetStringValue(FilePath, "TCP", "TCPPort4", "0")); QrCodeTCPAddress5 = IniFile.INIGetStringValue(FilePath, "TCP", "TCPAddress5", "127.0.0.1"); QrCodeTCPPort5 = int.Parse(IniFile.INIGetStringValue(FilePath, "TCP", "TCPPort5", "0")); // MES MESAppId = IniFile.INIGetStringValue(FilePath, "MES", "MESAppId", "mes_test"); MESAppKey = IniFile.INIGetStringValue(FilePath, "MES", "MESAppKey", "mes"); MESUserId = IniFile.INIGetStringValue(FilePath, "MES", "MESUserId", "mes_userid"); ServerHost = IniFile.INIGetStringValue(FilePath, "MES", "ServerHost", ConstServerHost); StationInMESUrl = IniFile.INIGetStringValue(FilePath, "MES", "StationInMESUrl", ""); StationInMESUrl = string.Format(StationInMESUrl, ServerHost); StationOutMESUrl = IniFile.INIGetStringValue(FilePath, "MES", "StationOutMESUrl", ""); StationOutMESUrl = string.Format(StationOutMESUrl, ServerHost); UpFileUrl = IniFile.INIGetStringValue(FilePath, "MQTT", "UpFileUrl", ""); UpFilePath = IniFile.INIGetStringValue(FilePath, "MQTT", "UpFilePath", ""); MESIsSendUpFile = bool.Parse(IniFile.INIGetStringValue(FilePath, "MQTT", "MESIsSendUpFile", ConstIsSend)); if (ServerHost.Contains(":")) { string[] mesServers = ServerHost.Split(':'); ServerIp = mesServers[0]; ServerIp = ServerHost.Replace("\\", "/"); mesServers = ServerHost.Split('/'); if (mesServers.Length > 3) ServerIp = mesServers[2]; } else { ServerHost = ServerHost.Replace("\\", "/"); string[] mesServers = ServerHost.Split('/'); if (mesServers.Length > 3) ServerIp = mesServers[2]; } //StationInMESUrl = IniFile.INIGetStringValue(MESConfig, "MES", "StationInMESUrl", ""); //StationInMESUrl = string.Format(StationInMESUrl, ServerHost); //StationOutMESUrl = IniFile.INIGetStringValue(MESConfig, "MES", "StationOutMESUrl", ""); //StationOutMESUrl = string.Format(StationOutMESUrl, ServerHost); IsUseMES = bool.Parse(IniFile.INIGetStringValue(FilePath, "MES", "IsUseMES", ConstIsSend)); IsSendStationIn = bool.Parse(IniFile.INIGetStringValue(FilePath, "MES", "IsSendStationIn", ConstIsSend)); IsSendProcessData = bool.Parse(IniFile.INIGetStringValue(FilePath, "MES", "IsSendProcessData", ConstIsSend)); IsSendCheckOneData = bool.Parse(IniFile.INIGetStringValue(FilePath, "MES", "IsSendCheckOneData", ConstIsSend)); IsSendWorkingData = bool.Parse(IniFile.INIGetStringValue(FilePath, "MES", "IsSendWorkingData", ConstIsSend)); IsSendAlarmData = bool.Parse(IniFile.INIGetStringValue(FilePath, "MES", "IsSendAlarmData", ConstIsSend)); IsUseMESRoute = bool.Parse(IniFile.INIGetStringValue(FilePath, "MES", "IsUseMESRoute", ConstIsSend)); IsSendProcessDetail = bool.Parse(IniFile.INIGetStringValue(FilePath, "MES", "IsSendProcessDetail", ConstIsSend)); IsSendTestData = bool.Parse(IniFile.INIGetStringValue(FilePath, "MES", "IsSendTestData", ConstIsSend)); // MQTT IsUseIot = bool.Parse(IniFile.INIGetStringValue(FilePath, "MQTT", "IsUseIot", "false")); MQTTServerHost = IniFile.INIGetStringValue(FilePath, "MQTT", "MQTTServerHost", "127.0.0.1"); MQTTServerPort = int.Parse(IniFile.INIGetStringValue(FilePath, "MQTT", "MQTTServerPort", "80")); IsMqttSendProcessData = bool.Parse(IniFile.INIGetStringValue(FilePath, "MQTT", "IsMqttSendProcessData", ConstIsSend)); IsMqttSendProcessResult = bool.Parse(IniFile.INIGetStringValue(FilePath, "MQTT", "IsMqttSendProcessResult", ConstIsSend)); IsMqttDeviceState = bool.Parse(IniFile.INIGetStringValue(FilePath, "MQTT", "IsMqttDeviceState", ConstIsSend)); IsMqttFaultLog = bool.Parse(IniFile.INIGetStringValue(FilePath, "MQTT", "IsMqttFaultLog", ConstIsSend)); IsMqttSensorData = bool.Parse(IniFile.INIGetStringValue(FilePath, "MQTT", "IsMqttSensorData", ConstIsSend)); IsMqttStationInputBegin = bool.Parse(IniFile.INIGetStringValue(FilePath, "MQTT", "IsMqttStationInputBegin", ConstIsSend)); IsMqttOperateLog = bool.Parse(IniFile.INIGetStringValue(FilePath, "MQTT", "IsMqttOperateLog", ConstIsSend)); IsMqttEquiConfig = bool.Parse(IniFile.INIGetStringValue(FilePath, "MQTT", "IsMqttEquiConfig", ConstIsSend)); IsMqttProcConfig = bool.Parse(IniFile.INIGetStringValue(FilePath, "MQTT", "IsMqttProcConfig", ConstIsSend)); MQTTIsSendUpFile = bool.Parse(IniFile.INIGetStringValue(FilePath, "MQTT", "MQTTIsSendUpFile", ConstIsSend)); MQTTAppId = IniFile.INIGetStringValue(FilePath, "MQTT", "MQTTAppId", "AKPKTSQAS46NKE4NHY"); MQTTAppPwd = IniFile.INIGetStringValue(FilePath, "MQTT", "MQTTAppPwd", "pwd"); appKey = IniFile.INIGetStringValue(FilePath, "MQTT", "appKey", ConstIsSend); appId = IniFile.INIGetStringValue(FilePath, "MQTT", "appId", ConstIsSend); address = IniFile.INIGetStringValue(FilePath, "MQTT", "address", ConstIsSend); product_mode = IniFile.INIGetStringValue(FilePath, "MQTT", "product_mode", ConstIsSend); run_mode = IniFile.INIGetStringValue(FilePath, "MQTT", "run_mode", ConstIsSend); FileAppId = IniFile.INIGetStringValue(FilePath, "MQTT", "FileAppId", ConstIsSend); FileAppKey = IniFile.INIGetStringValue(FilePath, "MQTT", "FileAppKey", ConstIsSend); // AGV配置 IsUseAGV = bool.Parse(IniFile.INIGetStringValue(FilePath, "AGV", "IsUseAGV", "false")); // 是否 启用AGV AGVHttpHost = IniFile.INIGetStringValue(FilePath, "AGV", "AGVHttpHost", "127.0.0.1:80"); // Http IP地址 string[] AGVHttps = AGVHttpHost.Split(':'); AGVHttpIp = AGVHttps[0]; AGVMQTTHost = IniFile.INIGetStringValue(FilePath, "AGV", "AGVMQTTHost", "127.0.0.1"); // MQTT IP地址 AGVMQTTPort = int.Parse(IniFile.INIGetStringValue(FilePath, "AGV", "AGVMQTTPort", "80")); // MQTT端口 AGVMQTTDeviceCode = IniFile.INIGetStringValue(FilePath, "AGV", "AGVMQTTDeviceCode", ""); // portCode // 入出站参数 S1_MachineId = IniFile.INIGetStringValue(FilePath, "StationOut", "S1_MachineId", "MId"); S1_StationId = IniFile.INIGetStringValue(FilePath, "StationOut", "S1_StationId", "SId"); S2_MachineId = IniFile.INIGetStringValue(FilePath, "StationOut", "S2_MachineId", "MId"); S2_StationId = IniFile.INIGetStringValue(FilePath, "StationOut", "S2_StationId", "SId"); S3_MachineId = IniFile.INIGetStringValue(FilePath, "StationOut", "S3_MachineId", "MId"); S3_StationId = IniFile.INIGetStringValue(FilePath, "StationOut", "S3_StationId", "SId"); S3_StationId_1 = IniFile.INIGetStringValue(FilePath, "StationOut", "S3_StationId_1", "SId"); S3_StationId_2 = IniFile.INIGetStringValue(FilePath, "StationOut", "S3_StationId_2", "SId"); S4_MachineId = IniFile.INIGetStringValue(FilePath, "StationOut", "S4_MachineId", "MId"); S4_StationId = IniFile.INIGetStringValue(FilePath, "StationOut", "S4_StationId", "SId"); S5_MachineId = IniFile.INIGetStringValue(FilePath, "StationOut", "S5_MachineId", "MId"); S5_StationId = IniFile.INIGetStringValue(FilePath, "StationOut", "S5_StationId", "SId"); S6_MachineId = IniFile.INIGetStringValue(FilePath, "StationOut", "S6_MachineId", "MId"); S6_StationId = IniFile.INIGetStringValue(FilePath, "StationOut", "S6_StationId", "SId"); S7_MachineId = IniFile.INIGetStringValue(FilePath, "StationOut", "S7_MachineId", "MId"); S7_StationId = IniFile.INIGetStringValue(FilePath, "StationOut", "S7_StationId", "SId"); S7_StationId_1 = IniFile.INIGetStringValue(FilePath, "StationOut", "S7_StationId_1", "SId"); S7_StationId_2 = IniFile.INIGetStringValue(FilePath, "StationOut", "S7_StationId_2", "SId"); S8_MachineId = IniFile.INIGetStringValue(FilePath, "StationOut", "S8_MachineId", "MId"); S8_StationId = IniFile.INIGetStringValue(FilePath, "StationOut", "S8_StationId", "SId"); S9_MachineId = IniFile.INIGetStringValue(FilePath, "StationOut", "S9_MachineId", "MId"); S9_StationId = IniFile.INIGetStringValue(FilePath, "StationOut", "S9_StationId", "SId"); // 本地数据库 Server = IniFile.INIGetStringValue(FilePath, "LocalDB", "Server", @"localhost"); User = IniFile.INIGetStringValue(FilePath, "LocalDB", "User", "sa"); PassWord = IniFile.INIGetStringValue(FilePath, "LocalDB", "PassWord", "bozhong123"); MacStr = IPHelper.GetMoAddress(); // 同步一次数据库当前订单信息到配置文件-后加的(加完后,设置页修改订单信息的功能不可用) //SyncCurOrderInfo(); Set?.Invoke(); } catch (Exception ex) { } } /// /// 同步数据量存储的当前订单信息到配置文件中 /// public static void SyncCurOrderInfo() { #region 校验配置文件是否和数据库实际订单一致,如果配置文件的订单和数据库不一致,以数据库优先 string sql = @" SELECT TOP 1 WorkOrderNum, BatchNumber, ProductMtltmrk, SupplierCode FROM OrderTable WHERE WorkOrderStatus = '正在处理订单' ORDER BY CreatedTime DESC "; SqlHelper _sqlHelper = new SqlHelper(); DataTable dt_data = _sqlHelper.Db.SqlQueryable(sql).ToDataTable(); // 查询订单数据 if (dt_data != null && dt_data.Rows.Count > 0) { string _workOrderNum = dt_data.Rows[0][1].ToString().Trim(); if (WorkOrderCode != _workOrderNum) { IniFile.INIWriteValue(FilePath, "Product", "WorkOrderCode", dt_data.Rows[0][0].ToString().Trim()); IniFile.INIWriteValue(FilePath, "Product", "BatchNumber", dt_data.Rows[0][1].ToString().Trim()); IniFile.INIWriteValue(FilePath, "Product", "Mtltmrk", dt_data.Rows[0][2].ToString().Trim()); } else { IniFile.INIWriteValue(FilePath, "Product", "WorkOrderCode", string.Empty); IniFile.INIWriteValue(FilePath, "Product", "BatchNumber", string.Empty); IniFile.INIWriteValue(FilePath, "Product", "Mtltmrk", string.Empty); } } else { IniFile.INIWriteValue(FilePath, "Product", "WorkOrderCode", string.Empty); IniFile.INIWriteValue(FilePath, "Product", "BatchNumber", string.Empty); IniFile.INIWriteValue(FilePath, "Product", "Mtltmrk", string.Empty); } #endregion } } }