Compare commits

..

No commits in common. "0b9c978a6d510857aba5073f3ae785856a8490d7" and "1095da2beaa8196c4b82fdce9b2275cdd5344937" have entirely different histories.

13 changed files with 6 additions and 169 deletions

View file

@ -53,10 +53,6 @@ function initWebSocket() {
}; };
websocket.onmessage = function (evt) { websocket.onmessage = function (evt) {
const obj = JSON.parse (evt.data); const obj = JSON.parse (evt.data);
if (Object.hasOwn (obj, 'channel')) {
RefreshSettings (obj);
return;
}
DrawTrig (); DrawTrig ();
DrawPolyLine (0, obj.a, '#FF0000'); DrawPolyLine (0, obj.a, '#FF0000');
DrawPolyLine (1, obj.b, '#00FF00'); DrawPolyLine (1, obj.b, '#00FF00');
@ -69,15 +65,6 @@ function initWebSocket() {
} }
} }
/************************************************************************/ /************************************************************************/
function RefreshSettings (obj) {
console.log (obj);
document.getElementById('trigger_src' ).value = obj.channel;
document.getElementById('trigger_mode').value = obj.mode;
document.getElementById('trigger_edge').value = obj.rising;
document.getElementById('time_base' ).value = obj.tim;
gTC.x = obj.offset; gTC.y = obj.value;
DrawTrig ();
};
function ReloadMatrix (sz) { function ReloadMatrix (sz) {
const xz = sz.x / MAX_X; const xz = sz.x / MAX_X;
const yz = sz.y / MAX_Y; const yz = sz.y / MAX_Y;

View file

@ -6,10 +6,6 @@ uint32_t SampleRing::Up (const char * data, const uint32_t len) {
for (unsigned n=0; n<len; n++) { for (unsigned n=0; n<len; n++) {
const char c = data [n]; const char c = data [n];
switch (c) { switch (c) {
case '?':
rcvd_counter = 0;
SendSettings();
break;
case '$': case '$':
rcvd_counter = 0; rcvd_counter = 0;
rcvd_status = RCVD_DATA; rcvd_status = RCVD_DATA;
@ -48,27 +44,6 @@ void SampleRing::CmdReceived() {
} }
CommandPass (result); CommandPass (result);
} }
/* in adcscope.cpp
void SampleRing::ReloadTimer(const unsigned int n) {
}
*/
void SampleRing::SendSettings() {
const unsigned max = 64;
char buf [max];
unsigned idx = 0;
AllSettings as (m_settings, m_time_base_order);
buf [idx++] = '!';
for (unsigned n=0u; n<sizeof(as); n++) {
const uint8_t c = as.common[n];
buf [idx++] = hexstr [c >> 4];
buf [idx++] = hexstr [c & 0xF];
}
buf [idx++] = '\r';
buf [idx++] = '\n';
buf [idx] = '\0';
BlockSend (buf, idx);
}
void SampleRing::CommandPass(const unsigned int cmd) { void SampleRing::CommandPass(const unsigned int cmd) {
RcvdHeader header; RcvdHeader header;
header.common = cmd & 0xFFFF; header.common = cmd & 0xFFFF;
@ -78,8 +53,7 @@ void SampleRing::CommandPass(const unsigned int cmd) {
case DEST_CHB: case DEST_CHB:
break; break;
case DEST_BASE: case DEST_BASE:
m_time_base_order = header.bits.cmd_value; ReloadTimer (header.bits.cmd_value);
ReloadTimer (m_time_base_order);
break; break;
case DEST_TRIG: { case DEST_TRIG: {
const TRIGGER_CMD command = static_cast<TRIGGER_CMD> (header.bits.cmd_type); const TRIGGER_CMD command = static_cast<TRIGGER_CMD> (header.bits.cmd_type);

View file

@ -26,7 +26,6 @@ class SampleRing : public BaseLayer {
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, o_mode;
unsigned m_time_base_order;
[[gnu::aligned(4)]]char rcvd_buffer [RCVD_BUFLEN]; [[gnu::aligned(4)]]char rcvd_buffer [RCVD_BUFLEN];
unsigned rcvd_counter; unsigned rcvd_counter;
@ -34,7 +33,7 @@ class SampleRing : public BaseLayer {
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), o_mode (TIME_BASE_TRIGERED), m_time_base_order(6u), 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);
@ -47,7 +46,6 @@ class SampleRing : public BaseLayer {
void CmdReceived (); void CmdReceived ();
void CommandPass (const unsigned cmd); void CommandPass (const unsigned cmd);
void ReloadTimer (const unsigned n); void ReloadTimer (const unsigned n);
void SendSettings();
}; };
#endif // SAMPLERING_H #endif // SAMPLERING_H

View file

@ -27,22 +27,6 @@ struct TrigerSettings {
explicit TrigerSettings () noexcept : value(0x80u), offset(100u), mode(TRIGER_MODE_AUTO), channel(V1_VSENSE), rising(false) {} explicit TrigerSettings () noexcept : value(0x80u), offset(100u), mode(TRIGER_MODE_AUTO), channel(V1_VSENSE), rising(false) {}
}; };
static_assert (sizeof(TrigerSettings) == 10, "TrigerSettings error"); static_assert (sizeof(TrigerSettings) == 10, "TrigerSettings error");
union AllSettings {
struct _x {
TrigerSettings trg;
uint16_t tim;
} part;
uint8_t common [sizeof (_x)];
explicit AllSettings (const TrigerSettings & ts, const unsigned n) noexcept {
part.trg.value = ts.value;
part.trg.offset = ts.offset;
part.trg.mode = ts.mode;
part.trg.channel = ts.channel;
part.trg.rising = ts.rising;
part.tim = n;
}
};
static_assert (sizeof(AllSettings) == 12, "TrigerSettings error");
union SendHeader { union SendHeader {
struct s_bits { struct s_bits {
uint16_t pack_len : 15; uint16_t pack_len : 15;

View file

@ -72,7 +72,7 @@ int main (int /*argc*/, const char * /*argv*/[]) {
epoll_ctl (myEpoll, EPOLL_CTL_ADD, server.fd(), &wakeSeasocks); epoll_ctl (myEpoll, EPOLL_CTL_ADD, server.fd(), &wakeSeasocks);
while (true) { while (true) {
constexpr auto maxEvents = 10; constexpr auto maxEvents = 2;
epoll_event events[maxEvents]; epoll_event events[maxEvents];
auto res = epoll_wait (myEpoll, events, maxEvents, -1); auto res = epoll_wait (myEpoll, events, maxEvents, -1);
if (res < 0) { if (res < 0) {

View file

@ -60,10 +60,8 @@ bool WsClient::start() {
printf ("Port %s opened (%d)\r\n", name, fd); printf ("Port %s opened (%d)\r\n", name, fd);
usleep (1000); usleep (1000);
const int r = ::write (fd, "?\r\n", 3);
(void) r;
running = true; running = true;
return running; return true;
} }
void WsClient::stop() { void WsClient::stop() {
cout << "Client Stop\n"; cout << "Client Stop\n";
@ -100,10 +98,6 @@ void WsClient::parse_input(const char * data, const long len) {
for (long i=0; i<len; i++) { for (long i=0; i<len; i++) {
const char c = data [i]; const char c = data [i];
switch (c) { switch (c) {
case '!':
state = StateReply;
packet_cnt = 0;
break;
case '$': case '$':
state = StateHeader; state = StateHeader;
packet_cnt = 0; packet_cnt = 0;
@ -141,43 +135,7 @@ void WsClient::parse_header() {
} }
*/ */
} }
static uint8_t from_hex (const char * ptr) {
uint8_t result = 0u;
for (unsigned n=0; n<2u; n++) {
result *= 0x10;
const char c = ptr [n];
const uint8_t v = c > '9' ? c - 'A' + 10 : c - '0';
result += v;
}
return result;
}
void WsClient::parse_reply(const char * data, const int len) {
printf("(%d):%s\n", len, data);
TrigerSettings ts;
AllSettings as (ts, 0);
const int bl = len >> 1;
int k = 0;
for (int n=0; n<bl; n++) {
as.common [n] = from_hex (data + k);
k += 2;
}
json msg;
msg["channel"] = as.part.trg.channel;
msg["mode"] = as.part.trg.mode;
msg["rising"] = as.part.trg.rising ? 1 : 0;
msg["offset"] = as.part.trg.offset;
msg["value"] = as.part.trg.value;
msg["tim"] = as.part.tim;
string s = to_string (msg);
cout << s << endl;
ws->send(s);
}
void WsClient::parse_packet() { void WsClient::parse_packet() {
if (state == StateReply) {
packet_buf[packet_cnt] = '\0';
parse_reply(packet_buf, packet_cnt);
return;
}
vector<int> ChA, ChB; vector<int> ChA, ChB;
if (state != StateData) return; if (state != StateData) return;
int k=0; int k=0;
@ -305,7 +263,6 @@ void WsClient::send_trig_mode() {
write (buffer, r); write (buffer, r);
} }
int WsClient::write(const char * data, const int len) { int WsClient::write(const char * data, const int len) {
if (!running) return 0;
string out (data, len); string out (data, len);
cout << out; cout << out;
int r = ::write (fd, data, len); int r = ::write (fd, data, len);

View file

@ -13,7 +13,6 @@ enum ParserState {
StateIdle = 0, StateIdle = 0,
StateHeader, StateHeader,
StateData, StateData,
StateReply,
}; };
class WsClient { class WsClient {
@ -58,7 +57,6 @@ class WsClient {
void parse_input (const char * data, const long len); void parse_input (const char * data, const long len);
void parse_header (); void parse_header ();
void parse_packet (); void parse_packet ();
void parse_reply (const char * data, const int len);
}; };
#endif // WSCLIENT_H #endif // WSCLIENT_H

View file

@ -14,7 +14,6 @@ DataSource::DataSource(QObject * p) : QObject (p),
connect (&usart, SIGNAL (readyRead()), this, SLOT (read_data())); connect (&usart, SIGNAL (readyRead()), this, SLOT (read_data()));
usart.open (QIODevice::ReadWrite); usart.open (QIODevice::ReadWrite);
usart.write("?\r\n", 3);
} }
DataSource::~DataSource() { DataSource::~DataSource() {
usart.close(); usart.close();
@ -35,10 +34,6 @@ void DataSource::parse_input(const char * data, const long len) {
for (long i=0; i<len; i++) { for (long i=0; i<len; i++) {
const char c = data [i]; const char c = data [i];
switch (c) { switch (c) {
case '!':
state = StateReply;
packet_cnt = 0;
break;
case '$': case '$':
state = StateHeader; state = StateHeader;
packet_cnt = 0; packet_cnt = 0;
@ -78,41 +73,7 @@ void DataSource::parse_header() {
emit PaketTriggered (); emit PaketTriggered ();
} }
} }
static uint8_t from_hex (const char * ptr) {
uint8_t result = 0u;
for (unsigned n=0; n<2u; n++) {
result *= 0x10;
const char c = ptr [n];
const uint8_t v = c > '9' ? c - 'A' + 10 : c - '0';
result += v;
}
return result;
}
void DataSource::parse_reply(const char * data, const int len) {
printf("(%d):%s\n", len, data);
TrigerSettings ts;
AllSettings as (ts, 0);
const int bl = len >> 1;
int k = 0;
for (int n=0; n<bl; n++) {
as.common [n] = from_hex (data + k);
k += 2;
}
trigerSettings.channel = as.part.trg.channel;
trigerSettings.mode = as.part.trg.mode;
trigerSettings.rising = as.part.trg.rising;
trigerSettings.offset = as.part.trg.offset;
trigerSettings.value = as.part.trg.value;
//trigerSettings. = as.part.trg.channel;
emit SettingReceived (as);
}
void DataSource::parse_packet() { void DataSource::parse_packet() {
if (state == StateReply) {
packet_buf[packet_cnt] = '\0';
parse_reply(packet_buf, packet_cnt);
return;
}
QVector<int> ChA, ChB; QVector<int> ChA, ChB;
if (state != StateData) return; if (state != StateData) return;
bool ok = false; bool ok = false;

View file

@ -11,7 +11,6 @@ enum ParserState {
StateIdle = 0, StateIdle = 0,
StateHeader, StateHeader,
StateData, StateData,
StateReply,
}; };
/** /**
*/ */
@ -42,12 +41,10 @@ class DataSource : public QObject {
signals: signals:
void Channels_received(QVector<int>, QVector<int>); void Channels_received(QVector<int>, QVector<int>);
void PaketTriggered (); void PaketTriggered ();
void SettingReceived (AllSettings);
protected: protected:
void parse_input (const char * data, const long len); void parse_input (const char * data, const long len);
void parse_packet (); void parse_packet ();
void parse_header (); void parse_header ();
void parse_reply (const char * data, const int len);
protected: protected:
void send_trig_mode (); void send_trig_mode ();
}; };

View file

@ -182,10 +182,7 @@ void DisplayWidget::reloadMatrix(const QSize & sz) {
m_forward = tm; m_forward = tm;
m_inverse = m_forward.inverted(); m_inverse = m_forward.inverted();
} }
void DisplayWidget::Refresh() {
drawBackground();
update();
}
void DisplayWidget::TimeBaseRange(int n) { void DisplayWidget::TimeBaseRange(int n) {
m_timeBase = n; m_timeBase = n;
reloadMatrix (size()); reloadMatrix (size());

View file

@ -39,7 +39,6 @@ class DisplayWidget : public QWidget {
void MarkerChanged (bool); void MarkerChanged (bool);
void saveSettings (QSettings & setting); void saveSettings (QSettings & setting);
void restSettings (QSettings & setting); void restSettings (QSettings & setting);
void Refresh ();
void resizeEvent (QResizeEvent * event) override; void resizeEvent (QResizeEvent * event) override;
void paintEvent (QPaintEvent * event) override; void paintEvent (QPaintEvent * event) override;
@ -47,7 +46,7 @@ class DisplayWidget : public QWidget {
void mousePressEvent(QMouseEvent * event) override; void mousePressEvent(QMouseEvent * event) override;
public slots: public slots:
void DispChannels (QVector<int>, QVector<int>); void DispChannels (QVector<int>, QVector<int>);
signals: signals:
void SettingsChanged (int n); void SettingsChanged (int n);
protected: protected:

View file

@ -44,7 +44,6 @@ MainWindow::MainWindow (QWidget * parent)
connect (&firmware, SIGNAL (Channels_received(QVector<int>, QVector<int>)), connect (&firmware, SIGNAL (Channels_received(QVector<int>, QVector<int>)),
ui->Display, SLOT (DispChannels (QVector<int>, QVector<int>))); ui->Display, SLOT (DispChannels (QVector<int>, QVector<int>)));
connect (&firmware, SIGNAL (PaketTriggered()), this, SLOT(PaketTriggered())); connect (&firmware, SIGNAL (PaketTriggered()), this, SLOT(PaketTriggered()));
connect (&firmware, SIGNAL (SettingReceived(AllSettings)), this, SLOT(SetSelections(AllSettings)));
connect (ui->Display, SIGNAL(SettingsChanged(int)), &firmware, SLOT(SettingChanged(int))); connect (ui->Display, SIGNAL(SettingsChanged(int)), &firmware, SLOT(SettingChanged(int)));
connect (ui->buttonStart,SIGNAL(pressed()), this, SLOT(Started())); connect (ui->buttonStart,SIGNAL(pressed()), this, SLOT(Started()));
@ -63,19 +62,6 @@ MainWindow::MainWindow (QWidget * parent)
ui->comboTimeRange->setCurrentIndex(6); ui->comboTimeRange->setCurrentIndex(6);
ui->buttonStart->setEnabled(false); ui->buttonStart->setEnabled(false);
} }
void MainWindow::SetSelections(AllSettings as) {
printf("channel : %d\n", as.part.trg.channel);
printf("mode : %d\n", as.part.trg.mode);
printf("rising : %d\n", as.part.trg.rising);
printf("offset : %d\n", as.part.trg.offset);
printf("value : %d\n", as.part.trg.value);
printf("tim bas : %d\n", as.part.tim);
ui->comboChannel ->setCurrentIndex(as.part.trg.channel);
ui->comboMode ->setCurrentIndex(as.part.trg.mode);
ui->comboRissing ->setCurrentIndex(as.part.trg.rising ? 1 : 0);
ui->comboTimeRange->setCurrentIndex(as.part.tim);
ui->Display->Refresh();
}
MainWindow::~MainWindow () { MainWindow::~MainWindow () {
delete ui; delete ui;

View file

@ -25,7 +25,6 @@ public slots:
void RestSettings (bool); void RestSettings (bool);
void PaketTriggered (); void PaketTriggered ();
void Started (); void Started ();
void SetSelections (AllSettings);
private: private:
Ui_MainWindow * ui; Ui_MainWindow * ui;
DataSource firmware; DataSource firmware;