Also move some previously static functions into their associated classes,
which lets us remove a few unnecessary wrapper functions used for testing.
No change in functionality.
Use git blame dd9a087 to follow the history before this refactoring.
bytesAvailable gets automatically calculated by QIODevice, so it doesn't
need to be reimplemented.
QIODevice doesn't necessarily buffer after a seek, and the underlying
device is unaware of peek/ungetChar, so canReadLine needs to check both
QIODevice and the device.
Most of the gains were from replacing endl with '\n', which avoids
unnecessary flushing. But there were a few hot functions whose
inefficiency ended up having a significan impact.
This is significant now because it will allow accurate recording of
multiple simultaneous connections.
This is important for the future because it establishes the
necessary infrastructure for recording downloaded sessions into their
own files so that they can be saved as backups.
Calling openConnection will return an open connection or nullptr.
Deleting the connection will close it.
SerialPort now uses this under the hood, while still presenting
the QSerialPort-compatible interface.
DreamStation ramp time and mask resistance "off" settings are now also imported.
Ventilator alarms are not yet parsed reliably enough to import at this time.
Previously it was reporting spurious information when the humidifier was
disconnected. Now it only reports settings details when the humidifier is
connected (the only time they're valid.)
It also now reports the humidification mode (fixed, adaptive, or heated
tube), and the heated tube temperature when appropriate.
The last statistics events in each slice are now correctly imported.
Previously, in the surprising edge case where two statistic periods are
reported with the same end-of-slice timestamp, they were both being duplicated
when marking the end of the slice.
Also, there were scattered instances where the final statistics in a slice
weren't being imported at all or were being imported incorrectly. These are
now fixed as well.
If there are no mask-on slices of nonzero duration, then there's not any
meaningful event or waveform data for the session. There is occasionally some
fragmentary data, but it's always less than 1 second.
When such fragmentary waveform data is present, it only contains 1-3 nonzero
samples, corresponding to 0.2s - 0.6s of data, which suggests that the
mask-on slice was really that long rather than precisely 0. As a result,
it appears that the timestamps of the mask-on/mask-off slices are just the
current value of the machine's internal clock, which only has 1-second
resolution.
But rather than embark on herculean efforts to derive a sub-second slice
duration from (only occasionally present) event or waveform data, we just
treat the session as having no detailed data.