Skip to content

Commit ae9d872

Browse files
committed
Merge branch 'master' of https://github.com/qreal/qreal into alt-linux
Conflicts: plugins/robots/utils/src/robotCommunication/protocol.h plugins/robots/utils/src/robotCommunication/runProgramProtocol.cpp qrgui/mainWindow/mainWindow.pro
2 parents c35021b + ac4a59d commit ae9d872

File tree

238 files changed

+14502
-9206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

238 files changed

+14502
-9206
lines changed

.travis.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
sudo: required
22
dist: trusty
33

4+
git:
5+
depth: 1
6+
47
language: cpp
58
compiler: gcc
69

@@ -13,7 +16,10 @@ env:
1316
- CONFIG=release PROJECT=qrealBP VERA=false TESTS=true
1417
- CONFIG=debug PROJECT=qrealTest VERA=false TESTS="./exampleTests-d && ./qrgui_unittests-d && ./qrrepo_unittests-d && ./qrutils_unittests-d && ./visualDebugSupport_unittests-d && ./qrtext_unittests-d && ./generationRulesTool_unittests-d"
1518
- CONFIG=release PROJECT=qrealTest VERA=false TESTS="./exampleTests && ./qrgui_unittests && ./qrrepo_unittests && ./qrutils_unittests && ./visualDebugSupport_unittests && ./qrtext_unittests && ./generationRulesTool_unittests"
16-
- CONFIG=debug PROJECT=qrealRobotsTest VERA=false TESTS="./robots_kitBase_unittests-d && ./robots_interpreterCore_unittests-d && ./robots_twoDModel_unittests-d && ./run-simulator-tests.sh"
19+
- CONFIG=debug PROJECT=qrealRobotsTest VERA=false TESTS="./robots_kitBase_unittests-d && ./robots_interpreterCore_unittests-d && ./robots_twoDModel_unittests-d && ./trik-v62-qts-generator-tests-d && ./run-simulator-tests.sh"
20+
21+
before_install:
22+
- if [ "$TESTS" != "true" ]; then pip install --user codecov; fi
1723

1824
install:
1925
- if [ "$CXX" = "g++" ]; then sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y; fi
@@ -46,5 +52,8 @@ script:
4652

4753
notifications:
4854
email:
49-
recipients:
50-
55+
recipients:
56+
57+
58+
after_success:
59+
- if [ "$TESTS" != "true" ]; then codecov; fi

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#[QReal] (http://qreal.ru)
44

