From ea68e91ef96ae2c17b22d4cadfb05bf86b84b5fc Mon Sep 17 00:00:00 2001 From: ulteq Date: Sat, 16 May 2015 11:13:54 +0200 Subject: [PATCH] Refactored and expanded the kestrel data collection --- addons/kestrel4500/XEH_postInit.sqf | 4 +- .../kestrel4500/functions/fnc_collectData.sqf | 77 ++++++++----------- 2 files changed, 34 insertions(+), 47 deletions(-) diff --git a/addons/kestrel4500/XEH_postInit.sqf b/addons/kestrel4500/XEH_postInit.sqf index 22465bc4e0..674e8c5026 100644 --- a/addons/kestrel4500/XEH_postInit.sqf +++ b/addons/kestrel4500/XEH_postInit.sqf @@ -4,8 +4,8 @@ GVAR(Menus) = ["Direction", "Wind SPD m/s", "CROSSWIND m/s", "HEADWIND m/s", "TEMP °C", "CHILL °C", "HUMIDITY %", "HEAT INDEX °C", "DEW POINT °C", "WET BULB °C", "BARO hPA", "ALTITUDE m", "User Screen 1", "User Screen 2"]; -GVAR(TOTAL) = [0, 0, 0, 0, 0, 0, 0, 0]; -GVAR(ENTRIES) = [0, 0, 0, 0, 0, 0, 0, 0]; +GVAR(TOTAL) = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; +GVAR(ENTRIES) = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; GVAR(MinAvgMax) = false; GVAR(MinAvgMaxMode) = 0; diff --git a/addons/kestrel4500/functions/fnc_collectData.sqf b/addons/kestrel4500/functions/fnc_collectData.sqf index 60bab4b9ec..8e19b93f22 100644 --- a/addons/kestrel4500/functions/fnc_collectData.sqf +++ b/addons/kestrel4500/functions/fnc_collectData.sqf @@ -14,27 +14,35 @@ */ #include "script_component.hpp" -private ["_playerAltitude", "_playerDir", "_windSpeed", "_crosswind", "_headwind", "_humidity", "_temperature", "_humidity", "_barometricPressure", "_altitude"]; +private ["_playerDir", "_playerAltitude", "_temperature", "_humidity", "_barometricPressure", "_altitude", "_chill", "_heatIndex", "_dewPoint", "_wetBulb", "_fnc_updateMemory", "_windSpeed", "_crosswind", "_headwind"]; +_playerDir = getDir ACE_player; _playerAltitude = (getPosASL ACE_player) select 2; +_temperature = _playerAltitude call EFUNC(weather,calculateTemperatureAtHeight); +_humidity = EGVAR(weather,currentHumidity); +_barometricPressure = _playerAltitude call EFUNC(weather,calculateBarometricPressure); +_altitude = EGVAR(weather,Altitude) + _playerAltitude; +_chill = [_temperature, _humidity] call EFUNC(weather,calculateWindChill); +_heatIndex = [_temperature, _humidity] call EFUNC(weather,calculateHeatIndex); +_dewPoint = [_temperature, _humidity] call EFUNC(weather,calculateDewPoint); +_wetBulb = [_temperature, _barometricPressure, _humidity] call EFUNC(weather,calculateWetBulb); if (isNil QGVAR(MIN) || isNil QGVAR(MAX)) then { - _temperature = _playerAltitude call EFUNC(weather,calculateTemperatureAtHeight); - _humidity = EGVAR(weather,currentHumidity); - _barometricPressure = _playerAltitude call EFUNC(weather,calculateBarometricPressure); - _altitude = EGVAR(weather,Altitude) + _playerAltitude; - GVAR(MIN) = [0, 0, 0, 0, _temperature, _humidity, _barometricPressure, _altitude]; - GVAR(MAX) = [0, 0, 0, 0, _temperature, _humidity, _barometricPressure, _altitude]; + GVAR(MIN) = [_playerDir, 0, 0, 0, _temperature, _chill, _humidity, _heatIndex, _dewPoint, _wetBulb, _barometricPressure, _altitude]; + GVAR(MAX) = [_playerDir, 0, 0, 0, _temperature, _chill, _humidity, _heatIndex, _dewPoint, _wetBulb, _barometricPressure, _altitude]; }; { GVAR(ENTRIES) set [_x, (GVAR(ENTRIES) select _x) + 1]; -} forEach [0, 4, 5, 6 ,7]; +} forEach [0, 4, 5, 6, 7, 8, 9, 10, 11]; -// Direction -_playerDir = getDir ACE_player; -GVAR(MIN) set [0, (GVAR(MIN) select 0) min _playerDir]; -GVAR(MAX) set [0, _playerDir max (GVAR(MAX) select 0)]; -GVAR(TOTAL) set [0, (GVAR(TOTAL) select 0) + _playerDir]; +_fnc_updateMemory = { + PARAMS_2(_slot,_value); + GVAR(MIN) set [_slot, (GVAR(MIN) select _slot) min _value]; + GVAR(MAX) set [_slot, _value max (GVAR(MAX) select _slot)]; + GVAR(TOTAL) set [_slot, (GVAR(TOTAL) select _slot) + _value]; +}; + +[0, _playerDir] call _fnc_updateMemory; if (GVAR(MinAvgMaxMode) == 1) then { { @@ -43,9 +51,7 @@ if (GVAR(MinAvgMaxMode) == 1) then { // Wind SPD _windSpeed = call FUNC(measureWindSpeed); - GVAR(MIN) set [1, (GVAR(MIN) select 1) min _windSpeed]; - GVAR(MAX) set [1, _windSpeed max (GVAR(MAX) select 1)]; - GVAR(TOTAL) set [1, (GVAR(TOTAL) select 1) + _windSpeed]; + [1, _windSpeed] call _fnc_updateMemory; // CROSSWIND _crosswind = 0; @@ -54,9 +60,7 @@ if (GVAR(MinAvgMaxMode) == 1) then { } else { _crosswind = abs(sin(GVAR(RefHeading)) * _windSpeed); }; - GVAR(MIN) set [2, (GVAR(MIN) select 2) min _crosswind]; - GVAR(MAX) set [2, _crosswind max (GVAR(MAX) select 2)]; - GVAR(TOTAL) set [2, (GVAR(TOTAL) select 2) + _crosswind]; + [2, _crosswind] call _fnc_updateMemory; // HEADWIND _headwind = 0; @@ -65,31 +69,14 @@ if (GVAR(MinAvgMaxMode) == 1) then { } else { _headwind = abs(cos(GVAR(RefHeading)) * _windSpeed); }; - GVAR(MIN) set [3, (GVAR(MIN) select 3) min _headwind]; - GVAR(MAX) set [3, _headwind max (GVAR(MAX) select 3)]; - GVAR(TOTAL) set [3, (GVAR(TOTAL) select 3) + _headwind]; + [3, _headwind] call _fnc_updateMemory; }; -// TEMP -_temperature = _playerAltitude call EFUNC(weather,calculateTemperatureAtHeight); -GVAR(MIN) set [4, (GVAR(MIN) select 4) min _temperature]; -GVAR(MAX) set [4, _temperature max (GVAR(MAX) select 4)]; -GVAR(TOTAL) set [4, (GVAR(TOTAL) select 4) + _temperature]; - -// HUMIDITY -_humidity = EGVAR(weather,currentHumidity); -GVAR(MIN) set [5, (GVAR(MIN) select 5) min _humidity]; -GVAR(MAX) set [5, _humidity max (GVAR(MAX) select 5)]; -GVAR(TOTAL) set [5, (GVAR(TOTAL) select 5) + _humidity]; - -// BARO -_barometricPressure = _playerAltitude call EFUNC(weather,calculateBarometricPressure); -GVAR(MIN) set [6, (GVAR(MIN) select 6) min _barometricPressure]; -GVAR(MAX) set [6, _barometricPressure max (GVAR(MAX) select 6)]; -GVAR(TOTAL) set [6, (GVAR(TOTAL) select 6) + _barometricPressure]; - -// ALTITUDE -_altitude = EGVAR(weather,Altitude) + _playerAltitude; -GVAR(MIN) set [7, (GVAR(MIN) select 7) min _altitude]; -GVAR(MAX) set [7, _altitude max (GVAR(MAX) select 7)]; -GVAR(TOTAL) set [7, (GVAR(TOTAL) select 7) + _altitude]; \ No newline at end of file +[4, _temperature] call _fnc_updateMemory; +[5, _chill] call _fnc_updateMemory; +[6, _humidity] call _fnc_updateMemory; +[7, _heatIndex] call _fnc_updateMemory; +[8, _dewPoint] call _fnc_updateMemory; +[9, _wetBulb] call _fnc_updateMemory; +[10, _barometricPressure] call _fnc_updateMemory; +[11, _altitude] call _fnc_updateMemory;