Labrador/Desktop_Interface/isobuffer.h

150 lines
4.1 KiB
C
Raw Permalink Normal View History

#ifndef ISOBUFFER_H
#define ISOBUFFER_H
Isobuffer refactor (#64) * make isobuffer.cpp follow the common bracket style * Add a few utility functions to isoBuffer, and reorganize and comment isobuffer.h * refactor a few functions in isoBuffer using the newly added functions * Clean up isoBuffer::readBuffer. Requires particular attention during review * remove unused variable isoBuffer::firstTime * Fix formatting and add a comment to isoBuffer::maybeOutputSampleToFile * move invariant out of loop in isoBuffer::writeBuffer_short * Substantially refactor isoBuffer::readBuffer * change spaces to tabs on isoBuffer.h * spaces to tabs on isobuffer.cpp and isobuffer.h, but properly * Enforce const correctness on some methods of isoBuffer * Add some comments to isobuffer.cpp * Remove duplication in isoBuffer::cap_xnfromxxx functions by extracting common functionality to a free function * Format isobuffer.h and isobuffer.cpp * add inserted count to isoBuffer * further modification to isoBuffer::readBuffer * Correct a comment in isoBuffer::readBuffer * add an anonymous namespace with file-wide constants * remove isoBuffer::openFile, and move initialization isoBuffer to initializer list * add lines between if statements in isoBuffer::insertIntoBuffer * add spaces after // to some comments * extract common functionality from writeBuffer_xxx functions to function template * update header file to reflect previous commits * make isoBuffer::return nullptr in a troublesome case * add space after // to some other comments * Make capSample a member function of isoBuffer, delete a macro in isobuffer.cpp * clean up various comments and declarations in isobuffer.cpp * make isoBuffer::gainBuffer work for any gain value * make enableFileIO use the constant definitions made in a recent commit * Remove type argument from isoBuffer::serialManage * make isoBuffer::readBuffer return a zero-filled buffer instead of null * Remove isoBuffer::glitchInsert * Add a bunch of TODOs to isobuffer.cpp and isobuffer.h * Rename member variables of isoBuffer to have an m_ prefix * Move isoBuffer::capSample comparison functors to anonymous namespace * Make CONSOLE_UPDATE_TIMER_PERIOD on isobuffer.h a constexpr intead of a macro
2019-01-23 05:13:40 +00:00
// TODO: Move headers used only in implementation to isobuffer.cpp
#include <memory>
#include <QWidget>
#include <QString>
#include <QByteArray>
#include <QDebug>
#include <QTimer>
#include <QPlainTextEdit>
#include <QDir>
#include <QFile>
#include "xmega.h"
#include "desktop_settings.h"
#include "genericusbdriver.h"
2021-05-08 00:06:44 +01:00
#include "asyncdft.h"
class isoDriver;
class uartStyleDecoder;
2018-12-11 09:25:14 +00:00
enum class UartParity : uint8_t;
2019-01-28 02:39:48 +00:00
enum class TriggerType : uint8_t
{
Disabled,
Rising,
Falling
};
enum class TriggerSeekState : uint8_t
{
BelowTriggerLevel,
AboveTriggerLevel
};
Isobuffer refactor (#64) * make isobuffer.cpp follow the common bracket style * Add a few utility functions to isoBuffer, and reorganize and comment isobuffer.h * refactor a few functions in isoBuffer using the newly added functions * Clean up isoBuffer::readBuffer. Requires particular attention during review * remove unused variable isoBuffer::firstTime * Fix formatting and add a comment to isoBuffer::maybeOutputSampleToFile * move invariant out of loop in isoBuffer::writeBuffer_short * Substantially refactor isoBuffer::readBuffer * change spaces to tabs on isoBuffer.h * spaces to tabs on isobuffer.cpp and isobuffer.h, but properly * Enforce const correctness on some methods of isoBuffer * Add some comments to isobuffer.cpp * Remove duplication in isoBuffer::cap_xnfromxxx functions by extracting common functionality to a free function * Format isobuffer.h and isobuffer.cpp * add inserted count to isoBuffer * further modification to isoBuffer::readBuffer * Correct a comment in isoBuffer::readBuffer * add an anonymous namespace with file-wide constants * remove isoBuffer::openFile, and move initialization isoBuffer to initializer list * add lines between if statements in isoBuffer::insertIntoBuffer * add spaces after // to some comments * extract common functionality from writeBuffer_xxx functions to function template * update header file to reflect previous commits * make isoBuffer::return nullptr in a troublesome case * add space after // to some other comments * Make capSample a member function of isoBuffer, delete a macro in isobuffer.cpp * clean up various comments and declarations in isobuffer.cpp * make isoBuffer::gainBuffer work for any gain value * make enableFileIO use the constant definitions made in a recent commit * Remove type argument from isoBuffer::serialManage * make isoBuffer::readBuffer return a zero-filled buffer instead of null * Remove isoBuffer::glitchInsert * Add a bunch of TODOs to isobuffer.cpp and isobuffer.h * Rename member variables of isoBuffer to have an m_ prefix * Move isoBuffer::capSample comparison functors to anonymous namespace * Make CONSOLE_UPDATE_TIMER_PERIOD on isobuffer.h a constexpr intead of a macro
2019-01-23 05:13:40 +00:00
// isoBuffer is a generic class that enables O(1) read times (!!!) on all
// read/write operations, while maintaining a huge buffer size.
// Imagine it as a circular buffer, but with access functions specifically
// designed for isochronous data from an Xmega.
2019-01-23 05:14:24 +00:00
constexpr uint32_t CONSOLE_UPDATE_TIMER_PERIOD = ISO_PACKETS_PER_CTX * 4;
Isobuffer refactor (#64) * make isobuffer.cpp follow the common bracket style * Add a few utility functions to isoBuffer, and reorganize and comment isobuffer.h * refactor a few functions in isoBuffer using the newly added functions * Clean up isoBuffer::readBuffer. Requires particular attention during review * remove unused variable isoBuffer::firstTime * Fix formatting and add a comment to isoBuffer::maybeOutputSampleToFile * move invariant out of loop in isoBuffer::writeBuffer_short * Substantially refactor isoBuffer::readBuffer * change spaces to tabs on isoBuffer.h * spaces to tabs on isobuffer.cpp and isobuffer.h, but properly * Enforce const correctness on some methods of isoBuffer * Add some comments to isobuffer.cpp * Remove duplication in isoBuffer::cap_xnfromxxx functions by extracting common functionality to a free function * Format isobuffer.h and isobuffer.cpp * add inserted count to isoBuffer * further modification to isoBuffer::readBuffer * Correct a comment in isoBuffer::readBuffer * add an anonymous namespace with file-wide constants * remove isoBuffer::openFile, and move initialization isoBuffer to initializer list * add lines between if statements in isoBuffer::insertIntoBuffer * add spaces after // to some comments * extract common functionality from writeBuffer_xxx functions to function template * update header file to reflect previous commits * make isoBuffer::return nullptr in a troublesome case * add space after // to some other comments * Make capSample a member function of isoBuffer, delete a macro in isobuffer.cpp * clean up various comments and declarations in isobuffer.cpp * make isoBuffer::gainBuffer work for any gain value * make enableFileIO use the constant definitions made in a recent commit * Remove type argument from isoBuffer::serialManage * make isoBuffer::readBuffer return a zero-filled buffer instead of null * Remove isoBuffer::glitchInsert * Add a bunch of TODOs to isobuffer.cpp and isobuffer.h * Rename member variables of isoBuffer to have an m_ prefix * Move isoBuffer::capSample comparison functors to anonymous namespace * Make CONSOLE_UPDATE_TIMER_PERIOD on isobuffer.h a constexpr intead of a macro
2019-01-23 05:13:40 +00:00
// TODO: Make private what should be private
// TODO: Change integer types to cstdint types
class isoBuffer : public QWidget
{
Q_OBJECT
public:
isoBuffer(QWidget* parent = 0, int bufferLen = 0, isoDriver* caller = 0, unsigned char channel_value = 0);
~isoBuffer() = default;
Isobuffer refactor (#64) * make isobuffer.cpp follow the common bracket style * Add a few utility functions to isoBuffer, and reorganize and comment isobuffer.h * refactor a few functions in isoBuffer using the newly added functions * Clean up isoBuffer::readBuffer. Requires particular attention during review * remove unused variable isoBuffer::firstTime * Fix formatting and add a comment to isoBuffer::maybeOutputSampleToFile * move invariant out of loop in isoBuffer::writeBuffer_short * Substantially refactor isoBuffer::readBuffer * change spaces to tabs on isoBuffer.h * spaces to tabs on isobuffer.cpp and isobuffer.h, but properly * Enforce const correctness on some methods of isoBuffer * Add some comments to isobuffer.cpp * Remove duplication in isoBuffer::cap_xnfromxxx functions by extracting common functionality to a free function * Format isobuffer.h and isobuffer.cpp * add inserted count to isoBuffer * further modification to isoBuffer::readBuffer * Correct a comment in isoBuffer::readBuffer * add an anonymous namespace with file-wide constants * remove isoBuffer::openFile, and move initialization isoBuffer to initializer list * add lines between if statements in isoBuffer::insertIntoBuffer * add spaces after // to some comments * extract common functionality from writeBuffer_xxx functions to function template * update header file to reflect previous commits * make isoBuffer::return nullptr in a troublesome case * add space after // to some other comments * Make capSample a member function of isoBuffer, delete a macro in isobuffer.cpp * clean up various comments and declarations in isobuffer.cpp * make isoBuffer::gainBuffer work for any gain value * make enableFileIO use the constant definitions made in a recent commit * Remove type argument from isoBuffer::serialManage * make isoBuffer::readBuffer return a zero-filled buffer instead of null * Remove isoBuffer::glitchInsert * Add a bunch of TODOs to isobuffer.cpp and isobuffer.h * Rename member variables of isoBuffer to have an m_ prefix * Move isoBuffer::capSample comparison functors to anonymous namespace * Make CONSOLE_UPDATE_TIMER_PERIOD on isobuffer.h a constexpr intead of a macro
2019-01-23 05:13:40 +00:00
// Basic buffer operations
short bufferAt(uint32_t idx) const;
void insertIntoBuffer(short item);
void clearBuffer();
void gainBuffer(int gain_log);
Isobuffer refactor (#64) * make isobuffer.cpp follow the common bracket style * Add a few utility functions to isoBuffer, and reorganize and comment isobuffer.h * refactor a few functions in isoBuffer using the newly added functions * Clean up isoBuffer::readBuffer. Requires particular attention during review * remove unused variable isoBuffer::firstTime * Fix formatting and add a comment to isoBuffer::maybeOutputSampleToFile * move invariant out of loop in isoBuffer::writeBuffer_short * Substantially refactor isoBuffer::readBuffer * change spaces to tabs on isoBuffer.h * spaces to tabs on isobuffer.cpp and isobuffer.h, but properly * Enforce const correctness on some methods of isoBuffer * Add some comments to isobuffer.cpp * Remove duplication in isoBuffer::cap_xnfromxxx functions by extracting common functionality to a free function * Format isobuffer.h and isobuffer.cpp * add inserted count to isoBuffer * further modification to isoBuffer::readBuffer * Correct a comment in isoBuffer::readBuffer * add an anonymous namespace with file-wide constants * remove isoBuffer::openFile, and move initialization isoBuffer to initializer list * add lines between if statements in isoBuffer::insertIntoBuffer * add spaces after // to some comments * extract common functionality from writeBuffer_xxx functions to function template * update header file to reflect previous commits * make isoBuffer::return nullptr in a troublesome case * add space after // to some other comments * Make capSample a member function of isoBuffer, delete a macro in isobuffer.cpp * clean up various comments and declarations in isobuffer.cpp * make isoBuffer::gainBuffer work for any gain value * make enableFileIO use the constant definitions made in a recent commit * Remove type argument from isoBuffer::serialManage * make isoBuffer::readBuffer return a zero-filled buffer instead of null * Remove isoBuffer::glitchInsert * Add a bunch of TODOs to isobuffer.cpp and isobuffer.h * Rename member variables of isoBuffer to have an m_ prefix * Move isoBuffer::capSample comparison functors to anonymous namespace * Make CONSOLE_UPDATE_TIMER_PERIOD on isobuffer.h a constexpr intead of a macro
2019-01-23 05:13:40 +00:00
2022-01-23 06:48:51 +00:00
void enableDftWrite(bool enable);
Isobuffer refactor (#64) * make isobuffer.cpp follow the common bracket style * Add a few utility functions to isoBuffer, and reorganize and comment isobuffer.h * refactor a few functions in isoBuffer using the newly added functions * Clean up isoBuffer::readBuffer. Requires particular attention during review * remove unused variable isoBuffer::firstTime * Fix formatting and add a comment to isoBuffer::maybeOutputSampleToFile * move invariant out of loop in isoBuffer::writeBuffer_short * Substantially refactor isoBuffer::readBuffer * change spaces to tabs on isoBuffer.h * spaces to tabs on isobuffer.cpp and isobuffer.h, but properly * Enforce const correctness on some methods of isoBuffer * Add some comments to isobuffer.cpp * Remove duplication in isoBuffer::cap_xnfromxxx functions by extracting common functionality to a free function * Format isobuffer.h and isobuffer.cpp * add inserted count to isoBuffer * further modification to isoBuffer::readBuffer * Correct a comment in isoBuffer::readBuffer * add an anonymous namespace with file-wide constants * remove isoBuffer::openFile, and move initialization isoBuffer to initializer list * add lines between if statements in isoBuffer::insertIntoBuffer * add spaces after // to some comments * extract common functionality from writeBuffer_xxx functions to function template * update header file to reflect previous commits * make isoBuffer::return nullptr in a troublesome case * add space after // to some other comments * Make capSample a member function of isoBuffer, delete a macro in isobuffer.cpp * clean up various comments and declarations in isobuffer.cpp * make isoBuffer::gainBuffer work for any gain value * make enableFileIO use the constant definitions made in a recent commit * Remove type argument from isoBuffer::serialManage * make isoBuffer::readBuffer return a zero-filled buffer instead of null * Remove isoBuffer::glitchInsert * Add a bunch of TODOs to isobuffer.cpp and isobuffer.h * Rename member variables of isoBuffer to have an m_ prefix * Move isoBuffer::capSample comparison functors to anonymous namespace * Make CONSOLE_UPDATE_TIMER_PERIOD on isobuffer.h a constexpr intead of a macro
2019-01-23 05:13:40 +00:00
// Advanced buffer operations
private:
2021-05-08 00:06:44 +01:00
template<typename T, typename Function>
void writeBuffer(T* data, int len, int TOP, Function transform);
Isobuffer refactor (#64) * make isobuffer.cpp follow the common bracket style * Add a few utility functions to isoBuffer, and reorganize and comment isobuffer.h * refactor a few functions in isoBuffer using the newly added functions * Clean up isoBuffer::readBuffer. Requires particular attention during review * remove unused variable isoBuffer::firstTime * Fix formatting and add a comment to isoBuffer::maybeOutputSampleToFile * move invariant out of loop in isoBuffer::writeBuffer_short * Substantially refactor isoBuffer::readBuffer * change spaces to tabs on isoBuffer.h * spaces to tabs on isobuffer.cpp and isobuffer.h, but properly * Enforce const correctness on some methods of isoBuffer * Add some comments to isobuffer.cpp * Remove duplication in isoBuffer::cap_xnfromxxx functions by extracting common functionality to a free function * Format isobuffer.h and isobuffer.cpp * add inserted count to isoBuffer * further modification to isoBuffer::readBuffer * Correct a comment in isoBuffer::readBuffer * add an anonymous namespace with file-wide constants * remove isoBuffer::openFile, and move initialization isoBuffer to initializer list * add lines between if statements in isoBuffer::insertIntoBuffer * add spaces after // to some comments * extract common functionality from writeBuffer_xxx functions to function template * update header file to reflect previous commits * make isoBuffer::return nullptr in a troublesome case * add space after // to some other comments * Make capSample a member function of isoBuffer, delete a macro in isobuffer.cpp * clean up various comments and declarations in isobuffer.cpp * make isoBuffer::gainBuffer work for any gain value * make enableFileIO use the constant definitions made in a recent commit * Remove type argument from isoBuffer::serialManage * make isoBuffer::readBuffer return a zero-filled buffer instead of null * Remove isoBuffer::glitchInsert * Add a bunch of TODOs to isobuffer.cpp and isobuffer.h * Rename member variables of isoBuffer to have an m_ prefix * Move isoBuffer::capSample comparison functors to anonymous namespace * Make CONSOLE_UPDATE_TIMER_PERIOD on isobuffer.h a constexpr intead of a macro
2019-01-23 05:13:40 +00:00
public:
void writeBuffer_char(char* data, int len);
void writeBuffer_short(short* data, int len);
Isobuffer refactor (#64) * make isobuffer.cpp follow the common bracket style * Add a few utility functions to isoBuffer, and reorganize and comment isobuffer.h * refactor a few functions in isoBuffer using the newly added functions * Clean up isoBuffer::readBuffer. Requires particular attention during review * remove unused variable isoBuffer::firstTime * Fix formatting and add a comment to isoBuffer::maybeOutputSampleToFile * move invariant out of loop in isoBuffer::writeBuffer_short * Substantially refactor isoBuffer::readBuffer * change spaces to tabs on isoBuffer.h * spaces to tabs on isobuffer.cpp and isobuffer.h, but properly * Enforce const correctness on some methods of isoBuffer * Add some comments to isobuffer.cpp * Remove duplication in isoBuffer::cap_xnfromxxx functions by extracting common functionality to a free function * Format isobuffer.h and isobuffer.cpp * add inserted count to isoBuffer * further modification to isoBuffer::readBuffer * Correct a comment in isoBuffer::readBuffer * add an anonymous namespace with file-wide constants * remove isoBuffer::openFile, and move initialization isoBuffer to initializer list * add lines between if statements in isoBuffer::insertIntoBuffer * add spaces after // to some comments * extract common functionality from writeBuffer_xxx functions to function template * update header file to reflect previous commits * make isoBuffer::return nullptr in a troublesome case * add space after // to some other comments * Make capSample a member function of isoBuffer, delete a macro in isobuffer.cpp * clean up various comments and declarations in isobuffer.cpp * make isoBuffer::gainBuffer work for any gain value * make enableFileIO use the constant definitions made in a recent commit * Remove type argument from isoBuffer::serialManage * make isoBuffer::readBuffer return a zero-filled buffer instead of null * Remove isoBuffer::glitchInsert * Add a bunch of TODOs to isobuffer.cpp and isobuffer.h * Rename member variables of isoBuffer to have an m_ prefix * Move isoBuffer::capSample comparison functors to anonymous namespace * Make CONSOLE_UPDATE_TIMER_PERIOD on isobuffer.h a constexpr intead of a macro
2019-01-23 05:13:40 +00:00
std::unique_ptr<short[]> readBuffer(double sampleWindow, int numSamples, bool singleBit, double delayOffset);
// file I/O
private:
void outputSampleToFile(double averageSample);
void maybeOutputSampleToFile(double convertedSample);
public:
double sampleConvert(short sample, int TOP, bool AC) const;
short inverseSampleConvert(double voltageLevel, int TOP, bool AC) const;
Isobuffer refactor (#64) * make isobuffer.cpp follow the common bracket style * Add a few utility functions to isoBuffer, and reorganize and comment isobuffer.h * refactor a few functions in isoBuffer using the newly added functions * Clean up isoBuffer::readBuffer. Requires particular attention during review * remove unused variable isoBuffer::firstTime * Fix formatting and add a comment to isoBuffer::maybeOutputSampleToFile * move invariant out of loop in isoBuffer::writeBuffer_short * Substantially refactor isoBuffer::readBuffer * change spaces to tabs on isoBuffer.h * spaces to tabs on isobuffer.cpp and isobuffer.h, but properly * Enforce const correctness on some methods of isoBuffer * Add some comments to isobuffer.cpp * Remove duplication in isoBuffer::cap_xnfromxxx functions by extracting common functionality to a free function * Format isobuffer.h and isobuffer.cpp * add inserted count to isoBuffer * further modification to isoBuffer::readBuffer * Correct a comment in isoBuffer::readBuffer * add an anonymous namespace with file-wide constants * remove isoBuffer::openFile, and move initialization isoBuffer to initializer list * add lines between if statements in isoBuffer::insertIntoBuffer * add spaces after // to some comments * extract common functionality from writeBuffer_xxx functions to function template * update header file to reflect previous commits * make isoBuffer::return nullptr in a troublesome case * add space after // to some other comments * Make capSample a member function of isoBuffer, delete a macro in isobuffer.cpp * clean up various comments and declarations in isobuffer.cpp * make isoBuffer::gainBuffer work for any gain value * make enableFileIO use the constant definitions made in a recent commit * Remove type argument from isoBuffer::serialManage * make isoBuffer::readBuffer return a zero-filled buffer instead of null * Remove isoBuffer::glitchInsert * Add a bunch of TODOs to isobuffer.cpp and isobuffer.h * Rename member variables of isoBuffer to have an m_ prefix * Move isoBuffer::capSample comparison functors to anonymous namespace * Make CONSOLE_UPDATE_TIMER_PERIOD on isobuffer.h a constexpr intead of a macro
2019-01-23 05:13:40 +00:00
private:
template<typename Function>
int capSample(int offset, int target, double seconds, double value, Function comp);
2019-01-28 02:39:48 +00:00
void checkTriggered();
Isobuffer refactor (#64) * make isobuffer.cpp follow the common bracket style * Add a few utility functions to isoBuffer, and reorganize and comment isobuffer.h * refactor a few functions in isoBuffer using the newly added functions * Clean up isoBuffer::readBuffer. Requires particular attention during review * remove unused variable isoBuffer::firstTime * Fix formatting and add a comment to isoBuffer::maybeOutputSampleToFile * move invariant out of loop in isoBuffer::writeBuffer_short * Substantially refactor isoBuffer::readBuffer * change spaces to tabs on isoBuffer.h * spaces to tabs on isobuffer.cpp and isobuffer.h, but properly * Enforce const correctness on some methods of isoBuffer * Add some comments to isobuffer.cpp * Remove duplication in isoBuffer::cap_xnfromxxx functions by extracting common functionality to a free function * Format isobuffer.h and isobuffer.cpp * add inserted count to isoBuffer * further modification to isoBuffer::readBuffer * Correct a comment in isoBuffer::readBuffer * add an anonymous namespace with file-wide constants * remove isoBuffer::openFile, and move initialization isoBuffer to initializer list * add lines between if statements in isoBuffer::insertIntoBuffer * add spaces after // to some comments * extract common functionality from writeBuffer_xxx functions to function template * update header file to reflect previous commits * make isoBuffer::return nullptr in a troublesome case * add space after // to some other comments * Make capSample a member function of isoBuffer, delete a macro in isobuffer.cpp * clean up various comments and declarations in isobuffer.cpp * make isoBuffer::gainBuffer work for any gain value * make enableFileIO use the constant definitions made in a recent commit * Remove type argument from isoBuffer::serialManage * make isoBuffer::readBuffer return a zero-filled buffer instead of null * Remove isoBuffer::glitchInsert * Add a bunch of TODOs to isobuffer.cpp and isobuffer.h * Rename member variables of isoBuffer to have an m_ prefix * Move isoBuffer::capSample comparison functors to anonymous namespace * Make CONSOLE_UPDATE_TIMER_PERIOD on isobuffer.h a constexpr intead of a macro
2019-01-23 05:13:40 +00:00
public:
int cap_x0fromLast(double seconds, double vbot);
int cap_x1fromLast(double seconds, int x0, double vbot);
int cap_x2fromLast(double seconds, int x1, double vtop);
void serialManage(double baudRate, UartParity parity, bool hexDisplay);
2019-01-28 02:39:48 +00:00
void setTriggerType(TriggerType newType);
void setTriggerLevel(double voltageLevel, uint16_t top, bool acCoupled);
2019-01-28 09:10:29 +00:00
double getDelayedTriggerPoint(double delay);
2021-06-24 11:12:28 +01:00
double getTriggerFrequencyHz();
Isobuffer refactor (#64) * make isobuffer.cpp follow the common bracket style * Add a few utility functions to isoBuffer, and reorganize and comment isobuffer.h * refactor a few functions in isoBuffer using the newly added functions * Clean up isoBuffer::readBuffer. Requires particular attention during review * remove unused variable isoBuffer::firstTime * Fix formatting and add a comment to isoBuffer::maybeOutputSampleToFile * move invariant out of loop in isoBuffer::writeBuffer_short * Substantially refactor isoBuffer::readBuffer * change spaces to tabs on isoBuffer.h * spaces to tabs on isobuffer.cpp and isobuffer.h, but properly * Enforce const correctness on some methods of isoBuffer * Add some comments to isobuffer.cpp * Remove duplication in isoBuffer::cap_xnfromxxx functions by extracting common functionality to a free function * Format isobuffer.h and isobuffer.cpp * add inserted count to isoBuffer * further modification to isoBuffer::readBuffer * Correct a comment in isoBuffer::readBuffer * add an anonymous namespace with file-wide constants * remove isoBuffer::openFile, and move initialization isoBuffer to initializer list * add lines between if statements in isoBuffer::insertIntoBuffer * add spaces after // to some comments * extract common functionality from writeBuffer_xxx functions to function template * update header file to reflect previous commits * make isoBuffer::return nullptr in a troublesome case * add space after // to some other comments * Make capSample a member function of isoBuffer, delete a macro in isobuffer.cpp * clean up various comments and declarations in isobuffer.cpp * make isoBuffer::gainBuffer work for any gain value * make enableFileIO use the constant definitions made in a recent commit * Remove type argument from isoBuffer::serialManage * make isoBuffer::readBuffer return a zero-filled buffer instead of null * Remove isoBuffer::glitchInsert * Add a bunch of TODOs to isobuffer.cpp and isobuffer.h * Rename member variables of isoBuffer to have an m_ prefix * Move isoBuffer::capSample comparison functors to anonymous namespace * Make CONSOLE_UPDATE_TIMER_PERIOD on isobuffer.h a constexpr intead of a macro
2019-01-23 05:13:40 +00:00
// ---- MEMBER VARIABLES ----
// Presentation?
// TODO: Add consoles as constructor arguments
// NOTE: These are initialized in mainwindow.cpp
QPlainTextEdit* m_console1;
QPlainTextEdit* m_console2;
unsigned char m_channel = 255;
bool m_serialAutoScroll = true;
Isobuffer refactor (#64) * make isobuffer.cpp follow the common bracket style * Add a few utility functions to isoBuffer, and reorganize and comment isobuffer.h * refactor a few functions in isoBuffer using the newly added functions * Clean up isoBuffer::readBuffer. Requires particular attention during review * remove unused variable isoBuffer::firstTime * Fix formatting and add a comment to isoBuffer::maybeOutputSampleToFile * move invariant out of loop in isoBuffer::writeBuffer_short * Substantially refactor isoBuffer::readBuffer * change spaces to tabs on isoBuffer.h * spaces to tabs on isobuffer.cpp and isobuffer.h, but properly * Enforce const correctness on some methods of isoBuffer * Add some comments to isobuffer.cpp * Remove duplication in isoBuffer::cap_xnfromxxx functions by extracting common functionality to a free function * Format isobuffer.h and isobuffer.cpp * add inserted count to isoBuffer * further modification to isoBuffer::readBuffer * Correct a comment in isoBuffer::readBuffer * add an anonymous namespace with file-wide constants * remove isoBuffer::openFile, and move initialization isoBuffer to initializer list * add lines between if statements in isoBuffer::insertIntoBuffer * add spaces after // to some comments * extract common functionality from writeBuffer_xxx functions to function template * update header file to reflect previous commits * make isoBuffer::return nullptr in a troublesome case * add space after // to some other comments * Make capSample a member function of isoBuffer, delete a macro in isobuffer.cpp * clean up various comments and declarations in isobuffer.cpp * make isoBuffer::gainBuffer work for any gain value * make enableFileIO use the constant definitions made in a recent commit * Remove type argument from isoBuffer::serialManage * make isoBuffer::readBuffer return a zero-filled buffer instead of null * Remove isoBuffer::glitchInsert * Add a bunch of TODOs to isobuffer.cpp and isobuffer.h * Rename member variables of isoBuffer to have an m_ prefix * Move isoBuffer::capSample comparison functors to anonymous namespace * Make CONSOLE_UPDATE_TIMER_PERIOD on isobuffer.h a constexpr intead of a macro
2019-01-23 05:13:40 +00:00
// Internal Storage
2019-02-15 10:44:02 +00:00
std::unique_ptr<short[]> m_bufferPtr;
short* m_buffer;
uint32_t m_back = 0;
uint32_t m_insertedCount = 0;
uint32_t m_bufferLen;
Isobuffer refactor (#64) * make isobuffer.cpp follow the common bracket style * Add a few utility functions to isoBuffer, and reorganize and comment isobuffer.h * refactor a few functions in isoBuffer using the newly added functions * Clean up isoBuffer::readBuffer. Requires particular attention during review * remove unused variable isoBuffer::firstTime * Fix formatting and add a comment to isoBuffer::maybeOutputSampleToFile * move invariant out of loop in isoBuffer::writeBuffer_short * Substantially refactor isoBuffer::readBuffer * change spaces to tabs on isoBuffer.h * spaces to tabs on isobuffer.cpp and isobuffer.h, but properly * Enforce const correctness on some methods of isoBuffer * Add some comments to isobuffer.cpp * Remove duplication in isoBuffer::cap_xnfromxxx functions by extracting common functionality to a free function * Format isobuffer.h and isobuffer.cpp * add inserted count to isoBuffer * further modification to isoBuffer::readBuffer * Correct a comment in isoBuffer::readBuffer * add an anonymous namespace with file-wide constants * remove isoBuffer::openFile, and move initialization isoBuffer to initializer list * add lines between if statements in isoBuffer::insertIntoBuffer * add spaces after // to some comments * extract common functionality from writeBuffer_xxx functions to function template * update header file to reflect previous commits * make isoBuffer::return nullptr in a troublesome case * add space after // to some other comments * Make capSample a member function of isoBuffer, delete a macro in isobuffer.cpp * clean up various comments and declarations in isobuffer.cpp * make isoBuffer::gainBuffer work for any gain value * make enableFileIO use the constant definitions made in a recent commit * Remove type argument from isoBuffer::serialManage * make isoBuffer::readBuffer return a zero-filled buffer instead of null * Remove isoBuffer::glitchInsert * Add a bunch of TODOs to isobuffer.cpp and isobuffer.h * Rename member variables of isoBuffer to have an m_ prefix * Move isoBuffer::capSample comparison functors to anonymous namespace * Make CONSOLE_UPDATE_TIMER_PERIOD on isobuffer.h a constexpr intead of a macro
2019-01-23 05:13:40 +00:00
// Conversion And Sampling
double m_voltage_ref = 1.65;
double m_frontendGain = (R4 / (R3 + R4));
int m_samplesPerSecond;
int m_sampleRate_bit;
2019-01-28 02:39:48 +00:00
TriggerType m_triggerType = TriggerType::Disabled;
TriggerSeekState m_triggerSeekState = TriggerSeekState::BelowTriggerLevel;
short m_triggerLevel = 0;
short m_triggerSensitivity = 0;
std::vector<uint32_t> m_triggerPositionList = {};
// UARTS decoding
uartStyleDecoder* m_decoder = NULL;
bool m_isDecoding = true;
//DFT
2022-01-23 06:48:51 +00:00
AsyncDFT* async_dft;
private:
// File I/O
bool m_fileIOEnabled = false;
QFile* m_currentFile;
int m_fileIO_sampleCountPerWrite;
int m_fileIO_sampleCount;
double m_fileIO_sampleAccumulator;
qulonglong m_fileIO_maxFileSize;
qulonglong m_fileIO_numBytesWritten;
unsigned int m_currentColumn = 0;
2021-06-24 10:04:36 +01:00
uint32_t m_lastTriggerDetlaT = 0;
2022-01-23 06:48:51 +00:00
bool m_asyncDftActive = false;
isoDriver* m_virtualParent;
2021-06-24 10:04:36 +01:00
void addTriggerPosition(uint32_t position);
signals:
void fileIOinternalDisable();
public slots:
void enableFileIO(QFile* file, int samplesToAverage, qulonglong max_file_size);
void disableFileIO();
};
#endif // ISOBUFFER_H