<commit_before>// ---------------- Operation --------------------------------------------------

// Database Access (salesforce REST-API)
var db = require('./../database/salesforce/database'),
    i2c = require('./../i2c/i2c-controller');

var tick = 0;


var _handler;

// ---------------- Operations -------------------------------------------------

var checkToken = function(_bars, pointer) {

  // Round-Robin Check
  console.log('TICK >>> '+tick+' >>> POINTER >>> '+pointer);
  tick >= 32000 ? tick = 0 : tick++;

//  console.log('STATUS CHECK: ' + _bars[pointer].motor__c);

  i2c.status(_bars[pointer]);
};

/*
 * Database Request to get all available bars
 */
var getAvailableBars = function(device, callback) {
  db.getBarsByDevice(device, callback);
};


// ---------------- Interface --------------------------------------------------

module.exports = {

  start : function(device, interval) {

    console.log('I2C Request Handler started');
    console.log('Interval: '+ interval);
    var req = {}, res = {}, next = function() {};
    _handler = setInterval(
        function() {
          // Handle functions
            getAvailableBars(device, function(_bars) { // database entries

              var req = {}, res = {};
              req.response = {};

              i2c.getBars(req, res, function(req,res, next) { // physically connected

                var availableBars = [];

                req.availableBars.forEach(function(bar, index, array) {
                  _bars.forEach(function(_bar, _index, _array) {
                    if (_bar.motor__c == bar.motor) {
                      availableBars.push(_bar);
                    }
                  });
                });

                checkToken(availableBars, (tick % availableBars.length) );
              });

           });
        },
        interval);

  },

  stop : function() {
    setTimeout(
      function() {
        clearInterval(_handler);
        console.log('I2C Request Handler stoped');
      },
      0);
  }
};<commit_msg>intervallservice<commit_after>// ---------------- Operation --------------------------------------------------

// Database Access (salesforce REST-API)
var db = require('./../database/salesforce/database'),
    i2c = require('./../i2c/i2c-controller');

var tick = 0;


var _handler;

// ---------------- Operations -------------------------------------------------

var checkToken = function(_bars, pointer) {

  // Round-Robin Check
  console.log('TICK >>> '+tick+' >>> POINTER >>> '+pointer);
  tick >= 32000 ? tick = 0 : tick++;

//  console.log('STATUS CHECK: ' + _bars[pointer].motor__c);

  i2c.status(_bars[pointer]);
};

/*
 * Database Request to get all available bars
 */
var getAvailableBars = function(device, callback) {
  db.getBarsByDevice(device, callback);
};


// ---------------- Interface --------------------------------------------------

module.exports = {

  start : function(device, interval) {

    console.log('I2C Request Handler started');
    console.log('Interval: '+ interval);
    var req = {}, res = {}, next = function() {};
    _handler = setInterval(
        function() {
          // Handle functions
            getAvailableBars(device, function(_bars) { // database entries

              var req = {}, res = {};
              req.response = {};
              req.response.objects = _bars;

              i2c.getBars(req, res, function(req,res, next) { // physically connected

                // var availableBars = [];

                // req.availableBars.forEach(function(bar, index, array) {
                //   _bars.forEach(function(_bar, _index, _array) {
                //     if (_bar.motor__c == bar.motor) {
                //       availableBars.push(_bar);
                //     }
                //   });
                // });

                checkToken(req.response.objects, (tick % req.response.objects.length) );
              });

           });
        },
        interval);

  },

  stop : function() {
    setTimeout(
      function() {
        clearInterval(_handler);
        console.log('I2C Request Handler stoped');
      },
      0);
  }
};
{'fraction_non_alphanumeric': 0.23208685162846804, 'fraction_numerical': 0.007237635705669481, 'mean_word_length': 1.473747016706444, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '1761607', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1056, 'n_words': 222}