I have a node's server embedded in the Raspberry Pi as well as an external board attached with an A/D and a D/A converter. When all parameters are completed and a button is pressed in the website, It is generated several voltage to an external circuit as well as sensed voltages are stored in a vector like ANI0. The main idea is to measure the current at each voltage using a Mathematical expression like Mathexp. Whereby I need to evaluate these operation for each value comprised in ANIO. The expression is in string cause is introduced by the user in the web page. I tried using the command eval to evaluate it but it did not work. Is it even possible to do this procedure using some commands??
var ANI0 = [0.0,0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0];
var Mathexp; //operation inserted by the user in the webpage in a input text
Mathexp = '(ANIO[i]-0.01)/20'; //Example
for (i=0; I<ANIO.length; i++){
singleObj = {};
singleObj['voltage'] = eval(xScale);
singleObj['current'] = eval(Mathexp);
listOfObjects.push(singleObj);
}
//generate a jsonFILE in order to graph results with metrics graphics
myJSON = JSON.stringify(listOfObjects);
fs.writeFile("public/data/file.json", myJSON, function(err){
if(err){console.log(err);} else {console.log("archivo guardado..");}
});
socket.emit('graphEvent',{message: ':)'});
enter code here