<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="xs3p.xsl"?>
<xs:schema targetNamespace="TestBenchFailures" xmlns="TestBenchFailures" xmlns:tbf="TestBenchFailures" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vc="VhtngClasses" elementFormDefault="qualified" version="3.0.0">
	<xs:import namespace="VhtngClasses" schemaLocation="VhtngClasses.xsd"/>
	<xs:simpleType name="FailureMode">
		<xs:restriction base="xs:string">
			<xs:enumeration value="add">
				<xs:annotation>
					<xs:documentation>The value of the failure is added to the original value. 
The operation is a mathematical "+"</xs:documentation>
				</xs:annotation>
			</xs:enumeration>
			<xs:enumeration value="replace">
				<xs:annotation>
					<xs:documentation>The original value is replaced by the value of the failure</xs:documentation>
				</xs:annotation>
			</xs:enumeration>
		</xs:restriction>
	</xs:simpleType>
	<xs:element name="StartTrigger" type="StartTrigger"/>
	<xs:complexType name="StartTrigger">
		<xs:annotation>
			<xs:documentation>Start trigger starts the advanced profile.
Start trigger for basic profile is not needed, because it starts directly after the end of the previous basic profile. (which can also be from type idle)</xs:documentation>
		</xs:annotation>
		<xs:complexContent>
			<xs:extension base="Trigger">
				<xs:sequence/>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	
	<xs:element name="FailureConfiguration" type="FailureConfiguration">
		<xs:unique name="variable_name_unique">
			<xs:selector xpath="AdvancedProfile/Variable"/>
			<xs:field xpath="@name"/>
		</xs:unique>
	</xs:element>
		<xs:complexType name="FailureConfiguration">
		<xs:annotation>
			<xs:documentation>The failure configuration is separated from the TestBenchConfiguration, because with the same configuration it should be possible to drive several failures.
A whole failure profile can be defined with the counting attributes and classes.</xs:documentation>
		</xs:annotation>
		<xs:complexContent>
			<xs:extension base="vc:GeneralInformation">
				<xs:sequence>
					
					<xs:element name="AdvancedProfile" type="AdvancedProfile" minOccurs="0" maxOccurs="unbounded">
						<xs:unique name="basic_prof_idx">
							<xs:selector xpath="BasicProfile"/>
							<xs:field xpath="@index"/>
						</xs:unique>
					</xs:element>
					</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:element name="AdvancedProfile" type="AdvancedProfile"/>
	<xs:complexType name="AdvancedProfile">
		<xs:annotation>
			<xs:documentation>An advanced profile is a sequence of basic profiles. 
