function arbInput(waveformData) {
                this.type = waveformData.type;
                this.rawData = waveformData.arbData;
                this.initial = Number(this.rawData[0][1]);
                this.channel = parseInt(waveformData.wavelengthIndex);
                //Transition rawData to a data array where every entry is a number tuple
                this.data = []
                for (var i = 0; i < this.rawData.length; i++) {
                    //If both entries in a row are numbers add it to data
                    if (this.rawData[i][0] !== null && typeof this.rawData[i][0] === "number" &&
                        this.rawData[i][1] !== null && typeof this.rawData[i][1] === "number") {
                        this.data.push([this.rawData[i][0] * 60 * 1000, this.rawData[i][1]]);//Convert from minutes to milliseconds here
                    }
                }
                //Sort data by the timepoint
                this.data.sort(function (a, b) {
                    if (a[0] < b[0]) return -1;
                    if (a[0] > b[0]) return 1;
                    return 0;
                });
                //returns the waveform associated with this input
                this.generateWaveforms = function () {
                    var waveforms = [];
                    (function (initial, data) {
                        //A index variable is declared to remember last returned index
                        //Search should begin here, likely resulting in O(1) operation
                        var index = 0;
                        waveforms.push(function (time) {
                            //A second recursive function so that it can call itself
                            function recursion(time) {
                                //If the time is past the time of the current index
                                if (time >= data[index][0]) {
                                    //If index is the last one in the list just return the intensity of the current index
                                    if (index >= data.length - 1) {
                                        return data[index][1];
                                    }
                                    //If the time is between the current index and the next one, return the current index's intensity
                                    if (time < data[index + 1][0]) {
                                        return data[index][1];
                                    }
                                    //If the time is greater than the next index and you aren't at the end of the array recurse looking at the next index
                                    else {
                                        index++;
                                        return recursion(time);
                                    }
                                }
                                //if time is less than current index traverse backwards until this is not true
                                //or until you reach begining of array, the return the initial value
                                else {
                                    if (index <= 0) {
                                        return initial;
                                    }
                                    else {
                                        index--;
                                        return recursion(time);
                                    }
                                }
                            }
                            //Handles the situation where there is only an initial timepoint
                            if(data.length === 0 ){
                                return initial;
                            }
                            else {
                                return recursion(time);
                            }
                        });
                    })(this.initial, this.data);
                    return waveforms;
                }
            }
//contains the inputs associated a arb input in the webform
contains the inputs associated a arb input in the webform
contains the inputs associated a arb input in the webform
function arbInput(waveformData) {
                this.type = waveformData.type;
                this.rawData = waveformData.arbData;
                this.initial = Number(this.rawData[0][1]);
                this.channel = parseInt(waveformData.wavelengthIndex);
                this.data = []
                for (var i = 0; i < this.rawData.length; i++) {
                    if (this.rawData[i][0] !== null && typeof this.rawData[i][0] === "number" &&
                        this.rawData[i][1] !== null && typeof this.rawData[i][1] === "number") {
                        this.data.push([this.rawData[i][0] * 60 * 1000, this.rawData[i][1]]);
                    }
                }
                this.data.sort(function (a, b) {
                    if (a[0] < b[0]) return -1;
                    if (a[0] > b[0]) return 1;
                    return 0;
                });
                this.generateWaveforms = function () {
                    var waveforms = [];
                    (function (initial, data) {
                        var index = 0;
                        waveforms.push(function (time) {
                            function recursion(time) {
                                if (time >= data[index][0]) {
                                    if (index >= data.length - 1) {
                                        return data[index][1];
                                    }
                                    if (time < data[index + 1][0]) {
                                        return data[index][1];
                                    }
                                    else {
                                        index++;
                                        return recursion(time);
                                    }
                                }
                                else {
                                    if (index <= 0) {
                                        return initial;
                                    }
                                    else {
                                        index--;
                                        return recursion(time);
                                    }
                                }
                            }
                            if(data.length === 0 ){
                                return initial;
                            }
                            else {
                                return recursion(time);
                            }
                        });
                    })(this.initial, this.data);
                    return waveforms;
                }
            }
function arbInput ( waveformData ) { this . type = waveformData . type ; this . rawData = waveformData . arbData ; this . initial = Number ( this . rawData [ 0 ] [ 1 ] ) ; this . channel = parseInt ( waveformData . wavelengthIndex ) ; this . data = [ ] for ( var i = 0 ; i < this . rawData . length ; i ++ ) { if ( this . rawData [ i ] [ 0 ] !== null && typeof this . rawData [ i ] [ 0 ] === "number" && this . rawData [ i ] [ 1 ] !== null && typeof this . rawData [ i ] [ 1 ] === "number" ) { this . data . push ( [ this . rawData [ i ] [ 0 ] * 60 * 1000 , this . rawData [ i ] [ 1 ] ] ) ; } } this . data . sort ( function ( a , b ) { if ( a [ 0 ] < b [ 0 ] ) return - 1 ; if ( a [ 0 ] > b [ 0 ] ) return 1 ; return 0 ; } ) ; this . generateWaveforms = function ( ) { var waveforms = [ ] ; ( function ( initial , data ) { var index = 0 ; waveforms . push ( function ( time ) { function recursion ( time ) { if ( time >= data [ index ] [ 0 ] ) { if ( index >= data . length - 1 ) { return data [ index ] [ 1 ] ; } if ( time < data [ index + 1 ] [ 0 ] ) { return data [ index ] [ 1 ] ; } else { index ++ ; return recursion ( time ) ; } } else { if ( index <= 0 ) { return initial ; } else { index -- ; return recursion ( time ) ; } } } if ( data . length === 0 ) { return initial ; } else { return recursion ( time ) ; } } ) ; } ) ( this . initial , this . data ) ; return waveforms ; } }
contains the inputs associated a arb input in the webform
contains the inputs associated a arb input in the webform
//Transition rawData to a data array where every entry is a number tuple //If both entries in a row are numbers add it to data //Convert from minutes to milliseconds here //Sort data by the timepoint //returns the waveform associated with this input //A index variable is declared to remember last returned index //Search should begin here, likely resulting in O(1) operation //A second recursive function so that it can call itself //If the time is past the time of the current index //If index is the last one in the list just return the intensity of the current index //If the time is between the current index and the next one, return the current index's intensity //If the time is greater than the next index and you aren't at the end of the array recurse looking at the next index //if time is less than current index traverse backwards until this is not true //or until you reach begining of array, the return the initial value //Handles the situation where there is only an initial timepoint