<?xml version="1.0"?>
<!--
    usable with flightgear or JSBSim stand-alone
    COPYRIGHT gerard robin  23-03-2010
    under license:  GPL v2


    Replace FlightGear_generic-electric.xml file
-->

<system name="electrical">


    <property>electrical/circuit-breakers/cabin-lights-pwr</property>
    <property>electrical/circuit-breakers/instr-ignition-switch</property>
    <property>electrical/switches/flashing-beacon</property>
    <property>electrical/circuit-breakers/flaps</property>
    <property>electrical/circuit-breakers/turn-coordinator</property>
    <property>electrical/switches/nav-lights</property>
    <property>electrical/circuit-breakers/instrument-lights</property>
    <property>electrical/switches/strobe-lights</property>
    <property>electrical/switches/taxi-lights</property>
    <property>electrical/switches/pitot-heat</property>
    <!--<property>electrical/lighting/landing-lights</property>-->
    
    
    
    
    <property value="0">animation/master-switch-lock-cmd</property>
    <property value="0">animation/master-switch-cmd</property>
    
    
    <channel name="Instruments">
    
    <switch name="animation/master-switch-lock">
            <default value="0"/>
            <test logic="OR" value="1">
                animation/master-switch-lock-cmd == 1
            </test>
        </switch>

        <switch name="animation/electrical-master-switch">
            <default value="0"/>
            <test logic="AND" value="1">
                animation/master-switch-lock  == 1
                animation/master-switch-cmd == 1
            </test>
            <output>animation/master-switch-cmd</output>
        </switch>


        <!--FIXME temporary placed in electrical-fdm-->
        <kinematic name="electrical/switch/master-timer">
            <input>animation/electrical-master-switch</input>
            <traverse>
                <setting>
                    <position>0</position>
                    <time>0</time>
                </setting>
                <setting>
                    <position>1</position>
                    <time>0.5</time>
                </setting>
            </traverse>
            <output>electrical/switch/master</output>
        </kinematic>

 </channel>

