71 lines
3.3 KiB
C#
71 lines
3.3 KiB
C#
using Hermes;
|
|
using ILSOS_PrismaticGun.Process;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using WeldingCommon.Devices;
|
|
|
|
namespace ILSOS_PrismaticGun.Device
|
|
{
|
|
partial class PLCControllerPrismaticGun
|
|
{
|
|
public (int err, bool data) ReadBit(eBitInput address) => ReadBit((ushort)address, ePLCDevice.M);
|
|
public (int err, bool data) ReadOutBit(eBitOutput address) => ReadBit((ushort)address, ePLCDevice.M, isInput:false);
|
|
public int WriteBit(eBitOutput addrOffset, bool onOff, ePLCDevice device = ePLCDevice.M, bool isOutput = true) => base.WriteBit((int)addrOffset, onOff, ePLCDevice.M, isOutput);
|
|
|
|
public (int err, short data) ReadWord(eWordInput address) => base.ReadWord((ushort)address, ePLCDevice.D);
|
|
public (int err, short data) ReadOutWord(eWordOutput address) => base.ReadWord((ushort)address, ePLCDevice.D, false);
|
|
|
|
public int WriteWord(eWordOutput addrOffset, short data, ePLCDevice device = ePLCDevice.D, bool isOutput = true) => base.WriteWord((int)addrOffset, data, ePLCDevice.D, isOutput);
|
|
|
|
public (int err, int data) ReadDWord(eWordInput address) => base.ReadDWord((ushort)address, ePLCDevice.D);
|
|
public int WriteDWord(eWordOutput addrOffset, int data, ePLCDevice device = ePLCDevice.D, bool isOutput = true) => base.WriteDWord((int)addrOffset, data, ePLCDevice.D, isOutput);
|
|
|
|
public (int err, short[] datas) ReadWords(eWordInput startAddress, eWordInput endAddress) => base.ReadWordBlock((int)startAddress, endAddress - startAddress + 1, ePLCDevice.D);
|
|
public int WriteWords(eWordOutput startAddress, eWordOutput endAddress, short[] data, ePLCDevice device = ePLCDevice.D, bool isOutput = true) => base.WriteWordBlock((int)startAddress, endAddress - startAddress, data, ePLCDevice.D, isOutput);
|
|
|
|
#region Word Bitmasking >> 워드 영역을 비트마스킹으로 사용하는 경우
|
|
public int WriteWordToBit((eWordOutput addrOffset, int bitNo) address, bool on)
|
|
{
|
|
var value = base.ReadWord((int)address.addrOffset, ePLCDevice.D, false);
|
|
short current = value.data;
|
|
|
|
if (on) {
|
|
current |= (short)(1 << address.bitNo);
|
|
} else {
|
|
current &= (short)~(1 << address.bitNo);
|
|
}
|
|
|
|
return base.WriteWord((int)address.addrOffset, current, ePLCDevice.D);
|
|
}
|
|
|
|
public bool ReadWordToBit((eWordInput addrOffset, int bitNo) address)
|
|
{
|
|
var value = base.ReadWord((int)address.addrOffset, ePLCDevice.D);
|
|
short current = value.data;
|
|
|
|
return (current & (1 << address.bitNo)) != 0;
|
|
}
|
|
#endregion
|
|
|
|
internal void LoadEnableToPLC(eStage weldingStage, bool on)
|
|
{
|
|
if(weldingStage is eStage.A)
|
|
WriteBit(eBitOutput.PC_STAGE_A_LOAD_ENABLE, on);
|
|
else
|
|
WriteBit(eBitOutput.PC_STAGE_B_LOAD_ENABLE, on);
|
|
}
|
|
|
|
internal void UnloadEnableToPLC(eStage weldingStage, bool on)
|
|
{
|
|
if (weldingStage is eStage.A)
|
|
WriteBit(eBitOutput.PC_STAGE_A_UNLOAD_ENABLE, on);
|
|
else
|
|
WriteBit(eBitOutput.PC_STAGE_B_UNLOAD_ENABLE, on);
|
|
}
|
|
}
|
|
}
|