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,GAAO,GAEpD,CAED,KAEK,CACR,CAGA,OAAO,QAAQ,CAAC,8BAAe,oBAAU,UAAK,MAAG,MAAG,QAAI","file":"/npm/atlas-scientific-i2c@0.1.1/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/atlas-scientific-i2c@0.1.1/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * The main entry point\n * @module atlas-scientific-i2c \n */\n\nconst i2c = require('i2c-bus');\n/**\n * Generic EZO device\n */\nconst EZODevice = require('./ezo_device.js').default;\n/**\n * Peristaltic Pump class\n */\nconst Pump = require('./pump.js').default;\n/**\n * pH circuit class\n */\nconst pH = require('./ph_meter.js').default;\n/**\n * Dissolved Oxygen circuit class\n */\nconst DO = require('./do_meter.js').default;\n/**\n * Oxidation Reduction Potential circuit class\n */\nconst ORP = require('./orp_meter.js').default;\n/**\n * Electric Connectivity circuit class\n */\nconst EC = require('./ec_meter').default;\n\nfunction later(delay) {\n    return new Promise(function(resolve) {\n        setTimeout(resolve, delay);\n    });\n}\n\n\n/**\n * Returns a promise that resolves into an array of available, EZO class devices.\n * This scans the i2c_bus for in use addresses. It sends each address the \"I\" info command, and if the response matches the EZO pattern, it will instantiate the corresponding wrapper class.\n * If the device is an unknown type, it will instantiate as a generic EZODevice. \n * @param i2c_bus {PromisifiedBus}\n * @returns {Promise<Array>}\n */\n async function FindAllDevices(i2c_bus){\n\tconst info = Buffer.from(\"I\");\n\tconst results = await i2c_bus.scan();\n\tconst writesP=Promise.allSettled(results.map(addr=>{\n\t\t\t\t\treturn i2c_bus.i2cWrite(addr,info.length,info);\n\t\t\t}));\n\tawait writesP;\n\tawait later(300);\n\tconst readsP=await Promise.allSettled(results.map(addr=>{\n\t\t\tconst rbuf= Buffer.alloc(16);\n\t\t\treturn i2c_bus.i2cRead(addr,rbuf.length,rbuf);\n\t}));\n\n\tconst devices=[];\n\treadsP.forEach((promResult,index)=>{\n\t\t\tif(promResult.status==\"fulfilled\"){\n\t\t\t\t//console.log(promResult.value.buffer.toString());\n\t\t\t\tconst info=promResult.value.buffer.toString();\n\t\t\t\tif(info.indexOf(\"?I,\")>-1){\n\t\t\t\t\tconst devType=info.split(',')[1];\n\t\t\t\t\tif(devType=='PMP'){\n\t\t\t\t\t\tdevices.push(new Pump(i2c_bus,results[index],info));\n\t\t\t\t\t}else if(devType=='pH'){\n\t\t\t\t\t\tdevices.push(new pH(i2c_bus,results[index],info));\n\t\t\t\t\t}else if(devType=='DO'){\n\t\t\t\t\t\tdevices.push(new DO(i2c_bus,results[index],info));\n\t\t\t\t\t}else if(devType=='EC'){\n\t\t\t\t\t\tdevices.push(new EC(i2c_bus,results[index],info));\n\t\t\t\t\t}else if(devType=='ORP'){\n\t\t\t\t\t\tdevices.push(new ORP(i2c_bus,results[index],info));\n\t\t\t\t\t}else{\n\t\t\t\t\t\tdevices.push(new EZODevice(i2c_bus,results[index],info));\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t});\n\treturn devices;\n}\n\n\nmodule.exports={FindAllDevices,EZODevice,Pump,pH,DO,ORP,EC}"]}