diff --git a/CMS_CORE_Library/S7Net/Nc_S7Net.cs b/CMS_CORE_Library/S7Net/Nc_S7Net.cs index 81997ef..7b2238e 100644 --- a/CMS_CORE_Library/S7Net/Nc_S7Net.cs +++ b/CMS_CORE_Library/S7Net/Nc_S7Net.cs @@ -620,16 +620,24 @@ namespace CMS_CORE_Library.S7Net public override CmsError PLC_RPowerOnData(ref PreAndPostPowerOnModel powerOnModel) { - int readValue = 0; - // Read pre power on and post power on data from memory - CmsError libraryError = MEM_RWInteger(R, 0, PRE_POST_POWER_ON.MemType, PRE_POST_POWER_ON.Address, PRE_POST_POWER_ON.SubAddress, ref readValue); + //int readValue = 0; + //// Read pre power on and post power on data from memory + //CmsError libraryError = MEM_RWInteger(R, 0, PRE_POST_POWER_ON.MemType, PRE_POST_POWER_ON.Address, PRE_POST_POWER_ON.SubAddress, ref readValue); + CmsError libraryError = NO_ERROR; + + List currMem = new List(); + libraryError = MEM_RWByteList(R, 0, PRE_POST_POWER_ON.MemType, PRE_POST_POWER_ON.Address, PRE_POST_POWER_ON.SubAddress,0, 4, ref currMem); + if (libraryError.IsError()) return libraryError; bool[] bits = new bool[32]; // Convert int into to true/false array - bits = IntToBits(readValue); + //bits = IntToBits(readValue); + var bArray = new BitArray(currMem.ToArray()); + bArray.CopyTo(bits, 0); + // Create adn set pre power on object PrePowerOnModel prePowerOn = new PrePowerOnModel() { diff --git a/CMS_CORE_Library/Utils/Nc_Utils.cs b/CMS_CORE_Library/Utils/Nc_Utils.cs index 28db11f..dc56657 100644 --- a/CMS_CORE_Library/Utils/Nc_Utils.cs +++ b/CMS_CORE_Library/Utils/Nc_Utils.cs @@ -179,7 +179,7 @@ namespace CMS_CORE_Library.Utils .Cast() .ToArray(); } - + // Convert a byte into an array of bools public static bool[] ByteToBits(byte val) {