コード例 #1
0
ファイル: Start.cs プロジェクト: wsgan001/plexe-sumo
        public bool ExportSumData(string path, string vehicle, string cycle, VehicleResult _VehicleResult)
        {
            if (path == null || vehicle == null || cycle == null || _VehicleResult == null)
            {
                return(false);
            }
            StringBuilder allLines = new StringBuilder();

            if (path.IndexOf(".", 0) < 0)
            {
                path = path + ".erg";
            }

            if (!File.Exists(path))
            {
                //Write head
                allLines.AppendLine("PHEMLight Results");
                allLines.AppendLine("");
                allLines.AppendLine("Vehicle, Cycle, Time, Speed, Gradient, Accelaration, Engine power raw, P_pos, P_norm_rated, P_norm_drive, FC, Electric Power, CO2, NOx, CO, HC, PM");
                allLines.AppendLine("[-], [-], [s], [km/h], [%], [m/s^2], [kW], [kW], [-], [-], [g/km], [kWh/km], [g/km], [g/km], [g/km], [g/km], [g/km]");
            }

            //Write data
            allLines.Append(vehicle + ",");
            allLines.Append(cycle + ",");
            allLines.Append(_VehicleResult.Time.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.Speed.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.Grad.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.Accelaration.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.Power.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.PPos.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.PNormRated.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.PNormDrive.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.EmissionData.FC.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.EmissionData.FCel.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.EmissionData.CO2.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.EmissionData.NOx.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.EmissionData.CO.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.EmissionData.HC.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.EmissionData.PM.ToString("0.0000", CultureInfo.InvariantCulture));

            // Write the string to a file.
            try
            {
                StreamWriter file = new StreamWriter(path, true);
                file.WriteLine(allLines);
                file.Close();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #2
0
ファイル: Start.cs プロジェクト: dkrajzew/sumo
        //Output sequence for the emissions
        private void OutSeq(VehicleResult _VehicleResult, bool STA = false, bool add = false)
        {
            string        Unit      = "/km";
            List <string> OutSeqStr = new List <string> {
                "FC", "FC_EL", "CO2", "NOX", "CO", "HC", "PM", "PN"
            };

            if (STA)
            {
                Unit = "/h";
            }

            if (!add)
            {
                //Clear the result arrays
                ErgEntries.Clear();
                ErgEntryList.Clear();

                AddToErg("FC", "FC", "[g" + Unit + "]");
                AddToErg("FC_EL", "Engine Power", "[kWh" + Unit + "]");
                AddToErg("CO2", "CO2", "[g" + Unit + "]");
                AddToErg("NOX", "NOx", "[g" + Unit + "]");
                AddToErg("CO", "CO", "[g" + Unit + "]");
                AddToErg("HC", "HC", "[g" + Unit + "]");
                AddToErg("PM", "PM", "[g" + Unit + "]");
                AddToErg("PN", "PN", "[#" + Unit + "]");

                foreach (string id in _VehicleResult.EmissionData.Emi.Keys)
                {
                    if (!OutSeqStr.Contains(id))
                    {
                        AddToErg(id.ToUpper(), id, "[g" + Unit + "]");
                    }
                }
            }
            else
            {
                foreach (string id in _VehicleResult.EmissionData.Emi.Keys)
                {
                    if (!ErgEntries.ContainsKey(id.ToUpper()))
                    {
                        AddToErg(id.ToUpper(), id, "[g" + Unit + "]");
                    }
                }
            }
        }
コード例 #3
0
ファイル: Start.cs プロジェクト: planetsumo/sumo
        public bool ExportSumData(string path, string vehicle, string cycle, VehicleResult _VehicleResult)
        {
            if (path == null || vehicle == null || cycle == null || _VehicleResult == null) return false;
            StringBuilder allLines = new StringBuilder();

            if (path.IndexOf(".", 0) < 0)
            {
                path = path + ".erg";
            }

            if (!File.Exists(path))
            {
                //Write head
                allLines.AppendLine("PHEMLight Results");
                allLines.AppendLine("");
                allLines.AppendLine("Vehicle, Cycle, Time, Speed, Gradient, Accelaration, Engine power raw, P_pos, P_norm_rated, P_norm_drive, FC, FC el., CO2, NOx, CO, HC, PM");
                allLines.AppendLine("[-], [-], [s], [km/h], [%], [m/s^2], [kW], [kW], [-], [-], [g/km], [kWh/km], [g/km], [g/km], [g/km], [g/km], [g/km]");
            }

            //Write data
            allLines.Append(vehicle + ",");
            allLines.Append(cycle + ",");
            allLines.Append(_VehicleResult.Time.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.Speed.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.Grad.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.Accelaration.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.Power.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.PPos.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.PNormRated.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.PNormDrive.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.EmissionData.FC.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.EmissionData.FCel.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.EmissionData.CO2.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.EmissionData.NOx.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.EmissionData.CO.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.EmissionData.HC.ToString("0.0000", CultureInfo.InvariantCulture) + ",");
            allLines.Append(_VehicleResult.EmissionData.PM.ToString("0.0000", CultureInfo.InvariantCulture));

            // Write the string to a file.
            try
            {
                StreamWriter file = new StreamWriter(path, true);
                file.WriteLine(allLines);
                file.Close();
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }