public bool Equals(EITEntry other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } var equal = Configuration == other.Configuration && StartDateTime.EqualsUpToMilliseconds(other.StartDateTime) && EndDateTime.EqualsUpToMilliseconds(other.EndDateTime) && VoltagesReal.Rank == other.VoltagesReal.Rank && Enumerable.Range(0, VoltagesReal.Rank).All(dimension => VoltagesReal.GetLength(dimension) == other.VoltagesReal.GetLength(dimension)) && VoltagesReal.Cast <float>().SequenceEqual(other.VoltagesReal.Cast <float>()) && VoltagesIm.Rank == other.VoltagesIm.Rank && Enumerable.Range(0, VoltagesIm.Rank).All(dimension => VoltagesIm.GetLength(dimension) == other.VoltagesIm.GetLength(dimension)) && VoltagesIm.Cast <float>().SequenceEqual(other.VoltagesIm.Cast <float>()) && CurrentsReal.Rank == other.CurrentsReal.Rank && Enumerable.Range(0, VoltagesIm.Rank).All(dimension => CurrentsReal.GetLength(dimension) == other.CurrentsReal.GetLength(dimension)) && CurrentsReal.Cast <float>().SequenceEqual(other.CurrentsReal.Cast <float>()) && CurrentsIm.Rank == other.CurrentsIm.Rank && Enumerable.Range(0, CurrentsIm.Rank).All(dimension => CurrentsIm.GetLength(dimension) == other.CurrentsIm.GetLength(dimension)) && CurrentsIm.Cast <float>().SequenceEqual(other.CurrentsIm.Cast <float>()) && Saturation.Rank == other.Saturation.Rank && Enumerable.Range(0, Saturation.Rank).All(dimension => Saturation.GetLength(dimension) == other.Saturation.GetLength(dimension)) && Saturation.Cast <ulong>().SequenceEqual(other.Saturation.Cast <ulong>()) && Timestamps.Rank == other.Timestamps.Rank && Enumerable.Range(0, Timestamps.Rank).All(dimension => Timestamps.GetLength(dimension) == other.Timestamps.GetLength(dimension)) && Timestamps.Cast <long>().SequenceEqual(other.Timestamps.Cast <long>()); if (PacketIds != null && other.PacketIds != null) { equal = equal && PacketIds.Rank == other.PacketIds.Rank && Enumerable.Range(0, PacketIds.Rank).All(dimension => PacketIds.GetLength(dimension) == other.PacketIds.GetLength(dimension)) && PacketIds.Cast <ulong>().SequenceEqual(other.PacketIds.Cast <ulong>()); } return(equal); }
private void AppendSample(ElectrodeFrame[] samples, int length) { float[,] vReData = new float[length, samples[0].ComplexVoltageMatrix.Length]; float[,] vImData = new float[length, samples[0].ComplexVoltageMatrix.Length]; float[,] cReData = new float[length, samples[0].ComplexCurrentMatrix.Length]; float[,] cImData = new float[length, samples[0].ComplexCurrentMatrix.Length]; ulong[,] saturationData = new ulong[length, 1]; long[,] timestampData = new long[length, 1]; // Write packet id, kalpa clock only if exist => value != Uint64.MaxValue (default value) ulong[,] packetIdData = samples[0].PacketId == UInt64.MaxValue ? null : new ulong[length, 1]; ulong[,] kalpaClockData = samples[0].KalpaClock == UInt64.MaxValue ? null : new ulong[length, 1]; for (var i = 0; i < length; i++) { ElectrodeFrame electrodeFrame = samples[i]; for (int j = 0; j < electrodeFrame.ComplexVoltageMatrix.Length; j++) { vReData[i, j] = electrodeFrame.ComplexVoltageMatrix[j].Re; vImData[i, j] = electrodeFrame.ComplexVoltageMatrix[j].Im; } for (int j = 0; j < electrodeFrame.ComplexCurrentMatrix.Length; j++) { cReData[i, j] = electrodeFrame.ComplexCurrentMatrix[j].Re; cImData[i, j] = electrodeFrame.ComplexCurrentMatrix[j].Im; } saturationData[i, 0] = electrodeFrame.SaturationMask; timestampData[i, 0] = electrodeFrame.timestamp; if (packetIdData != null) { packetIdData[i, 0] = electrodeFrame.PacketId; } if (kalpaClockData != null) { kalpaClockData[i, 0] = electrodeFrame.KalpaClock; } } VoltagesReal.AppendOrCreateDataset(vReData); VoltagesIm.AppendOrCreateDataset(vImData); CurrentsReal.AppendOrCreateDataset(cReData); CurrentsIm.AppendOrCreateDataset(cImData); Saturation.AppendOrCreateDataset(saturationData); Timestamps.AppendOrCreateDataset(timestampData); if (packetIdData != null) { PacketIds.AppendOrCreateDataset(packetIdData); } if (kalpaClockData != null) { KalpaClocks.AppendOrCreateDataset(kalpaClockData); } }
public void Dispose() { try { if (!Disposed) { VoltagesReal.Dispose(); VoltagesIm.Dispose(); CurrentsReal?.Dispose(); CurrentsIm.Dispose(); Saturation.Dispose(); Timestamps.Dispose(); PacketIds?.Dispose(); ElectrodeTaskWriter.Dispose(); Hdf5.CloseGroup(GroupId); Disposed = true; } } catch (Exception e) { Logger.LogError($"Error during dispose of EIT: {e.Message}"); } }