初步界面测试
This commit is contained in:
@ -13,6 +13,7 @@ using DH.Commons.Enums;
|
||||
using HslCommunication;
|
||||
using HslCommunication.Enthernet;
|
||||
using HslCommunication.Profinet.XINJE;
|
||||
using OpenCvSharp;
|
||||
|
||||
namespace DH.Devices.PLC
|
||||
{
|
||||
@ -59,7 +60,7 @@ namespace DH.Devices.PLC
|
||||
TcpNet.Write("M122", true);
|
||||
MonitorPieces();
|
||||
TurntableStop();
|
||||
|
||||
PrepareMotion();//心跳监听
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -440,6 +441,22 @@ namespace DH.Devices.PLC
|
||||
|
||||
OnNewPieces?.Invoke(axisIndex, pieceNumber);
|
||||
});
|
||||
}
|
||||
public async Task HeartbeatAsync1()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
while (Connected)
|
||||
{
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "心跳地址");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
string HeartbeatAddress = pLCItem.Type + pLCItem.Address;
|
||||
TcpNet.Write(HeartbeatAddress, true);
|
||||
await Task.Delay(900); // 非阻塞,等待1秒
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 入料监听
|
||||
@ -451,6 +468,7 @@ namespace DH.Devices.PLC
|
||||
PLCItem pLCItem= PLCItemList.FirstOrDefault(u => u.Name == "产品计数");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
string Count = pLCItem.Type + pLCItem.Address;
|
||||
DateTime startTime = DateTime.Now;
|
||||
DateTime endTime = startTime;
|
||||
TimeSpan timeSpan = endTime - startTime;
|
||||
@ -462,7 +480,8 @@ namespace DH.Devices.PLC
|
||||
uint tmpPieceNumber = 0;
|
||||
sw.Start();
|
||||
|
||||
var ret = TcpNet.ReadUInt16("D1016");
|
||||
// var ret = TcpNet.ReadUInt16("D1016");
|
||||
var ret = TcpNet.ReadUInt16(Count);
|
||||
|
||||
sw.Stop();
|
||||
if (ret.IsSuccess)
|
||||
@ -504,51 +523,539 @@ namespace DH.Devices.PLC
|
||||
/// <summary>
|
||||
/// 转盘开启操作
|
||||
/// </summary>
|
||||
public void TurntableOpen(int speed, bool Direction)
|
||||
public void TurntableOpen()
|
||||
{
|
||||
WriteBool("M122", true);
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "计数清零");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
string CountToZero = pLCItem.Type + pLCItem.Address;
|
||||
PLCItem DiskSpeedItem = PLCItemList.FirstOrDefault(u => u.Name == "转盘速度");
|
||||
if (DiskSpeedItem == null)
|
||||
return;
|
||||
string diskSpeedadress = DiskSpeedItem.Type + DiskSpeedItem.Address;
|
||||
int diskSpeedValue= Convert.ToInt32( DiskSpeedItem.Value);
|
||||
PLCItem DiskDirectionItem = PLCItemList.FirstOrDefault(u => u.Name == "转盘方向");
|
||||
if (DiskDirectionItem == null)
|
||||
return;
|
||||
string diskDirectionadress = DiskDirectionItem.Type + DiskDirectionItem.Address;
|
||||
bool Direction =Convert.ToBoolean( DiskDirectionItem.Value);
|
||||
PLCItem DiskOpenItem = PLCItemList.FirstOrDefault(u => u.Name == "转盘使能");
|
||||
if (DiskOpenItem == null)
|
||||
return;
|
||||
string diskopenadress = DiskOpenItem.Type + DiskOpenItem.Address;
|
||||
PLCItem DiskRunItem = PLCItemList.FirstOrDefault(u => u.Name == "转盘启动");
|
||||
if (DiskRunItem == null)
|
||||
return;
|
||||
string diskadress = DiskRunItem.Type + DiskRunItem.Address;
|
||||
|
||||
|
||||
WriteBool(CountToZero, true);
|
||||
Thread.Sleep(10);
|
||||
WriteBool("M10", false);
|
||||
Thread.Sleep(10);
|
||||
//速度
|
||||
TcpNet.Write("HD10", (ushort)speed);
|
||||
TcpNet.Write(diskSpeedadress, (ushort)diskSpeedValue);
|
||||
Thread.Sleep(10);
|
||||
//方向
|
||||
WriteBool("M1", Direction);
|
||||
WriteBool(diskDirectionadress, Direction);
|
||||
Thread.Sleep(10);
|
||||
//使能
|
||||
WriteBool("M2", true);
|
||||
WriteBool(diskopenadress, true);
|
||||
Thread.Sleep(10);
|
||||
//启动
|
||||
WriteBool("M0", true);
|
||||
WriteBool(diskadress, true);
|
||||
|
||||
|
||||
//WriteBool("M122", true);
|
||||
//Thread.Sleep(10);
|
||||
//WriteBool("M10", false);
|
||||
//Thread.Sleep(10);
|
||||
////速度
|
||||
//TcpNet.Write("HD10", (ushort)10000);
|
||||
//Thread.Sleep(10);
|
||||
////方向
|
||||
//WriteBool("M1", Direction);
|
||||
//Thread.Sleep(10);
|
||||
////使能
|
||||
//WriteBool("M2", true);
|
||||
//Thread.Sleep(10);
|
||||
////启动
|
||||
//WriteBool("M0", true);
|
||||
Thread.Sleep(10);
|
||||
// _mainMotion.CurrentState = DeviceState.DSOpen;
|
||||
piecesCount = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 转盘停止操作
|
||||
/// </summary>
|
||||
public void TurntableStop()
|
||||
{
|
||||
WriteBool("M122", true);
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "计数清零");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
string CountToZero = pLCItem.Type + pLCItem.Address;
|
||||
PLCItem DiskRunItem = PLCItemList.FirstOrDefault(u => u.Name == "转盘启动");
|
||||
if (DiskRunItem == null)
|
||||
return;
|
||||
string diskadress = DiskRunItem.Type + DiskRunItem.Address;
|
||||
PLCItem DiskOpenItem = PLCItemList.FirstOrDefault(u => u.Name == "转盘使能");
|
||||
if (DiskOpenItem == null)
|
||||
return;
|
||||
string diskopenadress = DiskOpenItem.Type + DiskOpenItem.Address;
|
||||
|
||||
WriteBool(CountToZero, true);
|
||||
Thread.Sleep(50);
|
||||
WriteBool("M0", false);
|
||||
WriteBool(diskadress, false);
|
||||
Thread.Sleep(50);
|
||||
WriteBool("M2", false);
|
||||
WriteBool(diskopenadress, false);
|
||||
Thread.Sleep(50);
|
||||
WriteBool("M50", false);
|
||||
WriteBool("M10", false);
|
||||
|
||||
//WriteBool("M122", true);
|
||||
//Thread.Sleep(50);
|
||||
//WriteBool("M0", false);
|
||||
//Thread.Sleep(50);
|
||||
//WriteBool("M2", false);
|
||||
//Thread.Sleep(50);
|
||||
//WriteBool("M50", false);
|
||||
piecesCount = 0;
|
||||
}
|
||||
|
||||
private void PrepareMotion()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
//心跳
|
||||
//if (X018PLCConfig.Heartbeat)
|
||||
//{
|
||||
|
||||
Task.Run(async () => await HeartbeatAsync1());
|
||||
//}
|
||||
|
||||
////写入工件最大值、最小值
|
||||
ProjectValue();
|
||||
|
||||
|
||||
////写入工位脉冲
|
||||
Workstation1Pulse();
|
||||
Workstation2Pulse();
|
||||
Workstation3Pulse();
|
||||
Workstation4Pulse();
|
||||
Workstation5Pulse();
|
||||
|
||||
////写入吹气时间
|
||||
ChuiQiTime();
|
||||
|
||||
|
||||
////写入吹气脉冲
|
||||
OKPulse();
|
||||
NGPulse();
|
||||
//if (_GC01Driver == null)
|
||||
//{
|
||||
// _GC01Driver = DeviceCollection.FirstOrDefault(u => u is GC01Driver) as GC01Driver;
|
||||
//}
|
||||
//if (_GC01Driver == null)
|
||||
//{
|
||||
// throw new ProcessException($"未能获取激光位移传感器驱动");
|
||||
//}
|
||||
//if (_vibrationDriver == null)
|
||||
//{
|
||||
// _vibrationDriver = DeviceCollection.FirstOrDefault(u => u is JYDAMDriver) as JYDAMDriver;
|
||||
//}
|
||||
//if (_vibrationDriver == null)
|
||||
//{
|
||||
// throw new ProcessException($"未能获取振动盘控制器驱动");
|
||||
//}
|
||||
|
||||
// ResetTimer = new Timer(FullResetProcessExcute, null, -1, -1);
|
||||
|
||||
//feedingProductTimer = new Timer(FeedingProductTriggerExcute, null, -1, -1);
|
||||
//feedingProductTimerTimer = new Timer(UpdateFeedingProductTrigger, null, -1, -1);
|
||||
|
||||
//_mainMotion.OnAxisPositionChanged -= MainMotion_OnAxisPositionChanged;
|
||||
//_mainMotion.OnAxisPositionChanged += MainMotion_OnAxisPositionChanged;
|
||||
|
||||
//_mainMotion.OnCapturePositionChanged -= MainMotion_OnCapturePositionChanged;
|
||||
//_mainMotion.OnCapturePositionChanged += MainMotion_OnCapturePositionChanged;
|
||||
|
||||
// _mainMotion.OnNewPieces -= MainMotion_NewPieces;
|
||||
// _mainMotion.OnNewPieces += MainMotion_NewPieces;
|
||||
|
||||
//_mainMotion.OnAlarmVibrationDisk -= MainMotion_AlarmVibrationDisk;
|
||||
//_mainMotion.OnAlarmVibrationDisk += MainMotion_AlarmVibrationDisk;
|
||||
// PrepareLightIndexes();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 挡料电机操作
|
||||
/// true: 顺时针
|
||||
/// False: 逆时针
|
||||
/// </summary>
|
||||
/// <param name="u"></param>
|
||||
public void FeedingMotor( bool direction)
|
||||
{
|
||||
|
||||
|
||||
// 设置最大等待时间,假设为 3 秒
|
||||
int timeout = 3000;
|
||||
int elapsedTime = 0;
|
||||
int checkInterval = 100; // 每次检查等待 100ms
|
||||
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "挡料电机回原点");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
PLCItem zerospeeditem = PLCItemList.FirstOrDefault(u => u.Name == "挡料电机回原点速度");
|
||||
if (zerospeeditem == null)
|
||||
return;
|
||||
|
||||
PLCItem CunSpeed = PLCItemList.FirstOrDefault(u => u.Name == "挡料电机速度");
|
||||
if (CunSpeed == null)
|
||||
return;
|
||||
|
||||
PLCItem CunClockwiseItem = PLCItemList.FirstOrDefault(u => u.Name == "挡料电机顺时针");
|
||||
if (CunClockwiseItem == null)
|
||||
return;
|
||||
|
||||
PLCItem CunCounterclockwiseItem = PLCItemList.FirstOrDefault(u => u.Name == "挡料电机逆时针");
|
||||
if (CunCounterclockwiseItem == null)
|
||||
return;
|
||||
|
||||
PLCItem CunPosItem = PLCItemList.FirstOrDefault(u => u.Name == "挡料电机位置");
|
||||
if (CunPosItem == null)
|
||||
return;
|
||||
|
||||
string CunToZero = pLCItem.Type + pLCItem.Address;
|
||||
string CunToZeroSpeed = zerospeeditem.Type + zerospeeditem.Address;
|
||||
string CunSpeedadress = CunSpeed.Type + CunSpeed.Address;
|
||||
string CunClockwise = CunClockwiseItem.Type + CunClockwiseItem.Address;
|
||||
string CunCounterclockwise = CunCounterclockwiseItem.Type + CunCounterclockwiseItem.Address;
|
||||
string CunPos = CunPosItem.Type + CunPosItem.Address;
|
||||
short zerospeed = (short)Convert.ToInt32(zerospeeditem.Value);
|
||||
short cunSpeed = (short)Convert.ToInt32(CunSpeed.Value);
|
||||
short u = (short)Convert.ToInt32(CunPosItem.Value);
|
||||
// WriteBool(CountToZero, true);
|
||||
|
||||
// 检查是否不在原点,如果不在,则回原点
|
||||
if (!ReadBool(CunToZero))
|
||||
{
|
||||
WriteShort(CunToZeroSpeed, (short)zerospeed); // 速度
|
||||
Thread.Sleep(10);
|
||||
// 发送回原点指令
|
||||
WriteBool(CunToZero, true);
|
||||
Thread.Sleep(1000); // 给设备一些时间响应
|
||||
|
||||
// 等待回到原点
|
||||
while (!ReadBool(CunToZero))
|
||||
{
|
||||
if (elapsedTime >= timeout)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Thread.Sleep(checkInterval);
|
||||
elapsedTime += checkInterval;
|
||||
}
|
||||
}
|
||||
|
||||
// 无论是刚回到原点还是已经在原点,执行目标位置、速度和方向设置
|
||||
|
||||
|
||||
|
||||
WriteShort(CunSpeedadress, (short)cunSpeed);
|
||||
Thread.Sleep(2000);
|
||||
string dir = string.Empty;
|
||||
if (direction)
|
||||
{
|
||||
WriteBool(CunClockwise, true); // 顺时针转动
|
||||
dir = "顺时针";
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteBool(CunCounterclockwise, true); // 逆时针转动
|
||||
dir = "逆时针";
|
||||
}
|
||||
Thread.Sleep(10);
|
||||
WriteShort(CunPos, (short)u); // 目标位置
|
||||
Thread.Sleep(2000);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 计数清零
|
||||
/// </summary>
|
||||
public void CountToZero()
|
||||
{
|
||||
WriteBool("M120", true);
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "计数清零");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
string CountToZero = pLCItem.Type + pLCItem.Address;
|
||||
WriteBool(CountToZero, true);
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
public void RedLight(bool b)
|
||||
{
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "指示灯红");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
string RedLight = pLCItem.Type + pLCItem.Address;
|
||||
WriteBool(RedLight, b);
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
public void GreenLight(bool b)
|
||||
{
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "指示灯绿");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
string Light = pLCItem.Type + pLCItem.Address;
|
||||
WriteBool(Light, b);
|
||||
// WriteBool(IIConfig.GreenLight, b);
|
||||
Thread.Sleep(10);
|
||||
|
||||
}
|
||||
|
||||
public void YellowLight(bool b)
|
||||
{
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "指示灯黄");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
string Light = pLCItem.Type + pLCItem.Address;
|
||||
WriteBool(Light, b);
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
public void Buzzer(bool b)
|
||||
{
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "蜂鸣器");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
string Light = pLCItem.Type + pLCItem.Address;
|
||||
WriteBool(Light, b);
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
public void Belt(bool b)
|
||||
{
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "皮带");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
string Light = pLCItem.Type + pLCItem.Address;
|
||||
WriteBool(Light, b);
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
|
||||
public void Workstation1Pulse()
|
||||
{
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "工位1");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
string Workstation1Pulse = pLCItem.Type + pLCItem.Address;
|
||||
int Pulse=Convert.ToInt32(pLCItem.Value);
|
||||
|
||||
string result = Regex.Replace(Workstation1Pulse, @"\D", "");
|
||||
int r = Convert.ToInt32(result) + 1;
|
||||
result = "HD" + r.ToString();
|
||||
short high = (short)(Pulse >> 16); // 高 16 位
|
||||
short low = (short)(Pulse & 0xFFFF); // 低 16 位
|
||||
WriteShort(result, high);
|
||||
Thread.Sleep(10);
|
||||
WriteShort(Workstation1Pulse, low);
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
public void Workstation2Pulse()
|
||||
{
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "工位2");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
string Workstation1Pulse = pLCItem.Type + pLCItem.Address;
|
||||
int Pulse=Convert.ToInt32(pLCItem.Value);
|
||||
string result = Regex.Replace(Workstation1Pulse, @"\D", "");
|
||||
int r = Convert.ToInt32(result) + 1;
|
||||
result = "HD" + r.ToString();
|
||||
short high = (short)(Pulse >> 16); // 高 16 位
|
||||
short low = (short)(Pulse & 0xFFFF); // 低 16 位
|
||||
WriteShort(result, high);
|
||||
Thread.Sleep(10);
|
||||
WriteShort(Workstation1Pulse, low);
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
public void Workstation3Pulse()
|
||||
{
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "工位3");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
string Workstation1Pulse = pLCItem.Type + pLCItem.Address;
|
||||
int Pulse = Convert.ToInt32(pLCItem.Value);
|
||||
|
||||
string result = Regex.Replace(Workstation1Pulse, @"\D", "");
|
||||
int r = Convert.ToInt32(result) + 1;
|
||||
result = "HD" + r.ToString();
|
||||
short high = (short)(Pulse >> 16); // 高 16 位
|
||||
short low = (short)(Pulse & 0xFFFF); // 低 16 位
|
||||
WriteShort(result, high);
|
||||
Thread.Sleep(10);
|
||||
WriteShort(Workstation1Pulse, low);
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
public void Workstation4Pulse()
|
||||
{
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "工位4");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
string Workstation1Pulse = pLCItem.Type + pLCItem.Address;
|
||||
int Pulse = Convert.ToInt32(pLCItem.Value);
|
||||
string result = Regex.Replace(Workstation1Pulse, @"\D", "");
|
||||
int r = Convert.ToInt32(result) + 1;
|
||||
result = "HD" + r.ToString();
|
||||
short high = (short)(Pulse >> 16); // 高 16 位
|
||||
short low = (short)(Pulse & 0xFFFF); // 低 16 位
|
||||
WriteShort(result, high);
|
||||
Thread.Sleep(10);
|
||||
WriteShort(Workstation1Pulse, low);
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
public void Workstation5Pulse()
|
||||
{
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "工位5");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
|
||||
string Workstation1Pulse = pLCItem.Type + pLCItem.Address;
|
||||
int Pulse = Convert.ToInt32(pLCItem.Value);
|
||||
string result = Regex.Replace(Workstation1Pulse, @"\D", "");
|
||||
int r = Convert.ToInt32(result) + 1;
|
||||
result = "HD" + r.ToString();
|
||||
short high = (short)(Pulse >> 16); // 高 16 位
|
||||
short low = (short)(Pulse & 0xFFFF); // 低 16 位
|
||||
WriteShort(result, high);
|
||||
Thread.Sleep(10);
|
||||
WriteShort(Workstation1Pulse, low);
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void ProjectValue()
|
||||
{
|
||||
PLCItem pLCItemmax = PLCItemList.FirstOrDefault(u => u.Name == "工件最大值");
|
||||
if (pLCItemmax == null)
|
||||
return;
|
||||
PLCItem pLCItemmin = PLCItemList.FirstOrDefault(u => u.Name == "工件最小值");
|
||||
if (pLCItemmin == null)
|
||||
return;
|
||||
int productMax =Convert.ToInt32( pLCItemmax.Value);
|
||||
int productMin = Convert.ToInt32( pLCItemmin.Value);
|
||||
|
||||
string ProductMax = pLCItemmax.Type + pLCItemmax.Address;
|
||||
string ProductMin = pLCItemmin.Type + pLCItemmin.Address;
|
||||
WriteShort(ProductMax, (short)productMax);
|
||||
Thread.Sleep(10);
|
||||
WriteShort(ProductMin, (short)productMin);
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
public void OKPulse()
|
||||
{
|
||||
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "OK脉冲");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
|
||||
string OKPulse = pLCItem.Type + pLCItem.Address;
|
||||
int Pulse =Convert.ToInt32( pLCItem.Value);
|
||||
string result = Regex.Replace(OKPulse, @"\D", "");
|
||||
int r = Convert.ToInt32(result) + 1;
|
||||
result = "HD" + r.ToString();
|
||||
short high = (short)(Pulse >> 16); // 高 16 位
|
||||
short low = (short)(Pulse & 0xFFFF); // 低 16 位
|
||||
WriteShort(result, high);
|
||||
Thread.Sleep(10);
|
||||
WriteShort(OKPulse, low);
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
public void NGPulse()
|
||||
{
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "NG脉冲");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
|
||||
string NGPulse = pLCItem.Type + pLCItem.Address;
|
||||
int Pulse=Convert.ToInt32(pLCItem.Value);
|
||||
string result = Regex.Replace(NGPulse, @"\D", "");
|
||||
int r = Convert.ToInt32(result) + 1;
|
||||
result = "HD" + r.ToString();
|
||||
short high = (short)(Pulse >> 16); // 高 16 位
|
||||
short low = (short)(Pulse & 0xFFFF); // 低 16 位
|
||||
WriteShort(result, high);
|
||||
Thread.Sleep(10);
|
||||
WriteShort(NGPulse, low);
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
|
||||
public void TurnClear(bool b)
|
||||
{
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "转盘清料");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
|
||||
string TurnClear = pLCItem.Type + pLCItem.Address;
|
||||
|
||||
WriteBool(TurnClear, b);
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
public void OpenHeartbeat(bool v)
|
||||
{
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "心跳功能");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
|
||||
string Heartbeat = pLCItem.Type + pLCItem.Address;
|
||||
|
||||
WriteBool(Heartbeat, v);
|
||||
Thread.Sleep(10);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void Vibratory(bool v)
|
||||
{
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "振动盘");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
|
||||
|
||||
string Vibratory = pLCItem.Type + pLCItem.Address;
|
||||
WriteBool(Vibratory, v);
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
|
||||
public void ChuiQiTime()
|
||||
{
|
||||
PLCItem pLCItem = PLCItemList.FirstOrDefault(u => u.Name == "吹气时间");
|
||||
if (pLCItem == null)
|
||||
return;
|
||||
|
||||
|
||||
string ChuiQiTime = pLCItem.Type + pLCItem.Address;
|
||||
short time = (short)Convert.ToInt32(pLCItem.Value);
|
||||
WriteShort(ChuiQiTime, time);
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user