<commit_before>// Dependency modules
var events        = require('events');

// Local modules
var baClient      = require('./lib/bacnet-client');
var baEnum        = require('./lib/bacnet-enum');

/**
 * To be able to communicate to BACNET devices, you have to initialize a new bacstack instance.
 * @class bacstack
 * @param {object=} settings - The options object used for parameterising the bacstack.
 * @param {number=} [settings.port=47808] - BACNET communication port for listening and sending.
 * @param {string=} settings.interface - Specific BACNET communication interface if different from primary one.
 * @param {string=} [settings.broadcastAddress=255.255.255.255] - The address used for broadcast messages.
 * @param {number=} [settings.adpuTimeout=3000] - The timeout in milliseconds until a transaction should be interpreted as error.
 * @example
 * var bacnet = require('bacstack');
 *
 * var client = new bacnet({
 *   port: 47809,                          // Use BAC1 as communication port
 *   interface: '192.168.251.10',          // Listen on a specific interface
 *   broadcastAddress: '192.168.251.255',  // Use the subnet broadcast address
 *   adpuTimeout: 6000                     // Wait twice as long for response
 * });
 */
module.exports = function(settings) {
  var self = new events.EventEmitter();

  settings = settings || {};
  var options = {
    port: settings.port || 47808,
    interface: settings.interface,
    transport: settings.transport,
    broadcastAddress: settings.broadcastAddress || '255.255.255.255',
    adpuTimeout: settings.adpuTimeout || 3000
  };

  var client = new baClient(options);

  // Public enums
  self.enum = baEnum;

  client.events.on('iAm', function(address, deviceId, maxAdpu, segmentation, vendorId) {

    /**
     * @event bacstack.iAm
     * @param {string} address - The IP address of the detected device.
     * @param {number} deviceId - The BACNET device-id of the detected device.
     * @param {number} maxAdpu - The max ADPU size the detected device is supporting.
     * @param {number} segmentation - The type of segmentation the detected device is supporting.
     * @param {number} vendorId - The BACNET vendor-id of the detected device.
     * @example
     * client.on('iAm', function(address, deviceId, maxAdpu, segmentation, vendorId) {
     *   console.log('address: ', address, ' - deviceId: ', deviceId, ' - maxAdpu: ', maxAdpu, ' - segmentation: ', segmentation, ' - vendorId: ', vendorId);
     * });
     */<commit_msg>refactor(index): move enum expose from instantiated object to root level<commit_after>// Dependency modules
var events        = require('events');

// Local modules
var baClient      = require('./lib/bacnet-client');
var baEnum        = require('./lib/bacnet-enum');

// Public enums
module.exports.enum = baEnum;

/**
 * To be able to communicate to BACNET devices, you have to initialize a new bacstack instance.
 * @class bacstack
 * @param {object=} settings - The options object used for parameterising the bacstack.
 * @param {number=} [settings.port=47808] - BACNET communication port for listening and sending.
 * @param {string=} settings.interface - Specific BACNET communication interface if different from primary one.
 * @param {string=} [settings.broadcastAddress=255.255.255.255] - The address used for broadcast messages.
 * @param {number=} [settings.adpuTimeout=3000] - The timeout in milliseconds until a transaction should be interpreted as error.
 * @example
 * var bacnet = require('bacstack');
 *
 * var client = new bacnet({
 *   port: 47809,                          // Use BAC1 as communication port
 *   interface: '192.168.251.10',          // Listen on a specific interface
 *   broadcastAddress: '192.168.251.255',  // Use the subnet broadcast address
 *   adpuTimeout: 6000                     // Wait twice as long for response
 * });
 */
module.exports = function(settings) {
  var self = new events.EventEmitter();

  settings = settings || {};
  var options = {
    port: settings.port || 47808,
    interface: settings.interface,
    transport: settings.transport,
    broadcastAddress: settings.broadcastAddress || '255.255.255.255',
    adpuTimeout: settings.adpuTimeout || 3000
  };

  var client = new baClient(options);

  client.events.on('iAm', function(address, deviceId, maxAdpu, segmentation, vendorId) {

    /**
     * @event bacstack.iAm
     * @param {string} address - The IP address of the detected device.
     * @param {number} deviceId - The BACNET device-id of the detected device.
     * @param {number} maxAdpu - The max ADPU size the detected device is supporting.
     * @param {number} segmentation - The type of segmentation the detected device is supporting.
     * @param {number} vendorId - The BACNET vendor-id of the detected device.
     * @example
     * client.on('iAm', function(address, deviceId, maxAdpu, segmentation, vendorId) {
     *   console.log('address: ', address, ' - deviceId: ', deviceId, ' - maxAdpu: ', maxAdpu, ' - segmentation: ', segmentation, ' - vendorId: ', vendorId);
     * });
     */
{'fraction_non_alphanumeric': 0.11854759568204122, 'fraction_numerical': 0.029440628066732092, 'mean_word_length': 3.208092485549133, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 8, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5570835', 'n_tokens_mistral': 1548, 'n_tokens_neox': 1409, 'n_words': 481}