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

Skip to content
Snippets Groups Projects
Commit e7c39cba authored by Markus QUARITSCH's avatar Markus QUARITSCH
Browse files

migrating more aaux code from vb to c#, correct namespaces

parent f45bd519
No related branches found
No related tags found
No related merge requests found
Showing
with 1430 additions and 212 deletions
// Copyright 2017 European Union.
// Licensed under the EUPL (the 'Licence');
//
// * You may not use this work except in compliance with the Licence.
// * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
// * Unless required by applicable law or agreed to in writing,
// software distributed under the Licence is distributed on an "AS IS" basis,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the LICENSE.txt for the specific language governing permissions and limitations.
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl;
using TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Electrics;
using TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC;
using TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Pneumatics;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.PneumaticSystem;
using TUGraz.VectoCore.BusAuxiliaries.Util;
namespace TUGraz.VectoCore.BusAuxiliaries {
/// <summary>
/// ''' Main entry point for the advanced auxiliary module.
/// ''' This class represents slide number 17 titled Calculations of Cycle FC accounting for Smart Auxiliaries.
/// ''' </summary>
/// ''' <remarks></remarks>
public class AdvancedAuxiliaries : IAdvancedAuxiliaries
{
protected internal AuxiliaryConfig auxConfig;
// Supporting classes which may generate event messages
private ICompressorMap compressorMap;
private SSMTOOL ssmTool;
private SSMTOOL ssmToolModule14;
private IAlternatorMap alternatorMap;
public IPneumaticActuationsMAP actuationsMap;
private IFuelConsumptionMap fuelMap;
// Classes which compose the model.
private IM0_NonSmart_AlternatorsSetEfficiency M0;
private IM0_5_SmartAlternatorSetEfficiency M05;
private IM1_AverageHVACLoadDemand M1;
private IM2_AverageElectricalLoadDemand M2;
private IM3_AveragePneumaticLoadDemand M3;
private IM4_AirCompressor M4;
private IM5_SmartAlternatorSetGeneration M5;
private IM6 M6;
private IM7 M7;
private IM8 M8;
private IM9 M9;
private IM10 M10;
private IM11 M11;
private IM12 M12;
private IM13 M13;
private IM14 M14;
private string vectoDirectory;
private HVACConstants hvacConstants;
// Event Handler top level bubble.
// Public Sub VectoEventHandler(ByRef sender As Object, message As String, messageType As AdvancedAuxiliaryMessageType) _
// Handles compressorMap.AuxiliaryEvent, alternatorMap.AuxiliaryEvent, ssmTool.Message, ssmToolModule14.Message
// If Signals.AuxiliaryEventReportingLevel <= messageType Then
// RaiseEvent AuxiliaryEvent(sender, message, messageType)
// End If
// End Sub
// Constructor
public AdvancedAuxiliaries()
{
VectoInputs = new VectoInputs();
Signals = new Signals();
}
// Initialise Model
public void Initialise(string IAuxPath, string vectoFilePath)
{
string auxPath;
vectoDirectory = FilePathUtils.fPATH(vectoFilePath);
auxPath = FilePathUtils.ResolveFilePath(vectoDirectory, IAuxPath);
hvacConstants = new HVACConstants(VectoInputs.FuelDensity);
Signals.CurrentCycleTimeInSeconds = 0;
auxConfig = new AuxiliaryConfig(auxPath);
// Pass some signals from config to Signals. ( These are stored in the configuration but shared in the signal distribution around modules )
Signals.SmartElectrics = auxConfig.ElectricalUserInputsConfig.SmartElectrical;
Signals.StoredEnergyEfficiency = auxConfig.ElectricalUserInputsConfig.StoredEnergyEfficiency;
Signals.SmartPneumatics = auxConfig.PneumaticUserInputsConfig.SmartAirCompression;
Signals.PneumaticOverrunUtilisation = auxConfig.PneumaticAuxillariesConfig.OverrunUtilisationForCompressionFraction;
alternatorMap = new CombinedAlternator(FilePathUtils.ResolveFilePath(vectoDirectory, auxConfig.ElectricalUserInputsConfig.AlternatorMap), Signals);
actuationsMap = new PneumaticActuationsMap(FilePathUtils.ResolveFilePath(vectoDirectory, auxConfig.PneumaticUserInputsConfig.ActuationsMap));
compressorMap = new CompressorMap(FilePathUtils.ResolveFilePath(vectoDirectory, auxConfig.PneumaticUserInputsConfig.CompressorMap));
compressorMap.Initialise();
// fuelMap = New cMAP()
// fuelMap.FilePath = FilePathUtils.ResolveFilePath(vectoDirectory, VectoInputs.FuelMap)
// If Not fuelMap.ReadFile() Then
// MessageBox.Show("Unable to read fuel map, aborting.")
// Return
// End If
// fuelMap.Triangulate()
fuelMap = VectoInputs.FuelMap;
auxConfig.ElectricalUserInputsConfig.ElectricalConsumers.DoorDutyCycleFraction = GetDoorActuationTimeFraction();
// SSM HVAC
var ssmPath = FilePathUtils.ResolveFilePath(vectoDirectory, auxConfig.HvacUserInputsConfig.SSMFilePath);
var BusDatabase = FilePathUtils.ResolveFilePath(vectoDirectory, auxConfig.HvacUserInputsConfig.BusDatabasePath);
ssmTool = new SSMTOOL(ssmPath, hvacConstants, auxConfig.HvacUserInputsConfig.SSMDisabled);
// This duplicate SSM is being created for use in M14 as its properties will be dynamically changed at that point
// to honour EngineWaste Heat Usage in Fueling calculations.
ssmToolModule14 = new SSMTOOL(ssmPath, hvacConstants, auxConfig.HvacUserInputsConfig.SSMDisabled);
if ((ssmTool.Load(ssmPath) == false || ssmToolModule14.Load(ssmPath) == false))
throw new Exception(string.Format("Unable to load the ssmTOOL with file {0}", ssmPath));
M0 = new M00Impl(auxConfig.ElectricalUserInputsConfig.ElectricalConsumers, alternatorMap, auxConfig.ElectricalUserInputsConfig.PowerNetVoltage.SI<Volt>(), Signals, ssmTool);
IM0_5_SmartAlternatorSetEfficiency M05tmp = new M0_5Impl(M0, auxConfig.ElectricalUserInputsConfig.ElectricalConsumers, alternatorMap, auxConfig.ElectricalUserInputsConfig.ResultCardIdle, auxConfig.ElectricalUserInputsConfig.ResultCardTraction, auxConfig.ElectricalUserInputsConfig.ResultCardOverrun, Signals);
M05 = M05tmp;
M1 = new M01Impl(M0, auxConfig.ElectricalUserInputsConfig.AlternatorGearEfficiency, auxConfig.PneumaticUserInputsConfig.CompressorGearEfficiency, auxConfig.ElectricalUserInputsConfig.PowerNetVoltage.SI<Volt>(), Signals, ssmTool);
M2 = new M02Impl(auxConfig.ElectricalUserInputsConfig.ElectricalConsumers, M0, auxConfig.ElectricalUserInputsConfig.AlternatorGearEfficiency, auxConfig.ElectricalUserInputsConfig.PowerNetVoltage.SI<Volt>(), Signals);
M3 = new M03Impl(auxConfig.PneumaticUserInputsConfig, auxConfig.PneumaticAuxillariesConfig, actuationsMap, compressorMap, VectoInputs.VehicleWeightKG, VectoInputs.Cycle, Signals);
M4 = new M04Impl(compressorMap, auxConfig.PneumaticUserInputsConfig.CompressorGearRatio, auxConfig.PneumaticUserInputsConfig.CompressorGearEfficiency, Signals);
M5 = new M05Impl(M05tmp, auxConfig.ElectricalUserInputsConfig.PowerNetVoltage.SI<Volt>(), auxConfig.ElectricalUserInputsConfig.AlternatorGearEfficiency);
M6 = new M06Impl(M1, M2, M3, M4, M5, Signals);
M7 = new M07Impl(M5, M6, Signals);
M8 = new M08Impl(M1, M6, M7, Signals);
M9 = new M09Impl(M1, M4, M6, M8, fuelMap, auxConfig.PneumaticAuxillariesConfig, Signals);
M10 = new M10Impl(M3, M9, Signals);
M11 = new M11Impl(M1, M3, M6, M8, fuelMap, Signals);
M12 = new M12Impl(M10, M11, Signals);
M13 = new M13Impl(M10, M11, M12, Signals);
M14 = new M14Impl(M13, ssmToolModule14, hvacConstants, Signals);
}
public ISignals Signals { get; set; }
public IVectoInputs VectoInputs { get; set; }
public event TUGraz.VectoCore.BusAuxiliaries.Interfaces.AuxiliaryEventEventHandler AuxiliaryEvent;
public delegate void AuxiliaryEventEventHandler(ref object sender, string message, AdvancedAuxiliaryMessageType messageType);
//public bool Configure(string filePath, string vectoFilePath)
//{
// try {
// frmAuxiliaryConfig frmAuxiliaryConfig = new frmAuxiliaryConfig(filePath, vectoFilePath);
// frmAuxiliaryConfig.Show();
// if (frmAuxiliaryConfig.DialogResult != DialogResult.OK) {
// return true;
// }
// return false;
// } catch (Exception ex) {
// return false;
// }
//}
public bool CycleStep(Second seconds, ref string message)
{
try {
M9.CycleStep(seconds);
M10.CycleStep(seconds);
M11.CycleStep(seconds);
Signals.CurrentCycleTimeInSeconds += seconds.Value();
} catch (Exception ex) {
MessageBox.Show("Exception: " + ex.Message + " Stack Trace: " + ex.StackTrace);
return false;
}
return true;
}
public bool Running
{
get {
throw new NotImplementedException();
}
}
public bool RunStart(string auxFilePath, string vectoFilePath)
{
try {
Initialise(auxFilePath, vectoFilePath);
} catch (Exception ex) {
return false;
}
return true;
}
public bool RunStop(ref string message)
{
throw new NotImplementedException();
}
public void ResetCalculations()
{
var modules = new List<IAbstractModule>() { M0, M05, M1, M2, M3, M4, M5, M6, M7, M8, M9, M10, M11, M12, M13, M14 };
foreach (var moduel in modules)
moduel.ResetCalculations();
}
public Kilogram TotalFuelGRAMS
{
get {
if (M13 != null)
return M14.TotalCycleFCGrams;
else
return 0.SI<Kilogram>();
}
}
public Liter TotalFuelLITRES
{
get {
if (M14 != null)
return M14.TotalCycleFCLitres;
else
return 0.SI<Liter>();
}
}
public string AuxiliaryName
{
get {
return "BusAuxiliaries";
}
}
public string AuxiliaryVersion
{
get {
return "Version 1.0 Beta";
}
}
// Helpers
private double GetDoorActuationTimeFraction()
{
var actuationsMap = new PneumaticActuationsMap(FilePathUtils.ResolveFilePath(vectoDirectory, auxConfig.PneumaticUserInputsConfig.ActuationsMap));
var actuationsKey = new ActuationsKey("Park brake + 2 doors", VectoInputs.Cycle);
var numActuations = actuationsMap.GetNumActuations(actuationsKey);
var secondsPerActuation = auxConfig.ElectricalUserInputsConfig.DoorActuationTimeSecond;
var doorDutyCycleFraction = (numActuations * secondsPerActuation) / (double)Signals.TotalCycleTimeSeconds;
return doorDutyCycleFraction;
}
public bool ValidateAAUXFile(string filePath, ref string message)
{
var validResult = FilePathUtils.ValidateFilePath(filePath, ".aaux", ref message);
return validResult;
}
// Diagnostics outputs for testing purposes in Vecto.
// Eventually this can be removed or rendered non effective to reduce calculation load on the model.
public double AA_NonSmartAlternatorsEfficiency
{
get {
return M0.AlternatorsEfficiency;
}
}
public Ampere AA_SmartIdleCurrent_Amps
{
get {
return M05.SmartIdleCurrent;
}
}
public double AA_SmartIdleAlternatorsEfficiency
{
get {
return M05.AlternatorsEfficiencyIdleResultCard;
}
}
public Ampere AA_SmartTractionCurrent_Amps
{
get {
return M05.SmartTractionCurrent;
}
}
public double AA_SmartTractionAlternatorEfficiency
{
get {
return M05.AlternatorsEfficiencyTractionOnResultCard;
}
}
public Ampere AA_SmartOverrunCurrent_Amps
{
get {
return M05.SmartOverrunCurrent;
}
}
public double AA_SmartOverrunAlternatorEfficiency
{
get {
return M05.AlternatorsEfficiencyOverrunResultCard;
}
}
public NormLiterPerSecond AA_CompressorFlowRate_LitrePerSec
{
get {
return M4.GetFlowRate();
}
}
public bool AA_OverrunFlag
{
get {
return M6.OverrunFlag;
}
}
public int? AA_EngineIdleFlag
{
get {
return Signals.EngineSpeed <= Signals.EngineIdleSpeed && (!Signals.ClutchEngaged || Signals.InNeutral) ? 1 : 0;
}
}
public bool AA_CompressorFlag
{
get {
return M8.CompressorFlag;
}
}
public Kilogram AA_TotalCycleFC_Grams
{
get {
return M14.TotalCycleFCGrams;
}
}
public Liter AA_TotalCycleFC_Litres
{
get {
return M14.TotalCycleFCLitres;
}
}
public Watt AuxiliaryPowerAtCrankWatts
{
get {
return M8.AuxPowerAtCrankFromElectricalHVACAndPneumaticsAncillaries;
}
}
public Watt AA_AveragePowerDemandCrankHVACMechanicals
{
get {
return M1.AveragePowerDemandAtCrankFromHVACMechanicalsWatts();
}
}
public Watt AA_AveragePowerDemandCrankHVACElectricals
{
get {
return M1.AveragePowerDemandAtCrankFromHVACElectricsWatts();
}
}
public Watt AA_AveragePowerDemandCrankElectrics
{
get {
return M2.GetAveragePowerAtCrankFromElectrics();
}
}
public Watt AA_AveragePowerDemandCrankPneumatics
{
get {
return M3.GetAveragePowerDemandAtCrankFromPneumatics();
}
}
public Kilogram AA_TotalCycleFuelConsumptionCompressorOff
{
get {
return M9.TotalCycleFuelConsumptionCompressorOffContinuously;
}
}
public Kilogram AA_TotalCycleFuelConsumptionCompressorOn
{
get {
return M9.TotalCycleFuelConsumptionCompressorOnContinuously;
}
}
}
}
// Copyright 2017 European Union.
// Licensed under the EUPL (the 'Licence');
//
// * You may not use this work except in compliance with the Licence.
// * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
// * Unless required by applicable law or agreed to in writing,
// software distributed under the Licence is distributed on an "AS IS" basis,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the LICENSE.txt for the specific language governing permissions and limitations.
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using Newtonsoft.Json;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Electrics;
using TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC;
using TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Pneumatics;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.PneumaticSystem;
using TUGraz.VectoCore.BusAuxiliaries.Legacy;
namespace TUGraz.VectoCore.BusAuxiliaries {
[Serializable()]
public class AuxiliaryConfig : IAuxiliaryConfig
{
// Vecto
public IVectoInputs VectoInputs { get; set; }
// Electrical
public IElectricsUserInputsConfig ElectricalUserInputsConfig { get; set; }
// Pneumatics
public IPneumaticUserInputsConfig PneumaticUserInputsConfig { get; set; }
public IPneumaticsAuxilliariesConfig PneumaticAuxillariesConfig { get; set; }
// Hvac
public IHVACUserInputsConfig HvacUserInputsConfig { get; set; }
// Vecto Signals
[JsonIgnore]
public ISignals Signals { get; set; }
// Constructors
public AuxiliaryConfig() : this("EMPTY") { }
public AuxiliaryConfig(string auxConfigFile)
{
// Special Condition
if (auxConfigFile == "EMPTY") {
ElectricalUserInputsConfig = new ElectricsUserInputsConfig() { PowerNetVoltage = 28.3 };
ElectricalUserInputsConfig.ElectricalConsumers = new ElectricalConsumerList(28.3, 0.096, false);
ElectricalUserInputsConfig.ResultCardIdle = new ResultCard(new List<SmartResult>());
ElectricalUserInputsConfig.ResultCardOverrun = new ResultCard(new List<SmartResult>());
ElectricalUserInputsConfig.ResultCardTraction = new ResultCard(new List<SmartResult>());
PneumaticAuxillariesConfig = new PneumaticsAuxilliariesConfig(false);
PneumaticUserInputsConfig = new PneumaticUserInputsConfig(false);
HvacUserInputsConfig = new HVACUserInputsConfig(string.Empty, string.Empty, false);
return;
}
if (auxConfigFile == null || auxConfigFile.Trim().Length == 0 || !File.Exists(auxConfigFile))
setDefaults();
else {
setDefaults();
if (!Load(auxConfigFile))
MessageBox.Show(string.Format("Unable to load file {0}", auxConfigFile));
}
}
// Set Default Values
private void setDefaults()
{
var tmp = new VectoInputs
() {
Cycle = "Urban",
VehicleWeightKG = 16500.SI<Kilogram>(),
PowerNetVoltage = 28.3.SI<Volt>()
};
VectoInputs = tmp;
Signals = new Signals() { EngineSpeed = 2000.RPMtoRad(), TotalCycleTimeSeconds = 3114, ClutchEngaged = false };
// Pneumatics set deault values
PneumaticUserInputsConfig = new PneumaticUserInputsConfig(true);
PneumaticAuxillariesConfig = new PneumaticsAuxilliariesConfig(true);
// Electrical set deault values
ElectricalUserInputsConfig = new ElectricsUserInputsConfig(true, tmp);
ElectricalUserInputsConfig.ElectricalConsumers = new ElectricalConsumerList(28.3, 0.096, true);
// HVAC set deault values
HvacUserInputsConfig = new HVACUserInputsConfig(string.Empty, string.Empty, false);
}
private double GetDoorActuationTimeFraction()
{
var actuationsMap = new PneumaticActuationsMap(PneumaticUserInputsConfig.ActuationsMap);
var actuationsKey = new ActuationsKey("Park brake + 2 doors", VectoInputs.Cycle);
var numActuations = actuationsMap.GetNumActuations(actuationsKey);
var secondsPerActuation = ElectricalUserInputsConfig.DoorActuationTimeSecond;
var doorDutyCycleFraction = (numActuations * secondsPerActuation) / (double)Signals.TotalCycleTimeSeconds;
return doorDutyCycleFraction;
}
private bool CompareElectricalConfiguration(AuxiliaryConfig other)
{
// AlternatorGearEfficiency
if (ElectricalUserInputsConfig.AlternatorGearEfficiency != other.ElectricalUserInputsConfig.AlternatorGearEfficiency)
return false;
// AlternatorMap
if (ElectricalUserInputsConfig.AlternatorMap != other.ElectricalUserInputsConfig.AlternatorMap)
return false;
// DoorActuationTimeSecond
if (ElectricalUserInputsConfig.DoorActuationTimeSecond != other.ElectricalUserInputsConfig.DoorActuationTimeSecond)
return false;
// Consumer list
if (ElectricalUserInputsConfig.ElectricalConsumers.Items.Count !=
other.ElectricalUserInputsConfig.ElectricalConsumers.Items.Count)
return false;
int i;
for (i = 0; i <= ElectricalUserInputsConfig.ElectricalConsumers.Items.Count - 1; i++) {
IElectricalConsumer thisConsumer, otherConsumer;
thisConsumer = ElectricalUserInputsConfig.ElectricalConsumers.Items[i];
otherConsumer = other.ElectricalUserInputsConfig.ElectricalConsumers.Items[i];
if (thisConsumer.AvgConsumptionAmps != otherConsumer.AvgConsumptionAmps ||
thisConsumer.BaseVehicle != otherConsumer.BaseVehicle || thisConsumer.Category != otherConsumer.Category ||
thisConsumer.ConsumerName != otherConsumer.ConsumerName ||
thisConsumer.NominalConsumptionAmps != otherConsumer.NominalConsumptionAmps ||
thisConsumer.NumberInActualVehicle != otherConsumer.NumberInActualVehicle ||
thisConsumer.PhaseIdle_TractionOn != otherConsumer.PhaseIdle_TractionOn ||
thisConsumer.TotalAvgConsumptionInWatts() != otherConsumer.TotalAvgConsumptionInWatts() ||
thisConsumer.TotalAvgConumptionAmps() != otherConsumer.TotalAvgConumptionAmps())
return false;
}
// PowerNetVoltage
if (ElectricalUserInputsConfig.PowerNetVoltage != other.ElectricalUserInputsConfig.PowerNetVoltage)
return false;
// ResultCardIdle
if (ElectricalUserInputsConfig.ResultCardIdle.Results.Count !=
other.ElectricalUserInputsConfig.ResultCardIdle.Results.Count)
return false;
for (i = 0; i <= ElectricalUserInputsConfig.ResultCardIdle.Results.Count - 1; i++) {
if (ElectricalUserInputsConfig.ResultCardIdle.Results[i].Amps !=
other.ElectricalUserInputsConfig.ResultCardIdle.Results[i].Amps ||
ElectricalUserInputsConfig.ResultCardIdle.Results[i].SmartAmps !=
other.ElectricalUserInputsConfig.ResultCardIdle.Results[i].SmartAmps)
return false;
}
// ResultCardOverrun
if (ElectricalUserInputsConfig.ResultCardOverrun.Results.Count !=
other.ElectricalUserInputsConfig.ResultCardOverrun.Results.Count)
return false;
for (i = 0; i <= ElectricalUserInputsConfig.ResultCardOverrun.Results.Count - 1; i++) {
if (ElectricalUserInputsConfig.ResultCardOverrun.Results[i].Amps !=
other.ElectricalUserInputsConfig.ResultCardOverrun.Results[i].Amps ||
ElectricalUserInputsConfig.ResultCardOverrun.Results[i].SmartAmps !=
other.ElectricalUserInputsConfig.ResultCardOverrun.Results[i].SmartAmps)
return false;
}
// ResultCardTraction
if (ElectricalUserInputsConfig.ResultCardTraction.Results.Count !=
other.ElectricalUserInputsConfig.ResultCardTraction.Results.Count)
return false;
for (i = 0; i <= ElectricalUserInputsConfig.ResultCardTraction.Results.Count - 1; i++) {
if (ElectricalUserInputsConfig.ResultCardTraction.Results[i].Amps !=
other.ElectricalUserInputsConfig.ResultCardTraction.Results[i].Amps ||
ElectricalUserInputsConfig.ResultCardTraction.Results[i].SmartAmps !=
other.ElectricalUserInputsConfig.ResultCardTraction.Results[i].SmartAmps)
return false;
}
// SmartElectrical
if (ElectricalUserInputsConfig.SmartElectrical != other.ElectricalUserInputsConfig.SmartElectrical)
return false;
return true;
}
private bool ComparePneumaticAuxiliariesConfig(AuxiliaryConfig other)
{
if (PneumaticAuxillariesConfig.AdBlueNIperMinute != other.PneumaticAuxillariesConfig.AdBlueNIperMinute)
return false;
if (PneumaticAuxillariesConfig.AirControlledSuspensionNIperMinute !=
other.PneumaticAuxillariesConfig.AirControlledSuspensionNIperMinute)
return false;
if (PneumaticAuxillariesConfig.BrakingNoRetarderNIperKG != other.PneumaticAuxillariesConfig.BrakingNoRetarderNIperKG)
return false;
if (PneumaticAuxillariesConfig.BrakingWithRetarderNIperKG !=
other.PneumaticAuxillariesConfig.BrakingWithRetarderNIperKG)
return false;
if (PneumaticAuxillariesConfig.BreakingPerKneelingNIperKGinMM !=
other.PneumaticAuxillariesConfig.BreakingPerKneelingNIperKGinMM)
return false;
if (PneumaticAuxillariesConfig.DeadVolBlowOutsPerLitresperHour !=
other.PneumaticAuxillariesConfig.DeadVolBlowOutsPerLitresperHour)
return false;
if (PneumaticAuxillariesConfig.DeadVolumeLitres != other.PneumaticAuxillariesConfig.DeadVolumeLitres)
return false;
if (PneumaticAuxillariesConfig.NonSmartRegenFractionTotalAirDemand !=
other.PneumaticAuxillariesConfig.NonSmartRegenFractionTotalAirDemand)
return false;
if (PneumaticAuxillariesConfig.PerDoorOpeningNI != other.PneumaticAuxillariesConfig.PerDoorOpeningNI)
return false;
if (PneumaticAuxillariesConfig.PerStopBrakeActuationNIperKG !=
other.PneumaticAuxillariesConfig.PerStopBrakeActuationNIperKG)
return false;
if (PneumaticAuxillariesConfig.SmartRegenFractionTotalAirDemand !=
other.PneumaticAuxillariesConfig.SmartRegenFractionTotalAirDemand)
return false;
if (PneumaticAuxillariesConfig.OverrunUtilisationForCompressionFraction !=
other.PneumaticAuxillariesConfig.OverrunUtilisationForCompressionFraction)
return false;
return true;
}
private bool ComparePneumaticUserConfig(AuxiliaryConfig other)
{
if (PneumaticUserInputsConfig.ActuationsMap != other.PneumaticUserInputsConfig.ActuationsMap)
return false;
if (PneumaticUserInputsConfig.AdBlueDosing != other.PneumaticUserInputsConfig.AdBlueDosing)
return false;
if (PneumaticUserInputsConfig.AirSuspensionControl != other.PneumaticUserInputsConfig.AirSuspensionControl)
return false;
if (PneumaticUserInputsConfig.CompressorGearEfficiency != other.PneumaticUserInputsConfig.CompressorGearEfficiency)
return false;
if (PneumaticUserInputsConfig.CompressorGearRatio != other.PneumaticUserInputsConfig.CompressorGearRatio)
return false;
if (PneumaticUserInputsConfig.CompressorMap != other.PneumaticUserInputsConfig.CompressorMap)
return false;
if (PneumaticUserInputsConfig.Doors != other.PneumaticUserInputsConfig.Doors)
return false;
if (PneumaticUserInputsConfig.KneelingHeightMillimeters != other.PneumaticUserInputsConfig.KneelingHeightMillimeters)
return false;
if (PneumaticUserInputsConfig.RetarderBrake != other.PneumaticUserInputsConfig.RetarderBrake)
return false;
if (PneumaticUserInputsConfig.SmartAirCompression != other.PneumaticUserInputsConfig.SmartAirCompression)
return false;
if (PneumaticUserInputsConfig.SmartRegeneration != other.PneumaticUserInputsConfig.SmartRegeneration)
return false;
return true;
}
private bool CompareHVACConfig(AuxiliaryConfig other)
{
if (HvacUserInputsConfig.SSMFilePath != other.HvacUserInputsConfig.SSMFilePath)
return false;
if (HvacUserInputsConfig.BusDatabasePath != other.HvacUserInputsConfig.BusDatabasePath)
return false;
if (HvacUserInputsConfig.SSMDisabled != other.HvacUserInputsConfig.SSMDisabled)
return false;
return true;
}
public bool ConfigValuesAreTheSameAs(AuxiliaryConfig other)
{
if (!CompareElectricalConfiguration(other))
return false;
if (!ComparePneumaticAuxiliariesConfig(other))
return false;
if (!ComparePneumaticUserConfig(other))
return false;
if (!CompareHVACConfig(other))
return false;
return true;
}
// Persistance Functions
public bool Save(string auxFile)
{
var returnValue = true;
var settings = new JsonSerializerSettings();
settings.TypeNameHandling = TypeNameHandling.Objects;
// JSON METHOD
try {
var output = JsonConvert.SerializeObject(this, Formatting.Indented, settings);
File.WriteAllText(auxFile, output);
} catch (Exception ex) {
returnValue = false;
}
return returnValue;
}
public bool Load(string auxFile)
{
var returnValue = true;
var settings = new JsonSerializerSettings();
AuxiliaryConfig tmpAux;
settings.TypeNameHandling = TypeNameHandling.Objects;
// JSON METHOD
try {
var output = File.ReadAllText(auxFile);
tmpAux = JsonConvert.DeserializeObject<AuxiliaryConfig>(output, settings);
// This is where we Assume values of loaded( Deserialized ) object.
AssumeValuesOfOther(tmpAux);
if (tmpAux.VectoInputs.FuelMapFile != null) {
var tmp = new cMAP();
tmp.FilePath = Path.Combine(Path.GetDirectoryName(auxFile), tmpAux.VectoInputs.FuelMapFile);
if (!tmp.ReadFile()) {
MessageBox.Show("Unable to read fuel map, aborting.");
return false;
}
tmp.Triangulate();
VectoInputs.FuelMap = tmp;
}
} catch (Exception ex) {
returnValue = false;
}
return returnValue;
}
// Persistance Helpers
public void AssumeValuesOfOther(AuxiliaryConfig other)
{
CloneElectricaConfiguration(other);
ClonePneumaticsAuxiliariesConfig(other);
ClonePneumaticsUserInputsConfig(other);
CloneHVAC(other);
}
private void CloneElectricaConfiguration(AuxiliaryConfig other)
{
// AlternatorGearEfficiency
ElectricalUserInputsConfig.AlternatorGearEfficiency = other.ElectricalUserInputsConfig.AlternatorGearEfficiency;
// AlternatorMap
ElectricalUserInputsConfig.AlternatorMap = other.ElectricalUserInputsConfig.AlternatorMap;
// DoorActuationTimeSecond
ElectricalUserInputsConfig.DoorActuationTimeSecond = other.ElectricalUserInputsConfig.DoorActuationTimeSecond;
// Electrical Consumer list
ElectricalUserInputsConfig.ElectricalConsumers.Items.Clear();
foreach (var otherConsumer in other.ElectricalUserInputsConfig.ElectricalConsumers.Items) {
var newConsumer = new ElectricalConsumer(
otherConsumer.BaseVehicle, otherConsumer.Category, otherConsumer.ConsumerName, otherConsumer.NominalConsumptionAmps,
otherConsumer.PhaseIdle_TractionOn, otherConsumer.PowerNetVoltage, otherConsumer.NumberInActualVehicle,
otherConsumer.Info);
ElectricalUserInputsConfig.ElectricalConsumers.Items.Add(newConsumer);
}
// PowerNetVoltage
ElectricalUserInputsConfig.PowerNetVoltage = other.ElectricalUserInputsConfig.PowerNetVoltage;
// ResultCardIdle
ElectricalUserInputsConfig.ResultCardIdle.Results.Clear();
foreach (var result in other.ElectricalUserInputsConfig.ResultCardIdle.Results)
ElectricalUserInputsConfig.ResultCardIdle.Results.Add(new SmartResult(result.Amps, result.SmartAmps));
// ResultCardOverrun
ElectricalUserInputsConfig.ResultCardOverrun.Results.Clear();
foreach (var result in other.ElectricalUserInputsConfig.ResultCardOverrun.Results)
ElectricalUserInputsConfig.ResultCardOverrun.Results.Add(new SmartResult(result.Amps, result.SmartAmps));
// ResultCardTraction
ElectricalUserInputsConfig.ResultCardTraction.Results.Clear();
foreach (var result in other.ElectricalUserInputsConfig.ResultCardTraction.Results)
ElectricalUserInputsConfig.ResultCardTraction.Results.Add(new SmartResult(result.Amps, result.SmartAmps));
// SmartElectrical
ElectricalUserInputsConfig.SmartElectrical = other.ElectricalUserInputsConfig.SmartElectrical;
}
private void ClonePneumaticsAuxiliariesConfig(AuxiliaryConfig other)
{
PneumaticAuxillariesConfig.AdBlueNIperMinute = other.PneumaticAuxillariesConfig.AdBlueNIperMinute;
PneumaticAuxillariesConfig.AirControlledSuspensionNIperMinute =
other.PneumaticAuxillariesConfig.AirControlledSuspensionNIperMinute;
PneumaticAuxillariesConfig.BrakingNoRetarderNIperKG = other.PneumaticAuxillariesConfig.BrakingNoRetarderNIperKG;
PneumaticAuxillariesConfig.BrakingWithRetarderNIperKG = other.PneumaticAuxillariesConfig.BrakingWithRetarderNIperKG;
PneumaticAuxillariesConfig.BreakingPerKneelingNIperKGinMM =
other.PneumaticAuxillariesConfig.BreakingPerKneelingNIperKGinMM;
PneumaticAuxillariesConfig.DeadVolBlowOutsPerLitresperHour =
other.PneumaticAuxillariesConfig.DeadVolBlowOutsPerLitresperHour;
PneumaticAuxillariesConfig.DeadVolumeLitres = other.PneumaticAuxillariesConfig.DeadVolumeLitres;
PneumaticAuxillariesConfig.NonSmartRegenFractionTotalAirDemand =
other.PneumaticAuxillariesConfig.NonSmartRegenFractionTotalAirDemand;
PneumaticAuxillariesConfig.PerDoorOpeningNI = other.PneumaticAuxillariesConfig.PerDoorOpeningNI;
PneumaticAuxillariesConfig.PerStopBrakeActuationNIperKG =
other.PneumaticAuxillariesConfig.PerStopBrakeActuationNIperKG;
PneumaticAuxillariesConfig.SmartRegenFractionTotalAirDemand =
other.PneumaticAuxillariesConfig.SmartRegenFractionTotalAirDemand;
PneumaticAuxillariesConfig.OverrunUtilisationForCompressionFraction =
other.PneumaticAuxillariesConfig.OverrunUtilisationForCompressionFraction;
}
private void ClonePneumaticsUserInputsConfig(AuxiliaryConfig other)
{
PneumaticUserInputsConfig.ActuationsMap = other.PneumaticUserInputsConfig.ActuationsMap;
PneumaticUserInputsConfig.AdBlueDosing = other.PneumaticUserInputsConfig.AdBlueDosing;
PneumaticUserInputsConfig.AirSuspensionControl = other.PneumaticUserInputsConfig.AirSuspensionControl;
PneumaticUserInputsConfig.CompressorGearEfficiency = other.PneumaticUserInputsConfig.CompressorGearEfficiency;
PneumaticUserInputsConfig.CompressorGearRatio = other.PneumaticUserInputsConfig.CompressorGearRatio;
PneumaticUserInputsConfig.CompressorMap = other.PneumaticUserInputsConfig.CompressorMap;
PneumaticUserInputsConfig.Doors = other.PneumaticUserInputsConfig.Doors;
PneumaticUserInputsConfig.KneelingHeightMillimeters = other.PneumaticUserInputsConfig.KneelingHeightMillimeters;
PneumaticUserInputsConfig.RetarderBrake = other.PneumaticUserInputsConfig.RetarderBrake;
PneumaticUserInputsConfig.SmartAirCompression = other.PneumaticUserInputsConfig.SmartAirCompression;
PneumaticUserInputsConfig.SmartRegeneration = other.PneumaticUserInputsConfig.SmartRegeneration;
}
private void CloneHVAC(AuxiliaryConfig other)
{
HvacUserInputsConfig.SSMFilePath = other.HvacUserInputsConfig.SSMFilePath;
HvacUserInputsConfig.BusDatabasePath = other.HvacUserInputsConfig.BusDatabasePath;
HvacUserInputsConfig.SSMDisabled = other.HvacUserInputsConfig.SSMDisabled;
}
}
}
......@@ -31,12 +31,19 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\STUDENTEN_PROJEKTE\Kober_VectoGIT\VECTO_GIT\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Omu.ValueInjecter, Version=3.1.1.0, Culture=neutral, PublicKeyToken=c7694541b0ac80e4, processorArchitecture=MSIL">
<HintPath>..\..\packages\ValueInjecter.3.1.1.5\lib\net40\Omu.ValueInjecter.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
......@@ -45,6 +52,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AuxiliaryConfig.cs" />
<Compile Include="AdvancedAuxiliaries.cs" />
<Compile Include="IAuxiliaryConfig.cs" />
<Compile Include="DownstreamModules\Impl\AbstractModule.cs" />
<Compile Include="DownstreamModules\Impl\AlternatorMap.cs" />
<Compile Include="DownstreamModules\Impl\Electrics\Alternator.cs" />
......@@ -57,6 +67,28 @@
<Compile Include="DownstreamModules\Impl\Electrics\CombinedAlternator.cs" />
<Compile Include="DownstreamModules\Impl\Electrics\M00Impl.cs" />
<Compile Include="DownstreamModules\Impl\Electrics\M02Impl.cs" />
<Compile Include="DownstreamModules\Impl\HVAC\Bus.cs" />
<Compile Include="DownstreamModules\Impl\HVAC\BusDatabase.cs" />
<Compile Include="DownstreamModules\Impl\HVAC\BusEngineType.cs" />
<Compile Include="DownstreamModules\Impl\HVAC\SSMTOOL.cs" />
<Compile Include="DownstreamModules\Impl\HVAC\SSMTechList.cs" />
<Compile Include="DownstreamModules\Impl\HVAC\SSMRun.cs" />
<Compile Include="DownstreamModules\Impl\HVAC\SSMGenInputs.cs" />
<Compile Include="DownstreamModules\Impl\HVAC\SSMCalculate.cs" />
<Compile Include="DownstreamModules\Impl\HVAC\HVACUserInputsConfig.cs" />
<Compile Include="DownstreamModules\Impl\HVAC\HVACSteadyStateModel.cs" />
<Compile Include="DownstreamModules\Impl\HVAC\HVACConstants.cs" />
<Compile Include="DownstreamModules\Impl\HVAC\EnvironmentalConditionsMap.cs" />
<Compile Include="DownstreamModules\Impl\HVAC\EnvironmentalCondition.cs" />
<Compile Include="DownstreamModules\Impl\HVAC\DeleteCell.cs" />
<Compile Include="DownstreamModules\Impl\HVAC\DeleteColumn.cs" />
<Compile Include="DownstreamModules\Impl\HVAC\IBusDatabase.cs" />
<Compile Include="DownstreamModules\Impl\HVAC\IBus.cs" />
<Compile Include="DownstreamModules\Impl\HVAC\TechListBenefitLine.cs" />
<Compile Include="DownstreamModules\Impl\Pneumatics\PneumaticUserInputsConfig.cs" />
<Compile Include="DownstreamModules\Impl\Pneumatics\PneumaticsAuxilliariesConfig.cs" />
<Compile Include="DownstreamModules\Impl\Pneumatics\PneumaticActuationsMap.cs" />
<Compile Include="DownstreamModules\Impl\Pneumatics\CompressorMap.cs" />
<Compile Include="DownstreamModules\Impl\Pneumatics\M03Impl.cs" />
<Compile Include="DownstreamModules\Impl\Pneumatics\M04Impl.cs" />
<Compile Include="DownstreamModules\Impl\Electrics\M05Impl.cs" />
......@@ -126,6 +158,9 @@
<Compile Include="Interfaces\IVectoInputs.cs" />
<Compile Include="Interfaces\Signals.cs" />
<Compile Include="Interfaces\VectoInputs.cs" />
<Compile Include="Legacy\cDelaunayMap.cs" />
<Compile Include="Legacy\cFile_V3.cs" />
<Compile Include="Legacy\Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Util\FilePathUtils.cs" />
</ItemGroup>
......@@ -135,7 +170,44 @@
<Name>VectoCommon</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<None Include="Images\application-export-icon-small.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Delete.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
</ItemGroup>
<ItemGroup>
<None Include="Images\Delete1.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Blank.bmp" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\desktop.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\favorites.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\file-history.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Image1.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Info.bmp" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\new_dir.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Open-icon.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
......
......@@ -8,24 +8,18 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the LICENSE.txt for the specific language governing permissions and limitations.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic;
using DownstreamModules.Electrics;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics;
namespace Electrics
namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl
{
public class AlternatorMap : IAlternatorMap
{
......@@ -185,87 +179,18 @@ namespace Electrics
private void getMapRanges()
{
;/* Cannot convert AssignmentStatementSyntax, System.NotImplementedException: Conversion for query clause with kind 'DistinctClause' not implemented
at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.NodesVisitor.<>c__DisplayClass99_0.<ConvertQueryBodyClause>b__0(QueryClauseSyntax _)
at ICSharpCode.CodeConverter.Util.ObjectExtensions.TypeSwitch[TBaseType,TDerivedType1,TDerivedType2,TDerivedType3,TDerivedType4,TResult](TBaseType obj, Func`2 matchFunc1, Func`2 matchFunc2, Func`2 matchFunc3, Func`2 matchFunc4, Func`2 defaultFunc)
at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.NodesVisitor.ConvertQueryBodyClause(QueryClauseSyntax node)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at Microsoft.CodeAnalysis.SyntaxList`1.CreateNode(IEnumerable`1 nodes)
at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.NodesVisitor.VisitQueryExpression(QueryExpressionSyntax node)
at Microsoft.CodeAnalysis.VisualBasic.Syntax.QueryExpressionSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.Visit(SyntaxNode node)
at ICSharpCode.CodeConverter.CSharp.CommentConvertingNodesVisitor.DefaultVisit(SyntaxNode node)
at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.VisitQueryExpression(QueryExpressionSyntax node)
at Microsoft.CodeAnalysis.VisualBasic.Syntax.QueryExpressionSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.NodesVisitor.VisitParenthesizedExpression(ParenthesizedExpressionSyntax node)
at Microsoft.CodeAnalysis.VisualBasic.Syntax.ParenthesizedExpressionSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.Visit(SyntaxNode node)
at ICSharpCode.CodeConverter.CSharp.CommentConvertingNodesVisitor.DefaultVisit(SyntaxNode node)
at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.VisitParenthesizedExpression(ParenthesizedExpressionSyntax node)
at Microsoft.CodeAnalysis.VisualBasic.Syntax.ParenthesizedExpressionSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.NodesVisitor.VisitMemberAccessExpression(MemberAccessExpressionSyntax node)
at Microsoft.CodeAnalysis.VisualBasic.Syntax.MemberAccessExpressionSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.Visit(SyntaxNode node)
at ICSharpCode.CodeConverter.CSharp.CommentConvertingNodesVisitor.DefaultVisit(SyntaxNode node)
at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.VisitMemberAccessExpression(MemberAccessExpressionSyntax node)
at Microsoft.CodeAnalysis.VisualBasic.Syntax.MemberAccessExpressionSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.NodesVisitor.VisitInvocationExpression(InvocationExpressionSyntax node)
at Microsoft.CodeAnalysis.VisualBasic.Syntax.InvocationExpressionSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.Visit(SyntaxNode node)
at ICSharpCode.CodeConverter.CSharp.CommentConvertingNodesVisitor.DefaultVisit(SyntaxNode node)
at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.VisitInvocationExpression(InvocationExpressionSyntax node)
at Microsoft.CodeAnalysis.VisualBasic.Syntax.InvocationExpressionSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.MethodBodyVisitor.VisitAssignmentStatement(AssignmentStatementSyntax node)
at Microsoft.CodeAnalysis.VisualBasic.Syntax.AssignmentStatementSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.Visit(SyntaxNode node)
at ICSharpCode.CodeConverter.CSharp.CommentConvertingMethodBodyVisitor.ConvertWithTrivia(SyntaxNode node)
at ICSharpCode.CodeConverter.CSharp.CommentConvertingMethodBodyVisitor.DefaultVisit(SyntaxNode node)
;/*
Input:
_yRange = (From coords As MapPoint In _map Order By coords.Y Select coords.Y Distinct).ToList()
*/
;/* Cannot convert AssignmentStatementSyntax, System.NotImplementedException: Conversion for query clause with kind 'DistinctClause' not implemented
at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.NodesVisitor.<>c__DisplayClass99_0.<ConvertQueryBodyClause>b__0(QueryClauseSyntax _)
at ICSharpCode.CodeConverter.Util.ObjectExtensions.TypeSwitch[TBaseType,TDerivedType1,TDerivedType2,TDerivedType3,TDerivedType4,TResult](TBaseType obj, Func`2 matchFunc1, Func`2 matchFunc2, Func`2 matchFunc3, Func`2 matchFunc4, Func`2 defaultFunc)
at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.NodesVisitor.ConvertQueryBodyClause(QueryClauseSyntax node)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at Microsoft.CodeAnalysis.SyntaxList`1.CreateNode(IEnumerable`1 nodes)
at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.NodesVisitor.VisitQueryExpression(QueryExpressionSyntax node)
at Microsoft.CodeAnalysis.VisualBasic.Syntax.QueryExpressionSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.Visit(SyntaxNode node)
at ICSharpCode.CodeConverter.CSharp.CommentConvertingNodesVisitor.DefaultVisit(SyntaxNode node)
at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.VisitQueryExpression(QueryExpressionSyntax node)
at Microsoft.CodeAnalysis.VisualBasic.Syntax.QueryExpressionSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.NodesVisitor.VisitParenthesizedExpression(ParenthesizedExpressionSyntax node)
at Microsoft.CodeAnalysis.VisualBasic.Syntax.ParenthesizedExpressionSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.Visit(SyntaxNode node)
at ICSharpCode.CodeConverter.CSharp.CommentConvertingNodesVisitor.DefaultVisit(SyntaxNode node)
at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.VisitParenthesizedExpression(ParenthesizedExpressionSyntax node)
at Microsoft.CodeAnalysis.VisualBasic.Syntax.ParenthesizedExpressionSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.NodesVisitor.VisitMemberAccessExpression(MemberAccessExpressionSyntax node)
at Microsoft.CodeAnalysis.VisualBasic.Syntax.MemberAccessExpressionSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.Visit(SyntaxNode node)
at ICSharpCode.CodeConverter.CSharp.CommentConvertingNodesVisitor.DefaultVisit(SyntaxNode node)
at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.VisitMemberAccessExpression(MemberAccessExpressionSyntax node)
at Microsoft.CodeAnalysis.VisualBasic.Syntax.MemberAccessExpressionSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.NodesVisitor.VisitInvocationExpression(InvocationExpressionSyntax node)
at Microsoft.CodeAnalysis.VisualBasic.Syntax.InvocationExpressionSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.Visit(SyntaxNode node)
at ICSharpCode.CodeConverter.CSharp.CommentConvertingNodesVisitor.DefaultVisit(SyntaxNode node)
at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.VisitInvocationExpression(InvocationExpressionSyntax node)
at Microsoft.CodeAnalysis.VisualBasic.Syntax.InvocationExpressionSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
at ICSharpCode.CodeConverter.CSharp.VisualBasicConverter.MethodBodyVisitor.VisitAssignmentStatement(AssignmentStatementSyntax node)
at Microsoft.CodeAnalysis.VisualBasic.Syntax.AssignmentStatementSyntax.Accept[TResult](VisualBasicSyntaxVisitor`1 visitor)
at Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxVisitor`1.Visit(SyntaxNode node)
at ICSharpCode.CodeConverter.CSharp.CommentConvertingMethodBodyVisitor.ConvertWithTrivia(SyntaxNode node)
at ICSharpCode.CodeConverter.CSharp.CommentConvertingMethodBodyVisitor.DefaultVisit(SyntaxNode node)
;/*
Input:
_xRange = (From coords As MapPoint In _map Order By coords.x Select coords.x Distinct).ToList()
*/
_yRange = _map.Select(x => x.Y).Distinct().OrderBy(x => x).ToList();
_xRange = _map.Select(x => x.x).Distinct().OrderBy(x => x).ToList();
_minX = _xRange.First();
_maxX = _xRange.Last();
_minY = _yRange.First();
......@@ -394,7 +319,7 @@ Input:
public bool Initialise()
{
if (File.Exists(filePath)) {
using (StreamReader sr = new StreamReader(filePath)) {
using (var sr = new StreamReader(filePath)) {
// get array og lines fron csv
var lines = sr.ReadToEnd().Split(new [] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries);
......@@ -413,7 +338,7 @@ Input:
break;
// split the line
string[] elements = line.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
var elements = line.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
// 3 entries per line required
if ((elements.Length != 3))
throw new ArgumentException("Incorrect number of values in csv file");
......
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic;
using DownstreamModules.Electrics;
namespace Electrics
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics;
namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Electrics
{
// Model based on CombinedALTS_V02_Editable.xlsx
public class Alternator : IAlternator
......
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic;
using DownstreamModules.Electrics;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics;
using TUGraz.VectoCore.BusAuxiliaries.Util;
namespace Electrics
namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Electrics
{
public class CombinedAlternator : IAlternatorMap, ICombinedAlternator
{
......@@ -74,7 +67,7 @@ namespace Electrics
// Constructors
public CombinedAlternator(string filePath, ISignals signals = null/* TODO Change to default(_) if this is not a reference type */)
{
string feedback = string.Empty;
var feedback = string.Empty;
this.Signals = signals;
if (!FilePathUtils.ValidateFilePath(filePath, ".aalt", ref feedback))
......@@ -99,7 +92,7 @@ namespace Electrics
// Calculate alternators average which is used only in the pre-run
var efficiencySum = 0.0;
foreach (IAlternator alt in Alternators) {
foreach (var alt in Alternators) {
efficiencySum += alt.InputTable2000.ElementAt(1).Eff;
efficiencySum += alt.InputTable2000.ElementAt(2).Eff;
efficiencySum += alt.InputTable2000.ElementAt(3).Eff;
......@@ -202,8 +195,8 @@ namespace Electrics
return false;
}
IAlternator altToRemove = Alternators.First(w => w.AlternatorName == alternatorName);
int numAlternators = Alternators.Count;
var altToRemove = Alternators.First(w => w.AlternatorName == alternatorName);
var numAlternators = Alternators.Count;
Alternators.Remove(altToRemove);
......@@ -224,7 +217,7 @@ namespace Electrics
sb.AppendLine("[AlternatorName],[RPM],[Amps],[Efficiency],[PulleyRatio]");
// write details
foreach (IAlternator alt in Alternators.OrderBy(o => o.AlternatorName)) {
foreach (var alt in Alternators.OrderBy(o => o.AlternatorName)) {
// 2000 - IE Alt1,2000,10,50,3
for (var row = 1; row <= 3; row++) {
var amps = alt.InputTable2000[row].Amps;
......@@ -255,7 +248,7 @@ namespace Electrics
sb.Append(ToString());
// Write the stream cotnents to a new file named "AllTxtFiles.txt"
using (StreamWriter outfile = new StreamWriter(aaltPath)) {
using (var outfile = new StreamWriter(aaltPath)) {
outfile.Write(sb.ToString());
}
......@@ -274,13 +267,13 @@ namespace Electrics
// Initialises the map, only valid when loadingUI for first time in edit mode or always in operational mode.
private bool InitialiseMap(string filePath)
{
bool returnValue = false;
var returnValue = false;
string[] elements;
if (File.Exists(filePath)) {
using (StreamReader sr = new StreamReader(filePath)) {
using (var sr = new StreamReader(filePath)) {
// get array og lines fron csv
string[] lines = sr.ReadToEnd().Split(new[] { Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries);
var lines = sr.ReadToEnd().Split(new[] { Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries);
// Must have at least 2 entries in map to make it usable [dont forget the header row]
if ((lines.Count() < 10))
......@@ -288,9 +281,9 @@ namespace Electrics
map = new List<ICombinedAlternatorMapRow>();
bool firstline = true;
var firstline = true;
foreach (string line in lines) {
foreach (var line in lines) {
if (!firstline) {
// Advanced Alternator Source Check.
......@@ -326,7 +319,7 @@ namespace Electrics
// Basically it is a check against the model/Spreadsheet
public override string ToString()
{
StringBuilder sb = new StringBuilder();
var sb = new StringBuilder();
string a1, a2, a3, e1, e2, e3;
const string vbTab = "\t";
......@@ -337,7 +330,7 @@ namespace Electrics
sb.AppendLine("******************************************************************");
sb.AppendLine("");
int i = 1;
var i = 1;
sb.AppendLine("Table 1 (2000)" + vbTab + "Table 2 (4000)" + vbTab + "Table 3 (6000)");
sb.AppendLine("Amps" + vbTab + "Eff" + vbTab + "Amps" + vbTab + "Eff" + vbTab + "Amps" + vbTab + "Eff" + vbTab);
sb.AppendLine("");
......@@ -384,7 +377,7 @@ namespace Electrics
if (this.Alternators.Count != other.Alternators.Count)
return false;
foreach (IAlternator alt in this.Alternators) {
foreach (var alt in this.Alternators) {
// Can we find the same alternatorName in other
if (other.Alternators.Where(f => f.AlternatorName == alt.AlternatorName).Count() != 1)
......
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic;
using DownstreamModules.Electrics;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics;
namespace Electrics
namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Electrics
{
// This class is reflective of the stored entries for the combined alternator
// And is used by the Combined Alternator Form and any related classes.
......
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic;
using DownstreamModules.Electrics;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics;
namespace Electrics
namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Electrics
{
// Used by the CombinedAlternator class and any other related classes.
public class CombinedAlternatorSignals : ICombinedAlternatorSignals
......
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic;
using System.ComponentModel;
using DownstreamModules.Electrics;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics;
// Copyright 2017 European Union.
// Licensed under the EUPL (the 'Licence');
......@@ -25,7 +14,7 @@ using TUGraz.VectoCommon.Utils;
//
// See the LICENSE.txt for the specific language governing permissions and limitations.
namespace Electrics
namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Electrics
{
/// <summary>
/// ''' Described a consumer of Alternator electrical power
......@@ -186,7 +175,7 @@ namespace Electrics
if (obj == null || GetType() != obj.GetType())
return false;
IElectricalConsumer other = (IElectricalConsumer)obj;
var other = (IElectricalConsumer)obj;
return this.ConsumerName == other.ConsumerName;
......
......@@ -12,20 +12,11 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic;
using DownstreamModules.Electrics;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics;
namespace Electrics
namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Electrics
{
public class ElectricalConsumerList : IElectricalConsumerList
{
......@@ -53,9 +44,9 @@ namespace Electrics
if (_items.Count != GetDefaultConsumerList().Count)
return;
List<IElectricalConsumer> dflt = GetDefaultConsumerList();
var dflt = GetDefaultConsumerList();
for (int idx = 0; idx <= _items.Count - 1; idx++)
for (var idx = 0; idx <= _items.Count - 1; idx++)
_items[idx].Info = dflt[idx].Info;
}
......@@ -68,7 +59,7 @@ namespace Electrics
// Vehicle Basic Equipment' category can be added or remove by customers.
// At some time in the future, this may be removed and replace with file based consumer lists.
List<IElectricalConsumer> items = new List<IElectricalConsumer>();
var items = new List<IElectricalConsumer>();
IElectricalConsumer c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20;
......
......@@ -9,23 +9,11 @@
//
// See the LICENSE.txt for the specific language governing permissions and limitations.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic;
using DownstreamModules.Electrics;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics;
namespace Electrics
namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Electrics
{
public class ElectricsUserInputsConfig : IElectricsUserInputsConfig
{
......
using System;
using DownstreamModules.Electrics;
using Electrics;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC;
namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Electrics
{
......
using System;
using DownstreamModules.Electrics;
using Electrics;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics;
namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Electrics
{
......
using System;
using DownstreamModules.Electrics;
using Electrics;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics;
namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Electrics
{
......
using System;
using DownstreamModules.Electrics;
using Electrics;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics;
namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Electrics
......
......@@ -11,21 +11,11 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic;
using DownstreamModules.Electrics;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics;
namespace Electrics
namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Electrics
{
public class ResultCard : IResultCard
{
......@@ -77,7 +67,7 @@ namespace Electrics
maxKey = _results.Max().Amps;
minKey = _results.Min().Amps;
SmartResult compareKey = new SmartResult(amps, 0);
var compareKey = new SmartResult(amps, 0);
// Is on boundary check
if (_results.Contains(compareKey))
......
using System;
namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC
{
public class Bus : IBus
{
// Private Property Backing
private int _id;
private string _model;
private string _floorType;
private string _engineType;
private double _lengthInMetres;
private double _widthInMetres;
private double _heightInMetres;
private int _registeredPassengers;
private bool _isDoubleDecker;
public int Id
{
get {
return _id;
}
}
public string Model
{
get {
return _model;
}
set {
if (!ModelOK(value))
throw new ArgumentException("Model argument is invalid");
_model = value;
}
}
public string FloorType
{
get {
return _floorType;
}
set {
if (!FloorTypeOK(value))
throw new ArgumentException("Model argument is invalid");
_floorType = value;
}
}
public string EngineType
{
get {
return _engineType;
}
set {
if (!EngineOK(value))
throw new ArgumentException("EngineType argument is invalid");
_engineType = value;
}
}
public double LengthInMetres
{
get {
return _lengthInMetres;
}
set {
if (!DimensionOK(value))
throw new ArgumentException("Invalid Length");
_lengthInMetres = value;
}
}
public double WidthInMetres
{
get {
return _widthInMetres;
}
set {
if (!DimensionOK(value))
throw new ArgumentException("Invalid Width");
_widthInMetres = value;
}
}
public double HeightInMetres
{
get {
return _heightInMetres;
}
set {
if (!DimensionOK(value))
throw new ArgumentException("Invalid Height");
_heightInMetres = value;
}
}
public int RegisteredPassengers
{
get {
return _registeredPassengers;
}
set {
if (!PassengersOK(value))
throw new ArgumentException("Invalid Number Of Passengers");
_registeredPassengers = value;
}
}
public bool IsDoubleDecker
{
get {
return _isDoubleDecker;
}
set {
_isDoubleDecker = value;
}
}
// Constructors
public Bus(int _id, string _model, string _floorType, string _engineType, double _lengthInMetres, double _widthInMetres, double _heightInMetres, int _registeredPassengers, bool _doubleDecker)
{
// Validity checks.
if (!ModelOK(_model))
throw new ArgumentException("Model argument is invalid");
if (!FloorTypeOK(_floorType))
throw new ArgumentException("Model argument is invalid");
if (!EngineOK(_engineType))
throw new ArgumentException("EngineType argument is invalid");
if (!DimensionOK(_lengthInMetres))
throw new ArgumentException("Invalid Length");
if (!DimensionOK(_widthInMetres))
throw new ArgumentException("Invalid Width");
if (!DimensionOK(_heightInMetres))
throw new ArgumentException("Invalid Height");
if (!PassengersOK(_registeredPassengers))
throw new ArgumentException("Invalid Number Of Passengers");
// Set Private Members
this._id = _id;
this._model = _model;
this._floorType = _floorType;
this._engineType = _engineType;
this._lengthInMetres = _lengthInMetres;
this._widthInMetres = _widthInMetres;
this._heightInMetres = _heightInMetres;
this._registeredPassengers = _registeredPassengers;
this._isDoubleDecker = _doubleDecker;
}
// Construction Validators Helpers
private bool ModelOK(string model)
{
model = model.ToLower();
if (model == null || model.Trim().Length == 0)
return false;
return true;
}
private bool FloorTypeOK(string floorType)
{
floorType = floorType.ToLower();
if (floorType == null || floorType.Trim().Length == 0)
return false;
if (floorType != "raised floor" && floorType != "low floor" && floorType != "semi low floor")
return false;
return true;
}
private bool EngineOK(string engine)
{
engine = engine.ToLower();
if (engine == null || engine.Trim().Length == 0)
return false;
if (engine != "diesel" && engine != "gas" && engine != "hybrid")
return false;
return true;
}
private bool DimensionOK(double dimension)
{
return dimension > 0.5;
}
private bool PassengersOK(int registeredPassengers)
{
return registeredPassengers > 1;
}
// To String function
public override string ToString()
{
return string.Format("{0},{1},{2},{3},{4},{5},{6},{7}", _model, _floorType, _engineType, _lengthInMetres, _widthInMetres, _heightInMetres, _registeredPassengers, _isDoubleDecker);
}
}
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC
{
public class BusDatabase : IBusDatabase
{
private List<IBus> buses = new List<IBus>();
private List<IBus> selectListBuses = new List<IBus>();
public bool AddBus(IBus bus)
{
var result = true;
try {
buses.Add(bus);
} catch (Exception ex) {
result = false;
}
return result;
}
public List<IBus> GetBuses(string busModel, bool AsSelectList = false)
{
if (AsSelectList) {
selectListBuses = new List<IBus>();
selectListBuses = buses.Where(v => v.Model == "" || v.Model.ToLower().Contains(busModel.ToLower())).ToList();
selectListBuses.Insert(0, new Bus(0, "<Select>", "low floor", "gas", 1, 1, 1, 2, false));
return selectListBuses;
}
return buses.Where(v => v.Model == "" || v.Model.ToLower().Contains(busModel.ToLower())).ToList();
}
public bool Initialise(string filepath)
{
var returnStatus = true;
if (File.Exists(filepath)) {
using (var sr = new StreamReader(filepath)) {
// get array og lines fron csv
var lines = sr.ReadToEnd().Split(new [] { Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries);
// Must have at least 2 entries in map to make it usable [dont forget the header row]
if (lines.Length < 2) {
return false;
}
var firstline = true;
var id = 1;
foreach (var line in lines) {
if (!firstline) {
// split the line
var elements = line.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
// 7 or 8 entries per line required
if ((elements.Length != 7 && elements.Length != 8))
throw new ArgumentException("Incorrect number of values in csv file");
// Bus
try {
var bus = new Bus(id, elements[0], elements[1], elements[2], double.Parse(elements[3], CultureInfo.InvariantCulture), double.Parse(elements[4], CultureInfo.InvariantCulture), double.Parse(elements[5], CultureInfo.InvariantCulture), int.Parse(elements[6], CultureInfo.InvariantCulture), elements.Length == 8 ? bool.Parse(elements[7]) : false);
buses.Add(bus);
} catch (Exception ex) {
// Indicate problems
returnStatus = false;
}
id = id + 1;
} else {
firstline = false;
}
}
}
} else {
returnStatus = false;
}
var uniqueBuses = buses.Select(b => b.Model).Distinct().Count();
if (buses.Count != uniqueBuses) {
returnStatus = false;
}
return returnStatus;
}
public bool UpdateBus(int id, IBus bus)
{
var result = true;
try {
var existingBus = buses.Single(b => b.Id == id);
existingBus.Model = bus.Model;
existingBus.RegisteredPassengers = bus.RegisteredPassengers;
existingBus.FloorType = bus.FloorType;
existingBus.LengthInMetres = bus.LengthInMetres;
existingBus.WidthInMetres = bus.WidthInMetres;
existingBus.HeightInMetres = bus.HeightInMetres;
existingBus.IsDoubleDecker = bus.IsDoubleDecker;
} catch (Exception ex) {
result = false;
}
return result;
}
public bool Save(string filepath)
{
var result = true;
var output = new StringBuilder();
try {
output.AppendLine("Bus Model,Type,engine Type,length in m,wide in m,height in m,registered passengers,double decker");
foreach (var bus in buses)
output.AppendLine(bus.ToString());
File.WriteAllText(filepath, output.ToString());
} catch (Exception ex) {
result = false;
}
return result;
}
}
}
namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC
{
public enum BusEngineType
{
Diesal = 1,
Gas = 2,
Hybrid = 3
}
}
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC {
public class DeleteCell : DataGridViewButtonCell
{
public string ToolTip { get; set; } = "Delete tech benefit line";
private Image del = null; //= My.Resources.ResourceManager.GetObject("Delete") as Image;
protected override void Paint(
Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState,
object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle,
DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
{
if (del == null) {
var assembly = Assembly.GetExecutingAssembly();
var file = assembly.GetManifestResourceStream("Delete");
del = Image.FromStream(file);
}
advancedBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Single;
this.ToolTipText = ToolTip;
cellStyle.BackColor = Color.White;
base.Paint(
graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle,
advancedBorderStyle, paintParts);
graphics.DrawImage(del, cellBounds);
}
}
public class DeleteAlternatorCell : DataGridViewButtonCell
{
public string ToolTip { get; set; } = "Delete alternator";
protected Image del = null;
//private Image del = My.Resources.ResourceManager.GetObject("Delete") as Image;
protected override void Paint(
Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState,
object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle,
DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
{
if (del == null) {
var assembly = Assembly.GetExecutingAssembly();
var file = assembly.GetManifestResourceStream("Delete");
del = Image.FromStream(file);
}
advancedBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Single;
this.ToolTipText = ToolTip;
cellStyle.BackColor = Color.White;
base.Paint(
graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle,
advancedBorderStyle, paintParts);
graphics.DrawImage(del, cellBounds);
}
}
}
\ 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