<?xml version="1.0"?>


<!--
    Copyright License:  GPL
    Usable with FlightGear
    Property of Gerard Robin
    but  the Fresnel Lens Optical Landing System which is copied from the Nimitz Model
    by Vivian Meazza
-->


<PropertyList>

	<path>clem-superstructure.ac</path>

    <nasal>
        <load>
            <![CDATA[ 
            var self = cmdarg();

	    print("Model load Clemenceau ", self.getPath());
	    var pathc = self.getPath();

	    # timescales

      	    var elevator_transit_time = 30.0;
      	    var jbd_transit_time = 5.0;

      	    # register the dialog

      	    setprop(pathc~"/dlg-name", "Clemenceau");

	    # init course control,  animation and detail properties

     	    setprop("/controls/clemenceau/lights", 0);

	    setprop("/controls/clemenceau/turn-to-launch-hdg", 0);
	    setprop("/controls/clemenceau/turn-to-recovery-hdg", 0);
	    setprop("/controls/clemenceau/turn-to-base-course", 1);


	    ################
	    #  elevators

	    setprop("/controls/clemenceau/elevator[0]/state",1);
	    setprop("/controls/clemenceau/elevator[1]/state",0);

      	    var elevator1 = aircraft.door.new(pathc~"/surface-positions/elevator[0]", elevator_transit_time, 1);
      	    var elevator2 = aircraft.door.new(pathc~"/surface-positions/elevator[1]", elevator_transit_time, 0);
      

      	    var elevator_array = [elevator1, elevator2];

	    ################
	    # jet blast deflectors

	    setprop("/controls/clemenceau/jbd[0]/state", 0);
	    setprop("/controls/clemenceau/jbd[1]/state", 0);


	    var jbd1 = aircraft.door.new(pathc~"/surface-positions/jbd[0]", jbd_transit_time, 0);
	    var jbd2 = aircraft.door.new(pathc~"/surface-positions/jbd[1]", jbd_transit_time, 0);

	 
	    var jbd_array = [jbd1, jbd2];


	    # elevator control 

	    var elevator_operate = func (i){

	    var tgt = getprop("/controls/clemenceau/elevator["~i~"]/state");
	    if (tgt == 1)
		{
		print ("Elevator ", i+1, " up.");
		elevator_array[i].open();

		}
	    else
		{
		print ("Elevator ", i+1, " down.");
		elevator_array[i].close();
		}
	    }

	    # JBD control

	    var jbd_operate = func (i) {

	    var tgt = getprop("/controls/clemenceau/jbd["~i~"]/state");
	    if (tgt == 1)
		{
		print ("JBD ", i+1, " up.");
		jbd_array[i].open();
		}
	    else
		{
		print ("JBD ", i+1, " down.");
		jbd_array[i].close();
		}

	    }


            # add AN/SPN-46 see http://chateau-logic.com/content/emesary-nasal-implementation-flightgear


            fn_an_spn_46 = getprop("/sim/fg-root") ~ "/Aircraft/Generic/an_spn_46.nas";
            io.load_nasal(fn_an_spn_46, "an_spn_46");
            var anspn = an_spn_46.ANSPN46_System.new("Clemenceau", self);
            anspn.SetChannel(2);
            var an_spn_46_timer = maketimer(6, func {
                anspn.Update();
                an_spn_46_timer.restart(anspn.GetUpdateRate());
            });
            an_spn_46_timer.restart(6);


	    # listeners

    	   var l_elev1 = setlistener("/controls/clemenceau/elevator/state", func {elevator_operate(0);},0,0);
     	   var l_elev2 = setlistener("/controls/clemenceau/elevator[1]/state", func {elevator_operate(1);},0,0);
     
	   var l_jbd1 = setlistener("/controls/clemenceau/jbd[0]/state", func {jbd_operate(0);},0,0);
	   var l_jbd2 = setlistener("/controls/clemenceau/jbd[1]/state", func {jbd_operate(1);},0,0);

        ]]>
        </load>

        <unload>
            <![CDATA[ 
            an_spn_46_timer.stop();

     	    # clean up listeners

     	    removelistener(l_elev1);
     	    removelistener(l_elev2);

     	    removelistener(l_jbd1);
     	    removelistener(l_jbd2);
            ]]>
        </unload>
    </nasal>
    
	<texture-path>Textures</texture-path>
 	<offsets>
	 	<z-m>0</z-m>
         </offsets>



	 <model>
		 <name>Wakes</name>
		 <path>Models/Geometry/Clemenceau/Models/Sillage.xml</path>
		 <offsets>
			 <x-m>0</x-m>
			 <y-m>0</y-m>
			 <z-m>0</z-m>
			 <heading-deg>0</heading-deg>
		 </offsets>
	</model>
        <model>
            <object-name>Pont</object-name>
            <path>Models/Geometry/Clemenceau/Pont.xml</path>
            <offsets>
                <x-m>0</x-m>
                <y-m>0</y-m>
                <z-m>0</z-m>
            </offsets>
	</model>
        <model>
            <object-name>Clock</object-name>
            <path>Models/Geometry/Clemenceau/Clock.xml</path>
            <offsets>
                <x-m>-11.7275</x-m>
                <y-m>10.6162</y-m>
                <z-m>19.9938</z-m>
                <heading-deg>45</heading-deg>
            </offsets>
	</model>
	<model>
		<name>Hull</name>
		<path>Models/Geometry/Clemenceau/Hull.xml</path>
		<offsets>
			<x-m>0</x-m>
			<y-m>0</y-m>
			<z-m>0</z-m>
		</offsets>
	</model>
	<model>
		<name>Flols</name>
		<path>Models/Geometry/Clemenceau/Models/flols.xml</path>
		<offsets>
			<x-m>25.9119</x-m>
			<y-m>-29.5</y-m>
			<z-m>14.7</z-m>
			<heading-deg>8</heading-deg>
		</offsets>
	</model>
        <!--<model>
		<name>Glide-path</name>
		<path>Models/Geometry/Clemenceau/Models/glide-path.xml</path>
		<offsets>
			<x-m>4902.52</x-m>
			<y-m>700.906</y-m>
			<z-m>137.228</z-m>
			<heading-deg>0</heading-deg>
		</offsets>
	</model>-->

	<!--<model>
		<path>Models/Geometry/Clemenceau/Models/Aircrafts/Alouette-III/Pedro.xml</path>
		<offsets>
			<x-m>-75.5149</x-m>
			<y-m>9.29045</y-m>
			<z-m>16.3118</z-m>
			<heading-deg>0</heading-deg>
		</offsets>
	</model>-->
        <model>
            <path>Models/Geometry/Clemenceau/Tracteur.xml</path>
            <offsets>
                <x-m>-34.9154</x-m>
                <y-m>9.92806</y-m>
                <z-m>14.8311</z-m>
                <heading-deg>180</heading-deg>
            </offsets>
	</model>
        <model>
            <path>Models/Geometry/Clemenceau/Tracteur.xml</path>
            <offsets>
                <x-m>-38.3693</x-m>
                <y-m>9.92806</y-m>
                <z-m>14.8311</z-m>
                <heading-deg>0</heading-deg>
            </offsets>
	</model>
        <model>
            <path>Models/Geometry/Clemenceau/Tracteur.xml</path>
            <offsets>
                <x-m>-32.343</x-m>
                <y-m>9.92806</y-m>
                <z-m>14.8311</z-m>
                <heading-deg>180</heading-deg>
            </offsets>
	</model>
        <model>
            <path>Models/Geometry/Clemenceau/Tracteur.xml</path>
            <offsets>
                <x-m>-27.2995</x-m>
                <y-m>9.92806</y-m>
                <z-m>14.8311</z-m>
                <heading-deg>180</heading-deg>
            </offsets>
	</model>
        <model>
            <path>Models/Geometry/Clemenceau/Tracteur.xml</path>
            <offsets>
                <x-m>-48.6205</x-m>
                <y-m>17.8154</y-m>
                <z-m>14.8311</z-m>
                <heading-deg>90</heading-deg>
            </offsets>
	</model>
        <model>
            <path>Models/Geometry/Clemenceau/Grue_pont.xml</path>
            <offsets>
                <x-m>-53.805</x-m>
                <y-m>17.6369</y-m>
                <z-m>16.4886</z-m>
                <heading-deg>-45</heading-deg>
            </offsets>
	</model>
        
        
        
       <!-- <animation>
		<type>select</type>
		<object-name>Glide-path</object-name>
		<condition>
                    <equals>
				<property>/ai/models/carrier[0]/controls/glide-path</property>
                                <value>true</value>
                    </equals>
		</condition>
	</animation>-->


        <animation>
            <condition>
                <and>
                    <equals>
                        <property>/sim/model/carrier-jsbsim</property>
                        <value>1</value>
                    </equals>
                    <equals>
                        <property>/sim/carrier/name</property>
                        <value>Clemenceau</value>
                    </equals>
                </and>
            </condition>
            <type>rotate</type>
            <object-name>JBD-1</object-name>
            <property>surface-positions/jbd[0]/position-norm</property>
            <factor>70</factor>
            <axis>
                <x1-m>-61.8038</x1-m>
                <y1-m>-4.90918</y1-m>
                <z1-m>14.2877</z1-m>
                <x2-m>-59.6654</x2-m>
                <y2-m>-8.61296</y2-m>
                <z2-m>14.2877</z2-m>
            </axis>
        </animation>
    <animation>
            <condition>
                <not-equals>
                    <property>/sim/model/carrier-jsbsim</property>
                    <value>1</value>
                </not-equals>
            </condition>
	    <type>rotate</type>
	    <object-name>JBD-1</object-name>
	    <property>surface-positions/jbd[0]/position-norm</property>
	    <factor>70</factor>
	    <axis>
		    <x1-m>-61.8038</x1-m>
		    <y1-m>-4.90918</y1-m>
		    <z1-m>14.2877</z1-m>
		    <x2-m>-59.6654</x2-m>
		    <y2-m>-8.61296</y2-m>
		    <z2-m>14.2877</z2-m>
	    </axis>
    </animation>
    <animation>
        <condition>
            <and>
                <equals>
                    <property>/sim/model/carrier-jsbsim</property>
                    <value>1</value>
                </equals>
                <equals>
                    <property>/sim/carrier/name</property>
                    <value>Clemenceau</value>
                </equals>
            </and>
        </condition>
        <type>rotate</type>
        <object-name>JBD-2</object-name>
        <property>surface-positions/jbd[1]/position-norm</property>
        <factor>70</factor>
        <axis>
            <x1-m>37.4696</x1-m>
            <y1-m>-15.5491</y1-m>
            <z1-m>14.2803</z1-m>
            <x2-m>39.8606</x2-m>
            <y2-m>-19.0947</y2-m>
            <z2-m>14.2803</z2-m>
        </axis>
    </animation>
    <animation>
            <condition>
                <not-equals>
                    <property>/sim/model/carrier-jsbsim</property>
                    <value>1</value>
                </not-equals>
            </condition>
	    <type>rotate</type>
	    <object-name>JBD-2</object-name>
	    <property>surface-positions/jbd[1]/position-norm</property>
	    <factor>70</factor>
	    <axis>
		    <x1-m>37.4696</x1-m>
		    <y1-m>-15.5491</y1-m>
		    <z1-m>14.2803</z1-m>
		    <x2-m>39.8606</x2-m>
		    <y2-m>-19.0947</y2-m>
		    <z2-m>14.2803</z2-m>
	    </axis>
    </animation>
    <animation>
	    <type>translate</type>
	    <object-name>Ascenseur1</object-name>
	    <object-name>Ascenseur1-Marquage</object-name>
	    <property>surface-positions/elevator[0]/position-norm</property>
	    <factor>9.20</factor>
	    <offset-m>-9.20</offset-m>
	    <axis>
		    <x>0</x>
		    <y>0</y>
		    <z>1</z>
	    </axis>
	</animation>
	<animation>
		<type>translate</type>
		<object-name>Ascenseur2</object-name>
		<object-name>Ascenseur2-Marquage</object-name>
		<property>surface-positions/elevator[1]/position-norm</property>
		<factor>9.20</factor>
		<axis>
			<x>0</x>
			<y>0</y>
			<z>1</z>
		</axis>
	</animation>
	<animation>
		<type>rotate</type>
		<object-name>Radar-DRBI-10-avant</object-name>
		<property>/sim/time/elapsed-sec</property>
		<factor>40</factor>
		<center>
			<x-m>-32.3538</x-m>
			<y-m>15.4584</y-m>
			<z-m>0</z-m>
		</center>
		<axis>
			<x>0</x>
			<y>0</y>
			<z>1</z>
		</axis>
    </animation>
    <animation>
	    <type>rotate</type>
	    <object-name>Radar-DRBI-10-arriere</object-name>
	    <property>/sim/time/elapsed-sec</property>
	    <factor>40</factor>
	    <center>
		    <x-m>-5.0133</x-m>
		    <y-m>15.4584</y-m>
		    <z-m>0</z-m>
	    </center>
	    <axis>
		    <x>0</x>
		    <y>0</y>
		    <z>1</z>
	    </axis>
    </animation>
    <animation>
	    <type>rotate</type>
	    <object-name>Radar-DRBV23</object-name>
	    <property>/sim/time/elapsed-sec</property>
	    <factor>40</factor>
	    <center>
		    <x-m>-31.7287</x-m>
		    <y-m>15.4584</y-m>
		    <z-m>0</z-m>
	    </center>
	    <axis>
		    <x>0</x>
		    <y>0</y>
		    <z>1</z>
	    </axis>
    </animation>
    <animation>
	    <type>rotate</type>
	    <object-name>Radar-DRBV20</object-name>
	    <property>/sim/time/elapsed-sec</property>
	    <factor>40</factor>
	    <center>
		    <x-m>-19.589</x-m>
		    <y-m>15.4584</y-m>
		    <z-m>0</z-m>
	    </center>
	    <axis>
		    <x>0</x>
		    <y>0</y>
		    <z>1</z>
	    </axis>
    </animation>
    <animation>
		<type>range</type>
		<object-name>Ba-Canon1</object-name>
		<max-m>5000</max-m>
	</animation>
	<animation>
		<type>range</type>
		<object-name>Ba-Canon2</object-name>
		<max-m>5000</max-m>
	</animation>
	<animation>
		<type>range</type>
		<object-name>Tri-Canon1</object-name>
		<max-m>5000</max-m>
	</animation>
	<animation>
		<type>range</type>
		<object-name>Tri-Canon2</object-name>
		<max-m>5000</max-m>
	</animation>
	<animation>
		<type>range</type>
		<object-name>Grue</object-name>
		<max-m>5000</max-m>
	</animation>
	<animation>
		<type>range</type>
		<object-name>Tux</object-name>
		<max-m>200</max-m>
	</animation>
	<animation>
		<type>range</type>
		<object-name>JBD-2</object-name>
		<max-m>5000</max-m>
	</animation>
	<animation>
		<type>range</type>
		<object-name>JBD-1</object-name>
		<max-m>5000</max-m>
	</animation>
	<animation>
		<type>range</type>
		<object-name>Sous-pont</object-name>
		<max-m>2000</max-m>
	</animation>

	<!--<animation>
		<type>range</type>
		<object-name></object-name>
		<max-m></max-m>
	</animation>-->

	<animation>
		<type>interaction</type>
		<object-name>cat-1</object-name>
		<object-name>cat-2</object-name>
		<interaction-type>carrier-catapult</interaction-type>
	</animation>
	<animation>
		<type>interaction</type>
		<object-name>brin-1</object-name>
		<object-name>brin-2</object-name>
		<object-name>brin-3</object-name>
		<object-name>brin-4</object-name>
		<interaction-type>carrier-wire</interaction-type>
	</animation>

 <!-- elevators -->

  <animation>
    <type>pick</type>
    <object-name>Ascenseur1</object-name>
    <action>
      <button>0</button>
      <repeatable>false</repeatable>
      <binding>
	<command>property-toggle</command>
	<property>/controls/clemenceau/elevator/state</property>
      </binding>
    </action>
    <hovered>
      <binding>
        <command>set-tooltip</command>
        <tooltip-id>elev1</tooltip-id>
        <label>move elevator 1</label>
      </binding>
    </hovered>
  </animation>

  <animation>
    <type>pick</type>
    <object-name>Ascenseur2</object-name>
    <action>
      <button>0</button>
      <repeatable>false</repeatable>
      <binding>
	<command>property-toggle</command>
	<property>/controls/clemenceau/elevator[1]/state</property>
      </binding>
    </action>
    <hovered>
      <binding>
        <command>set-tooltip</command>
        <tooltip-id>elev2</tooltip-id>
        <label>move elevator 2</label>
      </binding>
    </hovered>
  </animation>


