Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit d505e241 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

extending helper classes for enums (to be useful for GUI)

parent 05a2c0c1
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,8 @@
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using System;
namespace TUGraz.VectoCommon.Models
{
public enum AngularGearType
......@@ -37,4 +39,21 @@ namespace TUGraz.VectoCommon.Models
SeparateAngularGear,
LossesIncludedInGearbox,
}
public static class AngularGearTypeHelper
{
public static string GetLabel(this AngularGearType type)
{
switch (type) {
case AngularGearType.None:
return "No Angular Gear";
case AngularGearType.SeparateAngularGear:
return "Separate Angular Gear";
case AngularGearType.LossesIncludedInGearbox:
return "Included in Transmission Loss Maps";
default:
throw new ArgumentOutOfRangeException("type", type, null);
}
}
}
}
\ No newline at end of file
......@@ -43,23 +43,60 @@ namespace TUGraz.VectoCommon.Models
public static class CrossWindCorrectionModeHelper
{
private const string SpeedDependentCorrectionFactor = "CdofVEng";
private const string DeclarationModeCorrection = "CdofVdecl";
private const string VAirBetaLookupTable = "CdofBeta";
private const string NoCorrection = "Off";
public static CrossWindCorrectionMode Parse(string correctionMode)
{
if (correctionMode.Equals("CdofVEng", StringComparison.OrdinalIgnoreCase)) {
if (correctionMode.Equals(SpeedDependentCorrectionFactor, StringComparison.OrdinalIgnoreCase)) {
return CrossWindCorrectionMode.SpeedDependentCorrectionFactor;
}
if (correctionMode.Equals("CdofVdecl", StringComparison.OrdinalIgnoreCase)) {
if (correctionMode.Equals(DeclarationModeCorrection, StringComparison.OrdinalIgnoreCase)) {
return CrossWindCorrectionMode.DeclarationModeCorrection;
}
if (correctionMode.Equals("CdofBeta", StringComparison.OrdinalIgnoreCase)) {
if (correctionMode.Equals(VAirBetaLookupTable, StringComparison.OrdinalIgnoreCase)) {
return CrossWindCorrectionMode.VAirBetaLookupTable;
}
if (correctionMode.Equals("Off", StringComparison.OrdinalIgnoreCase)) {
if (correctionMode.Equals(NoCorrection, StringComparison.OrdinalIgnoreCase)) {
return CrossWindCorrectionMode.NoCorrection;
}
LogManager.GetLogger(typeof(CrossWindCorrectionModeHelper).ToString())
.Warn("Invalid Crosswind correction Mode given. Ignoring Crosswind Correction!");
return CrossWindCorrectionMode.NoCorrection;
}
public static string GetName(this CrossWindCorrectionMode mode)
{
switch (mode) {
case CrossWindCorrectionMode.NoCorrection:
return NoCorrection;
case CrossWindCorrectionMode.SpeedDependentCorrectionFactor:
return SpeedDependentCorrectionFactor;
case CrossWindCorrectionMode.VAirBetaLookupTable:
return VAirBetaLookupTable;
case CrossWindCorrectionMode.DeclarationModeCorrection:
return DeclarationModeCorrection;
default:
throw new ArgumentOutOfRangeException("mode", mode, null);
}
}
public static string GetLabel(this CrossWindCorrectionMode mode)
{
switch (mode) {
case CrossWindCorrectionMode.NoCorrection:
return "No Correction";
case CrossWindCorrectionMode.SpeedDependentCorrectionFactor:
return "Speed dependend (User-defined)";
case CrossWindCorrectionMode.VAirBetaLookupTable:
return "Vair & beta Input";
case CrossWindCorrectionMode.DeclarationModeCorrection:
return "Speed dependent (Declaration Mode)";
default:
throw new ArgumentOutOfRangeException("mode", mode, null);
}
}
}
}
\ No newline at end of file
......@@ -29,6 +29,7 @@
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using System;
using System.Diagnostics.CodeAnalysis;
using TUGraz.VectoCommon.Utils;
......@@ -45,8 +46,31 @@ namespace TUGraz.VectoCommon.Models
DrivingCycle
}
public static class GearBoxTypeExtension
public static class GearBoxTypeHelper
{
public static string GetLabel(this GearboxType type)
{
switch (type) {
case GearboxType.MT:
return "Manual Transmission (MT)";
case GearboxType.AMT:
return "Automated Transmission (AMT)";
case GearboxType.ATSerial:
return "Automatic Transmission - Serial (AT-S)";
case GearboxType.ATPowerSplit:
return "Automatic Transmission - PowerSplit (AT-P)";
case GearboxType.DrivingCycle:
return "Gear from Driving Cycle";
default:
throw new ArgumentOutOfRangeException("type", type, null);
}
}
public static string ShortName(this GearboxType type)
{
return type.ToString();
}
public static bool AutomaticTransmission(this GearboxType type)
{
return type == GearboxType.ATPowerSplit || type == GearboxType.ATSerial;
......
......@@ -29,6 +29,9 @@
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using System;
using TUGraz.VectoCommon.Utils;
namespace TUGraz.VectoCommon.Models
{
public enum RetarderType
......@@ -39,4 +42,49 @@ namespace TUGraz.VectoCommon.Models
EngineRetarder,
LossesIncludedInTransmission
}
public static class RetarderTypeHelper
{
public static RetarderType Parse(string retarderType)
{
switch (retarderType.ToLowerInvariant()) {
case "primary":
return RetarderType.TransmissionInputRetarder;
case "secondary":
return RetarderType.TransmissionOutputRetarder;
default:
return retarderType.ParseEnum<RetarderType>();
}
}
public static string GetName(this RetarderType retarder)
{
switch (retarder) {
case RetarderType.TransmissionInputRetarder:
return "primary";
case RetarderType.TransmissionOutputRetarder:
return "secondary";
default:
return retarder.ToString();
}
}
public static string GetLabel(this RetarderType retarder)
{
switch (retarder) {
case RetarderType.None:
return "None";
case RetarderType.TransmissionInputRetarder:
return "Primary Retarder";
case RetarderType.TransmissionOutputRetarder:
return "Secondary Retarder";
case RetarderType.EngineRetarder:
return "Engine Retarder";
case RetarderType.LossesIncludedInTransmission:
return "Included in Transmission Loss Maps";
default:
throw new ArgumentOutOfRangeException("retarder", retarder, null);
}
}
}
}
\ No newline at end of file
......@@ -29,6 +29,8 @@
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using System;
namespace TUGraz.VectoCommon.Models
{
public enum VehicleCategory
......@@ -39,4 +41,43 @@ namespace TUGraz.VectoCommon.Models
InterurbanBus,
Coach
}
public static class VehicleCategoryHelper
{
public static string GetLabel(this VehicleCategory category)
{
switch (category)
{
case VehicleCategory.RigidTruck:
return "Rigid Truck";
case VehicleCategory.Tractor:
return "Tractor";
case VehicleCategory.CityBus:
return "City Bus";
case VehicleCategory.InterurbanBus:
return "Interurban Bus";
case VehicleCategory.Coach:
return "Coach";
default:
return category.ToString();
}
}
public static string GetCategoryName(this VehicleCategory category)
{
switch (category) {
case VehicleCategory.RigidTruck:
return "Rigid Truck";
case VehicleCategory.Tractor:
return "Semitrailer Truck";
case VehicleCategory.CityBus:
return "Citybus";
case VehicleCategory.InterurbanBus:
return "Interurban Bus";
case VehicleCategory.Coach:
return "Coach";
default:
return category.ToString();
}
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment