/// <summary> /// Serializes the trace into a byte array. /// </summary> /// <returns>an array of bytes representing both the trace header and data</returns> public byte[] GetBytes() { byte[] headerBytes = Header.GetBytes(); byte[] traceBytes = new byte[headerBytes.Length + Data.Length * sizeof(float)]; float[] traceDataCpy = new float[Data.Length]; byte[] traceDataBytes = new byte[Data.Length * sizeof(float)]; // copy header bytes to output byte array Buffer.BlockCopy(headerBytes, 0, traceBytes, 0, headerBytes.Length); // copy data float array to copy array Buffer.BlockCopy(Data, 0, traceDataCpy, 0, traceDataCpy.Length * sizeof(float)); IbmConverter.float_to_ibm(traceDataCpy, traceDataCpy, traceDataCpy.Length); Buffer.BlockCopy(traceDataCpy, 0, traceDataBytes, 0, traceDataBytes.Length); for (int i = 0; i < traceDataCpy.Length; i++) { //var ibmBytes = IbmConverter.GetBytes(Data[i]); for (int j = 0; j < 4; j++) { traceBytes[240 + i * 4 + j] = traceDataBytes[i * 4 + j]; } } return(traceBytes); }