<?xml version='1.0' encoding='utf-8'?>
<root version="20190819">
    <world>
        <walls/>
        <skittles/>
        <balls/>
        <colorFields>
            <cubicBezier cp2="567:-214" stroke-style="solid" stroke="#ff000000" end="641:0" cp1="-16:-172" fill-style="none" fill="#ff000000" begin="16:-171" id="{cde94fb1-256d-40e4-9324-c3ba5c467ea0}" stroke-width="9"/>
            <cubicBezier cp2="557:222" stroke-style="solid" stroke="#ff000000" end="347:163" cp1="658:66" fill-style="none" fill="#ff000000" begin="641:0" id="{273dd9b6-94b8-4809-b5bd-100fe735bd49}" stroke-width="9"/>
            <cubicBezier cp2="137:166" stroke-style="solid" stroke="#ff000000" end="-35:154" cp1="213:73" fill-style="none" fill="#ff000000" begin="347:163" id="{53e338f8-fbcf-497e-a019-5a29d8031a89}" stroke-width="9"/>
            <cubicBezier cp2="-412:-135" stroke-style="solid" stroke="#ff000000" end="16:-171" cp1="-183:171" fill-style="none" fill="#ff000000" begin="-35:154" id="{1cc38594-ceda-4437-a9f7-ebc66b0ef9f0}" stroke-width="9"/>
        </colorFields>
        <images/>
        <regions>
            <region id="start_zone" visible="true" textY="0" text="Start" type="rectangle" height="50" x="150" filled="true" y="-200" textX="0" width="50" color="#0000ff"/>
            <region id="finish" visible="true" textY="0" text="Finish" type="rectangle" height="150" x="100" filled="true" y="-250" textX="0" width="50" color="#ff0000"/>
		
            <region id="good_zone1" visible="true" textY="0" text="" type="rectangle" height="100" x="200" filled="true" y="-220" textX="0" width="50" color="yellow"/>
            <region id="good_zone2" visible="true" textY="0" text="" type="rectangle" height="100" x="250" filled="true" y="-210" textX="0" width="50" color="yellow"/>
		    <region id="good_zone3" visible="true" textY="0" text="" type="rectangle" height="100" x="300" filled="true" y="-200" textX="0" width="50" color="yellow"/>
            <region id="good_zone4" visible="true" textY="0" text="" type="rectangle" height="100" x="350" filled="true" y="-200" textX="0" width="50" color="yellow"/>
            <region id="good_zone5" visible="true" textY="0" text="" type="rectangle" height="100" x="400" filled="true" y="-190" textX="0" width="50" color="yellow"/>
            <region id="good_zone6" visible="true" textY="0" text="" type="rectangle" height="100" x="450" filled="true" y="-180" textX="0" width="50" color="yellow"/>
            <region id="good_zone7" visible="true" textY="0" text="" type="rectangle" height="100" x="500" filled="true" y="-160" textX="0" width="50" color="yellow"/>
            <region id="good_zone8" visible="true" textY="0" text="" type="rectangle" height="350" x="550" filled="true" y="-140" textX="0" width="130" color="yellow"/>

            <region id="good_zone9" visible="true" textY="0" text="" type="rectangle" height="100" x="500" filled="true" y="100" textX="0" width="50" color="yellow"/>
            <region id="good_zone10" visible="true" textY="0" text="" type="rectangle" height="100" x="450" filled="true" y="120" textX="0" width="50" color="yellow"/>
            <region id="good_zone11" visible="true" textY="0" text="" type="rectangle" height="100" x="400" filled="true" y="120" textX="0" width="50" color="yellow"/>
            <region id="good_zone12" visible="true" textY="0" text="" type="rectangle" height="100" x="350" filled="true" y="120" textX="0" width="50" color="yellow"/>
            <region id="good_zone13" visible="true" textY="0" text="" type="rectangle" height="100" x="300" filled="true" y="90" textX="0" width="50" color="yellow"/>
            <region id="good_zone14" visible="true" textY="0" text="" type="rectangle" height="100" x="250" filled="true" y="80" textX="0" width="50" color="yellow"/>

            <region id="good_zone15" visible="true" textY="0" text="" type="rectangle" height="100" x="200" filled="true" y="80" textX="0" width="50" color="yellow"/>
            <region id="good_zone16" visible="true" textY="0" text="" type="rectangle" height="100" x="150" filled="true" y="80" textX="0" width="50" color="yellow"/>
            <region id="good_zone17" visible="true" textY="0" text="" type="rectangle" height="100" x="100" filled="true" y="80" textX="0" width="50" color="yellow"/>
            <region id="good_zone18" visible="true" textY="0" text="" type="rectangle" height="100" x="50" filled="true" y="90" textX="0" width="50" color="yellow"/>
            <region id="good_zone19" visible="true" textY="0" text="" type="rectangle" height="100" x="0" filled="true" y="100" textX="0" width="50" color="yellow"/>
            <region id="good_zone20" visible="true" textY="0" text="" type="rectangle" height="100" x="-50" filled="true" y="100" textX="0" width="50" color="yellow"/>
            <region id="good_zone21" visible="true" textY="0" text="" type="rectangle" height="100" x="-100" filled="true" y="100" textX="0" width="50" color="yellow"/>
            <region id="good_zone22" visible="true" textY="0" text="" type="rectangle" height="100" x="-150" filled="true" y="70" textX="0" width="50" color="yellow"/>

            <region id="good_zone23" visible="true" textY="0" text="" type="rectangle" height="330" x="-280" filled="true" y="-180" textX="0" width="130" color="yellow"/>

            <region id="good_zone24" visible="true" textY="0" text="" type="rectangle" height="100" x="-150" filled="true" y="-190" textX="0" width="50" color="yellow"/>
            <region id="good_zone25" visible="true" textY="0" text="" type="rectangle" height="100" x="-100" filled="true" y="-210" textX="0" width="50" color="yellow"/>
            <region id="good_zone26" visible="true" textY="0" text="" type="rectangle" height="100" x="-50" filled="true" y="-220" textX="0" width="50" color="yellow"/>
            <region id="good_zone27" visible="true" textY="0" text="" type="rectangle" height="100" x="0" filled="true" y="-220" textX="0" width="50" color="yellow"/>
            <region id="good_zone28" visible="true" textY="0" text="" type="rectangle" height="100" x="50" filled="true" y="-220" textX="0" width="150" color="yellow"/>
		</regions>
    </world>
    <robots>
        <robot direction="0" position="156:-192.111" id="trikKitRobot">
            <sensors>
                <sensor direction="0" port="M3###output###М3###" position="75:25" type="kitBase::robotModel::robotParts::Motor"/>
                <sensor direction="0" port="M4###output###М4###" position="75:25" type="kitBase::robotModel::robotParts::Motor"/>
                <sensor direction="0" port="A5###input###А5###sensorA5" position="56:27" type="trik::robotModel::parts::TrikLightSensor"/>
            </sensors>
            <startPosition direction="0" y="-169" id="{7611e628-7727-492b-9a8e-609f8200c7c2}" x="181"/>
            <wheels left="M4###output###М4###" right="M3###output###М3###"/>
        </robot>
    </robots>
    <settings realisticMotors="false" realisticPhysics="false" realisticSensors="false"/>
    <constraints>
        <!-- Лимит времени. Обязательное ограничение -->
        <timelimit value="60000"/>
        <!-- Провека, что нет датчиков, кроме датчика освещенности-->
        <constraint checkOnce="true" failMessage="У робота не должно быть датчиков, кроме датчика освещенности">
            <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.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>
        <!-- Проверка, что на порт А5 установлен датчик освященности -->
        <constraint checkOnce="true" failMessage="У робота должен быть установлен датчик освещенности на порту А5">
            <equals>
                <typeOf objectId="robot1.A5"/>
                <string value="trik::robotModel::twoD::parts::TwoDLightSensor"/>
            </equals>
        </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"/>
			<inside objectId="robot1" regionId="good_zone14"/>
			<inside objectId="robot1" regionId="good_zone15"/>
			<inside objectId="robot1" regionId="good_zone16"/>
			<inside objectId="robot1" regionId="good_zone17"/>
			<inside objectId="robot1" regionId="good_zone18"/>
			<inside objectId="robot1" regionId="good_zone19"/>
			<inside objectId="robot1" regionId="good_zone20"/>
			<inside objectId="robot1" regionId="good_zone21"/>
			<inside objectId="robot1" regionId="good_zone22"/>
			<inside objectId="robot1" regionId="good_zone23"/>
			<inside objectId="robot1" regionId="good_zone24"/>
			<inside objectId="robot1" regionId="good_zone25"/>
			<inside objectId="robot1" regionId="good_zone26"/>
			<inside objectId="robot1" regionId="good_zone27"/>
			<inside objectId="robot1" regionId="good_zone28"/>
			</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_zone9" objectId="robot1"/>
            </condition>
            <trigger>
				<setUp id="check2"/>
            </trigger>
        </event>
        <event id="check2">
            <condition>
                <inside regionId="good_zone22" 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>
