Skip to content

Commit

Permalink
Merge branch 'trikset:master' into pull/1667
Browse files Browse the repository at this point in the history
  • Loading branch information
iakov authored Feb 1, 2025
2 parents 5da5115 + eeafe92 commit 5787348
Show file tree
Hide file tree
Showing 16 changed files with 236 additions and 93 deletions.
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
url = https://bitbucket.org/codeimproved/qslog.git
[submodule "installer/nxt-tools"]
path = installer/nxt-tools
url = https://github.com/trikset/nxt-tools
url = https://github.com/trikset/nxt-tools.git
branch = main
[submodule "trik-checkapp"]
path = thirdparty/checkapp/checkapp
url = https://github.com/trikset/trik-checkapp
Expand Down
2 changes: 1 addition & 1 deletion installer/nxt-tools
Submodule nxt-tools updated 4377 files
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ cd "$(dirname "$0")"
source "$INSTALLER_ROOT"/utils/common_utils.sh
mkdir "$PWD"/../data/bin
cd "$PWD"/../data/bin
rsync -a "$INSTALLER_ROOT"/nxt-tools/linux/nxt-tools ./
rsync -a "$INSTALLER_ROOT"/nxt-tools ./
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ source "$INSTALLER_ROOT"/utils/common_utils.sh

cd "$PWD"/../data

rsync -aR "$INSTALLER_ROOT"/nxt-tools/win/./nxt-tools .
rsync -aR "$INSTALLER_ROOT"/./nxt-tools .
dos2unix nxt-tools/compile.sh
rm -rf bin
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ rsync -a "$BIN_DIR"/vcruntime*.dll
rsync -a "$BIN_DIR"/{system.js,TRIK.py,2D-model.exe,checkapp.exe} "$PWD/../data/"
rsync -a "$QT_LIB"/Qt5SerialPort.dll "$PWD"/../data

winscp_ver=5.17.10
putty_ver=0.75
winscp_ver=6.3.6
putty_ver=0.82

cache_dir="$(cygpath "$APPDATA")"/"$PRODUCT"/installer_cache
mkdir -p "$cache_dir"
cd "$cache_dir"
Expand Down
28 changes: 21 additions & 7 deletions plugins/robots/generators/nxt/nxtOsekCGenerator/nxtFlashTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,25 @@ bool NxtFlashTool::uploadProgram(const QFileInfo &fileInfo)
mCompileState = idle;
mSource = fileInfo;

#ifdef Q_OS_WIN
mCompileProcess.setWorkingDirectory(path());
mCompileProcess.start("cmd", { "/c", path("compile.bat")
+ " " + fileInfo.completeBaseName()
+ " " + fileInfo.absolutePath() });
#else
mCompileProcess.start("sh", { path("compile.sh") , fileInfo.absolutePath()});
#endif