55
[![Build Status](https://travis-ci.org/qreal/qreal.svg?branch=master)](https://travis-ci.org/qreal/qreal)
6+
[![Coverity](https://scan.coverity.com/projects/7874/badge.svg)](https://scan.coverity.com/projects/qreal-qreal)
7+
[![codecov.io](https://codecov.io/github/qreal/qreal/coverage.svg?branch=master)](https://codecov.io/github/qreal/qreal?branch=master)
68

79
QReal представляет собой metaCASE-инструментарий, т.е. среду для создания новых визуальных языков и интегрированных сред программирования для них.
810
Руководители: [Юрий Литвинов](https://github.com/yurii-litvinov) и [Тимофей Брыксин](https://github.com/jzuken)

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ environment:
88
matrix:
99
- PROJECT_FILE: qrealRobots
1010
- PROJECT_FILE: qreal
11-
# - PROJECT_FILE: qrealMinimal.pro
1211

1312
configuration:
1413
- debug
1514
- release
1615

1716
install:
1817
- set PATH=%QTDIR%\bin;%MINGW%\bin;%WINDIR%\system32;%WINDIR%;%WINDIR%\System32\WindowsPowerShell\v1.0\;
18+
1919
build_script:
2020
- qmake %PROJECT_FILE%.pro -r -spec win32-g++ CONFIG+=%CONFIGURATION%
2121
- mingw32-make -j2
22-
22+
2323
artifacts:
2424
- path: bin\$(configuration)
2525
name: qreal-$(configuration)-$(PROJECT_FILE)

global.pri

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ macx {
2727
CONFIG(debug, debug | release) {
2828
CONFIGURATION = debug
2929
CONFIGURATION_SUFFIX = -d
30+
QMAKE_CXXFLAGS += -coverage
31+
QMAKE_LFLAGS += -coverage
3032
} else {
3133
CONFIGURATION = release
3234
CONFIGURATION_SUFFIX =

plugins/blockDiagram/visualDebugSupport/visualDebugSupport.pri

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ links(qrkernel qrutils qrgui-preferences-dialog qrgui-tool-plugin-interface)
2323

2424
TRANSLATIONS = $$PWD/../../../qrtranslations/ru/plugins/visualDebugSupport_ru.ts
2525

26-
HEADERS = \
26+
HEADERS += \
2727
$$PWD/visualDebuggerPlugin.h \
2828
$$PWD/visualDebuggerPreferencesPage.h \
2929

30-
SOURCES = \
30+
SOURCES += \
3131
$$PWD/visualDebuggerPlugin.cpp \
3232
$$PWD/visualDebuggerPreferencesPage.cpp \
3333

plugins/plugins.pro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ SUBDIRS += \
3636
$$PWD/tools/exterminatus/exterminatus.pro \
3737
$$PWD/tools/visualInterpreter/visualInterpreter.pro \
3838
$$PWD/tools/refactoring/refactoring.pro \
39-
$$PWD/tools/testInvocation/testInvocation.pro \
4039
$$PWD/tools/uxInfo/uxInfo.pro \
4140

4241

plugins/robots/common/trikKit/include/trikKit/robotModel/trikRobotModelBase.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ class TrikRobotModelBase : public kitBase::robotModel::CommonRobotModel
3232

3333
QHash<QString, int> buttonCodes() const override;
3434

35+
/// Registers error reporter in a model.
3536
virtual void setErrorReporter(qReal::ErrorReporterInterface &errorReporter) = 0;
3637

38+
/// Returns config file version that shall be on a robot to be able to use this model.
39+
virtual QString robotConfigFileVersion() const = 0;
40+
3741
protected:
3842
virtual kitBase::robotModel::DeviceInfo displayInfo() const;
3943
virtual kitBase::robotModel::DeviceInfo speakerInfo() const;

plugins/robots/common/trikKit/include/trikKit/robotModel/trikRobotModelV6.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class TrikRobotModelV6 : public TrikRobotModelBase
2525

2626
public:
2727
TrikRobotModelV6(const QString &kitId, const QString &robotId);
28+
29+
QString robotConfigFileVersion() const override;
2830
};
2931

3032
}

plugins/robots/common/trikKit/include/trikKit/robotModel/trikRobotModelV62.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class TrikRobotModelV62 : public TrikRobotModelBase
2525

2626
public:
2727
TrikRobotModelV62(const QString &kitId, const QString &robotId);
28+
29+
QString robotConfigFileVersion() const override;
2830
};
2931

3032
}

plugins/robots/common/trikKit/src/robotModel/trikRobotModelV6.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@ TrikRobotModelV6::TrikRobotModelV6(const QString &kitId, const QString &robotId)
3434
addAllowedConnection(PortInfo("B3", input, { "M3", "В3" }, "encoder3"), { encoderInfo() });
3535
addAllowedConnection(PortInfo("B4", input, { "M4", "В4" }, "encoder4"), { encoderInfo() });
3636
}
37+
38+
QString TrikRobotModelV6::robotConfigFileVersion() const
39+
{
40+
return "model-2014";
41+
}

plugins/robots/common/trikKit/src/robotModel/trikRobotModelV62.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@ TrikRobotModelV62::TrikRobotModelV62(const QString &kitId, const QString &robotI
3434
addAllowedConnection(PortInfo("E3", input, { "M3", "Е3" }, "encoder3"), { encoderInfo() });
3535
addAllowedConnection(PortInfo("E4", input, { "M4", "Е4" }, "encoder4"), { encoderInfo() });
3636
}
37+
38+
QString TrikRobotModelV62::robotConfigFileVersion() const
39+
{
40+
return "model-2015";
41+
}

plugins/robots/common/twoDModel/include/twoDModel/engine/model/robotModel.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#include <QtGui/QPainterPath>
1818

19+
#include <utils/circularQueue.h>
20+
1921
#include "twoDModel/robotModel/twoDRobotModel.h"
2022
#include "sensorsConfiguration.h"
2123

@@ -199,8 +201,8 @@ public slots:
199201
bool mIsOnTheGround;
200202
QColor mMarker;
201203
QPointF mAcceleration;
202-
QVector<QPointF> mPosStamps;
203-
QVector<qreal> mAngleStamps;
204+
utils::CircularQueue<QPointF> mPosStamps;
205+
utils::CircularQueue<qreal> mAngleStamps;
204206

205207
physics::PhysicsEngineBase *mPhysicsEngine;
206208

plugins/robots/common/twoDModel/src/engine/model/robotModel.cpp

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ using namespace physics;
3636
using namespace kitBase::robotModel;
3737
using namespace kitBase::robotModel::robotParts;
3838

39+
const int positionStampsCount = 50;
40+
const int angleStampsCount = 50;
41+
3942
RobotModel::RobotModel(robotModel::TwoDRobotModel &robotModel
4043
, const Settings &settings
4144
, QObject *parent)
@@ -50,8 +53,8 @@ RobotModel::RobotModel(robotModel::TwoDRobotModel &robotModel
5053
, mIsOnTheGround(true)
5154
, mMarker(Qt::transparent)
5255
, mAcceleration(QPointF(0, 0))
53-
, mPosStamps(QVector<QPointF>(50))
54-
, mAngleStamps(QVector<qreal>(50))
56+
, mPosStamps(positionStampsCount)
57+
, mAngleStamps(angleStampsCount)
5558
, mPhysicsEngine(nullptr)
5659
, mStartPositionMarker(new items::StartPosition)
5760
{
@@ -174,6 +177,8 @@ void RobotModel::stopRobot()
174177
{
175178
mBeepTime = 0;
176179
mRobotModel.displayWidget()->reset();
180+
mAngleStamps.clear();
181+
mPosStamps.clear();
177182
emit playingSoundChanged(false);
178183
for (Motor * const engine : mMotors) {
179184
engine->speed = 0;
@@ -193,12 +198,18 @@ void RobotModel::countBeep()
193198

194199
void RobotModel::countSpeedAndAcceleration()
195200
{
196-
mAngleStamps.pop_front();
197-
mAngleStamps.append(mAngle);
201+
if (mAngleStamps.size() >= angleStampsCount) {
202+
mAngleStamps.dequeue();
203+
}
204+
205+
mAngleStamps.enqueue(mAngle);
198206
mAngularSpeed = averageAngularSpeed();
199207

200-
mPosStamps.pop_front();
201-
mPosStamps.append(mPos);
208+
if (mPosStamps.size() >= positionStampsCount) {
209+
mPosStamps.dequeue();
210+
}
211+
212+
mPosStamps.enqueue(mPos);
202213
mAcceleration = averageAcceleration();
203214
}
204215

@@ -207,12 +218,16 @@ QPointF RobotModel::averageAcceleration() const
207218
/// Some arcane formula that produces natural-looking results for some reason (with correct accelerometerConstant,
208219
/// since mPosStamps.size() as a divisor is obviously wrong here).
209220
/// Maybe it will be better to actually count average.
210-
return (mPosStamps[49] - mPosStamps[48] - mPosStamps[1] + mPosStamps[0]) / mPosStamps.size();
221+
222+
return mPosStamps.size() < 2 ? QPointF() : (mPosStamps.size() < 4
223+
? (mPosStamps.tail() - mPosStamps.head()) / mPosStamps.size()
224+
: (mPosStamps.tail() - mPosStamps.nthFromTail(1)
225+
- mPosStamps.nthFromHead(1) + mPosStamps.head()) / mPosStamps.size());
211226
}
212227

213228
qreal RobotModel::averageAngularSpeed() const
214229
{
215-
return (mAngleStamps[49] - mAngleStamps[0]) / mAngleStamps.size();
230+
return mAngleStamps.isEmpty() ? 0 : (mAngleStamps.tail() - mAngleStamps.head()) / mAngleStamps.size();
216231
}
217232

218233
QPointF RobotModel::rotationCenter() const

plugins/robots/generators/ev3/ev3RbfGenerator/ev3RbfGeneratorPlugin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Ev3RbfGeneratorPlugin::Ev3RbfGeneratorPlugin()
5252
mStopRobotAction->setIcon(QIcon(":/ev3/rbf/images/stop.png"));
5353
connect(mStopRobotAction, &QAction::triggered, this, &Ev3RbfGeneratorPlugin::stopRobot, Qt::UniqueConnection);
5454

55-
text::Languages::registerLanguage(text::LanguageInfo{ "rbf"
55+
text::Languages::registerLanguage(text::LanguageInfo{ "lms"
5656
, tr("EV3 Source Code language")
5757
, true
5858
, 4
@@ -104,7 +104,7 @@ QString Ev3RbfGeneratorPlugin::defaultFilePath(QString const &projectName) const
104104

105105
text::LanguageInfo Ev3RbfGeneratorPlugin::language() const
106106
{
107-
return text::Languages::pickByExtension("rbf");
107+
return text::Languages::pickByExtension("lms");
108108
}
109109

110110
QString Ev3RbfGeneratorPlugin::generatorName() const
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
CP_GTEQF@@TYPE@@(@@LEFT@@, @@RIGHT@@, @@RESULT@@)
1+
CP_GTEQ@@TYPE@@(@@LEFT@@, @@RIGHT@@, @@RESULT@@)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
CP_GTF@@TYPE@@(@@LEFT@@, @@RIGHT@@, @@RESULT@@)
1+
CP_GT@@TYPE@@(@@LEFT@@, @@RIGHT@@, @@RESULT@@)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
CP_LTEQF@@TYPE@@(@@LEFT@@, @@RIGHT@@, @@RESULT@@)
1+
CP_LTEQ@@TYPE@@(@@LEFT@@, @@RIGHT@@, @@RESULT@@)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
CP_LTF@@TYPE@@(@@LEFT@@, @@RIGHT@@, @@RESULT@@)
1+
CP_LT@@TYPE@@(@@LEFT@@, @@RIGHT@@, @@RESULT@@)

plugins/robots/generators/generatorBase/src/robotsGeneratorPluginBase.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ QFileInfo RobotsGeneratorPluginBase::srcPath()
106106
} while (!canGenerateTo(projectName));
107107

108108
QFileInfo fileInfo = generationTarget(projectName);
109-
QList<QFileInfo> const pathsList = mCodePath.values(activeDiagram);
109+
const QList<QFileInfo> pathsList = mCodePath.values(activeDiagram);
110110

111111
if (!pathsList.isEmpty()) {
112112
for (const QFileInfo &path : pathsList) {
@@ -130,10 +130,11 @@ QFileInfo RobotsGeneratorPluginBase::generateCodeForProcessing()
130130

131131
if (!activeDiagram.isNull()) {
132132
if (generateCode(false)) {
133-
foreach (const QFileInfo &path, mCodePath.values(activeDiagram)) {
133+
for (const QFileInfo &path : mCodePath.values(activeDiagram)) {
134134
if (mTextManager->isDefaultPath(path.absoluteFilePath())
135135
&& (!mTextManager->isModifiedEver(path.absoluteFilePath()))
136-
&& !mTextManager->generatorName(path.absoluteFilePath()).compare(generatorName())) {
136+
&& !mTextManager->generatorName(path.absoluteFilePath()).compare(generatorName()))
137+
{
137138
fileInfo = path;
138139
break;
139140
}

plugins/robots/generators/trik/trikGeneratorBase/include/trikGeneratorBase/robotModel/trikV62GeneratorRobotModel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ROBOTS_TRIK_GENERATOR_BASE_EXPORT TrikV62GeneratorRobotModel
4444
void addDevice(const kitBase::robotModel::PortInfo &port
4545
, kitBase::robotModel::robotParts::Device * const device) override;
4646

47-
void setErrorReporter(qReal::ErrorReporterInterface &errorReporter);
47+
void setErrorReporter(qReal::ErrorReporterInterface &errorReporter) override;
4848

4949
private:
5050
kitBase::robotModel::robotParts::Device *createDevice(const kitBase::robotModel::PortInfo &port

plugins/robots/generators/trik/trikGeneratorBase/include/trikGeneratorBase/robotModel/trikV6GeneratorRobotModel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ROBOTS_TRIK_GENERATOR_BASE_EXPORT TrikV6GeneratorRobotModel
4444
void addDevice(const kitBase::robotModel::PortInfo &port
4545
, kitBase::robotModel::robotParts::Device * const device) override;
4646

47-
void setErrorReporter(qReal::ErrorReporterInterface &errorReporter);
47+
void setErrorReporter(qReal::ErrorReporterInterface &errorReporter) override;
4848

4949
private:
5050
kitBase::robotModel::robotParts::Device *createDevice(const kitBase::robotModel::PortInfo &port

plugins/robots/generators/trik/trikGeneratorBase/include/trikGeneratorBase/trikGeneratorPluginBase.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,13 @@ class ROBOTS_TRIK_GENERATOR_BASE_EXPORT TrikGeneratorPluginBase : public generat
5252
protected:
5353
void regenerateExtraFiles(const QFileInfo &newFileInfo) override;
5454

55-
QScopedPointer<kitBase::robotModel::RobotModelInterface> mRobotModel;
55+
/// Provides access to robot model to descendant classes.
56+
kitBase::robotModel::RobotModelInterface &robotModel() const;
5657

5758
private:
59+
/// Robot model that is used to query information about various robot devices.
60+
QScopedPointer<kitBase::robotModel::RobotModelInterface> mRobotModel;
61+
5862
/// Does not have ownership.
5963
kitBase::blocksBase::BlocksFactoryInterface *mBlocksFactory;
6064
};

plugins/robots/generators/trik/trikGeneratorBase/src/trikGeneratorPluginBase.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,8 @@ void TrikGeneratorPluginBase::regenerateExtraFiles(const QFileInfo &newFileInfo)
5050
{
5151
Q_UNUSED(newFileInfo);
5252
}
53+
54+
kitBase::robotModel::RobotModelInterface &TrikGeneratorPluginBase::robotModel() const
55+
{
56+
return *mRobotModel.data();
57+
}

plugins/robots/generators/trik/trikQtsGeneratorLibrary/include/trikQtsGeneratorLibrary/trikQtsGeneratorPluginBase.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ class UploadProgramProtocol;
3535
}
3636

3737
namespace trik {
38+
39+
namespace robotModel {
40+
class TrikRobotModelBase;
41+
}
42+
3843
namespace qts {
3944

4045
/// Generation of QtScript program for TRIK, uploading and execution of a program.
@@ -44,7 +49,7 @@ class TrikQtsGeneratorPluginBase : public TrikGeneratorPluginBase
4449
Q_OBJECT
4550

4651
public:
47-
TrikQtsGeneratorPluginBase(kitBase::robotModel::RobotModelInterface * const robotModel
52+
TrikQtsGeneratorPluginBase(trik::robotModel::TrikRobotModelBase * const robotModel
4853
, kitBase::blocksBase::BlocksFactoryInterface * const blocksFactory
4954
, const QStringList &pathsToTemplates);
5055

@@ -98,6 +103,9 @@ private slots:
98103
/// Communicator object used to send commands to robot.
99104
QScopedPointer<utils::robotCommunication::TcpRobotCommunicator> mCommunicator;
100105

106+
/// Robot model that is used by generator to check config file version on a robot.
107+
trik::robotModel::TrikRobotModelBase &mRobotModel;
108+
101109
QStringList mPathsToTemplates;
102110

103111
/// Protocol that is used to upload program to robot.

0 commit comments

Comments
 (0)