<?xml version='1.0' encoding='utf-8'?>
<root version="20190819">
    <world>
        <walls/>
        <skittles/>
        <balls/>
        <colorFields>
            <line stroke="#ff000000" id="{a0374853-7127-4652-a345-50d5d85b07d4}" fill-style="none" stroke-width="10" begin="90:0" end="340:5" stroke-style="solid" fill="#ff000000"/>
            <cubicBezier stroke="#ff000000" id="{dfa507db-d3da-470e-8464-38a3a2911269}" fill-style="none" cp2="476:3" stroke-width="10" cp1="316:3" begin="340:5" end="440:-200" stroke-style="solid" fill="#ff000000"/>
            <cubicBezier stroke="#ff000000" id="{fcd9f2f1-33e2-423a-96e4-c4062eb10f4d}" fill-style="none" cp2="401:-384" stroke-width="10" cp1="283:-193" begin="190:-230" end="440:-200" stroke-style="solid" fill="#ff000000"/>
            <line stroke="#ff000000" id="{e6fc3040-5928-461f-b65f-204f97498393}" fill-style="none" stroke-width="10" begin="190:-230" end="30:-250" stroke-style="solid" fill="#ff000000"/>
            <cubicBezier stroke="#ff000000" id="{4c99ce04-42e5-4328-8192-0c32eb63e50d}" fill-style="none" cp2="-138:-146" stroke-width="10" cp1="-210:-260" begin="30:-250" end="-400:-85" stroke-style="solid" fill="#ff000000"/>
            <cubicBezier stroke="#ff000000" id="{b84e0dc1-be9c-4a75-b5df-4e29b378f1a6}" fill-style="none" cp2="-328:199" stroke-width="10" cp1="-503:-3" begin="-400:-85" end="-210:170" stroke-style="solid" fill="#ff000000"/>
            <cubicBezier stroke="#ff000000" id="{475b88c5-8176-428c-ab1d-f82d1328a7f8}" fill-style="none" cp2="-162:-81" stroke-width="10" cp1="-123:136" begin="-210:170" end="90:0" stroke-style="solid" fill="#ff000000"/>
        </colorFields>
        <images/>
        <regions>
            <region id="start_zone" visible="true" textY="0" text="Start" type="rectangle" height="50" x="150" filled="true" y="-25" textX="0" width="50" color="#0000ff"/>
            <region id="finish" visible="true" textY="0" text="Finish" type="rectangle" height="150" x="100" filled="true" y="-75" textX="0" width="50" color="#ff0000"/>
		
            <region id="good_zone1" visible="false" textY="0" text="" type="rectangle" height="120" x="-50" filled="true" y="-60" textX="0" width="350" color="yellow"/>
            <region id="good_zone2" visible="false" textY="0" text="" type="rectangle" height="400" x="300" filled="true" y="-325" textX="0" width="200" color="yellow"/>
		    <region id="good_zone3" visible="false" textY="0" text="" type="rectangle" height="120" x="-100" filled="true" y="-300" textX="0" width="400" color="yellow"/>
            <region id="good_zone4" visible="false" textY="0" text="" type="rectangle" height="200" x="-250" filled="true" y="-290" textX="0" width="150" color="yellow"/>
            <region id="good_zone5" visible="false" textY="0" text="" type="rectangle" height="100" x="-300" filled="true" y="-175" textX="0" width="50" color="yellow"/>
            <region id="good_zone6" visible="false" textY="0" text="" type="rectangle" height="100" x="-350" filled="true" y="-160" textX="0" width="50" color="yellow"/>
            <region id="good_zone7" visible="false" textY="0" text="" type="rectangle" height="300" x="-475" filled="true" y="-150" textX="0" width="125" color="yellow"/>
            <region id="good_zone8" visible="false" textY="0" text="" type="rectangle" height="125" x="-350" filled="true" y="75" textX="0" width="50" color="yellow"/>

            <region id="good_zone9" visible="false" textY="0" text="" type="rectangle" height="125" x="-300" filled="true" y="100" textX="0" width="50" color="yellow"/>
            <region id="good_zone10" visible="false" textY="0" text="" type="rectangle" height="125" x="-250" filled="true" y="90" textX="0" width="50" color="yellow"/>
            <region id="good_zone11" visible="false" textY="0" text="" type="rectangle" height="200" x="-200" filled="true" y="25" textX="0" width="50" color="yellow"/>
            <region id="good_zone12" visible="false" textY="0" text="" type="rectangle" height="220" x="-150" filled="true" y="-50" textX="0" width="50" color="yellow"/>
            <region id="good_zone13" visible="false" textY="0" text="" type="rectangle" height="150" x="-100" filled="true" y="-50" textX="0" width="50" color="yellow"/>

		</regions>
    </world>
    <robots>
        <robot id="trikKitRobot" direction="0" position="150.055:-22.2153">
            <sensors>
                <sensor type="trik::robotModel::parts::TrikLightSensor" port="A5###input###А5###sensorA5" direction="0" position="64:5"/>
                <sensor type="trik::robotModel::parts::TrikLightSensor" port="A6###input###А6###sensorA6" direction="0" position="64:44"/>
                <sensor type="kitBase::robotModel::robotParts::Motor" port="M4###output###М4###" direction="0" position="75:25"/>
                <sensor type="kitBase::robotModel::robotParts::Motor" port="M3###output###М3###" direction="0" position="75:25"/>
            </sensors>
            <startPosition y="2.78467" id="{ee9a32f7-c3fe-4eea-8d73-1073d9d0ea74}" x="175.055" direction="0"/>
            <wheels left="M4###output###М4###" right="M3###output###М3###"/>
        </robot>
    </robots>
    <settings realisticSensors="false" realisticMotors="false" realisticPhysics="false"/>
	<constraints>
        <!-- Лимит времени. Обязательное ограничение -->
        <timelimit value="60000"/>
        <!-- Провека, что нет датчиков, кроме 2х датчиков освещенности-->
        <constraint checkOnce="true" failMessage="У робота не должно быть датчиков, кроме 2х датчиков освещенности">
            <conditions glue="and">
                <equals>
                    <typeOf objectId="robot1.A1"/>
                    <string value="undefined"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.A2"/>
                    <string value="undefined"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.A3"/>
                    <string value="undefined"/>
                </equals>
                <equals>
                    <typeOf objectId="robot1.A4"/>
                    <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>
        <!-- Проверка, что на порт А5 и А6 установлен датчик освященности -->
        <constraint checkOnce="true" failMessage="У робота должен быть установлен датчик освещенности на портах А5 и А6">
            <conditions glue="and">
				<equals>
					<typeOf objectId="robot1.A5"/>
					<string value="trik::robotModel::twoD::parts::TwoDLightSensor"/>
				</equals>
				<equals>
					<typeOf objectId="robot1.A6"/>
					<string value="trik::robotModel::twoD::parts::TwoDLightSensor"/>
				</equals>
			</conditions>
        </constraint>
		<!-- Зональное ограничение на начало езды. Проверяется один раз в начале программы-->
        <constraint checkOnce="true" failMessage="Робот должен находиться в синей зоне перед стартом!">
            <inside regionId="start_zone" objectId="robot1"/>
        </constraint> 
		<!-- Проверяет, что робот находится в допустимом регионе на протяжении всего времени выполнения программы -->
		<constraint failMessage="Робот покинул допустимую зону!">
		<conditions glue="or">
			<inside objectId="robot1" regionId="good_zone1"/>
			<inside objectId="robot1" regionId="good_zone2"/>
			<inside objectId="robot1" regionId="good_zone3"/>
			<inside objectId="robot1" regionId="good_zone4"/>
			<inside objectId="robot1" regionId="good_zone5"/>
			<inside objectId="robot1" regionId="good_zone6"/>
			<inside objectId="robot1" regionId="good_zone7"/>
			<inside objectId="robot1" regionId="good_zone8"/>
			<inside objectId="robot1" regionId="good_zone9"/>
			<inside objectId="robot1" regionId="good_zone10"/>
			<inside objectId="robot1" regionId="good_zone11"/>
			<inside objectId="robot1" regionId="good_zone12"/>
			<inside objectId="robot1" regionId="good_zone13"/>
			</conditions>
		</constraint>
		
		<!-- Событие, которое говорит о том, что робот начал двигаться. Мощность на одном из моторов больше 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 regionId="good_zone3" objectId="robot1"/>
            </condition>
            <trigger>
				<setUp id="check2"/>
            </trigger>
        </event>
		<event id="check2">
            <condition>
                <inside regionId="good_zone6" objectId="robot1"/>
            </condition>
            <trigger>
				<setUp id="check3"/>
            </trigger>
        </event>
        <event id="check3">
            <condition>
                <inside regionId="good_zone11" objectId="robot1"/>
            </condition>
            <trigger>
				<setUp id="finish checker"/>
            </trigger>
        </event>
		<!-- Событие, оповещающее об успешном выполнении программы -->
        <event id="finish checker">
            <condition>
                <inside regionId="finish" objectId="robot1"/>
            </condition>
            <trigger>
                <success/>
            </trigger>
        </event>
    </constraints>
</root>
