DataCollector:
Filter:
SenseWorld/Classes (extension) | Logging

DataCollector
ExtensionExtension

collects Data with timestamps

Description

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

Class Methods

.new

Creates a new data collector.

Arguments:

name

A name for the collector.

collection

Optional argument to provide another DataCollector which is then added to this new one.

Returns:

a DataCollector

.fromFile

Load a stored DataCollector from file

Arguments:

path

The full path of the file to load from.

Returns:

a DataCollector

.makeBackupFolder

Creates the backup folder for storing DataCollectors to.

.initialized

Indicates whether or not the backup folder has been created.

.folder

The path to the backupfolder.

Returns:

a String

.makeList

Convenience method to create a SortedList sorted by date

Returns:

a SortedList

Instance Methods

.addData

Add data to the collection.

Arguments:

data

The data to be added.

date

The time stamp of the data. If non is given, one is created.

overwrite

Whether or not to overwrite a previous entry with the same datestamp. Default is true.

Returns:

the date time stamp (so it can be used for adding metadata)

.addMetaData

Add metadata to the collection. This can be for example higher level data or a comment.

Arguments:

mdata

The metadata to add.

date

The time stamp.

.at

Access an trace in the collection.

Arguments:

index

The index of the trace to access.

Returns:

an Event of the trace requested.

.getLast

Get the last N entries from the collection

Arguments:

howmany

The number of entries to get.

Returns:

a SortedList of entries.

.addTrace

Adds a trace of data to the collection. Called by addData or addMetaData.

Arguments:

trace

The trace to add.

overwrite

Whether or not to overwrite an existing trace.

Returns:

the date stamp of the trace.

Backup functionality

.backup

Create a backup in a file with an autogenerated filename, consisting of the backup folder, the name of the DataCollector and a timestamp.

Returns:

a String with the filename.

.recover

Recover the last saved backup with the same name.

.printAll

Print all data in the collector.

.lastBackupPath

Finds the most recently saved backup.

Returns:

a String with the filename.

.saveTo

Save the DataCollector to file.

Arguments:

path

The full path to save to.

Returns:

a File to which was saved.

.collection

The SortedList of the data collected.

Returns:

a SortedList

.name

The name of the DataCollector

Returns:

a String

Examples