Beispiel #1
0
 public Archive(RrdDb parentDb, ArcDef arcDef)
 {
    bool shouldInitialize = arcDef != null;
    this.parentDb = parentDb;
    consolFun = new RrdString(this, true);  // constant, may be cached
    xff = new RrdDouble(this);
    steps = new RrdInt(this, true);            // constant, may be cached
    rows = new RrdInt(this, true);            // constant, may be cached
    if (shouldInitialize)
    {
       consolFun.set(arcDef.getConsolFun().Name);
       xff.set(arcDef.getXff());
       steps.set(arcDef.getSteps());
       rows.set(arcDef.getRows());
    }
    int n = parentDb.getHeader().getDsCount();
    states = new ArcState[n];
    robins = new Robin[n];
    for (int i = 0; i < n; i++)
    {
       states[i] = new ArcState(this, shouldInitialize);
       int numRows = rows.get();
       robins[i] = new Robin(this, numRows, shouldInitialize);
    }
 }
Beispiel #2
0
        public Archive(RrdDb parentDb, ArcDef arcDef)
        {
            bool shouldInitialize = arcDef != null;

            this.parentDb = parentDb;
            consolFun     = new RrdString(this, true); // constant, may be cached
            xff           = new RrdDouble(this);
            steps         = new RrdInt(this, true);    // constant, may be cached
            rows          = new RrdInt(this, true);    // constant, may be cached
            if (shouldInitialize)
            {
                consolFun.set(arcDef.getConsolFun().Name);
                xff.set(arcDef.getXff());
                steps.set(arcDef.getSteps());
                rows.set(arcDef.getRows());
            }
            int n = parentDb.getHeader().getDsCount();

            states = new ArcState[n];
            robins = new Robin[n];
            for (int i = 0; i < n; i++)
            {
                states[i] = new ArcState(this, shouldInitialize);
                int numRows = rows.get();
                robins[i] = new Robin(this, numRows, shouldInitialize);
            }
        }
Beispiel #3
0
 public bool ContainsArchive(ArcDef otherArcDef)
 {
     foreach (ArcDef arcDef in arcDefs)
     {
         if (arcDef.getConsolFun().CSType == otherArcDef.getConsolFun().CSType &&
             arcDef.getSteps() == otherArcDef.getSteps())
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #4
0
 public bool ContainsArchive(ArcDef otherArcDef)
 {
    foreach (ArcDef arcDef in arcDefs)
    {
       if (arcDef.getConsolFun().CSType == otherArcDef.getConsolFun().CSType 
          && arcDef.getSteps() == otherArcDef.getSteps())
          return true;
    }
    return false;
 }
Beispiel #5
0
      public FetchData GetArchiveData(DatabaseData databaseData, string dataSourceName, ArcDef archiveDefinition)
      {
         RrdDb database = null;
         try
         {
            database = new RrdDb(databaseData.Definition.getPath(), true);
            int datasourceIndex = database.getDsIndex(dataSourceName);
            Archive archive = database.getArchive(new ConsolFun(archiveDefinition.getConsolFun().Name), archiveDefinition.Steps);
            Robin robin = archive.getRobin(datasourceIndex);
            double[] values = robin.getValues();
            DateTime archiveStartTime = archive.getStartDateTime();
            TimeSpan tick = new TimeSpan(archive.getArcStep() * TimeSpan.TicksPerSecond);

            FetchData fetchedData = new FetchData(archive.getArcStep(), archive.getEndTime(), new string[] { dataSourceName });
            long[] timestamps = new long[archive.getRows()];
            long offset = archive.getStartTime();
            for (var i = 0; i < archive.getRows(); i++)
            {
               timestamps[i] = offset;
               offset += archive.getArcStep();
            }
            fetchedData.setTimestamps(timestamps);
            double[][] value = new double[1][];
            value[0] = values;
            fetchedData.setValues(value);
            return fetchedData;

         }
         finally
         {
            if (database != null)
               database.close();
         }
      }
Beispiel #6
0
 public void UpdateArchive(ArcDef updatedArcDef)
 {
    var archDef = EditingDatabaseData.Definition.findArchive(updatedArcDef.getConsolFun(), updatedArcDef.getSteps());
    archDef.setRows(updatedArcDef.getRows());
    DatabaseDirty = true;
 }