按照客户要求将excel导出文件保存为一个条码一条记录,名称为SN_结果_时间.xslx

This commit is contained in:
LL
2025-11-14 17:27:29 +08:00
commit 883060d140
79 changed files with 166110 additions and 0 deletions

82
SLZ_4/PlcObject.cs Normal file
View File

@@ -0,0 +1,82 @@
using HslCommunication;
using HslCommunication.Profinet.Melsec;
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLZ_4
{
public class PlcObject
{
public MelsecFxSerial PLC; //串口通行方式三菱FX3U
/*******耕得柜式离线式上位机点位***********/
//M600:CH1M601:CH2true:开启扫码false:关闭扫码
//D120:CH1D121:CH210扫码完成
/*******耕得柜式离线式上位机点位***********/
/*******华贝上位机点位***********/
//读实时下压力D105:CH1D107:CH2
//写:
//M600:CH1M601:CH2true:开启扫码false:关闭扫码
//D500:CH1D501:CH210扫码完成
//M602:CH1M603:CH2true:负压模式false:正压模式
/*******耕得柜式离线式上位机点位***********/
/*******航同离线式上位机点位***********/
//M600:CH1M601:CH2true:开启扫码false:关闭扫码
//D530:CH1D531:CH210扫码完成
/*******航同离线式上位机点位***********/
public PlcObject()
{
PLC = new MelsecFxSerial();
}
public void openPLC(PLC_PARAM plcParam)
{
try
{
PLC.SerialPortInni(sp =>
{
sp.PortName = plcParam.sPort;
sp.BaudRate = plcParam.iBaudrate;
sp.DataBits = 7;
sp.StopBits = System.IO.Ports.StopBits.One;
sp.Parity = System.IO.Ports.Parity.Even;
});
PLC.Open();
}
catch (Exception ex)
{
FileLogger.Log("打开PLC失败:" + ex.Message, LogLevel.ERROR);
}
}
public void closePLC()
{
PLC.Close();
}
public bool SetScan(int iCH, bool bStart)
{
bool bRet = false;
if (PLC.IsOpen())
{
bRet = PLC.Write(iCH == 0 ? "M600" : "M601", bStart).IsSuccess;
}
return bRet;
}
public bool ScanFinish(int iCH)
{
bool bRet = false;
if (PLC.IsOpen())
{
bRet = PLC.Write(iCH == 0 ? "D530" : "D531", 10).IsSuccess;
}
return bRet;
}
}
}