- HMI Model: cMT-FHDX-820
- EasyBuilder Pro Version: 6.10.01.422
Hi everyone,
I’m currently working on customizing a chart using JavaScript, based on one of the official Weintek templates.
Template - Tutorial: Chart.js Demo - JS Action/Object SDK
I’m trying to dynamically link Weintek variables to populate the chart, but I’m running into an issue where the values being displayed are static/fallback values — which leads me to think that the variables are not being linked correctly.
Here’s the function I’m using to get the variable data:
// Function to get data from Weintek variables
async function getWeintekData() {
try {
// Array of Weintek variable names for each chart bar
const variableNames = [
'SX_ES1', 'DX_ES1',
'SX_ES2', 'DX_ES2',
'SX_ES3', 'DX_ES3',
'SX_ES4', 'DX_ES4',
'SX_ES5', 'DX_ES5',
'SX_ES6', 'DX_ES6',
'SX_ES7', 'DX_ES7',
'SX_ES8', 'DX_ES8'
];
const values = [];
for (const varName of variableNames) {
const data = await driver.promises.getData(this.config[varName], 1);
values.push(data.values[0]);
}
return values;
} catch (error) {
console.error("Error retrieving data:", error);
// Return default values if something goes wrong
return [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20];
}
}
The issue is that I always see these fallback values (10, 20, ...
), even though the variables exist and are correctly named.
It seems like the this.config[varName]
part might not be resolving correctly. Could someone point me in the right direction on how to properly bind Weintek variables in this context? Or is there something I might be missing in the config
object initialization?
Any help would be greatly appreciated!
Thanks in advance.