private bool ReadVehicleFile(string DataPath,
string emissionClass,
Helpers Helper,
out double vehicleMass,
out double vehicleLoading,
out double vehicleMassRot,
out double crossArea,
out double cWValue,
out double f0,
out double f1,
out double f2,
out double f3,
out double f4,
out double axleRatio,
out double auxPower,
out double ratedPower,
out double engineIdlingSpeed,
out double engineRatedSpeed,
out double effectiveWheelDiameter,
out List<double> transmissionGearRatios,
out string vehicleMassType,
out string vehicleFuelType,
out double pNormV0,
out double pNormP0,
out double pNormV1,
out double pNormP1,
out List<List<double>> matrixSpeedInertiaTable,
out List<List<double>> normedDragTable)
{
vehicleMass = 0;
vehicleLoading = 0;
vehicleMassRot = 0;
crossArea = 0;
cWValue = 0;
f0 = 0;
f1 = 0;
f2 = 0;
f3 = 0;
f4 = 0;
axleRatio = 0;
ratedPower = 0;
auxPower = 0;
engineIdlingSpeed = 0;
engineRatedSpeed = 0;
effectiveWheelDiameter = 0;
vehicleMassType = "";
vehicleFuelType = "";
pNormV0 = 0;
pNormP0 = 0;
pNormV1 = 0;
pNormP1 = 0;
transmissionGearRatios = new List<double>();
matrixSpeedInertiaTable = new List<List<double>>();
normedDragTable = new List<List<double>>();
string line;
string cell;
int dataCount = 0;
//Open file
string path = DataPath + @"\" + emissionClass + ".PHEMLight.veh";
if (!File.Exists(@path))
{
Helper.ErrMsg = "File do not exist! (" + path + ")";
return false;
}
StreamReader vehicleReader = File.OpenText(@path);
// skip header
ReadLine(vehicleReader);
while ((line = ReadLine(vehicleReader)) != null && dataCount <= 49)
{
if (line.Substring(0, 1) == Helper.CommentPrefix)
{
continue;
}
else
{
dataCount++;
}
cell = split(line, ',')[0];
// reading Mass
if (dataCount == 1)
vehicleMass = todouble(cell);
// reading vehicle loading
if (dataCount == 2)
vehicleLoading = todouble(cell);
// reading cWValue
if (dataCount == 3)
cWValue = todouble(cell);
// reading crossectional area
if (dataCount == 4)
crossArea = todouble(cell);
// reading vehicle mass rotational
if (dataCount == 7)
vehicleMassRot = todouble(cell);
// reading rated power
if (dataCount == 9)
auxPower = todouble(cell);
// reading rated power
if (dataCount == 10)
ratedPower = todouble(cell);
// reading engine rated speed
if (dataCount == 11)
engineRatedSpeed = todouble(cell);
// reading engine idling speed
if (dataCount == 12)
engineIdlingSpeed = todouble(cell);
// reading f0
if (dataCount == 14)
f0 = todouble(cell);
// reading f1
if (dataCount == 15)
f1 = todouble(cell);
// reading f2
if (dataCount == 16)
f2 = todouble(cell);
// reading f3
if (dataCount == 17)
f3 = todouble(cell);
// reading f4
if (dataCount == 18)
f4 = todouble(cell);
// reading axleRatio
if (dataCount == 21)
axleRatio = todouble(cell);
// reading effective wheel diameter
if (dataCount == 22)
effectiveWheelDiameter = todouble(cell);
if (dataCount >= 23 && dataCount <= 40)
transmissionGearRatios.Add(todouble(cell));
// reading vehicleMassType
if (dataCount == 45)
vehicleMassType = cell;
// reading vehicleFuelType
if (dataCount == 46)
vehicleFuelType = cell;
// reading pNormV0
if (dataCount == 47)
pNormV0 = todouble(cell);
// reading pNormP0
if (dataCount == 48)
pNormP0 = todouble(cell);
// reading pNormV1
if (dataCount == 49)
pNormV1 = todouble(cell);
// reading pNormP1
if (dataCount == 50)
pNormP1 = todouble(cell);
}
while ((line = ReadLine(vehicleReader)) != null && line.Substring(0, 1) != Helper.CommentPrefix)
{
if (line.Substring(0, 1) == Helper.CommentPrefix)
continue;
matrixSpeedInertiaTable.Add(todoubleList(split(line, ',')));
}
while ((line = ReadLine(vehicleReader)) != null)
{
if (line.Substring(0, 1) == Helper.CommentPrefix)
continue;
normedDragTable.Add(todoubleList(split(line, ',')));
}
vehicleReader.Close();
return true;
}
#endregion