/// <summary> /// This is called to load data from an ODCache /// </summary> /// <param name="o"></param> /// <param name="d"></param> internal void Set(int o, int d, ODCache cache) { this.LoadingO = o; if (this.Data[o] == null) { Data[o] = new float[HighestZone][]; HasData[o] = new bool[HighestZone]; for (int k = HighestZone - 1; k >= 0; k--) { Data[o][k] = new float[AmmountOfData]; } for (int k = 0; k < HighestZone; k++) { HasData[o][k] = false; } } HasData[o][d] = true; if (this.Data[o][d] == null) { this.Data[o][d] = new float[this.AmmountOfData]; } int entry = 0; for (int time = 0; time < this.Times; time++) { for (int type = 0; type < this.Types; type++) { this.Data[o][d][entry] = cache[o, d, time, type]; entry++; } } }
public void LoadFile(string odcFile) { ODCache cache = new ODCache(odcFile); this.FilesLoaded = new CacheGenerationInfo(cache.Times, cache.Types, cache.HighestZone, 5); this.Times = cache.Times; this.Types = cache.Types; this.AmmountOfData = this.Types * this.Times; this.HighestZone = cache.HighestZone; this.Data = new float[this.HighestZone][][]; this.HasData = new bool[this.HighestZone][]; this.Gap = 5; cache.DumpToCreator(this); cache.Release(); cache = null; }
protected virtual void Dispose(bool all) { if ( this.Data != null ) { this.Data.Dispose(); this.Data = null; } }
public void UnloadData() { if ( Data != null ) { this.Data.Release(); this.Data = null; this.StoredData = null; } }
public void LoadData() { if ( this.IterativeRoot != null ) { this.AlreadyLoaded = this.IterativeRoot.CurrentIteration > 0; } var cacheFile = GetFullPath( this.AlreadyLoaded ? this.UpdatedODC : this.ODC ); if ( ( this.AlreadyLoaded & this.RebuildDataOnSuccessiveLoads ) || !File.Exists( cacheFile ) ) { Generate( cacheFile ); } Data = new ODCache( cacheFile ); var loadedData = Data.StoreAll(); this.StoredData = ProcessLoadedData( loadedData, Data.Types, Data.Times ); Data.Release(); Data = null; this.AlreadyLoaded = true; }
public void LoadData() { if ( this.Data != null ) { this.Data.Release(); } var cache = GetFullPath( this.ODC ); if ( ( this.Regenerate && AlreadyLoaded ) || !File.Exists( cache ) ) { this.Generate(); } this.Data = new ODCache( cache ); this.StoredData = this.Data.StoreAll(); this.AlreadyLoaded = true; }
public void LoadData() { if ( this.Data != null ) { this.Data.Release(); } if ( this.IterativeRoot != null ) { this.AlreadyLoaded = this.Regenerate | ( this.IterativeRoot.CurrentIteration > 0 ); } var cache = GetFullPath( this.AlreadyLoaded ? this.UpdatedODC : this.ODC ); if ( ( this.Regenerate && AlreadyLoaded ) || !File.Exists( cache ) ) { this.Generate(); } this.Data = new ODCache( cache, UseCache ); if ( !UseCache ) { var loadedData = this.Data.StoreAll(); this.Data.Release(); this.StoredData = this.ProcessLoadedData( loadedData, Data.Times, Data.Types ); this.Data = null; } this.AlreadyLoaded = true; }
public void LoadData() { if ( Data == null ) { var cacheFile = GetFullPath( this.ODC ); if ( ( this.AlreadyLoaded & this.RebuildDataOnSuccessiveLoads ) || !File.Exists( cacheFile ) ) { // create the data if it doesn't already exist ODMatrixWriter<IZone> creator = new ODMatrixWriter<IZone>( this.Root.ZoneSystem.ZoneArray, 2, 3 ); creator.Year = this.Year; creator.AdditionalDescription = "Automatically Generated"; creator.StartTimesHeader = "6:00,15:30,Other"; creator.EndTimesHeader = "9:00AM,18:30,Other"; creator.TypeHeader = "TravelTime,Cost"; creator.Modes = "Auto"; LoadTimes( creator, this.AMTravelTimeOriginalData, 0 ); LoadTimes( creator, this.PMTravelTimeOriginalData, 1 ); LoadTimes( creator, this.OffpeakTravelTimeOriginalData, 2 ); LoadCosts( creator, this.AMTravelCostOriginalData, 0 ); LoadCosts( creator, this.PMTravelCostOriginalData, 1 ); LoadCosts( creator, this.OffpeakTravelCostOriginalData, 2 ); creator.Save( cacheFile, false ); } Data = new ODCache( cacheFile ); this.StoredData = Data.StoreAll(); } this.AlreadyLoaded = true; }
public void LoadData() { if ( Data == null ) { var cacheFile = GetFullPath( this.ODC ); if ( ( this.AlreadyLoaded & this.RebuildDataOnSuccessiveLoads ) || !File.Exists( cacheFile ) ) { // create the data if it doesn't already exist ODMatrixWriter<IZone> creator = new ODMatrixWriter<IZone>( this.Root.ZoneSystem.ZoneArray, 2, 3 ); creator.Year = this.Year; creator.AdditionalDescription = "Automatically Generated"; creator.StartTimesHeader = "Six,FiveThirty,Other"; creator.EndTimesHeader = "Nine,SixThirty,Other"; creator.TypeHeader = "TravelTime,Cost"; creator.Modes = String.IsNullOrWhiteSpace( this.NetworkType ) ? "Auto" : this.NetworkType; creator.LoadEMME2( FailIfNotExist( this.AMTravelTimeOriginalData ), 0, (int)AutoDataTypes.TravelTime ); creator.LoadEMME2( FailIfNotExist( this.AMTravelCostOriginalData ), 0, (int)AutoDataTypes.CarCost ); creator.LoadEMME2( FailIfNotExist( this.PMTravelTimeOriginalData ), 1, (int)AutoDataTypes.TravelTime ); creator.LoadEMME2( FailIfNotExist( this.PMTravelCostOriginalData ), 1, (int)AutoDataTypes.CarCost ); creator.LoadEMME2( FailIfNotExist( this.OffpeakTravelTimeOriginalData ), 2, (int)AutoDataTypes.TravelTime ); creator.LoadEMME2( FailIfNotExist( this.OffpeakTravelCostOriginalData ), 2, (int)AutoDataTypes.CarCost ); creator.Save( cacheFile, false ); } Data = new ODCache( cacheFile ); this.StoredData = Data.StoreAll(); } this.AlreadyLoaded = true; }
/// <summary> /// This is called to load data from an ODCache /// </summary> /// <param name="o"></param> /// <param name="d"></param> internal void Set(int o, int d, ODCache cache) { this.LoadingO = o; if ( this.Data[o] == null ) { Data[o] = new float[HighestZone][]; HasData[o] = new bool[HighestZone]; for ( int k = HighestZone - 1; k >= 0; k-- ) { Data[o][k] = new float[AmmountOfData]; } for ( int k = 0; k < HighestZone; k++ ) HasData[o][k] = false; } HasData[o][d] = true; if ( this.Data[o][d] == null ) { this.Data[o][d] = new float[this.AmmountOfData]; } int entry = 0; for ( int time = 0; time < this.Times; time++ ) { for ( int type = 0; type < this.Types; type++ ) { this.Data[o][d][entry] = cache[o, d, time, type]; entry++; } } }
public void LoadFile(string odcFile) { ODCache cache = new ODCache( odcFile ); this.FilesLoaded = new CacheGenerationInfo( cache.Times, cache.Types, cache.HighestZone, 5 ); this.Times = cache.Times; this.Types = cache.Types; this.AmmountOfData = this.Types * this.Times; this.HighestZone = cache.HighestZone; this.Data = new float[this.HighestZone][][]; this.HasData = new bool[this.HighestZone][]; this.Gap = 5; cache.DumpToCreator( this ); cache.Release(); cache = null; }
private void ValidateData(int[] zones, float[][][] data, string odcFileName) { ODCache odc = new ODCache( odcFileName ); var storedData = odc.StoreAll().GetFlatData(); odc.Release(); if ( storedData.Length != data.Length ) { Assert.Fail( "The stored data is not the same size as the given data! " + storedData.Length + " : " + data.Length ); } for ( int i = 0; i < storedData.Length; i++ ) { if ( ( storedData[i] == null ) != ( data[i] == null ) ) { Assert.Fail( "The data differs at zone " + zones[i] ); } if ( storedData[i] == null ) continue; if ( storedData[i].Length != data[i].Length ) { Assert.Fail( "The stored data is not the same size as the given data for zone " + zones[i] + "! " + storedData[i].Length + " : " + data[i].Length ); } for ( int j = 0; j < storedData[i].Length; j++ ) { if ( ( storedData[i][j] == null ) != ( data[i][j] == null ) ) { Assert.Fail( "The data differs at zone " + zones[i] + " in zone " + zones[j] ); } for ( int k = 0; k < storedData[i][j].Length; k++ ) { if ( storedData[i][j][k] != data[i][j][k] ) { if ( Math.Round( storedData[i][j][k], 3 ) != Math.Round( data[i][j][k], 3 ) ) { Assert.Fail( "The data differs at index " + i + ":" + j + ":" + k + " (" + storedData[i][j][k] + " / " + data[i][j][k] + ")" ); } } } } } }
private void OpenMenuItem_Click(object sender, RoutedEventArgs e) { var open = new Microsoft.Win32.OpenFileDialog(); open.Filter = "OD Cache (.odc)|*.odc|Zone File Cache (.zfc)|.zfc"; open.FilterIndex = 0; open.CheckPathExists = true; open.CheckFileExists = true; open.AddExtension = true; open.DereferenceLinks = true; if ( open.ShowDialog() == true ) { var fileName = open.FileName; var ext = System.IO.Path.GetExtension( fileName ).ToLowerInvariant(); switch ( ext ) { case ".zfc": { this.ODControlGrid.IsEnabled = false; Task t = new Task( new Action( delegate() { this.PresentationGrid.DataContext = null; try { ODCache odc = new ODCache( fileName ); var allData = odc.StoreAll(); //foreach(var index in odc.Release(); } catch { MessageBox.Show( this, "Unable to load the file", "Invalid Format", MessageBoxButton.OK, MessageBoxImage.Error ); } } ) ); t.Start(); } break; case ".odc": { this.ODControlGrid.IsEnabled = true; Task t = new Task( new Action( delegate() { try { ODCache odc = new ODCache( fileName ); var allData = odc.StoreAll().GetFlatData(); this.Dispatcher.BeginInvoke( new Action( delegate() { try { this.PresentationGrid.Items.Clear(); for ( int i = 0; i < 1; i++ ) { for ( int j = 0; j < 1; j++ ) { this.PresentationGrid.ItemsSource = allData[i][j]; } } } catch { MessageBox.Show( this, "Unable to display the data", "Loading Fail", MessageBoxButton.OK, MessageBoxImage.Error ); } } ) ); odc.Release(); } catch { MessageBox.Show( this, "Unable to load the file", "Invalid Format", MessageBoxButton.OK, MessageBoxImage.Error ); } } ) ); t.Start(); } break; default: MessageBox.Show( this, "Unable to load the extension " + ext + ".", "Invalid Format", MessageBoxButton.OK, MessageBoxImage.Error ); break; } } }