diff --git a/AuroraDevices/AuroraIO/Vendor/AJINEXTEK/AjinIO.cs b/AuroraDevices/AuroraIO/Vendor/AJINEXTEK/AjinIO.cs index 824ab82..37e317a 100644 --- a/AuroraDevices/AuroraIO/Vendor/AJINEXTEK/AjinIO.cs +++ b/AuroraDevices/AuroraIO/Vendor/AJINEXTEK/AjinIO.cs @@ -505,7 +505,7 @@ namespace AuroraIO.AJINEXTEK int err = (int)CAXD.AxdiReadInport(index, ref data); 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); } diff --git a/Machines/ILSOS_CCW_H52A/Device/PLC/PLCController.Logic.cs b/Machines/ILSOS_CCW_H52A/Device/PLC/PLCController.Logic.cs index 0073600..a8181ab 100644 --- a/Machines/ILSOS_CCW_H52A/Device/PLC/PLCController.Logic.cs +++ b/Machines/ILSOS_CCW_H52A/Device/PLC/PLCController.Logic.cs @@ -1,4 +1,6 @@ -using Hermes; +using Aurora.Util.HislogPlus; +using AuroraPLC; +using Hermes; using System; using System.Collections.Generic; using System.Linq; @@ -10,6 +12,28 @@ namespace ILSOS_CCW_H52A.Device { 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() { PLC_AUTO_REQAddr = (int)eBitInput.PLC_AUTO_REQ; @@ -92,5 +116,17 @@ namespace ILSOS_CCW_H52A.Device else 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; + } } } diff --git a/WeldingComponents/WeldingCommon/Devices/PLC/PLCController.Config.cs b/WeldingComponents/WeldingCommon/Devices/PLC/PLCController.Config.cs index 95b73a6..c53c675 100644 --- a/WeldingComponents/WeldingCommon/Devices/PLC/PLCController.Config.cs +++ b/WeldingComponents/WeldingCommon/Devices/PLC/PLCController.Config.cs @@ -20,7 +20,7 @@ namespace WeldingCommon.Devices public abstract partial class PLCController : PLCBase { // Log 사용 방법 - static Logger Log = new Logger("PLCController"); + protected static Logger Log = new Logger("PLCController"); //static Logger EventLog = new Logger(eMsg_TYPE.PLC.ToString(), "Event");