From cfa45aa09bfcc83ff4e114fe703e6e19038c39ac Mon Sep 17 00:00:00 2001 From: Sylvain Mariel Date: Sat, 11 Jan 2020 17:52:29 +0100 Subject: [PATCH] Input Voltage Limit (#72) --- html/itemEditor.html | 52 ++++++++++++++++++++++++++--------------- js/class.Item.Source.js | 20 ++++++++++++---- main.js | 9 +++++-- 3 files changed, 56 insertions(+), 25 deletions(-) diff --git a/html/itemEditor.html b/html/itemEditor.html index ea4e253..1b948ef 100644 --- a/html/itemEditor.html +++ b/html/itemEditor.html @@ -106,14 +106,6 @@

Characteristics

- -
-
- - -
-
-
@@ -131,17 +123,6 @@

Characteristics

- - -
- -
-
-
-
-
- -
@@ -172,6 +153,39 @@

Feadback

+ + + +
+

Limits

+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
+
+
+ +
+
diff --git a/js/class.Item.Source.js b/js/class.Item.Source.js index 64be573..76ddd30 100644 --- a/js/class.Item.Source.js +++ b/js/class.Item.Source.js @@ -36,6 +36,7 @@ class Source extends Item { vout_min : '1.78', vout_typ : '1.8', vout_max : '1.82', + vin_limit : '0', // v1.8.0, 0=no limit iout_limit : '0', // v1.8.0, 0=no limit r1 : '150000', r2 : '120000', @@ -475,13 +476,24 @@ class Source extends Item { } } + // Check if Vin < vin_limit + let vin_limit = parseFloat(this.characs.vin_limit); + if(vin_limit !== 0) { + for(let valType of ['typ', 'max']) { + let vin = this.getInputVoltage(valType); + if((vin > 0 && vin > vin_limit) || (vin < 0 && vin < vin_limit)) { + alerts.push(`VIN ${valType.toUpperCase()} (${vin}V) exceeds the input voltage limit (${vin_limit}V).`); + } + } + } + // Check if Iout < iout_limit - let ilimit = parseFloat(this.characs.iout_limit); - if(ilimit !== 0) { + let iout_limit = parseFloat(this.characs.iout_limit); + if(iout_limit !== 0) { for(let valType of ['typ', 'max']) { let iout = this.getOutputCurrent(valType); - if(Math.abs(iout) > Math.abs(ilimit)) { - alerts.push(`IOUT ${valType.toUpperCase()} is higher than the output current limit (|${iout}| > |${ilimit}|).`); + if((iout > 0 && iout > iout_limit) || (iout < 0 && iout < iout_limit)) { + alerts.push(`IOUT ${valType.toUpperCase()} (${iout}A) exceeds the output current limit (${iout_limit}A).`); } } } diff --git a/main.js b/main.js index c413272..14ebf75 100644 --- a/main.js +++ b/main.js @@ -10,6 +10,7 @@ const app = electron.app; const BrowserWindow = electron.BrowserWindow; // Electron module to send/receive message with all renderers const ipcMain = electron.ipcMain; + // Node.js module to access File System const fs = require('fs'); // Node.js module to work with paths @@ -270,10 +271,14 @@ ipcMain.on('Item-editReq', (evt, itemStr, itemType) => { // save the event to respond to this msg later renderers.itemEditor.reqEvent = evt; + // Electron module to get screen informations + const screen = electron.screen; + const maxWidth = screen.getPrimaryDisplay().workAreaSize.width; + // Create the itemEditor window renderers.itemEditor.browserWindow = new BrowserWindow({ - width : ('source' == itemType) ? 1000 : 650, - height : ('source' == itemType) ? 720 : 485, + width : ('source' == itemType) ? (1300>maxWidth)?maxWidth:1300 : 650, + height : ('source' == itemType) ? 540 : 485, parent : renderers.PTree.browserWindow, modal : true, resizable : false,