memory.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. 'use strict';
  2. // @ts-check
  3. // ==================================================================================
  4. // memory.js
  5. // ----------------------------------------------------------------------------------
  6. // Description: System Information - library
  7. // for Node.js
  8. // Copyright: (c) 2014 - 2022
  9. // Author: Sebastian Hildebrandt
  10. // ----------------------------------------------------------------------------------
  11. // License: MIT
  12. // ==================================================================================
  13. // 5. Memory
  14. // ----------------------------------------------------------------------------------
  15. const os = require('os');
  16. const exec = require('child_process').exec;
  17. const execSync = require('child_process').execSync;
  18. const util = require('./util');
  19. const fs = require('fs');
  20. let _platform = process.platform;
  21. const _linux = (_platform === 'linux' || _platform === 'android');
  22. const _darwin = (_platform === 'darwin');
  23. const _windows = (_platform === 'win32');
  24. const _freebsd = (_platform === 'freebsd');
  25. const _openbsd = (_platform === 'openbsd');
  26. const _netbsd = (_platform === 'netbsd');
  27. const _sunos = (_platform === 'sunos');
  28. const OSX_RAM_manufacturers = {
  29. '0x014F': 'Transcend Information',
  30. '0x2C00': 'Micron Technology Inc.',
  31. '0x802C': 'Micron Technology Inc.',
  32. '0x80AD': 'Hynix Semiconductor Inc.',
  33. '0x80CE': 'Samsung Electronics Inc.',
  34. '0xAD00': 'Hynix Semiconductor Inc.',
  35. '0xCE00': 'Samsung Electronics Inc.',
  36. '0x02FE': 'Elpida',
  37. '0x5105': 'Qimonda AG i. In.',
  38. '0x8551': 'Qimonda AG i. In.',
  39. '0x859B': 'Crucial',
  40. '0x04CD': 'G-Skill'
  41. };
  42. const LINUX_RAM_manufacturers = {
  43. '017A': 'Apacer',
  44. '0198': 'HyperX',
  45. '029E': 'Corsair',
  46. '04CB': 'A-DATA',
  47. '04CD': 'G-Skill',
  48. '059B': 'Crucial',
  49. '00CE': 'Samsung',
  50. '1315': 'Crutial',
  51. '014F': 'Transcend Information',
  52. '2C00': 'Micron Technology Inc.',
  53. '802C': 'Micron Technology Inc.',
  54. '80AD': 'Hynix Semiconductor Inc.',
  55. '80CE': 'Samsung Electronics Inc.',
  56. 'AD00': 'Hynix Semiconductor Inc.',
  57. 'CE00': 'Samsung Electronics Inc.',
  58. '02FE': 'Elpida',
  59. '5105': 'Qimonda AG i. In.',
  60. '8551': 'Qimonda AG i. In.',
  61. '859B': 'Crucial'
  62. };
  63. // _______________________________________________________________________________________
  64. // | R A M | H D |
  65. // |______________________|_________________________| | |
  66. // | active buffers/cache | | |
  67. // |________________________________________________|___________|_________|______________|
  68. // | used free | used free |
  69. // |____________________________________________________________|________________________|
  70. // | total | swap |
  71. // |____________________________________________________________|________________________|
  72. // free (older versions)
  73. // ----------------------------------
  74. // # free
  75. // total used free shared buffers cached
  76. // Mem: 16038 (1) 15653 (2) 384 (3) 0 (4) 236 (5) 14788 (6)
  77. // -/+ buffers/cache: 628 (7) 15409 (8)
  78. // Swap: 16371 83 16288
  79. //
  80. // |------------------------------------------------------------|
  81. // | R A M |
  82. // |______________________|_____________________________________|
  83. // | active (2-(5+6) = 7) | available (3+5+6 = 8) |
  84. // |______________________|_________________________|___________|
  85. // | active | buffers/cache (5+6) | |
  86. // |________________________________________________|___________|
  87. // | used (2) | free (3) |
  88. // |____________________________________________________________|
  89. // | total (1) |
  90. // |____________________________________________________________|
  91. //
  92. // free (since free von procps-ng 3.3.10)
  93. // ----------------------------------
  94. // # free
  95. // total used free shared buffers/cache available
  96. // Mem: 16038 (1) 628 (2) 386 (3) 0 (4) 15024 (5) 14788 (6)
  97. // Swap: 16371 83 16288
  98. //
  99. // |------------------------------------------------------------|
  100. // | R A M |
  101. // |______________________|_____________________________________|
  102. // | | available (6) estimated |
  103. // |______________________|_________________________|___________|
  104. // | active (2) | buffers/cache (5) | free (3) |
  105. // |________________________________________________|___________|
  106. // | total (1) |
  107. // |____________________________________________________________|
  108. //
  109. // Reference: http://www.software-architect.net/blog/article/date/2015/06/12/-826c6e5052.html
  110. // /procs/meminfo - sample (all in kB)
  111. //
  112. // MemTotal: 32806380 kB
  113. // MemFree: 17977744 kB
  114. // MemAvailable: 19768972 kB
  115. // Buffers: 517028 kB
  116. // Cached: 2161876 kB
  117. // SwapCached: 456 kB
  118. // Active: 12081176 kB
  119. // Inactive: 2164616 kB
  120. // Active(anon): 10832884 kB
  121. // Inactive(anon): 1477272 kB
  122. // Active(file): 1248292 kB
  123. // Inactive(file): 687344 kB
  124. // Unevictable: 0 kB
  125. // Mlocked: 0 kB
  126. // SwapTotal: 16768892 kB
  127. // SwapFree: 16768304 kB
  128. // Dirty: 268 kB
  129. // Writeback: 0 kB
  130. // AnonPages: 11568832 kB
  131. // Mapped: 719992 kB
  132. // Shmem: 743272 kB
  133. // Slab: 335716 kB
  134. // SReclaimable: 256364 kB
  135. // SUnreclaim: 79352 kB
  136. function mem(callback) {
  137. return new Promise((resolve) => {
  138. process.nextTick(() => {
  139. let result = {
  140. total: os.totalmem(),
  141. free: os.freemem(),
  142. used: os.totalmem() - os.freemem(),
  143. active: os.totalmem() - os.freemem(), // temporarily (fallback)
  144. available: os.freemem(), // temporarily (fallback)
  145. buffers: 0,
  146. cached: 0,
  147. slab: 0,
  148. buffcache: 0,
  149. swaptotal: 0,
  150. swapused: 0,
  151. swapfree: 0
  152. };
  153. if (_linux) {
  154. fs.readFile('/proc/meminfo', function (error, stdout) {
  155. if (!error) {
  156. const lines = stdout.toString().split('\n');
  157. result.total = parseInt(util.getValue(lines, 'memtotal'), 10);
  158. result.total = result.total ? result.total * 1024 : os.totalmem();
  159. result.free = parseInt(util.getValue(lines, 'memfree'), 10);
  160. result.free = result.free ? result.free * 1024 : os.freemem();
  161. result.used = result.total - result.free;
  162. result.buffers = parseInt(util.getValue(lines, 'buffers'), 10);
  163. result.buffers = result.buffers ? result.buffers * 1024 : 0;
  164. result.cached = parseInt(util.getValue(lines, 'cached'), 10);
  165. result.cached = result.cached ? result.cached * 1024 : 0;
  166. result.slab = parseInt(util.getValue(lines, 'slab'), 10);
  167. result.slab = result.slab ? result.slab * 1024 : 0;
  168. result.buffcache = result.buffers + result.cached + result.slab;
  169. let available = parseInt(util.getValue(lines, 'memavailable'), 10);
  170. result.available = available ? available * 1024 : result.free + result.buffcache;
  171. result.active = result.total - result.available;
  172. result.swaptotal = parseInt(util.getValue(lines, 'swaptotal'), 10);
  173. result.swaptotal = result.swaptotal ? result.swaptotal * 1024 : 0;
  174. result.swapfree = parseInt(util.getValue(lines, 'swapfree'), 10);
  175. result.swapfree = result.swapfree ? result.swapfree * 1024 : 0;
  176. result.swapused = result.swaptotal - result.swapfree;
  177. }
  178. if (callback) { callback(result); }
  179. resolve(result);
  180. });
  181. }
  182. if (_freebsd || _openbsd || _netbsd) {
  183. exec('/sbin/sysctl hw.realmem hw.physmem vm.stats.vm.v_page_count vm.stats.vm.v_wire_count vm.stats.vm.v_active_count vm.stats.vm.v_inactive_count vm.stats.vm.v_cache_count vm.stats.vm.v_free_count vm.stats.vm.v_page_size', function (error, stdout) {
  184. if (!error) {
  185. let lines = stdout.toString().split('\n');
  186. const pagesize = parseInt(util.getValue(lines, 'vm.stats.vm.v_page_size'), 10);
  187. const inactive = parseInt(util.getValue(lines, 'vm.stats.vm.v_inactive_count'), 10) * pagesize;
  188. const cache = parseInt(util.getValue(lines, 'vm.stats.vm.v_cache_count'), 10) * pagesize;
  189. result.total = parseInt(util.getValue(lines, 'hw.realmem'), 10);
  190. if (isNaN(result.total)) { result.total = parseInt(util.getValue(lines, 'hw.physmem'), 10); }
  191. result.free = parseInt(util.getValue(lines, 'vm.stats.vm.v_free_count'), 10) * pagesize;
  192. result.buffcache = inactive + cache;
  193. result.available = result.buffcache + result.free;
  194. result.active = result.total - result.free - result.buffcache;
  195. result.swaptotal = 0;
  196. result.swapfree = 0;
  197. result.swapused = 0;
  198. }
  199. if (callback) { callback(result); }
  200. resolve(result);
  201. });
  202. }
  203. if (_sunos) {
  204. if (callback) { callback(result); }
  205. resolve(result);
  206. }
  207. if (_darwin) {
  208. let pageSize = 4096;
  209. try {
  210. let sysPpageSize = util.toInt(execSync('sysctl -n vm.pagesize').toString());
  211. pageSize = sysPpageSize || pageSize;
  212. } catch (e) {
  213. util.noop();
  214. }
  215. exec('vm_stat 2>/dev/null | grep "Pages active"', function (error, stdout) {
  216. if (!error) {
  217. let lines = stdout.toString().split('\n');
  218. result.active = parseInt(lines[0].split(':')[1], 10) * pageSize;
  219. result.buffcache = result.used - result.active;
  220. result.available = result.free + result.buffcache;
  221. }
  222. exec('sysctl -n vm.swapusage 2>/dev/null', function (error, stdout) {
  223. if (!error) {
  224. let lines = stdout.toString().split('\n');
  225. if (lines.length > 0) {
  226. let line = lines[0].replace(/,/g, '.').replace(/M/g, '');
  227. line = line.trim().split(' ');
  228. for (let i = 0; i < line.length; i++) {
  229. if (line[i].toLowerCase().indexOf('total') !== -1) { result.swaptotal = parseFloat(line[i].split('=')[1].trim()) * 1024 * 1024; }
  230. if (line[i].toLowerCase().indexOf('used') !== -1) { result.swapused = parseFloat(line[i].split('=')[1].trim()) * 1024 * 1024; }
  231. if (line[i].toLowerCase().indexOf('free') !== -1) { result.swapfree = parseFloat(line[i].split('=')[1].trim()) * 1024 * 1024; }
  232. }
  233. }
  234. }
  235. if (callback) { callback(result); }
  236. resolve(result);
  237. });
  238. });
  239. }
  240. if (_windows) {
  241. let swaptotal = 0;
  242. let swapused = 0;
  243. try {
  244. util.powerShell('Get-CimInstance Win32_PageFileUsage | Select AllocatedBaseSize, CurrentUsage').then((stdout, error) => {
  245. if (!error) {
  246. let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0);
  247. lines.forEach(function (line) {
  248. if (line !== '') {
  249. line = line.trim().split(/\s\s+/);
  250. swaptotal = swaptotal + (parseInt(line[0], 10) || 0);
  251. swapused = swapused + (parseInt(line[1], 10) || 0);
  252. }
  253. });
  254. }
  255. result.swaptotal = swaptotal * 1024 * 1024;
  256. result.swapused = swapused * 1024 * 1024;
  257. result.swapfree = result.swaptotal - result.swapused;
  258. if (callback) { callback(result); }
  259. resolve(result);
  260. });
  261. } catch (e) {
  262. if (callback) { callback(result); }
  263. resolve(result);
  264. }
  265. }
  266. });
  267. });
  268. }
  269. exports.mem = mem;
  270. function memLayout(callback) {
  271. function getManufacturerDarwin(manId) {
  272. if ({}.hasOwnProperty.call(OSX_RAM_manufacturers, manId)) {
  273. return (OSX_RAM_manufacturers[manId]);
  274. }
  275. return manId;
  276. }
  277. function getManufacturerLinux(manId) {
  278. const manIdSearch = manId.replace('0x', '').toUpperCase();
  279. if (manIdSearch.length === 4 && {}.hasOwnProperty.call(LINUX_RAM_manufacturers, manIdSearch)) {
  280. return (LINUX_RAM_manufacturers[manIdSearch]);
  281. }
  282. return manId;
  283. }
  284. return new Promise((resolve) => {
  285. process.nextTick(() => {
  286. let result = [];
  287. if (_linux || _freebsd || _openbsd || _netbsd) {
  288. exec('export LC_ALL=C; dmidecode -t memory 2>/dev/null | grep -iE "Size:|Type|Speed|Manufacturer|Form Factor|Locator|Memory Device|Serial Number|Voltage|Part Number"; unset LC_ALL', function (error, stdout) {
  289. if (!error) {
  290. let devices = stdout.toString().split('Memory Device');
  291. devices.shift();
  292. devices.forEach(function (device) {
  293. let lines = device.split('\n');
  294. const sizeString = util.getValue(lines, 'Size');
  295. const size = sizeString.indexOf('GB') >= 0 ? parseInt(sizeString, 10) * 1024 * 1024 * 1024 : parseInt(sizeString, 10) * 1024 * 1024;
  296. if (parseInt(util.getValue(lines, 'Size'), 10) > 0) {
  297. const totalWidth = util.toInt(util.getValue(lines, 'Total Width'));
  298. const dataWidth = util.toInt(util.getValue(lines, 'Data Width'));
  299. result.push({
  300. size,
  301. bank: util.getValue(lines, 'Bank Locator'),
  302. type: util.getValue(lines, 'Type:'),
  303. ecc: dataWidth && totalWidth ? totalWidth > dataWidth : false,
  304. clockSpeed: (util.getValue(lines, 'Configured Clock Speed:') ? parseInt(util.getValue(lines, 'Configured Clock Speed:'), 10) : (util.getValue(lines, 'Speed:') ? parseInt(util.getValue(lines, 'Speed:'), 10) : null)),
  305. formFactor: util.getValue(lines, 'Form Factor:'),
  306. manufacturer: getManufacturerLinux(util.getValue(lines, 'Manufacturer:')),
  307. partNum: util.getValue(lines, 'Part Number:'),
  308. serialNum: util.getValue(lines, 'Serial Number:'),
  309. voltageConfigured: parseFloat(util.getValue(lines, 'Configured Voltage:')) || null,
  310. voltageMin: parseFloat(util.getValue(lines, 'Minimum Voltage:')) || null,
  311. voltageMax: parseFloat(util.getValue(lines, 'Maximum Voltage:')) || null,
  312. });
  313. } else {
  314. result.push({
  315. size: 0,
  316. bank: util.getValue(lines, 'Bank Locator'),
  317. type: 'Empty',
  318. ecc: null,
  319. clockSpeed: 0,
  320. formFactor: util.getValue(lines, 'Form Factor:'),
  321. partNum: '',
  322. serialNum: '',
  323. voltageConfigured: null,
  324. voltageMin: null,
  325. voltageMax: null,
  326. });
  327. }
  328. });
  329. }
  330. if (!result.length) {
  331. result.push({
  332. size: os.totalmem(),
  333. bank: '',
  334. type: '',
  335. ecc: null,
  336. clockSpeed: 0,
  337. formFactor: '',
  338. partNum: '',
  339. serialNum: '',
  340. voltageConfigured: null,
  341. voltageMin: null,
  342. voltageMax: null,
  343. });
  344. // Try Raspberry PI
  345. try {
  346. let stdout = execSync('cat /proc/cpuinfo 2>/dev/null');
  347. let lines = stdout.toString().split('\n');
  348. let model = util.getValue(lines, 'hardware', ':', true).toUpperCase();
  349. let version = util.getValue(lines, 'revision', ':', true).toLowerCase();
  350. if (model === 'BCM2835' || model === 'BCM2708' || model === 'BCM2709' || model === 'BCM2835' || model === 'BCM2837') {
  351. const clockSpeed = {
  352. '0': 400,
  353. '1': 450,
  354. '2': 450,
  355. '3': 3200
  356. };
  357. result[0].type = 'LPDDR2';
  358. result[0].type = version && version[2] && version[2] === '3' ? 'LPDDR4' : result[0].type;
  359. result[0].ecc = false;
  360. result[0].clockSpeed = version && version[2] && clockSpeed[version[2]] || 400;
  361. result[0].clockSpeed = version && version[4] && version[4] === 'd' ? 500 : result[0].clockSpeed;
  362. result[0].formFactor = 'SoC';
  363. stdout = execSync('vcgencmd get_config sdram_freq 2>/dev/null');
  364. lines = stdout.toString().split('\n');
  365. let freq = parseInt(util.getValue(lines, 'sdram_freq', '=', true), 10) || 0;
  366. if (freq) {
  367. result[0].clockSpeed = freq;
  368. }
  369. stdout = execSync('vcgencmd measure_volts sdram_p 2>/dev/null');
  370. lines = stdout.toString().split('\n');
  371. let voltage = parseFloat(util.getValue(lines, 'volt', '=', true)) || 0;
  372. if (voltage) {
  373. result[0].voltageConfigured = voltage;
  374. result[0].voltageMin = voltage;
  375. result[0].voltageMax = voltage;
  376. }
  377. }
  378. } catch (e) {
  379. util.noop();
  380. }
  381. }
  382. if (callback) { callback(result); }
  383. resolve(result);
  384. });
  385. }
  386. if (_darwin) {
  387. exec('system_profiler SPMemoryDataType', function (error, stdout) {
  388. if (!error) {
  389. const allLines = stdout.toString().split('\n');
  390. const eccStatus = util.getValue(allLines, 'ecc', ':', true).toLowerCase();
  391. let devices = stdout.toString().split(' BANK ');
  392. let hasBank = true;
  393. if (devices.length === 1) {
  394. devices = stdout.toString().split(' DIMM');
  395. hasBank = false;
  396. }
  397. devices.shift();
  398. devices.forEach(function (device) {
  399. let lines = device.split('\n');
  400. const bank = (hasBank ? 'BANK ' : 'DIMM') + lines[0].trim().split('/')[0];
  401. const size = parseInt(util.getValue(lines, ' Size'));
  402. if (size) {
  403. result.push({
  404. size: size * 1024 * 1024 * 1024,
  405. bank: bank,
  406. type: util.getValue(lines, ' Type:'),
  407. ecc: eccStatus ? eccStatus === 'enabled' : null,
  408. clockSpeed: parseInt(util.getValue(lines, ' Speed:'), 10),
  409. formFactor: '',
  410. manufacturer: getManufacturerDarwin(util.getValue(lines, ' Manufacturer:')),
  411. partNum: util.getValue(lines, ' Part Number:'),
  412. serialNum: util.getValue(lines, ' Serial Number:'),
  413. voltageConfigured: null,
  414. voltageMin: null,
  415. voltageMax: null,
  416. });
  417. } else {
  418. result.push({
  419. size: 0,
  420. bank: bank,
  421. type: 'Empty',
  422. ecc: null,
  423. clockSpeed: 0,
  424. formFactor: '',
  425. manufacturer: '',
  426. partNum: '',
  427. serialNum: '',
  428. voltageConfigured: null,
  429. voltageMin: null,
  430. voltageMax: null,
  431. });
  432. }
  433. });
  434. }
  435. if (!result.length) {
  436. const lines = stdout.toString().split('\n');
  437. const size = parseInt(util.getValue(lines, ' Memory:'));
  438. const type = util.getValue(lines, ' Type:');
  439. if (size && type) {
  440. result.push({
  441. size: size * 1024 * 1024 * 1024,
  442. bank: '0',
  443. type,
  444. ecc: false,
  445. clockSpeed: 0,
  446. formFactor: '',
  447. manufacturer: 'Apple',
  448. partNum: '',
  449. serialNum: '',
  450. voltageConfigured: null,
  451. voltageMin: null,
  452. voltageMax: null,
  453. });
  454. }
  455. }
  456. if (callback) { callback(result); }
  457. resolve(result);
  458. });
  459. }
  460. if (_sunos) {
  461. if (callback) { callback(result); }
  462. resolve(result);
  463. }
  464. if (_windows) {
  465. const memoryTypes = 'Unknown|Other|DRAM|Synchronous DRAM|Cache DRAM|EDO|EDRAM|VRAM|SRAM|RAM|ROM|FLASH|EEPROM|FEPROM|EPROM|CDRAM|3DRAM|SDRAM|SGRAM|RDRAM|DDR|DDR2|DDR2 FB-DIMM|Reserved|DDR3|FBD2|DDR4|LPDDR|LPDDR2|LPDDR3|LPDDR4'.split('|');
  466. const FormFactors = 'Unknown|Other|SIP|DIP|ZIP|SOJ|Proprietary|SIMM|DIMM|TSOP|PGA|RIMM|SODIMM|SRIMM|SMD|SSMP|QFP|TQFP|SOIC|LCC|PLCC|BGA|FPBGA|LGA'.split('|');
  467. try {
  468. util.powerShell('Get-WmiObject Win32_PhysicalMemory | select DataWidth,TotalWidth,Capacity,BankLabel,MemoryType,SMBIOSMemoryType,ConfiguredClockSpeed,FormFactor,Manufacturer,PartNumber,SerialNumber,ConfiguredVoltage,MinVoltage,MaxVoltage | fl').then((stdout, error) => {
  469. if (!error) {
  470. let devices = stdout.toString().split(/\n\s*\n/);
  471. devices.shift();
  472. devices.forEach(function (device) {
  473. let lines = device.split('\r\n');
  474. const dataWidth = util.toInt(util.getValue(lines, 'DataWidth', ':'));
  475. const totalWidth = util.toInt(util.getValue(lines, 'TotalWidth', ':'));
  476. const size = parseInt(util.getValue(lines, 'Capacity', ':'), 10) || 0;
  477. if (size) {
  478. result.push({
  479. size,
  480. bank: util.getValue(lines, 'BankLabel', ':'), // BankLabel
  481. type: memoryTypes[parseInt(util.getValue(lines, 'MemoryType', ':'), 10) || parseInt(util.getValue(lines, 'SMBIOSMemoryType', ':'), 10)],
  482. ecc: dataWidth && totalWidth ? totalWidth > dataWidth : false,
  483. clockSpeed: parseInt(util.getValue(lines, 'ConfiguredClockSpeed', ':'), 10) || parseInt(util.getValue(lines, 'Speed', ':'), 10) || 0,
  484. formFactor: FormFactors[parseInt(util.getValue(lines, 'FormFactor', ':'), 10) || 0],
  485. manufacturer: util.getValue(lines, 'Manufacturer', ':'),
  486. partNum: util.getValue(lines, 'PartNumber', ':'),
  487. serialNum: util.getValue(lines, 'SerialNumber', ':'),
  488. voltageConfigured: (parseInt(util.getValue(lines, 'ConfiguredVoltage', ':'), 10) || 0) / 1000.0,
  489. voltageMin: (parseInt(util.getValue(lines, 'MinVoltage', ':'), 10) || 0) / 1000.0,
  490. voltageMax: (parseInt(util.getValue(lines, 'MaxVoltage', ':'), 10) || 0) / 1000.0,
  491. });
  492. }
  493. });
  494. }
  495. if (callback) { callback(result); }
  496. resolve(result);
  497. });
  498. } catch (e) {
  499. if (callback) { callback(result); }
  500. resolve(result);
  501. }
  502. }
  503. });
  504. });
  505. }
  506. exports.memLayout = memLayout;