From e7c39cba41abad204046286c5052fb67436ad56d Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Mon, 23 Sep 2019 17:52:19 +0200 Subject: [PATCH] migrating more aaux code from vb to c#, correct namespaces --- .../BusAuxiliaries/AdvancedAuxiliaries.cs | 441 ++++++++++++ VECTOAux/BusAuxiliaries/AuxiliaryConfig.cs | 445 ++++++++++++ VECTOAux/BusAuxiliaries/BusAuxiliaries.csproj | 80 ++- .../DownstreamModules/Impl/AlternatorMap.cs | 93 +-- .../Impl/Electrics/Alternator.cs | 15 +- .../Impl/Electrics/CombinedAlternator.cs | 39 +- .../Electrics/CombinedAlternatorMapRow.cs | 15 +- .../Electrics/CombinedAlternatorSignals.cs | 18 +- .../Impl/Electrics/ElectricalConsumer.cs | 17 +- .../Impl/Electrics/ElectricalConsumerList.cs | 19 +- .../Electrics/ElectricsUserInputsConfig.cs | 14 +- .../Impl/Electrics/M00Impl.cs | 5 +- .../Impl/Electrics/M02Impl.cs | 4 +- .../Impl/Electrics/M05Impl.cs | 4 +- .../Impl/Electrics/M0_5Impl.cs | 3 +- .../Impl/Electrics/ResultCard.cs | 14 +- .../DownstreamModules/Impl/HVAC/Bus.cs | 207 ++++++ .../Impl/HVAC/BusDatabase.cs | 136 ++++ .../Impl/HVAC/BusEngineType.cs | 9 + .../DownstreamModules/Impl/HVAC/DeleteCell.cs | 64 ++ .../Impl/HVAC/DeleteColumn.cs | 19 + .../Impl/HVAC/EnvironmentalCondition.cs | 40 ++ .../Impl/HVAC/EnvironmentalConditionsMap.cs | 73 ++ .../Impl/HVAC/HVACConstants.cs | 60 ++ .../Impl/HVAC/HVACSteadyStateModel.cs | 103 +++ .../Impl/HVAC/HVACUserInputsConfig.cs | 33 + .../DownstreamModules/Impl/HVAC/IBus.cs | 16 + .../Impl/HVAC/IBusDatabase.cs | 17 + .../DownstreamModules/Impl/HVAC/M01Impl.cs | 6 +- .../Impl/HVAC/SSMCalculate.cs | 672 ++++++++++++++++++ .../Impl/HVAC/SSMGenInputs.cs | 424 +++++++++++ .../DownstreamModules/Impl/HVAC/SSMRun.cs | 196 +++++ .../DownstreamModules/Impl/HVAC/SSMTOOL.cs | 270 +++++++ .../Impl/HVAC/SSMTechList.cs | 487 +++++++++++++ .../Impl/HVAC/TechListBenefitLine.cs | 300 ++++++++ .../DownstreamModules/Impl/M06Impl.cs | 7 +- .../DownstreamModules/Impl/M07Impl.cs | 5 +- .../DownstreamModules/Impl/M08Impl.cs | 5 +- .../DownstreamModules/Impl/M09Impl.cs | 5 +- .../DownstreamModules/Impl/M10Impl.cs | 3 +- .../DownstreamModules/Impl/M11Impl.cs | 6 +- .../DownstreamModules/Impl/M12Impl.cs | 4 +- .../DownstreamModules/Impl/M13Impl.cs | 4 +- .../DownstreamModules/Impl/M14Impl.cs | 6 +- .../Impl/Pneumatics/CompressorMap.cs | 270 +++++++ .../Impl/Pneumatics/M03Impl.cs | 5 +- .../Impl/Pneumatics/M04Impl.cs | 3 +- .../Impl/Pneumatics/PneumaticActuationsMap.cs | 91 +++ .../Pneumatics/PneumaticUserInputsConfig.cs | 60 ++ .../PneumaticsAuxilliariesConfig.cs | 65 ++ VECTOAux/BusAuxiliaries/IAuxiliaryConfig.cs | 41 ++ VECTOAux/BusAuxiliaries/Images/Delete-32.png | Bin 0 -> 1430 bytes VECTOAux/BusAuxiliaries/Images/Delete.png | Bin 0 -> 1430 bytes VECTOAux/BusAuxiliaries/Images/Delete1.png | Bin 0 -> 1430 bytes .../Images/application-export-icon-small.png | Bin 0 -> 645 bytes .../Electrics/AltUserInput.cs | 3 +- .../Electrics/ElectricConstants.cs | 2 +- .../Electrics/IAlternator.cs | 2 +- .../Electrics/IAlternatorMap.cs | 4 +- .../Electrics/ICombinedAlternator.cs | 2 +- .../Electrics/ICombinedAlternatorMapRow.cs | 2 +- .../Electrics/ICombinedAlternatorSignals.cs | 2 +- .../Electrics/IElectricalConsumer.cs | 3 +- .../Electrics/IElectricalConsumerList.cs | 2 +- .../Electrics/IElectricsUserInputsConfig.cs | 4 +- .../Electrics/SmartResult.cs | 2 +- .../DownstreamModules/HVAC/Class1.cs | 2 +- .../HVAC/IEnvironmentalCondition.cs | 2 +- .../HVAC/IEnvironmentalConditionsMap.cs | 2 +- .../DownstreamModules/HVAC/IHVACConstants.cs | 2 +- .../HVAC/IHVACSteadyStateModel.cs | 2 +- .../HVAC/IHVACUserInputsConfig.cs | 2 +- .../DownstreamModules/HVAC/ISSMCalculate.cs | 2 +- .../DownstreamModules/HVAC/ISSMGenInputs.cs | 2 +- .../DownstreamModules/HVAC/ISSMRun.cs | 2 +- .../DownstreamModules/HVAC/ISSMTOOL.cs | 58 +- .../DownstreamModules/HVAC/ISSMTechList.cs | 2 +- .../HVAC/ITechListBenefitLine.cs | 2 +- .../DownstreamModules/IAbstractModule.cs | 8 +- .../IM0_5_SmartAlternatorSetEfficiency.cs | 2 +- .../IM0_NonSmart_AlternatorsSetEfficiency.cs | 2 +- .../Interfaces/DownstreamModules/IM10.cs | 3 +- .../Interfaces/DownstreamModules/IM11.cs | 3 +- .../Interfaces/DownstreamModules/IM13.cs | 3 +- .../Interfaces/DownstreamModules/IM14.cs | 3 +- .../IM1_AverageHVACLoadDemand.cs | 2 +- .../IM2_AverageElectrialLoadDemand.cs | 2 +- .../IM3_AveragePneumaticLoadDemand.cs | 2 +- .../DownstreamModules/IM4_AirCompressor.cs | 2 +- .../IM5_SmartAlternatorSetGeneration.cs | 2 +- .../Interfaces/DownstreamModules/IM6.cs | 2 +- .../Interfaces/DownstreamModules/IM7.cs | 3 +- .../Interfaces/DownstreamModules/IM8.cs | 3 +- .../Interfaces/DownstreamModules/IM9.cs | 4 +- .../PneumaticSystem/ActuationsKey.cs | 4 +- .../PneumaticSystem/ICompressorMap.cs | 3 +- .../IPneumaticActuationsMAP.cs | 2 +- .../IPneumaticUserInputsConfig.cs | 2 +- .../IPneumaticsAuxilliariesConfig.cs | 30 +- .../BusAuxiliaries/Interfaces/Enumerations.cs | 12 +- .../Interfaces/IAdvancedAuxiliaries.cs | 2 +- VECTOAux/BusAuxiliaries/Interfaces/IM12.cs | 1 + VECTOAux/BusAuxiliaries/Legacy/Class1.cs | 192 +++++ .../BusAuxiliaries/Legacy/cDelaunayMap.cs | 476 +++++++++++++ VECTOAux/BusAuxiliaries/Legacy/cFile_V3.cs | 175 +++++ VECTOAux/BusAuxiliaries/Resources/Blank.bmp | Bin 0 -> 4150 bytes VECTOAux/BusAuxiliaries/Resources/Image1.png | Bin 0 -> 233 bytes VECTOAux/BusAuxiliaries/Resources/Info.bmp | Bin 0 -> 4150 bytes .../BusAuxiliaries/Resources/Open-icon.png | Bin 0 -> 786 bytes VECTOAux/BusAuxiliaries/Resources/desktop.png | Bin 0 -> 642 bytes .../BusAuxiliaries/Resources/favorites.png | Bin 0 -> 850 bytes .../BusAuxiliaries/Resources/file-history.png | Bin 0 -> 757 bytes VECTOAux/BusAuxiliaries/Resources/new_dir.png | Bin 0 -> 625 bytes VECTOAux/BusAuxiliaries/Util/FilePathUtils.cs | 232 +++--- VECTOAux/BusAuxiliaries/packages.config | 5 + 115 files changed, 5764 insertions(+), 464 deletions(-) create mode 100644 VECTOAux/BusAuxiliaries/AdvancedAuxiliaries.cs create mode 100644 VECTOAux/BusAuxiliaries/AuxiliaryConfig.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/Bus.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/BusDatabase.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/BusEngineType.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/DeleteCell.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/DeleteColumn.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/EnvironmentalCondition.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/EnvironmentalConditionsMap.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/HVACConstants.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/HVACSteadyStateModel.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/HVACUserInputsConfig.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/IBus.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/IBusDatabase.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMCalculate.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMGenInputs.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMRun.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMTOOL.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMTechList.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/TechListBenefitLine.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/CompressorMap.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/PneumaticActuationsMap.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/PneumaticUserInputsConfig.cs create mode 100644 VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/PneumaticsAuxilliariesConfig.cs create mode 100644 VECTOAux/BusAuxiliaries/IAuxiliaryConfig.cs create mode 100644 VECTOAux/BusAuxiliaries/Images/Delete-32.png create mode 100644 VECTOAux/BusAuxiliaries/Images/Delete.png create mode 100644 VECTOAux/BusAuxiliaries/Images/Delete1.png create mode 100644 VECTOAux/BusAuxiliaries/Images/application-export-icon-small.png create mode 100644 VECTOAux/BusAuxiliaries/Legacy/Class1.cs create mode 100644 VECTOAux/BusAuxiliaries/Legacy/cDelaunayMap.cs create mode 100644 VECTOAux/BusAuxiliaries/Legacy/cFile_V3.cs create mode 100644 VECTOAux/BusAuxiliaries/Resources/Blank.bmp create mode 100644 VECTOAux/BusAuxiliaries/Resources/Image1.png create mode 100644 VECTOAux/BusAuxiliaries/Resources/Info.bmp create mode 100644 VECTOAux/BusAuxiliaries/Resources/Open-icon.png create mode 100644 VECTOAux/BusAuxiliaries/Resources/desktop.png create mode 100644 VECTOAux/BusAuxiliaries/Resources/favorites.png create mode 100644 VECTOAux/BusAuxiliaries/Resources/file-history.png create mode 100644 VECTOAux/BusAuxiliaries/Resources/new_dir.png create mode 100644 VECTOAux/BusAuxiliaries/packages.config diff --git a/VECTOAux/BusAuxiliaries/AdvancedAuxiliaries.cs b/VECTOAux/BusAuxiliaries/AdvancedAuxiliaries.cs new file mode 100644 index 0000000000..617b274618 --- /dev/null +++ b/VECTOAux/BusAuxiliaries/AdvancedAuxiliaries.cs @@ -0,0 +1,441 @@ +// 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; + } + } + } +} diff --git a/VECTOAux/BusAuxiliaries/AuxiliaryConfig.cs b/VECTOAux/BusAuxiliaries/AuxiliaryConfig.cs new file mode 100644 index 0000000000..428ff7b874 --- /dev/null +++ b/VECTOAux/BusAuxiliaries/AuxiliaryConfig.cs @@ -0,0 +1,445 @@ +// 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; + } + } +} diff --git a/VECTOAux/BusAuxiliaries/BusAuxiliaries.csproj b/VECTOAux/BusAuxiliaries/BusAuxiliaries.csproj index e1d74c1abf..b4889beeed 100644 --- a/VECTOAux/BusAuxiliaries/BusAuxiliaries.csproj +++ b/VECTOAux/BusAuxiliaries/BusAuxiliaries.csproj @@ -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. diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/AlternatorMap.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/AlternatorMap.cs index 2909cd614a..264d84c505 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/AlternatorMap.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/AlternatorMap.cs @@ -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"); diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/Alternator.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/Alternator.cs index 0d563b0884..d231fad269 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/Alternator.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/Alternator.cs @@ -1,18 +1,9 @@ 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 diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/CombinedAlternator.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/CombinedAlternator.cs index de15bb33d8..668ec47a10 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/CombinedAlternator.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/CombinedAlternator.cs @@ -1,22 +1,15 @@ 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) diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/CombinedAlternatorMapRow.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/CombinedAlternatorMapRow.cs index bf92600190..4b76ce4afe 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/CombinedAlternatorMapRow.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/CombinedAlternatorMapRow.cs @@ -1,18 +1,7 @@ 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. diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/CombinedAlternatorSignals.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/CombinedAlternatorSignals.cs index 7133c281b8..180ea9a3b8 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/CombinedAlternatorSignals.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/CombinedAlternatorSignals.cs @@ -1,19 +1,7 @@ -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 diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricalConsumer.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricalConsumer.cs index 4fa98ab74e..1beaaeb277 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricalConsumer.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricalConsumer.cs @@ -1,18 +1,7 @@ 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; diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricalConsumerList.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricalConsumerList.cs index f5bf2b4606..f535ce8707 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricalConsumerList.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricalConsumerList.cs @@ -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; diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricsUserInputsConfig.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricsUserInputsConfig.cs index ab170636b3..1d068acb5e 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricsUserInputsConfig.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/ElectricsUserInputsConfig.cs @@ -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 { diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/M00Impl.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/M00Impl.cs index 49acda8ec8..ac99ecf368 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/M00Impl.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/M00Impl.cs @@ -1,8 +1,9 @@ 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 { diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/M02Impl.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/M02Impl.cs index e8a8b47ac3..e334c8db64 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/M02Impl.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/M02Impl.cs @@ -1,8 +1,8 @@ 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 { diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/M05Impl.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/M05Impl.cs index 7aeab7f919..23d608d681 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/M05Impl.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/M05Impl.cs @@ -1,7 +1,7 @@ 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 { diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/M0_5Impl.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/M0_5Impl.cs index 037ce76ee8..10318e37c5 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/M0_5Impl.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/M0_5Impl.cs @@ -1,8 +1,7 @@ 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 diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/ResultCard.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/ResultCard.cs index 10376e08cb..99fe0342dc 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/ResultCard.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Electrics/ResultCard.cs @@ -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)) diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/Bus.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/Bus.cs new file mode 100644 index 0000000000..7dbb8d12aa --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/Bus.cs @@ -0,0 +1,207 @@ +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); + } + } +} diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/BusDatabase.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/BusDatabase.cs new file mode 100644 index 0000000000..95cce08dda --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/BusDatabase.cs @@ -0,0 +1,136 @@ +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; + } + } +} diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/BusEngineType.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/BusEngineType.cs new file mode 100644 index 0000000000..5bee1d3394 --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/BusEngineType.cs @@ -0,0 +1,9 @@ +namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC +{ + public enum BusEngineType + { + Diesal = 1, + Gas = 2, + Hybrid = 3 + } +} diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/DeleteCell.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/DeleteCell.cs new file mode 100644 index 0000000000..52c6871448 --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/DeleteCell.cs @@ -0,0 +1,64 @@ +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 diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/DeleteColumn.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/DeleteColumn.cs new file mode 100644 index 0000000000..2a48b0425e --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/DeleteColumn.cs @@ -0,0 +1,19 @@ +using System.Windows.Forms; + +namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC { + public class DeleteColumn : DataGridViewButtonColumn + { + public DeleteColumn() : base() + { + this.CellTemplate = new DeleteCell(); + } + } + + public class DeleteAlternatorColumn : DataGridViewButtonColumn + { + public DeleteAlternatorColumn() : base() + { + this.CellTemplate = new DeleteAlternatorCell(); + } + } +} \ No newline at end of file diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/EnvironmentalCondition.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/EnvironmentalCondition.cs new file mode 100644 index 0000000000..2b0d49eaee --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/EnvironmentalCondition.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using System.Linq; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC; + +namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC +{ + public class EnvironmentalCondition : IEnvironmentalCondition + { + private double _temperature; + private double _solar; + private double _weight; + + public EnvironmentalCondition(double temperature, double solar, double weight) + { + _temperature = temperature; + _solar = solar; + _weight = weight; + } + + public double GetTemperature() + { + return _temperature; + } + + public double GetSolar() + { + return _solar; + } + + public double GetWeighting() + { + return _weight; + } + + public double GetNormalisedWeighting(List<IEnvironmentalCondition> map) + { + return _weight / map.Sum(w => w.GetWeighting()); + } + } +} diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/EnvironmentalConditionsMap.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/EnvironmentalConditionsMap.cs new file mode 100644 index 0000000000..97dffa47d2 --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/EnvironmentalConditionsMap.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC; +using TUGraz.VectoCore.BusAuxiliaries.Util; + +namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC +{ + public class EnvironmentalConditionsMap : IEnvironmentalConditionsMap + { + private string filePath; + private string vectoDirectory; + + private List<IEnvironmentalCondition> _map = new List<IEnvironmentalCondition>(); + + public EnvironmentalConditionsMap(string filepath, string vectoDirectory) + { + this.filePath = filepath; + this.vectoDirectory = vectoDirectory; + + Initialise(); + } + + public bool Initialise() + { + if ((!string.IsNullOrWhiteSpace(filePath))) { + filePath = FilePathUtils.ResolveFilePath(vectoDirectory, filePath); + + 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 1 entries to make it usable [dont forget the header row] + if ((lines.Count() < 2)) + return false; + + var firstline = true; + + foreach (var line in lines) { + if (!firstline) { + + // split the line + var elements = line.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + + // 3 entries per line required + if ((elements.Length != 4)) + return false; + + // Add environment condition + var newCondition = new EnvironmentalCondition(double.Parse(elements[1], CultureInfo.InvariantCulture), double.Parse(elements[2], CultureInfo.InvariantCulture), double.Parse(elements[3], CultureInfo.InvariantCulture)); + + _map.Add(newCondition); + } else + firstline = false; + } + } + } else + return false; + } + + return true; + } + + public List<IEnvironmentalCondition> GetEnvironmentalConditions() + { + return _map; + } + } +} diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/HVACConstants.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/HVACConstants.cs new file mode 100644 index 0000000000..7951d34b9d --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/HVACConstants.cs @@ -0,0 +1,60 @@ +// 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 Newtonsoft.Json; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC; + +namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC +{ + public class HVACConstants : IHVACConstants + { + [JsonProperty("FuelDensity")] + private readonly double _fuelDensity; + [JsonProperty("DieselGCVJperGram")] + private readonly double _dieselGcvJperGram = 44800; + + public HVACConstants() + { + _fuelDensity = 835; // .SI(Of KilogramPerCubicMeter)() + } + + public HVACConstants(KilogramPerCubicMeter fuelDensitySingle) + { + _fuelDensity = fuelDensitySingle.Value(); + } + + + [JsonIgnore] + public JoulePerKilogramm DieselGCVJperGram + { + get { + return _dieselGcvJperGram.SI(Unit.SI.Joule.Per.Gramm).Cast<JoulePerKilogramm>(); + } + } + + [JsonIgnore()] + public KilogramPerCubicMeter FuelDensity + { + get { + return _fuelDensity.SI<KilogramPerCubicMeter>(); + } + } + + [JsonIgnore()] + public double FuelDensityAsGramPerLiter + { + get { + return _fuelDensity * 1000; + } + } + } +} diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/HVACSteadyStateModel.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/HVACSteadyStateModel.cs new file mode 100644 index 0000000000..656ffc9ecf --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/HVACSteadyStateModel.cs @@ -0,0 +1,103 @@ +// 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.IO; +using System.Linq; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC; + +namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC +{ + public class HVACSteadyStateModel : IHVACSteadyStateModel + { + public float HVACElectricalLoadPowerWatts { get; set; } + public float HVACFuellingLitresPerHour { get; set; } + public float HVACMechanicalLoadPowerWatts { get; set; } + + // Constructors + public HVACSteadyStateModel() + { + } + + public HVACSteadyStateModel(float elecPowerW, float mechPowerW, float fuellingLPH) + { + HVACElectricalLoadPowerWatts = elecPowerW; + HVACFuellingLitresPerHour = mechPowerW; + HVACMechanicalLoadPowerWatts = fuellingLPH; + } + + // Implementation + public bool SetValuesFromMap(string filePath, ref string message) + { + string myData; + string[] linesArray; + + var vbLf = '\n'; + + // Check map file can be found. + try { + myData = System.IO.File.ReadAllText(filePath, System.Text.Encoding.UTF8); + } catch (FileNotFoundException ex) { + message = "HVAC Steady State Model : The map file was not found"; + return false; + } + + + linesArray = (from s in myData.Split(vbLf) + select s.Trim()).ToArray(); + + // Check count is at least 2 rows + if (linesArray.Count() < 2) { + message = "HVAC Steady State Model : Insufficient Lines in this File"; + return false; + } + + // validate headers + var headers = linesArray[0].Split(','); + if (headers.Length != 3 || headers[0].Trim() != "[Electrical Power (w)]" || headers[1].Trim() != "[Mechanical Power (w)]" || headers[2].Trim() != "[Fuelling (L/H)]") { + message = "HVAC Steady State Model : Column headers in *.AHSM file being read are incompatable."; + return false; + } + + // validate values + var values = linesArray[1].Split(','); + double unused; + if (headers.Length != 3 || !double.TryParse(values[0], out unused) || !double.TryParse(values[1], out unused) || !double.TryParse(values[2], out unused)) { + message = "Steady State Model : Unable to confirm numeric values in the *.AHSM file being read."; + return false; + } + + // OK we have the values so lets set the properties + float out1, out2, out3; + out1 = HVACElectricalLoadPowerWatts; + out2 = HVACMechanicalLoadPowerWatts; + out3 = HVACFuellingLitresPerHour; + try { + HVACElectricalLoadPowerWatts = float.Parse(values[0]); + HVACMechanicalLoadPowerWatts = float.Parse(values[1]); + HVACFuellingLitresPerHour = float.Parse(values[2]); + } catch (Exception ex) { + + // Restore in the event of failure to fully assign + HVACElectricalLoadPowerWatts = out1; + HVACMechanicalLoadPowerWatts = out2; + HVACFuellingLitresPerHour = out3; + + // Return result + message = "Steady State Model : Unable to parse the values in the *.AHSM file being read no values were harmed in reading of this file."; + return false; + } + + + return true; + } + } +} diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/HVACUserInputsConfig.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/HVACUserInputsConfig.cs new file mode 100644 index 0000000000..ef2bc763dc --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/HVACUserInputsConfig.cs @@ -0,0 +1,33 @@ +// 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 TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC; + +namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC +{ + public class HVACUserInputsConfig : IHVACUserInputsConfig + { + + // Constructor + public HVACUserInputsConfig(string ssmFilePath, string busDatabasePath, bool isDisabled) + { + this.SSMFilePath = ssmFilePath; + this.BusDatabasePath = busDatabasePath; + this.SSMDisabled = isDisabled; + } + + public string SSMFilePath { get; set; } + + public string BusDatabasePath { get; set; } + + public bool SSMDisabled { get; set; } + } +} diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/IBus.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/IBus.cs new file mode 100644 index 0000000000..452e9f583e --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/IBus.cs @@ -0,0 +1,16 @@ +namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC +{ + public interface IBus + { + int Id { get; } + + string Model { get; set; } + string FloorType { get; set; } + string EngineType { get; set; } + double LengthInMetres { get; set; } + double WidthInMetres { get; set; } + double HeightInMetres { get; set; } + int RegisteredPassengers { get; set; } + bool IsDoubleDecker { get; set; } + } +} diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/IBusDatabase.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/IBusDatabase.cs new file mode 100644 index 0000000000..32cf843ba2 --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/IBusDatabase.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC +{ + public interface IBusDatabase + { + bool AddBus(IBus bus); + + List<IBus> GetBuses(string busModel, bool AsSelectList = false); + + bool Initialise(string busFileCSV); + + bool UpdateBus(int id, IBus bus); + + bool Save(string filepath); + } +} diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/M01Impl.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/M01Impl.cs index 9c0763ddd8..b5cc278a90 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/M01Impl.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/M01Impl.cs @@ -1,9 +1,9 @@ using System; -using DownstreamModules.Electrics; -using Electrics; -using Hvac; 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.HVAC { diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMCalculate.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMCalculate.cs new file mode 100644 index 0000000000..b206d71468 --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMCalculate.cs @@ -0,0 +1,672 @@ +using System; +using System.Text; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC; + +namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC +{ + // Modeling SSHVAC V07 + public class SSMCalculate : ISSMCalculate + { + private ISSMTOOL ssmTOOL; + public ISSMRun Run1 { get; set; } + public ISSMRun Run2 { get; set; } + + // Constructor + public SSMCalculate(ISSMTOOL ssmTool) + { + this.ssmTOOL = ssmTool; + Run1 = new SSMRun(this.ssmTOOL, 1); + Run2 = new SSMRun(this.ssmTOOL, 2); + } + + + // BASE RESULTS + public double ElectricalWBase + { + get { + var ElectricalWBaseWeightedAverage = 0.0; + var gen = ssmTOOL.GenInputs; + var EC_EnviromentalTemperatureBefore = gen.EC_EnviromentalTemperature; + var EC_SolarBefore = gen.EC_Solar; + + // If batch mode is disabled use the EC_EnviromentalTemperature and EC_Solar variables. + // Else if batch is enable calculate the ElectricalWBase for each input in the AENV file and then calculate the weighted average + if (!gen.EC_EnviromentalConditions_BatchEnabled) + ElectricalWBaseWeightedAverage = CalculateElectricalWBase(gen, gen.EC_EnviromentalTemperature, gen.EC_Solar, 1); + else { + foreach (var envCondition in gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions()) + ElectricalWBaseWeightedAverage += CalculateElectricalWBase(gen, envCondition.GetTemperature(), envCondition.GetSolar(), envCondition.GetNormalisedWeighting(gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions())); + gen.EC_EnviromentalTemperature = EC_EnviromentalTemperatureBefore; + gen.EC_Solar = EC_SolarBefore; + } + + return ElectricalWBaseWeightedAverage; + } + } + + public double MechanicalWBase + { + get { + var MechanicalWBaseWeightedAverage = 0.0; + var gen = ssmTOOL.GenInputs; + var EC_EnviromentalTemperatureBefore = gen.EC_EnviromentalTemperature; + var EC_SolarBefore = gen.EC_Solar; + + // If batch mode is disabled use the EC_EnviromentalTemperature and EC_Solar variables. + // Else if batch is enable calculate the MechanicalWBase for each input in the AENV file and then calculate the weighted average + if (!gen.EC_EnviromentalConditions_BatchEnabled) + MechanicalWBaseWeightedAverage = CalculateMechanicalWBase(gen, gen.EC_EnviromentalTemperature, gen.EC_Solar, 1); + else { + foreach (var envCondition in gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions()) + MechanicalWBaseWeightedAverage += CalculateMechanicalWBase(gen, envCondition.GetTemperature(), envCondition.GetSolar(), envCondition.GetNormalisedWeighting(gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions())); + gen.EC_EnviromentalTemperature = EC_EnviromentalTemperatureBefore; + gen.EC_Solar = EC_SolarBefore; + } + + return MechanicalWBaseWeightedAverage; + } + } + + public double FuelPerHBase + { + get { + var FuelLPerHBaseWeightedAverage = 0.0; + var gen = ssmTOOL.GenInputs; + var EC_EnviromentalTemperatureBefore = gen.EC_EnviromentalTemperature; + var EC_SolarBefore = gen.EC_Solar; + + // If batch mode is disabled use the EC_EnviromentalTemperature and EC_Solar variables. + // Else if batch is enable calculate the FuelLPerHBase for each input in the AENV file and then calculate the weighted average + if (!gen.EC_EnviromentalConditions_BatchEnabled) + FuelLPerHBaseWeightedAverage = CalculateFuelLPerHBase(gen, gen.EC_EnviromentalTemperature, gen.EC_Solar, 1); + else { + foreach (var envCondition in gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions()) + FuelLPerHBaseWeightedAverage += CalculateFuelLPerHBase(gen, envCondition.GetTemperature(), envCondition.GetSolar(), envCondition.GetNormalisedWeighting(gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions())); + gen.EC_EnviromentalTemperature = EC_EnviromentalTemperatureBefore; + gen.EC_Solar = EC_SolarBefore; + } + + return FuelLPerHBaseWeightedAverage; + } + } + + // ADJUSTED RESULTS + public double ElectricalWAdjusted + { + get { + var ElectricalWAdjustedAverage = 0.0; + var gen = ssmTOOL.GenInputs; + var tl = ssmTOOL.TechList; + var EC_EnviromentalTemperatureBefore = gen.EC_EnviromentalTemperature; + var EC_SolarBefore = gen.EC_Solar; + + // If batch mode is disabled use the EC_EnviromentalTemperature and EC_Solar variables. + // Else if batch is enable calculate the ElectricalWAdjusted for each input in the AENV file and then calculate the weighted average + if (!gen.EC_EnviromentalConditions_BatchEnabled) + ElectricalWAdjustedAverage = CalculateElectricalWAdjusted(gen, tl, gen.EC_EnviromentalTemperature, gen.EC_Solar, 1); + else { + foreach (var envCondition in gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions()) + ElectricalWAdjustedAverage += CalculateElectricalWAdjusted(gen, tl, envCondition.GetTemperature(), envCondition.GetSolar(), envCondition.GetNormalisedWeighting(gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions())); + gen.EC_EnviromentalTemperature = EC_EnviromentalTemperatureBefore; + gen.EC_Solar = EC_SolarBefore; + } + + return ElectricalWAdjustedAverage; + } + } + + public double MechanicalWBaseAdjusted + { + get { + var MechanicalWBaseAdjustedAverage = 0.0; + var gen = ssmTOOL.GenInputs; + var tl = ssmTOOL.TechList; + var EC_EnviromentalTemperatureBefore = gen.EC_EnviromentalTemperature; + var EC_SolarBefore = gen.EC_Solar; + + // If batch mode is disabled use the EC_EnviromentalTemperature and EC_Solar variables. + // Else if batch is enable calculate the MechanicalWBaseAdjusted for each input in the AENV file and then calculate the weighted average + if (!gen.EC_EnviromentalConditions_BatchEnabled) + MechanicalWBaseAdjustedAverage = CalculateMechanicalWBaseAdjusted(gen, tl, gen.EC_EnviromentalTemperature, gen.EC_Solar, 1); + else { + foreach (var envCondition in gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions()) + MechanicalWBaseAdjustedAverage += CalculateMechanicalWBaseAdjusted(gen, tl, envCondition.GetTemperature(), envCondition.GetSolar(), envCondition.GetNormalisedWeighting(gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions())); + gen.EC_EnviromentalTemperature = EC_EnviromentalTemperatureBefore; + gen.EC_Solar = EC_SolarBefore; + } + + return MechanicalWBaseAdjustedAverage; + } + } + + public double FuelPerHBaseAdjusted + { + get { + var FuelLPerHBaseAdjustedAverage = 0.0; + var gen = ssmTOOL.GenInputs; + var tl = ssmTOOL.TechList; + var EC_EnviromentalTemperatureBefore = gen.EC_EnviromentalTemperature; + var EC_SolarBefore = gen.EC_Solar; + + // If batch mode is disabled use the EC_EnviromentalTemperature and EC_Solar variables. + // Else if batch is enable calculate the FuelLPerHBaseAdjusted for each input in the AENV file and then calculate the weighted average + if (!gen.EC_EnviromentalConditions_BatchEnabled) + FuelLPerHBaseAdjustedAverage = CalculateFuelLPerHBaseAdjusted(gen, tl, gen.EC_EnviromentalTemperature, gen.EC_Solar, 1); + else { + foreach (var envCondition in gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions()) + FuelLPerHBaseAdjustedAverage += CalculateFuelLPerHBaseAdjusted(gen, tl, envCondition.GetTemperature(), envCondition.GetSolar(), envCondition.GetNormalisedWeighting(gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions())); + gen.EC_EnviromentalTemperature = EC_EnviromentalTemperatureBefore; + gen.EC_Solar = EC_SolarBefore; + } + + return FuelLPerHBaseAdjustedAverage; + } + } + + + + + // Base Values + public double BaseHeatingW_Mechanical + { + get { + return default(Double); + } + } + + public double BaseHeatingW_ElectricalCoolingHeating + { + get { + return default(Double); + } + } + + public double BaseHeatingW_ElectricalVentilation + { + get { + // =IF(AND(M89<0,M90<0),IF(AND(C62="yes",C66="high"),C33,IF(AND(C62="yes",C66="low"),C34,0)),0) + + var gen = ssmTOOL.GenInputs; + + // Dim C33 = gen.BC_HighVentPowerW + // Dim C34 = gen.BC_LowVentPowerW + // Dim C62 = gen.VEN_VentilationONDuringHeating + // Dim C66 = gen.VEN_VentilationDuringHeating + // Dim M89 = Me.Run1.TotalW + // Dim M90 = Me.Run2.TotalW + + double res; + + res = Run1.TotalW < 0 && Run2.TotalW < 0 ? gen.VEN_VentilationOnDuringHeating && gen.VEN_VentilationDuringHeating.ToLower() == "high" ? gen.BC_HighVentPowerW : gen.VEN_VentilationOnDuringHeating && gen.VEN_VentilationDuringHeating.ToLower() == "low" ? gen.BC_LowVentPowerW : 0 : 0; + + + return res; + } + } + + public double BaseHeatingW_FuelFiredHeating + { + get { + // =IF(AND(M89<0,M90<0),VLOOKUP(MAX(M89:M90),M89:O90,3),0) + + // Dim M89 = Me.Run1.TotalW + // Dim M90 = Me.Run2.TotalW + // VLOOKUP(MAX(M89:M90),M89:O90 => VLOOKUP ( lookupValue, tableArray, colIndex, rangeLookup ) + + // If both Run TotalW values are >=0 then return FuelW from Run with largest TotalW value, else return 0 + if ((Run1.TotalW < 0 && Run2.TotalW < 0)) + return Run1.TotalW > Run2.TotalW ? Run1.FuelW : Run2.FuelW; + else + return 0; + } + } + + public double BaseCoolingW_Mechanical + { + get { + // =IF(C46<C28,0,IF(C53="electrical", 0, IF(AND(M89>0,M90>0),MIN(M89:M90),0))) + + var gen = ssmTOOL.GenInputs; + + // Dim C46 = gen.EC_EnviromentalTemperature + // Dim C28 = gen.BC_TemperatureCoolingTurnsOff + // Dim C53 = gen.AC_CompressorTypeDerived + // Dim M89 = Run1.TotalW + // Dim M90 = Run2.TotalW + + return gen.EC_EnviromentalTemperature < gen.BC_TemperatureCoolingTurnsOff ? 0 : gen.AC_CompressorTypeDerived.ToLower() == "electrical" ? 0 : Run1.TotalW > 0 && Run2.TotalW > 0 ? Math.Min(Run1.TotalW, Run2.TotalW) : 0; + } + } + + public double BaseCoolingW_ElectricalCoolingHeating + { + get { + // =IF(C46<C28,0,IF(C53="electrical",IF(AND(M89>0,M90>0),MIN(M89:M90),0),0)) + + var gen = ssmTOOL.GenInputs; + + // Dim C46 = gen.EC_EnviromentalTemperature + // Dim C28 = gen.BC_TemperatureCoolingTurnsOff + // Dim C53 = gen.AC_CompressorTypeDerived + // Dim M89 = Run1.TotalW + // Dim M90 = Run2.TotalW + + return gen.EC_EnviromentalTemperature < gen.BC_TemperatureCoolingTurnsOff ? 0 : gen.AC_CompressorTypeDerived.ToLower() == "electrical" ? Run1.TotalW > 0 && Run2.TotalW > 0 ? Math.Min(Run1.TotalW, Run2.TotalW) : 0 : 0; + } + } + + public double BaseCoolingW_ElectricalVentilation + { + get { + // =IF(AND(C46>=C28,M89>0,M90>0),IF(AND(C64="yes",C67="high"),C33,IF(AND(C64="yes",C67="low"),C34,0)),0) + + var gen = ssmTOOL.GenInputs; + + // Dim C46 = gen.EC_EnviromentalTemperature + // Dim C28 = gen.BC_TemperatureCoolingTurnsOff + // Dim M89 = Run1.TotalW + // Dim M90 = Run2.TotalW + // Dim C64 = gen.VEN_VentilationDuringAC + // Dim C67 = gen.VEN_VentilationDuringCooling + // Dim C33 = gen.BC_HighVentPowerW + // Dim C34 = gen.BC_LowVentPowerW + + return gen.EC_EnviromentalTemperature >= gen.BC_TemperatureCoolingTurnsOff && Run1.TotalW > 0 && Run2.TotalW > 0 ? gen.VEN_VentilationDuringAC && gen.VEN_VentilationDuringCooling.ToLower() == "high" ? gen.BC_HighVentPowerW : gen.VEN_VentilationDuringAC && gen.VEN_VentilationDuringCooling.ToLower() == "low" ? gen.BC_LowVentPowerW : 0 : 0; + } + } + + public double BaseCoolingW_FuelFiredHeating + { + get { + return 0; + } + } + + public double BaseVentilationW_Mechanical + { + get { + return default(Double); + } + } + + public double BaseVentilationW_ElectricalCoolingHeating + { + get { + return default(Double); + } + } + + public double BaseVentilationW_ElectricalVentilation + { + get { + // =IF(OR(AND(C46<C28,M89>0,M90>0),AND(M89>0,M90<0)),IF(AND(C63="yes",C65="high"),C33,IF(AND(C63="yes",C65="low"),C34,0)),0) + + var gen = ssmTOOL.GenInputs; + + // Dim C46 = gen.EC_EnviromentalTemperature + // Dim C28 = gen.BC_TemperatureCoolingTurnsOff + // Dim M89 = Run1.TotalW + // Dim M90 = Run2.TotalW + // Dim C63 = gen.VEN_VentilationWhenBothHeatingAndACInactive + // Dim C65 = gen.VEN_VentilationFlowSettingWhenHeatingAndACInactive + // Dim C33 = gen.BC_HighVentPowerW + // Dim C34 = gen.BC_LowVentPowerW + + return (gen.EC_EnviromentalTemperature < gen.BC_TemperatureCoolingTurnsOff && Run1.TotalW > 0 && Run2.TotalW > 0) || (Run1.TotalW > 0 && Run2.TotalW < 0) ? gen.VEN_VentilationWhenBothHeatingAndACInactive && gen.VEN_VentilationFlowSettingWhenHeatingAndACInactive.ToLower() == "high" ? gen.BC_HighVentPowerW : gen.VEN_VentilationWhenBothHeatingAndACInactive && gen.VEN_VentilationFlowSettingWhenHeatingAndACInactive.ToLower() == "low" ? gen.BC_LowVentPowerW : 0 : 0; + } + } + + public double BaseVentilationW_FuelFiredHeating + { + get { + return 0; + } + } + + // Adjusted Values + public double TechListAdjustedHeatingW_Mechanical + { + get { + return default(Double); + } + } + + public double TechListAdjustedHeatingW_ElectricalCoolingHeating + { + get { + return default(Double); + } + } + + public double TechListAdjustedHeatingW_ElectricalVentilation + { + get { + // =IF('TECH LIST INPUT'!O92>0,MIN('TECH LIST INPUT'!O92,C43),MAX('TECH LIST INPUT'!O92,-C43)) + var gen = ssmTOOL.GenInputs; + var tl = ssmTOOL.TechList; + + // TECH LIST INPUT'!O92 + // Dim C43 As Double = gen.BC_MaxPossibleBenefitFromTechnologyList + // Dim TLO92 As Double = tl.VHValueVariation + + + return tl.VHValueVariation > 0 ? Math.Min(tl.VHValueVariation, gen.BC_MaxPossibleBenefitFromTechnologyList) : Math.Max(tl.VHValueVariation, -gen.BC_MaxPossibleBenefitFromTechnologyList); + } + } + + public double TechListAdjustedHeatingW_FuelFiredHeating + { + get { + // =IF('TECH LIST INPUT'!N92>0,MIN('TECH LIST INPUT'!N92,C43),MAX('TECH LIST INPUT'!N92,-C43)) + + var gen = ssmTOOL.GenInputs; + var tl = ssmTOOL.TechList; + + // TECH LIST INPUT'!N92 + // Dim C43 As Double = gen.BC_MaxPossibleBenefitFromTechnologyList + // Dim TLN92 As Double = tl.HValueVariation + + + return tl.HValueVariation > 0 ? Math.Min(tl.HValueVariation, gen.BC_MaxPossibleBenefitFromTechnologyList) : Math.Max(tl.HValueVariation, -gen.BC_MaxPossibleBenefitFromTechnologyList); + } + } + + public double TechListAdjustedCoolingW_Mechanical + { + get { + // =IF(IF(C53="mechanical",'TECH LIST INPUT'!R92,0)>0,MIN(IF(C53="mechanical",'TECH LIST INPUT'!R92,0),C43),MAX(IF(C53="mechanical",'TECH LIST INPUT'!R92,0),-C43)) + + var gen = ssmTOOL.GenInputs; + var tl = ssmTOOL.TechList; + double result; + // Dim TLR92 As Double = tl.CValueVariation 'TECH LIST INPUT'!R92 + // Dim C43 As Double = gen.BC_MaxPossibleBenefitFromTechnologyList + // Dim C53 As string = gen.AC_CompressorType + + result = gen.AC_CompressorType.ToLower() == "mechanical" ? tl.CValueVariation : 0 > 0 ? Math.Min(gen.AC_CompressorType.ToLower() == "mechanical" ? tl.CValueVariation : 0, gen.BC_MaxPossibleBenefitFromTechnologyList) : Math.Max(gen.AC_CompressorType.ToLower() == "mechanical" ? tl.CValueVariation : 0, -gen.BC_MaxPossibleBenefitFromTechnologyList); + + return result; + } + } + + public double TechListAdjustedCoolingW_ElectricalCoolingHeating + { + get { + // =IF(IF(C53="mechanical",0,'TECH LIST INPUT'!R92)>0,MIN(IF(C53="mechanical",0,'TECH LIST INPUT'!R92),C43),MAX(IF(C53="mechanical",0,'TECH LIST INPUT'!R92),-C43)) + + var gen = ssmTOOL.GenInputs; + var tl = ssmTOOL.TechList; + double result; + + // Dim TLR92 As Double = tl.CValueVariation 'TECH LIST INPUT'!R92 + // Dim C43 As Double = gen.BC_MaxPossibleBenefitFromTechnologyList + // Dim C53 As string = gen.AC_CompressorType + + result = gen.AC_CompressorType.ToLower() == "mechanical" ? 0 : tl.CValueVariation > 0 ? Math.Min(gen.AC_CompressorType.ToLower() == "mechanical" ? 0 : tl.CValueVariation, gen.BC_MaxPossibleBenefitFromTechnologyList) : Math.Max(gen.AC_CompressorType.ToLower() == "mechanical" ? 0 : tl.CValueVariation, -gen.BC_MaxPossibleBenefitFromTechnologyList); + + return result; + } + } + + public double TechListAdjustedCoolingW_ElectricalVentilation + { + get { + // =IF('TECH LIST INPUT'!Q92>0,MIN('TECH LIST INPUT'!Q92,C43),MAX('TECH LIST INPUT'!Q92,-C43)) + + var gen = ssmTOOL.GenInputs; + var tl = ssmTOOL.TechList; + + // Dim TLQ92 As Double = tl.VCValueVariation'TECH LIST INPUT'!Q92 + // Dim C43 As Double = gen.BC_MaxPossibleBenefitFromTechnologyList + + return tl.VCValueVariation > 0 ? Math.Min(tl.VCValueVariation, gen.BC_MaxPossibleBenefitFromTechnologyList) : Math.Max(tl.VCValueVariation, -gen.BC_MaxPossibleBenefitFromTechnologyList); + } + } + + public double TechListAdjustedCoolingW_FuelFiredHeating + { + get { + return 0; + } + } + + public double TechListAdjustedVentilationW_Mechanical + { + get { + return default(Double); + } + } + + public double TechListAdjustedVentilationW_ElectricalCoolingHeating + { + get { + return default(Double); + } + } + + public double TechListAdjustedVentilationW_ElectricalVentilation + { + get { + // =IF('TECH LIST INPUT'!P92>0,MIN('TECH LIST INPUT'!P92,C43),MAX('TECH LIST INPUT'!P92,-C43)) + + var gen = ssmTOOL.GenInputs; + var tl = ssmTOOL.TechList; + + // Dim TLP92 As Double = tl.VVValueVariation 'TECH LIST INPUT'!P92 + // Dim C43 As Double = gen.BC_MaxPossibleBenefitFromTechnologyList + + + return tl.VVValueVariation > 0 ? Math.Min(tl.VVValueVariation, gen.BC_MaxPossibleBenefitFromTechnologyList) : Math.Max(tl.VVValueVariation, -gen.BC_MaxPossibleBenefitFromTechnologyList); + } + } + + public double TechListAdjustedVentilationW_FuelFiredHeating + { + get { + return 0; + } + } + + + // Provides Diagnostic Information for the user which can be displayed on the form. + // Based on the inputs generated, can be used to cross reference the Excel Model with the + // Outputs generated here. + public override string ToString() + { + var sb = new StringBuilder(); + var vbTab = "\t"; + + sb.AppendLine(""); + sb.AppendLine("TechList Detail"); + sb.AppendLine("***********************"); + + var nameLength = 40; + var catLength = 15; + var unitLength = 15; + var firstValuePos = nameLength + catLength + unitLength + 2; + string cat; + string name; + string units; + + sb.AppendLine(string.Format(new string(' ', firstValuePos) + "H{0}VH{0}VV{0}VC{0}C{0}", vbTab)); + + + foreach (var line in ssmTOOL.TechList.TechLines) { + { + var withBlock = line; + int extraNameSpaces, extraCatSpaces, extraUnitSpaces; + + extraNameSpaces = nameLength - withBlock.BenefitName.Length; + extraCatSpaces = catLength - withBlock.Category.Length; + extraUnitSpaces = unitLength - withBlock.Units.Length; + + cat = line.Category.Substring(0, Math.Min(line.Category.Length, catLength)) + new string(' ', extraCatSpaces < 0 ? 0 : extraCatSpaces).Replace(" ", "."); + name = line.BenefitName.Substring(0, Math.Min(line.BenefitName.Length, nameLength)) + new string(' ', extraNameSpaces < 0 ? 0 : extraNameSpaces).Replace(" ", "."); + units = line.Units.Substring(0, Math.Min(line.Units.Length, unitLength)) + new string(' ', extraUnitSpaces < 0 ? 0 : extraUnitSpaces).Replace(" ", "."); + + sb.AppendLine(string.Format(units + cat + name + " {0}{1}{0}{2}{0}{3}{0}{4}{0}{5}", vbTab, withBlock.H.ToString("0.000"), withBlock.VH.ToString("0.000"), withBlock.VV.ToString("0.000"), withBlock.VC.ToString("0.000"), withBlock.C.ToString("0.000"))); + } + } + + sb.AppendLine(""); + sb.AppendLine("TechList Totals"); + sb.AppendLine("***********************"); + + { + var withBlock = ssmTOOL.TechList; + sb.AppendLine(vbTab + vbTab + "H" + vbTab + "VH" + vbTab + "VV" + vbTab + "VC" + vbTab + "C"); + sb.AppendLine(string.Format("Base Var % {0}{1}{0}{2}{0}{3}{0}{4}{0}{5}", vbTab, withBlock.HValueVariation.ToString("0.000"), withBlock.VHValueVariation.ToString("0.000"), withBlock.VVValueVariation.ToString("0.000"), withBlock.VCValueVariation.ToString("0.000"), withBlock.CValueVariation.ToString("0.000"))); + sb.AppendLine(string.Format("Base Var KW {0}{1}{0}{2}{0}{3}{0}{4}{0}{5}", vbTab, withBlock.HValueVariationKW.ToString("0.000"), withBlock.VHValueVariationKW.ToString("0.000"), withBlock.VVValueVariationKW.ToString("0.000"), withBlock.VCValueVariationKW.ToString("0.000"), withBlock.CValueVariationKW.ToString("0.000"))); + } + + + // Runs + sb.AppendLine(Run1.ToString()); + sb.AppendLine(Run2.ToString()); + + // Staging Calcs + sb.AppendLine("Staging Base Values"); + sb.AppendLine("*******************"); + sb.AppendLine(vbTab + vbTab + vbTab + "Mechanical" + vbTab + "Elec Cool/Heat" + vbTab + "Elec Vent" + vbTab + "Fuel Fired Heating"); + + sb.AppendLine(string.Format("Heating {0}{1}{0}{2}{0}{3}{0}{4}", vbTab + vbTab, BaseHeatingW_Mechanical.ToString("0.00"), BaseHeatingW_ElectricalCoolingHeating.ToString("0.00"), BaseHeatingW_ElectricalVentilation.ToString("0.00"), BaseHeatingW_FuelFiredHeating.ToString("0.00"))); + sb.AppendLine(string.Format("Cooling {0}{1}{0}{2}{0}{3}{0}{4}", vbTab + vbTab, BaseCoolingW_Mechanical.ToString("0.00"), BaseCoolingW_ElectricalCoolingHeating.ToString("0.00"), BaseCoolingW_ElectricalVentilation.ToString("0.00"), BaseCoolingW_FuelFiredHeating.ToString("0.00"))); + sb.AppendLine(string.Format("Ventilate {0}{1}{0}{2}{0}{3}{0}{4}", vbTab + vbTab, BaseVentilationW_Mechanical.ToString("0.00"), BaseVentilationW_ElectricalCoolingHeating.ToString("0.00"), BaseVentilationW_ElectricalVentilation.ToString("0.00"), BaseVentilationW_FuelFiredHeating.ToString("0.00"))); + + sb.AppendLine(""); + sb.AppendLine("Staging Adjusted Values"); + sb.AppendLine("***********************"); + + sb.AppendLine(string.Format("Heating {0}{1}{0}{2}{0}{3}{0}{4}", vbTab + vbTab, TechListAdjustedHeatingW_Mechanical.ToString("0.00"), TechListAdjustedHeatingW_ElectricalCoolingHeating.ToString("0.00"), TechListAdjustedHeatingW_ElectricalVentilation.ToString("0.00"), TechListAdjustedHeatingW_FuelFiredHeating.ToString("0.00"))); + sb.AppendLine(string.Format("Cooling {0}{1}{0}{2}{0}{3}{0}{4}", vbTab + vbTab, TechListAdjustedCoolingW_Mechanical.ToString("0.00"), TechListAdjustedCoolingW_ElectricalCoolingHeating.ToString("0.00"), TechListAdjustedCoolingW_ElectricalVentilation.ToString("0.00"), TechListAdjustedCoolingW_FuelFiredHeating.ToString("0.00"))); + sb.AppendLine(string.Format("Ventilate {0}{1}{0}{2}{0}{3}{0}{4}", vbTab + vbTab, TechListAdjustedVentilationW_Mechanical.ToString("0.00"), TechListAdjustedVentilationW_ElectricalCoolingHeating.ToString("0.00"), TechListAdjustedVentilationW_ElectricalVentilation.ToString("0.00"), TechListAdjustedVentilationW_FuelFiredHeating.ToString("0.00"))); + + + return sb.ToString(); + } + + private double CalculateElectricalWBase(ISSMGenInputs genInputs, double EnviromentalTemperature, double Solar, double Weight) + { + + // MIN(SUM(H94),C54*1000)/C59+SUM(I93:I95) + + genInputs.EC_EnviromentalTemperature = EnviromentalTemperature; + genInputs.EC_Solar = Solar; + + // Dim H94 = BaseCoolingW_ElectricalCoolingHeating + // Dim C54 = genInputs.AC_CompressorCapacitykW + // Dim C59 = genInputs.AC_COP + // Dim I93 = BaseHeatingW_ElectricalVentilation + // Dim I94 = BaseCoolingW_ElectricalVentilation + // Dim I95 = BaseVentilationW_ElectricalVentilation + + var ElectricalWBaseCurrentResult = Math.Min(BaseCoolingW_ElectricalCoolingHeating, genInputs.AC_CompressorCapacitykW * 1000) / (double)genInputs.AC_COP + BaseHeatingW_ElectricalVentilation + BaseCoolingW_ElectricalVentilation + BaseVentilationW_ElectricalVentilation; + + return ElectricalWBaseCurrentResult * Weight; + } + + private double CalculateMechanicalWBase(ISSMGenInputs genInputs, double EnviromentalTemperature, double Solar, double Weight) + { + + // =MIN(F94,C54*1000)/C59 + + genInputs.EC_EnviromentalTemperature = EnviromentalTemperature; + genInputs.EC_Solar = Solar; + + // Dim F94 = BaseCoolingW_Mechanical + // Dim C54 = genInputs.AC_CompressorCapacitykW + // Dim C59 = genInputs.AC_COP + + var MechanicalWBaseCurrentResult = Math.Min(BaseCoolingW_Mechanical, genInputs.AC_CompressorCapacitykW * 1000) / (double)genInputs.AC_COP; + + return MechanicalWBaseCurrentResult * Weight; + } + + private double CalculateFuelLPerHBase(ISSMGenInputs genInputs, double EnviromentalTemperature, double Solar, double Weight) + { + + // =(MIN(ABS(J93/1000),C71)/C37)*(1/(C39*C38)) + + genInputs.EC_EnviromentalTemperature = EnviromentalTemperature; + genInputs.EC_Solar = Solar; + + // Dim J93 = BaseHeatingW_FuelFiredHeating + // Dim C71 = genInputs.AH_FuelFiredHeaterkW + // Dim C37 = genInputs.BC_AuxHeaterEfficiency + // Dim C39 = ssmTOOL.HVACConstants.FuelDensity + // Dim C38 = genInputs.BC_GCVDieselOrHeatingOil + + var FuelLPerHBaseCurrentResult = (Math.Min(Math.Abs(BaseHeatingW_FuelFiredHeating / 1000), genInputs.AH_FuelFiredHeaterkW) / (double)genInputs.BC_AuxHeaterEfficiency) * (1 / (double)(genInputs.BC_GCVDieselOrHeatingOil * ssmTOOL.HVACConstants.FuelDensityAsGramPerLiter)); + + return FuelLPerHBaseCurrentResult * Weight; + } + + private double CalculateElectricalWAdjusted(ISSMGenInputs genInputs, ISSMTechList tecList, double EnviromentalTemperature, double Solar, double Weight) + { + + // =(MIN((H94*(1-H100)),C54*1000)/C59)+(I93*(1-I99))+(I94*(1-I100))+(I95*(1-I101)) + + genInputs.EC_EnviromentalTemperature = EnviromentalTemperature; + genInputs.EC_Solar = Solar; + + var H94 = BaseCoolingW_ElectricalCoolingHeating; + var H100 = TechListAdjustedCoolingW_ElectricalCoolingHeating; + var C54 = genInputs.AC_CompressorCapacitykW; + var C59 = genInputs.AC_COP; + + var I93 = BaseHeatingW_ElectricalVentilation; + var I94 = BaseCoolingW_ElectricalVentilation; + var I95 = BaseVentilationW_ElectricalVentilation; + var I99 = TechListAdjustedHeatingW_ElectricalVentilation; + var I100 = TechListAdjustedCoolingW_ElectricalVentilation; + var I101 = TechListAdjustedVentilationW_ElectricalVentilation; + + var ElectricalWAdjusted = (Math.Min((H94 * (1 - H100)), C54 * 1000) / C59) + (I93 * (1 - I99)) + (I94 * (1 - I100)) + (I95 * (1 - I101)); + + return ElectricalWAdjusted * Weight; + } + + private double CalculateMechanicalWBaseAdjusted(ISSMGenInputs genInputs, ISSMTechList tecList, double EnviromentalTemperature, double Solar, double Weight) + { + + // =(MIN((F94*(1-F100)),C54*1000)/C59) + + genInputs.EC_EnviromentalTemperature = EnviromentalTemperature; + genInputs.EC_Solar = Solar; + + var F94 = BaseCoolingW_Mechanical; + var F100 = TechListAdjustedCoolingW_Mechanical; + var C54 = genInputs.AC_CompressorCapacitykW; + var C59 = genInputs.AC_COP; + + var MechanicalWBaseAdjusted = (Math.Min((F94 * (1 - F100)), C54 * 1000) / C59); + + return MechanicalWBaseAdjusted * Weight; + } + + private double CalculateFuelLPerHBaseAdjusted(ISSMGenInputs genInputs, ISSMTechList tecList, double EnviromentalTemperature, double Solar, double Weight) + { + + // =MIN(ABS(IF(AND(M89<0,M90<0),VLOOKUP(MAX(M89:M90),M89:P90,4),0)/1000),C71)/C37*(1/(C39*C38)) + + genInputs.EC_EnviromentalTemperature = EnviromentalTemperature; + genInputs.EC_Solar = Solar; + + // Dim M89 = Run1.TotalW + // Dim M90 = genInputs.BC_GCVDieselOrHeatingOil + // Dim C71 = genInputs.AH_FuelFiredHeaterkW + // Dim C37 = genInputs.BC_AuxHeaterEfficiency + // Dim C38 = genInputs.BC_GCVDieselOrHeatingOil + // Dim C39 = ssmTOOL.HVACConstants.FuelDensity + + double result = 0; + + if (Run1.TotalW < 0 && Run2.TotalW < 0) + result = Math.Abs(Run1.TotalW > Run2.TotalW ? Run1.TechListAmendedFuelW : Run2.TechListAmendedFuelW / (double)1000); + + var FuelLPerHBaseAdjusted = Math.Min(result, genInputs.AH_FuelFiredHeaterkW) / (double)genInputs.BC_AuxHeaterEfficiency * (1 / (double)(genInputs.BC_GCVDieselOrHeatingOil * ssmTOOL.HVACConstants.FuelDensityAsGramPerLiter)); + + return FuelLPerHBaseAdjusted * Weight; + } + } +} diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMGenInputs.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMGenInputs.cs new file mode 100644 index 0000000000..90bb2fe732 --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMGenInputs.cs @@ -0,0 +1,424 @@ +using System; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC; + +namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC +{ + // Used by SSMHVAC Class + public class SSMGenInputs : ISSMGenInputs + { + private string _EC_EnviromentalConditions_BatchFile; + private IEnvironmentalConditionsMap _EC_EnvironmentalConditionsMap; + private string _vectoDir; + + + public SSMGenInputs(bool initialiseDefaults = false, string vectoDir = "") + { + _vectoDir = vectoDir; + BP_BusModel = ""; + BP_BusFloorType = ""; + EC_EnviromentalConditions_BatchFile = ""; + AC_CompressorType = ""; + VEN_VentilationDuringCooling = ""; + VEN_VentilationDuringHeating = ""; + VEN_VentilationFlowSettingWhenHeatingAndACInactive = ""; + if (initialiseDefaults) + SetDefaults(); + } + + + + // C4/D4 + public string BP_BusModel { get; set; } + + // C5/D5 + public double BP_NumberOfPassengers { get; set; } + + // C6/D6 + public string BP_BusFloorType { get; set; } + + // D7/C7 - ( M/2 ) + public double BP_BusFloorSurfaceArea + { + get { + + // =IF(AND(C6="low floor",C13<=2.55,C13>=2.5),(2.55*(C12-1.2)),((C12-1.2)*C13)) + if (BP_BusFloorType == "low floor" && BP_BusWidth <= 2.55 && BP_BusWidth >= 2.5) + return Math.Round((2.55 * (BP_BusLength - 1.2)), 6); + else + return Math.Round(((BP_BusLength - 1.2) * BP_BusWidth), 6); + } + } + + // D8/C8 - ( M/2 ) + public double BP_BusSurfaceAreaM2 + { + get { + // 2 * (C12*C13 + C12*C14 + C13*C14) + return 2 * ((BP_BusLength * BP_BusWidth) + (BP_BusLength * BP_BusHeight) + (BP_BusWidth * BP_BusHeight)); + } + } + + // D9/C9 - ( M/2 ) + public double BP_BusWindowSurface + { + get { + // =(C40*C12)+C41 + return (BC_WindowAreaPerUnitBusLength * BP_BusLength) + BC_FrontRearWindowArea; + } + } + + // C10/D10 + public bool BP_DoubleDecker { get; set; } + + // D11/C11 - ( M/3 ) + public double BP_BusVolume + { + get { + // =(C12*C13*C14) + return (BP_BusLength * BP_BusWidth * BP_BusHeight); + } + } + + // D12/C12 - ( M ) + public double BP_BusLength { get; set; } + + // D13/C13 - ( M ) + public double BP_BusWidth { get; set; } + + // D14/C14 - ( M ) + public double BP_BusHeight { get; set; } + + + + // C17 + public double BC_GFactor { get; set; } + + // C18 + public double BC_SolarClouding + { + get { + // =IF(C46<17,0.65,0.8) + return EC_EnviromentalTemperature < 17 ? 0.65 : 0.8; + } + } + + // C19 - ( W ) + public double BC_HeatPerPassengerIntoCabinW + { + get { + // =IF(C46<17,50,80) + return EC_EnviromentalTemperature < 17 ? 50 : 80; + } + } + + // C20 - ( oC ) + public double BC_PassengerBoundaryTemperature { get; set; } + + // C21 - ( Passenger/Metre Squared ) + public double BC_PassengerDensityLowFloor + { + get { + // =IF($C$10="No",3,3.7) + return BP_DoubleDecker ? 3.7 : 3; + } + } + + // C22 - ( Passenger/Metre Squared ) + public double BC_PassengerDensitySemiLowFloor + { + get { + // =IF($C$10="No",2.2,3) + return BP_DoubleDecker ? 3 : 2.2; + } + } + + // C23 - ( Passenger/Metre Squared ) + public double BC_PassengerDensityRaisedFloor + { + get { + // =IF($C$10="No",1.4,2) + return BP_DoubleDecker ? 2 : 1.4; + } + } + + // C24 + public double BC_CalculatedPassengerNumber + { + get { + // =ROUND(IF($D$5<IF(D6="low floor",C21,IF(D6="semi low floor",C22,C23))*D7,$D$5,IF(D6="low floor",C21,IF(D6="semi low floor",C22,C23))*D7),0) + var tmp = BP_BusFloorType == "low floor" ? BC_PassengerDensityLowFloor : BP_BusFloorType == "semi low floor" ? BC_PassengerDensitySemiLowFloor : BC_PassengerDensityRaisedFloor * BP_BusFloorSurfaceArea; + return Math.Round(BP_NumberOfPassengers < tmp ? BP_NumberOfPassengers : tmp, 0); + } + } + + // C25 - ( W/K/M3 ) + public double BC_UValues + { + get { + // =IF(D6="low floor",4,IF(D6="semi low floor",3.5,3)) + return BP_BusFloorType == "low floor" ? 4 : BP_BusFloorType == "semi low floor" ? 3.5 : 3; + } + } + + // C26 - ( oC ) + public double BC_HeatingBoundaryTemperature { get; set; } + + // C27 - ( oC ) + public double BC_CoolingBoundaryTemperature { get; set; } + + // C28 - ( oC ) + public double BC_TemperatureCoolingTurnsOff + { + get { + return 17; + } + } + + // C29 - ( L/H ) + public double BC_HighVentilation { get; set; } + + // C30 - ( L/H ) + public double BC_lowVentilation { get; set; } + + // C31 - ( M3/H ) + public double BC_High + { + get { + // =D11*C29 + return BP_BusVolume * BC_HighVentilation; + } + } + + // C32 - ( M3/H ) + public double BC_Low + { + get { + // =C30*D11 + return BP_BusVolume * BC_lowVentilation; + } + } + + // C33 - ( W ) + public double BC_HighVentPowerW + { + get { + // =C31*C35 + return BC_High * BC_SpecificVentilationPower; + } + } + + // C34 - ( W ) + public double BC_LowVentPowerW + { + get { + // =C32*C35 + return BC_Low * BC_SpecificVentilationPower; + } + } + + // C35 - ( Wh/M3 ) + public double BC_SpecificVentilationPower { get; set; } + + // C37 + public double BC_AuxHeaterEfficiency { get; set; } + + // C38 - ( KW/HKG ) + public double BC_GCVDieselOrHeatingOil { get; set; } + + // C40 - ( M2/M ) + public double BC_WindowAreaPerUnitBusLength + { + get { + // =IF($C$10="No",1.5,2.5) + return BP_DoubleDecker ? 2.5 : 1.5; + } + } + + // C41 - ( M/2 ) + public double BC_FrontRearWindowArea + { + get { + // =IF($C$10="No",5,8) + return BP_DoubleDecker ? 8 : 5; + } + } + + // C42 - ( K ) + public double BC_MaxTemperatureDeltaForLowFloorBusses { get; set; } + + // C43 - ( Fraction ) + public double BC_MaxPossibleBenefitFromTechnologyList { get; set; } + + + + // C46 - ( oC ) + public double EC_EnviromentalTemperature { get; set; } + + // C47 - ( W/M3 ) + public double EC_Solar { get; set; } + + // ( EC_EnviromentalTemperature and EC_Solar) (Batch Mode) + public IEnvironmentalConditionsMap EC_EnvironmentalConditionsMap + { + get { + return _EC_EnvironmentalConditionsMap; + } + } + + public string EC_EnviromentalConditions_BatchFile + { + get { + return _EC_EnviromentalConditions_BatchFile; + } + set { + _EC_EnvironmentalConditionsMap = new EnvironmentalConditionsMap(value, _vectoDir); + _EC_EnviromentalConditions_BatchFile = value; + } + } + + public bool EC_EnviromentalConditions_BatchEnabled { get; set; } + + + + // C53 - "Continous/2-stage/3-stage/4-stage + public string AC_CompressorType { get; set; } + + // mechanical/electrical + public string AC_CompressorTypeDerived + { + get { + return AC_CompressorType == "Continuous" ? "Electrical" : "Mechanical"; + } + } + + // C54 - ( KW ) + public double AC_CompressorCapacitykW { get; set; } + + // C59 + public double AC_COP + { + get { + var cop = 3.5D; + + if ((AC_CompressorType != null)) { + cop = AC_CompressorType.ToLower() == "3-stage" ? cop * 1.02 : cop; + cop = AC_CompressorType.ToLower() == "4-stage" ? cop * 1.02 : cop; + cop = AC_CompressorType.ToLower() == "continuous" ? BP_BusFloorType.ToLower() == "low floor" ? cop * 1.04 : cop * 1.06 : cop; + } + + return Math.Round(cop, 2); + } + } + + + + // C62 - Boolean Yes/No + public bool VEN_VentilationOnDuringHeating { get; set; } + + // C63 - Boolean Yes/No + public bool VEN_VentilationWhenBothHeatingAndACInactive { get; set; } + + // C64 - Boolean Yes/No + public bool VEN_VentilationDuringAC { get; set; } + + // C65 - String high/low + public string VEN_VentilationFlowSettingWhenHeatingAndACInactive { get; set; } + + // C66 - String high/low + public string VEN_VentilationDuringHeating { get; set; } + + // C67 - String high/low + public string VEN_VentilationDuringCooling { get; set; } + + + + // C70 - ( KW ) + public double AH_EngineWasteHeatkW { get; set; } + + // C71 - ( KW ) + public double AH_FuelFiredHeaterkW { get; set; } + + public double AH_FuelEnergyToHeatToCoolant { get; set; } + + public double AH_CoolantHeatTransferredToAirCabinHeater { get; set; } + + + + private void SetDefaults() + { + + // BUS Parameterisation + // ******************** + BP_BusModel = "DummyBus"; + BP_NumberOfPassengers = 47.0D; + BP_BusFloorType = "raised floor"; + BP_DoubleDecker = false; + BP_BusLength = 10.655D; + BP_BusWidth = 2.55D; + BP_BusHeight = 2.275D; + // BP_BusFloorSurfaceArea : Calculated + // BP_BusSurfaceAreaM2 : Calculated + // BP_BusWindowSurface : Calculated + // BP_BusVolume : Calculated + + // BOUNDRY CONDITIONS + // ****************** + + BC_GFactor = 0.95D; + // BC_SolarClouding As Double :Calculated + // BC_HeatPerPassengerIntoCabinW :Calculated + BC_PassengerBoundaryTemperature = 12.0D; + // BC_PassengerDensityLowFloor :Calculated + // BC_PassengerDensitySemiLowFloor :Calculated + // BC_PassengerDensityRaisedFloor :Calculated + // BC_CalculatedPassengerNumber :Calculated + // BC_UValues :Calculated + BC_HeatingBoundaryTemperature = 18.0D; + BC_CoolingBoundaryTemperature = 23.0D; + // BC_CoolingBoundaryTemperature : ReadOnly Static + BC_HighVentilation = 20.0D; + BC_lowVentilation = 7.0D; + // BC_High :Calculated + // BC_Low :Calculated + // BC_HighVentPowerW :Calculated + // BC_LowVentPowerW :Calculated + BC_SpecificVentilationPower = 0.56D; + // BC_COP :Calculated + BC_AuxHeaterEfficiency = 0.84D; + BC_GCVDieselOrHeatingOil = 11.8D; + // BC_WindowAreaPerUnitBusLength :Calculated + // BC_FrontRearWindowArea :Calculated + BC_MaxTemperatureDeltaForLowFloorBusses = 3.0D; + BC_MaxPossibleBenefitFromTechnologyList = 0.5D; + + // Environmental Conditions + // ************************ + EC_EnviromentalTemperature = 25.0D; + EC_Solar = 400.0D; + EC_EnviromentalConditions_BatchEnabled = true; + EC_EnviromentalConditions_BatchFile = "DefaultClimatic.aenv"; + + // AC SYSTEM + // ********* + AC_CompressorType = "2-stage"; + AC_CompressorCapacitykW = 18.0D; + + + // VENTILATION + // *********** + VEN_VentilationOnDuringHeating = true; + VEN_VentilationWhenBothHeatingAndACInactive = true; + VEN_VentilationDuringAC = true; + VEN_VentilationFlowSettingWhenHeatingAndACInactive = "high"; + VEN_VentilationDuringHeating = "high"; + VEN_VentilationDuringCooling = "high"; + + + // AUX HEATER + // ********** + AH_FuelFiredHeaterkW = 30.0D; + AH_FuelEnergyToHeatToCoolant = 0.2; + AH_CoolantHeatTransferredToAirCabinHeater = 0.75; + } + } +} diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMRun.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMRun.cs new file mode 100644 index 0000000000..76fca6a627 --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMRun.cs @@ -0,0 +1,196 @@ +using System; +using System.Text; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC; + +namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC +{ + + // Used By SSMHVAC Class + public class SSMRun : ISSMRun + { + private ISSMTOOL ssmTOOL; + private int runNumber; + + + public SSMRun(ISSMTOOL ssm, int runNbr) + { + if (runNbr != 1 && runNbr != 2) + throw new ArgumentException("Run number must be either 1 or 2"); + + runNumber = runNbr; + ssmTOOL = ssm; + } + + + public double HVACOperation + { + get { + // =IF(C43>C25,3,IF(C43<C24,1,2)) + // C43 = EC_Enviromental Temperature + // C25 = BC_CoolingBoundary Temperature + // C24 = BC_HeatingBoundaryTemperature + + var gen = ssmTOOL.GenInputs; + + return gen.EC_EnviromentalTemperature > gen.BC_CoolingBoundaryTemperature ? 3 : gen.EC_EnviromentalTemperature < gen.BC_HeatingBoundaryTemperature ? 1 : 2; + } + } + public double TCalc + { + get { + + // C24 = BC_HeatingBoundaryTemperature + // C25 = BC_CoolingBoundary Temperature + // C6 = BP_BusFloorType + // C43 = EC_Enviromental Temperature + // C39 = BC_FontAndRearWindowArea + + var gen = ssmTOOL.GenInputs; + double returnVal; + + if (runNumber == 1) + returnVal = gen.BC_HeatingBoundaryTemperature; + else + returnVal = gen.BP_BusFloorType == "low floor" ? (gen.EC_EnviromentalTemperature - gen.BC_CoolingBoundaryTemperature) < gen.BC_FrontRearWindowArea ? gen.BC_CoolingBoundaryTemperature : gen.EC_EnviromentalTemperature - 3 : gen.BC_CoolingBoundaryTemperature; + + + return returnVal; + } + } + public double TemperatureDelta + { + get { + // =C43-F79/F80 + // C43 = EC_Enviromental Temperature + // F79/80 = Me.TCalc + + var gen = ssmTOOL.GenInputs; + return gen.EC_EnviromentalTemperature - TCalc; + } + } + public double QWall + { + get { + // =I79*D8*C23 or '=I80*D8*C23 + // Translated to + // =I79*C8*C23 or '=I80*C8*C23 + + // C23 = BC_UValues + // C8 = BP_BusSurfaceAreaM2 + // I78/I80 = Me.TemperatureDelta + + var gen = ssmTOOL.GenInputs; + + return TemperatureDelta * gen.BP_BusSurfaceAreaM2 * gen.BC_UValues; + } + } + public double WattsPerPass + { + get { + + // =IF(D5="",C22,IF(E5="",IF(C22<D5,C22,D5),E5))*C17 + // Translated to + // =IF(IF(C22<C5,C22,C5))*C17 + // Simplified to + // Max( C22,C5 ) + + // C5 = BP_NumberOfPassengers + // C22 = BC_Calculated Passenger Number + // C17 = BC_Heat Per Passenger into cabin + + + var gen = ssmTOOL.GenInputs; + + return Math.Min(gen.BP_NumberOfPassengers, gen.BC_CalculatedPassengerNumber) * gen.BC_HeatPerPassengerIntoCabinW; + } + } + public double Solar + { + get { + // =C44*D9*C15*C16*0.25 + // Translated to + // =C44*C9*C15*C16*0.25 + + // C44 = EC_Solar + // C9 = BP_BusWindowSurfaceArea + // C15 = BC_GFactor + // C16 = BC_SolarClouding + + var gen = ssmTOOL.GenInputs; + + + return gen.EC_Solar * gen.BP_BusWindowSurface * gen.BC_GFactor * gen.BC_SolarClouding * 0.25; + } + } + public double TotalW + { + get { + + // =SUM(J79:L79) or =SUM(J80:L80) + // Tanslated to + // =Sum ( Me.Qwall ,Me.WattsPerPass,Me.Solar ) + + return QWall + WattsPerPass + Solar; + } + } + public double TotalKW + { + get { + // =M79 or =M80 / (1000) + + return TotalW / 1000; + } + } + public double FuelW + { + get { + // =IF(AND(N79<0,N79<(C60*-1)),N79-(C60*-1),0)*1000 + + var gen = ssmTOOL.GenInputs; + + // Dim N79 as Double = TotalKW + // Dim C60 As Double = gen.AH_EngineWasteHeatkW + + return (TotalKW < 0 && TotalKW < (gen.AH_EngineWasteHeatkW * -1)) ? TotalKW - (gen.AH_EngineWasteHeatkW * -1) : 0 + * 1000; + } + } + public double TechListAmendedFuelW + { + get { + // =IF(IF(AND((N79*(1-$J$89))<0,(N79*(1-$J$89))<(C60*-1)),(N79*(1-$J$89))-(C60*-1),0)*1000<0,IF(AND((N79*(1-$J$89))<0,(N79*(1-$J$89))<(C60*-1)),(N79*(1-$J$89))-(C60*-1),0)*1000,0) + + var gen = ssmTOOL.GenInputs; + var TLFFH = ssmTOOL.Calculate.TechListAdjustedHeatingW_FuelFiredHeating; + // Dim C60 As Double = gen.AH_EngineWasteHeatkW + // Dim N79 As Double = Me.TotalKW + + return ((TotalKW * (1 - TLFFH)) < 0 && (TotalKW * (1 - TLFFH)) < (gen.AH_EngineWasteHeatkW * -1)) ? (TotalKW * (1 - TLFFH)) - (gen.AH_EngineWasteHeatkW * -1) : 0 * 1000 < 0 ? ((TotalKW * (1 - TLFFH)) < 0 && (TotalKW * (1 - TLFFH)) < (gen.AH_EngineWasteHeatkW * -1)) ? (TotalKW * (1 - TLFFH)) - (gen.AH_EngineWasteHeatkW * -1) : 0 * 1000 : 0; + } + } + + // Provides Diagnostic Information + // To be utilised by the User. + public override string ToString() + { + var sb = new StringBuilder(); + + var vbTab = "\t"; + sb.AppendLine(string.Format("Run : {0}", runNumber)); + sb.AppendLine(string.Format("************************************")); + sb.AppendLine(string.Format("HVAC OP " + vbTab + ": {0}", HVACOperation)); + sb.AppendLine(string.Format("TCALC " + vbTab + ": {0}", TCalc)); + sb.AppendLine(string.Format("Tempurature D " + vbTab + ": {0}", TemperatureDelta)); + sb.AppendLine(string.Format("QWall " + vbTab + ": {0}", QWall)); + sb.AppendLine(string.Format("WattsPerPass " + vbTab + ": {0}", WattsPerPass)); + sb.AppendLine(string.Format("Solar " + vbTab + ": {0}", Solar)); + sb.AppendLine(string.Format("TotalW " + vbTab + ": {0}", TotalW)); + sb.AppendLine(string.Format("TotalKW " + vbTab + ": {0}", TotalKW)); + sb.AppendLine(string.Format("Fuel W " + vbTab + ": {0}", FuelW)); + sb.AppendLine(string.Format("Fuel Tech Adj " + vbTab + ": {0}", TechListAmendedFuelW)); + + + return sb.ToString(); + } + } +} diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMTOOL.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMTOOL.cs new file mode 100644 index 0000000000..f95831aa13 --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMTOOL.cs @@ -0,0 +1,270 @@ +using System; +using System.IO; +using System.Linq; +using System.Text; +using Newtonsoft.Json; +using Omu.ValueInjecter; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC; +using TUGraz.VectoCore.BusAuxiliaries.Util; + +namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC +{ + // Used by frmHVACTool + // Replaces Spreadsheet model which does the same calculation + // Version of which appears on the form title. + public class SSMTOOL : ISSMTOOL + { + private string filePath; + public ISSMGenInputs GenInputs { get; set; } + public ISSMTechList TechList { get; set; } + public ISSMCalculate Calculate { get; set; } + public bool SSMDisabled { get; set; } + public IHVACConstants HVACConstants { get; set; } + + // Repeat Warning Flags + private bool CompressorCapacityInsufficientWarned; + private bool FuelFiredHeaterInsufficientWarned; + + // Base Values + public double ElectricalWBase + { + get { + return SSMDisabled ? 0 : Calculate.ElectricalWBase; // .SI(Of Watt)() + } + } + + public double MechanicalWBase + { + get { + return SSMDisabled ? 0 : Calculate.MechanicalWBase; // .SI(Of Watt)() + } + } + + public double FuelPerHBase + { + get { + return SSMDisabled ? 0 : Calculate.FuelPerHBase; // .SI(Of LiterPerHour)() + } + } + + // Adjusted Values + public double ElectricalWAdjusted + { + get { + return SSMDisabled ? 0 : Calculate.ElectricalWAdjusted; // .SI(Of Watt)() + } + } + + public double MechanicalWBaseAdjusted + { + get { + var mechAdjusted = SSMDisabled ? 0 : Calculate.MechanicalWBaseAdjusted; + + if (CompressorCapacityInsufficientWarned == false && (mechAdjusted) / (1000 * GenInputs.AC_COP) > GenInputs.AC_CompressorCapacitykW) { + OnMessage(this, "HVAC SSM :AC-Compressor Capacity unable to service cooling, run continues as if capacity was sufficient.", AdvancedAuxiliaryMessageType.Warning); + CompressorCapacityInsufficientWarned = true; + } + + + return mechAdjusted; // .SI(Of Watt)() + } + } + + public double FuelPerHBaseAdjusted + { + get { + return SSMDisabled ? 0 : Calculate.FuelPerHBaseAdjusted; // .SI(Of LiterPerHour)() + } + } + + // Constructors + public SSMTOOL(string filePath, HVACConstants hvacConstants, bool isDisabled = false, bool useTestValues = false) + { + this.filePath = filePath; + this.SSMDisabled = isDisabled; + this.HVACConstants = hvacConstants; + + GenInputs = new SSMGenInputs(useTestValues, FilePathUtils.fPATH(filePath)); + TechList = new SSMTechList(filePath, GenInputs, useTestValues); + + Calculate = new SSMCalculate(this); + } + + // Clone values from another object of same type + public void Clone(ISSMTOOL from) + { + var feedback = string.Empty; + + GenInputs.InjectFrom((SSMTOOL)from.GenInputs); + + TechList.Clear(); + + foreach (var line in from.TechList.TechLines) { + var newLine = new TechListBenefitLine(this.GenInputs); + // newLine.InjectFrom() + newLine.InjectFrom(line); + TechList.Add(newLine, ref feedback); + } + } + + // Persistance Functions + public bool Save(string filePath) + { + var returnValue = true; + var settings = new JsonSerializerSettings(); + settings.TypeNameHandling = TypeNameHandling.Objects; + + // JSON METHOD + try { + var output = JsonConvert.SerializeObject(this, Formatting.Indented, settings); + + File.WriteAllText(filePath, output); + } catch (Exception ex) { + + // Nothing to do except return false. + returnValue = false; + } + + return returnValue; + } + + public bool Load(string filePath) + { + var returnValue = true; + var settings = new JsonSerializerSettings(); + SSMTOOL tmpAux; // = New SSMTOOL(filePath, HVACConstants) + + settings.TypeNameHandling = TypeNameHandling.Objects; + + // JSON METHOD + try { + var output = File.ReadAllText(filePath); + + + tmpAux = JsonConvert.DeserializeObject<SSMTOOL>(output, settings); + + tmpAux.TechList.SetSSMGeneralInputs(tmpAux.GenInputs); + + foreach (TechListBenefitLine tll in tmpAux.TechList.TechLines) + + tll.inputSheet = tmpAux.GenInputs; + + + // This is where we Assume values of loaded( Deserialized ) object. + Clone(tmpAux); + } catch (Exception ex) { + + // Nothing to do except return false. + + returnValue = false; + } + + return returnValue; + } + + // Comparison + public bool IsEqualTo(ISSMTOOL source) + { + + // In this methods we only want to compare the non Static , non readonly public properties of + // The class's General, User Inputs and Tech Benefit members. + + return compareGenUserInputs(source) && compareTechListBenefitLines(source); + } + + private bool compareGenUserInputs(ISSMTOOL source) + { + var src = (SSMTOOL)source; + + var returnValue = true; + + var properties = this.GenInputs.GetType().GetProperties(); + + foreach (var prop in properties) { + + // If Not prop.GetAccessors.IsReadOnly Then + if (prop.CanWrite) { + if (!prop.GetValue(this.GenInputs, null/* TODO Change to default(_) if this is not a reference type */).Equals(prop.GetValue(src.GenInputs, null/* TODO Change to default(_) if this is not a reference type */))) + returnValue = false; + } + } + + return returnValue; + } + + private bool compareTechListBenefitLines(ISSMTOOL source) + { + var src = (SSMTOOL)source; + + // Equal numbers of lines check + if (this.TechList.TechLines.Count != src.TechList.TechLines.Count) + return false; + + foreach (var tl in this.TechList.TechLines.OrderBy(o => o.Category).ThenBy(n => n.BenefitName)) { + + // First Check line exists in other + if (src.TechList.TechLines.Where(w => w.BenefitName == tl.BenefitName && w.Category == tl.Category).Count() != 1) + return false; + else { + + // check are equal + + var testLine = src.TechList.TechLines.First(w => w.BenefitName == tl.BenefitName && w.Category == tl.Category); + + if (!testLine.IsEqualTo(tl)) + return false; + } + } + + // All Looks OK + return true; + } + + // Overrides + public override string ToString() + { + var sb = new StringBuilder(); + + sb.AppendLine(Calculate.ToString()); + + + return sb.ToString(); + } + + // Dynamicly Get Fuel having re-adjusted Engine Heat Waste, this was originally supposed to be Solid State. Late adjustment request 24/3/2015 + public double FuelPerHBaseAsjusted(double AverageUseableEngineWasteHeatKW) + { + if (SSMDisabled) + return 0; + + // Set Engine Waste Heat + GenInputs.AH_EngineWasteHeatkW = AverageUseableEngineWasteHeatKW; + var fba = FuelPerHBaseAdjusted; + + // Dim FuelFiredWarning As Boolean = fba * GenInputs.BC_AuxHeaterEfficiency * HVACConstants.FuelDensity * GenInputs.BC_GCVDieselOrHeatingOil * 1000 > (AverageUseableEngineWasteHeatKW + GenInputs.AH_FuelFiredHeaterkW) + + // If Not FuelFiredHeaterInsufficientWarned AndAlso FuelFiredWarning Then + + // FuelFiredHeaterInsufficientWarned = True + + // OnMessage(Me, " HVAC SSM : Fuel fired heater insufficient for heating requirements, run continues assuming it was sufficient.", AdvancedAuxiliaryMessageType.Warning) + + // End If + + return fba; + } + + // Events + public event MessageEventHandler Message; + + // Raise Message Event. + private void OnMessage(object sender, string message, AdvancedAuxiliaryMessageType messageType) + { + if (message != null) { + object ssmtool = this; + Message?.Invoke(ref ssmtool, message: message, messageType: messageType); + } + } + } +} diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMTechList.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMTechList.cs new file mode 100644 index 0000000000..e4fe9e701d --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/SSMTechList.cs @@ -0,0 +1,487 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC; + +namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC +{ + // Used By SSMTOOL Class. + public class SSMTechList : ISSMTechList + { + + // Private Fields + private string filePath; + private ISSMGenInputs _ssmInputs; + private bool _dirty; + + public List<ITechListBenefitLine> TechLines { get; set; } + + // Constructors + public SSMTechList(string filepath, ISSMGenInputs genInputs, bool initialiseDefaults = false) + { + TechLines = new List<ITechListBenefitLine>(); + + filePath = filepath; + + _ssmInputs = genInputs; + + if (initialiseDefaults) + SetDefaults(); + } + + + public void SetSSMGeneralInputs(ISSMGenInputs genInputs) + { + _ssmInputs = genInputs; + } + + // Initialisation Methods + public bool Initialise(string filepath) + { + filePath = filepath; + + return Initialise(); + } + + public bool Initialise() + { + 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 < 1) { + return false; + } + + var firstline = true; + + foreach (var line in lines) { + if (!firstline) { + + // split the line + var elements = line.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + // 3 entries per line required + if (elements.Length != 17) + throw new ArgumentException("Incorrect number of values in csv file"); + // add values to map + + // 00. Category, + // 01. BenefitName, + // 02. Units, + // 03. LowH, + // 04. LowV, + // 05. LowC, + // 06. SemiLowH, + // 07. SemiLowV, + // 08. SemiLowC, + // 09. RaisedH, + // 10. RaisedV, + // 11. RaisedC, + // 12. OnVehicle, + // 13. LineType, + // 14. AvtiveVH, + // 15. ActiveVV, + // 16. ActiveVC + + + // Bus + try { + var tbline = new TechListBenefitLine(_ssmInputs, elements[2], elements[0], elements[1], double.Parse(elements[3], CultureInfo.InvariantCulture), double.Parse(elements[4], CultureInfo.InvariantCulture), double.Parse(elements[5], CultureInfo.InvariantCulture), double.Parse(elements[6], CultureInfo.InvariantCulture), double.Parse(elements[7], CultureInfo.InvariantCulture), double.Parse(elements[8], CultureInfo.InvariantCulture), double.Parse(elements[9], CultureInfo.InvariantCulture), double.Parse(elements[10], CultureInfo.InvariantCulture), double.Parse(elements[11], CultureInfo.InvariantCulture), bool.Parse(elements[12]), elements[13].ParseEnum<TechLineType>(), bool.Parse(elements[14]), bool.Parse(elements[15]), bool.Parse(elements[16])); + + TechLines.Add(tbline); + } catch (Exception ex) { + + // Indicate problems + returnStatus = false; + } + } else { + firstline = false; + } + } + } + } else { + returnStatus = false; + } + + return returnStatus; + } + + // Public Properties - Outputs Of Class + public double CValueVariation + { + get { + double a; + + a = TechLines.Where(x => x.Units.ToLower() == "fraction").Sum(s => s.C); + + return a; + } + } + + public double CValueVariationKW + { + get { + double a; + + a = TechLines.Where(x => x.Units.ToLower() == "kw").Sum(s => s.C); + + return a; + } + } + + public double HValueVariation + { + get { + + // Dim a,b As double + return TechLines.Where(x => x.Units == "fraction").Sum(s => s.H); + } + } + + public double HValueVariationKW + { + get { + return TechLines.Where(x => x.Units.ToLower() == "kw").Sum(s => s.H); + } + } + + public double VCValueVariation + { + get { + return TechLines.Where(x => x.Units.ToLower() == "fraction").Sum(s => s.VC); // - VCValueVariationKW + } + } + + public double VCValueVariationKW + { + get { + return TechLines.Where(x => x.Units.ToLower() == "kw").Sum(s => s.VC); + } + } + + public double VHValueVariation + { + get { + // Dim a,b As double + + return TechLines.Where(x => x.Units.ToLower() == "fraction").Sum(s => s.VH); + } + } + + public double VHValueVariationKW + { + get { + return TechLines.Where(x => x.Units.ToLower() == "kw").Sum(s => s.VH); + } + } + + public double VVValueVariation + { + get { + return TechLines.Where(x => x.Units.ToLower() == "fraction").Sum(s => s.VV); + } + } + + public double VVValueVariationKW + { + get { + return TechLines.Where(x => x.Units.ToLower() == "kw").Sum(s => s.VV); // - VVValueVariationKW + } + } + + // Member Management + public bool Add(ITechListBenefitLine item, ref string feedback) + { + var initialCount = TechLines.Count; + + if (TechLines.Any(w => w.Category == item.Category && w.BenefitName == item.BenefitName)) { + // Failure + feedback = "Item already exists."; + return false; + } + + + try { + TechLines.Add(item); + + if (TechLines.Count == initialCount + 1) { + + // Success + feedback = "OK"; + _dirty = true; + return true; + } else { + + // Failure + feedback = "The system was unable to add the new tech benefit list item."; + return false; + } + } catch (Exception ex) { + feedback = "The system threw an exception and was unable to add the new tech benefit list item."; + return false; + } + } + + public void Clear() + { + if (TechLines.Count > 0) + _dirty = true; + + TechLines.Clear(); + } + + public bool Delete(ITechListBenefitLine item, ref string feedback) + { + var currentCount = TechLines.Count; + + if ((TechLines.Count(c => c.Category == item.Category && c.BenefitName == item.BenefitName) == 1)) { + try { + TechLines.RemoveAt(TechLines.FindIndex(c => c.Category == item.Category && c.BenefitName == item.BenefitName)); + + if (TechLines.Count == currentCount - 1) { + // This succeeded + _dirty = true; + return true; + } else { + // No Exception, but this failed for some reason. + feedback = "The system was unable to remove the item from the list."; + return false; + } + } catch (Exception ex) { + feedback = "An exception occured, the removal failed."; + return false; + } + } else { + feedback = "the item was not found in the list."; + return false; + } + } + + public bool Modify(ITechListBenefitLine originalItem, ITechListBenefitLine newItem, ref string feedback) + { + var fi = TechLines.Find(f => f.Category == originalItem.Category && f.BenefitName == originalItem.BenefitName); + + if (fi != null) { + try { + var originalUnits = fi.Units; + fi.CloneFrom(newItem); + + // The lines below are to assist in testing. The KW units are being excluded, but for benchmarking against the spreadsheet model + // Two KW entries are left in. There is no provision for adding KW units in so we check if the original entry was KW and + // force it back to KW if it was already so. There shoud be no need to remove this as newly created lists will not match this + // Phenomenon. + if ((originalUnits.ToLower() == "kw")) { + fi.Units = originalUnits; + newItem.Units = originalUnits; + } + + if (newItem == fi) { + // This succeeded + _dirty = true; + return true; + } else { + // No Exception, but this failed for some reason. + feedback = "The system was unable to remove the item from the list."; + return false; + } + } catch (Exception ex) { + feedback = "An exception occured, the update failed."; + return false; + } + } else { + feedback = "the item was not found so cannot be modified."; + return false; + } + } + + + private void SetDefaults() + { + ITechListBenefitLine techLine1 = new TechListBenefitLine(_ssmInputs); + { + var withBlock = techLine1; + withBlock.Category = "Cooling"; + withBlock.BenefitName = "Separate air distribution ducts"; + withBlock.LowFloorH = 0; + withBlock.LowFloorC = 0.04; + withBlock.LowFloorV = 0.04; + withBlock.SemiLowFloorH = 0; + withBlock.SemiLowFloorC = 0.04; + withBlock.SemiLowFloorV = 0.04; + withBlock.RaisedFloorH = 0; + withBlock.RaisedFloorC = 0.04; + withBlock.RaisedFloorV = 0.04; + withBlock.ActiveVH = false; + withBlock.ActiveVV = false; + withBlock.ActiveVC = true; + withBlock.OnVehicle = false; + withBlock.Units = "fraction"; + } + + ITechListBenefitLine techLine2 = new TechListBenefitLine(_ssmInputs); + { + var withBlock = techLine2; + withBlock.Category = "Heating"; + withBlock.BenefitName = "Adjustable auxiliary heater"; + withBlock.LowFloorH = 0.02; + withBlock.LowFloorC = 0; + withBlock.LowFloorV = 0.02; + withBlock.SemiLowFloorH = 0.02; + withBlock.SemiLowFloorC = 0; + withBlock.SemiLowFloorV = 0.02; + withBlock.RaisedFloorH = 0.02; + withBlock.RaisedFloorC = 0; + withBlock.RaisedFloorV = 0.02; + withBlock.ActiveVH = true; + withBlock.ActiveVV = false; + withBlock.ActiveVC = false; + withBlock.OnVehicle = false; + withBlock.Units = "fraction"; + } + + ITechListBenefitLine techLine3 = new TechListBenefitLine(_ssmInputs); + { + var withBlock = techLine3; + withBlock.Category = "Heating"; + withBlock.BenefitName = "Adjustable coolant thermostat"; + withBlock.LowFloorH = 0.02; + withBlock.LowFloorC = 0; + withBlock.LowFloorV = 0.02; + withBlock.SemiLowFloorH = 0.02; + withBlock.SemiLowFloorC = 0; + withBlock.SemiLowFloorV = 0.02; + withBlock.RaisedFloorH = 0.02; + withBlock.RaisedFloorC = 0; + withBlock.RaisedFloorV = 0.02; + withBlock.ActiveVH = true; + withBlock.ActiveVV = false; + withBlock.ActiveVC = false; + withBlock.OnVehicle = false; + withBlock.Units = "fraction"; + } + + ITechListBenefitLine techLine4 = new TechListBenefitLine(_ssmInputs); + { + var withBlock = techLine4; + withBlock.Category = "Heating"; + withBlock.BenefitName = "Engine waste gas heat exchanger"; + withBlock.LowFloorH = 0.04; + withBlock.LowFloorC = 0; + withBlock.LowFloorV = 0.04; + withBlock.SemiLowFloorH = 0; + withBlock.SemiLowFloorC = 0; + withBlock.SemiLowFloorV = 0; + withBlock.RaisedFloorH = 0; + withBlock.RaisedFloorC = 0; + withBlock.RaisedFloorV = 0; + withBlock.ActiveVH = true; + withBlock.ActiveVV = false; + withBlock.ActiveVC = false; + withBlock.OnVehicle = false; + withBlock.Units = "fraction"; + } + + ITechListBenefitLine techLine5 = new TechListBenefitLine(_ssmInputs); + { + var withBlock = techLine5; + withBlock.Category = "Heating"; + withBlock.BenefitName = "Heat pump systems"; + withBlock.LowFloorH = 0.06; + withBlock.LowFloorC = 0; + withBlock.LowFloorV = 0.06; + withBlock.SemiLowFloorH = 0.04; + withBlock.SemiLowFloorC = 0; + withBlock.SemiLowFloorV = 0.04; + withBlock.RaisedFloorH = 0.04; + withBlock.RaisedFloorC = 0; + withBlock.RaisedFloorV = 0.04; + withBlock.ActiveVH = true; + withBlock.ActiveVV = false; + withBlock.ActiveVC = false; + withBlock.OnVehicle = false; + withBlock.Units = "fraction"; + } + + ITechListBenefitLine techLine6 = new TechListBenefitLine(_ssmInputs); + { + var withBlock = techLine6; + withBlock.Category = "Insulation"; + withBlock.BenefitName = "Double-glazing"; + withBlock.LowFloorH = 0.04; + withBlock.LowFloorC = 0.04; + withBlock.LowFloorV = 0.04; + withBlock.SemiLowFloorH = 0.04; + withBlock.SemiLowFloorC = 0.04; + withBlock.SemiLowFloorV = 0.04; + withBlock.RaisedFloorH = 0.04; + withBlock.RaisedFloorC = 0.04; + withBlock.RaisedFloorV = 0.04; + withBlock.ActiveVH = true; + withBlock.ActiveVV = true; + withBlock.ActiveVC = true; + withBlock.OnVehicle = false; + withBlock.Units = "fraction"; + } + + ITechListBenefitLine techLine7 = new TechListBenefitLine(_ssmInputs); + { + var withBlock = techLine7; + withBlock.Category = "Insulation"; + withBlock.BenefitName = "Tinted windows"; + withBlock.LowFloorH = 0; + withBlock.LowFloorC = 0; + withBlock.LowFloorV = 0; + withBlock.SemiLowFloorH = 0; + withBlock.SemiLowFloorC = 0; + withBlock.SemiLowFloorV = 0; + withBlock.RaisedFloorH = 0; + withBlock.RaisedFloorC = 0; + withBlock.RaisedFloorV = 0; + withBlock.ActiveVH = false; + withBlock.ActiveVV = false; + withBlock.ActiveVC = false; + withBlock.OnVehicle = false; + withBlock.Units = "fraction"; + } + + ITechListBenefitLine techLine8 = new TechListBenefitLine(_ssmInputs); + { + var withBlock = techLine8; + withBlock.Category = "Ventilation"; + withBlock.BenefitName = "Fan control strategy (serial/parallel)"; + withBlock.LowFloorH = 0.02; + withBlock.LowFloorC = 0.02; + withBlock.LowFloorV = 0.02; + withBlock.SemiLowFloorH = 0.02; + withBlock.SemiLowFloorC = 0.02; + withBlock.SemiLowFloorV = 0.02; + withBlock.RaisedFloorH = 0.02; + withBlock.RaisedFloorC = 0.02; + withBlock.RaisedFloorV = 0.02; + withBlock.ActiveVH = true; + withBlock.ActiveVV = true; + withBlock.ActiveVC = true; + withBlock.OnVehicle = false; + withBlock.Units = "fraction"; + withBlock.LineType = TechLineType.HVCActiveSelection; + } + + var feedback = string.Empty; + Add(techLine1, ref feedback); + Add(techLine2, ref feedback); + Add(techLine3, ref feedback); + Add(techLine4, ref feedback); + Add(techLine5, ref feedback); + Add(techLine6, ref feedback); + Add(techLine7, ref feedback); + Add(techLine8, ref feedback); + } + } +} diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/TechListBenefitLine.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/TechListBenefitLine.cs new file mode 100644 index 0000000000..96ec989bc2 --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/HVAC/TechListBenefitLine.cs @@ -0,0 +1,300 @@ +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC; + +namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.HVAC +{ + public enum PowerType + { + Mechanical, + Electrical + } + + // Used by SSMTOOL Class, refer to original spreadsheet model + // Or PDF Model Document which articulates the same spreadsheet functionality + // But within the context of the Vecto interpretation of the same. + + public class TechListBenefitLine : ITechListBenefitLine + { + private float _h, _vh, _vv, _vc, _c; + public ISSMGenInputs inputSheet; + + public string Units { get; set; } + public string Category { get; set; } + public string BenefitName { get; set; } + public double LowFloorH { get; set; } = new double(); + public double LowFloorV { get; set; } = new double(); + public double LowFloorC { get; set; } = new double(); + + public double SemiLowFloorH { get; set; } = new double(); + public double SemiLowFloorV { get; set; } = new double(); + public double SemiLowFloorC { get; set; } = new double(); + + public double RaisedFloorH { get; set; } = new double(); + public double RaisedFloorV { get; set; } = new double(); + public double RaisedFloorC { get; set; } = new double(); + + public bool OnVehicle { get; set; } + public bool ActiveVH { get; set; } + public bool ActiveVV { get; set; } + public bool ActiveVC { get; set; } + public TechLineType LineType { get; set; } + + public double H + { + get { + double returnValue = 0; + + // =IF($M49=0,0,IF(AND($M49=1,'INPUT & RESULTS SHEET'!$D$6="low floor"),'TECH LIST INPUT'!D49, IF(AND($M49=1,'INPUT & RESULTS SHEET'!$D$6="semi low floor"),'TECH LIST INPUT'!G49,'TECH LIST INPUT'!J49))) + if (!OnVehicle) + return returnValue; + + switch (inputSheet.BP_BusFloorType) { + case "low floor": { + returnValue = LowFloorH; + break; + } + + case "semi low floor": { + returnValue = SemiLowFloorH; + break; + } + + case "raised floor": { + returnValue = RaisedFloorH; + break; + } + } + + return returnValue; + } + } + + public double VH + { + get { + double floorValue = 0; + + if (!OnVehicle) + return floorValue; + + // Get floor value + switch (inputSheet.BP_BusFloorType) { + case "low floor": { + floorValue = LowFloorV; + break; + } + + case "semi low floor": { + floorValue = SemiLowFloorV; + break; + } + + case "raised floor": { + floorValue = RaisedFloorV; + break; + } + } + + // Active + if (ActiveVH) + return floorValue; + else + return 0; + } + } + + public double VV + { + get { + double floorValue = 0; + + if (!OnVehicle) + return floorValue; + + // Get floor value + switch (inputSheet.BP_BusFloorType) { + case "low floor": { + floorValue = LowFloorV; + break; + } + + case "semi low floor": { + floorValue = SemiLowFloorV; + break; + } + + case "raised floor": { + floorValue = RaisedFloorV; + break; + } + } + + // Active + if (ActiveVV) + return floorValue; + else + return 0; + } + } + + public double VC + { + get { + double floorValue = 0; + + if (!OnVehicle) + return floorValue; + + // Get floor value + switch (inputSheet.BP_BusFloorType) { + case "low floor": { + floorValue = LowFloorV; + break; + } + + case "semi low floor": { + floorValue = SemiLowFloorV; + break; + } + + case "raised floor": { + floorValue = RaisedFloorV; + break; + } + } + + // Active + if (ActiveVC) + return floorValue; + else + return 0; + } + } + + public double C + { + get { + double returnValue = 0; + + if (!OnVehicle) + return returnValue; + + switch (inputSheet.BP_BusFloorType) { + case "low floor": { + returnValue = LowFloorC; + break; + } + + case "semi low floor": { + returnValue = SemiLowFloorC; + break; + } + + case "raised floor": { + returnValue = RaisedFloorC; + break; + } + } + + return returnValue; + } + } + + public TechListBenefitLine() { } + + public TechListBenefitLine(ISSMGenInputs geninputs) + { + this.inputSheet = geninputs; + } + + public TechListBenefitLine( + ISSMGenInputs geninputs, string units, string category, string benefitName, double lowFloorH, double lowFloorV, + double lowFloorC, double semiLowFloorH, double semiLowFloorV, double semiLowFloorC, double raisedFloorH, + double raisedFloorV, double raisedFloorC, bool onVehicle, TechLineType lineType, bool activeVH, bool activeVV, + bool activeVC + ) + { + inputSheet = geninputs; + Units = units; + Category = category; + BenefitName = benefitName; + LowFloorH = lowFloorH; + LowFloorV = lowFloorV; + LowFloorC = lowFloorC; + SemiLowFloorH = semiLowFloorH; + SemiLowFloorV = semiLowFloorV; + SemiLowFloorC = semiLowFloorC; + RaisedFloorH = raisedFloorH; + RaisedFloorV = raisedFloorV; + RaisedFloorC = raisedFloorC; + OnVehicle = onVehicle; + LineType = lineType; + ActiveVH = activeVH; + ActiveVV = activeVV; + ActiveVC = activeVC; + } + + // Operator Overloads + public static bool operator ==(TechListBenefitLine op1, TechListBenefitLine op2) + { + if ((op1.Category == op2.Category && op1.BenefitName == op2.BenefitName && op1.ActiveVC == op2.ActiveVC && + op1.ActiveVH == op2.ActiveVH && op1.ActiveVV == op2.ActiveVV && op1.LineType == op2.LineType && + op1.LowFloorC == op2.LowFloorC && op1.LowFloorV == op2.LowFloorV && op1.LowFloorH == op2.LowFloorH && + op1.SemiLowFloorC == op2.SemiLowFloorC && op1.SemiLowFloorH == op2.SemiLowFloorH && + op1.SemiLowFloorV == op2.SemiLowFloorV && op1.RaisedFloorC == op2.RaisedFloorC && + op1.RaisedFloorH == op2.RaisedFloorH && op1.RaisedFloorV == op2.RaisedFloorV && op1.OnVehicle == op2.OnVehicle && + op1.Units == op2.Units)) { + return true; + } else { + return false; + } + } + + public static bool operator !=(TechListBenefitLine op1, TechListBenefitLine op2) + { + if ((op1.Category != op2.Category || op1.BenefitName != op2.BenefitName || op1.ActiveVC != op2.ActiveVC || + op1.ActiveVH != op2.ActiveVH || op1.ActiveVV != op2.ActiveVV || op1.LineType != op2.LineType || + op1.LowFloorC != op2.LowFloorC || op1.LowFloorV != op2.LowFloorV || op1.LowFloorH != op2.LowFloorH || + op1.SemiLowFloorC != op2.SemiLowFloorC || op1.SemiLowFloorH != op2.SemiLowFloorH || + op1.SemiLowFloorV != op2.SemiLowFloorV || op1.RaisedFloorC != op2.RaisedFloorC || + op1.RaisedFloorH != op2.RaisedFloorH || op1.RaisedFloorV != op2.RaisedFloorV || op1.OnVehicle != op2.OnVehicle || + op1.Units != op2.Units)) + return true; + else + return false; + } + + public void CloneFrom(ITechListBenefitLine source) + { + this.Units = source.Units; + this.Category = source.Category; + this.BenefitName = source.BenefitName; + this.LowFloorH = source.LowFloorH; + this.LowFloorV = source.LowFloorV; + this.LowFloorC = source.LowFloorC; + + this.SemiLowFloorH = source.SemiLowFloorH; + this.SemiLowFloorV = source.SemiLowFloorV; + this.SemiLowFloorC = source.SemiLowFloorC; + + this.RaisedFloorH = source.RaisedFloorH; + this.RaisedFloorV = source.RaisedFloorV; + this.RaisedFloorC = source.RaisedFloorC; + + this.OnVehicle = source.OnVehicle; + this.ActiveVH = source.ActiveVH; + this.ActiveVV = source.ActiveVV; + this.ActiveVC = source.ActiveVC; + this.LineType = source.LineType; + } + + public bool IsEqualTo(ITechListBenefitLine source) + { + var mySource = (TechListBenefitLine)source; + if (object.ReferenceEquals(mySource, null)) { + return false; + } + + return this == mySource; + } + } +} diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M06Impl.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M06Impl.cs index 468174e0bb..34971ea499 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M06Impl.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M06Impl.cs @@ -1,9 +1,6 @@ -using DownstreamModules; -using Electrics; -using Hvac; -using Pneumatics; -using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.BusAuxiliaries.Interfaces; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules; namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M07Impl.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M07Impl.cs index a9e9a811e8..c0ef9161e5 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M07Impl.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M07Impl.cs @@ -1,7 +1,6 @@ -using DownstreamModules; -using Electrics; -using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.BusAuxiliaries.Interfaces; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules; namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M08Impl.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M08Impl.cs index e7a41e3961..91450b4caa 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M08Impl.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M08Impl.cs @@ -1,7 +1,6 @@ -using DownstreamModules; -using Hvac; -using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.BusAuxiliaries.Interfaces; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules; namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M09Impl.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M09Impl.cs index eea410b8fe..3e169e84c0 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M09Impl.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M09Impl.cs @@ -1,9 +1,8 @@ using System; -using DownstreamModules; -using Hvac; -using Pneumatics; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.BusAuxiliaries.Interfaces; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.PneumaticSystem; namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M10Impl.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M10Impl.cs index 1d57472aae..34568bcd74 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M10Impl.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M10Impl.cs @@ -1,8 +1,7 @@ using System; -using DownstreamModules; -using Pneumatics; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.BusAuxiliaries.Interfaces; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules; namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M11Impl.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M11Impl.cs index a828361c94..f33dbe6889 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M11Impl.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M11Impl.cs @@ -1,8 +1,6 @@ -using DownstreamModules; -using Hvac; -using Pneumatics; -using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.BusAuxiliaries.Interfaces; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules; namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M12Impl.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M12Impl.cs index c8f079c857..560cad0a8d 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M12Impl.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M12Impl.cs @@ -1,6 +1,6 @@ -using DownstreamModules; -using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.BusAuxiliaries.Interfaces; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules; namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M13Impl.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M13Impl.cs index f193e70e90..36275ddaef 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M13Impl.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M13Impl.cs @@ -1,6 +1,6 @@ -using DownstreamModules; -using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.BusAuxiliaries.Interfaces; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules; namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M14Impl.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M14Impl.cs index 8c7d4998b7..0ed0e7d710 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M14Impl.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/M14Impl.cs @@ -1,7 +1,7 @@ -using DownstreamModules; -using DownstreamModules.HVAC; -using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.BusAuxiliaries.Interfaces; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC; namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/CompressorMap.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/CompressorMap.cs new file mode 100644 index 0000000000..2502c4c62a --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/CompressorMap.cs @@ -0,0 +1,270 @@ +// 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.Globalization; +using System.IO; +using System.Linq; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.PneumaticSystem; + +namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Pneumatics +{ + /// <summary> + /// ''' Compressor Flow Rate and Power Map + /// ''' </summary> + /// ''' <remarks></remarks> + public class CompressorMap : ICompressorMap, IAuxiliaryEvent + { + private readonly string filePath; + private double _averagePowerDemandPerCompressorUnitFlowRateLitresperSec; + private bool _MapBoundariesExceeded; + + /// <summary> + /// ''' Dictionary of values keyed by the rpm valaues in the csv file + /// ''' Values are held as a tuple as follows + /// ''' Item1 = flow rate + /// ''' Item2 - power [compressor on] + /// ''' Item3 - power [compressor off] + /// ''' </summary> + /// ''' <remarks></remarks> + private Dictionary<int, CompressorMapValues> map; + + // Returns the AveragePowerDemand per unit flow rate in seconds. + public double GetAveragePowerDemandPerCompressorUnitFlowRate() + { + return _averagePowerDemandPerCompressorUnitFlowRateLitresperSec; + } + + + /// <summary> + /// ''' Creates a new instance of the CompressorMap class + /// ''' </summary> + /// ''' <param name="path">full path to csv data file</param> + /// ''' <remarks></remarks> + public CompressorMap(string path) + { + filePath = path; + } + + /// <summary> + /// ''' Initilaises the map from the supplied csv data + /// ''' </summary> + /// ''' <remarks></remarks> + public bool Initialise() + { + if (File.Exists(filePath)) { + using (var sr = new StreamReader(filePath)) { + // get array of lines from 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 < 3) + throw new ArgumentException("Insufficient rows in csv to build a usable map"); + + map = new Dictionary<int, CompressorMapValues>(); + var firstline = true; + + foreach (var line in lines) { + if (!firstline) { + // split the line + var elements = line.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + // 4 entries per line required + if ((elements.Length != 4)) + throw new ArgumentException("Incorrect number of values in csv file"); + // add values to map + try { + map.Add(int.Parse(elements[0]), new CompressorMapValues(double.Parse(elements[1], CultureInfo.InvariantCulture).SI<NormLiterPerSecond>(), double.Parse(elements[2], CultureInfo.InvariantCulture).SI<Watt>(), double.Parse(elements[3], CultureInfo.InvariantCulture).SI<Watt>())); + } catch (FormatException fe) { + throw new InvalidCastException(string.Format("Compresor Map: line '{0}", line), fe); + } + } else + firstline = false; + } + } + + // ********************************************************************* + // Calculate the Average Power Demand Per Compressor Unit FlowRate / per second. + double powerDividedByFlowRateSum = 0; + foreach (var speed in map) + powerDividedByFlowRateSum += (speed.Value.PowerCompressorOn - speed.Value.PowerCompressorOff).Value() / (double)speed.Value.FlowRate.Value(); + + // Map in Litres Per Minute, so * 60 to get per second, calculated only once at initialisation. + _averagePowerDemandPerCompressorUnitFlowRateLitresperSec = (powerDividedByFlowRateSum / map.Count) * 60; + } else + throw new ArgumentException("supplied input file does not exist"); + + // If we get here then all should be well and we can return a True value of success. + return true; + } + + /// <summary> + /// ''' Returns compressor flow rate at the given rotation speed + /// ''' </summary> + /// ''' <param name="rpm">compressor rotation speed</param> + /// ''' <returns></returns> + /// ''' <remarks>Single</remarks> + public NormLiterPerSecond GetFlowRate(double rpm) + { + var val = InterpolatedTuple(rpm); + return val.FlowRate; + } + + /// <summary> + /// ''' Returns mechanical power at rpm when compressor is on + /// ''' </summary> + /// ''' <param name="rpm">compressor rotation speed</param> + /// ''' <returns></returns> + /// ''' <remarks>Single</remarks> + public Watt GetPowerCompressorOn(double rpm) + { + var val = InterpolatedTuple(rpm); + return val.PowerCompressorOn; + } + + /// <summary> + /// ''' Returns mechanical power at rpm when compressor is off + /// ''' </summary> + /// ''' <param name="rpm">compressor rotation speed</param> + /// ''' <returns></returns> + /// ''' <remarks>Single</remarks> + public Watt GetPowerCompressorOff(double rpm) + { + var val = InterpolatedTuple(rpm); + return val.PowerCompressorOff; + } + + /// <summary> + /// ''' Returns an instance of CompressorMapValues containing the values at a key, or interpolated values + /// ''' </summary> + /// ''' <returns>CompressorMapValues</returns> + /// ''' <remarks>Throws exception if rpm are outside map</remarks> + private CompressorMapValues InterpolatedTuple(double rpm) + { + // check the rpm is within the map + var min = map.Keys.Min(); + var max = map.Keys.Max(); + + if (rpm < min || rpm > max) { + if (!_MapBoundariesExceeded) { + OnMessage(this, string.Format("Compresser : limited RPM of '{2}' to extent of map - map range is {0} to {1}", min, max, rpm), AdvancedAuxiliaryMessageType.Warning); + _MapBoundariesExceeded = true; + } + + // Limiting as agreed. + if (rpm > max) + rpm = max; + if (rpm < min) + rpm = min; + } + + // If supplied rpm is a key, we can just return the appropriate tuple + var intRpm = System.Convert.ToInt32(rpm); + if (rpm.IsEqual(intRpm) && map.ContainsKey(intRpm)) + return map[intRpm]; + + // Not a key value, interpolate + // get the entries before and after the supplied rpm + var pre = (from m in map + where m.Key < rpm + select m).Last(); + var post = (from m in map + where m.Key > rpm + select m).First(); + + // get the delta values for rpm and the map values + double dRpm = post.Key - pre.Key; + var dFlowRate = post.Value.FlowRate - pre.Value.FlowRate; + var dPowerOn = post.Value.PowerCompressorOn - pre.Value.PowerCompressorOn; + var dPowerOff = post.Value.PowerCompressorOff - pre.Value.PowerCompressorOff; + + // calculate the slopes + var flowSlope = dFlowRate.Value() / dRpm; + var powerOnSlope = dPowerOn.Value() / dRpm; + var powerOffSlope = dPowerOff.Value() / dRpm; + + // calculate the new values + var flowRate = (((rpm - pre.Key) * flowSlope).SI<NormLiterPerSecond>() + pre.Value.FlowRate); + var powerCompressorOn = (((rpm - pre.Key) * powerOnSlope).SI<Watt>() + pre.Value.PowerCompressorOn); + var powerCompressorOff = (((rpm - pre.Key) * powerOffSlope).SI<Watt>() + pre.Value.PowerCompressorOff); + + // Build and return a new CompressorMapValues instance + return new CompressorMapValues(flowRate, powerCompressorOn, powerCompressorOff); + } + + /// <summary> + /// ''' Encapsulates compressor map values + /// ''' Flow Rate + /// ''' Power - Compressor On + /// ''' Power - Compressor Off + /// ''' </summary> + /// ''' <remarks></remarks> + /// ''' + + private struct CompressorMapValues + { + /// <summary> + /// ''' Compressor flowrate + /// ''' </summary> + /// ''' <remarks></remarks> + public readonly NormLiterPerSecond FlowRate; + + /// <summary> + /// ''' Power, compressor on + /// ''' </summary> + /// ''' <remarks></remarks> + public readonly Watt PowerCompressorOn; + + /// <summary> + /// ''' Power compressor off + /// ''' </summary> + /// ''' <remarks></remarks> + public readonly Watt PowerCompressorOff; + + /// <summary> + /// ''' Creates a new instance of CompressorMapValues + /// ''' </summary> + /// ''' <param name="flowRate">flow rate</param> + /// ''' <param name="powerCompressorOn">power - compressor on</param> + /// ''' <param name="powerCompressorOff">power - compressor off</param> + /// ''' <remarks></remarks> + public CompressorMapValues(NormLiterPerSecond flowRate, Watt powerCompressorOn, Watt powerCompressorOff) + { + this.FlowRate = flowRate; + this.PowerCompressorOn = powerCompressorOn; + this.PowerCompressorOff = powerCompressorOff; + } + } + + + public event MessageEventHandler Message; + + //public delegate void MessageEventHandler(ref object sender, string message, AdvancedAuxiliaryMessageType messageType); + + private void OnMessage(object sender, string message, AdvancedAuxiliaryMessageType messageType) + { + if (message != null) { + object compressorMap = this; + Message?.Invoke(ref compressorMap, message, messageType); + } + + } + + #region Implementation of IAuxiliaryEvent + + public event AuxiliaryEventEventHandler AuxiliaryEvent; + + #endregion + } +} diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/M03Impl.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/M03Impl.cs index 625981d7cf..add764da68 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/M03Impl.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/M03Impl.cs @@ -1,6 +1,7 @@ -using Pneumatics; -using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.BusAuxiliaries.Interfaces; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.PneumaticSystem; namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Pneumatics { diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/M04Impl.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/M04Impl.cs index 5bbfa8428c..c7289b03f3 100644 --- a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/M04Impl.cs +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/M04Impl.cs @@ -1,7 +1,8 @@ using System; -using Pneumatics; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.BusAuxiliaries.Interfaces; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.PneumaticSystem; namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Pneumatics { diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/PneumaticActuationsMap.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/PneumaticActuationsMap.cs new file mode 100644 index 0000000000..a847261b78 --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/PneumaticActuationsMap.cs @@ -0,0 +1,91 @@ +// 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.Globalization; +using System.IO; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.PneumaticSystem; + +namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Pneumatics +{ + public class PneumaticActuationsMap : IPneumaticActuationsMAP + { + private Dictionary<ActuationsKey, int> map; + private string filePath; + + + public int GetNumActuations(ActuationsKey key) + { + if (map == null || !map.ContainsKey(key)) + throw new ArgumentException(string.Format("Pneumatic Actuations map does not contain the key '{0}'.", key.CycleName + ":" + key.ConsumerName)); + + return map[key]; + } + + + public PneumaticActuationsMap(string filePath) + { + this.filePath = filePath; + + if (filePath.Trim().Length == 0) + throw new ArgumentException("A filename for the Pneumatic Actuations Map has not been supplied"); + + Initialise(); + } + + public bool Initialise() + { + ActuationsKey newKey; + int numActuations; + + if (File.Exists(filePath)) { + using (var sr = new StreamReader(filePath)) { + // get array of lines from 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 < 3) + throw new ArgumentException("Pneumatic Actuations Map does not have sufficient rows in file to build a usable map"); + + map = new Dictionary<ActuationsKey, int>(); + var firstline = true; + + foreach (var line in lines) { + if (!firstline) { + // split the line + var elements = line.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + // 3 entries per line required + if ((elements.Length != 3)) + throw new ArgumentException("Pneumatic Actuations Map has Incorrect number of values in file"); + + // add values to map + + + if (!int.TryParse(elements[2], out numActuations)) + throw new ArgumentException("Pneumatic Actuations Map Contains Non Integer values in actuations column"); + + // Should throw exception if ConsumerName or CycleName are empty. + newKey = new ActuationsKey(elements[0].ToString(), elements[1].ToString()); + + map.Add(newKey, int.Parse(elements[2], CultureInfo.InvariantCulture)); + } else + firstline = false; + } + } + } else + throw new ArgumentException(string.Format(" Pneumatic Acutations map '{0}' supplied does not exist", filePath)); + + // If we get here then all should be well and we can return a True value of success. + return true; + } + } +} diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/PneumaticUserInputsConfig.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/PneumaticUserInputsConfig.cs new file mode 100644 index 0000000000..753411043f --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/PneumaticUserInputsConfig.cs @@ -0,0 +1,60 @@ +// 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 TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.PneumaticSystem; + +namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Pneumatics +{ + public class PneumaticUserInputsConfig : IPneumaticUserInputsConfig + { + public string CompressorMap { get; set; } + public double CompressorGearRatio { get; set; } + public double CompressorGearEfficiency { get; set; } + + // pnmeumatic or electric + public string AdBlueDosing { get; set; } + + // mechanical or electrical + public string AirSuspensionControl { get; set; } + + // pneumatic or electric + public string Doors { get; set; } + public double KneelingHeightMillimeters { get; set; } + + // PneumaticActuationsMap + public string ActuationsMap { get; set; } + + public bool RetarderBrake { get; set; } + public bool SmartAirCompression { get; set; } + public bool SmartRegeneration { get; set; } + + public PneumaticUserInputsConfig(bool setToDefaults = false) + { + if (setToDefaults) + SetPropertiesToDefaults(); + } + + public void SetPropertiesToDefaults() + { + CompressorMap = string.Empty; + CompressorGearRatio = 1.0; + CompressorGearEfficiency = 0.97; + AdBlueDosing = "Pneumatic"; + AirSuspensionControl = "Mechanically"; + Doors = "Pneumatic"; + KneelingHeightMillimeters = 70; + ActuationsMap = null; + RetarderBrake = true; + SmartAirCompression = false; + SmartRegeneration = false; + } + } +} diff --git a/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/PneumaticsAuxilliariesConfig.cs b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/PneumaticsAuxilliariesConfig.cs new file mode 100644 index 0000000000..c377393eb3 --- /dev/null +++ b/VECTOAux/BusAuxiliaries/DownstreamModules/Impl/Pneumatics/PneumaticsAuxilliariesConfig.cs @@ -0,0 +1,65 @@ +// 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 TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.PneumaticSystem; + +namespace TUGraz.VectoCore.BusAuxiliaries.DownstreamModules.Impl.Pneumatics +{ + public class PneumaticsAuxilliariesConfig : IPneumaticsAuxilliariesConfig + { + public double AdBlueNIperMinute { get; set; } + + public double AirControlledSuspensionNIperMinute { get; set; } + + public double BrakingNoRetarderNIperKG { get; set; } + + public double BrakingWithRetarderNIperKG { get; set; } + + public double BreakingPerKneelingNIperKGinMM { get; set; } + + public double DeadVolBlowOutsPerLitresperHour { get; set; } + + public double DeadVolumeLitres { get; set; } + + public double NonSmartRegenFractionTotalAirDemand { get; set; } + + public double OverrunUtilisationForCompressionFraction { get; set; } + + public double PerDoorOpeningNI { get; set; } + + public double PerStopBrakeActuationNIperKG { get; set; } + + public double SmartRegenFractionTotalAirDemand { get; set; } + + + public PneumaticsAuxilliariesConfig(bool setToDefaults = false) + { + if (setToDefaults) + SetDefaults(); + } + + public void SetDefaults() + { + AdBlueNIperMinute = 21.25; + AirControlledSuspensionNIperMinute = 15; + BrakingNoRetarderNIperKG = 0.00081; + BrakingWithRetarderNIperKG = 0.0006; + BreakingPerKneelingNIperKGinMM = 0.000066; + DeadVolBlowOutsPerLitresperHour = 24; + DeadVolumeLitres = 30; + NonSmartRegenFractionTotalAirDemand = 0.26; + OverrunUtilisationForCompressionFraction = 0.97; + PerDoorOpeningNI = 12.7; + PerStopBrakeActuationNIperKG = 0.00064; + SmartRegenFractionTotalAirDemand = 0.12; + } + } +} diff --git a/VECTOAux/BusAuxiliaries/IAuxiliaryConfig.cs b/VECTOAux/BusAuxiliaries/IAuxiliaryConfig.cs new file mode 100644 index 0000000000..bdf0eca6f6 --- /dev/null +++ b/VECTOAux/BusAuxiliaries/IAuxiliaryConfig.cs @@ -0,0 +1,41 @@ +// 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 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; + +namespace TUGraz.VectoCore.BusAuxiliaries { + public interface IAuxiliaryConfig + { + // Vecto + IVectoInputs VectoInputs { get; set; } + + // Electrical + IElectricsUserInputsConfig ElectricalUserInputsConfig { get; set; } + + + // Pneumatics + IPneumaticUserInputsConfig PneumaticUserInputsConfig { get; set; } + IPneumaticsAuxilliariesConfig PneumaticAuxillariesConfig { get; set; } + + // Hvac + IHVACUserInputsConfig HvacUserInputsConfig { get; set; } + + bool ConfigValuesAreTheSameAs(AuxiliaryConfig other); + + + // Persistance Functions + bool Save(string filePath); + bool Load(string filePath); + } +} diff --git a/VECTOAux/BusAuxiliaries/Images/Delete-32.png b/VECTOAux/BusAuxiliaries/Images/Delete-32.png new file mode 100644 index 0000000000000000000000000000000000000000..31eab12612c7a2895ef3e9fad8110f6dcb6b3448 GIT binary patch literal 1430 zcmb7EZA{!`94~MzW6C7x6wm0o5{PbceYw|G4(MImadU@wM+D=`DA#gV?ykMHJ?}V| zD2SON8seDj!{o!1ZAJu576RFv#<`hs*>om4<7Aq!XtHcG7&MB?e9Ab+hlRu@?eq5k z{eJ(qr>{0PY%N}AUI#%?v9F#9fDty{wQImv%Vg%jaIem`=s~4jPw}b<(Sp(@!oD~k z76T$LbnZMYRzpz12U1gu-s0a*g_O93H*75FcmkjysJb?t;6qVShug%kB)gGckA8x{ zlHf*~?S9Ok@QM+sKBJ1kOhZ#B6Ah69Qd<L8rzt=X7j+&^$78ZarQOIPF9qhtHj2QD zCVJG3+;FPJ-w1mZRfO#ptSW>#FxY`xaI4MfbUq9d7>=PBf#O6J?xd^)g<<g0g8(&E zXr}@Ux1<GDZX}}X2?|A1sgxyUwJ2&B#YvJhI0&K&SX619vd*WgWUV~Mz=&E%l@hw7 z$gsi4w<$^8jQ~$?gb+^zq;N#nmdRypDOn(GXqr!;xCKMiMH?f&9Ln!s9TAT&TWfki zyy^Tc`L(9bgop-2O-ZUDP{sE06;i7U8HP(SP<~#GilB-dAJfFe1HYeo3^*^ze2h^- z$+#%%KE{nClafHutd+AlFqeySkqnFDw9A2!B!?3?O<*>H%n_^v0xgRGup~}8tgPMT zv9lbGvzUjbtsW0+W1Jq`YR8!z)+cK^FNZ`!)WAwNvCdVolvfpbT~V79C6?=^#)zUT zT0}{}-k=?BmSjOmX-1&|GYFIsRp~iV;8Z0JFXo(*ZlP`^SPyBlF)Ro4F&rmpkB#OS z60?$=)y{g5C9Lqj(}e<0P@~6I^jvNWG_o;WzCmEId<R7tluQLTZ0xCylMs~mypN%q z(%)ZcraMkxC3BTs&zd6}zgm-#hDx^Wcr&`mz4!R=C4nCMw;rA=Iy2lqmv?5<V99~k zOJn7eTcQ=&+2QU&a(wH|^tnjEEBlU+lrQ^EGT%LOIeB=;@aD?RJ-xrw?K00?eScr~ zXx^?#^q{FMZK(;)*7Kk0bhz%?x$*SEBZEu@cm9d|$-##T%JT0)r@sDXiXUkGTmNEu zPszle($mLYD0sW;{@(32UtQ(IrI%+bGHV<&U3c^k6^*4VwQt>Bd_`E_Yd?9)^30Px z^DlkmHt*+pO0#I|p4X19{T#`QZ8_WbU}e#vos&f4Zd2AiX*#Q!5A=;se;3~Ed-2*E zm)|Y?n5iFtIX|Y~cj_+Fy!r7vJD5Wo!ljYluzBxiv27IxPvf^8gR(ztc<*=DLgz%y zqh8f|y^tvA?Q@l?Cey|2iHrRsT=VGI;R^#pm|S~)FUS0~z_C9D_m6ygJeUU`d0=$o rhgYY{gg<_|{-t!mv_AiKsQKsO?vdVqjDIcUV;h)JPir@BBOLz$rKa%@ literal 0 HcmV?d00001 diff --git a/VECTOAux/BusAuxiliaries/Images/Delete.png b/VECTOAux/BusAuxiliaries/Images/Delete.png new file mode 100644 index 0000000000000000000000000000000000000000..31eab12612c7a2895ef3e9fad8110f6dcb6b3448 GIT binary patch literal 1430 zcmb7EZA{!`94~MzW6C7x6wm0o5{PbceYw|G4(MImadU@wM+D=`DA#gV?ykMHJ?}V| zD2SON8seDj!{o!1ZAJu576RFv#<`hs*>om4<7Aq!XtHcG7&MB?e9Ab+hlRu@?eq5k z{eJ(qr>{0PY%N}AUI#%?v9F#9fDty{wQImv%Vg%jaIem`=s~4jPw}b<(Sp(@!oD~k z76T$LbnZMYRzpz12U1gu-s0a*g_O93H*75FcmkjysJb?t;6qVShug%kB)gGckA8x{ zlHf*~?S9Ok@QM+sKBJ1kOhZ#B6Ah69Qd<L8rzt=X7j+&^$78ZarQOIPF9qhtHj2QD zCVJG3+;FPJ-w1mZRfO#ptSW>#FxY`xaI4MfbUq9d7>=PBf#O6J?xd^)g<<g0g8(&E zXr}@Ux1<GDZX}}X2?|A1sgxyUwJ2&B#YvJhI0&K&SX619vd*WgWUV~Mz=&E%l@hw7 z$gsi4w<$^8jQ~$?gb+^zq;N#nmdRypDOn(GXqr!;xCKMiMH?f&9Ln!s9TAT&TWfki zyy^Tc`L(9bgop-2O-ZUDP{sE06;i7U8HP(SP<~#GilB-dAJfFe1HYeo3^*^ze2h^- z$+#%%KE{nClafHutd+AlFqeySkqnFDw9A2!B!?3?O<*>H%n_^v0xgRGup~}8tgPMT zv9lbGvzUjbtsW0+W1Jq`YR8!z)+cK^FNZ`!)WAwNvCdVolvfpbT~V79C6?=^#)zUT zT0}{}-k=?BmSjOmX-1&|GYFIsRp~iV;8Z0JFXo(*ZlP`^SPyBlF)Ro4F&rmpkB#OS z60?$=)y{g5C9Lqj(}e<0P@~6I^jvNWG_o;WzCmEId<R7tluQLTZ0xCylMs~mypN%q z(%)ZcraMkxC3BTs&zd6}zgm-#hDx^Wcr&`mz4!R=C4nCMw;rA=Iy2lqmv?5<V99~k zOJn7eTcQ=&+2QU&a(wH|^tnjEEBlU+lrQ^EGT%LOIeB=;@aD?RJ-xrw?K00?eScr~ zXx^?#^q{FMZK(;)*7Kk0bhz%?x$*SEBZEu@cm9d|$-##T%JT0)r@sDXiXUkGTmNEu zPszle($mLYD0sW;{@(32UtQ(IrI%+bGHV<&U3c^k6^*4VwQt>Bd_`E_Yd?9)^30Px z^DlkmHt*+pO0#I|p4X19{T#`QZ8_WbU}e#vos&f4Zd2AiX*#Q!5A=;se;3~Ed-2*E zm)|Y?n5iFtIX|Y~cj_+Fy!r7vJD5Wo!ljYluzBxiv27IxPvf^8gR(ztc<*=DLgz%y zqh8f|y^tvA?Q@l?Cey|2iHrRsT=VGI;R^#pm|S~)FUS0~z_C9D_m6ygJeUU`d0=$o rhgYY{gg<_|{-t!mv_AiKsQKsO?vdVqjDIcUV;h)JPir@BBOLz$rKa%@ literal 0 HcmV?d00001 diff --git a/VECTOAux/BusAuxiliaries/Images/Delete1.png b/VECTOAux/BusAuxiliaries/Images/Delete1.png new file mode 100644 index 0000000000000000000000000000000000000000..31eab12612c7a2895ef3e9fad8110f6dcb6b3448 GIT binary patch literal 1430 zcmb7EZA{!`94~MzW6C7x6wm0o5{PbceYw|G4(MImadU@wM+D=`DA#gV?ykMHJ?}V| zD2SON8seDj!{o!1ZAJu576RFv#<`hs*>om4<7Aq!XtHcG7&MB?e9Ab+hlRu@?eq5k z{eJ(qr>{0PY%N}AUI#%?v9F#9fDty{wQImv%Vg%jaIem`=s~4jPw}b<(Sp(@!oD~k z76T$LbnZMYRzpz12U1gu-s0a*g_O93H*75FcmkjysJb?t;6qVShug%kB)gGckA8x{ zlHf*~?S9Ok@QM+sKBJ1kOhZ#B6Ah69Qd<L8rzt=X7j+&^$78ZarQOIPF9qhtHj2QD zCVJG3+;FPJ-w1mZRfO#ptSW>#FxY`xaI4MfbUq9d7>=PBf#O6J?xd^)g<<g0g8(&E zXr}@Ux1<GDZX}}X2?|A1sgxyUwJ2&B#YvJhI0&K&SX619vd*WgWUV~Mz=&E%l@hw7 z$gsi4w<$^8jQ~$?gb+^zq;N#nmdRypDOn(GXqr!;xCKMiMH?f&9Ln!s9TAT&TWfki zyy^Tc`L(9bgop-2O-ZUDP{sE06;i7U8HP(SP<~#GilB-dAJfFe1HYeo3^*^ze2h^- z$+#%%KE{nClafHutd+AlFqeySkqnFDw9A2!B!?3?O<*>H%n_^v0xgRGup~}8tgPMT zv9lbGvzUjbtsW0+W1Jq`YR8!z)+cK^FNZ`!)WAwNvCdVolvfpbT~V79C6?=^#)zUT zT0}{}-k=?BmSjOmX-1&|GYFIsRp~iV;8Z0JFXo(*ZlP`^SPyBlF)Ro4F&rmpkB#OS z60?$=)y{g5C9Lqj(}e<0P@~6I^jvNWG_o;WzCmEId<R7tluQLTZ0xCylMs~mypN%q z(%)ZcraMkxC3BTs&zd6}zgm-#hDx^Wcr&`mz4!R=C4nCMw;rA=Iy2lqmv?5<V99~k zOJn7eTcQ=&+2QU&a(wH|^tnjEEBlU+lrQ^EGT%LOIeB=;@aD?RJ-xrw?K00?eScr~ zXx^?#^q{FMZK(;)*7Kk0bhz%?x$*SEBZEu@cm9d|$-##T%JT0)r@sDXiXUkGTmNEu zPszle($mLYD0sW;{@(32UtQ(IrI%+bGHV<&U3c^k6^*4VwQt>Bd_`E_Yd?9)^30Px z^DlkmHt*+pO0#I|p4X19{T#`QZ8_WbU}e#vos&f4Zd2AiX*#Q!5A=;se;3~Ed-2*E zm)|Y?n5iFtIX|Y~cj_+Fy!r7vJD5Wo!ljYluzBxiv27IxPvf^8gR(ztc<*=DLgz%y zqh8f|y^tvA?Q@l?Cey|2iHrRsT=VGI;R^#pm|S~)FUS0~z_C9D_m6ygJeUU`d0=$o rhgYY{gg<_|{-t!mv_AiKsQKsO?vdVqjDIcUV;h)JPir@BBOLz$rKa%@ literal 0 HcmV?d00001 diff --git a/VECTOAux/BusAuxiliaries/Images/application-export-icon-small.png b/VECTOAux/BusAuxiliaries/Images/application-export-icon-small.png new file mode 100644 index 0000000000000000000000000000000000000000..308a361b10574649a2b733de3d933a243c4f4f4d GIT binary patch literal 645 zcmV;00($+4P)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00001b5ch_0Itp) z=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2i*e? z3L7y0&#^ZE00IR`L_t(I%gvL$Yg1tq#-H=vv^SCFqX{*LAGD=9iIqwQ5uxJ8pi_2> z{sI00PKuk8pdttk0Xw-VSTF_$MLGx$7A(?e(`t;hHffTZ^yc38<2abK-l{mbc;Mk( z-t&83p7R{wABzAWo6U;l)&4%M6i5gVQCGcd3}!}ZM@<(B&(zO=5CE9|k;&sHk6k1Y zj%lM=YXhSVm>D1ef(5%z`|Q4dA%wV}&lj8kKvHV5Nk^u>)x*%nz;wliVVD6B;*k!b z+8N2uwjKir0`{a@8<(bb!D(v-GXePVdiQiaLV3-?!UucMN*3dKe3tN%coSfYmOMDx z52X}sH;EZ2mI>1{6%5%6-rjhrwbX3}0096}O2KTPlnkiTanWcrP+PA-D;MWZPuSz5 zUM7>tL<0cd_bsIqq?DWTeINCvhqsG9DqmfkIU42t!^yGBS8m^krN+(&Jn%fv>NQb! zc3K;h%56+P5m;U^NDj0qF$g>=tb3)kA+;SKq*U;{EdT)Q-f82)SqmLW$Ul9K`FCO| zckkw%aQf5(;MNwPxe*E%%Y<6p3IKX0f*A1u3-hmXZbZF)=)Sqz4E$iRA|lswtJRgd zEx^CeYdUdA4yUVM-0B?v5@ivcIBa4k4!}y-e+<2@d#KHPiiSSVIgZl~0002{u8O~I f&c|y8|6P3tDMAaeGu$>d00000NkvXXu0mjfx-1ar literal 0 HcmV?d00001 diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/AltUserInput.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/AltUserInput.cs index 7770866c13..9ae644a922 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/AltUserInput.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/AltUserInput.cs @@ -1,7 +1,6 @@ using System; - -namespace DownstreamModules.Electrics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics { // Used by the Combined Alternator Form/Classes to accept user input for the combined alternators efficiency // At different Current Demands diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ElectricConstants.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ElectricConstants.cs index d459d3a36d..ac6d1e76ac 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ElectricConstants.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ElectricConstants.cs @@ -1,4 +1,4 @@ -namespace DownstreamModules.Electrics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics { public class ElectricConstants { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IAlternator.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IAlternator.cs index c0a100e423..8ffccdbe39 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IAlternator.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IAlternator.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace DownstreamModules.Electrics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics { public class Table4Row { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IAlternatorMap.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IAlternatorMap.cs index e68bd0b740..a7a7fa87c6 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IAlternatorMap.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IAlternatorMap.cs @@ -10,10 +10,8 @@ // See the LICENSE.txt for the specific language governing permissions and limitations. using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.BusAuxiliaries.Interfaces; -using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics; -namespace DownstreamModules.Electrics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics { public interface IAlternatorMap : IAuxiliaryEvent { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ICombinedAlternator.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ICombinedAlternator.cs index aa89af1bdd..48329d6d08 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ICombinedAlternator.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ICombinedAlternator.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace DownstreamModules.Electrics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics { public interface ICombinedAlternator { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ICombinedAlternatorMapRow.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ICombinedAlternatorMapRow.cs index 80cb4ae09e..f375cbbd5e 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ICombinedAlternatorMapRow.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ICombinedAlternatorMapRow.cs @@ -1,4 +1,4 @@ -namespace DownstreamModules.Electrics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics { // Reflects stored data in pesisted CombinedAlternator Map .AALT public interface ICombinedAlternatorMapRow diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ICombinedAlternatorSignals.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ICombinedAlternatorSignals.cs index d1a9bb73d6..725f5316bb 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ICombinedAlternatorSignals.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/ICombinedAlternatorSignals.cs @@ -1,6 +1,6 @@ using TUGraz.VectoCommon.Utils; -namespace DownstreamModules.Electrics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics { // Used by CombinedAlternator public interface ICombinedAlternatorSignals diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IElectricalConsumer.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IElectricalConsumer.cs index 3fd03cb75f..e6e91498d2 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IElectricalConsumer.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IElectricalConsumer.cs @@ -8,11 +8,12 @@ // 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.ComponentModel; using TUGraz.VectoCommon.Utils; -namespace DownstreamModules.Electrics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics { public interface IElectricalConsumer : INotifyPropertyChanged { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IElectricalConsumerList.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IElectricalConsumerList.cs index 378199f78d..94139b75fe 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IElectricalConsumerList.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IElectricalConsumerList.cs @@ -12,7 +12,7 @@ using System.Collections.Generic; using TUGraz.VectoCommon.Utils; -namespace DownstreamModules.Electrics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics { public interface IElectricalConsumerList { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IElectricsUserInputsConfig.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IElectricsUserInputsConfig.cs index 8ebefc20f8..29e63b70a1 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IElectricsUserInputsConfig.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/IElectricsUserInputsConfig.cs @@ -10,9 +10,7 @@ // See the LICENSE.txt for the specific language governing permissions and limitations. -using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics; - -namespace DownstreamModules.Electrics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics { public interface IElectricsUserInputsConfig { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/SmartResult.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/SmartResult.cs index e1ed684801..b8ca2b37c7 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/SmartResult.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/Electrics/SmartResult.cs @@ -43,7 +43,7 @@ namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics // Comparison Overrides public override bool Equals(object obj) { - SmartResult other = (SmartResult)obj; + var other = (SmartResult)obj; return Amps == other.Amps; } diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/Class1.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/Class1.cs index 1bc55a51a8..2ad245a613 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/Class1.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/Class1.cs @@ -1,4 +1,4 @@ -namespace DownstreamModules.HVAC +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC { public enum TechLineType { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IEnvironmentalCondition.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IEnvironmentalCondition.cs index 5fc78f0d50..408b4434ef 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IEnvironmentalCondition.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IEnvironmentalCondition.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace DownstreamModules.HVAC +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC { public interface IEnvironmentalCondition { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IEnvironmentalConditionsMap.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IEnvironmentalConditionsMap.cs index 00ab72bcff..6b45aa1633 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IEnvironmentalConditionsMap.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IEnvironmentalConditionsMap.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace DownstreamModules.HVAC +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC { public interface IEnvironmentalConditionsMap { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IHVACConstants.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IHVACConstants.cs index 82fa85c6d9..e8ba4fa7ae 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IHVACConstants.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IHVACConstants.cs @@ -1,6 +1,6 @@ using TUGraz.VectoCommon.Utils; -namespace DownstreamModules.HVAC +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC { public interface IHVACConstants { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IHVACSteadyStateModel.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IHVACSteadyStateModel.cs index 47baf5a025..e90485e89c 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IHVACSteadyStateModel.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IHVACSteadyStateModel.cs @@ -1,4 +1,4 @@ -namespace DownstreamModules.HVAC +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC { public interface IHVACSteadyStateModel { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IHVACUserInputsConfig.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IHVACUserInputsConfig.cs index c627716ae8..751c3b2f57 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IHVACUserInputsConfig.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/IHVACUserInputsConfig.cs @@ -1,4 +1,4 @@ -namespace DownstreamModules.HVAC +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC { public interface IHVACUserInputsConfig { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMCalculate.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMCalculate.cs index 763b9b37c3..4f3a63eebc 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMCalculate.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMCalculate.cs @@ -1,4 +1,4 @@ -namespace DownstreamModules.HVAC +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC { public interface ISSMCalculate { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMGenInputs.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMGenInputs.cs index 75a5d1b58e..1200f23926 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMGenInputs.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMGenInputs.cs @@ -1,4 +1,4 @@ -namespace DownstreamModules.HVAC +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC { public interface ISSMGenInputs { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMRun.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMRun.cs index eac78d1871..08fbfa00e8 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMRun.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMRun.cs @@ -1,4 +1,4 @@ -namespace DownstreamModules.HVAC +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC { public interface ISSMRun { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMTOOL.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMTOOL.cs index 8c81a8930f..c0e58df2b6 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMTOOL.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMTOOL.cs @@ -1,39 +1,39 @@ -using DownstreamModules.HVAC; +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC { + public interface ISSMTOOL + { + ISSMGenInputs GenInputs { get; set; } + ISSMTechList TechList { get; set; } + ISSMCalculate Calculate { get; set; } + bool SSMDisabled { get; set; } + IHVACConstants HVACConstants { get; set; } -public interface ISSMTOOL -{ - ISSMGenInputs GenInputs { get; set; } - ISSMTechList TechList { get; set; } - ISSMCalculate Calculate { get; set; } - bool SSMDisabled { get; set; } - IHVACConstants HVACConstants { get; set; } + double ElectricalWBase { get; } // Watt + double MechanicalWBase { get; } // Watt + double FuelPerHBase { get; } // LiterPerHour - double ElectricalWBase { get; } // Watt - double MechanicalWBase { get; } // Watt - double FuelPerHBase { get; } // LiterPerHour + double ElectricalWAdjusted { get; } // Watt + double MechanicalWBaseAdjusted { get; } // Watt + double FuelPerHBaseAdjusted { get; } // LiterPerHour - double ElectricalWAdjusted { get; } // Watt - double MechanicalWBaseAdjusted { get; } // Watt - double FuelPerHBaseAdjusted { get; } // LiterPerHour + void Clone(ISSMTOOL from); - void Clone(ISSMTOOL from); + bool Load(string filePath); - bool Load(string filePath); + bool Save(string filePath); - bool Save(string filePath); + bool IsEqualTo(ISSMTOOL source); - bool IsEqualTo(ISSMTOOL source); + /// <summary> + /// This alters the waste heat and returns an adjusted fueling value + /// </summary> + /// <param name="AverageUseableEngineWasteHeatKW"></param> + /// <returns></returns> + /// <remarks></remarks> + double FuelPerHBaseAsjusted(double AverageUseableEngineWasteHeatKW); - /// <summary> - /// This alters the waste heat and returns an adjusted fueling value - /// </summary> - /// <param name="AverageUseableEngineWasteHeatKW"></param> - /// <returns></returns> - /// <remarks></remarks> - double FuelPerHBaseAsjusted(double AverageUseableEngineWasteHeatKW); + event MessageEventHandler Message; - event MessageEventHandler Message; + } -} - -public delegate void MessageEventHandler(ref object sender, string message, AdvancedAuxiliaryMessageType messageType); + public delegate void MessageEventHandler(ref object sender, string message, AdvancedAuxiliaryMessageType messageType); +} \ No newline at end of file diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMTechList.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMTechList.cs index c733c4c464..253e8cfc51 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMTechList.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ISSMTechList.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace DownstreamModules.HVAC +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC { public interface ISSMTechList { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ITechListBenefitLine.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ITechListBenefitLine.cs index 6f323f25f3..e776bea651 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ITechListBenefitLine.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/HVAC/ITechListBenefitLine.cs @@ -1,4 +1,4 @@ -namespace DownstreamModules.HVAC { +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.HVAC { public interface ITechListBenefitLine { string Units { get; set; } diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IAbstractModule.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IAbstractModule.cs index 17325bf0d6..850bc73eda 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IAbstractModule.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IAbstractModule.cs @@ -1,4 +1,6 @@ -public interface IAbstractModule -{ - void ResetCalculations(); +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules { + public interface IAbstractModule + { + void ResetCalculations(); + } } diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM0_5_SmartAlternatorSetEfficiency.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM0_5_SmartAlternatorSetEfficiency.cs index 159fb12d36..2a7fa8c63e 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM0_5_SmartAlternatorSetEfficiency.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM0_5_SmartAlternatorSetEfficiency.cs @@ -11,7 +11,7 @@ using TUGraz.VectoCommon.Utils; -namespace Electrics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules { public interface IM0_5_SmartAlternatorSetEfficiency : IAbstractModule { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM0_NonSmart_AlternatorsSetEfficiency.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM0_NonSmart_AlternatorsSetEfficiency.cs index c3b94b2408..8dd5cd1f4d 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM0_NonSmart_AlternatorsSetEfficiency.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM0_NonSmart_AlternatorsSetEfficiency.cs @@ -11,7 +11,7 @@ using TUGraz.VectoCommon.Utils; -namespace Electrics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules { public interface IM0_NonSmart_AlternatorsSetEfficiency : IAbstractModule { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM10.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM10.cs index b714a2a7a5..36c6a950d6 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM10.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM10.cs @@ -11,8 +11,7 @@ using TUGraz.VectoCommon.Utils; - -namespace DownstreamModules +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules { public interface IM10 : IAbstractModule { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM11.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM11.cs index e57b6a99bf..787fffd74a 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM11.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM11.cs @@ -11,8 +11,7 @@ using TUGraz.VectoCommon.Utils; - -namespace DownstreamModules +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules { public interface IM11 : IAbstractModule { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM13.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM13.cs index ffd033cbc6..1252568221 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM13.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM13.cs @@ -12,8 +12,7 @@ using TUGraz.VectoCommon.Utils; - -namespace DownstreamModules +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules { public interface IM13 : IAbstractModule { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM14.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM14.cs index 2fdb84c6ba..bd06c88fef 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM14.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM14.cs @@ -1,7 +1,6 @@ using TUGraz.VectoCommon.Utils; - -namespace DownstreamModules +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules { public interface IM14 : IAbstractModule { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM1_AverageHVACLoadDemand.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM1_AverageHVACLoadDemand.cs index 388aac78b8..d04ec8a01c 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM1_AverageHVACLoadDemand.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM1_AverageHVACLoadDemand.cs @@ -11,7 +11,7 @@ using TUGraz.VectoCommon.Utils; -namespace Hvac +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules { public interface IM1_AverageHVACLoadDemand : IAbstractModule { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM2_AverageElectrialLoadDemand.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM2_AverageElectrialLoadDemand.cs index 5af93198d4..0a427d74bd 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM2_AverageElectrialLoadDemand.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM2_AverageElectrialLoadDemand.cs @@ -11,7 +11,7 @@ using TUGraz.VectoCommon.Utils; -namespace Electrics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules { public interface IM2_AverageElectricalLoadDemand : IAbstractModule { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM3_AveragePneumaticLoadDemand.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM3_AveragePneumaticLoadDemand.cs index c9c745d440..f45b6cf6ad 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM3_AveragePneumaticLoadDemand.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM3_AveragePneumaticLoadDemand.cs @@ -11,7 +11,7 @@ using TUGraz.VectoCommon.Utils; -namespace Pneumatics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules { public interface IM3_AveragePneumaticLoadDemand : IAbstractModule { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM4_AirCompressor.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM4_AirCompressor.cs index 043021e216..1248b8a518 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM4_AirCompressor.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM4_AirCompressor.cs @@ -11,7 +11,7 @@ using TUGraz.VectoCommon.Utils; -namespace Pneumatics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules { public interface IM4_AirCompressor : IAbstractModule { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM5_SmartAlternatorSetGeneration.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM5_SmartAlternatorSetGeneration.cs index cdec493959..50d8998b1b 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM5_SmartAlternatorSetGeneration.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM5_SmartAlternatorSetGeneration.cs @@ -11,7 +11,7 @@ using TUGraz.VectoCommon.Utils; -namespace Electrics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules { public interface IM5_SmartAlternatorSetGeneration : IAbstractModule { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM6.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM6.cs index ed47f1f8da..bfbdcd7dfb 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM6.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM6.cs @@ -11,7 +11,7 @@ using TUGraz.VectoCommon.Utils; -namespace DownstreamModules +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules { public interface IM6 : IAbstractModule { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM7.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM7.cs index 1184a27940..95656f3895 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM7.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM7.cs @@ -11,8 +11,7 @@ using TUGraz.VectoCommon.Utils; - -namespace DownstreamModules +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules { public interface IM7 : IAbstractModule { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM8.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM8.cs index e7f5560135..ae97c00319 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM8.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM8.cs @@ -12,8 +12,7 @@ using TUGraz.VectoCommon.Utils; - -namespace DownstreamModules +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules { public interface IM8 : IAbstractModule { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM9.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM9.cs index b06e7ca672..d840df6d9e 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM9.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/IM9.cs @@ -10,10 +10,8 @@ // See the LICENSE.txt for the specific language governing permissions and limitations. using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.BusAuxiliaries.Interfaces; - -namespace DownstreamModules +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules { public interface IM9 : IAuxiliaryEvent, IAbstractModule { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/ActuationsKey.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/ActuationsKey.cs index 5a2488ebc5..6abe470365 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/ActuationsKey.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/ActuationsKey.cs @@ -11,7 +11,7 @@ using System; -namespace Pneumatics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.PneumaticSystem { public class ActuationsKey { @@ -46,7 +46,7 @@ namespace Pneumatics // Overrides to enable this class to be used as a dictionary key in the ActuationsMap. public override bool Equals(object obj) { - ActuationsKey other = (ActuationsKey)obj; + var other = (ActuationsKey)obj; return other.ConsumerName == this.ConsumerName && other.CycleName == this.CycleName; } diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/ICompressorMap.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/ICompressorMap.cs index e3fb0293b6..4cee1360c2 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/ICompressorMap.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/ICompressorMap.cs @@ -10,9 +10,8 @@ // See the LICENSE.txt for the specific language governing permissions and limitations. using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.BusAuxiliaries.Interfaces; -namespace Pneumatics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.PneumaticSystem { public interface ICompressorMap : IAuxiliaryEvent { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/IPneumaticActuationsMAP.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/IPneumaticActuationsMAP.cs index 7d8c912a98..37cd7dea73 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/IPneumaticActuationsMAP.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/IPneumaticActuationsMAP.cs @@ -10,7 +10,7 @@ // See the LICENSE.txt for the specific language governing permissions and limitations. -namespace Pneumatics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.PneumaticSystem { public interface IPneumaticActuationsMAP { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/IPneumaticUserInputsConfig.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/IPneumaticUserInputsConfig.cs index 8679d67f5d..b32a18968b 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/IPneumaticUserInputsConfig.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/IPneumaticUserInputsConfig.cs @@ -1,4 +1,4 @@ -namespace Pneumatics +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.PneumaticSystem { public interface IPneumaticUserInputsConfig { diff --git a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/IPneumaticsAuxilliariesConfig.cs b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/IPneumaticsAuxilliariesConfig.cs index 51b0715ed4..833b9a255d 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/IPneumaticsAuxilliariesConfig.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/DownstreamModules/PneumaticSystem/IPneumaticsAuxilliariesConfig.cs @@ -1,15 +1,17 @@ -public interface IPneumaticsAuxilliariesConfig -{ - double OverrunUtilisationForCompressionFraction { get; set; } - double BrakingWithRetarderNIperKG { get; set; } - double BrakingNoRetarderNIperKG { get; set; } - double BreakingPerKneelingNIperKGinMM { get; set; } - double PerDoorOpeningNI { get; set; } - double PerStopBrakeActuationNIperKG { get; set; } - double AirControlledSuspensionNIperMinute { get; set; } - double AdBlueNIperMinute { get; set; } - double NonSmartRegenFractionTotalAirDemand { get; set; } - double SmartRegenFractionTotalAirDemand { get; set; } - double DeadVolumeLitres { get; set; } - double DeadVolBlowOutsPerLitresperHour { get; set; } +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.PneumaticSystem { + public interface IPneumaticsAuxilliariesConfig + { + double OverrunUtilisationForCompressionFraction { get; set; } + double BrakingWithRetarderNIperKG { get; set; } + double BrakingNoRetarderNIperKG { get; set; } + double BreakingPerKneelingNIperKGinMM { get; set; } + double PerDoorOpeningNI { get; set; } + double PerStopBrakeActuationNIperKG { get; set; } + double AirControlledSuspensionNIperMinute { get; set; } + double AdBlueNIperMinute { get; set; } + double NonSmartRegenFractionTotalAirDemand { get; set; } + double SmartRegenFractionTotalAirDemand { get; set; } + double DeadVolumeLitres { get; set; } + double DeadVolBlowOutsPerLitresperHour { get; set; } + } } diff --git a/VECTOAux/BusAuxiliaries/Interfaces/Enumerations.cs b/VECTOAux/BusAuxiliaries/Interfaces/Enumerations.cs index 7df4a69036..ea4fa8b4fc 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/Enumerations.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/Enumerations.cs @@ -1,6 +1,8 @@ -public enum AdvancedAuxiliaryMessageType -{ - Information = 1, - Warning = 2, - Critical = 3 +namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces { + public enum AdvancedAuxiliaryMessageType + { + Information = 1, + Warning = 2, + Critical = 3 + } } diff --git a/VECTOAux/BusAuxiliaries/Interfaces/IAdvancedAuxiliaries.cs b/VECTOAux/BusAuxiliaries/Interfaces/IAdvancedAuxiliaries.cs index d7a0f3d125..ce122663cf 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/IAdvancedAuxiliaries.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/IAdvancedAuxiliaries.cs @@ -96,7 +96,7 @@ namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces { /// <param name="vectoFilePath"></param> /// <returns></returns> /// <remarks></remarks> - bool Configure(string filePath, string vectoFilePath); + //bool Configure(string filePath, string vectoFilePath); /// <summary> /// Validate AAUX file path supplied. diff --git a/VECTOAux/BusAuxiliaries/Interfaces/IM12.cs b/VECTOAux/BusAuxiliaries/Interfaces/IM12.cs index a9187abd6e..1e4390d565 100644 --- a/VECTOAux/BusAuxiliaries/Interfaces/IM12.cs +++ b/VECTOAux/BusAuxiliaries/Interfaces/IM12.cs @@ -10,6 +10,7 @@ // See the LICENSE.txt for the specific language governing permissions and limitations. using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules; namespace TUGraz.VectoCore.BusAuxiliaries.Interfaces { diff --git a/VECTOAux/BusAuxiliaries/Legacy/Class1.cs b/VECTOAux/BusAuxiliaries/Legacy/Class1.cs new file mode 100644 index 0000000000..e51920eb4d --- /dev/null +++ b/VECTOAux/BusAuxiliaries/Legacy/Class1.cs @@ -0,0 +1,192 @@ +// 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.Globalization; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.BusAuxiliaries.Interfaces; + +namespace TUGraz.VectoCore.BusAuxiliaries.Legacy { + public class cMAP : IFuelConsumptionMap + { + private List<float> LnU; + private List<float> LTq; + private List<float> lFC; + + private string sFilePath; + private int iMapDim; + + private cDelaunayMap FuelMap; + + private void ResetMe() + { + lFC = null; + LTq = null; + LnU = null; + iMapDim = -1; + FuelMap = new cDelaunayMap(); + } + + public bool ReadFile(bool ShowMsg = true) + { + cFile_V3 file; + string[] line; + float nU; + string MsgSrc; + + + MsgSrc = "Main/ReadInp/MAP"; + + // Reset + ResetMe(); + + // Stop if there's no file + if (sFilePath == "" || !System.IO.File.Exists(sFilePath)) + return false; + + // Open file + file = new cFile_V3(); + if (!file.OpenRead(sFilePath)) { + file = null/* TODO Change to default(_) if this is not a reference type */; + return false; + } + + // Skip Header + file.ReadLine(); + + // Initi Lists (before version check so ReadOldFormat works) + lFC = new System.Collections.Generic.List<float>(); + LTq = new System.Collections.Generic.List<float>(); + LnU = new System.Collections.Generic.List<float>(); + + try { + while (!file.EndOfFile) { + + // Line read + line = file.ReadLine(); + + // Line counter up (was reset in ResetMe) + iMapDim += 1; + + // Revolutions + nU = float.Parse(line[0], CultureInfo.InvariantCulture); + + LnU.Add(nU); + + // Power + LTq.Add(float.Parse(line[1], CultureInfo.InvariantCulture)); + + // FC + // Check sign + if (System.Convert.ToSingle(line[2]) < 0) { + file.Close(); + + return false; + } + + lFC.Add(System.Convert.ToSingle(line[2])); + } + } catch (Exception ex) { + goto lbEr; + } + + // Close file + file.Close(); + + file = null/* TODO Change to default(_) if this is not a reference type */; + + return true; + + + // ERROR-label for clean Abort + lbEr: + ; + file.Close(); + file = null/* TODO Change to default(_) if this is not a reference type */; + + return false; + } + + public bool Triangulate() + { + int i; + + string MsgSrc; + + MsgSrc = "MAP/Norm"; + + // FC Delauney + for (i = 0; i <= iMapDim; i++) + FuelMap.AddPoints(LnU[i], LTq[i], lFC[i]); + + return FuelMap.Triangulate(); + } + + + public float fFCdelaunay_Intp(float nU, float Tq) + { + float val; + + val = System.Convert.ToSingle(FuelMap.Intpol(nU, Tq)); + + if (FuelMap.ExtrapolError) + return -10000; + else + return val; + } + + + public string FilePath + { + get { + return sFilePath; + } + set { + sFilePath = value; + } + } + + public int MapDim + { + get { + return iMapDim; + } + } + + public List<float> Tq + { + get { + return LTq; + } + } + + public List<float> FC + { + get { + return lFC; + } + } + + public List<float> nU + { + get { + return LnU; + } + } + + + public KilogramPerSecond GetFuelConsumption(NewtonMeter torque, PerSecond angularVelocity) + { + return (fFCdelaunay_Intp(System.Convert.ToSingle(angularVelocity.AsRPM), System.Convert.ToSingle(torque.Value())) / 3600.0 / 1000.0).SI<KilogramPerSecond>(); + } + } +} diff --git a/VECTOAux/BusAuxiliaries/Legacy/cDelaunayMap.cs b/VECTOAux/BusAuxiliaries/Legacy/cDelaunayMap.cs new file mode 100644 index 0000000000..7efd9ea13b --- /dev/null +++ b/VECTOAux/BusAuxiliaries/Legacy/cDelaunayMap.cs @@ -0,0 +1,476 @@ +// 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; + +namespace TUGraz.VectoCore.BusAuxiliaries.Legacy { + public class cDelaunayMap + { + public int ptDim; + + public List<dPoint> ptList; + private List<dTriangle> lDT; + private List<double[]> planes; + + public bool DualMode; + private List<dPoint> ptListXZ; + private List<double[]> planesXZ; + private List<dTriangle> lDTXZ; + + public bool ExtrapolError; + + + public cDelaunayMap() + { + ptList = new List<dPoint>(); + ptListXZ = new List<dPoint>(); + DualMode = false; + } + + public void AddPoints(double X, double Y, double Z) + { + ptList.Add(new dPoint(X, Y, Z)); + if (DualMode) + ptListXZ.Add(new dPoint(X, Z, Y)); + } + + public bool Triangulate() + { + //dTriangle tr; + dTriangulation DT; + + ptDim = ptList.Count - 1; + + // XY-triangulation + try { + DT = new dTriangulation(); + lDT = DT.Triangulate(ptList); + } catch (Exception ex) { + return false; + } + + planes = new List<double[]>(); + + foreach (var tr in lDT) + planes.Add(GetPlane(tr)); + + + // #If DEBUG Then + // Dim i As Int16 + // Debug.Print("#,x1,y1,z1,x2,y2,z2") + // i = -1 + // For Each tr In lDT + // i += 1 + // Debug.Print(i & "," & tr.P1.X & "," & tr.P1.Y & "," & tr.P1.Z & "," & tr.P2.X & "," & tr.P2.Y & "," & tr.P2.Z) + // Debug.Print(i & "," & tr.P3.X & "," & tr.P3.Y & "," & tr.P3.Z & "," & tr.P2.X & "," & tr.P2.Y & "," & tr.P2.Z) + // Debug.Print(i & "," & tr.P1.X & "," & tr.P1.Y & "," & tr.P1.Z & "," & tr.P3.X & "," & tr.P3.Y & "," & tr.P3.Z) + // Next + // #End If + + + // XZ-triangulation + if (DualMode) { + if (ptDim != ptListXZ.Count - 1) + return false; + + try { + DT = new dTriangulation(); + lDTXZ = DT.Triangulate(ptListXZ); + } catch (Exception ex) { + return false; + } + + planesXZ = new List<double[]>(); + + foreach (var tr in lDTXZ) + planesXZ.Add(GetPlane(tr)); + } + + return true; + } + + // XY => Z Interpolation + public double Intpol(double x, double y) + { + int j; + double[] l0; + //dTriangle tr; + + ExtrapolError = false; + + // Try exact solution for IsInside() + j = -1; + foreach (var tr in lDT) { + j += 1; + if (IsInside(tr, x, y, true)) { + l0 = planes[j]; + return (l0[3] - x * l0[0] - y * l0[1]) / l0[2]; + } + } + + // Try approx. solution (fixes rounding errors when points lies exactly on an edge of a triangle) + j = -1; + foreach (var tr in lDT) { + j += 1; + if (IsInside(tr, x, y, false)) { + l0 = planes[j]; + return (l0[3] - x * l0[0] - y * l0[1]) / l0[2]; + } + } + + + // ERROR: Extrapolation + ExtrapolError = true; + + return default(Double); + } + + // XZ => Y Interpolation + public double IntpolXZ(double x, double z) + { + int j; + double[] l0; + //dTriangle tr; + + ExtrapolError = false; + + if (DualMode) { + j = -1; + + // Try exact solution for IsInside() + foreach (var tr in lDTXZ) { + j += 1; + if (IsInside( tr, x, z, true)) { + l0 = planesXZ[j]; + return (l0[3] - x * l0[0] - z * l0[1]) / l0[2]; + } + } + + // Try approx. solution (fixes rounding errors when points lies exactly on an edge of a triangle) + j = -1; + foreach (var tr in lDTXZ) { + j += 1; + if (IsInside( tr, x, z, false)) { + l0 = planesXZ[j]; + return (l0[3] - x * l0[0] - z * l0[1]) / l0[2]; + } + } + + // ERROR: Extrapolation + ExtrapolError = true; + return default(Double); + } else { + + // ERROR: Extrapolation + ExtrapolError = true; + return default(Double); + } + } + + private double[] GetPlane(dTriangle tr) + { + dPoint AB; + dPoint AC; + dPoint cross; + var l = new double[4]; + dPoint pt1; + dPoint pt2; + dPoint pt3; + + pt1 = tr.P1; + pt2 = tr.P2; + pt3 = tr.P3; + + AB = new dPoint(pt2.X - pt1.X, pt2.Y - pt1.Y, pt2.Z - pt1.Z); + AC = new dPoint(pt3.X - pt1.X, pt3.Y - pt1.Y, pt3.Z - pt1.Z); + + cross = new dPoint(AB.Y * AC.Z - AB.Z * AC.Y, AB.Z * AC.X - AB.X * AC.Z, AB.X * AC.Y - AB.Y * AC.X); + + l[0] = cross.X; + l[1] = cross.Y; + l[2] = cross.Z; + + l[3] = pt1.X * cross.X + pt1.Y * cross.Y + pt1.Z * cross.Z; + + return l; + } + + private bool IsInside(dTriangle tr, double xges, double yges, bool Exact) + { + var v0 = new double[2]; + var v1 = new double[2]; + var v2 = new double[2]; + double dot00; + double dot01; + double dot02; + double dot11; + double dot12; + double invDenom; + double u; + double v; + dPoint pt1; + dPoint pt2; + dPoint pt3; + + pt1 = tr.P1; + pt2 = tr.P2; + pt3 = tr.P3; + + // Quelle: http://www.blackpawn.com/texts/pointinpoly/default.html (Barycentric Technique) + + // Compute vectors + v0[0] = pt3.X - pt1.X; + v0[1] = pt3.Y - pt1.Y; + + v1[0] = pt2.X - pt1.X; + v1[1] = pt2.Y - pt1.Y; + + v2[0] = xges - pt1.X; + v2[1] = yges - pt1.Y; + + // Compute dot products + dot00 = v0[0] * v0[0] + v0[1] * v0[1]; + dot01 = v0[0] * v1[0] + v0[1] * v1[1]; + dot02 = v0[0] * v2[0] + v0[1] * v2[1]; + dot11 = v1[0] * v1[0] + v1[1] * v1[1]; + dot12 = v1[0] * v2[0] + v1[1] * v2[1]; + + // Compute barycentric coordinates + invDenom = 1 / (dot00 * dot11 - dot01 * dot01); + u = (dot11 * dot02 - dot01 * dot12) * invDenom; + v = (dot00 * dot12 - dot01 * dot02) * invDenom; + + // Debug.Print(u & ", " & v & ", " & u + v) + + // Check if point is in triangle + if (Exact) + return (u >= 0) & (v >= 0) & (u + v <= 1); + else + return (u >= -0.001) & (v >= -0.001) & (u + v <= 1.001); + } + + public struct dPoint + { + public double X; + public double Y; + public double Z; + + public dPoint(double xd, double yd, double zd) + { + X = xd; + Y = yd; + Z = zd; + } + + public static bool operator ==(dPoint left, dPoint right) + { + + // If DirectCast(left, Object) = DirectCast(right, Object) Then + // Return True + // End If + + // If (DirectCast(left, Object) Is Nothing) OrElse (DirectCast(right, Object) Is Nothing) Then + // Return False + // End If + + // Just compare x and y here... + if (left.X != right.X) + return false; + + if (left.Y != right.Y) + return false; + + return true; + } + + public static bool operator !=(dPoint left, dPoint right) + { + return !(left == right); + } + } + + public class dTriangle + { + public dPoint P1; + public dPoint P2; + public dPoint P3; + + public dTriangle( dPoint pp1, dPoint pp2, dPoint pp3) + { + P1 = pp1; + P2 = pp2; + P3 = pp3; + } + + public double ContainsInCircumcircle(dPoint pt) + { + var ax = this.P1.X - pt.X; + var ay = this.P1.Y - pt.Y; + var bx = this.P2.X - pt.X; + var by = this.P2.Y - pt.Y; + var cx = this.P3.X - pt.X; + var cy = this.P3.Y - pt.Y; + var det_ab = ax * by - bx * ay; + var det_bc = bx * cy - cx * by; + var det_ca = cx * ay - ax * cy; + var a_squared = ax * ax + ay * ay; + var b_squared = bx * bx + by * by; + var c_squared = cx * cx + cy * cy; + + return a_squared * det_bc + b_squared * det_ca + c_squared * det_ab; + } + + public bool SharesVertexWith(dTriangle triangle) + { + if (this.P1.X == triangle.P1.X && this.P1.Y == triangle.P1.Y) + return true; + if (this.P1.X == triangle.P2.X && this.P1.Y == triangle.P2.Y) + return true; + if (this.P1.X == triangle.P3.X && this.P1.Y == triangle.P3.Y) + return true; + + if (this.P2.X == triangle.P1.X && this.P2.Y == triangle.P1.Y) + return true; + if (this.P2.X == triangle.P2.X && this.P2.Y == triangle.P2.Y) + return true; + if (this.P2.X == triangle.P3.X && this.P2.Y == triangle.P3.Y) + return true; + + if (this.P3.X == triangle.P1.X && this.P3.Y == triangle.P1.Y) + return true; + if (this.P3.X == triangle.P2.X && this.P3.Y == triangle.P2.Y) + return true; + if (this.P3.X == triangle.P3.X && this.P3.Y == triangle.P3.Y) + return true; + + return false; + } + } + + public class dEdge + { + public dPoint StartPoint; + public dPoint EndPoint; + + public dEdge(dPoint p1, dPoint p2) + { + StartPoint = p1; + EndPoint = p2; + } + + public static bool operator ==(dEdge left, dEdge right) + { + // If DirectCast(left, Object) = DirectCast(right, Object) Then + // Return True + // End If + + // If (DirectCast(left, Object) Is Nothing) Or (DirectCast(right, Object) Is Nothing) Then + // Return False + // End If + + return ((left.StartPoint == right.StartPoint && left.EndPoint == right.EndPoint) || (left.StartPoint == right.EndPoint && left.EndPoint == right.StartPoint)); + } + + public static bool operator !=(dEdge left, dEdge right) + { + return !(left == right); + } + } + + public class dTriangulation + { + public List<dTriangle> Triangulate(List<dPoint> triangulationPoints) + { + if (triangulationPoints.Count < 3) + throw new ArgumentException("Can not triangulate less than three vertices!"); + + // The triangle list + var triangles = new List<dTriangle>(); + + + // The "supertriangle" which encompasses all triangulation points. + // This triangle initializes the algorithm and will be removed later. + var superTriangle = this.SuperTriangle(triangulationPoints); + triangles.Add(superTriangle); + + // Include each point one at a time into the existing triangulation + for (var i = 0; i <= triangulationPoints.Count - 1; i++) { + // Initialize the edge buffer. + var EdgeBuffer = new List<dEdge>(); + + // If the actual vertex lies inside the circumcircle, then the three edges of the + // triangle are added to the edge buffer and the triangle is removed from list. + for (var j = triangles.Count - 1; j >= 0; j += -1) { + var t = triangles[j]; + if (t.ContainsInCircumcircle(triangulationPoints[i]) > 0) { + EdgeBuffer.Add(new dEdge(t.P1, t.P2)); + EdgeBuffer.Add(new dEdge(t.P2, t.P3)); + EdgeBuffer.Add(new dEdge(t.P3, t.P1)); + triangles.RemoveAt(j); + } + } + + // Remove duplicate edges. This leaves the convex hull of the edges. + // The edges in this convex hull are oriented counterclockwise! + for (var j = EdgeBuffer.Count - 2; j >= 0; j += -1) { + for (var k = EdgeBuffer.Count - 1; k >= j + 1; k += -1) { + if (EdgeBuffer[j] == EdgeBuffer[k]) { + EdgeBuffer.RemoveAt(k); + EdgeBuffer.RemoveAt(j); + k -= 1; + continue; + } + } + } + + // Generate new counterclockwise oriented triangles filling the "hole" in + // the existing triangulation. These triangles all share the actual vertex. + for (var j = 0; j <= EdgeBuffer.Count - 1; j++) + triangles.Add(new dTriangle(EdgeBuffer[j].StartPoint, EdgeBuffer[j].EndPoint, triangulationPoints[i])); + } + + // We don't want the supertriangle in the triangulation, so + // remove all triangles sharing a vertex with the supertriangle. + for (var i = triangles.Count - 1; i >= 0; i += -1) { + if (triangles[i].SharesVertexWith(superTriangle)) + triangles.RemoveAt(i); + } + + // Return the triangles + return triangles; + } + + + private dTriangle SuperTriangle(List<dPoint> triangulationPoints) + { + var M = triangulationPoints[0].X; + + // get the extremal x and y coordinates + for (var i = 1; i <= triangulationPoints.Count - 1; i++) { + var xAbs = Math.Abs(triangulationPoints[i].X); + var yAbs = Math.Abs(triangulationPoints[i].Y); + if (xAbs > M) + M = xAbs; + if (yAbs > M) + M = yAbs; + } + + // make a triangle + var sp1 = new dPoint(10 * M, 0, 0); + var sp2 = new dPoint(0, 10 * M, 0); + var sp3 = new dPoint(-10 * M, -10 * M, 0); + + return new dTriangle( sp1, sp2, sp3); + } + } + } +} diff --git a/VECTOAux/BusAuxiliaries/Legacy/cFile_V3.cs b/VECTOAux/BusAuxiliaries/Legacy/cFile_V3.cs new file mode 100644 index 0000000000..15e41ec7f2 --- /dev/null +++ b/VECTOAux/BusAuxiliaries/Legacy/cFile_V3.cs @@ -0,0 +1,175 @@ +// 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.IO; +using Microsoft.VisualBasic.FileIO; +using TUGraz.VectoCore.BusAuxiliaries.Util; + +namespace TUGraz.VectoCore.BusAuxiliaries.Legacy { + public class cFile_V3 + { + private TextFieldParser TxtFldParser; + private StreamWriter StrWrter; + private FileMode Mode; + private string Path; + private string Sepp; + private bool SkipCom; + private bool StopE; + private bool FileOpen; + private string[] PreLine; + private bool FileEnd; + + // File format + private System.Text.Encoding FileFormat = System.Text.Encoding.UTF8; + + public cFile_V3() + { + Reset(); + } + + private void Reset() + { + FileOpen = false; + Mode = FileMode.Undefined; + PreLine = null; + FileEnd = false; + } + + public bool OpenRead(string FileName, string Separator = ",", bool SkipComment = true, bool StopAtE = false) + { + Reset(); + StopE = StopAtE; + Path = FileName; + Sepp = Separator; + SkipCom = SkipComment; + if (!(Mode == FileMode.Undefined)) + return false; + if (!File.Exists(Path)) + return false; + Mode = FileMode.Read; + try { + TxtFldParser = new TextFieldParser(Path, System.Text.Encoding.Default); + FileOpen = true; + } catch (Exception ex) { + return false; + } + TxtFldParser.TextFieldType = FieldType.Delimited; + TxtFldParser.Delimiters = new string[] { Sepp }; + + // If TxtFldParser.EndOfData Then Return False + + ReadLine(); + return true; + } + + public string[] ReadLine() + { + var line = PreLine; + + lb10: + ; + if (TxtFldParser.EndOfData) { + FileEnd = true; + } else { + PreLine = TxtFldParser.ReadFields(); + var line0 = PreLine[0].Trim().ToUpper(); + + if (SkipCom) { + if (FilePathUtils.Left(line0, 1) == "#") + goto lb10; + } + + if (StopE) + FileEnd = (line0 == "E"); + } + + return line; + } + + public void Close() + { + switch (Mode) { + case FileMode.Read: { + if (FileOpen) + TxtFldParser.Close(); + TxtFldParser = null; + break; + } + + case FileMode.Write: { + if (FileOpen) + StrWrter.Close(); + StrWrter = null; + break; + } + } + Reset(); + } + + public bool EndOfFile + { + get { + return FileEnd; + } + } + + public bool OpenWrite(string FileName, string Separator = ",", bool AutoFlush = false, bool Append = false) + { + Reset(); + Path = FileName; + Sepp = Separator; + if (Mode != FileMode.Undefined) + return false; + Mode = FileMode.Write; + try { + if (!Append) { + File.Delete(Path); + } + StrWrter = new StreamWriter(File.OpenWrite(Path), FileFormat); + FileOpen = true; + } catch (Exception ex) { + return false; + } + StrWrter.AutoFlush = AutoFlush; + return true; + } + + public void WriteLine(params object[] x) + { + //string St; + var StB = new System.Text.StringBuilder(); + bool Skip; + Skip = true; + foreach (var St in x) { + if (Skip) { + StB.Append(St); + Skip = false; + } else + StB.Append(Sepp + St); + } + StrWrter.WriteLine(StB.ToString()); + StB = null; + } + + public void WriteLine(string x) + { + StrWrter.WriteLine(x); + } + + private enum FileMode + { + Undefined, + Read, + Write + } + } +} diff --git a/VECTOAux/BusAuxiliaries/Resources/Blank.bmp b/VECTOAux/BusAuxiliaries/Resources/Blank.bmp new file mode 100644 index 0000000000000000000000000000000000000000..3356cb1a16ef78415ac26ff4ddfe2ec06e7f5e1a GIT binary patch literal 4150 zcmeIuK@9*P3`5ajfFOY*3MPO%uJHxUh6?hVbXl)&E^iib-J$l^5}$^$Yc`kJAqXIV V00IagfB*srAb<b@2q5sizy)IH^cnyF literal 0 HcmV?d00001 diff --git a/VECTOAux/BusAuxiliaries/Resources/Image1.png b/VECTOAux/BusAuxiliaries/Resources/Image1.png new file mode 100644 index 0000000000000000000000000000000000000000..3e9d6ed41b4901ee2e3811ef6e85df0978acf1d2 GIT binary patch literal 233 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1SD@H<Xr$#jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCijSl0AZa85pY67#JE_7#My5g&JNkFq8sKd6mGxU^Rn*LA+qju0R{0M7pPo zV@QPi+e;e-85DU~3}5We_#b?58J|m4r~8|^GdI8b%f7ZM{i^Bv-7+FfEn0$3EnW-C wcm=f@Z<)HRV9B~Juuy14tTTSW>!x2AA6$+S6}hN-9%v<lr>mdKI;Vst04O9%8~^|S literal 0 HcmV?d00001 diff --git a/VECTOAux/BusAuxiliaries/Resources/Info.bmp b/VECTOAux/BusAuxiliaries/Resources/Info.bmp new file mode 100644 index 0000000000000000000000000000000000000000..c87470c216723cf67cf853cec686934aee6c9c66 GIT binary patch literal 4150 zcmZ?rH4|U}12Z700mKSW%m`)yIY4lP4}u{)28REmU^E0qLtw~+!0T^3|8Ze@cmkK* zAaQztQTs>ZA6FU}O@Fix0bF4}n*T@3Kia3h|2XTuk&^!C5yperj=@m=U<)65roVx< PA6Fb;bJwWY;0^%*r<-Z| literal 0 HcmV?d00001 diff --git a/VECTOAux/BusAuxiliaries/Resources/Open-icon.png b/VECTOAux/BusAuxiliaries/Resources/Open-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..5b25c5b924bd2a400e3b1a24887bad98d10b5ad2 GIT binary patch literal 786 zcmV+t1MU2YP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV0008nNkl<Zc-oDV zO-vI(6vzMDZNUJgB@iJR`4Ef9H$frsK*V57{7BGvlY@k-Mo2K4s0WSVf+iZHC;2#u za4}M2q6tC~1H=d=<ug>I<x2$G?Uq8j%g#ET7A*1NOI~K?&3nK3znNWbsIz(mK#`W$ zK&z$BbKp1*k*3kGwV)_!eeQ*pw#Yq>0@Tv;1z25hLHH%Yy&@vvU?!5%a@e?IesK-< zz78S(Vr#-bfaB-#0W}oZmK6vTGG|*r>4`#`5zaKE!)$5CZC@X@{p9IPt*d?)P;xep z<){o2A`O2UM^V;(1X~NYfOk`NG<Yr8BHQ3auGd-TsbGNO%3NBe?y3lywR-}2hm*il zKy(z(Vk6TlxboXvv8j=JB&t;B<{vOXVa2iV=^+8Zsm(HpqiKoIX*oDmFK#&o!EFKN z>TxdRS=?KXK2WvK$qNjSU!F|?Dk4RU_fI3^fDsNNqG4qKH%~vpE6YoKxNPB)8)JLK z6zLT2;6ithb2961vC5jk)Zh#@4GLZ;3%FW#1HJR_(e<?po9^v4C6-+C8Dwzw@FixK znV15Vgn9^y>HcoT8@&tH%kQIO@;OFVMzB1)0a>F!idV29%OI0#2w*D7q{ZPDs0X$J zsC9hAoik17oOlAedj?)9fDK97b>D^zWtj9bKxSbEJ3Xl4=hz&B+|$@_<WLG$15R2j z?E!c<sgFv6B9hQEX5^)V5S6KLPC2peA#f-nUK1N)(zQ@^U;sh%V|{)Lq9ZV;_{k-? znOGShH9M6R2O*301uU=0@JlLUj5;(4{UB*{FN$Dh$c6fZ65Or-!bN_{?)XH5G0vc8 zkmb2WO#WDh*C!!4F&5E!9uJoWpqK!s&4W(U#p24EPHQB<NXJ%Pl&(sjV1(!r&~6^9 zd))HPOyje`q`0~$qau-3C7=pYvr@C?XWE%iP*o5_-8f)fDyVDxY{P%pA3>9tEbk%O QBLDyZ07*qoM6N<$g6<?}N&o-= literal 0 HcmV?d00001 diff --git a/VECTOAux/BusAuxiliaries/Resources/desktop.png b/VECTOAux/BusAuxiliaries/Resources/desktop.png new file mode 100644 index 0000000000000000000000000000000000000000..59c84dc6b7c229730f174dd03f2987f674fc6e20 GIT binary patch literal 642 zcmV-|0)737P)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV0006>Nkl<Zc-qC& zTS(Jk9L8~PgFw29pqqla@WKwXF`YIohm%s$wK6*(R$3_@n{&AgNz(;sU^7pcR-zDs zXkuye?{T<1&oZ5dbkjA2iV6z4`L;%BvkNb}=!J*(;^q1LZho(q*MC2cTKZU@x>gfS z#zBk&6AVpQnVwr@amj&w*~#pJgV8rOguxk_x+if1n+_DPS)#|=|2A6>7qdOIm>ow; z*d1xWM^(z6m@@p%R}m0jP0*DZ<jJ+f<ka)T_-YM^(sZD@*2&47E{^L2j%fvsWC?_3 z8VOMwQMlg1bX`Q`cB8!2M{Hgr_3f75Kp{%a3nDe0u3``2+CCJTenMP1l-W<P>ki8? z6OlKFQa?;|(I^-6t<*gm{{@KjgkN<{Nf%J4O~}<|S8<pi%@_x>#t7C~h$x&wdB@7B zl3C7`z2)*<!4r@tw<AjukfjX}kTHV4`Zdz5DFU;t$ZyUORct5P;NWb9len4{k_;wK zK$_5o=wc`0L^GmP3!?OCB-(joHx>ykSVDDgh0_)9iGA>q_`1)eR1A3nK2eqIimb&q zegNOZ3HGMV;+JhBD0dl!-pPs551gs`MBKwKTx$4AYUPM0kW~JhjOOo%3L&AomwoF1 z)nCBq8eq6z?k<0md80AycO!ZE`5R^x$kgiGrESfCHHMujJ&48P4YLYJrBVW~H@J&i zl=b)&^&*i-HjEp1{Is9Oj+eBX#xajiGdZ)sf_)jg!^ynu9TuyNo{>3PdMDkR_p|h8 c{`oWh09p_ty(6?-mH+?%07*qoM6N<$f(mUfGynhq literal 0 HcmV?d00001 diff --git a/VECTOAux/BusAuxiliaries/Resources/favorites.png b/VECTOAux/BusAuxiliaries/Resources/favorites.png new file mode 100644 index 0000000000000000000000000000000000000000..12d6fc99713d7cfe23191a759747818531d77731 GIT binary patch literal 850 zcmV-Y1FigtP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV0009SNkl<Zc-no_ zTTByH7{GC|ERF}wo`w&)EK#->QPXTO#5s(JGudKfF`03qCXndlVQvc9)Dlq{=;j6I z#<T`6Lt%i(u;PXaUQ$5Y(w5%16k2S7mR@LqmePXz@6ZQh)$Al+a?VM<-*>JF38MLQ zB~G8V*zN8(!iee+t|wB4+xIirnvea_cRYRY4YuZ7`tR<vTAFh56JBltAm}K^XE=^W z^aC~-Rzn%l$rhePA3cw$F*&_|@36iWm=52HMc7}1&r&*D4U_s8#yoPKO`DmC8i@w~ zp}R4Q{{^C<2Bs!%U}?&xv;73dC#9mgm6=FC;Xngj@-43cw8ccjaw4I>L~<RIfoghg zZ%3yn!O(h&kZc=)vMfUGYD^7Zz6y9XMMQ%2gvYNl>Hm|U_bOetwxW4hguYn-g~@pH z78118i23cW0v>Vt;jvmm{wgNC6^ywqV!F9mtU!jgQp$9-gvmcr8CPG%XOq);ePdZ1 zFrq3XG+N1o=ZZ)!$3J)uWBn$S^(C}R*8)E?GqN9V`4>!B1yHe$-pn_bnLeE(i2*KU z0psq=1e_Nbb(G;9ID@_}6UCkn&{S;@Kof-W2;W)7=<lhxN*7}LdLH`pIdw6>`S>7# zVHrNhZ+L8_j97j`SGxg&Di^b+09+z00&=g1rz;t+e2>1Yxp#DFZ+#pChT49>Xa5zC z^%O44afZ8!&{ls&+tKA18#6?b*oO5({xzoHzqAbfk16p7IjG3P-G35S?=gnVM{pPl z=%`xHL#YJw?T^4I5nGTDQ7lGxbO-8d8S%jEdw2E}Gh{l9T`y%o^F8Xybv!<?2y^{X z9QkkKJv|?~mS8@dit55A@xbh788jAR?>xXjM?O~Nx2UeBqd4>~E&JZ5??wi_vX$7S z3$P!YkE$SLI1aG2<kHu&i=O5jx|_4<zMqY<Vhy!9$uyo_jq2Lk7^pnI3jLO(h<am^ zx-~iRjpsoBy<P8gH*Q-k?tZtn=JWHaE9uJiOKDTZUnOTA+p{9+#bRws64ONTUd5us cxwGT{0I=j};`IYJq5uE@07*qoM6N<$g2Anq_y7O^ literal 0 HcmV?d00001 diff --git a/VECTOAux/BusAuxiliaries/Resources/file-history.png b/VECTOAux/BusAuxiliaries/Resources/file-history.png new file mode 100644 index 0000000000000000000000000000000000000000..8dbe20e0272030574f39f5c471d48a20744f7c7d GIT binary patch literal 757 zcmV<R0t)?!P)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV0008KNkl<Zc-pm- zT}+Zu7{|G)3omSa+_buJ-L%!Z?aHhcEpz466iv(NYE7GjGn<VvT$r}ya;Z5#rl~Ah z%t$7p6riPOkS_=b@#4!@@FGHfq^a{9o&cAdecsgBp3C3w{Lgcqhr#$CN9L5oHrXEM zJfg~<+#(947o|y7ZY%d`Q*&D$`v!Z*A7QEc<>@k0!4&6X4qR1aK$)xr21f``Y9>K3 zMu4zK>|t{_Nxy`9riCZ(TW_x2c3y!3c@DIwTQNPmfGX;rf!*svLs~tKh-3;SW)~M{ zY=IL5NB0&Hmz`yF9%L)dK$VJ*J^o;{A_9xuiH$Z2zaxzJEn$KlN#9aoQPF`-!37nw zl1-;W{tOe?L-`>(Fo)f~*^tBQ3q=IeE;qJN4s0YTELTs2ljxy>&wscn$R!iWl0_D< zed+LEoELKY{n$m%gxp?#RA3~hk=|-U1{;Npb|=!BZP3=$MKI2b;x(Kl)_Un&Hk1al z;kq*oE*Vcj>QFp%4~wu;t&2WkP_4zPa1TawMyv~`7&BQxA{+EEw(s1wD@)FFa@TX= znk^Yvx?{kUAAwHgb4=(dRNEnfh~UT4TkY_wuWun5KlX6Up0xf1Pv%qt9G4x0hS!bQ zWbz>Oq!H=K4T<OTJeprwMQb5IApm4^d7(ofux$2V-?`m!C&Y)GcYDi$ARK5k3~Njl zWOlgGr@$NvE`3F-2!Dt12Qvx$>Z<lFUs>BwS2z4#4=U{>9@TH$PSG<c@MRgTu49C8 z2tioj^#?&D7Oy0yq{RI+OoDFVfJ#Han{gfJtQ7W!qX!n3qafv`v4i$Que2X$WU^9! zJI>WLHN}#FfrT-H1$3kX3|0r2?Jh8oc6cEc)9G1R%)c(w9UgB#_a3jXw!U82-q|_P n*xb@zQCZ1KOgbC$PdE1)>J$2kMUY_>00000NkvXXu0mjfH-B3T literal 0 HcmV?d00001 diff --git a/VECTOAux/BusAuxiliaries/Resources/new_dir.png b/VECTOAux/BusAuxiliaries/Resources/new_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..1035fe49b199854810d1e6d33e91dfe338d3366f GIT binary patch literal 625 zcmV-%0*?KOP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV0006wNkl<Zc-rlf zT}YF06vmgt#G8n`HjIL>C@M(1Nur<<32A5w>I`FB)2!JN8^u^CRF)viT7GQlD9lKR z7JV>-V#Z9w*8FJbHrw1s+q-vrUHhu`?&)uWxQl|i?!dV?hx2<l=izWT|KpEg(o46; z-TghuuvxP}*&eEUo3H+M7#No0$CLXB-@U<aUeypwDW3)`m)(oA^$1Q@BV;-Oc=_17 zCs&jXG7nD1oJuWaRi;ArcF?n}2w1PdZ&AQEeF>hA7vM3SVd+T$;6Dd~6r>3R=k6%t z9u>m#HxT?pAagUmjGu*TR0!w08aUooU~aey)bwd+jXY%T%o3yt*x%o*N(MBDEZim{ z?JR9+fq&{E>zk0kJyyrMMr+|V)UrkcA4kUy;rOEiae}Q|5qLe=v>%KX2~Rho&Q37) z<xMEEiT6Vz=<#~Qi~^Y62q3UmpnTv6L$I|g0_wKv9EAGu-P?nNyNiu}Rw86;V*@jC zgr{U|x1NV$eIYBF;GreZz+PvhDXERmi04aV1mC=DWO4u?XQZfJ#NBrhaddzoMn)}H zaLZ5*k*gB&m>9B94J33Kgj5MiJ%vk#9{wfJ)ggX9@}kv2Sv654bpZPq_^JlzPMAl| z<CLTTeAzBECMr`!L-~=64V=EroQyt#Ze8ssmt^)*lgs56?bw#vP*#$!R5TrXsZ$GP zUg?A(zONYjRC$YJChPCtat$Z%;IrM>SeH$cYW=@{_a>5CRyTeEg)&%nu0G8K00000 LNkvXXu0mjf^Clv6 literal 0 HcmV?d00001 diff --git a/VECTOAux/BusAuxiliaries/Util/FilePathUtils.cs b/VECTOAux/BusAuxiliaries/Util/FilePathUtils.cs index 4cbe6fe130..5a5db65d9c 100644 --- a/VECTOAux/BusAuxiliaries/Util/FilePathUtils.cs +++ b/VECTOAux/BusAuxiliaries/Util/FilePathUtils.cs @@ -1,148 +1,158 @@ using System; using System.IO; using System.Linq; -using Microsoft.VisualBasic; -public class FilePathUtils -{ - - public static string Left(string str, int length) +namespace TUGraz.VectoCore.BusAuxiliaries.Util { + public class FilePathUtils { - return str.Substring(0, Math.Min(length, str.Length)); - } - public static string Right(string value, int length) - { - if (string.IsNullOrEmpty(value)) return string.Empty; + public static string fPATH(string path) + { + if (string.IsNullOrWhiteSpace(path) || path.Length < 3 || path.Substring(1, 2) != @":\") { + return ""; + } - return value.Length <= length ? value : value.Substring(value.Length - length); - } + return Path.GetDirectoryName(path); + } - public static bool ValidateFilePath(string filePath, string expectedExtension, ref string message) - { - char[] illegalFileNameCharacters = new[] { '<', '>', ':', '"', '/', '\\', '|', '?', '*', '~' }; - string detectedExtention = fileExtentionOnly(filePath); - string pathOnly = filePathOnly(filePath); - string fileNameOnlyWithExtension = fileNameOnly(filePath, true); - string fileNameOnlyNoExtension = fileNameOnly(filePath, false); - - // Is this filePath empty - if (filePath.Trim().Length == 0 || Right(filePath, 1) == @"\") { - message = "A filename cannot be empty"; - return false; + public static string Left(string str, int length) + { + return str.Substring(0, Math.Min(length, str.Length)); } + public static string Right(string value, int length) + { + if (string.IsNullOrEmpty(value)) return string.Empty; - // Extension Expected, but not match - if (expectedExtension.Trim().Length > 0) { - if (string.Compare(expectedExtension, detectedExtention, true) != 0) { - message = string.Format("The file extension type does not match the expected type of {0}", expectedExtension); - return false; - } + return value.Length <= length ? value : value.Substring(value.Length - length); } - // Extension Not Expected, but was supplied - if (expectedExtension.Trim().Length > 0) { - if (detectedExtention.Length == 0) { - message = string.Format("No Extension was supplied, but an extension of {0}, this is not required", detectedExtention); + public static bool ValidateFilePath(string filePath, string expectedExtension, ref string message) + { + var illegalFileNameCharacters = new[] { '<', '>', ':', '"', '/', '\\', '|', '?', '*', '~' }; + var detectedExtention = fileExtentionOnly(filePath); + var pathOnly = filePathOnly(filePath); + var fileNameOnlyWithExtension = fileNameOnly(filePath, true); + var fileNameOnlyNoExtension = fileNameOnly(filePath, false); + + // Is this filePath empty + if (filePath.Trim().Length == 0 || Right(filePath, 1) == @"\") { + message = "A filename cannot be empty"; return false; } - } - // Illegal characters - if (!fileNameLegal(fileNameOnlyWithExtension)) { - message = string.Format("The filenames have one or more illegal characters"); - return false; - } + // Extension Expected, but not match + if (expectedExtension.Trim().Length > 0) { + if (string.Compare(expectedExtension, detectedExtention, true) != 0) { + message = string.Format("The file extension type does not match the expected type of {0}", expectedExtension); + return false; + } + } + // Extension Not Expected, but was supplied + if (expectedExtension.Trim().Length > 0) { + if (detectedExtention.Length == 0) { + message = string.Format("No Extension was supplied, but an extension of {0}, this is not required", detectedExtention); + return false; + } + } - message = "OK"; - return true; - } + // Illegal characters + if (!fileNameLegal(fileNameOnlyWithExtension)) { + message = string.Format("The filenames have one or more illegal characters"); + return false; + } - public static bool fileNameLegal(string fileName) - { - char[] illegalFileNameCharacters = new[] { '<', '>', ':', '"', '/', '\\', '|', '?', '*', '~' }; + message = "OK"; + return true; + } - // Illegal characters - foreach (char ch in illegalFileNameCharacters) { - if (fileName.Contains(ch)) - return false; + + public static bool fileNameLegal(string fileName) + { + var illegalFileNameCharacters = new[] { '<', '>', ':', '"', '/', '\\', '|', '?', '*', '~' }; + + + // Illegal characters + foreach (var ch in illegalFileNameCharacters) { + if (fileName.Contains(ch)) + return false; + } + return true; } - return true; - } - public static string ResolveFilePath(string vectoPath, string filename) - { + public static string ResolveFilePath(string vectoPath, string filename) + { - // No Vecto Path supplied - if (vectoPath == "") - return filename; + // No Vecto Path supplied + if (vectoPath == "") + return filename; - // This is not relative - if (filename.Contains(@":\")) + // This is not relative + if (filename.Contains(@":\")) - // Filepath is already absolute - return filename; - else - return Path.Combine(vectoPath, filename);// vectoPath & filename - } + // Filepath is already absolute + return filename; + else + return Path.Combine(vectoPath, filename);// vectoPath & filename + } - /// <summary> - /// ''' File name without the path "C:\temp\TEST.txt" >> "TEST.txt" oder "TEST" - /// ''' </summary> - /// ''' <param name="filePath"></param> - /// ''' <param name="WithExtention"></param> - /// ''' <returns>Return file portion of the path, with or without the extension</returns> - /// ''' <remarks></remarks> - public static string fileNameOnly(string filePath, bool WithExtention) - { - int x; - x = filePath.LastIndexOf(@"\") + 1; - filePath = Right(filePath, filePath.Length - x); - if (!WithExtention) { - x = filePath.LastIndexOf("."); - if (x > 0) - filePath = Left(filePath, x); + /// <summary> + /// ''' File name without the path "C:\temp\TEST.txt" >> "TEST.txt" oder "TEST" + /// ''' </summary> + /// ''' <param name="filePath"></param> + /// ''' <param name="WithExtention"></param> + /// ''' <returns>Return file portion of the path, with or without the extension</returns> + /// ''' <remarks></remarks> + public static string fileNameOnly(string filePath, bool WithExtention) + { + int x; + x = filePath.LastIndexOf(@"\") + 1; + filePath = Right(filePath, filePath.Length - x); + if (!WithExtention) { + x = filePath.LastIndexOf("."); + if (x > 0) + filePath = Left(filePath, x); + } + return filePath; } - return filePath; - } - /// <summary> - /// ''' Extension alone "C:\temp\TEST.txt" >> ".txt" - /// ''' </summary> - /// ''' <param name="filePath"></param> - /// ''' <returns>Extension alone Including the dot IE .EXT</returns> - /// ''' <remarks></remarks> - public static string fileExtentionOnly(string filePath) - { - int x; - x = filePath.LastIndexOf("."); - if (x == -1) - return ""; - else - return Right(filePath, filePath.Length - x); - } + /// <summary> + /// ''' Extension alone "C:\temp\TEST.txt" >> ".txt" + /// ''' </summary> + /// ''' <param name="filePath"></param> + /// ''' <returns>Extension alone Including the dot IE .EXT</returns> + /// ''' <remarks></remarks> + public static string fileExtentionOnly(string filePath) + { + int x; + x = filePath.LastIndexOf("."); + if (x == -1) + return ""; + else + return Right(filePath, filePath.Length - x); + } - /// <summary> - /// ''' File Path alone "C:\temp\TEST.txt" >> "C:\temp\" - /// ''' "TEST.txt" >> "" - /// ''' </summary> - /// ''' <param name="filePath"></param> - /// ''' <returns>Filepath without the extension</returns> - /// ''' <remarks></remarks> - public static string filePathOnly(string filePath) - { - int x; - if (filePath == null || filePath.Length < 3 || filePath.Substring(1, 2) != @":\") - return ""; - x = filePath.LastIndexOf(@"\"); - return Left(filePath, x + 1); + /// <summary> + /// ''' File Path alone "C:\temp\TEST.txt" >> "C:\temp\" + /// ''' "TEST.txt" >> "" + /// ''' </summary> + /// ''' <param name="filePath"></param> + /// ''' <returns>Filepath without the extension</returns> + /// ''' <remarks></remarks> + public static string filePathOnly(string filePath) + { + int x; + if (filePath == null || filePath.Length < 3 || filePath.Substring(1, 2) != @":\") + return ""; + x = filePath.LastIndexOf(@"\"); + return Left(filePath, x + 1); + } } } diff --git a/VECTOAux/BusAuxiliaries/packages.config b/VECTOAux/BusAuxiliaries/packages.config new file mode 100644 index 0000000000..5abf7ccb21 --- /dev/null +++ b/VECTOAux/BusAuxiliaries/packages.config @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" /> + <package id="ValueInjecter" version="3.1.1.5" targetFramework="net45" /> +</packages> \ No newline at end of file -- GitLab