Compare commits
No commits in common. "b2c0bc43feab4b816c06512d319065cd79fb571d" and "d19e62862b28f9a8f9c2e59f1b8407a205ea6685" have entirely different histories.
b2c0bc43fe
...
d19e62862b
5 changed files with 34 additions and 47 deletions
|
@ -77,20 +77,6 @@ void SampleRing::CommandPass(const unsigned int cmd) {
|
|||
|
||||
void SampleRing::write(DATA_BLOCK const * data) {
|
||||
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_lenght = m_lenght; // následujícího cyklu
|
||||
if (m_mode == TIME_BASE_TRIGERED) {
|
||||
|
@ -108,7 +94,7 @@ void SampleRing::write(DATA_BLOCK const * data) {
|
|||
}
|
||||
}
|
||||
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
|
||||
if ((m_settings.mode != TRIGER_MODE_AUTO) and !m_trigered) continue;
|
||||
t_lenght = RING_LEN;
|
||||
|
@ -155,7 +141,9 @@ uint32_t SampleRing::BlockSend (const char * buf, const uint32_t len) {
|
|||
}
|
||||
|
||||
void SampleRing::pass() {
|
||||
if (!m_finished) return;
|
||||
if (!m_finished) {
|
||||
return;
|
||||
}
|
||||
SendPrefix();
|
||||
DATA_BLOCK data;
|
||||
while (read(data)) {
|
||||
|
|
|
@ -25,15 +25,14 @@ class SampleRing : public BaseLayer {
|
|||
bool m_old_triger;
|
||||
bool m_trigered;
|
||||
volatile bool m_finished;
|
||||
TIME_BASE_MODE m_mode, o_mode;
|
||||
TIME_BASE_MODE m_mode;
|
||||
|
||||
[[gnu::aligned(4)]]char rcvd_buffer [RCVD_BUFLEN];
|
||||
unsigned rcvd_counter;
|
||||
RCVD_STATUS rcvd_status;
|
||||
public:
|
||||
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), o_mode (TIME_BASE_TRIGERED),
|
||||
m_old_triger(false), m_trigered(false), m_finished(false), m_mode (TIME_BASE_TRIGERED),
|
||||
rcvd_counter(0u), rcvd_status (RCVD_IDLE) {};
|
||||
uint32_t Up (const char * data, const uint32_t len) override;
|
||||
void write (DATA_BLOCK const * data);
|
||||
|
|
|
@ -97,9 +97,6 @@ void DataSource::parse_packet() {
|
|||
bool sok = true;
|
||||
if (ChA.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 (trigerSettings.mode == TRIGER_MODE_SINGLE) {
|
||||
if (catching) {
|
||||
|
|
|
@ -19,12 +19,10 @@ static const double ChannelsSteps [] = {
|
|||
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 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),
|
||||
ChA (T_SIZE), ChB(T_SIZE), m_items (MOVE_VALUE), m_timeBase(6), m_ChBase(0), m_timeCount(0u) {
|
||||
x_lenght = T_SIZE;
|
||||
ChA (1024), ChB(1024), m_items (MOVE_VALUE), m_timeBase(6), m_ChBase(0), m_timeCount(0u) {
|
||||
x_lenght = 1024;
|
||||
m_time.a = 200.0;
|
||||
m_time.b = 300.0;
|
||||
m_volt.a = 1.0 / STEP_Y;
|
||||
|
@ -145,12 +143,15 @@ void DisplayWidget::DispChannels(QVector<int> cha, QVector<int> chb) {
|
|||
reloadData();
|
||||
update();
|
||||
}
|
||||
static constexpr unsigned T_SIZE = 1u << 10;
|
||||
static constexpr unsigned T_MASK = T_SIZE - 1u;
|
||||
void DisplayWidget::reloadData () {
|
||||
const size_t Alen = ACopy.size();
|
||||
const size_t Blen = BCopy.size();
|
||||
const size_t Amin = Alen < T_SIZE ? Alen : T_SIZE;
|
||||
const size_t Bmin = Blen < T_SIZE ? Blen : T_SIZE;
|
||||
if ((Alen == 1u) and (Blen == 1u)) { // kontinuální mód
|
||||
const int Alen = ACopy.size();
|
||||
const int Blen = BCopy.size();
|
||||
QVector<QPointF> va (Alen), vb (Blen);
|
||||
if (Alen == 1 and Blen == 1) { // 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]);
|
||||
ChA[m_timeCount] = pta;
|
||||
ChB[m_timeCount] = ptb;
|
||||
|
@ -159,14 +160,18 @@ void DisplayWidget::reloadData () {
|
|||
m_timeCount &= T_MASK;
|
||||
return;
|
||||
}
|
||||
for (unsigned n=0u; n<Amin; n++) {
|
||||
QPointF & p = ChA [n];
|
||||
p.setY (ACopy [n]);
|
||||
for (int n=0u; n<Alen; n++) {
|
||||
const double x = (double (n));
|
||||
const double y = ( ACopy [n]);
|
||||
va [n] = QPointF (x,y);
|
||||
}
|
||||
for (unsigned n=0u; n<Bmin; n++) {
|
||||
QPointF & p = ChB [n];
|
||||
p.setY (BCopy [n]);
|
||||
ChA = QPolygonF (va);
|
||||
for (int n=0u; n<Blen; 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;
|
||||
if (l != x_lenght) {
|
||||
x_lenght = l;
|
||||
|
|
|
@ -79,10 +79,8 @@ void MainWindow::TriggerValues (int n) {
|
|||
void MainWindow::SendTrigerMode (int n) {
|
||||
if (n == TRIGER_MODE_SINGLE) ui->buttonStart->setEnabled(true);
|
||||
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ě
|
||||
else ui->comboTimeRange->setEnabled(false); // fixed
|
||||
*/
|
||||
else ui->comboTimeRange->setEnabled(false); // TODO
|
||||
firmware.SendTrigerMode(n);
|
||||
}
|
||||
void MainWindow::SendTrigerEdge (int n) {
|
||||
|
|
Loading…
Reference in a new issue