<channel name="electrical">



        <!--supplier-->
        <switch name="electrical/supplier/battery-volts">
            <default value="0"/>
            <test  logic="AND" value="28">
                electrical/supplier/battery-on == 1
            </test>
            <output>/systems/electrical/suppliers/battery</output>
        </switch>
        <switch name="electrical/supplier/alternator-volts">
            <default value="0"/>
            <test  logic="AND" value="28.7">
                electrical/supplier/alternator-on == 1
            </test>
            <output>/systems/electrical/suppliers/alternator</output>
        </switch>
        <switch name="electrical/supplier/external-volts">
            <default value="0"/>
            <test  logic="AND" value="29">
                electrical/supplier/external-on == 1
            </test>
            <output>/systems/electrical/suppliers/external</output>
        </switch>
        <switch name="electrical/supplier/emergency-volts">
            <default value="0"/>
            <test  logic="AND" value="28.7">
                electrical/supplier/emergency-on == 1
            </test>
            <output>/systems/electrical/suppliers/emergency</output>
        </switch>

        <switch name="electrical/source-volts">
            <default value="0"/>
            <test  logic="AND" value="electrical/supplier/battery-volts">
                electrical/supplier/battery-on == 1
                electrical/supplier/battery-volts gt  electrical/supplier/alternator-volts
                electrical/supplier/battery-volts gt  electrical/supplier/emergency-volts
                electrical/supplier/battery-volts gt electrical/supplier/external-volts
                electrical/switch/master == 1
            </test>
            <test  logic="AND" value="electrical/supplier/alternator-volts">
                electrical/supplier/alternator-on == 1
                electrical/switch/master == 1
            </test>
            <test  logic="AND" value="electrical/supplier/external-volts">
                electrical/supplier/external-on == 1
                electrical/switch/master == 1
            </test>
            <test  logic="AND" value="electrical/supplier/emergency-volts">
                electrical/supplier/emergency-on == 1
                electrical/switch/master == 1
            </test>
        </switch>



        <!--bus-->
        <switch name="electrical/bus/master-volts">
            <default value="0"/>
            <test  logic="AND" value="electrical/source-volts">
                electrical/switch/master == 1
            </test>
        </switch>

        <switch name="electrical/bus/master-avionic-volts">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/switch/master == 1
            </test>
        </switch>

        <switch name="electrical/bus/auxiliary-volts">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/switch/master == 1
            </test>
        </switch>

       <!-- temporary-->
       <switch name="electrical/generic/outputs-on">
           <default value="0"/>
           <test  logic="AND" value="1">
               electrical/switch/master == 1
           </test>
        </switch>


        <switch name="electrical/avionic/instruments-on">
            <default value="0"/>
            <test  logic="AND" value="1">
                electrical/switch/master == 1
            </test>
        </switch>

        <switch name="master avionics">
            <default value="0"/>
            <test  logic="AND" value="1">
                electrical/switch/master == 1
            </test>
            <output>electrical/switches/master-avionics</output>
        </switch>
        <!-- ==================from generic-electrical===not useful at the moment,  wants to be included  later on  with switches and breaker systems===============-->
        <switch name="electrical/generic/cabin-lights-power">
            <default value="0"/>
            <test  logic="AND" value="1">
                electrical/circuit-breakers/cabin-lights-pwr == 1
            </test>
        </switch>

        <switch name="electrical/generic/instrument-power">
            <default value="0"/>
            <test  logic="AND" value="1">
                electrical/circuit-breakers/instr-ignition-switch == 1
            </test>
        </switch>

        <switch name="electrical/generic/fuel-pump-power">
            <default value="0"/>
            <test  logic="AND" value="1">
                electrical/propulsion/engine[0]/fuel-pump == 1
            </test>
        </switch>

        <switch name="electrical/generic/landing-light-power">
            <default value="0"/>
            <test  logic="AND" value="1">
                electrical/lighting/landing-lights == 1
            </test>
        </switch>

        <switch name="electrical/generic/beacon-power">
            <default value="0"/>
            <test  logic="AND" value="1">
                electrical/lighting/beacon == 1
            </test>
        </switch>
	
	<switch name="electrical/generic/position-light">
            <default value="0"/>
            <test  logic="AND" value="1">
                electrical/lighting/position-lights == 1
            </test>
        </switch>

        <switch name="electrical/generic/flaps-power">
            <default value="0"/>
            <test  logic="AND" value="1">
                electrical/circuit-breakers/flaps == 1
            </test>
        </switch>

        <switch name="electrical/generic/turn-coordinator-power">
            <default value="0"/>
            <test  logic="AND" value="1">
                electrical/circuit-breakers/turn-coordinator == 1
            </test>
        </switch>

        <switch name="electrical/generic/map-lights-power">
            <default value="0"/>
            <test  logic="AND" value="1">
                electrical/switches/nav-lights == 1
            </test>
        </switch>

        <switch name="electrical/generic/instrument-lights-power">
            <default value="0"/>
            <test  logic="AND" value="1">
                electrical/circuit-breakers/instrument-lights == 1
            </test>
        </switch>
	

        <switch name="electrical/generic/strobe-lights-power">
            <default value="0"/>
            <test  logic="AND" value="1">
                electrical/switches/strobe-lights == 1
            </test>
        </switch>

        <switch name="electrical/generic/taxi-lights-power">
            <default value="0"/>
            <test  logic="AND" value="1">
                electrical/switches/taxi-lights  == 1
            </test>
        </switch>

        <switch name="electrical/generic/pitot-heat-power">
            <default value="0"/>
            <test  logic="AND" value="1">
                electrical/switches/pitot-heat  == 1
            </test>
        </switch>
	
	
	!-- =====================================-->
       
        <switch name="electrical/generic/outputs-starter-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/generic/outputs-on  == 1
            </test>
	    <output>electrical/outputs/starter[0]</output>
        </switch>

        <switch name="electrical/generic/outputs-cabin-l">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/generic/outputs-on  == 1
            </test>
	    <output>electrical/outputs/cabin-lights</output>
        </switch>

        <switch name="electrical/generic/outputs-ignition-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/generic/outputs-on  == 1
            </test>
	    <output>electrical/outputs/instr-ignition-switch</output>
        </switch>

        <switch name="electrical/generic/outputs-pump">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/generic/outputs-on  == 1
            </test>
	    <output>electrical/outputs/fuel-pump</output>
        </switch>

        <switch name="electrical/generic/outputs-pump-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/generic/outputs-on  == 1
            </test>
	    <output>electrical/outputs/refuel-pump</output>
        </switch>

        <switch name="electrical/generic/outputs-landing-l">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/generic/outputs-on  == 1
            </test>
	    <output>electrical/outputs/landing-light</output>
        </switch>

        <switch name="electrical/generic/outputs-beacon-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/generic/outputs-on  == 1
            </test>
	    <output>electrical/outputs/beacon</output>
        </switch>

        <switch name="electrical/generic/outputs-flaps-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/generic/outputs-on  == 1
            </test>
	    <output>electrical/outputs/flaps</output>
        </switch>


        <switch name="electrical/generic/outputs-turn">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/generic/outputs-on  == 1
            </test>
	    <output>electrical/outputs/turn-coordinator</output>
        </switch>

        <switch name="electrical/generic/outputs-map-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/generic/outputs-on  == 1
            </test>
	    <output>electrical/outputs/map-lights</output>
        </switch>

        <switch name="electrical/generic/outputs-instrument-l">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/generic/outputs-on  == 1
            </test>
	    <output>electrical/outputs/instrument-lights</output>
        </switch>

        <switch name="electrical/generic/outputs-strobe-l">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/generic/outputs-on  == 1
            </test>
	     <output>electrical/outputs/strobe-lights</output>
        </switch>
	
	<switch name="electrical/generic/outputs-position-l">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/generic/outputs-on  == 1
            </test>
	     <output>electrical/outputs/position-lights</output>
        </switch>

        <switch name="electrical/generic/outputs-taxi-l">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/generic/outputs-on  == 1
            </test>
	    <output>electrical/outputs/taxi-lights</output>
        </switch>

        <switch name="electrical/generic/outputs-pitot-h">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/generic/outputs-on  == 1
            </test>
	    <output>electrical/outputs/pitot-heat</output>
        </switch>

        <switch name="electrical/avionic/instruments-radar-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/avionic/instruments-on  == 1
            </test>
	    <output>electrical/outputs/radar</output>
        </switch>

        <switch name="electrical/avionic/instruments-fan-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/avionic/instruments-on  == 1
            </test>
	    <output>electrical/outputs/avionics-fan</output>
        </switch>

        <switch name="electrical/avionic/instruments-mfd-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/avionic/instruments-on  == 1
            </test>
	    <output>electrical/outputs/gps-mfd</output>
        </switch>

        <switch name="electrical/avionic/instruments-gps-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/avionic/instruments-on  == 1
            </test>
	    <output>electrical/outputs/gps</output>
        </switch>

        <switch name="electrical/avionic/instruments-hsi-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/avionic/instruments-on  == 1
            </test>
	    <output>electrical/outputs/hsi</output>
        </switch>

        <switch name="electrical/avionic/instruments-nav0-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/avionic/instruments-on  == 1
            </test>
	    <output>electrical/outputs/nav[0]</output>
        </switch>

        <switch name="electrical/avionic/instruments-dme-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/avionic/instruments-on  == 1
            </test>
	    <output>electrical/outputs/dme</output>
        </switch>

        <switch name="electrical/avionic/instruments-audio0-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/avionic/instruments-on  == 1
            </test>
	    <output>electrical/outputs/audio-panel[0]</output>
        </switch>

        <switch name="electrical/avionic/instruments-nav1-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/avionic/instruments-on  == 1
            </test>
	    <output>electrical/outputs/nav[1]</output>
        </switch>

        <switch name="electrical/avionic/instruments-audio1-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/avionic/instruments-on  == 1
            </test>
	    <output>electrical/outputs/audio-panel[1]</output>
        </switch>

        <switch name="electrical/avionic/instruments-transponder-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/avionic/instruments-on  == 1
            </test>
	    <output>electrical/outputs/transponder</output>
        </switch>

        <switch name="electrical/avionic/instruments-autopilot-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/avionic/instruments-on  == 1
            </test>
	    <output>electrical/outputs/autopilot</output>
        </switch>

        <switch name="electrical/avionic/instruments-adf-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/avionic/instruments-on  == 1
            </test>
	    <output>electrical/outputs/adf</output>
        </switch>

        <switch name="electrical/avionic/instruments-mk_vii-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/avionic/instruments-on  == 1
            </test>
	    <output>electrical/outputs/mk-viii</output>
        </switch>

        <switch name="electrical/avionic/instruments-tacan-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/avionic/instruments-on  == 1
            </test>
	    <output>electrical/outputs/tacan</output>
        </switch>

        <switch name="electrical/avionic/instruments">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/avionic/instruments-on  == 1
            </test>
	    <output>electrical/outputs/comm</output>
        </switch>

        <switch name="electrical/avionic/instruments-comm1-v">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/avionic/instruments-on  == 1
            </test>
	    <output>electrical/outputs/comm[1]</output>
        </switch>
	
	
	

        <!-- =====================================-->
        <!--<switch name="electrical/generic/outputs">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/generic/outputs-on  == 1
            </test>
            <output>/systems/electrical/outputs/starter[0]</output>
            <output>/systems/electrical/outputs/cabin-lights</output>
            <output>/systems/electrical/outputs/instr-ignition-switch</output>
            <output>/systems/electrical/outputs/fuel-pump</output>
            <output>/systems/electrical/outputs/refuel-pump</output>
            <output>/systems/electrical/outputs/landing-light</output>
            <output>/systems/electrical/outputs/beacon</output>
            <output>/systems/electrical/outputs/flaps</output>
            <output>/systems/electrical/outputs/turn-coordinator</output>
            <output>/systems/electrical/outputs/map-lights</output>
            <output>/systems/electrical/outputs/instrument-lights</output>
            <output>/systems/electrical/outputs/strobe-lights</output>
            <output>/systems/electrical/outputs/taxi-lights</output>
            <output>/systems/electrical/outputs/pitot-heat</output>
        </switch>


        <switch name="electrical/avionic/instruments">
            <default value="0"/>
            <test  logic="AND" value="electrical/bus/master-volts">
                electrical/avionic/instruments-on  == 1
            </test>
            <output>/systems/electrical/outputs/radar</output>
            <output>/systems/electrical/outputs/avionics-fan</output>
            <output>/systems/electrical/outputs/gps-mfd</output>
            <output>/systems/electrical/outputs/gps</output>
            <output>/systems/electrical/outputs/hsi</output>
            <output>/systems/electrical/outputs/nav[0]</output>
            <output>/systems/electrical/outputs/dme</output>
            <output>/systems/electrical/outputs/audio-panel[0]</output>
            <output>/systems/electrical/outputs/nav[1]</output>
            <output>/systems/electrical/outputs/audio-panel[1]</output>
            <output>/systems/electrical/outputs/transponder</output>
            <output>/systems/electrical/outputs/autopilot</output>
            <output>/systems/electrical/outputs/adf</output>
            <output>/systems/electrical/outputs/mk-viii</output>
            <output>/systems/electrical/outputs/tacan</output>
            <output>/systems/electrical/outputs/comm</output>
            <output>/systems/electrical/outputs/comm[1]</output>
        </switch>-->

    </channel>



</system>