<!-- jet blast deflectors -->

<animation>
    <type>pick</type>
    <object-name>JBD-1</object-name>

    <action>
      <button>0</button>
      <repeatable>false</repeatable>
      <binding>
        <command>property-toggle</command>
	<property>/controls/clemenceau/jbd[0]/state</property>
      </binding>
    </action>
    <hovered>
      <binding>
        <command>set-tooltip</command>
        <tooltip-id>jbd1</tooltip-id>
        <label>operate JBD1</label>
      </binding>
    </hovered>
  </animation>

  <animation>
    <type>pick</type>
    <object-name>JBD-2</object-name>

    <action>
      <button>0</button>
      <repeatable>false</repeatable>
      <binding>
        <command>property-toggle</command>
	<property>/controls/clemenceau/jbd[1]/state</property>
      </binding>
    </action>
    <hovered>
      <binding>
        <command>set-tooltip</command>
        <tooltip-id>jbd2</tooltip-id>
        <label>operate JBD2</label>
      </binding>
    </hovered>
  </animation>

  <animation>
    <type>pick</type>
    <object-name>Island</object-name>
    <action>
      <button>0</button>
      <repeatable>false</repeatable>
      <binding>
	<command>dialog-show</command>
	<dialog-name>Clemenceau</dialog-name>
	<property></property>
      </binding>
    </action>
    <hovered>
      <binding>
        <command>set-tooltip</command>
        <tooltip-id>bridge</tooltip-id>
        <label>show Clemenceau control dialog</label>
      </binding>
    </hovered>
  </animation>

</PropertyList>