public static int BUILD_BYTE_ARRAY_HEADER(MESSAGE_FRAME_TYPE_T frameType, MESSAGE_DATA_CODE_T dataCode, COMMANDS_T command, SUB_COMMANDS_T subcommand, ReadOnlySpan <byte> errorInformation, byte[] dataArray, int startIndex) { int headerLength = 0; IntPtr p = IntPtr.Zero; try { switch (frameType, dataCode) { case (MESSAGE_FRAME_TYPE_T.MC_3E, MESSAGE_DATA_CODE_T.ASCII): case (MESSAGE_FRAME_TYPE_T.MC_4E, MESSAGE_DATA_CODE_T.ASCII): if (errorInformation == null) { headerLength = 0; } else { headerLength = Marshal.SizeOf <REQUEST_COMMAND_HEADER_IN_3E_ASCII_T>(); if (dataArray.Length - startIndex < headerLength + errorInformation.Length) { throw new SLMPException(SLMP_EXCEPTION_CODE_T.INSUFFICIENT_DATA_ARRAY_BUFFER); } REQUEST_COMMAND_HEADER_IN_3E_ASCII_T header3a = new REQUEST_COMMAND_HEADER_IN_3E_ASCII_T(0x30); Message.Message.BINARY_TO_ASCII_ARRAY((ushort)command, header3a.command, 0); Message.Message.BINARY_TO_ASCII_ARRAY((ushort)subcommand, header3a.subcommand, 0); p = Marshal.AllocHGlobal(headerLength); Marshal.StructureToPtr(header3a, p, false); errorInformation.CopyTo(dataArray.AsSpan(startIndex)); Marshal.Copy(p, dataArray, startIndex + errorInformation.Length, headerLength); headerLength += errorInformation.Length; } break;
public static int BUILD_BYTE_ARRAY_HEADER(MESSAGE_FRAME_TYPE_T frameType, MESSAGE_DATA_CODE_T dataCode, ushort serialNo, byte destinationNetwork, byte destinationStation, ushort destinationModuleIO, byte destinationMultidropStation, ushort destinationExtensionStation, ushort responseLength, ushort endCode, byte[] dataArray, int startIndex) { int headerLength = 0; IntPtr p = IntPtr.Zero; try { switch (frameType, dataCode) { case (MESSAGE_FRAME_TYPE_T.MC_3E, MESSAGE_DATA_CODE_T.ASCII): headerLength = Marshal.SizeOf <RESPONSE_MESSAGE_HEADER_IN_3E_ASCII_T>(); if (headerLength > dataArray.Length - startIndex) { throw new SLMPException(SLMP_EXCEPTION_CODE_T.INSUFFICIENT_DATA_ARRAY_BUFFER); } RESPONSE_MESSAGE_HEADER_IN_3E_ASCII_T header3a = new RESPONSE_MESSAGE_HEADER_IN_3E_ASCII_T(0x30); Message.BINARY_TO_ASCII_ARRAY(destinationNetwork, header3a.network, 0); Message.BINARY_TO_ASCII_ARRAY(destinationStation, header3a.station, 0); Message.BINARY_TO_ASCII_ARRAY(destinationModuleIO, header3a.module_io, 0); Message.BINARY_TO_ASCII_ARRAY(destinationMultidropStation, header3a.multidrop_station, 0); Message.BINARY_TO_ASCII_ARRAY(endCode, header3a.end_code, 0); Message.BINARY_TO_ASCII_ARRAY((ushort)(responseLength + 4), header3a.response_length, 0); p = Marshal.AllocHGlobal(headerLength); Marshal.StructureToPtr(header3a, p, false); break;
public RemoteOperationMaster(MESSAGE_FRAME_TYPE_T frameType, MESSAGE_DATA_CODE_T dataCode, bool dedicationR, SocketInterface sc, ref DESTINATION_ADDRESS_T destination, int sendBufferSize = 4096, int receiveBufferSize = 4096, object sync = null) { __socket = sc; __frame_type = frameType; __data_code = dataCode; __destination = destination; __send_byte_array = new byte[sendBufferSize]; __receive_byte_array = new byte[receiveBufferSize]; __sync_object = sync ?? new object(); switch (frameType, dataCode, dedicationR) {