Products > Test Equipment
Open source EEZ Studio for accessing your (SCPI) instruments
mvladic:
Hello Pjoms!
You need to await for command to finish, like this:
--- Code: ---var chargeCurr
connection.acquire();
chargeCurr = await connection.command('MEAS:CURR? CH1');
connection.release();
console.log(chargeCurr);
--- End code ---
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
Pjoms:
Thanks! Another major thing was the need to use connection.query instead of connection.command.
chargeCurr = await connection.query(`MEAS:CURR? CH1`);
Pjoms:
Now I'm in some deep water here, as a totally beginner in Java Script...
I have copied the code for the input dialog from the script "Dlog start" and modified it for my purpurs.
It went quite well, but suddenly, and for me without any obvious reason, the script stopped to work.
After some frustrating, testing, more frustrating and testing (without knowing what I'm doing or what the error messages means...) it turns out that it works just fine if I just change the name for the storage.getItem!
My best guess is that it is an array that has been messed up some way.
I'm using the EEZ PSU software simulator ver. v1.1 as instrument by the way.
Can someone bring some light over my confusion here...?
The original lines in Dlog start
--- Code: ---var defaultValues = storage.getItem("EezDlogValues", {
...
storage.setItem("EezDlogValues", values);
--- End code ---
My lines that not working anymore
--- Code: ---var defaultValues = storage.getItem("LiPoChargeValues", {
...
storage.setItem("LiPoChargeValues", values);
--- End code ---
If I just change the name, the code works...
--- Code: ---var defaultValues = storage.getItem("LiPoChargeValuesX", {
...
storage.setItem("LiPoChargeValuesX", values);
--- End code ---
The console give me this messages then I try to run the script, but I'm afraid that I'm not able to understand much of it...
--- Code: ---Uncaught TypeError: Cannot read property 'toFixed' of undefined
at Object.roundNumber (C:\Program Files\EEZ Studio\resources\app.asar\dist\eez-studio-shared\roundNumber.js:11)
at TimeUnit.formatValue (C:\Program Files\EEZ Studio\resources\app.asar\dist\eez-studio-shared\units.js:19)
at TimeUnit.formatValue (C:\Program Files\EEZ Studio\resources\app.asar\dist\eez-studio-shared\units.js:116)
at GenericDialog.props.dialogDefinition.fields.forEach.fieldProperties (C:\Program Files\EEZ Studio\resources\app.asar\dist\eez-studio-ui\generic-dialog.js:49)
at Array.forEach (<anonymous>)
at new GenericDialog (C:\Program Files\EEZ Studio\resources\app.asar\dist\eez-studio-ui\generic-dialog.js:47)
at zf (C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:127)
at Wg (C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:163)
at ah (C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:176)
at hi (C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:221)
roundNumber @ C:\Program Files\EEZ Studio\resources\app.asar\dist\eez-studio-shared\roundNumber.js:11
formatValue @ C:\Program Files\EEZ Studio\resources\app.asar\dist\eez-studio-shared\units.js:19
formatValue @ C:\Program Files\EEZ Studio\resources\app.asar\dist\eez-studio-shared\units.js:116
GenericDialog.props.dialogDefinition.fields.forEach.fieldProperties @ C:\Program Files\EEZ Studio\resources\app.asar\dist\eez-studio-ui\generic-dialog.js:49
GenericDialog @ C:\Program Files\EEZ Studio\resources\app.asar\dist\eez-studio-ui\generic-dialog.js:47
zf @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:127
Wg @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:163
ah @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:176
hi @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:221
ii @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:222
Ki @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:238
fi @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:234
uf @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:232
Si @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:252
Ti @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:252
Yi.render @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:260
(anonymous) @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:263
Qi @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:249
aj @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:263
render @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:265
showDialog @ C:\Program Files\EEZ Studio\resources\app.asar\dist\eez-studio-ui\dialog.js:125
Promise @ C:\Program Files\EEZ Studio\resources\app.asar\dist\eez-studio-ui\generic-dialog.js:260
showGenericDialog @ C:\Program Files\EEZ Studio\resources\app.asar\dist\eez-studio-ui\generic-dialog.js:259
resolve @ C:\Program Files\EEZ Studio\resources\app.asar\dist\instrument\window\script.js:23
input @ C:\Program Files\EEZ Studio\resources\app.asar\dist\instrument\window\script.js:22
(anonymous) @ VM536:16
(anonymous) @ C:\Program Files\EEZ Studio\resources\app.asar\dist\eez-studio-shared\script-engines\javascript.js:20
(anonymous) @ C:\Program Files\EEZ Studio\resources\app.asar\dist\eez-studio-shared\script-engines\javascript.js:7
__awaiter @ C:\Program Files\EEZ Studio\resources\app.asar\dist\eez-studio-shared\script-engines\javascript.js:3
run @ C:\Program Files\EEZ Studio\resources\app.asar\dist\eez-studio-shared\script-engines\javascript.js:12
doExecuteShortcut @ C:\Program Files\EEZ Studio\resources\app.asar\dist\instrument\window\script.js:224
executeShortcut @ C:\Program Files\EEZ Studio\resources\app.asar\dist\instrument\window\script.js:253
executeShortcut @ C:\Program Files\EEZ Studio\resources\app.asar\dist\instrument\window\terminal\terminal.js:257
executeShortcut @ C:\Program Files\EEZ Studio\resources\app.asar\dist\instrument\window\terminal\toolbar.js:76
onClick @ C:\Program Files\EEZ Studio\resources\app.asar\dist\eez-studio-ui\action.js:26
da @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:14
ka @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:15
la @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:15
ya @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:17
Ca @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:18
Aa @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:18
Fa @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:21
Gd @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:84
Pi @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:249
Nb @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:39
Jd @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:86
Ri @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:250
Id @ C:\Program Files\EEZ Studio\resources\app.asar\node_modules\react-dom\cjs\react-dom.production.min.js:85
--- End code ---
I don't know if this means anything, but sometimes then I just scrolling in the code the console spits out a burst of messages like this.
--- Code: ---Uncaught TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'.
at a.scrollLines (index.min.js:1)
at p.$renderChanges (index.min.js:1)
at index.min.js:1
scrollLines @ index.min.js:1
$renderChanges @ index.min.js:1
(anonymous) @ index.min.js:1
requestAnimationFrame (async)
schedule @ index.min.js:1
scrollToY @ index.min.js:1
onScrollTopChange @ index.min.js:1
n._signal @ index.min.js:1
setScrollTop @ index.min.js:1
$computeLayerConfig @ index.min.js:1
$renderChanges @ index.min.js:1
(anonymous) @ index.min.js:1
requestAnimationFrame (async)
schedule @ index.min.js:1
scrollToY @ index.min.js:1
onScrollTopChange @ index.min.js:1
n._signal @ index.min.js:1
setScrollTop @ index.min.js:1
scrollBy @ index.min.js:1
onMouseWheel @ index.min.js:1
n._emit.n._dispatchEvent @ index.min.js:1
onMouseWheel @ index.min.js:1
(anonymous) @ index.min.js:1
--- End code ---
mvladic:
Nothing is wrong with the "LiPoChargeValues" name per se. Problem is what is currently stored under that name in local storage. For some reason it contains invalid value for some of the fields. Can you open console, print the contents of "LiPoChargeValues" like this:
--- Code: ---console.log(JSON.stringify(storage.getItem("LiPoChargeValues")))
--- End code ---
and send here the result.
Pjoms:
The console returns the follow:
--- Code: ---{"startCurrent":1.5,"stopCurrent":0.1,"maxChargeTime":10}
--- End code ---
It turns out that if I use these exact variabels the script work, but if I change a name or add an other variable it dosen't work anymore.
Then if I change the name as I mentioned before, the code works again. After that it looks like it is "locked" to this structure.
It also looks like those values lives even outside the actual script, eg it is possible to access from another script.
Is there a need or a way to clear or reset the string/array someway then changes are done?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version