コード例 #1
0
        private void SetDefaults()
        {
            Name           = "Not defined";
            N1             = N2 = 0.0;
            engineType     = Engine.EngineType.Turboprop;
            MilThrust      = 10000.0;
            IdleN1         = 30.0;
            IdleN2         = 60.0;
            MaxN1          = 100.0;
            MaxN2          = 100.0;
            ThrottleCmd    = 0.0;
            InletPosition  = 1.0;
            NozzlePosition = 1.0;
            Reversed       = false;
            Cutoff         = true;
            phase          = phaseType.tpOff;
            Stalled        = false;
            Seized         = false;
            Overtemp       = false;
            Fire           = false;
            Eng_ITT_degC   = 0.0;

            GeneratorPower = true;
            Condition      = 0;
            Ielu_intervent = false;

            Idle_Max_Delay = 1.0;
        }
コード例 #2
0
        private double SpinUp()
        {
            double EngPower_HP;

            running      = false;
            EngStarting  = true;
            fuelFlow_pph = 0.0;

            if (!GeneratorPower)
            {
                EngStarting = false;
                phase       = phaseType.tpOff;
                StartTime   = -1;
                return(0.0);
            }

            N1 = ExpSeek(N1, StarterN1, Idle_Max_Delay * 6, Idle_Max_Delay * 2.4);

            Eng_Temperature = ExpSeek(Eng_Temperature, TAT, 300, 400);
            double ITT_goal = ITT_N1.GetValue(N1, 0.1) + ((N1 > 20) ? 0.0 : (20 - N1) / 20.0 * Eng_Temperature);

            Eng_ITT_degC = ExpSeek(Eng_ITT_degC, ITT_goal, ITT_Delay, ITT_Delay * 1.2);

            OilTemp_degK = ExpSeek(OilTemp_degK, 273.15 + TAT, 400, 400);

            OilPressure_psi = (N1 / 100.0 * 0.25 + (0.1 - (OilTemp_degK - 273.15) * 0.1 / 80.0) * N1 / 100.0) / 7692.0e-6; //from MPa to psi
            NozzlePosition  = 1.0;

            EngPower_HP  = EnginePowerRPM_N1.GetValue(Prop_RPM, N1);
            EngPower_HP *= EnginePowerVC.GetValue();
            if (EngPower_HP > MaxPower)
            {
                EngPower_HP = MaxPower;
            }

            if (StartTime >= 0)
            {
                StartTime += dt;
            }
            if (StartTime > MaxStartingTime && MaxStartingTime > 0)
            { //start failed due timeout
                phase     = phaseType.tpOff;
                StartTime = -1;
            }

            ConsumeFuel(); // for possible setting Starved = false when fuel tank
            // is refilled (fuel crossfeed etc.)

            return(EngPower_HP);
        }
コード例 #3
0
        private double Start()
        {
            double EngPower_HP = 0.0, eff_coef;

            EngStarting = false;
            if ((N1 > 15.0) && !starved)
            {                    // minimum 15% N2 needed for start
                double old_N1 = N1;
                cranking = true; // provided for sound effects signal
                if (N1 < IdleN1)
                {
                    EngPower_HP  = EnginePowerRPM_N1.GetValue(Prop_RPM, N1);
                    EngPower_HP *= EnginePowerVC.GetValue();
                    if (EngPower_HP > MaxPower)
                    {
                        EngPower_HP = MaxPower;
                    }
                    N1              = ExpSeek(N1, IdleN1 * 1.1, Idle_Max_Delay * 4, Idle_Max_Delay * 2.4);
                    eff_coef        = 9.333 - (N1) / 12; // 430%Fuel at 60%N1
                    fuelFlow_pph    = PSFC * EngPower_HP * eff_coef;
                    Eng_Temperature = ExpSeek(Eng_Temperature, Eng_ITT_degC, 300, 400);
                    double ITT_goal = ITT_N1.GetValue((N1 - old_N1) * 300 + N1, 1);
                    Eng_ITT_degC = ExpSeek(Eng_ITT_degC, ITT_goal, ITT_Delay, ITT_Delay * 1.2);

                    OilPressure_psi = (N1 / 100.0 * 0.25 + (0.1 - (OilTemp_degK - 273.15) * 0.1 / 80.0) * N1 / 100.0) / 7692.0e-6; //from MPa to psi
                    OilTemp_degK    = Seek(OilTemp_degK, 353.15, 0.4 - N1 * 0.001, 0.04);
                }
                else
                {
                    phase        = phaseType.tpRun;
                    running      = true;
                    Starter      = false;
                    cranking     = false;
                    fuelFlow_pph = 0;
                    EngPower_HP  = 0.0;
                }
            }
            else
            {                 // no start if N2 < 15% or Starved
                phase   = phaseType.tpOff;
                Starter = false;
            }

            ConsumeFuel();

            return(EngPower_HP);
        }
