<?xml version="1.0"?>
<!--
    This file is part of do228

    The do228 is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 2 of the License, or
    (at your option) any later version.

    The do228 is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with do228.  If not, see <http://www.gnu.org/licenses/>.

    Dornier DO228 simulation by Bea Wolf (D-ECHO)
    Started 06/2020
-->

<!--	Universal RCU simulation
	References:	see docs/instruments.md
	-->
				
<PropertyList>

	<path>rcu.ac</path>
	
	<!--
	#######################
		Effects	
	####################### -->
	<effect>
		<inherits-from>Aircraft/do228/Models/Effects/display-lcd</inherits-from>
		<object-name>rcu.display</object-name>
	</effect>
	
	<effect>
		<inherits-from>Effects/model-transparent</inherits-from>
		<object-name>btn.actv.lit</object-name>
		<object-name>btn.l1.lit</object-name>
		<object-name>btn.l2.lit</object-name>
		<object-name>btn.l3.lit</object-name>
		<object-name>btn.l4.lit</object-name>
		<object-name>btn.r1.lit</object-name>
		<object-name>btn.r2.lit</object-name>
		<object-name>btn.r3.lit</object-name>
		<object-name>btn.r4.lit</object-name>
	</effect>
	
	<!--
	#######################
		Animations	
	####################### -->
	<!--	Lighting	-->
	<animation>
		<type>material</type>
		<object-name>btn.actv.lit</object-name>
		<object-name>btn.l1.lit</object-name>
		<object-name>btn.l2.lit</object-name>
		<object-name>btn.l3.lit</object-name>
		<object-name>btn.l4.lit</object-name>
		<object-name>btn.r1.lit</object-name>
		<object-name>btn.r2.lit</object-name>
		<object-name>btn.r3.lit</object-name>
		<object-name>btn.r4.lit</object-name>
		<emission>
			<red>1</red>
			<green>1</green>
			<blue>1</blue>
			<factor-prop>systems/electrical/lights/panel-lights[1]</factor-prop>
		</emission>
	</animation>
	<!--	Top Row of Buttons	-->
	<animation>
		<type>pick</type>
		<object-name>btn.actv</object-name>
		<object-name>btn.actv.lit</object-name>
		<action>
			<button>0</button>
			<binding>
				<command>property-cycle</command>
				<property>instrumentation/rcu/active-selection</property>
				<value>9</value>
				<value>10</value>
				<value>11</value>
				<value>12</value>
			</binding>
			<binding>
				<command>property-assign</command>
				<property>instrumentation/rcu/buttons/actv</property>
				<value>1</value>
			</binding>
			<mod-up>
				<binding>
					<command>property-assign</command>
					<property>instrumentation/rcu/buttons/actv</property>
					<value>0</value>
				</binding>
			</mod-up>
		</action>
	</animation>
	<animation>
		<type>translate</type>
		<object-name>btn.actv</object-name>
		<object-name>btn.actv.lit</object-name>
		<property>instrumentation/rcu/buttons/actv</property>
		<factor>-0.0003</factor>
		<axis>
			<z>1</z>
		</axis>
	</animation>
	<!--	Line Select Keys	-->
	<animation>
		<type>pick</type>
		<object-name>btn.l1</object-name>
		<object-name>btn.l1.lit</object-name>
		<action>
			<button>0</button>
			<binding>
				<command>property-assign</command>
				<property>instrumentation/rcu/active-selection</property>
				<value>1</value>
			</binding>
			<binding>
				<command>property-assign</command>
				<property>instrumentation/rcu/buttons/l1</property>
				<value>1</value>
			</binding>
			<mod-up>
				<binding>
					<command>property-assign</command>
					<property>instrumentation/rcu/buttons/l1</property>
					<value>0</value>
				</binding>
			</mod-up>
		</action>
	</animation>
	<animation>
		<type>translate</type>
		<object-name>btn.l1</object-name>
		<object-name>btn.l1.lit</object-name>
		<property>instrumentation/rcu/buttons/l1</property>
		<factor>-0.0003</factor>
		<axis>
			<z>1</z>
		</axis>
	</animation>
	<animation>
		<type>pick</type>
		<object-name>btn.l2</object-name>
		<object-name>btn.l2.lit</object-name>
		<action>
			<button>0</button>
			<binding>
				<command>property-assign</command>
				<property>instrumentation/rcu/active-selection</property>
				<value>2</value>
			</binding>
			<binding>
				<command>property-assign</command>
				<property>instrumentation/rcu/buttons/l2</property>
				<value>1</value>
			</binding>
			<mod-up>
				<binding>
					<command>property-assign</command>
					<property>instrumentation/rcu/buttons/l2</property>
					<value>0</value>
				</binding>
			</mod-up>
		</action>
	</animation>
	<animation>
		<type>translate</type>
		<object-name>btn.l2</object-name>
		<object-name>btn.l2.lit</object-name>
		<property>instrumentation/rcu/buttons/l2</property>
		<factor>-0.0003</factor>
		<axis>
			<z>1</z>
		</axis>
	</animation>
	<animation>
		<type>pick</type>
		<object-name>btn.l3</object-name>
		<object-name>btn.l3.lit</object-name>
		<action>
			<button>0</button>
			<binding>
				<command>property-assign</command>
				<property>instrumentation/rcu/active-selection</property>
				<value>3</value>
			</binding>
			<binding>
				<command>property-assign</command>
				<property>instrumentation/rcu/buttons/l3</property>
				<value>1</value>
			</binding>
			<mod-up>
				<binding>
					<command>property-assign</command>
					<property>instrumentation/rcu/buttons/l3</property>
					<value>0</value>
				</binding>
			</mod-up>
		</action>
	</animation>
	<animation>
		<type>translate</type>
		<object-name>btn.l3</object-name>
		<object-name>btn.l3.lit</object-name>
		<property>instrumentation/rcu/buttons/l3</property>
		<factor>-0.0003</factor>
		<axis>
			<z>1</z>
		</axis>
	</animation>
	<animation>
		<type>pick</type>
		<object-name>btn.l4</object-name>
		<object-name>btn.l4.lit</object-name>
		<action>
			<button>0</button>
			<binding>
				<command>property-assign</command>
				<property>instrumentation/rcu/active-selection</property>
				<value>4</value>
			</binding>
			<binding>
				<command>property-assign</command>
				<property>instrumentation/rcu/buttons/l4</property>
				<value>1</value>
			</binding>
			<mod-up>
				<binding>
					<command>property-assign</command>
					<property>instrumentation/rcu/buttons/l4</property>
					<value>0</value>
				</binding>
			</mod-up>
		</action>
	</animation>
	<animation>
		<type>translate</type>
		<object-name>btn.l4</object-name>
		<object-name>btn.l4.lit</object-name>
		<property>instrumentation/rcu/buttons/l4</property>
		<factor>-0.0003</factor>
		<axis>
			<z>1</z>
		</axis>
	</animation>
	<animation>
		<type>pick</type>
		<object-name>btn.r1</object-name>
		<object-name>btn.r1.lit</object-name>
		<action>
			<button>0</button>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>5</value>
					</equals>
				</condition>
				<command>property-swap</command>
				<property>/instrumentation/comm[0]/frequencies/selected-mhz</property>
				<property>/instrumentation/comm[0]/frequencies/standby-mhz</property>
			</binding>
			<binding>
				<condition>
					<not-equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>5</value>
					</not-equals>
				</condition>
				<command>property-assign</command>
				<property>instrumentation/rcu[0]/active-selection</property>
				<value>5</value>
			</binding>
			<binding>
				<command>property-assign</command>
				<property>instrumentation/rcu/buttons/r1</property>
				<value>1</value>
			</binding>
			<mod-up>
				<binding>
					<command>property-assign</command>
					<property>instrumentation/rcu/buttons/r1</property>
					<value>0</value>
				</binding>
			</mod-up>
		</action>
	</animation>
	<animation>
		<type>translate</type>
		<object-name>btn.r1</object-name>
		<object-name>btn.r1.lit</object-name>
		<property>instrumentation/rcu/buttons/r1</property>
		<factor>-0.0003</factor>
		<axis>
			<z>1</z>
		</axis>
	</animation>
	<animation>
		<type>pick</type>
		<object-name>btn.r2</object-name>
		<object-name>btn.r2.lit</object-name>
		<action>
			<button>0</button>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu/active-selection</property>
						<value>6</value>
					</equals>
				</condition>
				<command>property-swap</command>
				<property>/instrumentation/nav[0]/frequencies/selected-mhz</property>
				<property>/instrumentation/nav[0]/frequencies/standby-mhz</property>
			</binding>
			<binding>
				<condition>
					<not-equals>
						<property>instrumentation/rcu/active-selection</property>
						<value>6</value>
					</not-equals>
				</condition>
				<command>property-assign</command>
				<property>instrumentation/rcu/active-selection</property>
				<value>6</value>
			</binding>
			<binding>
				<command>property-assign</command>
				<property>instrumentation/rcu/buttons/r2</property>
				<value>1</value>
			</binding>
			<mod-up>
				<binding>
					<command>property-assign</command>
					<property>instrumentation/rcu/buttons/r2</property>
					<value>0</value>
				</binding>
			</mod-up>
		</action>
	</animation>
	<animation>
		<type>translate</type>
		<object-name>btn.r2</object-name>
		<object-name>btn.r2.lit</object-name>
		<property>instrumentation/rcu/buttons/r2</property>
		<factor>-0.0003</factor>
		<axis>
			<z>1</z>
		</axis>
	</animation>
	<animation>
		<type>pick</type>
		<object-name>btn.r3</object-name>
		<object-name>btn.r3.lit</object-name>
		<action>
			<button>0</button>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu/active-selection</property>
						<value>7</value>
					</equals>
				</condition>
				<command>property-swap</command>
				<property>/instrumentation/adf[0]/frequencies/selected-khz</property>
				<property>/instrumentation/adf[0]/frequencies/standby-khz</property>
			</binding>
			<binding>
				<condition>
					<not-equals>
						<property>instrumentation/rcu/active-selection</property>
						<value>7</value>
					</not-equals>
				</condition>
				<command>property-assign</command>
				<property>instrumentation/rcu/active-selection</property>
				<value>7</value>
			</binding>
			<binding>
				<command>property-assign</command>
				<property>instrumentation/rcu/buttons/r3</property>
				<value>1</value>
			</binding>
			<mod-up>
				<binding>
					<command>property-assign</command>
					<property>instrumentation/rcu/buttons/r3</property>
					<value>0</value>
				</binding>
			</mod-up>
		</action>
	</animation>
	<animation>
		<type>translate</type>
		<object-name>btn.r3</object-name>
		<object-name>btn.r3.lit</object-name>
		<property>instrumentation/rcu/buttons/r3</property>
		<factor>-0.0003</factor>
		<axis>
			<z>1</z>
		</axis>
	</animation>
	<animation>
		<type>pick</type>
		<object-name>btn.r4</object-name>
		<object-name>btn.r4.lit</object-name>
		<action>
			<button>0</button>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu/active-selection</property>
						<value>8</value>
					</equals>
				</condition>
				<command>property-swap</command>
				<property>/instrumentation/transponder[0]/inputs/id-code-standby</property>
				<property>/instrumentation/transponder[0]/id-code</property>
			</binding>
			<binding>
				<condition>
					<not-equals>
						<property>instrumentation/rcu/active-selection</property>
						<value>8</value>
					</not-equals>
				</condition>
				<command>property-assign</command>
				<property>instrumentation/rcu/active-selection</property>
				<value>8</value>
			</binding>
			<binding>
				<command>property-assign</command>
				<property>instrumentation/rcu/buttons/r4</property>
				<value>1</value>
			</binding>
			<mod-up>
				<binding>
					<command>property-assign</command>
					<property>instrumentation/rcu/buttons/r4</property>
					<value>0</value>
				</binding>
			</mod-up>
		</action>
	</animation>
	<animation>
		<type>translate</type>
		<object-name>btn.r4</object-name>
		<object-name>btn.r4.lit</object-name>
		<property>instrumentation/rcu/buttons/r4</property>
		<factor>-0.0003</factor>
		<axis>
			<z>1</z>
		</axis>
	</animation>
	
	<!--	Bottom Row of Buttons	-->
	<animation>
		<type>pick</type>
		<object-name>btn.id</object-name>
		<object-name>btn.id.lit</object-name>
		<action>
			<button>0</button>
			<binding>
				<command>nasal</command>
				<script>
					setprop("instrumentation/transponder/inputs/ident-btn", 1);
					settimer( func { setprop("instrumentation/transponder/inputs/ident-btn", 0); }, 18 );
				</script>
			</binding>
			<binding>
				<command>property-assign</command>
				<property>instrumentation/rcu/buttons/id</property>
				<value>1</value>
			</binding>
			<mod-up>
				<binding>
					<command>property-assign</command>
					<property>instrumentation/rcu/buttons/id</property>
					<value>0</value>
				</binding>
			</mod-up>
		</action>
	</animation>
	<animation>
		<type>translate</type>
		<object-name>btn.id</object-name>
		<object-name>btn.id.lit</object-name>
		<property>instrumentation/rcu/buttons/id</property>
		<factor>-0.0003</factor>
		<axis>
			<z>1</z>
		</axis>
	</animation>
	
	<!--	Knob	-->
	<animation>
		<type>knob</type>
		<object-name>knob.outer</object-name>
		<property>instrumentation/rcu/knob-outer</property>
		<factor>11.25</factor>	<!-- 32 detents per 360 deg -->
		<axis>
			<z>1</z>
		</axis>
		<center>
			<x-m> 0.034551 </x-m>
			<y-m> 0.0      </y-m>
		</center>
		<action>
			<binding>
				<command>property-adjust</command>
				<property>instrumentation/rcu/knob-outer</property>
				<factor>1</factor>
				<min>0</min>
				<max>32</max>
				<wrap>1</wrap>
			</binding>
			<!--	dependent on active selection	-->
			<!--	TODO 1-3 (presets) are not implemented yet	-->
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>4</value>
					</equals>
				</condition>
				<command>property-adjust</command>
				<property>instrumentation/transponder[0]/inputs/knob-mode</property>
				<factor>1</factor>
				<min>0</min>
				<max>5</max>
				<wrap>0</wrap>
			</binding>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>5</value>
					</equals>
				</condition>
				<command>property-adjust</command>
				<property>instrumentation/comm[0]/frequencies/standby-mhz</property>
				<factor>1</factor>
				<min>118.0</min>
				<max>136.99167</max>
				<wrap>true</wrap>
				<mask>integer</mask>
			</binding>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>6</value>
					</equals>
				</condition>
				<command>property-adjust</command>
				<property>instrumentation/nav[0]/frequencies/standby-mhz</property>
				<factor>1</factor>
				<min>108.0</min>
				<max>118.0</max>
				<wrap>true</wrap>
				<mask>integer</mask>
			</binding>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>7</value>
					</equals>
				</condition>
				<command>property-adjust</command>
				<property>instrumentation/adf[0]/frequencies/standby-khz</property>
				<factor>100</factor>
				<min>200</min>
				<max>1800</max>
				<resolution>1</resolution>
				<wrap>true</wrap>
			</binding>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>8</value>
					</equals>
				</condition>
				<command>property-adjust</command>
				<property>instrumentation/transponder[0]/inputs/id-code-standby</property>
				<factor>100</factor>
				<min>0</min>
				<max>7777</max>
				<resolution>1</resolution>
				<wrap>true</wrap>
			</binding>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>9</value>
					</equals>
				</condition>
				<command>property-adjust</command>
				<property>instrumentation/comm[0]/frequencies/selected-mhz</property>
				<factor>1</factor>
				<min>118.0</min>
				<max>136.99167</max>
				<wrap>true</wrap>
				<mask>integer</mask>
			</binding>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>10</value>
					</equals>
				</condition>
				<command>property-adjust</command>
				<property>instrumentation/nav[0]/frequencies/selected-mhz</property>
				<factor>1</factor>
				<min>108.0</min>
				<max>118.0</max>
				<wrap>true</wrap>
				<mask>integer</mask>
			</binding>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>11</value>
					</equals>
				</condition>
				<command>property-adjust</command>
				<property>instrumentation/adf[0]/frequencies/selected-khz</property>
				<factor>100</factor>
				<min>200</min>
				<max>1800</max>
				<resolution>1</resolution>
				<wrap>true</wrap>
			</binding>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>12</value>
					</equals>
				</condition>
				<command>property-adjust</command>
				<property>instrumentation/transponder[0]/id-code</property>
				<factor>100</factor>
				<min>0</min>
				<max>7777</max>
				<resolution>1</resolution>
				<wrap>true</wrap>
			</binding>
		</action>
	</animation>
	<animation>
		<type>knob</type>
		<object-name>knob.inner</object-name>
		<property>instrumentation/rcu/knob-inner</property>
		<factor>11.25</factor>	<!-- 32 detents per 360 deg -->
		<axis>
			<z>1</z>
		</axis>
		<center>
			<x-m> 0.034551 </x-m>
			<y-m> 0.0      </y-m>
		</center>
		<action>
			<binding>
				<command>property-adjust</command>
				<property>instrumentation/rcu/knob-inner</property>
				<factor>1</factor>
				<min>0</min>
				<max>32</max>
				<wrap>1</wrap>
			</binding>
			<!--	dependent on active selection	-->
			<!--	TODO 1-3 (presets) are not implemented yet	-->
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>4</value>
					</equals>
				</condition>
				<command>property-adjust</command>
				<property>instrumentation/transponder[0]/inputs/knob-mode</property>
				<factor>1</factor>
				<min>0</min>
				<max>5</max>
				<wrap>0</wrap>
			</binding>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>5</value>
					</equals>
				</condition>
				<command>property-adjust</command>
				<property>instrumentation/comm[0]/frequencies/standby-mhz</property>
				<factor>0.025</factor>
				<mask>decimal</mask>
			</binding>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>6</value>
					</equals>
				</condition>
				<command>property-adjust</command>
				<property>instrumentation/nav[0]/frequencies/standby-mhz</property>
				<factor>0.025</factor>
				<mask>decimal</mask>
			</binding>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>7</value>
					</equals>
				</condition>
				<command>property-adjust</command>
				<property>instrumentation/adf[0]/frequencies/standby-khz</property>
				<factor>1</factor>
				<min>200</min>
				<max>1800</max>
				<resolution>1</resolution>
				<wrap>true</wrap>
			</binding>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>8</value>
					</equals>
				</condition>
				<command>property-adjust</command>
				<property>instrumentation/transponder[0]/inputs/id-code-standby</property>
				<factor>1</factor>
				<min>0</min>
				<max>7777</max>
				<resolution>1</resolution>
				<wrap>true</wrap>
			</binding>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>9</value>
					</equals>
				</condition>
				<command>property-adjust</command>
				<property>instrumentation/comm[0]/frequencies/selected-mhz</property>
				<factor>0.025</factor>
				<mask>decimal</mask>
			</binding>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>10</value>
					</equals>
				</condition>
				<command>property-adjust</command>
				<property>instrumentation/nav[0]/frequencies/selected-mhz</property>
				<factor>0.025</factor>
				<mask>decimal</mask>
			</binding>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>11</value>
					</equals>
				</condition>
				<command>property-adjust</command>
				<property>instrumentation/adf[0]/frequencies/selected-khz</property>
				<factor>1</factor>
				<min>200</min>
				<max>1800</max>
				<resolution>1</resolution>
				<wrap>true</wrap>
			</binding>
			<binding>
				<condition>
					<equals>
						<property>instrumentation/rcu[0]/active-selection</property>
						<value>12</value>
					</equals>
				</condition>
				<command>property-adjust</command>
				<property>instrumentation/transponder[0]/id-code</property>
				<factor>1</factor>
				<min>0</min>
				<max>7777</max>
				<resolution>1</resolution>
				<wrap>true</wrap>
			</binding>
		</action>
	</animation>
	
</PropertyList>
