Пример #1
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();
                }
            }
        }
Пример #2
0
 public void setArcXff(String sourcePath, String consolFun, int steps, double newXff)
 {
     RrdDb rrd = new RrdDb(sourcePath);
     Archive arc = rrd.getArchive(consolFun, steps);
     arc.setXff(newXff);
     rrd.close();
 }