File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,466 @@
|
||||
using JinYuan.CommunicationLib.Enum;
|
||||
using JinYuan.DataConvertLib;
|
||||
using JinYuan.Helper;
|
||||
using JinYuan.MES.Enums;
|
||||
using JinYuan.MES.Models;
|
||||
using JinYuan.Models;
|
||||
using JinYuan.VirtualDataLibrary;
|
||||
using PLCCommunication;
|
||||
using PLCCommunication.Language;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using HslCommunication.ModBus;
|
||||
|
||||
namespace JinYuan.ControlCenters
|
||||
{
|
||||
public partial class ControlCenter
|
||||
{
|
||||
#region 刷新12小时产能
|
||||
public void Refresh12HourProdQty()
|
||||
{
|
||||
List<Chart12HourData> chart12Hours = new List<Chart12HourData>();
|
||||
int j = 0;
|
||||
int m = 0;
|
||||
int n = 0;
|
||||
DateTime dtTime = DateTime.Now;
|
||||
string strDate = dtTime.ToString("yyyy-MM-dd");
|
||||
int Hour = GetHour();
|
||||
var listTotal = CommonMethods.db.QueryWhereList<Hourprod>(t => t.FDate == strDate);// 查询稼动率表中total数据
|
||||
if (listTotal != null && listTotal.Count > 0)
|
||||
{
|
||||
for (int i = 1; i < 13; i++)
|
||||
{
|
||||
#region X轴数据
|
||||
|
||||
if (CommonMethods.strClass != "白班")
|
||||
{
|
||||
j = i + 21;
|
||||
|
||||
if (j >= 25 && j < 26)
|
||||
{
|
||||
m = j - 2;
|
||||
n = j - 25;
|
||||
}
|
||||
else if (j >= 26)
|
||||
{
|
||||
m = j - 26;
|
||||
n = j - 25;
|
||||
}
|
||||
else
|
||||
{
|
||||
m = j - 2;
|
||||
n = j - 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
j = i + 9;
|
||||
m = j - 2;
|
||||
n = j - 1;
|
||||
}
|
||||
#endregion
|
||||
|
||||
int Fhour = Convert.ToInt32(m);
|
||||
var hour1 = listTotal.Where(p => p.FHour == Fhour).FirstOrDefault();
|
||||
int ProdALLQty = 0;
|
||||
int ProdOKQty = 0;
|
||||
int ProdNGQty = 0;
|
||||
string strOkRatio = "0.00";
|
||||
|
||||
if (hour1 != null)
|
||||
{
|
||||
ProdALLQty += hour1.ProdIn;
|
||||
ProdOKQty += hour1.ProdOut;
|
||||
}
|
||||
|
||||
ProdNGQty = ProdALLQty - ProdOKQty;
|
||||
if (ProdOKQty >= 0 && ProdALLQty > 0)
|
||||
{
|
||||
strOkRatio = (Math.Round(decimal.Parse(ProdOKQty.ToString()) / decimal.Parse(ProdALLQty.ToString()), 4)).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
strOkRatio = "0.00";
|
||||
}
|
||||
|
||||
chart12Hours.Add(new Chart12HourData()
|
||||
{
|
||||
DisplayTime = m + ":30~" + (n) + ":30",
|
||||
ProdIn = ProdALLQty,
|
||||
ProdOut = ProdOKQty,
|
||||
ProdNg = ProdNGQty,
|
||||
OKRatio = strOkRatio
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 1; i < 13; i++)
|
||||
{
|
||||
#region X轴数据
|
||||
|
||||
if (CommonMethods.strClass != "白班")
|
||||
{
|
||||
j = i + 21;
|
||||
|
||||
if (j >= 25 && j < 26)
|
||||
{
|
||||
m = j - 2;
|
||||
n = j - 25;
|
||||
}
|
||||
else if (j >= 26)
|
||||
{
|
||||
m = j - 26;
|
||||
n = j - 25;
|
||||
}
|
||||
else
|
||||
{
|
||||
m = j - 2;
|
||||
n = j - 1;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
j = i + 9;
|
||||
m = j - 2;
|
||||
n = j - 1;
|
||||
}
|
||||
#endregion
|
||||
|
||||
Random rand = new Random();
|
||||
int ranOK = rand.Next(1000, 3000);
|
||||
int ranNG = rand.Next(400, 1200);
|
||||
int total = ranOK + ranNG;
|
||||
|
||||
chart12Hours.Add(new Chart12HourData()
|
||||
{
|
||||
DisplayTime = m + ":30~" + n + ":30",
|
||||
ProdIn = ranOK + ranNG,
|
||||
ProdOut = ranOK,
|
||||
ProdNg = ranNG,
|
||||
OKRatio = (Math.Round(decimal.Parse(ranOK.ToString()) / decimal.Parse(total.ToString()) * 0.01m, 2) * 100).ToString()
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (chart12Hours != null)
|
||||
{
|
||||
CommonMethods.Lst_Prod12HourData = chart12Hours;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int GetHour()
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
int nowHour = Convert.ToInt32($"{now.Hour}30");
|
||||
int hour = 0;
|
||||
if (CommonMethods.LastHour != nowHour)
|
||||
{
|
||||
hour = Convert.ToInt32($"{now.Hour - 1}30");
|
||||
if (now.Hour == 0)
|
||||
{
|
||||
hour = 2330;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hour = Convert.ToInt32($"{now.Hour}30");
|
||||
}
|
||||
return hour;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 检测项不良
|
||||
/// <summary>
|
||||
/// 读取检测项不良
|
||||
/// </summary>
|
||||
private void GetDefectTypeQty()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
if (CommonMethods.Lst_DefectTypeQty.Count <= 0)
|
||||
{
|
||||
|
||||
CommonMethods.Lst_DefectTypeQty.Add(new ChartDataType { DataType = "极性检测不良", DataCount = 0 });
|
||||
CommonMethods.Lst_DefectTypeQty.Add(new ChartDataType { DataType = "称重不良", DataCount = 0 });
|
||||
CommonMethods.Lst_DefectTypeQty.Add(new ChartDataType { DataType = "铜极耳剪切不良", DataCount = 0 });
|
||||
CommonMethods.Lst_DefectTypeQty.Add(new ChartDataType { DataType = "铝极耳剪切不良", DataCount = 0 });
|
||||
//CommonMethods.Lst_DefectTypeQty.Add(new ChartDataType { DataType = "厚度不良", DataCount = 0 });
|
||||
//CommonMethods.Lst_DefectTypeQty.Add(new ChartDataType { DataType = "焊前CCD正极耳顶面不良", DataCount = 0 });
|
||||
}
|
||||
else //读取PLC数据
|
||||
{
|
||||
if (CommonMethods.plcDevice != null && CommonMethods.plcDevice.IsConnected)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
int ProdDRFIDNgQty = CommonMethods.PlcLink.ReadInt16("D1000");//极性检测不良
|
||||
int ProdDXNgQty = CommonMethods.PlcLink.ReadInt16("D1002");//称重不良
|
||||
int ProdGRFIDNgQty = CommonMethods.PlcLink.ReadInt16("D1006");//铜极耳剪切不良
|
||||
int ProdYLZNgQty = CommonMethods.PlcLink.ReadInt16("D1004");//铝极耳剪切不良
|
||||
|
||||
//從PLC讀取數據賦值給到NGList
|
||||
CommonMethods.Lst_DefectTypeQty.Where(p => p.DataType == "极性检测不良").FirstOrDefault().DataCount = ProdDRFIDNgQty;
|
||||
CommonMethods.Lst_DefectTypeQty.Where(p => p.DataType == "称重不良").FirstOrDefault().DataCount = ProdDXNgQty;
|
||||
CommonMethods.Lst_DefectTypeQty.Where(p => p.DataType == "铜极耳剪切不良").FirstOrDefault().DataCount = ProdGRFIDNgQty;
|
||||
CommonMethods.Lst_DefectTypeQty.Where(p => p.DataType == "铝极耳剪切不良").FirstOrDefault().DataCount = ProdYLZNgQty;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteEX(ex);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteEX(ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 智能电表 ---默认D1100开始
|
||||
public void GetEnergyData()
|
||||
{
|
||||
ModbusRtu busRtuClient = new ModbusRtu();
|
||||
if (CommonMethods.plcDevice != null && CommonMethods.plcDevice.IsConnected)
|
||||
{
|
||||
|
||||
List<ElectricEnergy> listM = new List<ElectricEnergy>();
|
||||
List<float> ListF = new List<float>();
|
||||
List<string> listAddre = new List<string>()
|
||||
{
|
||||
"D1100","D1102","D1104","D1106","D1108","D1110","D1112","D1114","D1116","D1118","D1120","D1122","D1124","D1126"
|
||||
};
|
||||
try
|
||||
{
|
||||
busRtuClient.SerialPortInni(sp =>
|
||||
{
|
||||
sp.PortName = "COM1";
|
||||
sp.BaudRate = 9600;
|
||||
sp.DataBits = 8;
|
||||
sp.StopBits = System.IO.Ports.StopBits.One;
|
||||
sp.Parity = System.IO.Ports.Parity.None;
|
||||
});
|
||||
busRtuClient.DataFormat = HslCommunication.Core.DataFormat.CDAB;
|
||||
busRtuClient.Open(); // 打开
|
||||
if (busRtuClient.IsOpen())
|
||||
{
|
||||
// 读取数据
|
||||
HslCommunication.OperateResult<byte[]> readResult = busRtuClient.Read("35", 30);
|
||||
HslCommunication.OperateResult<byte[]> readResult1 = busRtuClient.Read("3", 2);
|
||||
if (readResult.IsSuccess && readResult1.IsSuccess)
|
||||
{
|
||||
//DPT
|
||||
Byte DptH = busRtuClient.ByteTransform.TransByte(readResult.Content, 0);//高8位
|
||||
Byte DptL = busRtuClient.ByteTransform.TransByte(readResult.Content, 1);//低8位
|
||||
//DPQ
|
||||
Byte DpqH = busRtuClient.ByteTransform.TransByte(readResult.Content, 2);//高8位
|
||||
Byte DpqL = busRtuClient.ByteTransform.TransByte(readResult.Content, 3);//低8位
|
||||
|
||||
ElectricEnergy m = new ElectricEnergy();
|
||||
Decimal q = busRtuClient.ByteTransform.TransUInt16(readResult.Content, 56);
|
||||
Decimal w = busRtuClient.ByteTransform.TransUInt16(readResult.Content, 58);
|
||||
|
||||
m.pt = Convert.ToDecimal(busRtuClient.ByteTransform.TransInt16(readResult1.Content, 0)); //电压变比 D1124
|
||||
m.ct = Convert.ToDecimal(busRtuClient.ByteTransform.TransInt16(readResult1.Content, 2)); //电流变比 D1126
|
||||
Decimal Power = (q * 65536 + w) / 1000;
|
||||
m.AccumulatedElectricity = Convert.ToDecimal(Power * m.pt * m.ct); //有功电能(累计电能)D1100
|
||||
ListF.Add((float)m.AccumulatedElectricity.Value);
|
||||
//电压
|
||||
m.PhaseVoltageA = Convert.ToDecimal(busRtuClient.ByteTransform.TransUInt16(readResult.Content, 4) * Math.Pow(10, DptH - 4)); //A相电压 D1102
|
||||
m.PhaseVoltageB = Convert.ToDecimal(busRtuClient.ByteTransform.TransUInt16(readResult.Content, 6) * Math.Pow(10, DptH - 4));//B相电压 D1104
|
||||
m.PhaseVoltageC = Convert.ToDecimal(busRtuClient.ByteTransform.TransUInt16(readResult.Content, 8) * Math.Pow(10, DptH - 4));//C相电压 D1106
|
||||
ListF.Add((float)m.PhaseVoltageA.Value);
|
||||
ListF.Add((float)m.PhaseVoltageB.Value);
|
||||
ListF.Add((float)m.PhaseVoltageC.Value);
|
||||
|
||||
//电流
|
||||
m.PhaseCurrentA = Convert.ToDecimal(busRtuClient.ByteTransform.TransUInt16(readResult.Content, 16) * Math.Pow(10, DptL - 4)); //电流IA D1108
|
||||
m.PhaseCurrentB = Convert.ToDecimal(busRtuClient.ByteTransform.TransUInt16(readResult.Content, 18) * Math.Pow(10, DptL - 4));//电流IB D1110
|
||||
m.PhaseCurrentC = Convert.ToDecimal(busRtuClient.ByteTransform.TransUInt16(readResult.Content, 20) * Math.Pow(10, DptL - 4));//电流IC D1112
|
||||
ListF.Add((float)m.PhaseCurrentA.Value);
|
||||
ListF.Add((float)m.PhaseCurrentB.Value);
|
||||
ListF.Add((float)m.PhaseCurrentC.Value);
|
||||
|
||||
//有功功率
|
||||
m.PhasePowerA = Convert.ToDecimal(busRtuClient.ByteTransform.TransInt16(readResult.Content, 22) * Math.Pow(10, DpqH - 4)); //A相有功功率 D1114
|
||||
m.PhasePowerB = Convert.ToDecimal(busRtuClient.ByteTransform.TransInt16(readResult.Content, 24) * Math.Pow(10, DpqH - 4)); //B相有功功率 D1116
|
||||
m.PhasePowerC = Convert.ToDecimal(busRtuClient.ByteTransform.TransInt16(readResult.Content, 26) * Math.Pow(10, DpqH - 4));//C相有功功率 D1118
|
||||
m.ActivePower = Convert.ToDecimal(busRtuClient.ByteTransform.TransInt16(readResult.Content, 28) * Math.Pow(10, DpqH - 4)); //总有功功率 D1120
|
||||
ListF.Add((float)m.PhasePowerA.Value);
|
||||
ListF.Add((float)m.PhasePowerB.Value);
|
||||
ListF.Add((float)m.PhasePowerC.Value);
|
||||
ListF.Add((float)m.ActivePower.Value);
|
||||
m.PowerFactor = Convert.ToDecimal(busRtuClient.ByteTransform.TransInt16(readResult.Content, 44)) / 1000; //总功率因数 D1122
|
||||
ListF.Add((float)m.PowerFactor.Value);
|
||||
ListF.Add((float)m.pt.Value);
|
||||
ListF.Add((float)m.ct.Value);
|
||||
|
||||
for (int i = 0; i < ListF.Count; i++)
|
||||
{
|
||||
CommonMethods.PlcLink.WriteFloat(listAddre[i], ListF[i]);
|
||||
}
|
||||
listM.Add(m);
|
||||
CommonMethods.listElectricEnergy = listM;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
TxtHelper.WriteTxt($@"D:\APILog\Logs\智能电表信息\{DateTime.Now.ToString("yyyy-MM-dd")}.txt", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "智能电表:读取数据失败");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TxtHelper.WriteTxt($@"D:\APILog\Logs\智能电表信息\{DateTime.Now.ToString("yyyy-MM-dd")}.txt", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "智能电表:串口打开失败");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TxtHelper.WriteTxt($@"D:\APILog\Logs\智能电表信息\{DateTime.Now.ToString("yyyy-MM-dd")}.txt", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + $"智能电表:{ex}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (busRtuClient.IsOpen())
|
||||
{
|
||||
busRtuClient.Close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 能耗上传MES
|
||||
/// </summary>
|
||||
public void UploadEquEnergy()
|
||||
{
|
||||
if (CommonMethods.listElectricEnergy.Count > 0)
|
||||
{
|
||||
if (CommonMethods.mesConfig.isUpMes)
|
||||
{
|
||||
string msg = string.Empty;
|
||||
DateTime nowDate = DateTime.Now;
|
||||
string filePath = string.Empty;
|
||||
string fileName = string.Empty;
|
||||
string fileTitle = string.Empty;
|
||||
string fileContent = string.Empty;
|
||||
List<WattrMeter> listP = new List<WattrMeter>();
|
||||
int i = 0;
|
||||
foreach (ElectricEnergy m in CommonMethods.listElectricEnergy)
|
||||
{
|
||||
WattrMeter param = new WattrMeter();
|
||||
param.siteCode = CommonMethods.mesConfig.siteCode;
|
||||
param.lineCode = CommonMethods.mesConfig.lineCode;
|
||||
param.equipNum = CommonMethods.mesConfig.equipNum;
|
||||
param.userName = CommonMethods.mesConfig.mesUserName;
|
||||
param.electricMeterNum = CommonMethods.mesConfig.electricMeterNum[i];
|
||||
param.recordDate = nowDate.ToString("yyyy/MM/dd HH:mm:ss");
|
||||
param.accumulatedElectricity = (decimal)m.AccumulatedElectricity;
|
||||
param.phaseVoltageA = (decimal)m.PhaseVoltageA;
|
||||
param.phaseVoltageB = (decimal)m.PhaseVoltageB;
|
||||
param.phaseVoltageC = (decimal)m.PhaseVoltageC;
|
||||
param.phaseCurrentA = (decimal)m.PhaseCurrentA;
|
||||
param.phaseCurrentB = (decimal)m.PhaseCurrentB;
|
||||
param.phaseCurrentC = (decimal)m.PhaseCurrentC;
|
||||
param.phasePowerA = (decimal)m.PhasePowerA;
|
||||
param.phasePowerB = (decimal)m.PhasePowerB;
|
||||
param.phasePowerC = (decimal)m.PhasePowerC;
|
||||
param.activePower = (decimal)m.ActivePower;
|
||||
param.powerFactor = (decimal)m.PowerFactor;
|
||||
param.pt = (decimal)m.pt;
|
||||
param.ct = (decimal)m.ct;
|
||||
|
||||
listP.Add(param);
|
||||
i++;
|
||||
|
||||
// 写csv文件
|
||||
string productName = string.Empty;
|
||||
|
||||
filePath = $@"{CommonMethods.strWattrMeterpath}\{nowDate.Year}\{nowDate.Month}";
|
||||
fileName = $@"{nowDate.Day}.csv";
|
||||
fileTitle = "工序名称,生产机台编号,拉线,型号,物料编号,操作人员,班次,电表编号,采集时间,有功电能(累计电能)KwH,A相电压 V,B相电压 V,C相电压 V,A相电流 A,B相电流 A,C相电流 A,A相功率 Kw,B相功率 Kw,C相功率 Kw,总有功功率 Kw,总功率因数 %,电压变比,电流变比";
|
||||
fileContent = $"入壳A工序,{CommonMethods.mesConfig.equipNum},{CommonMethods.mesConfig.lineCode},{productName},{CommonMethods.mesConfig.MaterialCode},{CommonMethods.mesConfig.mesUserName},{CommonMethods.strClass},{param.electricMeterNum},{nowDate.ToString("yyyy-MM-dd HH:mm:ss")}," +
|
||||
$"{param.accumulatedElectricity},{param.phaseVoltageA},{param.phaseVoltageB},{param.phaseVoltageC},{param.phaseCurrentA},{param.phaseCurrentB},{param.phaseCurrentC}," +
|
||||
$"{param.phasePowerA},{param.phasePowerB},{param.phasePowerC},{param.activePower},{param.powerFactor},{param.pt},{param.ct}";
|
||||
CSVHelper<object>.WriterCSV(filePath, fileName, fileTitle, fileContent);
|
||||
}
|
||||
//上传MES
|
||||
string Mesage = "";
|
||||
bool b = CommonMethods.hbgMes.UploadEquEnergy(CommonMethods.mesConfig.WattrMeterUrl, CommonMethods.mesConfig.equipNum, CommonMethods.mesConfig.siteCode, CommonMethods.mesConfig.lineCode,
|
||||
CommonMethods.mesConfig.mesUserName, CommonMethods.mesConfig.electricMeterNum, listP, ref Mesage);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 风速仪数据采集
|
||||
/// </summary>
|
||||
public void UPloadAnemograph()
|
||||
{
|
||||
int _anemometerNumber = 34;//风速仪的个数
|
||||
string _anemometerAddress = "D15000";//风速仪起始地址
|
||||
if (CommonMethods.mesConfig.isUpMes)
|
||||
{
|
||||
JYResult<byte[]> jYResult = CommonMethods.PlcLink.ReadValue<JYResult<byte[]>>(_anemometerAddress, Data_Type.ArrByte,150);
|
||||
List<float> _anemograph = GetList<float>(_anemometerNumber, 0);//初始化列表
|
||||
List<string> _anemometerName=new List<string>();
|
||||
string _mesage = "";
|
||||
for (int i=0;i< _anemometerNumber;i++)
|
||||
{
|
||||
//初始化风速仪名称
|
||||
int _temple = i+1;
|
||||
string _name = "风速仪" + _temple.ToString();
|
||||
_anemometerName.Add(_name);
|
||||
|
||||
//解析数据
|
||||
_anemograph[i] = FloatLib.GetFloatFromByteArray(jYResult.Content, i * 4, DataFormat.CDAB);
|
||||
}
|
||||
//
|
||||
// 写csv文件
|
||||
string productName = string.Empty;
|
||||
string fileName=string.Empty;
|
||||
string filePath=string.Empty;
|
||||
DateTime nowDate = DateTime.Now;
|
||||
string fileTitle= "工序名称,生产机台编号,拉线,型号,物料编号,操作人员,班次,采集时间,";
|
||||
string fileContent= $"预焊工序,{CommonMethods.mesConfig.equipNum},{CommonMethods.mesConfig.lineCode},{productName},{CommonMethods.mesConfig.MaterialCode},{CommonMethods.mesConfig.mesUserName},{CommonMethods.strClass},{nowDate.ToString("yyyy-MM-dd HH:mm:ss")},";
|
||||
filePath = $@"{CommonMethods.strAnemographpath}\{nowDate.Year}\{nowDate.Month}";
|
||||
fileName = $@"{nowDate.Day}.csv";
|
||||
|
||||
for (int j = 0; j < _anemometerNumber; j++)
|
||||
{
|
||||
fileTitle = fileTitle +","+ _anemometerName[j];
|
||||
fileContent = fileContent + "," + _anemograph[j];
|
||||
}
|
||||
CSVHelper<object>.WriterCSV(filePath, fileName, fileTitle, fileContent);
|
||||
|
||||
|
||||
|
||||
if (false)//待确认接口
|
||||
{
|
||||
string ur = CommonMethods.mesConfig.CollectData;
|
||||
string equipNum = CommonMethods.mesConfig.equipNum;
|
||||
bool isResult = CommonMethods.hbgMes.UploadDeviceCollectData(ur, equipNum, _anemometerName, _anemograph, ref _mesage);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{1D0FA5A4-07F0-4621-B6BB-683AEC91E658}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>JinYuan.ControlCenters</RootNamespace>
|
||||
<AssemblyName>JinYuan.ControlCenters</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="DataConvertLib, Version=6.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\LargeSquareOne\Lib\DataConvertLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HslCommunication">
|
||||
<HintPath>.\HslCommunication.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="JinYuan.CommunicationLib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\LargeSquareOne\Lib\JinYuan.CommunicationLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="log4net">
|
||||
<HintPath>.\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MiniExcel, Version=1.31.2.0, Culture=neutral, PublicKeyToken=e7310002a53eac39, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MiniExcel.1.31.2\lib\net45\MiniExcel.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PLCCommunication, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\HBG_NegativeElectrodeWeld\Lib\PLCCommunication.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SqlSugar, Version=5.1.4.94, Culture=neutral, PublicKeyToken=null" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Diagnostics.Tracing" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ControlCenter_Plc.cs" />
|
||||
<Compile Include="MES\MESDataCombin.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ControlCenter_Total.cs" />
|
||||
<Compile Include="ControlCenter.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\JinYuan.DAL\JinYuan.DAL.csproj">
|
||||
<Project>{114aa012-29c9-418c-a2d6-3173c5341f51}</Project>
|
||||
<Name>JinYuan.DAL</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\JinYuan.Helper\JinYuan.Helper.csproj">
|
||||
<Project>{258D0AB7-2B4F-4D8F-A3CD-7A8CB4A85360}</Project>
|
||||
<Name>JinYuan.Helper</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\JinYuan.MES\JinYuan.MES.csproj">
|
||||
<Project>{530B6426-08E7-461C-91DC-787F876620FC}</Project>
|
||||
<Name>JinYuan.MES</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\JinYuan.Models\JinYuan.Models.csproj">
|
||||
<Project>{4c0bcb84-5cd7-4846-8363-c4c10d46e391}</Project>
|
||||
<Name>JinYuan.Models</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\JinYuan.VirtualDataLibrary\JinYuan.VirtualDataLibrary.csproj">
|
||||
<Project>{2ab7e380-7795-448a-933c-0f6a081b5e7e}</Project>
|
||||
<Name>JinYuan.VirtualDataLibrary</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="MES\MESDataCombin.cs.bak" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectView>ProjectFiles</ProjectView>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,116 @@
|
||||
using JinYuan.VirtualDataLibrary;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using JinYuan.Helper;
|
||||
using JinYuan.MES;
|
||||
using JinYuan.MES.Models;
|
||||
using JinYuan.MES.Enums;
|
||||
using JinYuan.Models;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JinYuan.ControlCenters
|
||||
{
|
||||
public class MESDataCombin
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
#region 9、报警信息
|
||||
/// <summary>
|
||||
/// 报警信息
|
||||
/// </summary>
|
||||
/// <param name="alarmObj">报警内容</param>
|
||||
/// <param name="alarmFlag">报警标志 1:报警开始 0:报警结束</param>
|
||||
/// <returns></returns>
|
||||
public static string EquAlarm(AlarmData alarmObj, int alarmFlag)
|
||||
{
|
||||
DateTime nowTime = DateTime.Now;
|
||||
string resJson = "";
|
||||
string josnTxtMsg = string.Empty;
|
||||
try
|
||||
{
|
||||
UploadAlarmParam alarmParam = new UploadAlarmParam();
|
||||
alarmParam.siteCode = CommonMethods.mesConfig.siteCode;
|
||||
alarmParam.lineCode = CommonMethods.mesConfig.lineCode;
|
||||
alarmParam.equipNum = CommonMethods.mesConfig.equipNum;
|
||||
alarmParam.materialCode = CommonMethods.mesConfig.MaterialCode;
|
||||
alarmParam.userName = CommonMethods.mesConfig.mesUserName;
|
||||
alarmParam.recordDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||
alarmParam.guid = alarmObj.AlarmGuid;
|
||||
alarmParam.seatId = "";
|
||||
List<AlarmLineListItem> alarmLineList = new List<AlarmLineListItem>();
|
||||
|
||||
AlarmLineListItem alarmList = new AlarmLineListItem();
|
||||
alarmList.alarmEndTime = alarmFlag == 1 ? "" : alarmObj.EndTime.ToString();
|
||||
alarmList.alarmType = alarmObj.AlarmType;
|
||||
alarmList.alarmName = alarmObj.AlarmContent;
|
||||
alarmList.alarmStartTime = alarmObj.StartTime.ToString();
|
||||
alarmList.faultCode = alarmObj.AlarmCode;
|
||||
alarmLineList.Add(alarmList);
|
||||
alarmParam.alarmLineList = alarmLineList;
|
||||
string SendJosn = JsonConvert.SerializeObject(alarmParam);
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
resJson = MESApiHelper.HttpPostJsonAPI(CommonMethods.mesConfig.AlarmCurrencyMesUrl, SendJosn);
|
||||
sw.Stop();
|
||||
josnTxtMsg = $"{nowTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用MES设备报警接口:{CommonMethods.mesConfig.AlarmCurrencyMesUrl},请求数据为:{SendJosn},\n{nowTime.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resJson}";
|
||||
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowTime.ToString("yyyyMMdd")}\设备报警\{nowTime.ToString("HH")}.txt", josnTxtMsg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteEX("调用MES设备报警接口", ex);
|
||||
}
|
||||
return resJson;
|
||||
|
||||
}
|
||||
#endregion
|
||||
#region 10、设备状态
|
||||
/// <summary>
|
||||
/// 设备状态
|
||||
/// </summary>
|
||||
/// <param name="strStatus"></param>
|
||||
/// <returns></returns>
|
||||
public static string EqpStatusParam(string strStatus, string StartDate, string strGuid, List<FaultCodeList> FaultCodeLists = null)
|
||||
{
|
||||
var nowTime = DateTime.Now;
|
||||
string resJson = "";
|
||||
string josnTxtMsg = string.Empty;
|
||||
string Date = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||
try
|
||||
{
|
||||
EqpStatusParam statusParam = new EqpStatusParam();
|
||||
statusParam.siteCode = CommonMethods.mesConfig.siteCode;
|
||||
statusParam.lineCode = CommonMethods.mesConfig.lineCode;
|
||||
statusParam.equipNum = CommonMethods.mesConfig.equipNum;
|
||||
statusParam.userName = CommonMethods.mesConfig.mesUserName;
|
||||
statusParam.seatId = "";
|
||||
statusParam.recordDate = StartDate;
|
||||
statusParam.statusCode = strStatus;
|
||||
statusParam.uploadTime = Date;
|
||||
statusParam.guid = strGuid;
|
||||
statusParam.faultCodeList = FaultCodeLists;
|
||||
string SendJosn = JsonConvert.SerializeObject(statusParam);
|
||||
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
resJson = MESApiHelper.HttpPostJsonAPI(CommonMethods.mesConfig.StatusMesUrl, SendJosn);
|
||||
sw.Stop();
|
||||
josnTxtMsg = $"{nowTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用MES设备运行状态接口:{CommonMethods.mesConfig.StatusMesUrl},请求数据为:{SendJosn},\n{nowTime.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resJson}";
|
||||
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowTime.ToString("yyyyMMdd")}\设备运行状态\{nowTime.ToString("HH")}.txt", josnTxtMsg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteEX("调用MES设备运行状态接口", ex);
|
||||
}
|
||||
return resJson;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("JinYuan.ControlCenters")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("JinYuan.ControlCenters")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("1d0fa5a4-07f0-4621-b6bb-683aec91e658")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.1.0.0" newVersion="8.1.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Text.Encoding.CodePages" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Security.Cryptography.Xml" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.1" newVersion="6.0.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.IO.Pipelines" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Google.Protobuf" publicKeyToken="a7d26565bac4d604" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.23.4.0" newVersion="3.23.4.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="ZstdSharp" publicKeyToken="8d151af33a4ad5cf" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-0.7.2.0" newVersion="0.7.2.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MiniExcel" version="1.31.2" targetFramework="net472" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user