<commit_before>// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license.

'use strict';

var device = require('azure-iot-device');

// Use the DeviceExplorer or IotHub-Exploror tools to create a device and get its connection string.
var connectionString = process.env.IOTHUB_CONN || 'YOUR IOT HUB DEVICE-SPECIFIC CONNECTION STRING HERE';
// Create the Azure IoT Hub Client, which is the local instance of the connected device
var client = new device.Client(connectionString, new device.Https());

// For this simulation, create an Array of five simulated devices
var sensors = new Array();
createSimulatedSensors();

// Use setInterval to send the data from each of the five simulated device
// in 10-second intervals (i.e. five device messages every 10 seconds,
// which is 30 messages per minute, or 43,200 messages per day).
// This is simulating five independent devices sending messages.
// An alternative would be to collect the data from five devices
// in a field gateway and aggregate the data into a single message.
// This would reduce the message count.
setInterval(function(){
  // Set up valiables used for the simulation
  var sensor;
  // Iterate through each of the five devices to gather the device data
  for(var i=0; i< sensors.length; i++) {
    sensor = updateSensor(sensors[i]);
    
    // Create a new message using random values based on the last known values
    var payload = JSON.stringify({
        deviceId: sensor.deviceId,
        location: sensor.location,
        fahrenheit: sensor.fahrenheit,
        celsius: sensor.celsius,
        relativeHumidity: sensor.relativeHumidity,
        pressure: sensor.pressure,
        altitude_f: sensor.altitude_f,
        altitude_m: sensor.altitude_f,
      });
      
      // Create the message based on the payload JSON
      var message = new device.Message(payload);
      // For debugging purposes, write out the message paylod to the console
      console.log("Sending message: " + message.getData());
      // Send the message to Azure IoT Hub
      client.sendEvent(message, printResultFor('send'));<commit_msg>Update to simulator to match weather.js<commit_after>// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license.

'use strict';

var device = require('azure-iot-device');

// Use the DeviceExplorer or IotHub-Exploror tools to create a device and get its connection string.
var connectionString = process.env.IOTHUB_CONN || 'YOUR IOT HUB DEVICE-SPECIFIC CONNECTION STRING HERE';
// Create the Azure IoT Hub Client, which is the local instance of the connected device
var client = new device.Client(connectionString, new device.Https());

// For this simulation, create an Array of five simulated devices
var sensors = new Array();
createSimulatedSensors();

// Use setInterval to send the data from each of the five simulated device
// in 10-second intervals (i.e. five device messages every 10 seconds,
// which is 30 messages per minute, or 43,200 messages per day).
// This is simulating five independent devices sending messages.
// An alternative would be to collect the data from five devices
// in a field gateway and aggregate the data into a single message.
// This would reduce the message count.
setInterval(function(){
  // Set up valiables used for the simulation
  var sensor;
  // Iterate through each of the five devices to gather the device data
  for(var i=0; i< sensors.length; i++) {
    sensor = updateSensor(sensors[i]);
    
    // Create a new message using random values based on the last known values
    var payload = JSON.stringify({
        deviceId: sensor.deviceId,
        location: sensor.location,
        celsius: sensor.celsius,
        fahrenheit: sensor.fahrenheit,
        relativeHumidity: sensor.relativeHumidity,
        pressure: sensor.pressure,
        feet: sensor.altitude_f,
        meters: sensor.altitude_f,
      });
      
      // Create the message based on the payload JSON
      var message = new device.Message(payload);
      // For debugging purposes, write out the message paylod to the console
      console.log("Sending message: " + message.getData());
      // Send the message to Azure IoT Hub
      client.sendEvent(message, printResultFor('send'));
{'fraction_non_alphanumeric': 0.0819633630812588, 'fraction_numerical': 0.0056364490371066224, 'mean_word_length': 3.3592630501535314, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2178391', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1090, 'n_words': 494}