DataRun

DataRun

new DataRun()

Source:
Defines a class to track the configuration of sensors for Devices.

Methods

(async, static) compareModules(newSchema, oldSchema) → {Object}

Source:
Compares the schemas of two separate deviceData objects. 1. Fills an array of strings for each module-key pair 2. Compares the arrays for equality.
Parameters:
Name Type Description
newSchema Array The data contents array of the deviceData object which contains modules and key-value pairs for data points.
oldSchema Array The data contents array of an old deviceData object which contains modules and key-value pairs for data points.
Returns:
- True if they have the same schemas (every module-key pair is identical)
Type
Object

(async, static) getSchema(dataRun, device_id) → {Object}

Source:
Declares and fills an array with strings for each module-key pair for a single module. 1. Counts the number of module-key pairs. 2. Initializes and fills the array with the module-key pairs.
Parameters:
Name Type Description
dataRun number The index corresponding to the module within the schema.
device_id string The id of the device.
Returns:
- Returns the data contents array for a single document from the given dataRun.
Type
Object

(async, static) modulekey_Array(j, schema) → {Object}

Source:
Declares and fills an array with strings for each module-key pair for a single module. 1. Counts the number of module-key pairs. 2. Initializes and fills the array with the module-key pairs.
Parameters:
Name Type Description
j number The index corresponding to the module within the schema.
schema Array The data contents array of a deviceData object which contains modules and key-value pairs for data points.
Returns:
- Returns the array of strings
Type
Object

(async) getDataRun(newSchema, device_id) → {DataRun}

Source:
Determines the data_run for a new deviceData object based on the modules in its contents array. 1. For the new deviceData object, fill an array of strings with each module-key pair. 2. For each prior data_run, use one document to fill an array of strings with each module-key pair. 3. Compare each index of the array. If they match, set the data_run. 4. If the new deviceData object is distinct from all past data_runs, increment the number of data_runs for the Device and set the data_run for the new object to the new maximum.
Parameters:
Name Type Description
newSchema string The data contents array of the deviceData object which contains modules and key-value pairs for data points.
device_id string The id of the device
Returns:
The DataRun object which called the function, containing the dataRun for the deviceData object and the total number of data runs for the device.
Type
DataRun