Skip to content

Commit

Permalink
Merge branch 'vedderb:master' into ci
Browse files Browse the repository at this point in the history
  • Loading branch information
darwinbeing authored Feb 11, 2024
2 parents ec4674f + e6c6632 commit cde5ad3
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 16 deletions.
13 changes: 7 additions & 6 deletions commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,15 +399,15 @@ void Commands::processPacket(QByteArray data)
break;

case COMM_SET_MCCONF:
emit ackReceived("MCCONF Write OK");
emit ackReceived("Motor config write OK");
break;

case COMM_SET_APPCONF:
emit ackReceived("APPCONF Write OK");
emit ackReceived("App config write OK");
break;

case COMM_SET_APPCONF_NO_STORE:
emit ackReceived("APPCONF_NO_STORE Write OK");
emit ackReceived("App config set OK");
break;

case COMM_CUSTOM_APP_DATA:
Expand Down Expand Up @@ -731,9 +731,10 @@ void Commands::processPacket(QByteArray data)
emit bmsValuesRx(val);
} break;

case COMM_SET_CUSTOM_CONFIG:
emit ackReceived("COMM_SET_CUSTOM_CONFIG Write OK");
break;
case COMM_SET_CUSTOM_CONFIG: {
int confId = vb.vbPopFrontUint8();
emit customConfigAckReceived(confId);
} break;

case COMM_GET_CUSTOM_CONFIG:
case COMM_GET_CUSTOM_CONFIG_DEFAULT: {
Expand Down
1 change: 1 addition & 0 deletions commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class Commands : public QObject
void bmsValuesRx(BMS_VALUES val);
void customConfigChunkRx(int confInd, int lenConf, int ofsConf, QByteArray data);
void customConfigRx(int confInd, QByteArray data);
void customConfigAckReceived(int confId);
void pswStatusRx(PSW_STATUS stat);
void qmluiHwRx(int lenQml, int ofsQml, QByteArray data);
void qmluiAppRx(int lenQml, int ofsQml, QByteArray data);
Expand Down
19 changes: 19 additions & 0 deletions pages/pagescripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,25 @@ void PageScripting::on_stopButton_clicked()
mQmlUi.stopCustomGui();
}

void PageScripting::on_reloadAndRunButton_clicked()
{
QFile file(ui->mainEdit->fileNow());

if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::critical(this, "Open QML File",
"Could not open example for reading");
return;
}

ui->mainEdit->codeEditor()->setPlainText(file.readAll());

file.close();

ui->qmlWidget->setSource(QUrl(QLatin1String("qrc:/res/qml/DynamicLoader.qml")));
ui->qmlWidget->engine()->clearComponentCache();
emit reloadQml(qmlToRun());
}

