
rel_pitot = globalPropertyi("sim/operation/failures/rel_pitot")
rel_pitot2 = globalPropertyi("sim/operation/failures/rel_pitot2")
heat_on_1 = globalPropertyi("sim/cockpit/switches/pitot_heat_on")
heat_on_2 = globalPropertyi("sim/cockpit/switches/pitot_heat_on2")
airspeed_kts_pilot = globalPropertyf("sim/cockpit2/gauges/indicators/airspeed_kts_pilot")


local maxPitotHeat1 = 120
local maxPitotHeat2 = 120


function onAvionicsDone()
end

function checkPitot()
	if get(heat_on_1) > 0 then
		if get(airspeed_kts_pilot) < 108 then
			maxPitotHeat1 = maxPitotHeat1 - 1 -- TODO 1 legyen ambient temp fuggo
		else 
			maxPitotHeat1 = maxPitotHeat1 + 1
		end
		if maxPitotHeat1 <= 0 then
			set(rel_pitot, 6)
			maxPitotHeat1 = 120
		end
	end

	if get(heat_on_2) > 0 then
		if get(airspeed_kts_pilot) < 108 then
			maxPitotHeat2 = maxPitotHeat2 - 1 
		else 
			maxPitotHeat2 = maxPitotHeat2 + 1
		end
		if maxPitotHeat2 <= 0 then
			set(rel_pitot2, 6)
			maxPitotHeat2 = 120
		end
	end
end

function update()
	updateTimed(checkPitot, 1)
end

