public WriteParameters(ApplicationLayerParameters parameters, byte[] msg, int startIndex) : base(parameters, msg, startIndex, true) { if ((msg.Length - startIndex) < GetEncodedSize()) { throw new ASDUParsingException("Message too small"); } _sn = BitConverter.ToUInt16(msg, startIndex); startIndex += 2; _pi = new ParameterIdentification(msg[startIndex++]); }
internal ReadParameters(ApplicationLayerParameters parameters, byte[] msg, int startIndex, int elementCount) : base(parameters, msg, startIndex, true) { _sn = BitConverter.ToUInt16(msg, startIndex); startIndex += 2; _pi = new ParameterIdentification(msg[startIndex++]); if ((msg.Length - startIndex) < GetEncodedSize()) { throw new ASDUParsingException("Message too small"); } _parameters = new List <Parameter>(); for (int i = 0; i < elementCount; i++) { var param = new Parameter(); param.ioa = msg[startIndex++]; if (parameters.SizeOfIOA > 1) { param.ioa += (msg[startIndex++] * 0x100); } if (parameters.SizeOfIOA > 2) { param.ioa += (msg[startIndex++] * 0x10000); } param.Tag = msg[startIndex++]; param.Length = msg[startIndex++]; param.RawBytes = new byte[param.Length]; if (param.Length > 0) { Array.Copy(msg, startIndex, param.RawBytes, 0, param.Length); startIndex += param.Length; } _parameters.Add(param); } }
public WriteParameters(ushort sn, ParameterIdentification pi, Parameter[] parameters) : base(0) { _sn = sn; _pi = pi; _parameters = parameters; }