Compare commits
2 commits
d19e62862b
...
b2c0bc43fe
Author | SHA1 | Date | |
---|---|---|---|
|
b2c0bc43fe | ||
|
776ffd5bd2 |
5 changed files with 47 additions and 34 deletions
|
@ -77,6 +77,20 @@ 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) {
|
||||||
|
@ -94,7 +108,7 @@ void SampleRing::write(DATA_BLOCK const * data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_old_triger = !compare;
|
m_old_triger = !compare;
|
||||||
if (t_lenght >= RING_LEN) {
|
if (t_lenght >= RING_LEN) { // je fuk o kolik je to delší
|
||||||
// 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;
|
||||||
|
@ -106,9 +120,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
|
||||||
|
@ -141,9 +155,7 @@ uint32_t SampleRing::BlockSend (const char * buf, const uint32_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SampleRing::pass() {
|
void SampleRing::pass() {
|
||||||
if (!m_finished) {
|
if (!m_finished) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
SendPrefix();
|
SendPrefix();
|
||||||
DATA_BLOCK data;
|
DATA_BLOCK data;
|
||||||
while (read(data)) {
|
while (read(data)) {
|
||||||
|
|
|
@ -25,16 +25,17 @@ 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;
|
TIME_BASE_MODE m_mode, o_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_mode (TIME_BASE_TRIGERED),
|
m_old_triger(false), m_trigered(false), m_finished(false),
|
||||||
|
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:
|
||||||
|
|
|
@ -97,6 +97,9 @@ 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) {
|
||||||
|
|
|
@ -16,13 +16,15 @@ 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 (1024), ChB(1024), m_items (MOVE_VALUE), m_timeBase(6), m_ChBase(0), m_timeCount(0u) {
|
ChA (T_SIZE), ChB(T_SIZE), m_items (MOVE_VALUE), m_timeBase(6), m_ChBase(0), m_timeCount(0u) {
|
||||||
x_lenght = 1024;
|
x_lenght = T_SIZE;
|
||||||
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;
|
||||||
|
@ -143,15 +145,12 @@ 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 int Alen = ACopy.size();
|
const size_t Alen = ACopy.size();
|
||||||
const int Blen = BCopy.size();
|
const size_t Blen = BCopy.size();
|
||||||
QVector<QPointF> va (Alen), vb (Blen);
|
const size_t Amin = Alen < T_SIZE ? Alen : T_SIZE;
|
||||||
if (Alen == 1 and Blen == 1) { // kontinuální mód
|
const size_t Bmin = Blen < T_SIZE ? Blen : T_SIZE;
|
||||||
if (ChA.size() != T_SIZE) { ChA = QPolygonF (T_SIZE); }
|
if ((Alen == 1u) and (Blen == 1u)) { // kontinuální mód
|
||||||
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;
|
||||||
|
@ -160,18 +159,14 @@ void DisplayWidget::reloadData () {
|
||||||
m_timeCount &= T_MASK;
|
m_timeCount &= T_MASK;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int n=0u; n<Alen; n++) {
|
for (unsigned n=0u; n<Amin; n++) {
|
||||||
const double x = (double (n));
|
QPointF & p = ChA [n];
|
||||||
const double y = ( ACopy [n]);
|
p.setY (ACopy [n]);
|
||||||
va [n] = QPointF (x,y);
|
|
||||||
}
|
}
|
||||||
ChA = QPolygonF (va);
|
for (unsigned n=0u; n<Bmin; n++) {
|
||||||
for (int n=0u; n<Blen; n++) {
|
QPointF & p = ChB [n];
|
||||||
const double x = (double (n));
|
p.setY (BCopy [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;
|
||||||
|
|
|
@ -79,8 +79,10 @@ 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); // TODO
|
else ui->comboTimeRange->setEnabled(false); // fixed
|
||||||
|
*/
|
||||||
firmware.SendTrigerMode(n);
|
firmware.SendTrigerMode(n);
|
||||||
}
|
}
|
||||||
void MainWindow::SendTrigerEdge (int n) {
|
void MainWindow::SendTrigerEdge (int n) {
|
||||||
|
|
Loading…
Reference in a new issue