void PageScripting::on_runWindowButton_clicked()
{
ui->runWindowButton->setEnabled(false);
Expand Down
1 change: 1 addition & 0 deletions pages/pagescripting.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public slots:
private slots:
void on_runButton_clicked();
void on_stopButton_clicked();
void on_reloadAndRunButton_clicked();
void on_runWindowButton_clicked();
void on_fullscreenButton_clicked();
void on_openRecentButton_clicked();
Expand Down
32 changes: 29 additions & 3 deletions pages/pagescripting.ui
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>12</number>
<number>2</number>
</property>
<item>
<widget class="QPushButton" name="runButton">
<property name="toolTip">
<string>Run in panel.</string>
</property>
<property name="text">
<string>Run</string>
</property>
Expand All @@ -55,9 +58,29 @@
</item>
<item>
<widget class="QPushButton" name="runWindowButton">
<property name="text">
<property name="toolTip">
<string>Run in Window</string>
</property>
<property name="text">
<string>Window</string>
</property>
<property name="icon">
<iconset resource="../res.qrc">
<normaloff>:/res/icons/Circled Play-96.png</normaloff>:/res/icons/Circled Play-96.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="reloadAndRunButton">
<property name="toolTip">
<string>Reload file from filesystem and run in panel. Warning: This will replace the editor content if it is unsaved.</string>
</property>
<property name="text">
<string>Reload &amp;&amp; Run</string>
</property>
<property name="icon">
<iconset resource="../res.qrc">
<normaloff>:/res/icons/Circled Play-96.png</normaloff>:/res/icons/Circled Play-96.png</iconset>
Expand All @@ -69,8 +92,11 @@
</item>
<item>
<widget class="QPushButton" name="fullscreenButton">
<property name="toolTip">
<string>Toggle fullscreen in running window.</string>
</property>
<property name="text">
<string>Toggle Fullscreen</string>
<string>Fullscreen</string>
</property>
<property name="icon">
<iconset resource="../res.qrc">
Expand Down
25 changes: 18 additions & 7 deletions vescinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,17 @@ VescInterface::VescInterface(QObject *parent) : QObject(parent)
connect(mCommands, SIGNAL(customConfigRx(int,QByteArray)),
this, SLOT(customConfigRx(int,QByteArray)));

connect(mCommands, &Commands::customConfigAckReceived, [this](int confId) {
ConfigParams *custConf = customConfig(confId);
QString name;
if (custConf) {
name = custConf->getLongName("hw_name");
} else {
name = tr("Custom config %1").arg(confId);
}
emit ackReceived(tr("%1 write OK").arg(name));
});

#if VT_IS_TEST_VERSION
QTimer::singleShot(1000, [this]() {
emitMessageDialog("VESC Tool Test Version",
Expand Down Expand Up @@ -3823,7 +3834,7 @@ void VescInterface::fwVersionReceived(FW_RX_PARAMS params)
break;
}

emitStatusMessage(QString("Got custom config %1").arg(i), true);
emitStatusMessage(QString("Got %1").arg(mCustomConfigs.last()->getLongName("hw_name")), true);
} else {
emitMessageDialog("Get Custom Config",
"Could not read custom config from hardware",
Expand Down Expand Up @@ -3951,12 +3962,12 @@ void VescInterface::fwVersionReceived(FW_RX_PARAMS params)

void VescInterface::appconfUpdated()
{
emit statusMessage(tr("App configuration updated"), true);
emit statusMessage(tr("App config updated"), true);
}

void VescInterface::mcconfUpdated()
{
emit statusMessage(tr("MC configuration updated"), true);
emit statusMessage(tr("Motor config updated"), true);

if (isPortConnected() && fwRx()) {
QPair<int, int> fw_connected = qMakePair(mLastFwParams.major, mLastFwParams.minor);
Expand Down Expand Up @@ -3988,7 +3999,7 @@ void VescInterface::customConfigRx(int confId, QByteArray data)
auto vb = VByteArray(data);
if (params->deSerialize(vb)) {
params->updateDone();
emitStatusMessage(tr("Custom config %1 updated").arg(confId), true);
emitStatusMessage(tr("%1 updated").arg(params->getLongName("hw_name")), true);
} else {
emitMessageDialog(tr("Custom Configuration"),
tr("Could not deserialize custom config %1").arg(confId),
Expand Down Expand Up @@ -4305,17 +4316,17 @@ bool VescInterface::confRestoreBackup(bool can)

if (!txMc) {
emitMessageDialog("Restore Configuration",
"No response when writing MC configuration to " + uuid + ".", false, false);
"No response when writing Motor config to " + uuid + ".", false, false);
}

if (!txApp) {
emitMessageDialog("Restore Configuration",
"No response when writing app configuration to " + uuid + ".", false, false);
"No response when writing App config to " + uuid + ".", false, false);
}

if (!txCustom) {
emitMessageDialog("Restore Configuration",
"No response when writing" + pCustom->getParam("hw_name")->longName + "configuration to " + uuid + ".", false, false);
"No response when writing " + pCustom->getLongName("hw_name") + " configuration to " + uuid + ".", false, false);
}

return txMc && txApp;
Expand Down

0 comments on commit cde5ad3

Please sign in to comment.