/// <summary> /// Writes HD time series data object to the data repository /// </summary> public void Finish() { //check to see if the database path is overridden var db = conn != null ? RepositoryFactory.Instance.Get <IRepositoryManager>(DatabaseTypes.SQLite, conn) : RepositoryFactory.Instance.Get <IRepositoryManager>(); //write each series to the database foreach (Series series in serieses.Values) { //-- get the theme Theme theme = series.ThemeList[0]; //-- need to adjust the series values back by one time step Dictionary <DateTime, double> new_data = new Dictionary <DateTime, double>(); // determine the timestep using the first two values (assumes uniform timstep) double timestep = _timestep[theme.Name][1].Subtract(_timestep[theme.Name][0]).TotalSeconds; // change the data value times back 1 time step // this is necessary b/c each model advances it's time before dbwriter gets the data for (int i = 0; i <= series.ValueCount - 1; i++) { // subtract 1 for the timestep advancement // subtract 1 for the 1-timestep delay that OpenMI creates series.DataValueList[i].DateTimeUTC = series.DataValueList[i].DateTimeUTC.AddSeconds(-2 * timestep); series.DataValueList[i].LocalDateTime = series.DataValueList[i].LocalDateTime.AddSeconds(-2 * timestep); // remove data value if less than start if (series.DataValueList[i].LocalDateTime < CalendarConverter.ModifiedJulian2Gregorian(_start).AddSeconds(-timestep)) { //series.DataValueList[i].Value = series.GetNoDataValue(); series.DataValueList.RemoveAt(i); // This change was necessary b/c series.GetNoDataValue() was removed } } //-- save data series //db.SaveSeriesAsCopy(series, theme); db.SaveSeries(series, theme, OverwriteOptions.Copy); //This change was necessary b/c db.SaveSeriesAsCopy() was removed } //clear all values in the buffer _smartBuffer.Clear(this.TimeHorizon); }
public void Finish() { //clear all values in the buffer _smartBuffer.Clear(this.TimeHorizon); }