/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2012 RomRaider.com
*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.logger.ecu.ui.handler.dyno;
import com.romraider.logger.ecu.comms.query.Response;
import com.romraider.logger.ecu.definition.LoggerData;
import com.romraider.logger.ecu.ui.handler.DataUpdateHandler;
import com.romraider.logger.ecu.ui.tab.dyno.DynoTab;
import static java.lang.System.currentTimeMillis;
import org.apache.log4j.Logger;
import static org.apache.log4j.Logger.getLogger;
import javax.swing.SwingUtilities;
import java.util.Set;
public final class DynoUpdateHandler implements DataUpdateHandler {
private static final Logger LOGGER = getLogger(DynoUpdateHandler.class);
private static final String RPM = "P8";
private static final String VS = "P9";
private static final String IAT = "P11";
private static final String TA = "P13";
private static final String ATM = "P24";
private static final Boolean TEST = false;
private DynoTab dynoTab;
// 05 OBXT Cobb Stg1 May 2009, 3rd gear, 200 ft, 60F
private static final long[] logTime = {1, 250, 490, 750, 1000, 1230, 1480, 1720, 1980, 2220, 2470, 2690, 2940, 3170, 3420, 3660, 3920, 4160, 4400, 4650, 4890, 5120, 5370, 5610, 5860, 6130, 6370, 6620, 6860, 7090, 7330, 7600, 7840, 8090, 8330, 8570, 8820, 9050, 9290, 9580, 9830, 10070, 10330, 10560, 10810, 11050, 11290, 11580, 11790, 12040, 12280, 12560, 12790, 13040, 13320, 13550, 13780};
private static final double[] logRpm = {1690, 1733, 1776, 1852, 1935, 2004, 2091, 2148, 2241, 2325, 2405, 2496, 2597, 2754, 2871, 2943, 3093, 3243, 3350, 3475, 3617, 3780, 3843, 4025, 4125, 4234, 4355, 4511, 4618, 4720, 4835, 4947, 5067, 5138, 5254, 5351, 5485, 5581, 5642, 5735, 5816, 5939, 6041, 6104, 6183, 6280, 6347, 6406, 6483, 6548, 6651, 6693, 6800, 6870, 6924, 6974, 7079};
private static final double[] logThrottle = {49.78, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 99.96, 10};
private static final double[] logKph = {36, 37, 39, 40, 42, 43, 45, 46, 48, 50, 52, 54, 56, 59, 61, 64, 67, 70, 73, 75, 78, 81, 83, 86, 89, 92, 94, 97, 99, 102, 104, 106, 109, 111, 113, 116, 118, 120, 122, 124, 126, 128, 130, 132, 133, 135, 137, 138, 140, 141, 143, 145, 146, 148, 149, 150, 150};
// 05 LGT tingtang (http://legacygt.com/forums/showpost.php?p=2783186&postcount=185) 3rd gear, 5800ft, 45 degrees F
// private static final long[] logTime = {825, 1050, 1238, 1454, 1655, 1875, 2087, 2295, 2502, 2713, 2918, 3125, 3334, 3546, 3753, 3969, 4167, 4382, 4580, 4798, 4995, 5232, 5426, 5639, 5832, 6040, 6248, 6456, 6664, 6880, 7083, 7289, 7498, 7708, 7912, 8138, 8331, 8546, 8748, 8957, 9165, 9373, 9617, 9811, 10006, 10208, 10428, 10644, 10844, 11053, 11264, 11469, 11677};
// private static final double[] logRpm = {1417, 1476, 1538, 1570, 1645, 1656, 1708, 1778, 1826, 1872, 1945, 1989, 2057, 2114, 2157, 2232, 2314, 2368, 2421, 2509, 2604, 2685, 2752, 2857, 2944, 3058, 3166, 3311, 3424, 3524, 3676, 3826, 3897, 4055, 4153, 4321, 4430, 4569, 4704, 4870, 4951, 5117, 5249, 5372, 5504, 5568, 5710, 5841, 5904, 6050, 6105, 6216, 6305};
// private static final double[] logThrottle = {69.8, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 10};
// 06 STi collegemt (http://legacygt.com/forums/showpost.php?p=2783296&postcount=188) 4th gear, 5800ft, 45F
// private static final long[] logTime = {66875, 67110, 67360, 67594, 67844, 68094, 68344, 68594, 68828, 69094, 69328, 69563, 69813, 70063, 70313, 70563, 70797, 71047, 71282, 71532, 71782, 72016, 72266, 72500, 72750, 73000, 73250, 73485, 73735, 73985, 74235, 74469, 74719, 74969, 75203, 75453, 75703, 75938, 76188};
// private static final double[] logRpm = {1833, 1955, 2012, 2069, 2156, 2237, 2338, 2374, 2502, 2581, 2738, 2856, 2998, 3180, 3362, 3568, 3688, 3926, 4086, 4241, 4449, 4591, 4736, 4950, 5072, 5224, 5359, 5555, 5656, 5792, 5920, 6046, 6175, 6324, 6394, 6506, 6596, 6698, 6853};
// private static final double[] logThrottle = {100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 10};
// 05 OBXT Stg2 Dec 2009, 3rd gear, 200 ft, 27F
// private static final long[] logTime = {797, 953, 1109, 1281, 1437, 1593, 1765, 1922, 2078, 2234, 2390, 2547, 2718, 2875, 3031, 3203, 3359, 3515, 3672, 3828, 4000, 4156, 4312, 4484, 4640, 4797, 4953, 5109, 5281, 5437, 5593, 5765, 5906, 6078, 6234, 6390, 6547, 6718, 6875, 7031, 7203, 7359, 7515, 7672, 7828, 8000, 8156, 8312, 8468, 8640, 8797, 8953, 9109, 9281, 9437, 9593, 9750, 9922, 10078, 10234};
// private static final double[] logThrottle = {10, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 10};
// private static final double[] logRpm = {2000, 2108, 2115, 2130, 2200, 2289, 2351, 2408, 2490, 2575, 2662, 2760, 2850, 2973, 3050, 3154, 3286, 3386, 3500, 3598, 3690, 3800, 3923, 3984, 4095, 4178, 4304, 4376, 4492, 4581, 4663, 4779, 4888, 4944, 5050, 5146, 5204, 5289, 5403, 5472, 5507, 5623, 5656, 5722, 5806, 5856, 5929, 5985, 6044, 6147, 6206, 6270, 6282, 6344, 6398, 6458, 6538, 6556, 6639, 6654};
// smoothed RPM from Airboy SS
// private static final double[] logRpm = {2029, 2079.12776, 2128.70831, 2183.374046, 2232.954597, 2281.318373, 2351.923543, 2427.351978, 2506.207436, 2583.915691, 2671.162641, 2761.967057, 2862.985225, 2962.323119, 3062.697066, 3175.904917, 3281.036045, 3380.281832, 3484.964687, 3593.266196, 3700.250711, 3798.571429, 3892.575574, 4000.355604, 4096.780475, 4193.40157, 4284.464728, 4380.0873, 4484.619382, 4584.589724, 4673.170346, 4776.132747, 4859.278292, 4956.101945, 5042.857143, 5130.635704, 5212.007526, 5297.823159, 5377.854146, 5448.484312, 5527.570262, 5600.215485, 5662.965742, 5726.67913, 5794.11765, 5859.697531, 5927.956025, 5995.118562, 6059.296969, 6125.865145, 6183.582871, 6240.889946, 6298.623784, 6358.806827, 6407.230158, 6458.300943, 6510.258872, 6568.310398, 6620.961783, 6673.613168};
// 05 LGT Legend 225/40-18, 3520lbs, 62F (http://legacygt.com/forums/showpost.php?p=2414502&postcount=26)
// private static final long[] logTime = {0, 60, 120, 190, 250, 320, 401, 461, 521, 601, 651, 711, 781, 841, 901, 971, 1031, 1092, 1162, 1222, 1312, 1362, 1432, 1492, 1572, 1652, 1702, 1762, 1833, 1903, 1963, 2023, 2083, 2143, 2233, 2293, 2353, 2413, 2484, 2544, 2624, 2684, 2754, 2814, 2904, 2954, 3024, 3084, 3154, 3215, 3275, 3335, 3405, 3465, 3525, 3595, 3685, 3735, 3795, 3865, 3926, 3986, 4056, 4146, 4196, 4266, 4336, 4416, 4466, 4526, 4597, 4677, 4747, 4797, 4867, 4927, 4997, 5057, 5117, 5177, 5247, 5338, 5388, 5458, 5518, 5588, 5648, 5708, 5768, 5838, 5898, 5959, 6029, 6089, 6149, 6219, 6299, 6369, 6419, 6499, 6559, 6619, 6680, 6740, 6810, 6870, 6940, 7000, 7060, 7140, 7200, 7280, 7330, 7391, 7461, 7521, 7581, 7651, 7721, 7771, 7851, 7901, 7981, 8031, 8092, 8162, 8222, 8282, 8352, 8412, 8472, 8562, 8632, 8682, 8743, 8813, 8873, 8953, 9013, 9093, 9143, 9203, 9273, 9343, 9393, 9464, 9524, 9594, 9664, 9714, 9794, 9844, 9914, 9984, 10044, 10104, 10165, 10225, 10285, 10355, 10435, 10495, 10555, 10635, 10685, 10765, 10826, 10906, 10976};
// private static final double[] logRpm = {1896, 1924, 1951, 1952, 1968, 1987, 2012, 2003, 2015, 2028, 2068, 2073, 2062, 2081, 2088, 2124, 2141, 2136, 2174, 2182, 2209, 2204, 2246, 2246, 2277, 2284, 2314, 2313, 2352, 2351, 2392, 2396, 2424, 2465, 2450, 2520, 2509, 2551, 2586, 2573, 2607, 2660, 2686, 2727, 2740, 2778, 2810, 2826, 2876, 2890, 2942, 2962, 3024, 3064, 3070, 3152, 3174, 3215, 3290, 3291, 3352, 3388, 3436, 3476, 3531, 3553, 3618, 3669, 3720, 3773, 3800, 3822, 3894, 3922, 3933, 4022, 4076, 4050, 4162, 4141, 4190, 4238, 4296, 4338, 4367, 4440, 4442, 4474, 4554, 4584, 4632, 4672, 4706, 4755, 4783, 4817, 4869, 4875, 4948, 4954, 4993, 5070, 5074, 5139, 5132, 5217, 5212, 5292, 5272, 5369, 5362, 5432, 5460, 5520, 5471, 5522, 5563, 5588, 5631, 5650, 5733, 5711, 5800, 5841, 5848, 5836, 5905, 5945, 5925, 6012, 5996, 6060, 6047, 6117, 6099, 6172, 6168, 6201, 6218, 6238, 6312, 6344, 6324, 6350, 6407, 6436, 6472, 6448, 6466, 6491, 6508, 6536, 6560, 6586, 6607, 6633, 6697, 6719, 6738, 6760, 6733, 6759, 6844, 6851, 6818, 6836, 6864, 6900, 6929};
// private static final double[] logThrottle = {10, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 10};
// 04 WRX WGN 6MT*, 225/45/17, 48F
// private static final long[] logTime = {820,840,860,880,900,920,940,960,980,1000,1020,1040,1060,1080,1100,1120,1140,1160,1180,1200,1220,1240,1260,1280,1300,1320,1340,1360,1380,1400,1420,1440,1460,1480,1500,1520,1540,1560,1580,1600,1620,1640,1660,1680,1700,1720,1740,1760,1780,1800,1820,1840,1860,1880,1900,1920,1940,1960,1980,2000,2020,2040,2060,2080,2100,2120,2140,2160,2180,2200,2220,2240,2260,2280,2300,2320,2340,2360,2380,2400,2420,2440,2460,2480,2500,2520,2540,2560,2580,2600,2620,2640,2660,2680,2700,2720,2740,2760,2780,2800,2820,2840,2860,2880,
// 2900,2920,2940,2960,2980,3000,3020,3040,3060,3080,3100,3120,3140,3160,3180,3200,3220,3240,3260,3280,3300,3320,3340,3360,3380,3400,3420,3440,3460,3480,3500,3520,3540,3560,3580,3600,3620,3640,3660,3680,3700,3720,3740,3760,3780,3800,3820,3840,3860,3880,3900,3920,3940,3960,3980,4000,4020,4040,4060,4080,4100,4120,4140,4160,4180,4200,4220,4240,4260,4280,4300,4320,4340,4360,4380,4400,4420,4440,4460,4480,4500,4520,4540,4560,4580,4600,4620,4640,4660,4680,4700,4720,4740,4760,4780,4800,4820,4840,4860,4880,4900,4920,4940,4960,4980,
// 5000,5020,5040,5060,5080,5100,5120,5140,5160,5180,5200,5220,5240,5260,5280,5300,5320,5340,5360,5380,5400,5420,5440,5460,5480,5500,5520,5540,5560,5580,5600,5620,5640,5660,5680,5700,5720,5740,5760,5780,5800,5820,5840,5860,5880,5900,5920,5940,5960,5980,6000,6020,6040,6060,6080,6100,6120,6140,6160,6180,6200,6220,6240,6260,6280,6300,6320,6340,6360,6380,6400,6420,6440,6460,6480,6500,6520,6540,6560,6580,6600,6620,6640,6660,6680,6700,6720,6740,6760,6780,6800,6820,6840,6860,6880,6900,6920,6940,6960,6980,7000,7020,7040,7060,7080,
// 7100,7120,7140,7160,7180,7200,7220,7240,7260,7280,7300,7320,7340,7360,7380,7400,7420,7440,7460,7480,7500,7520,7540,7560,7580,7600,7620,7640,7660,7680,7700,7720,7740,7760,7780,7800,7820,7840,7860,7880,7900,7920,7940,7960,7980,8000,8020,8040,8060,8080,8100,8120,8140,8160,8180,8200,8220,8240,8260,8280,8300,8320,8340,8360,8380,8400,8420,8440,8460,8480,8500,8520,8540,8560,8580,8600,8620,8640,8660,8680,8700,8720,8740,8760,8780,8800,8820,8840,8860,8880,8900,8920,8940,8960,8980,9000,9020,9040,9060,9080,9100,9120,9140,9160,9180,
// 9200,9220,9240,9260,9280,9300,9320,9340,9360,9380,9400,9420,9440,9460,9480,9500,9520,9540,9560,9580,9600,9620,9640,9660,9680,9700,9720,9740,9760,9780,9800,9820,9840,9860,9880,9900,9920,9940,9960,9980,10000,10020,10040,10060,10080,10100,10120,10140,10160,10180,10200,10220,10240,10260,10280,10300,10320,10340,10360,10380,10400,10420,10440,10460,10480,10500,10520,10540,10560,10580,10600,10620,10640,10660,10680,10700,10720,10740,10760,10780,10800,10820,10840,10860,10880,10900,10920,10940,10960,10980,11000,11020,11040,11060,11080,11100,11120,11140,11160,11180,11200,11220,11240,11260,11280};
// private static final double[] logRpm = {1949.21875,1917.96875,1914.0625,1914.0625,1949.21875,1949.21875,1972.65625,1972.65625,1957.03125,1949.21875,1949.21875,1980.46875,1980.46875,2000,2000,1992.1875,1988.28125,1988.28125,2003.90625,2003.90625,2031.25,2027.34375,2027.34375,2019.53125,2019.53125,2039.0625,2039.0625,2062.5,2062.5,2062.5,2058.59375,2058.59375,2074.21875,2074.21875,2097.65625,2097.65625,2097.65625,2097.65625,2093.75,2109.375,2109.375,2128.90625,2128.90625,2132.8125,2132.8125,2132.8125,2148.4375,2148.4375,2164.0625,2164.0625,2171.875,2171.875,2175.78125,2175.78125,2183.59375,2199.21875,2199.21875,2214.84375,2214.84375,2214.84375,2214.84375,2214.84375,2234.375,2234.375,2253.90625,2253.90625,2257.8125,2253.90625,2253.90625,2269.53125,2269.53125,2292.96875,2292.96875,2292.96875,2292.96875,2300.78125,2300.78125,2312.5,2312.5,2332.03125,2343.75,2343.75,2343.75,2347.65625,2355.46875,2355.46875,2355.46875,2367.1875,2378.90625,2378.90625,2378.90625,2394.53125,2402.34375,2402.34375,2410.15625,2410.15625,2429.6875,2429.6875,2441.40625,2441.40625,2445.3125,2445.3125,2460.9375,2460.9375,
// 2476.5625,2476.5625,2484.375,2484.375,2500,2500,2503.90625,2503.90625,2511.71875,2511.71875,2539.0625,2539.0625,2550.78125,2550.78125,2542.96875,2566.40625,2566.40625,2566.40625,2593.75,2597.65625,2597.65625,2597.65625,2601.5625,2621.09375,2621.09375,2621.09375,2632.8125,2632.8125,2644.53125,2664.0625,2664.0625,2664.0625,2675.78125,2683.59375,2683.59375,2683.59375,2703.125,2703.125,2722.65625,2722.65625,2726.5625,2726.5625,2742.1875,2742.1875,2761.71875,2761.71875,2761.71875,2777.34375,2785.15625,2785.15625,2785.15625,2808.59375,2828.125,2828.125,2828.125,2828.125,2828.125,2839.84375,2875,2875,2875,2882.8125,2882.8125,2894.53125,2894.53125,2914.0625,2914.0625,2937.5,2937.5,2937.5,2937.5,2937.5,2968.75,2968.75,2984.375,2984.375,2992.1875,2992.1875,3011.71875,3011.71875,3031.25,3031.25,3046.875,3046.875,3062.5,3062.5,3085.9375,3085.9375,3085.9375,3101.5625,3101.5625,3113.28125,3113.28125,3136.71875,3136.71875,3136.71875,3164.0625,3167.96875,3167.96875,3167.96875,3191.40625,3191.40625,3218.75,3218.75,3218.75,
// 3218.75,3218.75,3253.90625,3253.90625,3273.4375,3273.4375,3281.25,3281.25,3281.25,3308.59375,3308.59375,3328.125,3328.125,3355.46875,3355.46875,3355.46875,3363.28125,3363.28125,3390.625,3390.625,3421.875,3421.875,3421.875,3425.78125,3425.78125,3457.03125,3457.03125,3492.1875,3492.1875,3492.1875,3492.1875,3507.8125,3507.8125,3507.8125,3523.4375,3523.4375,3570.3125,3570.3125,3589.84375,3589.84375,3589.84375,3601.5625,3601.5625,3640.625,3640.625,3671.875,3671.875,3671.875,3687.5,3687.5,3687.5,3687.5,3722.65625,3722.65625,3765.625,3765.625,3765.625,3777.34375,3777.34375,3777.34375,3843.75,3843.75,3843.75,3847.65625,3847.65625,3847.65625,3910.15625,3910.15625,3910.15625,3945.3125,3945.3125,3972.65625,3972.65625,3972.65625,4035.15625,4035.15625,4035.15625,4035.15625,4070.3125,4070.3125,4070.3125,4132.8125,4132.8125,4132.8125,4132.8125,4183.59375,4183.59375,4183.59375,4230.46875,4230.46875,4230.46875,4230.46875,4308.59375,4308.59375,4308.59375,4308.59375,4335.9375,4335.9375,4335.9375,4335.9375,4433.59375,4433.59375,4433.59375,4433.59375,4468.75,
// 4468.75,4468.75,4468.75,4554.6875,4554.6875,4554.6875,4554.6875,4609.375,4609.375,4609.375,4609.375,4609.375,4609.375,4683.59375,4683.59375,4683.59375,4683.59375,4683.59375,4792.96875,4792.96875,4792.96875,4792.96875,4792.96875,4843.75,4843.75,4843.75,4843.75,4843.75,4933.59375,4933.59375,4933.59375,4933.59375,4933.59375,5019.53125,5019.53125,5019.53125,5019.53125,5019.53125,5019.53125,5117.1875,5117.1875,5117.1875,5117.1875,5117.1875,5117.1875,5222.65625,5222.65625,5222.65625,5222.65625,5222.65625,5222.65625,5312.5,5312.5,5312.5,5312.5,5312.5,5312.5,5386.71875,5386.71875,5386.71875,5386.71875,5386.71875,5386.71875,5468.75,5468.75,5468.75,5468.75,5468.75,5468.75,5546.875,5546.875,5546.875,5546.875,5546.875,5546.875,5648.4375,5648.4375,5648.4375,5648.4375,5648.4375,5648.4375,5648.4375,5738.28125,5738.28125,5738.28125,5738.28125,5738.28125,5738.28125,5832.03125,5832.03125,5832.03125,5832.03125,5832.03125,5832.03125,5921.875,5921.875,5921.875,5921.875,5921.875,5921.875,6007.8125,6007.8125,6007.8125,6007.8125,6007.8125,
// 6007.8125,6007.8125,6121.09375,6121.09375,6121.09375,6121.09375,6121.09375,6121.09375,6148.4375,6148.4375,6148.4375,6148.4375,6148.4375,6148.4375,6246.09375,6246.09375,6246.09375,6246.09375,6246.09375,6246.09375,6246.09375,6335.9375,6335.9375,6335.9375,6335.9375,6335.9375,6335.9375,6386.71875,6386.71875,6386.71875,6386.71875,6386.71875,6386.71875,6386.71875,6492.1875,6492.1875,6492.1875,6492.1875,6492.1875,6492.1875,6492.1875,6550.78125,6550.78125,6550.78125,6550.78125,6550.78125,6550.78125,6550.78125,6640.625,6640.625,6640.625,6640.625,6640.625,6640.625,6640.625,6710.9375,6710.9375,6710.9375,6710.9375,6710.9375,6710.9375,6710.9375,6804.6875,6804.6875,6804.6875,6804.6875,6804.6875,6804.6875,6804.6875,6878.90625,6878.90625,6878.90625,6878.90625,6878.90625,6878.90625,6878.90625,6960.9375,6960.9375,6960.9375,6960.9375,6960.9375,6960.9375,6960.9375,7031.25,7031.25,7031.25,7031.25,7031.25,7031.25,7031.25,7085.9375,7085.9375,7085.9375,7085.9375,7085.9375,7085.9375,7085.9375,7171.875,7171.875,7171.875,7171.875,7171.875,7171.875,7171.875,6574.21875};
// private static final double[] logThrottle = {83.33282,92.70782,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,
// 99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,
// 99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,
// 99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,
// 99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,97.17255,97.17255,97.17255,97.17255,97.17255,97.17255,97.17255,0.44556};
// 06 STi MT6, 225/45/17, 50F
// private static final long[] logTime = {600,620,640,660,680,700,720,740,760,780,800,820,840,860,880,900,920,940,960,980,1000,1020,1040,1060,1080,1100,1120,1140,1160,1180,1200,1220,1240,1260,1280,1300,1320,1340,1360,1380,1400,1420,1440,1460,1480,1500,1520,1540,1560,1580,1600,1620,1640,1660,1680,1700,1720,1740,1760,1780,1800,1820,1840,1860,1880,1900,1920,1940,1960,1980,2000,2020,2040,2060,2080,2100,2120,2140,2160,2180,2200,2220,2240,2260,2280,2300,2320,2340,2360,2380,2400,2420,2440,2460,2480,2500,2520,2540,2560,2580,2600,2620,2640,2660,2680,2700,2720,2740,2760,2780,2800,2820,2840,2860,2880,2900,2920,2940,2960,2980,3000,3020,3040,3060,3080,3100,3120,3140,3160,3180,3200,3220,3240,3260,3280,3300,3320,3340,3360,3380,3400,3420,3440,3460,3480,3500,3520,3540,3560,3580,3600,3620,3640,3660,3680,3700,3720,3740,3760,3780,3800,3820,3840,3860,3880,3900,3920,3940,3960,3980,4000,4020,4040,4060,4080,4100,4120,4140,4160,4180,
// 4200,4220,4240,4260,4280,4300,4320,4340,4360,4380,4400,4420,4440,4460,4480,4500,4520,4540,4560,4580,4600,4620,4640,4660,4680,4700,4720,4740,4760,4780,4800,4820,4840,4860,4880,4900,4920,4940,4960,4980,5000,5020,5040,5060,5080,5100,5120,5140,5160,5180,5200,5220,5240,5260,5280,5300,5320,5340,5360,5380,5400,5420,5440,5460,5480,5500,5520,5540,5560,5580,5600,5620,5640,5660,5680,5700,5720,5740,5760,5780,5800,5820,5840,5860,5880,5900,5920,5940,5960,5980,6000,6020,6040,6060,6080,6100,6120,6140,6160,6180,6200,6220,6240,6260,6280,6300,6320,6340,6360,6380,6400,6420,6440,6460,6480,6500,6520,6540,6560,6580,6600,6620,6640,6660,6680,6700,6720,6740,6760,6780,6800,6820,6840,6860,6880,6900,6920,6940,6960,6980,7000,7020,7040,7060,7080,7100,7120,7140,7160,7180,7200,7220,7240,7260,7280,7300,7320,7340,7360,7380,7400,7420,7440,7460,7480,7500,7520,7540,7560,7580,7600,7620,7640,7660,7680,7700,7720,7740,7760,7780,
// 7800,7820,7840,7860,7880,7900,7920,7940,7960,7980,8000,8020,8040,8060,8080,8100,8120,8140,8160,8180,8200,8220,8240,8260,8280,8300,8320,8340,8360,8380,8400,8420,8440,8460,8480,8500,8520,8540,8560,8580,8600,8620,8640,8660,8680,8700,8720,8740,8760,8780,8800,8820,8840,8860,8880,8900,8920,8940,8960,8980,9000,9020,9040,9060,9080,9100,9120,9140,9160,9180,9200,9220,9240,9260,9280,9300,9320,9340,9360,9380,9400,9420,9440,9460,9480,9500,9520,9540,9560,9580,9600,9620,9640,9660,9680,9700,9720,9740,9760,9780,9800,9820,9840,9860,9880,9900,9920,9940,9960,9980,10000,10020,10040,10060,10080,10100,10120,10140,10160,10180,10200,10220,10240,10260,10280,10300,10320,10340,10360,10380,10400,10420,10440,10460,10480,10500,10520,10540,10560,10580,10600,10620,10640,10660,10680,10700,10720,10740,10760,10780,10800,10820,10840,10860,10880,10900,10920,10940,10960,10980,11000,11020,11040,11060,11080,11100,11120,11140,11160,11180,11200,11220,11240,11260,11280,11300,11320,11340};
// private static final double[] logRpm = {1804.6875,1812.5,1789.0625,1765.625,1773.4375,1773.4375,1812.5,1835.9375,1832.03125,1832.03125,1816.40625,1804.6875,1824.21875,1847.65625,1847.65625,1863.28125,1859.375,1847.65625,1843.75,1843.75,1859.375,1886.71875,1890.625,1890.625,1882.8125,1875,1882.8125,1906.25,1906.25,1921.875,1921.875,1914.0625,1914.0625,1914.0625,1933.59375,1953.125,1953.125,1957.03125,1953.125,1945.3125,1945.3125,1953.125,1972.65625,1988.28125,1988.28125,1984.375,1984.375,1984.375,1984.375,2011.71875,2011.71875,2015.625,2019.53125,2019.53125,2019.53125,2027.34375,2039.0625,2050.78125,2050.78125,2058.59375,2058.59375,2062.5,2062.5,2074.21875,2074.21875,2082.03125,2089.84375,2097.65625,2097.65625,2101.5625,2109.375,2121.09375,2121.09375,2128.90625,2132.8125,2136.71875,2136.71875,2144.53125,2152.34375,2160.15625,2160.15625,2164.0625,2171.875,2171.875,2187.5,2187.5,2191.40625,2191.40625,2207.03125,2207.03125,2214.84375,2222.65625,2222.65625,2230.46875,2234.375,2242.1875,2242.1875,2250,2261.71875,2269.53125,2269.53125,2277.34375,2281.25,2285.15625,2285.15625,2292.96875,2304.6875,2312.5,2312.5,2320.3125,2324.21875,2324.21875,2328.125,2339.84375,2351.5625,2351.5625,2355.46875,2363.28125,2363.28125,2375,2386.71875,2386.71875,2386.71875,2390.625,2406.25,2406.25,2421.875,2425.78125,2425.78125,2425.78125,2433.59375,2445.3125,2445.3125,2457.03125,2464.84375,2472.65625,2472.65625,2476.5625,2480.46875,2480.46875,2496.09375,2511.71875,2519.53125,2519.53125,2519.53125,2523.4375,2523.4375,2535.15625,2550.78125,2550.78125,2562.5,2562.5,2562.5,2562.5,2578.125,2601.5625,2601.5625,2609.375,2609.375,2605.46875,2613.28125,2613.28125,2628.90625,2644.53125,2644.53125,2648.4375,2648.4375,2656.25,2656.25,2679.6875,2695.3125,2695.3125,2695.3125,2695.3125,2695.3125,2714.84375,2714.84375,2730.46875,2730.46875,2738.28125,
// 2746.09375,2746.09375,2757.8125,2761.71875,2769.53125,2769.53125,2781.25,2804.6875,2804.6875,2812.5,2816.40625,2816.40625,2828.125,2828.125,2843.75,2843.75,2855.46875,2863.28125,2863.28125,2871.09375,2871.09375,2886.71875,2906.25,2906.25,2914.0625,2914.0625,2914.0625,2925.78125,2949.21875,2949.21875,2960.9375,2960.9375,2968.75,2988.28125,2988.28125,2996.09375,2992.1875,2992.1875,3011.71875,3046.875,3046.875,3050.78125,3050.78125,3046.875,3046.875,3062.5,3082.03125,3082.03125,3093.75,3105.46875,3105.46875,3121.09375,3121.09375,3132.8125,3132.8125,3144.53125,3144.53125,3160.15625,3175.78125,3175.78125,3187.5,3187.5,3199.21875,3199.21875,3214.84375,3234.375,3234.375,3246.09375,3246.09375,3261.71875,3261.71875,3273.4375,3296.875,3296.875,3300.78125,3300.78125,3312.5,3312.5,3347.65625,3347.65625,3351.5625,3351.5625,3351.5625,3390.625,3390.625,3406.25,3406.25,3410.15625,3425.78125,3425.78125,3449.21875,3449.21875,3457.03125,3457.03125,3480.46875,3480.46875,3492.1875,3492.1875,3515.625,3539.0625,3539.0625,3539.0625,3554.6875,3562.5,3562.5,3562.5,3582.03125,3621.09375,3621.09375,3621.09375,3636.71875,3644.53125,3644.53125,3667.96875,3667.96875,3691.40625,3691.40625,3718.75,3718.75,3726.5625,3726.5625,3753.90625,3753.90625,3753.90625,3792.96875,3804.6875,3804.6875,3820.3125,3820.3125,3820.3125,3867.1875,3867.1875,3898.4375,3898.4375,3898.4375,3910.15625,3910.15625,3937.5,3988.28125,3988.28125,3988.28125,4007.8125,4007.8125,4046.875,4046.875,4082.03125,4082.03125,4082.03125,4121.09375,4121.09375,4121.09375,4148.4375,4148.4375,4195.3125,4195.3125,4195.3125,4234.375,4234.375,4234.375,4292.96875,4292.96875,4292.96875,4343.75,4343.75,4343.75,4371.09375,4371.09375,4371.09375,4421.875,4421.875,4472.65625,4472.65625,4472.65625,4472.65625,4507.8125,4507.8125,4507.8125,4570.3125,4570.3125,4570.3125,
// 4570.3125,4625,4625,4625,4660.15625,4660.15625,4660.15625,4660.15625,4734.375,4734.375,4734.375,4796.875,4796.875,4796.875,4796.875,4859.375,4859.375,4859.375,4859.375,4921.875,4921.875,4921.875,4921.875,5003.90625,5003.90625,5003.90625,5003.90625,5003.90625,5050.78125,5050.78125,5050.78125,5050.78125,5117.1875,5117.1875,5117.1875,5117.1875,5210.9375,5210.9375,5210.9375,5210.9375,5210.9375,5281.25,5281.25,5281.25,5281.25,5281.25,5343.75,5343.75,5343.75,5343.75,5433.59375,5433.59375,5433.59375,5433.59375,5433.59375,5503.90625,5503.90625,5503.90625,5503.90625,5503.90625,5570.3125,5570.3125,5570.3125,5570.3125,5656.25,5656.25,5656.25,5656.25,5656.25,5734.375,5734.375,5734.375,5734.375,5734.375,5804.6875,5804.6875,5804.6875,5804.6875,5804.6875,5871.09375,5871.09375,5871.09375,5871.09375,5937.5,5937.5,5937.5,5937.5,5937.5,6023.4375,6023.4375,6023.4375,6023.4375,6023.4375,6097.65625,6097.65625,6097.65625,6097.65625,6097.65625,6164.0625,6164.0625,6164.0625,6164.0625,6164.0625,6242.1875,6242.1875,6242.1875,6242.1875,6242.1875,6304.6875,6304.6875,6304.6875,6304.6875,6304.6875,6304.6875,6375,6375,6375,6375,6437.5,6437.5,6437.5,6437.5,6437.5,6437.5,6503.90625,6503.90625,6503.90625,6503.90625,6593.75,6593.75,6593.75,6593.75,6593.75,6593.75,6656.25,6656.25,6656.25,6656.25,6656.25,6718.75,6718.75,6718.75,6718.75,6718.75,6718.75,6785.15625,6785.15625,6785.15625,6785.15625,6785.15625,6835.9375,6835.9375,6835.9375,6835.9375,6835.9375,6890.625,6890.625,6890.625,6890.625,6890.625,6960.9375,6960.9375,6960.9375,6960.9375,6960.9375,6960.9375,7035.15625,7035.15625,7035.15625,7035.15625,7035.15625,7105.46875,7105.46875,7105.46875,7105.46875,7105.46875,7105.46875,7128.90625};
// private static final double[] logThrottle = {80.95093,91.66565,99.40338,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,
// 99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,
// 99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,99.99847,47.91565};
private int i = 0;
private double rpm;
private double vs;
private double ta;
private long now;
private long startNow = -999999999;
private double iat;
private double atm;
public synchronized void handleDataUpdate(Response response) {
if (dynoTab.isRecordData() && (containsData(response, RPM, TA)
|| containsData(response, VS, TA)
|| containsData(response, VS))) {
boolean valid = true;
if (valid && containsData(response, RPM, TA) &&
dynoTab.isManual()) {
if (TEST) {
if (i >= logTime.length) {
i = 0;
}
now = logTime[i];
rpm = logRpm[i];
ta = logThrottle[i];
i++;
} else {
now = currentTimeMillis();
rpm = findValue(response, RPM);
ta = findValue(response, TA);
}
valid = dynoTab.isValidData(rpm, ta);
LOGGER.info("DYNO Sample: [Time]: " + now + " [RPM:P8]: " + rpm + " [TA:P13]: " + ta);
if (valid) addRawData(now, rpm);
}
if (valid && containsData(response, VS, TA) &&
!dynoTab.isManual()) {
if (TEST) {
if (i >= logTime.length) {
i = 0;
}
vs = logKph[i];
ta = logThrottle[i];
now = logTime[i];
i++;
} else {
now = currentTimeMillis();
vs = findValue(response, VS);
ta = findValue(response, TA);
}
rpm = dynoTab.calcRpm(vs);
valid = dynoTab.isValidData(rpm, ta);
LOGGER.info("DYNO Sample: [Time]: " + now + " [RPM:calc]: " + rpm + " [TA:P13]: " + ta + " [VS:P9]: " + vs);
if (valid) addRawData(now, vs);
}
if (valid && dynoTab.isRecordET() && containsData(response, VS)) {
if (TEST) {
if (i >= logTime.length) {
i = 0;
}
vs = logKph[i];
now = logTime[i];
i++;
} else {
now = currentTimeMillis();
vs = findValue(response, VS);
}
valid = dynoTab.isValidET(now, vs);
LOGGER.info("DYNO Sample: [Time]: " + now + " [VS:P9]: " + vs + " valid: " + valid);
if (valid) addRawData(now, vs);
}
} else {
startNow = -999999999;
}
if (dynoTab.getEnv() && containsData(response, IAT, ATM)) {
if (TEST) {
iat = 27;
atm = 14.54;
} else {
iat = findValue(response, IAT);
atm = findValue(response, ATM);
}
dynoTab.updateEnv(iat, atm);
LOGGER.info("DYNO Enviornment: [IAT:P11]: " + iat + " [ATM_Pressure:P24]: " + atm);
}
}
private void addRawData(final long time, final double speed) {
if (startNow == -999999999) startNow = time;
final long sampleTime = time - startNow;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
dynoTab.addRawData(sampleTime, speed);
}
});
}
private boolean containsData(Response response, String... ids) {
Set<LoggerData> datas = response.getData();
for (String id : ids) {
boolean found = false;
for (LoggerData data : datas) {
if (data.getId().equals(id)) {
found = true;
break;
}
}
if (!found) {
return false;
}
}
return true;
}
private double findValue(Response response, String id) {
for (LoggerData loggerData : response.getData()) {
if (id.equals(loggerData.getId())) {
return response.getDataValue(loggerData);
}
}
throw new IllegalStateException("Expected data item " + id + " not in response.");
}
public synchronized void registerData(LoggerData loggerData) {
}
public synchronized void deregisterData(LoggerData loggerData) {
}
public synchronized void cleanUp() {
}
public synchronized void reset() {
}
public void setDynoTab(DynoTab dynoTab) {
this.dynoTab = dynoTab;
}
}