454 lines
15 KiB
C#
454 lines
15 KiB
C#
using JinYuan.Models;
|
||
using JinYuan.VirtualDataLibrary;
|
||
using MiniExcelLibs;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Windows.Forms;
|
||
|
||
namespace JinYuan.VirtualDataLibrary
|
||
{
|
||
public class MesConfig
|
||
{
|
||
/// <summary>
|
||
/// 工厂代码
|
||
/// </summary>
|
||
public string siteCode = "";
|
||
/// <summary>
|
||
/// 产线编号
|
||
/// </summary>
|
||
public string lineCode = "";
|
||
/// <summary>
|
||
/// 设备编号
|
||
/// </summary>
|
||
public string equipNum = "";
|
||
/// <summary>
|
||
/// 客户料号
|
||
/// </summary>
|
||
public string CustomerPartNum = "";
|
||
/// MES密码
|
||
/// </summary>
|
||
public string mesPwd = "";
|
||
/// <summary>
|
||
/// MES账户
|
||
/// </summary>
|
||
public string mesUserName = "";
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 将电池等级转换成下发PLC的等级编号
|
||
/// </summary>
|
||
/// <param name="strGrade"></param>
|
||
/// <returns></returns>
|
||
public static string GetLocGrade(int stationNo, FDConfig fdconfig)
|
||
{
|
||
string grade = "";
|
||
switch (stationNo)
|
||
{
|
||
case 1:
|
||
grade = fdconfig.Grade1;
|
||
break;
|
||
case 2:
|
||
grade = fdconfig.Grade2;
|
||
break;
|
||
case 3:
|
||
grade = fdconfig.Grade3;
|
||
break;
|
||
}
|
||
return grade;
|
||
}
|
||
// 组盘PLC 机架-工位对应的寄存器
|
||
public Dictionary<int, Dictionary<int, string>> gw_loc_plcAddr =
|
||
new Dictionary<int, Dictionary<int, string>>()
|
||
{
|
||
// 机架1:loc1-loc3 对应PLC地址段D21600-D21602
|
||
{
|
||
1, new Dictionary<int, string>()
|
||
{
|
||
{1, "D21600"},
|
||
{2, "D21601"},
|
||
{3, "D21602"}
|
||
}
|
||
},
|
||
// 机架2:loc1-loc3 对应PLC地址段D23600-D23602
|
||
{
|
||
2, new Dictionary<int, string>()
|
||
{
|
||
{1, "D23600"},
|
||
{2, "D23601"},
|
||
{3, "D23602"}
|
||
}
|
||
},
|
||
// 机架3:loc1-loc3 对应PLC地址段D25600-D25602
|
||
{
|
||
3, new Dictionary<int, string>()
|
||
{
|
||
{1, "D25600"},
|
||
{2, "D25601"},
|
||
{3, "D25602"}
|
||
}
|
||
}
|
||
};
|
||
|
||
//// 电池等级,PLC等级关系
|
||
//private static Dictionary<string, int> gradeDic = new Dictionary<string, int>()
|
||
//{
|
||
// { "V1", 1 },
|
||
// { "A", 2 },
|
||
// { "A-", 3 },
|
||
// { "B", 4 },
|
||
// { "NG", 0},
|
||
// { "不设置", 0},
|
||
//};
|
||
|
||
//public static List<string> GetGrades()
|
||
//{
|
||
// var validGradeKeys = gradeDic.Keys.ToList();
|
||
// return validGradeKeys;
|
||
//}
|
||
|
||
|
||
/// <summary>
|
||
/// 将电池等级转换成下发PLC的等级编号
|
||
/// </summary>
|
||
/// <param name="strGrade"></param>
|
||
/// <returns></returns>
|
||
//public int GetGradeNo(string strGrade)
|
||
//{
|
||
// if (gradeDic.TryGetValue(strGrade, out int result))
|
||
// {
|
||
// return result; // 键存在,返回对应值
|
||
// }
|
||
// // 键不存在,返回0
|
||
// return 0;
|
||
//}
|
||
|
||
/// <summary>
|
||
/// 电表编号
|
||
/// </summary>
|
||
public List<string> electricMeterNum = new List<string>();
|
||
|
||
/// <summary>
|
||
/// 风速仪个数
|
||
/// </summary>
|
||
public int AntiDustAirSpeedCount = 0;
|
||
/// <summary>
|
||
/// 风速仪编号
|
||
/// </summary>
|
||
public List<string> listAntiDustAirSpeedNum = new List<string>();
|
||
|
||
/// <summary>
|
||
/// 权限
|
||
/// </summary>
|
||
public string userLevel = "";
|
||
/// <summary>
|
||
/// mes返回权限
|
||
/// </summary>
|
||
public string mesUserLevel = "";
|
||
/// <summary>
|
||
/// 物料编码
|
||
/// </summary>
|
||
public string MaterialCode = "";
|
||
/// <summary>
|
||
/// 生产型号
|
||
/// </summary>
|
||
public string ModelName = "";
|
||
// 产品型号转plc值
|
||
private Dictionary<string, int> modelMapping = new Dictionary<string, int>()
|
||
{
|
||
{ "LF350S", 1 }, //MB36
|
||
{ "LF314", 2 }, //MB31
|
||
{ "LF628", 3 }, //MB56
|
||
{ "LF668", 3 }, //MB56
|
||
{ "MB36", 1 }, //MB36
|
||
{ "MB31", 2 }, //MB31
|
||
{ "MB56", 3 }, //MB56
|
||
};
|
||
|
||
/// <summary>
|
||
/// 将电池型号转换成下发PLC的型号编号
|
||
/// </summary>
|
||
/// <param name="strGrade"></param>
|
||
/// <returns></returns>
|
||
public int GetModel(string modelName)
|
||
{
|
||
if (modelMapping.TryGetValue(modelName, out int result))
|
||
{
|
||
return result; // 键存在,返回对应值
|
||
}
|
||
// 键不存在,返回0
|
||
return 0;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 将电池型号+车间转换成下发PLC的型号编号
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public short GetModelNum(string modelName, string workshopCode)
|
||
{
|
||
short defVal = 0;
|
||
bool existModel = modelMapping.TryGetValue(modelName, out int resModel);
|
||
if (!existModel)
|
||
{
|
||
return defVal; // 键存在,返回对应值
|
||
}
|
||
|
||
bool existCode = ConstValue.WorkshopMap.TryGetValue(workshopCode, out short workshopOffset);
|
||
if (!existCode)
|
||
{
|
||
workshopOffset = 0;
|
||
}
|
||
|
||
defVal = (short)(resModel * 10 + workshopOffset);
|
||
return defVal;
|
||
}
|
||
|
||
// 物流线各工位,生产型号写PLC地址
|
||
private Dictionary<string, string> modelPLCAddr_Mapping = new Dictionary<string, string>()
|
||
{
|
||
{ "2-1", "D2009" },
|
||
{ "2-2", "D2109" },
|
||
{ "2-3", "D2209" },
|
||
{ "1-1", "D2309" },
|
||
{ "1-2", "D2409" },
|
||
{ "1-3", "D2509" }
|
||
};
|
||
|
||
public string GetWuliuModelAddr()
|
||
{
|
||
if (modelPLCAddr_Mapping.TryGetValue(CommonMethods.sysConfig.GongWei, out string plcAdrr))
|
||
{
|
||
return plcAdrr; // 键存在,返回对应值
|
||
}
|
||
// 键不存在,返回""
|
||
return "";
|
||
}
|
||
|
||
// 物流线各工位,等级写PLC地址
|
||
private Dictionary<string, Dictionary<int, string>> gradePLCAddr_Mapping = new Dictionary<string, Dictionary<int, string>>()
|
||
{
|
||
{ "2-1", new Dictionary<int, string> {{1, "D2006"}, {2, "D2007"}, {3, "D2008"}} },
|
||
{ "2-2", new Dictionary<int, string> {{1, "D2106"}, {2, "D2107"}, {3, "D2108"}} },
|
||
{ "2-3", new Dictionary<int, string> {{1, "D2206"}, {2, "D2207"}, {3, "D2208"}} },
|
||
{ "1-1", new Dictionary<int, string> {{1, "D2306"}, {2, "D2307"}, {3, "D2308"}} },
|
||
{ "1-2", new Dictionary<int, string> {{1, "D2406"}, {2, "D2407"}, {3, "D2408"}} },
|
||
{ "1-3", new Dictionary<int, string> {{1, "D2506"}, {2, "D2507"}, {3, "D2508"}} }
|
||
};
|
||
|
||
public Dictionary<int, string> GetWuliuGradeAddr()
|
||
{
|
||
if (gradePLCAddr_Mapping.TryGetValue(CommonMethods.sysConfig.GongWei, out Dictionary<int, string> plc_addrs))
|
||
{
|
||
return plc_addrs;
|
||
}
|
||
return new Dictionary<int, string>();
|
||
}
|
||
|
||
// PLC触摸屏用户名称与权限
|
||
private Dictionary<string, Dictionary<string, string>> userPLCAddr_Mapping = new Dictionary<string, Dictionary<string, string>>()
|
||
{
|
||
{ "1-1", new Dictionary<string, string> {{"user", "D22"}, {"right", "D21"}} },
|
||
{ "1-2", new Dictionary<string, string> {{"user", "D24" }, {"right", "D23" } } },
|
||
{ "1-3", new Dictionary<string, string> {{"user", "D26" }, {"right", "D25" } } },
|
||
{ "2-1", new Dictionary<string, string> {{"user", "D22" }, {"right", "D21" } } },
|
||
{ "2-2", new Dictionary<string, string> {{"user", "D24" }, {"right", "D23" } } },
|
||
{ "2-3", new Dictionary<string, string> {{"user", "D26" }, {"right", "D25" } } },
|
||
};
|
||
|
||
public Dictionary<string, string> GetHMIUserRightAddr()
|
||
{
|
||
if (userPLCAddr_Mapping.TryGetValue(CommonMethods.sysConfig.GongWei, out Dictionary<string, string> plc_addrs))
|
||
{
|
||
return plc_addrs;
|
||
}
|
||
return new Dictionary<string, string>();
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 是否上传MES
|
||
/// </summary>
|
||
public bool isUpMes = false;
|
||
/// <summary>
|
||
/// MES接口URL地址中的IP地址
|
||
/// </summary>
|
||
public string MESURLAddressIP = "10.100.111.81";
|
||
/// <summary>
|
||
/// MES接口URL地址中的端口号
|
||
/// </summary>
|
||
public string MESURLAddressPort = "80";
|
||
/// <summary>
|
||
/// 是否连接MES
|
||
/// </summary>
|
||
public bool isConnected = false;
|
||
/// <summary>
|
||
/// 是否刷卡?
|
||
/// </summary>
|
||
public bool Isshuaka = false;
|
||
/// <summary>
|
||
/// 是否登录成功?
|
||
/// </summary>
|
||
public bool IsLoginOK = false;
|
||
/// <summary>
|
||
/// 是否登录MES成功?
|
||
/// </summary>
|
||
public bool IsLoginMesOK = false;
|
||
/// <summary>
|
||
/// 获取MES参数
|
||
/// </summary>
|
||
public bool IsMesParam = false;
|
||
/// <summary>
|
||
/// MES超时
|
||
/// </summary>
|
||
public long MesOutTime = 0;
|
||
/// <summary>
|
||
/// 焊接点个数
|
||
/// </summary>
|
||
public int weldNum = 0;
|
||
/// <summary>
|
||
/// 是否2个电表(此功能仅适用于908-6负极焊接两台设备共用一台敢接机只有一个电表)
|
||
/// </summary>
|
||
public bool IsTwoDianBiao = false;
|
||
/// <summary>
|
||
/// 电表编号
|
||
/// </summary>
|
||
public string ElectricMeterNum = "";
|
||
/// <summary>
|
||
/// 除尘风速
|
||
/// </summary>
|
||
public decimal antiDustAirSpeed = 0;
|
||
|
||
/// <summary>
|
||
/// 电机旋转速度
|
||
/// </summary>
|
||
public decimal dianjiXzSpeed = 0;
|
||
/// <summary>
|
||
/// 设备状态上传时间
|
||
/// </summary>
|
||
public int EquStatuasTime = 0;
|
||
/// <summary>
|
||
/// 获取服务器数据
|
||
/// </summary>
|
||
public bool IsGet_Server = true;
|
||
/// <summary>
|
||
/// 生成假数据
|
||
/// </summary>
|
||
public bool IsDebug = true;
|
||
/// <summary>
|
||
/// 钢壳码计数
|
||
/// </summary>
|
||
public int SteelshellCount = 0;
|
||
///// <summary>
|
||
///// 每个档位最大电芯数量
|
||
///// </summary>
|
||
//public int maxBatteriesPerGrade = 240;
|
||
|
||
/// <summary>
|
||
/// 电芯装箱层数
|
||
/// </summary>
|
||
public int packLayers = 4;
|
||
/// <summary>
|
||
/// 电芯装箱每层行数
|
||
/// </summary>
|
||
public int rowsPerLayer = 5;
|
||
/// <summary>
|
||
/// 电芯装箱每层列数
|
||
/// </summary>
|
||
public int colsPerLayer = 12;
|
||
/// <summary>
|
||
/// 卡板托盘计数
|
||
/// </summary>
|
||
public int CoreCount = 0;
|
||
/// <summary>
|
||
/// 卡板托盘生成时间
|
||
/// </summary>
|
||
public string CardTime = "";
|
||
/// <summary>
|
||
/// 卡板码是否发送成功
|
||
/// </summary>
|
||
public bool CardSuccess = false;
|
||
/// <summary>
|
||
/// 原材料上料位置
|
||
/// </summary>
|
||
public string materialLotCodeLocator = "";
|
||
/// <summary>
|
||
/// 存储服务器IP地址
|
||
/// </summary>
|
||
public string RotueServerIP = "192.168.2.108";
|
||
/// <summary>
|
||
/// 员工权限校验
|
||
/// </summary>
|
||
public string EmployeeAuthCheck = "http://10.100.111.81/core/api/public/equipment/base/user/permission/verify";
|
||
///// <summary>
|
||
///// 原材料投入信息
|
||
///// </summary>
|
||
//public string MaterialInputInfo = "http://10.100.111.81/core/api/public/raw/material/input/un/first/process";
|
||
/// <summary>
|
||
/// 设备参数设定值请求
|
||
/// </summary>
|
||
public string DeviceParamRequest = "http://10.100.111.81/core/api/public/param/setting/request";
|
||
/// <summary>
|
||
/// 设备参数设定值变更
|
||
/// </summary>
|
||
public string DeviceParamChange = "http://10.100.111.81/core/api/public/param/setting/change";
|
||
|
||
/// <summary>
|
||
/// 料盘信息获取
|
||
/// </summary>
|
||
public string queryTrayUrl = "http://10.22.160.9/prod-api/produce/trayQuery/trayComposeInfo";
|
||
|
||
public string queryGradeUrl = "http://10.22.160.141:8080/core/api/public/equip/auto/gradequery";
|
||
public string upResultParamUrl = "http://10.22.160.3/core/api/public/process/param/new/result";
|
||
/// <summary>
|
||
/// 解绑料框码
|
||
/// </summary>
|
||
public string unbindTrayUrl = "http://10.22.160.9/prod-api/api/fms/mp/unbindWholeTray";
|
||
|
||
/// <summary>
|
||
/// 半成品电池绑盘
|
||
/// </summary>
|
||
public string packLoadUrl = "http://10.54.50.1:8082/core/api/public/equip/auto/pack/load";
|
||
|
||
/// <summary>
|
||
/// 成品电池绑盘
|
||
/// </summary>
|
||
public string finishedPackUrl = "http://10.54.50.1:8082/core/api/public/equip/auto/pack/load";
|
||
/// <summary>
|
||
/// 设备报警信息
|
||
/// </summary>
|
||
public string DeviceAlarm = "http://10.100.111.81/core/api/public/equipment/alarm/currency";
|
||
/// <summary>
|
||
/// 设备运行状态
|
||
/// </summary>
|
||
public string DeviceStatus = "http://10.100.111.81/core/api/public/eve/pm/eqm/run/status/operation";
|
||
/// <summary>
|
||
/// 能耗数据
|
||
/// </summary>
|
||
public string EnergyConsumption = "http://10.100.111.81/core/api/public/eve/pm/energy/consumption/collection/submit";
|
||
/// <summary>
|
||
/// 设备风速接口
|
||
/// </summary>
|
||
public string Anemometer = "https://iot.eveportal.com:9470/eve_api/ems/iot/upload_device_collect_data";
|
||
|
||
///// <summary>
|
||
///// 进出站一体模式×
|
||
///// </summary>
|
||
//public string InAndOutStationMesUrl = "http://10.17.96.73/core/api/public/14j/out/station/process/turn-in-out";
|
||
|
||
/// <summary>
|
||
/// appId
|
||
/// </summary>
|
||
public string AppID = "e36ef900320d442f850913e2ebc1d7a1";
|
||
/// <summary>
|
||
/// AppKey
|
||
/// </summary>
|
||
public string AppKey = "8279ce76217245f48c0cc495c09124a3";
|
||
/// <summary>
|
||
/// 获取TOKEN
|
||
/// </summary>
|
||
public string GetTokenUrl = "https://esb.evebattery.com:13502/gateway/ewms-eu/openapi/oauth/token";
|
||
}
|
||
}
|