DataCollector

collects Data with timestamps

Inherits from:: Object

DataCollector collects data with timestamps, as it is added to the collection. It provides backup mechanism to recover from stored data. The data can be used for realtime or offline analysis in the same or in a later session. inspired by MemoryRecorder developed by Alberto de Campo and Marije Baalman for the Institute of Predictive Sonobotanics (www.sonobotanics.org)

Creation / Class Methods

*new(name,collection)
Creates a new data collector with the name. collection is an optional argument and can be from another DataCollector, the elements of which are then added to the new one.
*fromFile(path)
Load a stored DataCollector from file
*makeBackupFolder
creates the backup folder in the working directory for stored DataCollectors. This is called from *initClass.
*folder_
Set the folder which will be used for backups
*folder
The folder which will be used for backups.
*makeList
create a SortedList sorted by date

Accessing Instance and Class Variables

addData(data,date,overwrite)
Add data to the collection
data
The data to be added.
date
The time stamp of the data. If non is given, one is created.
overwrite
Overwrite a previous entry with the same datestamp. Default is true.
addMetaData(mdata,date)
Add metadata to the collection. This can be for example higher level data or a comment.
date
The time stamp
mdata
The metadata to add
getLast(howmany)
Get the last howmany entries from the collection
backup
Create a backup in the backup folder.
recover
Recover the last saved backup with the same name.
printAll
Print all data in the collector
at(index)
Access an trace in the collection by index
name
Name of the collector.
name_
Set the name for this DataCollector
collection
A SortedList sorted by date
collection_
Set the SortedList
addTrace(trace,overwrite)
Adds a trace of data to the collection. Called by addData or addMetaData
storeArgs
This is what is stored in the file.
saveTo(path)
Save the DataCollector to file.
lastBackupPath
Finds the most recently saved backup.

Example 1

// create a new DataCollector:
d = DataCollector.new( "test" );
d.collection; // empty sorted list

d.addData( [1,2,3] );
d.collection // now we have one entry with data in it and a timestamp
   
d.addMetaData( [5,6,7], d.collection.first[\date] ); // add some metadata to it
d.collection

d.addData( [3,4.5,6] );
d.collection

// create a backup:
d.backup

// create a new collector:
e = DataCollector.new( "test" );

// recover from the backup
e.recover

// we have the same data again:
e.collection;


This helpfile was created with the class HelpFile2