Пример #1
0
PioneerGetLPSPosition::PioneerGetLPSPosition(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "quadcopterCommands/getLPSPosition.t"
		, {
			Binding::createConverting(
					"@@X@@"
					, "X"
					, customizer.factory()->stringPropertyConverter(id, "X"))
			, Binding::createConverting(
					"@@Y@@"
					, "Y"
					, customizer.factory()->stringPropertyConverter(id, "Y"))
			, Binding::createConverting(
					"@@Z@@"
					, "Z"
					, customizer.factory()->stringPropertyConverter(id, "Z"))
			}
		, parent)
{
	customizer.factory()->functionBlockConverter(id, "")->convert(
			QString("%1 = 0;%2 = 0;%3 = 0;")
					.arg(repo.stringProperty(id, "X"))
					.arg(repo.stringProperty(id, "Y"))
					.arg(repo.stringProperty(id, "Z")));
}
Пример #2
0
EnginesStopGenerator::EnginesStopGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "engines/stop.t", QList<Binding *>()
			<< Binding::createConverting("@@PORT@@", "Ports"
					, static_cast<Ev3GeneratorFactory *>(customizer.factory())->outputPortNameConverter())
			<< Binding::createConverting("@@BREAK_MODE@@", "Mode", customizer.factory()->breakModeConverter())
			, parent)
{
}
Пример #3
0
WaitGamepadWheelGenerator::WaitGamepadWheelGenerator(const qrRepo::RepoApi &repo
        , generatorBase::GeneratorCustomizer &customizer
        , const Id &id
        , QObject *parent)
    : BindingGenerator(repo, customizer, id, "wait/gamepadWheel.t"
    , {
    Binding::createConverting("@@ANGLE@@", "Angle", customizer.factory()->intPropertyConverter(id, "Angle"))
    , Binding::createConverting("@@SIGN@@", "Sign", customizer.factory()->inequalitySignConverter())
}
, parent)
{
}
ReadSensorArrayGenerator::ReadSensorArrayGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "sensors/lineLeader/readSensorArray.t", QList<Binding *>()
			<< Binding::createConverting("@@PORT@@", "Port"
					, static_cast<Ev3GeneratorFactory *>(customizer.factory())->portNameConverter())
			, parent)
{
	Binding::ConverterInterface *nameNormalizer = customizer.factory()->nameNormalizerConverter();
	const QString variable = nameNormalizer->convert(mRepo.property(mId, "Variable").toString());
	addBinding(Binding::createStatic("@@VARIABLE@@", variable));
	customizer.factory()->functionBlockConverter(id, "Variable")->convert(QString("%1 = {0}").arg(variable));
}
Пример #5
0
TrikEnginesGenerator::TrikEnginesGenerator(qrRepo::RepoApi const &repo
		, generatorBase::GeneratorCustomizer &customizer
		, qReal::Id const &id
		, QString const &engineType
		, QObject *parent)
	: BindingGenerator(repo, customizer, id
			, engineType.contains("EnginesBackward") ? "engines/backward.t" : "engines/forward.t"
			, { Binding::createMultiTarget("@@PORT@@", "Ports"
						, dynamic_cast<trik::TrikGeneratorFactory *>(customizer.factory())->enginesConverter())
				, Binding::createConverting("@@POWER@@", "Power", customizer.factory()->intPropertyConverter()) }
			, parent)
{
	// AngularServo is just another block for EnginesForward, since it is controlled the same way as radial servo
	// or power motor.
	mCustomizer.factory()->engines()->registerUsageOnPorts(repo.property(id, "Ports").toString());
}
Пример #6
0
DrawPixelGenerator::DrawPixelGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "drawing/drawPixel.t"
			, {
			Binding::createConverting("@@XCoordinatePix@@", "XCoordinatePix"
					, customizer.factory()->intPropertyConverter(id, "XCoordinatePix"))
			, Binding::createConverting("@@YCoordinatePix@@", "YCoordinatePix"
					, customizer.factory()->intPropertyConverter(id, "YCoordinatePix"))
			}
			, parent)
{
	// Calling virtual readTemplate() before base class constructor will cause segfault.
	addBinding(Binding::createStatic("@@REDRAW@@", repo.property(id, "Redraw").toBool()
			? readTemplate("drawing/redraw.t") : QString()));
}
Пример #7
0
DrawEllipseGenerator::DrawEllipseGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "drawing/drawEllipse.t"
			, {
					Binding::createConverting("@@XCoordinateEllipse@@", "XCoordinateEllipse"
							, customizer.factory()->intPropertyConverter(id, "XCoordinateEllipse"))
					, Binding::createConverting("@@YCoordinateEllipse@@", "YCoordinateEllipse"
							, customizer.factory()->intPropertyConverter(id, "YCoordinateEllipse"))
					, Binding::createConverting("@@WidthEllipse@@", "WidthEllipse"
							, customizer.factory()->intPropertyConverter(id, "WidthEllipse"))
					, Binding::createConverting("@@HeightEllipse@@", "HeightEllipse"
							, customizer.factory()->intPropertyConverter(id, "HeightEllipse"))
			}
			, parent)
{
}
SetPainterColorGenerator::SetPainterColorGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "drawing/setPainterColor.t", QList<Binding *>()
			<< Binding::createConverting("@@Color@@", "Color", new BackgroundColorConverter(customizer.factory()->pathToTemplates()))
			, parent)
{
}
Пример #9
0
WaitForButtonGenerator::WaitForButtonGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "wait/button.t"
			, {Binding::createConverting("@@BUTTON@@", "Button", customizer.factory()->portNameConverter())}
			, parent)
{
}
Пример #10
0
DrawRectGenerator::DrawRectGenerator(qrRepo::RepoApi const &repo
		, generatorBase::GeneratorCustomizer &customizer
		, qReal::Id const &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "drawing/drawRect.t"
			, {
					Binding::createConverting("@@XCoordinateRect@@", "XCoordinateRect"
							, customizer.factory()->intPropertyConverter(id, "XCoordinateRect"))
					, Binding::createConverting("@@YCoordinateRect@@", "YCoordinateRect"
							, customizer.factory()->intPropertyConverter(id, "YCoordinateRect"))
					, Binding::createConverting("@@WidthRect@@", "WidthRect"
							, customizer.factory()->intPropertyConverter(id, "WidthRect"))
					, Binding::createConverting("@@HeightRect@@", "HeightRect"
							, customizer.factory()->intPropertyConverter(id, "HeightRect"))
			}
			, parent)
{
}
StartCompassCalibrationGenerator::StartCompassCalibrationGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "sensors/startCompassCalibration.t", QList<Binding *>()
			<< Binding::createConverting("@@PORT@@", "Port"
					, static_cast<Ev3GeneratorFactory *>(customizer.factory())->portNameConverter())
			, parent)
{
}
Пример #12
0
WaitGamepadButtonGenerator::WaitGamepadButtonGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "wait/gamepadButton.t"
			, {Binding::createConverting(
					"@@BUTTON@@", "Button", customizer.factory()->stringPropertyConverter(id, "Button"))
					}
			, parent)
{
}
Пример #13
0
ReadRGBGenerator::ReadRGBGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "sensors/readRGBIntoVariables.t", QList<Binding *>()
			<< Binding::createConverting("@@PORT@@", "Port"
					, static_cast<Ev3GeneratorFactory *>(customizer.factory())->portNameConverter())
			, parent)
{
	Binding::ConverterInterface *nameNormalizer = customizer.factory()->nameNormalizerConverter();
	const QString rVariable = nameNormalizer->convert(mRepo.property(mId, "RVariable").toString());
	addBinding(Binding::createStatic("@@R_VARIABLE@@", rVariable));
	const QString gVariable = nameNormalizer->convert(mRepo.property(mId, "GVariable").toString());
	addBinding(Binding::createStatic("@@G_VARIABLE@@", gVariable));
	const QString bVariable = nameNormalizer->convert(mRepo.property(mId, "BVariable").toString());
	addBinding(Binding::createStatic("@@B_VARIABLE@@", bVariable));

	customizer.factory()->functionBlockConverter(id, "")->convert(
			QString("%1 = 0;%2 = 0;%3 = 0;").arg(rVariable).arg(gVariable).arg(bVariable));
}
Пример #14
0
InitCameraGenerator::InitCameraGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id
			, "videosensors/init" + repo.property(id, "Mode").toString() + "Sensor.t"
			, { Binding::createConverting("@@DRAW@@"
						, "DrawStream", customizer.factory()->boolPropertyConverter(id, "DrawStream", false))
			}
			, parent)
{
}
Пример #15
0
DrawRectGenerator::DrawRectGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, (repo.stringProperty(id, "Filled") == "true")
					? "drawing/drawFilledRect.t"
					: "drawing/drawRect.t"
			, {
				Binding::createConverting("@@XCoordinateRect@@", "XCoordinateRect"
						, customizer.factory()->intPropertyConverter(id, "XCoordinateRect"))
				, Binding::createConverting("@@YCoordinateRect@@", "YCoordinateRect"
						, customizer.factory()->intPropertyConverter(id, "YCoordinateRect"))
				, Binding::createConverting("@@WidthRect@@", "WidthRect"
						, customizer.factory()->intPropertyConverter(id, "WidthRect"))
				, Binding::createConverting("@@HeightRect@@", "HeightRect"
						, customizer.factory()->intPropertyConverter(id, "HeightRect"))
			}
			, parent)
{
	addBinding(Binding::createStatic("@@REDRAW@@", repo.property(id, "Redraw").toBool()
			? readTemplate("drawing/redraw.t") : QString()));
}
Пример #16
0
ClearScreenBlockGenerator::ClearScreenBlockGenerator(qrRepo::RepoApi const &repo
		, generatorBase::GeneratorCustomizer &customizer
		, qReal::Id const &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id
			, static_cast<NxtGeneratorFactory *>(customizer.factory())->images().bmpFilesCount()
					// WARNING: this may not work when we traverse here earlier than
					// into drawing block but it will be executed before this block
					? "drawing/clearUsedScreen.t"
					: "drawing/clearUnusedScreen.t"
			, {}, parent)
{
}
Пример #17
0
SayGenerator::SayGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id
			, "say.t"
			, { repo.property(id, "Evaluate").toBool()
					? Binding::createConverting("@@TEXT@@", "Text"
								, customizer.factory()->stringPropertyConverter(id, "Text"))
					: Binding::createStatic("@@TEXT@@", utils::StringUtils::wrap(repo.property(id, "Text").toString()))
			} , parent)
{
}
Пример #18
0
SetBackgroundGenerator::SetBackgroundGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id
			, "drawing/setBackground.t"
			, { Binding::createConverting("@@COLOR@@", "Color"
					, new BackgroundColorConverter(customizer.factory()->pathsToTemplates()))
			}, parent)
{
	// Calling virtual readTemplate() before base class constructor will cause segfault.
	addBinding(Binding::createStatic("@@REDRAW@@", repo.property(id, "Redraw").toBool()
			? readTemplate("drawing/redraw.t") : QString()));
}
Пример #19
0
LabelGenerator::LabelGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent
		, GotoLabelManager &gotoLabelManager)
	: BindingGenerator(repo, customizer, id, "label.t"
			, { Binding::createStaticConverting(
					"@@ID@@"
					, gotoLabelManager.labelFor(id)
					, customizer.factory()->nameNormalizerConverter()
				)
			}
			, parent)
{
}
Пример #20
0
SystemGenerator::SystemGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id
			, repo.property(id, "Code").toBool() ? "nativeCode.t" : "system.t"
			, { repo.property(id, "Code").toBool()
					? Binding::createStatic("@@COMMAND@@"
							, utils::StringUtils::dequote(repo.property(id, "Command").toString()))
					: repo.property(id, "Evaluate").toBool()
							? Binding::createConverting("@@COMMAND@@", "Command"
									, customizer.factory()->stringPropertyConverter(id, "Command"))
							: Binding::createStatic("@@COMMAND@@"
									, utils::StringUtils::wrap(repo.property(id, "Command").toString()))
			}
			, parent)
{
}