<commit_before>angular.module('PhmWebApp').provider('DataService', function () {
    'use strict';

    var sensorProtocolDefinitionUrl = 'https://raw.githubusercontent.com/tabman83/phm-messages/master/sensor-message.proto';

    this.$get = function($http, $rootScope, settings) {

        function DataService() {
            var self = this;

            var mqttClient = null;

            var initialize = function() {
                $http.get(sensorProtocolDefinitionUrl).then(function(result) {
                    var builder = dcodeIO.ProtoBuf.loadProto(result.data);
                    if(!builder) {
                        console.error('Error while decoding protobuf definition file.');
                    } else {
                        var SensorMessage = builder.build('SensorMessage');

                        if(typeof mqtt === 'undefined') {
                            console.error('Cannot load \'mqtt.js\'. Cannot contact MQTT server.');
                        } else {
                            console.log('Connection to MQTT broker established.');
                            var mqttUrl = 'mqtt://' + settings.MQTT_HOSTNAME + ':' + settings.MQTT_PORT;
                            mqttClient = mqtt.connect(mqttUrl, {
                                username: settings.MQTT_USERNAME,
                                password: settings.MQTT_PASSWORD
                            });
                            mqttClient.subscribe(settings.MQTT_SENSORS_QUEUE);
                            mqttClient.on('message', function(topic, payload) {
                                if(topic === 'phm/sensors') {
                                    var sensorMessage = SensorMessage.decode(payload);
                                    $rootScope.$emit('sensor', sensorMessage);
                                    //var date = new Date(+sensorMessage.timestamp.toString());
                                    //console.log(date, sensorMessage);
                                } else {
                                    console.log(topic, payload);
                                }
                            });
                        }

                    }
                }).catch(function() {
                    console.error('Cannot download \'sensor-message.proto\'.');
                });

            };

            this.sendBoolean = function(location, value) {
                if(mqttClient) {
                    var topic = 'phm/actuators';
                    mqttClient.publish(topic, 'H');
                } else {
                    console.error('MQTT client not initialized.');
                }
            };

            this.apiCall = function() {
            };

            initialize();

        }

        return new DataService();
    };
});<commit_msg>Send correct actuator value.<commit_after>angular.module('PhmWebApp').provider('DataService', function () {
    'use strict';

    var sensorProtocolDefinitionUrl = 'https://raw.githubusercontent.com/tabman83/phm-messages/master/sensor-message.proto';

    this.$get = function($http, $rootScope, settings) {

        function DataService() {
            var self = this;

            var mqttClient = null;

            var initialize = function() {
                $http.get(sensorProtocolDefinitionUrl).then(function(result) {
                    var builder = dcodeIO.ProtoBuf.loadProto(result.data);
                    if(!builder) {
                        console.error('Error while decoding protobuf definition file.');
                    } else {
                        var SensorMessage = builder.build('SensorMessage');

                        if(typeof mqtt === 'undefined') {
                            console.error('Cannot load \'mqtt.js\'. Cannot contact MQTT server.');
                        } else {
                            console.log('Connection to MQTT broker established.');
                            var mqttUrl = 'mqtt://' + settings.MQTT_HOSTNAME + ':' + settings.MQTT_PORT;
                            mqttClient = mqtt.connect(mqttUrl, {
                                username: settings.MQTT_USERNAME,
                                password: settings.MQTT_PASSWORD
                            });
                            mqttClient.subscribe(settings.MQTT_SENSORS_QUEUE);
                            mqttClient.on('message', function(topic, payload) {
                                if(topic === 'phm/sensors') {
                                    var sensorMessage = SensorMessage.decode(payload);
                                    $rootScope.$emit('sensor', sensorMessage);
                                    //var date = new Date(+sensorMessage.timestamp.toString());
                                    //console.log(date, sensorMessage);
                                } else {
                                    console.log(topic, payload);
                                }
                            });
                        }

                    }
                }).catch(function() {
                    console.error('Cannot download \'sensor-message.proto\'.');
                });

            };

            this.sendBoolean = function(location, value) {
                if(mqttClient) {
                    var topic = 'phm/actuators';
                    mqttClient.publish(topic, value ? 'ON': 'OFF');
                } else {
                    console.error('MQTT client not initialized.');
                }
            };

            this.apiCall = function() {
            };

            initialize();

        }

        return new DataService();
    };
});
{'fraction_non_alphanumeric': 0.10514225128114509, 'fraction_numerical': 0.0007068386640749249, 'mean_word_length': 1.1246246246246245, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5509512', 'n_tokens_mistral': 1343, 'n_tokens_neox': 1234, 'n_words': 223}