Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Select Git revision
  • e8b2bb6b347e0218f82da23367b28e34c0f2f2ff
  • stable default
  • feat-fchv-bus
  • fix-h2-ice-bus
  • powertrains-multiple-axles
  • amdm3/develop
  • issue-1039
  • amdm3/main
  • test/nuget_publish
  • IEPC-experiments
  • amdm2/main
  • amdm2/develop
  • aptngearbox-not-auto
  • playground
  • official/main
  • official/develop
  • issue-templates
  • pdf-reports
  • HEV-timeruns-dev
  • timerun-empower-hybrids
  • timerun-pwheel-hybrids
  • Release/v5.0.3
  • Release/v5.0.1
  • Release/5.0.0-RC
  • Nuget/v0.11.4-DEV
  • Release/v0.11.4-DEV
  • Release/4.3.4-DEV
  • Release/4.3.3
  • Release/4.3.2-RC
  • Release/v4.3.0-DEV
  • Release/4.2.7
  • XMLConverterTool/4.2.6.0
  • Release/4.2.6-RC
  • Release/v4.2.5
  • Release/v4.2.3
  • Release/v4.2.2.3539-RC
  • Release/v4.2.1.3469
  • Release/v0.11.2.3456-DEV
  • Release/v4.2.0.3448-RC
  • Release/v4.1.3.3415
  • Release/v4.1.1.3413
41 results

TestModalDataWriter.cs

Blame
  • Forked from VECTO / VECTO Sim
    11498 commits behind the upstream repository.
    user avatar
    Michael KRISPER authored
    e8b2bb6b
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    TestModalDataWriter.cs 1.57 KiB
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Linq;
    using TUGraz.VectoCore.Models.Simulation.Data;
    using TUGraz.VectoCore.Utils;
    
    namespace TUGraz.VectoCore.Tests.Utils
    {
    	/// <summary>
    	///     Fake Data Writer Class for Tests.
    	/// </summary>
    	internal class TestModalDataWriter : IModalDataWriter
    	{
    		public TestModalDataWriter()
    		{
    			Data = new ModalResults();
    			CurrentRow = Data.NewRow();
    		}
    
    		public ModalResults Data { get; set; }
    		public DataRow CurrentRow { get; set; }
    
    		public bool HasTorqueConverter { get; set; }
    
    		public void CommitSimulationStep()
    		{
    			Data.Rows.Add(CurrentRow);
    			CurrentRow = Data.NewRow();
    		}
    
    		public void Finish() {}
    
    		public object Compute(string expression, string filter)
    		{
    			return Data.Compute(expression, filter);
    		}
    
    		public IEnumerable<T> GetValues<T>(ModalResultField key)
    		{
    			return Data.Rows.Cast<DataRow>().Select(x => x.Field<T>((int)key));
    		}
    
    		public Dictionary<string, Watt> Auxiliaries { get; set; }
    
    		public object this[ModalResultField key]
    		{
    			get { return CurrentRow[key.GetName()]; }
    			set { CurrentRow[key.GetName()] = value; }
    		}
    
    		public void CommitSimulationStep(TimeSpan absTime, TimeSpan simulationInterval)
    		{
    			CurrentRow[ModalResultField.time.GetName()] =
    				(absTime + TimeSpan.FromTicks(simulationInterval.Ticks / 2)).TotalSeconds;
    			CurrentRow[ModalResultField.simulationInterval.GetName()] = simulationInterval.TotalSeconds;
    			CommitSimulationStep();
    		}
    
    		public double GetDouble(ModalResultField key)
    		{
    			return CurrentRow.Field<double>(key.GetName());
    		}
    	}
    }