示例#1
0
        private void checkCurrentState(flightData data)
        {
            switch (currentState)
            {
            case FSECONOMY_STATES.IDLE:
                break;

            case FSECONOMY_STATES.STARTED_GROUND:
                if (data.onground == 0)
                {
                    switchToState(FSECONOMY_STATES.AIRBORNE);
                }
                break;

            case FSECONOMY_STATES.AIRBORNE:
                if (data.onground != 0 && data.groundVelocity < 20)
                {
                    switchToState(FSECONOMY_STATES.LANDED);
                }
                break;

            case FSECONOMY_STATES.LANDED:
                if (data.onground != 0 && data.parkingBreak != 0 && data.wheelRpm == 0)
                {
                    switchToState(FSECONOMY_STATES.FINISHED);
                }
                break;
            }
        }
        public void receiveData(SIMCONNECT_RECV_SIMOBJECT_DATA data)
        {
            int diffSeconds = latestData.zuluTime;

            latestData = (flightData)data.dwData[0];
            if (!flightDataValid)
            {
                // First reception of data
                initialFuel     = latestData.totalFuel;
                flightDataValid = true;
                return;
            }
            diffSeconds = latestData.zuluTime - diffSeconds;
            if (diffSeconds <= 0)
            {
                return;
            }

            int envBonusFactor = latestData.altitude_agl <= 1000 ? 5 : latestData.altitude_agl < 2000 ? 3 : 1;

            envBonusTime += envBonusFactor * diffSeconds;
            envBonus     += envBonusFactor * diffSeconds * weatherSeverity();

            if (isTacho)
            {
                rentalTicker += diffSeconds * latestData.rpmPercentage / 36.0f;
            }
            else
            {
                engineTime += diffSeconds;
            }

            if (latestData.timeOfDay != 1)
            {
                nightTime += diffSeconds;
            }

            if (engines.Length > 0)
            {
                engines[0].feed(diffSeconds, latestData.combustion1 != 0, latestData.rpm1, latestData.cht1, latestData.mixture1, latestData.altitude);
            }
            if (engines.Length > 1)
            {
                engines[1].feed(diffSeconds, latestData.combustion2 != 0, latestData.rpm2, latestData.cht2, latestData.mixture2, latestData.altitude);
            }
            if (engines.Length > 2)
            {
                engines[2].feed(diffSeconds, latestData.combustion3 != 0, latestData.rpm3, latestData.cht3, latestData.mixture3, latestData.altitude);
            }
            if (engines.Length > 3)
            {
                engines[3].feed(diffSeconds, latestData.combustion4 != 0, latestData.rpm4, latestData.cht4, latestData.mixture4, latestData.altitude);
            }
        }