/// <summary> /// Contructor /// </summary> /// <param name="callingModule">Reference to the calling module</param> /// <param name="opcode">OPCode used for the outgoing messages</param> /// <param name="statusCodeType">Type of the enum for status code parsing on error</param> /// <param name="destinationAddress">Destination node address</param> /// <param name="content">Content to send in bytes</param> public FragmentWriteTransaction(ModuleBase callingModule, OperationMessage.OPCodes opcode, Type statusCodeType, ushort destinationAddress, byte[] content) { this.callingModule = callingModule; this.operationResponseOPCode = (OperationMessage.OPCodes)((int)opcode + 1); this.applicationStatusCodeType = statusCodeType; this.OpCode = opcode; this.DestinationAddress = destinationAddress; this.outputBuffer = new List <OperationMessage>(); this.totalFragments = (byte)(content.Length / MAX_CONTENT_SIZE); for (byte i = 0; i <= this.totalFragments; i++) { this.CurrentFrameSize = Math.Min(MAX_CONTENT_SIZE, content.Length - (i * MAX_CONTENT_SIZE)); OperationMessage currentOp = new OperationMessage() { SourceAddress = 0x00, DestinationAddress = destinationAddress, OpCode = OperationMessage.OPCodes.ConfigWrite, Args = new byte[this.CurrentFrameSize + 2] }; currentOp.Args[0] = (byte)((this.totalFragments << 4) | (i & 0xF)); currentOp.Args[1] = (byte)this.CurrentFrameSize; Buffer.BlockCopy(content, (i * MAX_CONTENT_SIZE), currentOp.Args, 2, this.CurrentFrameSize); this.outputBuffer.Add(currentOp); } }
public FragmentReadTransaction(ModuleBase callingModule, OperationMessage.OPCodes startOpcode, OperationMessage.OPCodes confirmationOpcode, Type statusCodeType, ushort destinationAddress) { this.callingModule = callingModule; this.operationResponseOPCode = (OperationMessage.OPCodes)((int)startOpcode + 1); this.StartOpCode = startOpcode; this.ConfirmationOpCode = confirmationOpcode; this.DestinationAddress = destinationAddress; this.inputBuffer = new List <OperationMessage>(); }
public FragmentReadTransaction(ModuleBase callingModule, OperationMessage.OPCodes startOpcode, OperationMessage.OPCodes confirmationOpcode, Type statusCodeType, ushort destinationAddress) { this.callingModule = callingModule; this.operationResponseOPCode = (OperationMessage.OPCodes)((int)startOpcode + 1); this.StartOpCode = startOpcode; this.ConfirmationOpCode = confirmationOpcode; this.DestinationAddress = destinationAddress; this.inputBuffer = new List<OperationMessage>(); }
/// <summary> /// Contructor /// </summary> /// <param name="callingModule">Reference to the calling module</param> /// <param name="opcode">OPCode used for the outgoing messages</param> /// <param name="statusCodeType">Type of the enum for status code parsing on error</param> /// <param name="destinationAddress">Destination node address</param> /// <param name="content">Content to send in bytes</param> public FragmentWriteTransaction(ModuleBase callingModule, OperationMessage.OPCodes opcode, Type statusCodeType, ushort destinationAddress, byte[] content) { this.callingModule = callingModule; this.operationResponseOPCode = (OperationMessage.OPCodes)((int)opcode + 1); this.applicationStatusCodeType = statusCodeType; this.OpCode = opcode; this.DestinationAddress = destinationAddress; this.outputBuffer = new List<OperationMessage>(); this.totalFragments = (byte)(content.Length / MAX_CONTENT_SIZE); for (byte i = 0; i <= this.totalFragments; i++) { this.CurrentFrameSize = Math.Min(MAX_CONTENT_SIZE, content.Length - (i * MAX_CONTENT_SIZE)); OperationMessage currentOp = new OperationMessage() { SourceAddress = 0x00, DestinationAddress = destinationAddress, OpCode = OperationMessage.OPCodes.ConfigWrite, Args = new byte[this.CurrentFrameSize + 2] }; currentOp.Args[0] = (byte)((this.totalFragments << 4) | (i & 0xF)); currentOp.Args[1] = (byte)this.CurrentFrameSize; Buffer.BlockCopy(content, (i * MAX_CONTENT_SIZE), currentOp.Args, 2, this.CurrentFrameSize); this.outputBuffer.Add(currentOp); } }