PLC Api 추가

This commit is contained in:
최이근 2026-02-13 20:36:46 +09:00
parent a95534302f
commit e946197f8b
3 changed files with 39 additions and 3 deletions

View File

@ -505,7 +505,7 @@ namespace AuroraIO.AJINEXTEK
int err = (int)CAXD.AxdiReadInport(index, ref data); int err = (int)CAXD.AxdiReadInport(index, ref data);
if (err != (int)AXT_FUNC_RESULT.AXT_RT_SUCCESS) if (err != (int)AXT_FUNC_RESULT.AXT_RT_SUCCESS)
{ {
throw new Exception(string.Format("ERR_IO_FAIL_TO_GET_BIT;ERROR CODE:{0}", err)); return false;
} }
return Convert.ToBoolean(data); return Convert.ToBoolean(data);
} }

View File

@ -1,4 +1,6 @@
using Hermes; using Aurora.Util.HislogPlus;
using AuroraPLC;
using Hermes;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -10,6 +12,28 @@ namespace ILSOS_CCW_H52A.Device
{ {
partial class PLCControllerCCWH52A partial class PLCControllerCCWH52A
{ {
public (int err, bool data) ReadBit(eBitInput inputAddr, ePLCDevice device = ePLCDevice.B, bool isInput = true) => base.ReadBit((int)inputAddr, device, isInput);
public int WriteBit(eBitOutput outputAddr, bool onOff, ePLCDevice device = ePLCDevice.B, bool isOutput = true) => base.WriteBit((int)outputAddr, onOff, device, isOutput);
public (int err, short data) ReadWord(eWordInput inputAddr, ePLCDevice device = ePLCDevice.W, bool isInput = true) => base.ReadWord((int)inputAddr, device, isInput);
public int WriteWord(eWordOutput outputAddr, short shData, ePLCDevice device = ePLCDevice.W, bool isOutput = true) => base.WriteWord((int)outputAddr, shData, device, isOutput);
public (int err, int data) ReadDWord(eWordInput inputAddr, ePLCDevice device = ePLCDevice.W, bool isInput = true) => base.ReadDWord((int)inputAddr, device, isInput);
public int WriteDWord(eWordOutput outputAddr, int iVal, ePLCDevice device = ePLCDevice.W, bool isOutput = true) => base.WriteDWord((int)outputAddr, iVal, device, isOutput);
public (int err, short[] datas) ReadWords(eWordInput startAddress, eWordInput endAddress, ePLCDevice device = ePLCDevice.W, bool isInput = true) => base.ReadWordBlock((int)startAddress, endAddress - startAddress + 1, device, isInput);
public int WriteWords(eWordOutput startAddress, eWordOutput endAddress, short[] data, ePLCDevice device = ePLCDevice.W, bool isOutput = true) => base.WriteWordBlock((int)startAddress, endAddress - startAddress, data, device, isOutput);
public string ReadASCII(eWordInput start, eWordInput end)
{
StringBuilder sb = new StringBuilder();
var words = ReadWords(start, end);
foreach (var word in words.datas)
sb.Append(Conv_ReadData(PLCBase.eDataType.Type_Ascii, word, 0, false, false));
return sb.ToString();
}
public override void MappingPLCAddr() public override void MappingPLCAddr()
{ {
PLC_AUTO_REQAddr = (int)eBitInput.PLC_AUTO_REQ; PLC_AUTO_REQAddr = (int)eBitInput.PLC_AUTO_REQ;
@ -92,5 +116,17 @@ namespace ILSOS_CCW_H52A.Device
else else
return 1000; return 1000;
} }
public int ToggleBit(eBitInput readBit, eBitOutput writeBit)
{
int ret = 0;
if (ReadBit(readBit).data)
ret = WriteBit(writeBit, false);
else
ret = WriteBit(writeBit, true);
Log.I($"{Enum.GetName(typeof(eBitOutput), writeBit)} -> {!ReadBit(readBit).data}");
return ret;
}
} }
} }

View File

@ -20,7 +20,7 @@ namespace WeldingCommon.Devices
public abstract partial class PLCController : PLCBase public abstract partial class PLCController : PLCBase
{ {
// Log 사용 방법 // Log 사용 방법
static Logger Log = new Logger("PLCController"); protected static Logger Log = new Logger("PLCController");
//static Logger EventLog = new Logger(eMsg_TYPE.PLC.ToString(), "Event"); //static Logger EventLog = new Logger(eMsg_TYPE.PLC.ToString(), "Event");