<commit_before>(function ($, fluid) {

    "use strict";

    var environment = flock.init();
    environment.start();

    fluid.defaults("gpii.sensorPlayer.sensor", {
        gradeNames: ["fluid.modelComponent"],
        model: {
            sensorValue: 50,
            simulateChanges: false,
            simulateChangesInterval: 2000,
            sensorMax: 100,
            sensorMin: 0,
            description: "A sensor"
        },
        members: {
            simulateChangesIntervalId: null
        },
        modelListeners: {
            sensorValue: {
                "this": "console",
                "method": "log",
                "args": "{that}.model.sensorValue"
            },
            simulateChanges: {
                "funcName": "gpii.sensorPlayer.sensor.simulateChanges",
                "args": ["{that}", "{that}.model.simulateChanges"]
            }
        }
    });

    gpii.sensorPlayer.sensor.randomInt = function(min, max) {
        min = Math.ceil(min);
        max = Math.floor(max);
        return Math.floor(Math.random() * (max - min)) + min;
    };

    fluid.defaults("gpii.sensorPlayer.sensor.pHSensor", {
        gradeNames: ["gpii.sensorPlayer.sensor"],
        model: {
            sensorValue: 7,
            sensorMax: 14,
            sensorMin: 1,
            description: "A simulated pH sensor."
        }
    });

    fluid.defaults("gpii.sensorPlayer.sensor.temperatureSensor", {
        gradeNames: ["gpii.sensorPlayer.sensor"],
        model: {
            sensorValue: 18,
            sensorMax: 26,
            sensorMin: 18,
            description: "A simulated temperature sensor (in celcius); constrained from 18 to 26."
        }
    });

    gpii.sensorPlayer.sensor.simulateChanges = function(that, simulateChanges) {
        if(simulateChanges) {
            // Turn on the interval changes to the sensorValue
            that.simulateChangesIntervalId = setInterval(function() {
                that.applier.change("sensorValue", gpii.sensorPlayer.sensor.randomInt(that.model.sensorMax, that.model.sensorMin));
            }, that.model.simulateChangesInterval);
        } else {
            // Turn off the interval changes to the sensorValue
            clearInterval(that.simulateChangesIntervalId);
        }
    };

    // A sensor sonifier that uses the scaling synth
    fluid.defaults("gpii.sensorPlayer.sensorSonifier", {
        gradeNames: ["fluid.modelComponent"],
        model: {
            sensorMax: 100,
            sensorMin: 0,
            sensorValue: 50
        },
        components: {
            scalingSynth: {
                type: "gpii.sensorPlayer.scalingSynth",
                options: {
                    model: {
                        valueInformation: {
                            max: "{sensorSonifier}.model.sensorMax",
                            min: "{sensorSonifier}.model.sensorMin",
                            current: "{sensorSonifier}.model.sensorValue"
                        }
                    }
                }
            }
        }
    });

    // A model-driven synth that scales model values
    // with specified min / max to a min/max frequency range
    fluid.defaults("gpii.sensorPlayer.scalingSynth", {
        gradeNames: ["flock.modelSynth"],
        modelRelay: [{
            target: "inputs.carrier.freq",
            singleTransform: {
                type: "gpii.sensorPlayer.transforms.minMaxScale",
                input: "{that}.model.valueInformation.current",
                inputScaleMax: "{that}.model.valueInformation.max",
                inputScaleMin: "{that}.model.valueInformation.min",
                outputScaleMax: "{that}.model.freqMax",
                outputScaleMin: "{that}.model.freqMin"
            }
        },
        {
            target: "inputs.midpoint.freq",
            singleTransform: {
                type: "fluid.transforms.binaryOp",
                left: {
                    transform: {
                        type: "fluid.transforms.binaryOp",
                        left: "{that}.model.freqMax",
                        right: "{that}.model.freqMin",
                        operator: "+"
                    }
                },
                right: "2",
                operator: "/"
            }
        }
        ],
        model: {
            // In real-world usage, these will be bound
            // to models from other components
            valueInformation: {
                max: "680",
                min: "200",
                current: "440"
            },
            inputs: {
                carrier: {
                    freq: 440<commit_msg>GPII-2190: fix default model values to numbers.<commit_after>(function ($, fluid) {

    "use strict";

    var environment = flock.init();
    environment.start();

    fluid.defaults("gpii.sensorPlayer.sensor", {
        gradeNames: ["fluid.modelComponent"],
        model: {
            sensorValue: 50,
            simulateChanges: false,
            simulateChangesInterval: 2000,
            sensorMax: 100,
            sensorMin: 0,
            description: "A sensor"
        },
        members: {
            simulateChangesIntervalId: null
        },
        modelListeners: {
            sensorValue: {
                "this": "console",
                "method": "log",
                "args": "{that}.model.sensorValue"
            },
            simulateChanges: {
                "funcName": "gpii.sensorPlayer.sensor.simulateChanges",
                "args": ["{that}", "{that}.model.simulateChanges"]
            }
        }
    });

    gpii.sensorPlayer.sensor.randomInt = function(min, max) {
        min = Math.ceil(min);
        max = Math.floor(max);
        return Math.floor(Math.random() * (max - min)) + min;
    };

    fluid.defaults("gpii.sensorPlayer.sensor.pHSensor", {
        gradeNames: ["gpii.sensorPlayer.sensor"],
        model: {
            sensorValue: 7,
            sensorMax: 14,
            sensorMin: 1,
            description: "A simulated pH sensor."
        }
    });

    fluid.defaults("gpii.sensorPlayer.sensor.temperatureSensor", {
        gradeNames: ["gpii.sensorPlayer.sensor"],
        model: {
            sensorValue: 18,
            sensorMax: 26,
            sensorMin: 18,
            description: "A simulated temperature sensor (in celcius); constrained from 18 to 26."
        }
    });

    gpii.sensorPlayer.sensor.simulateChanges = function(that, simulateChanges) {
        if(simulateChanges) {
            // Turn on the interval changes to the sensorValue
            that.simulateChangesIntervalId = setInterval(function() {
                that.applier.change("sensorValue", gpii.sensorPlayer.sensor.randomInt(that.model.sensorMax, that.model.sensorMin));
            }, that.model.simulateChangesInterval);
        } else {
            // Turn off the interval changes to the sensorValue
            clearInterval(that.simulateChangesIntervalId);
        }
    };

    // A sensor sonifier that uses the scaling synth
    fluid.defaults("gpii.sensorPlayer.sensorSonifier", {
        gradeNames: ["fluid.modelComponent"],
        model: {
            sensorMax: 100,
            sensorMin: 0,
            sensorValue: 50
        },
        components: {
            scalingSynth: {
                type: "gpii.sensorPlayer.scalingSynth",
                options: {
                    model: {
                        valueInformation: {
                            max: "{sensorSonifier}.model.sensorMax",
                            min: "{sensorSonifier}.model.sensorMin",
                            current: "{sensorSonifier}.model.sensorValue"
                        }
                    }
                }
            }
        }
    });

    // A model-driven synth that scales model values
    // with specified min / max to a min/max frequency range
    fluid.defaults("gpii.sensorPlayer.scalingSynth", {
        gradeNames: ["flock.modelSynth"],
        modelRelay: [{
            target: "inputs.carrier.freq",
            singleTransform: {
                type: "gpii.sensorPlayer.transforms.minMaxScale",
                input: "{that}.model.valueInformation.current",
                inputScaleMax: "{that}.model.valueInformation.max",
                inputScaleMin: "{that}.model.valueInformation.min",
                outputScaleMax: "{that}.model.freqMax",
                outputScaleMin: "{that}.model.freqMin"
            }
        },
        {
            target: "inputs.midpoint.freq",
            singleTransform: {
                type: "fluid.transforms.binaryOp",
                left: {
                    transform: {
                        type: "fluid.transforms.binaryOp",
                        left: "{that}.model.freqMax",
                        right: "{that}.model.freqMin",
                        operator: "+"
                    }
                },
                right: "2",
                operator: "/"
            }
        }
        ],
        model: {
            // In real-world usage, these will be bound
            // to models from other components
            valueInformation: {
                max: 100,
                min: 0,
                current: 50
            },
            inputs: {
                carrier: {
                    freq: 440
{'fraction_non_alphanumeric': 0.1104458462525393, 'fraction_numerical': 0.009301828290388111, 'mean_word_length': 1.3953905249679897, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5705738', 'n_tokens_mistral': 2520, 'n_tokens_neox': 2307, 'n_words': 457}