Compare commits

..

No commits in common. "b2c0bc43feab4b816c06512d319065cd79fb571d" and "d19e62862b28f9a8f9c2e59f1b8407a205ea6685" have entirely different histories.

5 changed files with 34 additions and 47 deletions

View file

@ -77,20 +77,6 @@ void SampleRing::CommandPass(const unsigned int cmd) {
void SampleRing::write(DATA_BLOCK const * data) { void SampleRing::write(DATA_BLOCK const * data) {
if (m_finished) return; if (m_finished) return;
/** Tady je problém - tato funkce běží pod přerušením s vyšší prioritou,
* takže m_mode se během tt. funkce změnit nemůže. Z toho vyplývá, že se
* odeslání dat musí vykonat a nelze tedy změnit m_mode dokud se data
* meodešlou do ring_buffer všechna.
* */
if (m_mode != o_mode) { // bug fix
if (m_mode == TIME_BASE_CONTINUOUS) { // Při změně na kontinuální provoz
m_lenght = RING_LEN; // odešli celý ring_buffer.
m_tail = m_head; // Není to ideální, ale funguje to.
m_finished = true; // Příkaz k odeslání to odstartuje.
}
o_mode = m_mode;
return;
}
unsigned t_head = m_head; // dočasné proměnné kvůli zrychlení unsigned t_head = m_head; // dočasné proměnné kvůli zrychlení
unsigned t_lenght = m_lenght; // následujícího cyklu unsigned t_lenght = m_lenght; // následujícího cyklu
if (m_mode == TIME_BASE_TRIGERED) { if (m_mode == TIME_BASE_TRIGERED) {
@ -108,7 +94,7 @@ void SampleRing::write(DATA_BLOCK const * data) {
} }
} }
m_old_triger = !compare; m_old_triger = !compare;
if (t_lenght >= RING_LEN) { // je fuk o kolik je to delší if (t_lenght >= RING_LEN) {
// zastavit odesílání dat, pokud není AUTO a není splněna podmínka trigeru // zastavit odesílání dat, pokud není AUTO a není splněna podmínka trigeru
if ((m_settings.mode != TRIGER_MODE_AUTO) and !m_trigered) continue; if ((m_settings.mode != TRIGER_MODE_AUTO) and !m_trigered) continue;
t_lenght = RING_LEN; t_lenght = RING_LEN;
@ -120,9 +106,9 @@ void SampleRing::write(DATA_BLOCK const * data) {
} else { } else {
const DATA_BLOCK & sample = data [0]; const DATA_BLOCK & sample = data [0];
ring_buffer [t_head].common_data = sample.common_data; ring_buffer [t_head].common_data = sample.common_data;
t_head += 1u; t_head += 1u;
t_head &= RING_MSK; t_head &= RING_MSK;
t_lenght += 1u; t_lenght += 1u;
m_finished = true; m_finished = true;
} }
m_head = t_head; // vrať zpátky hodnoty m_head = t_head; // vrať zpátky hodnoty
@ -155,7 +141,9 @@ uint32_t SampleRing::BlockSend (const char * buf, const uint32_t len) {
} }
void SampleRing::pass() { void SampleRing::pass() {
if (!m_finished) return; if (!m_finished) {
return;
}
SendPrefix(); SendPrefix();
DATA_BLOCK data; DATA_BLOCK data;
while (read(data)) { while (read(data)) {

View file

@ -25,17 +25,16 @@ class SampleRing : public BaseLayer {
bool m_old_triger; bool m_old_triger;
bool m_trigered; bool m_trigered;
volatile bool m_finished; volatile bool m_finished;
TIME_BASE_MODE m_mode, o_mode; TIME_BASE_MODE m_mode;
[[gnu::aligned(4)]]char rcvd_buffer [RCVD_BUFLEN]; [[gnu::aligned(4)]]char rcvd_buffer [RCVD_BUFLEN];
unsigned rcvd_counter; unsigned rcvd_counter;
RCVD_STATUS rcvd_status; RCVD_STATUS rcvd_status;
public: public:
explicit SampleRing () noexcept : BaseLayer(), m_settings(), m_head(0), m_tail(0), m_lenght(0), explicit SampleRing () noexcept : BaseLayer(), m_settings(), m_head(0), m_tail(0), m_lenght(0),
m_old_triger(false), m_trigered(false), m_finished(false), m_old_triger(false), m_trigered(false), m_finished(false), m_mode (TIME_BASE_TRIGERED),
m_mode (TIME_BASE_TRIGERED), o_mode (TIME_BASE_TRIGERED),
rcvd_counter(0u), rcvd_status (RCVD_IDLE) {}; rcvd_counter(0u), rcvd_status (RCVD_IDLE) {};
uint32_t Up (const char * data, const uint32_t len) override; uint32_t Up (const char * data, const uint32_t len) override;
void write (DATA_BLOCK const * data); void write (DATA_BLOCK const * data);
void pass (); void pass ();
protected: protected:

View file

@ -97,9 +97,6 @@ void DataSource::parse_packet() {
bool sok = true; bool sok = true;
if (ChA.size() != (int) header.bits.pack_len) sok = false; if (ChA.size() != (int) header.bits.pack_len) sok = false;
if (ChB.size() != (int) header.bits.pack_len) sok = false; if (ChB.size() != (int) header.bits.pack_len) sok = false;
const size_t al = ChA.size(), bl = ChB.size();
if ((al != 1ul) and (al != 1024ul)) { qDebug ("A packet len = %zd", al); }
if ((bl != 1ul) and (bl != 1024ul)) { qDebug ("B packet len = %zd", bl); }
if (sok) { if (sok) {
if (trigerSettings.mode == TRIGER_MODE_SINGLE) { if (trigerSettings.mode == TRIGER_MODE_SINGLE) {
if (catching) { if (catching) {

View file

@ -16,15 +16,13 @@ static const double TimeBaseSteps [] = {
static const double ChannelsSteps [] = { static const double ChannelsSteps [] = {
1.0, 2.0, 5.0, 1.0, 2.0, 5.0,
}; };
static constexpr double REF_Y = 3.3; // maximum napětí převodníku static constexpr double REF_Y = 3.3; // maximum napětí převodníku
static constexpr double MAX_Y = double (1 << 12); // 12. bit rozlišení - 4096 steps static constexpr double MAX_Y = double (1 << 12); // 12. bit rozlišení - 4096 steps
static constexpr double STEP_Y = REF_Y / MAX_Y; // jeden krok ve Voltech static constexpr double STEP_Y = REF_Y / MAX_Y; // jeden krok ve Voltech
static constexpr unsigned T_SIZE = 1u << 10;
static constexpr unsigned T_MASK = T_SIZE - 1u;
DisplayWidget::DisplayWidget(QWidget * p) : QWidget(p), ACopy(), BCopy(), m_forward(), m_inverse(), background(), m_ts(nullptr), DisplayWidget::DisplayWidget(QWidget * p) : QWidget(p), ACopy(), BCopy(), m_forward(), m_inverse(), background(), m_ts(nullptr),
ChA (T_SIZE), ChB(T_SIZE), m_items (MOVE_VALUE), m_timeBase(6), m_ChBase(0), m_timeCount(0u) { ChA (1024), ChB(1024), m_items (MOVE_VALUE), m_timeBase(6), m_ChBase(0), m_timeCount(0u) {
x_lenght = T_SIZE; x_lenght = 1024;
m_time.a = 200.0; m_time.a = 200.0;
m_time.b = 300.0; m_time.b = 300.0;
m_volt.a = 1.0 / STEP_Y; m_volt.a = 1.0 / STEP_Y;
@ -145,12 +143,15 @@ void DisplayWidget::DispChannels(QVector<int> cha, QVector<int> chb) {
reloadData(); reloadData();
update(); update();
} }
static constexpr unsigned T_SIZE = 1u << 10;
static constexpr unsigned T_MASK = T_SIZE - 1u;
void DisplayWidget::reloadData () { void DisplayWidget::reloadData () {
const size_t Alen = ACopy.size(); const int Alen = ACopy.size();
const size_t Blen = BCopy.size(); const int Blen = BCopy.size();
const size_t Amin = Alen < T_SIZE ? Alen : T_SIZE; QVector<QPointF> va (Alen), vb (Blen);
const size_t Bmin = Blen < T_SIZE ? Blen : T_SIZE; if (Alen == 1 and Blen == 1) { // kontinuální mód
if ((Alen == 1u) and (Blen == 1u)) { // kontinuální mód if (ChA.size() != T_SIZE) { ChA = QPolygonF (T_SIZE); }
if (ChB.size() != T_SIZE) { ChB = QPolygonF (T_SIZE); }
const QPointF pta (m_timeCount, ACopy [0]), ptb (m_timeCount, BCopy [0]); const QPointF pta (m_timeCount, ACopy [0]), ptb (m_timeCount, BCopy [0]);
ChA[m_timeCount] = pta; ChA[m_timeCount] = pta;
ChB[m_timeCount] = ptb; ChB[m_timeCount] = ptb;
@ -159,14 +160,18 @@ void DisplayWidget::reloadData () {
m_timeCount &= T_MASK; m_timeCount &= T_MASK;
return; return;
} }
for (unsigned n=0u; n<Amin; n++) { for (int n=0u; n<Alen; n++) {
QPointF & p = ChA [n]; const double x = (double (n));
p.setY (ACopy [n]); const double y = ( ACopy [n]);
va [n] = QPointF (x,y);
} }
for (unsigned n=0u; n<Bmin; n++) { ChA = QPolygonF (va);
QPointF & p = ChB [n]; for (int n=0u; n<Blen; n++) {
p.setY (BCopy [n]); const double x = (double (n));
const double y = ( BCopy [n]);
vb [n] = QPointF (x,y);
} }
ChB = QPolygonF (vb);
const int l = Alen > Blen ? Alen : Blen; const int l = Alen > Blen ? Alen : Blen;
if (l != x_lenght) { if (l != x_lenght) {
x_lenght = l; x_lenght = l;

View file

@ -79,10 +79,8 @@ void MainWindow::TriggerValues (int n) {
void MainWindow::SendTrigerMode (int n) { void MainWindow::SendTrigerMode (int n) {
if (n == TRIGER_MODE_SINGLE) ui->buttonStart->setEnabled(true); if (n == TRIGER_MODE_SINGLE) ui->buttonStart->setEnabled(true);
else ui->buttonStart->setEnabled(false); else ui->buttonStart->setEnabled(false);
/*
if (n == TRIGER_MODE_AUTO) ui->comboTimeRange->setEnabled(true); // BUG - jinak dojde při přepínání k chybě if (n == TRIGER_MODE_AUTO) ui->comboTimeRange->setEnabled(true); // BUG - jinak dojde při přepínání k chybě
else ui->comboTimeRange->setEnabled(false); // fixed else ui->comboTimeRange->setEnabled(false); // TODO
*/
firmware.SendTrigerMode(n); firmware.SendTrigerMode(n);
} }
void MainWindow::SendTrigerEdge (int n) { void MainWindow::SendTrigerEdge (int n) {