The reference to all variables which are used in the advanced profile, has to be given here.</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="Variable" type="Variable" minOccurs="0" maxOccurs="unbounded"/>
			<xs:element name="StartTrigger" type="StartTrigger" minOccurs="0" maxOccurs="unbounded"/>
			<xs:element name="StopTrigger" type="StopTrigger" minOccurs="0" maxOccurs="unbounded"/>
			<xs:element name="BasicProfile" type="BasicProfile" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
	</xs:complexType>
	<xs:element name="BasicProfile" type="BasicProfile"/>
	<xs:complexType name="BasicProfile">
		<xs:annotation>
			<xs:documentation>A basic profile describes one specific failure. If a changing failure profile is needed, several basic profiles need to be combined to an advanced profile.</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="duration" type="xs:double" minOccurs="1" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>duration of the profile in seconds.</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="mode" type="FailureMode" minOccurs="1" maxOccurs="1"/>
			<xs:choice minOccurs="1" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>Each basic profile can be only of one type.</xs:documentation>
				</xs:annotation>
				<xs:element name="Const" type="Const" minOccurs="0" maxOccurs="1"/>
				<xs:element name="Noise" type="Noise" minOccurs="0" maxOccurs="1"/>
				<xs:element name="Ramp" type="Ramp" minOccurs="1" maxOccurs="1"/>
				<xs:element name="RampSlope" type="RampSlope" minOccurs="1" maxOccurs="1"/>
				<xs:element name="SawTooth" type="SawTooth" minOccurs="1" maxOccurs="1"/>
				<xs:element name="Pulse" type="Pulse" minOccurs="1" maxOccurs="1"/>
				<xs:element name="Exponential" type="Exponential" minOccurs="1" maxOccurs="1"/>
				<xs:element name="Sine" type="Sine" minOccurs="1" maxOccurs="1"/>
				<xs:element name="Idle" type="Idle" minOccurs="1" maxOccurs="1"/>
				<xs:element name="A664" type="A664" minOccurs="0" maxOccurs="unbounded"/>
				<xs:element name="Can" type="Can" minOccurs="0" maxOccurs="unbounded"/>
				<xs:element name="A429" type="A429" minOccurs="0" maxOccurs="unbounded"/>
				<xs:element name="FileReference" type="FileReference" minOccurs="1" maxOccurs="1"/>
			</xs:choice>
			<xs:element name="StopTrigger" type="StopTrigger" minOccurs="0" maxOccurs="unbounded"/>
			<xs:element name="Variable" type="Variable" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="index" use="required" type="xs:int">
			<xs:annotation>
				<xs:documentation>The index defines the order of the basic profiles within one advanced profile. The index has to be unique within one advanced profile.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>
	<xs:element name="Const" type="Const"/>
	<xs:complexType name="Const">
		<xs:annotation>
			<xs:documentation>Constant Profile applies a constant value</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="amplitude" type="xs:double" minOccurs="1" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>The value of the injected failure</xs:documentation>
				</xs:annotation>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
	<xs:element name="Noise" type="Noise"/>
	<xs:complexType name="Noise">
		<xs:annotation>
			<xs:documentation>To apply a defined noise on the signal</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="mean" type="xs:double" minOccurs="1" maxOccurs="1"/>
			<xs:element name="seed" type="xs:double" minOccurs="1" maxOccurs="1"/>
			<xs:element name="sigma" type="xs:double" minOccurs="1" maxOccurs="1"/>
		</xs:sequence>
	</xs:complexType>
	<xs:element name="Ramp" type="Ramp"/>
	<xs:complexType name="Ramp">
		<xs:annotation>
			<xs:documentation>A ramp profile defined by its initial and final values according to the following formula: y=(stop-start)/(t1-t0)*(t-t0)+start, where t0 is the instant where the profile starts and t1=t0+duration.</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="start" type="xs:double" minOccurs="0" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>Initial value of the ramp (If missing, it equals 0)</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="stop" type="xs:double" minOccurs="1" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>Final value of the ramp after the duration of the profile is elapsed.</xs:documentation>
				</xs:annotation>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
	<xs:element name="RampSlope" type="RampSlope"/>
	<xs:complexType name="RampSlope">
		<xs:annotation>
			<xs:documentation>A ramp profile defined its slope and initial offset according to the following formula: y=slope*(t-t0)+offset, where t0 is the instant where the profile starts.</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="offset" type="xs:double" minOccurs="0" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>The value offset which should be applied when this profile starts (If missing the offset equals 0)</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="slope" type="xs:double" minOccurs="1" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>Rising characteristic in y/second (whereby "y" is the unit of the variable)</xs:documentation>
				</xs:annotation>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
	<xs:element name="SawTooth" type="SawTooth"/>
	<xs:complexType name="SawTooth">
		<xs:annotation>
			<xs:documentation>Saw Tooth Profile</xs:documentation>
		</xs:annotation>
		<xs:complexContent>
			<xs:extension base="PeriodicProfiles">
				<xs:sequence/>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:element name="Pulse" type="Pulse"/>
	<xs:complexType name="Pulse">
		<xs:annotation>
			<xs:documentation>Pulse Profile</xs:documentation>
		</xs:annotation>
		<xs:complexContent>
			<xs:extension base="PeriodicProfiles">
				<xs:sequence>
					<xs:element name="duty_cycle" type="xs:double" minOccurs="0" maxOccurs="1">
						<xs:annotation>
							<xs:documentation>On/Off ratio (Equals 0.5 if missing)</xs:documentation>
						</xs:annotation>
					</xs:element>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:element name="Exponential" type="Exponential"/>
	<xs:complexType name="Exponential">
		<xs:annotation>
			<xs:documentation>To apply an exponential value according to the following formula: y=start*e^(tau*(t-t0)), where t0 is the instant where the profile starts.</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="start" type="xs:double" minOccurs="1" maxOccurs="1"/>
			<xs:element name="stop" type="xs:double" minOccurs="1" maxOccurs="1"/>
			<xs:element name="tau" type="xs:double" minOccurs="1" maxOccurs="1"/>
		</xs:sequence>
	</xs:complexType>
	<xs:element name="Sine" type="Sine"/>
	<xs:complexType name="Sine">
		<xs:annotation>
			<xs:documentation>Sine Profile according to the following formula: y=amplitude*sin(2Pi((t-t0)/period+phase/360))+offset, where t0 is the instant where the profile starts.</xs:documentation>
		</xs:annotation>
		<xs:complexContent>
			<xs:extension base="PeriodicProfiles">
				<xs:sequence/>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:element name="PeriodicProfiles" type="PeriodicProfiles"/>
	<xs:complexType name="PeriodicProfiles">
		<xs:sequence>
			<xs:element name="amplitude" type="xs:double" minOccurs="1" maxOccurs="1"/>
			<xs:element name="offset" type="xs:double" minOccurs="0" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>Equals 0 if missing</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="period" type="xs:double" minOccurs="1" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>period in second</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="phase" type="xs:double" minOccurs="0" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>phase in degree (Equals 0 if missing)</xs:documentation>
				</xs:annotation>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
	<xs:element name="Idle" type="Idle"/>
	<xs:complexType name="Idle">
		<xs:annotation>
			<xs:documentation>This basic profile does nothing. I.e. the variable is not written</xs:documentation>
		</xs:annotation>
		<xs:sequence/>
	</xs:complexType>
	<xs:element name="Trigger" type="Trigger"/>
	<xs:complexType name="Trigger">
		<xs:annotation>
			<xs:documentation>Triggers can be defined on variables and on basic Profiles.
