private byte[] GetDataBytes(IRegisterMessage message, out IReadOnlyCollection <IRegisterGroup> composedGroups) { byte gByte; bool withValues = false; switch (message.Type) { case MessageType.Request: gByte = MilliGanjubusInfo.GRequest; break; case MessageType.Response: gByte = (byte)(MilliGanjubusInfo.GReply << 4); withValues = true; break; default: throw new NandakaBaseException("Undefined message type"); } bool isRange = RegisterConverter.IsRange(message.RegisterGroups, _info); switch (message.OperationType) { case OperationType.Read: if (isRange) { gByte |= MilliGanjubusInfo.FReadRange; } else { gByte |= MilliGanjubusInfo.FReadSeries; } break; case OperationType.Write: if (isRange) { gByte |= MilliGanjubusInfo.FWriteRange; } else { gByte |= MilliGanjubusInfo.FWriteSeries; } // By default assume that this is read operation. Otherwise invert variable. withValues = !withValues; break; default: throw new NandakaBaseException("Undefined operation type"); } byte[] dataHeader = { gByte }; if (isRange) { return(RegisterConverter.ComposeDataAsRange(message.RegisterGroups, _info, dataHeader, withValues, out composedGroups)); } return(RegisterConverter.ComposeDataAsSeries(message.RegisterGroups, _info, dataHeader, withValues, out composedGroups)); }