コード例 #4
0
        private double Run()
        {
            //TODO check it. Not used double idlethrust, milthrust;
            double thrust = 0.0, EngPower_HP, eff_coef;

            running = true; Starter = false; EngStarting = false;

            //---
            double old_N1 = N1;

            N1 = ExpSeek(N1, IdleN1 + ThrottleCmd * N1_factor, Idle_Max_Delay, Idle_Max_Delay * 2.4);

            EngPower_HP  = EnginePowerRPM_N1.GetValue(Prop_RPM, N1);
            EngPower_HP *= EnginePowerVC.GetValue();
            if (EngPower_HP > MaxPower)
            {
                EngPower_HP = MaxPower;
            }

            eff_coef     = 9.333 - (N1) / 12; // 430%Fuel at 60%N1
            fuelFlow_pph = PSFC * EngPower_HP * eff_coef;

            Eng_Temperature = ExpSeek(Eng_Temperature, Eng_ITT_degC, 300, 400);
            double ITT_goal = ITT_N1.GetValue((N1 - old_N1) * 300 + N1, 1);

            Eng_ITT_degC = ExpSeek(Eng_ITT_degC, ITT_goal, ITT_Delay, ITT_Delay * 1.2);

            OilPressure_psi = (N1 / 100.0 * 0.25 + (0.1 - (OilTemp_degK - 273.15) * 0.1 / 80.0) * N1 / 100.0) / 7692.0e-6; //from MPa to psi
            //---
            EPR = 1.0 + thrust / MilThrust;

            OilTemp_degK = Seek(OilTemp_degK, 353.15, 0.4 - N1 * 0.001, 0.04);

            ConsumeFuel();

            if (Cutoff)
            {
                phase = phaseType.tpOff;
            }
            if (starved)
            {
                phase = phaseType.tpOff;
            }

            return(EngPower_HP);
        }
コード例 #5
0
    void Start()
    {
        vehicleFactory = FindObjectOfType <VehicleFactory>();
        string filePath = System.IO.Path.Combine(Application.dataPath, "Sumo");

        ImportAndGenerate.parseXMLfiles(filePath);
        ImportAndGenerate.CreateStreetNetwork();
        client = new TraCIClient();
        if (client.Connect(ip, port))
        {
            Debug.Log("Connected to Sumo");
            connected = true;
        }
        else
        {
            Debug.Log("Unable to connect to Sumo");
            this.enabled = false;
            return;
        }
        FindObjectOfType <CameraManager>().frameRate = 60;
        StartCoroutine(Run());
        vehicleFactory.StopAllCoroutines();
        TrafficLightManager.GetInstance().RefreshTrafficLightsAndJunctions();

        // Traffic Flow
        if (!IsControlledBySumo(SumoLinkControlPoint.TRAFFIC_FLOW))
        {
            StartCoroutine(RunTraffic3DTrafficFlow());
        }

        // Traffic Lights
        List <string> junctionIds = client.TrafficLight.GetIdList().Content;

        foreach (string id in junctionIds)
        {
            List <string> controlledLanes = client.TrafficLight.GetControlledLanes(id).Content;
            string        currentState    = client.TrafficLight.GetState(id).Content;
            for (int i = 0; i < controlledLanes.Count; i++)
            {
                TrafficLight trafficLight = TrafficLightManager.GetInstance().GetTrafficLight(controlledLanes[i]);
                if (trafficLight != null)
                {
                    SumoTrafficLight sumoTrafficLight = sumoTrafficLights.Find(s => s.trafficLight.trafficLightId.Equals(trafficLight.trafficLightId));
                    if (sumoTrafficLight == null)
                    {
                        sumoTrafficLights.Add(new SumoTrafficLight(trafficLight, id, new HashSet <int>()
                        {
                            i
                        }));
                    }
                    else
                    {
                        sumoTrafficLight.AddIndexState(i);
                    }
                }
            }
            // Remove all current traffic light programs in Sumo
            if (!IsControlledBySumo(SumoLinkControlPoint.TRAFFIC_LIGHTS))
            {
                client.TrafficLight.SetRedYellowGreenState(id, new string('r', currentState.Length));
                client.TrafficLight.SetPhaseDuration(id, Double.MaxValue);
            }
        }
        if (IsControlledBySumo(SumoLinkControlPoint.TRAFFIC_LIGHTS))
        {
            TrafficLightManager.GetInstance().StopAllCoroutines();
            StartCoroutine(RunTrafficLights());
        }
        else
        {
            TrafficLightManager.GetInstance().trafficLightChangeEvent += ChangeSumoTrafficLights;

            foreach (tlLogicType tlLogicType in ImportAndGenerate.trafficLightPrograms.Values)
            {
                int      stateCounter = 0;
                Junction junction     = FindObjectsOfType <Junction>().ToList().Find(j => j.junctionId.Equals(tlLogicType.id));
                List <SumoTrafficLight> sumoTrafficLightsForJunction = sumoTrafficLights.FindAll(sumoTrafficLight => sumoTrafficLight.junctionId.Equals(tlLogicType.id));
                foreach (object obj in tlLogicType.Items)
                {
                    if (obj is phaseType)
                    {
                        stateCounter++;
                        GameObject stateObject = new GameObject("State" + stateCounter);
                        stateObject.transform.SetParent(junction.gameObject.transform);
                        JunctionState junctionState = stateObject.AddComponent <JunctionState>();
                        junctionState.stateNumber        = stateCounter;
                        junctionState.trafficLightStates = new JunctionState.TrafficLightState[sumoTrafficLightsForJunction.Count()];
                        int       trafficLightStateCounter = 0;
                        phaseType phase = (phaseType)obj;

                        foreach (SumoTrafficLight sumoTrafficLight in sumoTrafficLightsForJunction)
                        {
                            TrafficLight.LightColour lightColour = sumoTrafficLight.GetLightColourFromStateString(phase.state);
                            junctionState.trafficLightStates[trafficLightStateCounter] = new JunctionState.TrafficLightState(sumoTrafficLight.trafficLight.trafficLightId, lightColour);
                            trafficLightStateCounter++;
                        }
                    }
                }
            }
        }
    }
コード例 #6
0
 public void SetPhase(phaseType p)
 {
     phase = p;
 }