<?xml version='1.0' encoding='utf-8'?>
<root version="20190819">
    <world>
        <walls>
            <wall stroke-style="none" fill="#ff000000" begin="-150:-150" end="-150:300" id="{04fc486f-4c61-48eb-87c1-46e0ccae595e}" stroke-width="10" stroke="#ff000000"/>
            <wall stroke-style="none" fill="#ff000000" begin="300:-150" end="-150:-150" id="{21d767e3-8ed2-4f52-956f-f0d55c4f5411}" stroke-width="10" stroke="#ff000000"/>
            <wall stroke-style="none" fill="#ff000000" begin="-150:300" end="0:300" id="{9ca4fbe8-2b13-4909-8429-d0797dbd7ae2}" stroke-width="10" stroke="#ff000000"/>
            <wall stroke-style="none" fill="#ff000000" begin="0:150" end="0:300" id="{0396abe5-2e75-4e21-a870-344f60ae6bf9}" stroke-width="10" stroke="#ff000000"/>
            <wall stroke-style="none" fill="#ff000000" begin="300:150" end="0:150" id="{253dbb5f-4655-4d5f-ac12-0bc2815f834e}" stroke-width="10" stroke="#ff000000"/>
            <wall stroke-style="none" fill="#ff000000" begin="0:-150" end="0:0" id="{acdb6560-8006-46e8-937e-6777fdfd4844}" stroke-width="10" stroke="#ff000000"/>
            <wall stroke-style="none" fill="#ff000000" begin="300:-150" end="300:150" id="{6698382d-e324-43a8-9452-c7ce6d777320}" stroke-width="10" stroke="#ff000000"/>
            <wall stroke-style="none" fill="#ff000000" begin="0:0" end="150:0" id="{cf3bd70b-1fcf-4b65-a377-2bcd88eb98e9}" stroke-width="10" stroke="#ff000000"/>
        </walls>
        <skittles/>
        <balls/>
        <colorFields>
            <rectangle stroke-style="solid" fill="#ff000000" begin="0:-150" end="150:0" id="{ad6f66cb-04ed-4d74-b2f9-2dd4f2e58fca}" stroke-width="6" stroke="#ff000000" fill-style="solid"/>
        </colorFields>
        <images/>
        <regions>
            <region id="start_zone" visible="true" textY="0" text="Start" type="rectangle" height="50" x="-100" filled="true" y="-100" textX="0" width="50" color="#0000ff"/>
            <region id="finish" visible="true" textY="0" text="Finish" type="rectangle" height="150" x="0" filled="true" y="-150" textX="0" width="150" color="#ff0000"/>
		   
            <region id="wayzone6" visible="true" type="rectangle" height="150" x="150" filled="true" y="0" width="150" color="#008000"/>
            <region id="wayzone5" visible="true" type="rectangle" height="150" x="150" filled="true" y="-150" width="150" color="#008000"/>
            <region id="wayzone4" visible="true" type="rectangle" height="150" x="0" filled="true" y="0" width="150" color="#008000"/>
            <region id="wayzone3" visible="true" type="rectangle" height="150" x="-150" filled="true" y="150" width="150" color="#008000"/>
            <region id="wayzone2" visible="true" type="rectangle" height="150" x="-150" filled="true" y="0" width="150" color="#008000"/>
            <region id="wayzone1" visible="true" type="rectangle" height="150" x="-150" filled="true" y="-150" width="150" color="#008000"/>
        </regions>
    </world>
    <robots>
        <robot position="-100:-100" id="trikKitRobot" direction="90">
            <sensors>
                <sensor position="75:25" direction="0" port="M4###output###М4###" type="kitBase::robotModel::robotParts::Motor"/>
                <sensor position="75:25" direction="0" port="E1###input###M1$$$Е1###encoder1" type="kitBase::robotModel::robotParts::EncoderSensor"/>
                <sensor position="50:25" direction="0" port="A5###input###А5###sensorA5" type="trik::robotModel::parts::TrikLightSensor"/>
                <sensor position="75:25" direction="0" port="M3###output###М3###" type="kitBase::robotModel::robotParts::Motor"/>
                <sensor position="75:25" direction="0" port="E2###input###M2$$$Е2###encoder2" type="kitBase::robotModel::robotParts::EncoderSensor"/>
                <sensor position="75:25" direction="0" port="M2###output###М2###" type="kitBase::robotModel::robotParts::Motor"/>
                <sensor position="75:25" direction="0" port="E3###input###M3$$$Е3###encoder3" type="kitBase::robotModel::robotParts::EncoderSensor"/>
                <sensor position="75:25" direction="0" port="M1###output###М1###" type="kitBase::robotModel::robotParts::Motor"/>
                <sensor position="75:25" direction="0" port="E4###input###M4$$$Е4###encoder4" type="kitBase::robotModel::robotParts::EncoderSensor"/>
                <sensor position="25:25" direction="90" port="A1###input###А1###sensorA1" type="trik::robotModel::parts::TrikInfraredSensor"/>
                <sensor position="25:23" direction="0" port="A2###input###А2###sensorA2" type="trik::robotModel::parts::TrikInfraredSensor"/>
            </sensors>
            <startPosition y="-75" x="-75" id="{dd2d17cb-ff7d-4705-9cdd-754843d18516}" direction="90"/>
            <wheels right="M3###output###М3###" left="M4###output###М4###"/>
        </robot>
    </robots>
    <settings realisticPhysics="false" realisticSensors="false" realisticMotors="false"/>
    <constraints>
        <timelimit value="130000"/>
        <!-- Провека, что нет датчиков, кроме двух датчиков расстояния и одного датчика освещенности-->
        <constraint checkOnce="true" failMessage="У робота не должно быть датчиков, кроме двух датчиков расстояния и одного датчика освещенности">
            <conditions glue="and">
                <equals>
                    <typeOf objectId="robot1.A3"/>
                    <string value="undefined"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.A4"/>
                    <string value="undefined"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.A6"/>
                    <string value="undefined"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.D1"/>
                    <string value="undefined"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.D2"/>
                    <string value="undefined"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.F1"/>
                    <string value="undefined"/>
                </equals>
            </conditions>
        </constraint>
        <!-- Проверка, что на порт А1 и А2 установлены датчики расстояния, на порт А5 установлен датчик освещенности -->
        <constraint checkOnce="true" failMessage="У робота должены быть установлены датчики расстояния на портах А1 и А2 и датчик освещенности на порту А5">
            <conditions glue="and">
                <equals>
                    <typeOf objectId="robot1.A1"/>
                    <string value="twoDModel::robotModel::parts::RangeSensor"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.A2"/>
                    <string value="twoDModel::robotModel::parts::RangeSensor"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.A5"/>
                    <string value="trik::robotModel::twoD::parts::TwoDLightSensor"/>
                </equals>
            </conditions>
        </constraint>
        <!-- Зональное ограничение на начало езды. Проверяется один раз в начале программы-->
        <constraint checkOnce="true" failMessage="Робот должен находиться перед черной меткой перед стартом!">
            <inside objectId="robot1" regionId="start_zone"/>
        </constraint>
        <!-- Событие, которое выдает ошибку, если робот не тронулся с места в первую секунду -->
        <event id="Waiting for going forward too long" settedUpInitially="true">
            <conditions glue="and">
                <timer forceDropOnTimeout="true" timeout="1000"/>
                <settedUp id="We are alive, first move"/>
            </conditions>
            <trigger>
                <fail message="Робот так и не поехал в первую секунду"/>
            </trigger>
        </event>
        <!-- Событие, которое говорит о том, что робот начал двигаться. Мощность на одном из моторов больше 0. Запускается цепочка проверок -->
        <event id="We are alive, first move" settedUpInitially="true">
            <conditions glue="or">
                <notEquals>
                    <objectState object="robot1.M3.power"/>
                    <int value="0"/>
                </notEquals>
                <notEquals>
                    <objectState object="robot1.M4.power"/>
                    <int value="0"/>
                </notEquals>
            </conditions>
            <triggers>
                <setUp id="check1"/>
            </triggers>
        </event>
        <!-- Цепочка проверок, что робот едет по правильной траектории -->
        <event id="check1">
            <condition>
                <inside objectId="robot1" regionId="wayzone2"/>
            </condition>
            <trigger>
                <setUp id="check2"/>
            </trigger>
        </event>
        <event id="check2">
            <condition>
                <inside objectId="robot1" regionId="wayzone3"/>
            </condition>
            <trigger>
                <setUp id="check3"/>
            </trigger>
        </event>
        <event id="check3">
            <condition>
                <inside objectId="robot1" regionId="wayzone2"/>
            </condition>
            <trigger>
                <setUp id="check4"/>
            </trigger>
        </event>
        <event id="check4">
            <condition>
                <inside objectId="robot1" regionId="wayzone4"/>
            </condition>
            <trigger>
                <setUp id="black check"/>
            </trigger>
        </event>

        <!-- Событие, проверяющее, что робот увидел черную метку -->
        <event id="black check">
            <condition>
                <greater>
                    <objectState object="robot1.A5.value"/>
                    <int value="67"/>
                </greater>
            </condition>
            <triggers>
                <setUp id="finish zone"/>
            </triggers>
        </event>
		
		<!-- Событие, проверяющее, что остановились в зоне финиша -->
		<event id="finish zone">
            <conditions glue="and">
				<inside regionId="finish" objectId="robot1"/>
				<equals>
					<objectState object="robot1.M3.power"/>
					<int value="0"/>
				</equals>
				<equals>
					<objectState object="robot1.M4.power"/>
					<int value="0"/>
				</equals>
            </conditions>
            <triggers>
                <setUp id="array check"/>
				<setUp id="array checker false length"/>
            </triggers>
        </event>
		
        <!-- Событие, оповещающее об успешном выполнении программы -->
        <event id="array check">
            <conditions glue="and">
				<timer timeout="1800" forceDropOnTimeout="true"/>
				<equals>
					<objectState object="robot1.display.labels.first.text"/>
					<string value="3"/>
				</equals>
				<equals>
					<objectState object="robot1.display.labels.last.text"/>
					<string value="3"/>
				</equals>
				<equals>
					<objectState object="robot1.display.labels.size"/>
					<string value="8"/>
				</equals>
			</conditions>
            <trigger>
                <success/>
            </trigger>
        </event>
		
		<!-- Событие, которое выдает ошибку, если получена траектория неправильной длины -->
		<event id="array checker false length" settedUpInitially="false">
            <conditions glue="and">
				<timer timeout="1000" forceDropOnTimeout="true"/>
					<notEquals>
						<objectState object="robot1.display.labels.size"/>
						<string value="8"/>
					</notEquals>
            </conditions>
            <trigger>
                <fail message="Получена массив неправильной длины"/>
            </trigger>
        </event>
	</constraints>
</root>