auto osType = PlatformInfo::osType();
if (osType == "windows") {
auto line = path("compile.bat")
+ " " + fileInfo.completeBaseName()
+ " " + fileInfo.absolutePath()
+ " " + path("gnuarm");
mCompileProcess.start("cmd", { "/c", line});
}
else if (osType == "linux") {
auto line = "./compile.sh . " + fileInfo.absolutePath() +
" GNUARM_ROOT="+SettingsManager::value("pathToArmNoneEabi").toString();
mCompileProcess.start("/bin/bash", {"-c", line});
}
else {
QLOG_INFO() << "Platform: " << osType << "not supported for upload program";
return false;
}
information(tr("Uploading program started. Please don't disconnect robot during the process"));
return true;
}
Expand Down Expand Up @@ -291,6 +301,10 @@ void NxtFlashTool::readNxtCompileData()
"If you sure in their validness contact developers"));
} else {
error(tr("Could not upload program. Make sure the robot is connected and ON"));
if (PlatformInfo::osType() == "linux") {
error(tr("If you are using GNU/Linux visit "
"https://help.trikset.com/nxt/run-upload-programs to get instructions"));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* limitations under the License. */

#include "nxtOsekCGeneratorPlugin.h"

#include <QtCore/QDir>
#include <QtCore/QDateTime>
#include <QtWidgets/QApplication>
Expand All @@ -22,6 +21,7 @@
#include <qrkernel/platformInfo.h>
#include <qrutils/singleton.h>

#include "QsLog.h"
#include "nxtOsekCMasterGenerator.h"

using namespace nxt::osekC;
Expand All @@ -34,9 +34,14 @@ NxtOsekCGeneratorPlugin::NxtOsekCGeneratorPlugin()
, mFlashRobotAction(new QAction(this))
, mUploadProgramAction(new QAction(this))
, mNxtToolsPresent(false)
, mMasterGenerator(nullptr)
, mCommunicator(utils::Singleton<communication::UsbRobotCommunicationThread>::instance())
{
const QString key = "pathToArmNoneEabi";
const QString defaultPath = QDir(PlatformInfo::invariantSettingsPath("pathToNxtTools")).absolutePath()
+"/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi";
if (qReal::SettingsManager::value(key).isNull()) {
qReal::SettingsManager::setValue(key, defaultPath);
}
initActions();
initHotKeyActions();
}
Expand Down Expand Up @@ -96,7 +101,6 @@ void NxtOsekCGeneratorPlugin::onCurrentDiagramChanged(const TabInfo &info)
void NxtOsekCGeneratorPlugin::init(const kitBase::KitPluginConfigurator &configurator)
{
RobotsGeneratorPluginBase::init(configurator);

mFlashTool.reset(new NxtFlashTool(*mMainWindowInterface->errorReporter(), *mCommunicator));
connect(&*mFlashTool, &NxtFlashTool::uploadingComplete, this, &NxtOsekCGeneratorPlugin::onUploadingComplete);
}
Expand Down Expand Up @@ -179,21 +183,24 @@ void NxtOsekCGeneratorPlugin::onUploadingComplete(bool success)

generatorBase::MasterGeneratorBase *NxtOsekCGeneratorPlugin::masterGenerator()
{
mMasterGenerator = new NxtOsekCMasterGenerator(*mRepo
return new NxtOsekCMasterGenerator(*mRepo
, *mMainWindowInterface->errorReporter()
, *mParserErrorReporter
, *mRobotModelManager
, *mTextLanguage
, mMainWindowInterface->activeDiagram()
, generatorName());
return mMasterGenerator;
}

void NxtOsekCGeneratorPlugin::regenerateExtraFiles(const QFileInfo &newFileInfo)
{
mMasterGenerator->initialize();
mMasterGenerator->setProjectDir(newFileInfo);
mMasterGenerator->generateOilAndMakeFiles();
// Static cast is possible and correct, but dynamic will be more flexible.
if (auto nxtGenerator = qobject_cast<NxtOsekCMasterGenerator*>(masterGenerator())) {
QScopedPointer<NxtOsekCMasterGenerator> generator(nxtGenerator);
generator->initialize();
generator->setProjectDir(newFileInfo);
generator->generateOilAndMakeFiles();
}
}

void NxtOsekCGeneratorPlugin::flashRobot()
Expand Down Expand Up @@ -223,21 +230,27 @@ void NxtOsekCGeneratorPlugin::uploadProgram()
void NxtOsekCGeneratorPlugin::checkNxtTools()
{
const QDir dir(PlatformInfo::invariantSettingsPath("pathToNxtTools"));
if (!dir.exists()) {
mNxtToolsPresent = false;
} else {
QDir gnuarm(dir.absolutePath() + "/gnuarm/bin");
QDir nexttool(dir.absolutePath() + "/nexttool");
QDir nxtOSEK(dir.absolutePath() + "/nxtOSEK");

#ifdef Q_OS_WIN
QFile compile1(dir.absolutePath() + "/compile.bat");
QFile compile2(dir.absolutePath() + "/compile.sh");
mNxtToolsPresent = gnuarm.exists() && nexttool.exists() && nxtOSEK.exists()
&& compile1.exists() && compile2.exists();
#else
QFile compile(dir.absolutePath() + "/compile.sh");
mNxtToolsPresent = gnuarm.exists() && nexttool.exists() && nxtOSEK.exists() && compile.exists();
#endif
auto compilePath = dir.absolutePath() + "/compile.sh";

auto nxtToolsPresent = dir.exists()
&& QFileInfo::exists(dir.absolutePath() + "/gnuarm")
&& QFileInfo::exists(dir.absolutePath() + "/nexttool")
&& QFileInfo::exists(dir.absolutePath() + "/nxtOSEK")
&& QFileInfo::exists(compilePath) && QFileInfo(compilePath).isFile();

if (!nxtToolsPresent) {
mNxtToolsPresent = false;
QLOG_ERROR() << "Missing" << dir.absolutePath() << "or mandatory subdirectory" <<
dir.entryList(QDir::Filter::NoFilter, QDir::SortFlag::DirsFirst | QDir::SortFlag::Name);
return;
}

auto osType = PlatformInfo::osType();
if (osType == "linux") {
mNxtToolsPresent = true;
}
else if (osType == "windows") {
auto compileBatPath = dir.absolutePath() + "/compile.bat";
mNxtToolsPresent = QFileInfo::exists(compileBatPath) && QFileInfo(compileBatPath).isFile();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ private slots:
bool mNxtToolsPresent { false };
/// Flasher object
QScopedPointer<NxtFlashTool> mFlashTool;

NxtOsekCMasterGenerator *mMasterGenerator;
const QSharedPointer<communication::UsbRobotCommunicationThread> mCommunicator;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@

#include "nxtAdditionalPreferences.h"
#include "ui_nxtAdditionalPreferences.h"

#include <qrkernel/settingsManager.h>
#include <utils/widgets/comPortPicker.h>
#include "QsLog.h"
#include <QOperatingSystemVersion>
#include <qrkernel/platformInfo.h>

using namespace nxt;
using namespace qReal;
Expand All @@ -28,6 +30,13 @@ NxtAdditionalPreferences::NxtAdditionalPreferences(const QString &realRobotName,
{
mUi->setupUi(this);
mUi->robotImagePicker->configure("nxtRobot2DImage", tr("2D robot image:"));
if (PlatformInfo::osType() == "linux") {
mUi->compilerPicker->configure("pathToArmNoneEabi", tr("Path to arm-none-eabi:"));
setTextOnGeneratorLabel();
}
else {
mUi->generatorSettingsGroupBox->setVisible(false);
}
connect(mUi->manualComPortCheckbox, &QCheckBox::toggled
, this, &NxtAdditionalPreferences::manualComPortCheckboxChecked);
}
Expand All @@ -37,18 +46,44 @@ NxtAdditionalPreferences::~NxtAdditionalPreferences()
delete mUi;
}

void NxtAdditionalPreferences::setColorOnGeneratorLabel(QColor color){
QPalette palette = mUi->generatorLabel->palette();
palette.setColor(mUi->generatorLabel->foregroundRole(), color);
mUi->generatorLabel->setPalette(palette);
}

void NxtAdditionalPreferences::setTextOnGeneratorLabel(){
if (!mUi->compilerPicker->isSavedDirExist()){
mUi->generatorLabel->setText(tr("WARNING: Current directory doesn't exist. \nOpen "
"<a href=\"https://help.trikset.com/nxt/run-upload-programs\">link</a>"
" for instructions"));
mUi->generatorLabel->setTextFormat(Qt::RichText);
mUi->generatorLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
mUi->generatorLabel->setOpenExternalLinks(true);
setColorOnGeneratorLabel(QColor("red"));
}
else {
mUi->generatorLabel->setText("Current directory exist.");
setColorOnGeneratorLabel(QColor("black"));
}
}

void NxtAdditionalPreferences::save()
{
SettingsManager::setValue("NxtBluetoothPortName", selectedPortName());
SettingsManager::setValue("NxtManualComPortCheckboxChecked", mUi->manualComPortCheckbox->isChecked());
mUi->robotImagePicker->save();
mUi->compilerPicker->save();
setTextOnGeneratorLabel();
emit settingsChanged();
}

void NxtAdditionalPreferences::restoreSettings()
{
ui::ComPortPicker::populate(*mUi->comPortComboBox, "NxtBluetoothPortName");
mUi->robotImagePicker->restore();
mUi->compilerPicker->restore();
setTextOnGeneratorLabel();

if (mUi->comPortComboBox->count() == 0) {
mUi->comPortComboBox->hide();
Expand All @@ -72,7 +107,11 @@ void NxtAdditionalPreferences::restoreSettings()

void NxtAdditionalPreferences::onRobotModelChanged(kitBase::robotModel::RobotModelInterface * const robotModel)
{
QLOG_DEBUG() << robotModel->name();
mUi->bluetoothSettingsGroupBox->setVisible(robotModel->name() == mBluetoothRobotName);
if (PlatformInfo::osType() == "linux") {
mUi->generatorSettingsGroupBox->setVisible(robotModel->name() == "NxtOsekCGeneratorRobotModel");
}
}

void NxtAdditionalPreferences::manualComPortCheckboxChecked(bool state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ private slots:

private:
QString selectedPortName() const;

void setColorOnGeneratorLabel(QColor color);
void setTextOnGeneratorLabel();
Ui::NxtAdditionalPreferences *mUi;
const QString mBluetoothRobotName;
};
Expand Down
Loading

0 comments on commit 5787348

Please sign in to comment.