diff --git a/index.js b/index.js index 0c437c8..6039c02 100644 --- a/index.js +++ b/index.js @@ -26,6 +26,13 @@ const predict = require('./src/predict/predict_class.js'); const interpolation = require('./src/predict/interpolation.js'); const childRegistrationUtils = require('./src/helper/childRegistrationUtils.js'); const { loadCurve } = require('./datasets/assetData/curves/index.js'); +const Fysics = require('./src/convert/fysics.js'); + +// Gravity helper (used by rotatingMachine for efficiency calculations) +const gravity = { + getStandardGravity: () => 9.80665, + fysics: new Fysics() +}; // Export everything module.exports = { @@ -44,5 +51,6 @@ module.exports = { convert, MenuManager, childRegistrationUtils, - loadCurve + loadCurve, + gravity }; diff --git a/src/convert/definitions/illuminance.js b/src/convert/definitions/illuminance.js index eefb1f3..05c1b33 100644 --- a/src/convert/definitions/illuminance.js +++ b/src/convert/definitions/illuminance.js @@ -30,8 +30,8 @@ module.exports = { ratio: 1/10.76391 }, imperial: { - unit: 'ft-cd', - ratio: 10.76391 + unit: 'ft-cd', + ratio: 10.76391 } } }; diff --git a/src/convert/index.js b/src/convert/index.js index 0734221..179287c 100644 --- a/src/convert/index.js +++ b/src/convert/index.js @@ -127,7 +127,7 @@ Converter.prototype.toBest = function(options) { if(!this.origin) throw new Error('.toBest must be called after .from'); - var options = Object.assign({ + options = Object.assign({ exclude: [], cutOffNumber: 1, }, options) @@ -268,22 +268,22 @@ Converter.prototype.throwUnsupportedUnitError = function (what) { Converter.prototype.possibilities = function (measure) { var possibilities = []; if(!this.origin && !measure) { - each(keys(measures), function (measure){ - each(measures[measure], function (units, system) { - if(system == '_anchors') - return false; + each(keys(measures), function (measure){ + each(measures[measure], function (units, system) { + if(system == '_anchors') + return false; - possibilities = possibilities.concat(keys(units)); - }); - }); + possibilities = possibilities.concat(keys(units)); + }); + }); } else { - measure = measure || this.origin.measure; - each(measures[measure], function (units, system) { - if(system == '_anchors') - return false; + measure = measure || this.origin.measure; + each(measures[measure], function (units, system) { + if(system == '_anchors') + return false; - possibilities = possibilities.concat(keys(units)); - }); + possibilities = possibilities.concat(keys(units)); + }); } return possibilities; diff --git a/src/convert/lodash/lodash._basecreate/index.js b/src/convert/lodash/lodash._basecreate/index.js index c6fc38a..bdea56c 100644 --- a/src/convert/lodash/lodash._basecreate/index.js +++ b/src/convert/lodash/lodash._basecreate/index.js @@ -21,12 +21,12 @@ var nativeCreate = reNative.test(nativeCreate = Object.create) && nativeCreate; * @param {Object} prototype The object to inherit from. * @returns {Object} Returns the new object. */ -function baseCreate(prototype, properties) { +function baseCreate(prototype, properties) { // eslint-disable-line no-func-assign return isObject(prototype) ? nativeCreate(prototype) : {}; } // fallback for browsers without `Object.create` if (!nativeCreate) { - baseCreate = (function() { + baseCreate = (function() { // eslint-disable-line no-func-assign function Object() {} return function(prototype) { if (isObject(prototype)) { diff --git a/src/convert/lodash/lodash._setbinddata/index.js b/src/convert/lodash/lodash._setbinddata/index.js index 7e86d4c..c3250ad 100644 --- a/src/convert/lodash/lodash._setbinddata/index.js +++ b/src/convert/lodash/lodash._setbinddata/index.js @@ -24,7 +24,7 @@ var defineProperty = (function() { var o = {}, func = reNative.test(func = Object.defineProperty) && func, result = func(o, o, o) && func; - } catch(e) { } + } catch(e) { /* intentionally empty */ } return result; }()); diff --git a/src/helper/assertionUtils.js b/src/helper/assertionUtils.js index 2ec2645..a6dee40 100644 --- a/src/helper/assertionUtils.js +++ b/src/helper/assertionUtils.js @@ -16,7 +16,7 @@ class Assertions { assertNoNaN(arr, label = "array") { if (Array.isArray(arr)) { for (const el of arr) { - assertNoNaN(el, label); + this.assertNoNaN(el, label); } } else { if (Number.isNaN(arr)) { diff --git a/src/helper/assetUtils.js b/src/helper/assetUtils.js index 2155549..70cbf1b 100644 --- a/src/helper/assetUtils.js +++ b/src/helper/assetUtils.js @@ -1,3 +1,5 @@ -export function getAssetVariables() { +function getAssetVariables() { -} \ No newline at end of file +} + +module.exports = { getAssetVariables }; diff --git a/src/helper/childRegistrationUtils.js b/src/helper/childRegistrationUtils.js index 6433a1e..3a18f27 100644 --- a/src/helper/childRegistrationUtils.js +++ b/src/helper/childRegistrationUtils.js @@ -39,7 +39,7 @@ class ChildRegistrationUtils { // IMPORTANT: Only call parent registration - no automatic handling and if parent has this function then try to register this child if (typeof this.mainClass.registerChild === 'function') { - this.mainClass.registerChild(child, softwareType); + return this.mainClass.registerChild(child, softwareType); } this.logger.info(`✅ Child ${name} registered successfully`); diff --git a/src/helper/childRegistrationUtils_DEPRECATED.js b/src/helper/childRegistrationUtils_DEPRECATED.js index c04109c..166376d 100644 --- a/src/helper/childRegistrationUtils_DEPRECATED.js +++ b/src/helper/childRegistrationUtils_DEPRECATED.js @@ -93,7 +93,7 @@ class ChildRegistrationUtils { break; default: - this.logger.error(`Child registration unrecognized desc: ${desc}`); + this.logger.error(`Child registration unrecognized desc: ${softwareType}`); this.logger.error(`Unrecognized softwareType: ${softwareType}`); } } diff --git a/src/helper/logger.js b/src/helper/logger.js index 8b4f696..239aff2 100644 --- a/src/helper/logger.js +++ b/src/helper/logger.js @@ -44,7 +44,7 @@ class Logger { if (this.levels.includes(level)) { this.logLevel = level; } else { - console.error(`[ERROR ${nameModule}]: Invalid log level: ${level}`); + console.error(`[ERROR ${this.nameModule}]: Invalid log level: ${level}`); } } diff --git a/src/helper/menuUtils.js b/src/helper/menuUtils.js index ebed6b8..35dc33c 100644 --- a/src/helper/menuUtils.js +++ b/src/helper/menuUtils.js @@ -158,7 +158,7 @@ async apiCall(node) { // OLFIANT when a browser refreshes the tag code is lost!!! fix this later!!!!! // FIX UUID ALSO LATER - if(node.assetTagCode !== "" || node.assetTagCode !== null){ } + if(node.assetTagCode !== "" || node.assetTagCode !== null){ /* intentionally empty */ } // API call to register or check asset in central database let assetregisterAPI = node.configUrls.cloud.taggcodeAPI + "/asset/create_asset.php"; @@ -264,6 +264,7 @@ async fetchProjectData(url) { return responsData; } catch (err) { + /* intentionally empty */ } } diff --git a/src/helper/menuUtils_DEPRECATED.js b/src/helper/menuUtils_DEPRECATED.js index ebed6b8..35dc33c 100644 --- a/src/helper/menuUtils_DEPRECATED.js +++ b/src/helper/menuUtils_DEPRECATED.js @@ -158,7 +158,7 @@ async apiCall(node) { // OLFIANT when a browser refreshes the tag code is lost!!! fix this later!!!!! // FIX UUID ALSO LATER - if(node.assetTagCode !== "" || node.assetTagCode !== null){ } + if(node.assetTagCode !== "" || node.assetTagCode !== null){ /* intentionally empty */ } // API call to register or check asset in central database let assetregisterAPI = node.configUrls.cloud.taggcodeAPI + "/asset/create_asset.php"; @@ -264,6 +264,7 @@ async fetchProjectData(url) { return responsData; } catch (err) { + /* intentionally empty */ } } diff --git a/src/helper/nodeTemplates.js b/src/helper/nodeTemplates.js index da259e4..9f61b6d 100644 --- a/src/helper/nodeTemplates.js +++ b/src/helper/nodeTemplates.js @@ -53,4 +53,4 @@ const nodeTemplates = { // …add more node “templates” here… }; -export default nodeTemplates; +module.exports = nodeTemplates; diff --git a/src/helper/outputUtils.js b/src/helper/outputUtils.js index bd6fb8d..b365019 100644 --- a/src/helper/outputUtils.js +++ b/src/helper/outputUtils.js @@ -37,14 +37,15 @@ class OutputUtils { if (Object.keys(changedFields).length > 0) { switch (format) { - case 'influxdb': + case 'influxdb': { // Extract the relevant config properties. const relevantConfig = this.extractRelevantConfig(config); // Flatten the tags so that no nested objects are passed on. const flatTags = this.flattenTags(relevantConfig); msg = this.influxDBFormat(changedFields, config, flatTags); - + break; + } case 'process': diff --git a/src/measurements/MeasurementContainer.js b/src/measurements/MeasurementContainer.js index 68f7ed9..78d96b5 100644 --- a/src/measurements/MeasurementContainer.js +++ b/src/measurements/MeasurementContainer.js @@ -95,7 +95,7 @@ class MeasurementContainer { } - this._currentPosition = positionValue.toString().toLowerCase();; + this._currentPosition = positionValue.toString().toLowerCase(); return this; } @@ -328,7 +328,7 @@ class MeasurementContainer { getLaggedSample(lag = 1,requestedUnit = null ){ const measurement = this.get(); if (!measurement) return null; - + let sample = measurement.getLaggedSample(lag); if (sample === null) return null; @@ -340,7 +340,7 @@ class MeasurementContainer { // Convert if needed if (measurement.unit && requestedUnit !== measurement.unit) { try { - const convertedValue = convertModule(value).from(measurement.unit).to(requestedUnit); + const convertedValue = convertModule(sample.value).from(measurement.unit).to(requestedUnit); //replace old value in sample and return obj sample.value = convertedValue ; sample.unit = requestedUnit; diff --git a/src/measurements/examples.js b/src/measurements/examples.js index 5cc2459..877957f 100644 --- a/src/measurements/examples.js +++ b/src/measurements/examples.js @@ -1,5 +1,7 @@ const { MeasurementContainer } = require('./index'); +const measurements = new MeasurementContainer(); + console.log('=== MEASUREMENT CONTAINER EXAMPLES ===\n'); console.log('This guide shows how to use the MeasurementContainer for storing,'); console.log('retrieving, and converting measurement data with automatic unit handling.\n'); diff --git a/src/predict/interpolation.js b/src/predict/interpolation.js index dcfc37a..2844d09 100644 --- a/src/predict/interpolation.js +++ b/src/predict/interpolation.js @@ -101,6 +101,7 @@ class Interpolation { } else if (type == "monotone_cubic_spline") { this.monotonic_cubic_spline(); } else if (type == "linear") { + /* intentionally empty */ } else { this.error = 1000; } @@ -266,6 +267,7 @@ class Interpolation { let k = 0; if (xpoint < xdata[0] || xpoint > xdata[n - 1]) { + /* intentionally empty */ } while (k < n - 1 && xpoint > xdata[k + 1] && !(xpoint < xdata[0] || xpoint > xdata[n - 1])) { diff --git a/src/state/movementManager.js b/src/state/movementManager.js index 424c628..c210e4b 100644 --- a/src/state/movementManager.js +++ b/src/state/movementManager.js @@ -49,15 +49,17 @@ class movementManager { try { // Execute the movement logic based on the mode switch (this.movementMode) { - case "staticspeed": + case "staticspeed": { const movelinFeedback = await this.moveLinear(targetPosition,signal); this.logger.info(`Linear move: ${movelinFeedback} `); break; + } - case "dynspeed": + case "dynspeed": { const moveDynFeedback = await this.moveEaseInOut(targetPosition,signal); this.logger.info(`Dynamic move : ${moveDynFeedback}`); break; + } default: throw new Error(`Unsupported movement mode: ${this.movementMode}`);