Triggers on variables have higher priority than triggers on basic profile.</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="condition" type="xs:string" minOccurs="1" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>Syntax for triggers: TBD</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="timeout" type="xs:double" minOccurs="1" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>Unit: milliseconds</xs:documentation>
				</xs:annotation>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
	<xs:element name="FailureVariable" type="FailureVariable"/>
	<xs:complexType name="FailureVariable">
		<xs:sequence/>
	</xs:complexType>
	<xs:element name="Duration" type="Duration"/>
	<xs:complexType name="Duration">
		<xs:sequence/>
	</xs:complexType>
	<xs:element name="A664" type="A664"/>
	<xs:complexType name="A664">
		<xs:annotation>
			<xs:documentation>A664 (i.e. AFDX) Profile</xs:documentation>
		</xs:annotation>
		<xs:complexContent>
			<xs:extension base="IoProfiles">
				<xs:sequence/>
				<xs:attribute name="kind" use="required" type="vc:A664Failures">
					<xs:annotation>
						<xs:documentation>One kind of A664 failures can be applied. See enumeration for detailed definition.</xs:documentation>
					</xs:annotation>
				</xs:attribute>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:element name="BasicA429Profile" type="BasicA429Profile"/>
	<xs:complexType name="BasicA429Profile">
		<xs:sequence/>
		<xs:attribute name="index" use="required" type="xs:int"/>
		<xs:attribute name="key" use="required" type="xs:string"/>
		<xs:attribute name="type" use="required" type="vc:A429Failures"/>
	</xs:complexType>
	<xs:element name="A429" type="A429"/>
	<xs:complexType name="A429">
		<xs:annotation>
			<xs:documentation>A429 Profile</xs:documentation>
		</xs:annotation>
		<xs:complexContent>
			<xs:extension base="IoProfiles">
				<xs:sequence/>
				<xs:attribute name="kind" use="required" type="vc:A429Failures">
					<xs:annotation>
						<xs:documentation>One kind of A429 failures can be applied. See enumeration for detailed definition.</xs:documentation>
					</xs:annotation>
				</xs:attribute>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:element name="Can" type="Can"/>
	<xs:complexType name="Can">
		<xs:annotation>
			<xs:documentation>CAN Profile</xs:documentation>
		</xs:annotation>
		<xs:complexContent>
			<xs:extension base="IoProfiles">
				<xs:sequence/>
				<xs:attribute name="kind" use="required" type="vc:CanFailures">
					<xs:annotation>
						<xs:documentation>One kind of CAN failures can be applied. See enumeration for detailed definition.</xs:documentation>
					</xs:annotation>
				</xs:attribute>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:element name="IoProfiles" type="IoProfiles"/>
	<xs:complexType name="IoProfiles">
		<xs:sequence>
			<xs:element name="key" type="xs:string" minOccurs="0" maxOccurs="1"/>
		</xs:sequence>
	</xs:complexType>
	<xs:element name="Variable" type="Variable"/>
	<xs:complexType name="Variable">
		<xs:sequence>
			<xs:element name="reference_variable" type="xs:string" minOccurs="0" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>Variable, which is used as the reference for the calculation in continuous mode.
If empty, the calculation is based on the Variable defined in the attribute name.</xs:documentation>
				</xs:annotation>
			</xs:element>
		</xs:sequence>
		<xs:attribute name="name" use="optional" type="xs:string">
			<xs:annotation>
				<xs:documentation>Name of the polluted variable</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>
	<xs:element name="StopTrigger" type="StopTrigger"/>
	<xs:complexType name="StopTrigger">
		<xs:annotation>
			<xs:documentation>For the advanced profile, the stop trigger stops the advanced profile
For the basic profile, the stop trigger stops the current basic profile.
For the advanced profile, the stop trigger stops the advanced profie.</xs:documentation>
		</xs:annotation>
		<xs:complexContent>
			<xs:extension base="Trigger">
				<xs:sequence/>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:element name="FileReference" type="FileReference"/>
	<xs:complexType name="FileReference">
		<xs:annotation>
			<xs:documentation>To reference a previous recorded file.</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="url" type="xs:anyURI" minOccurs="1" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>URL which points to the data file with recorded data.
File format is a VHTNG recording file, which is TBD</xs:documentation>
				</xs:annotation>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
</xs:schema>
