@liv-in-sky
Hallo liv-in-sky
Meine Antwort hat ein wenig länger gedauert.
Danke für die Codefragmente. Die haben mich auf den richtigen Pfad gebracht. Hier ist nun der Code, wie ich das umgesetzt habe. Wichtig war mir, dass die Abfrage synchron abgehandelt wird. Dabei gilt es zu beachten, dass alle übergeordneten Funktionen ebenfalls mit sync deklariert sind.
Hier die Funktion GetState
async function GetState (strDataPoint, oDPValue) {
return await new Promise((resolve, reject) => {
window.servConn.getStates([strDataPoint], (error, states) => {
console.log(++iStepCount+": 1. oDPValue.iVal = " + oDPValue.iVal);
oDP = states[strDataPoint];
if (oDP !== null)
{
resolve(oDPValue.iVal = states[strDataPoint].val);
}
else
{
reject(Error("The specified data point does not exist! DP: "
+ strDataPoint));
}
console.log(++iStepCount+": 2. oDPValue.iVal = " + oDPValue.iVal);
});
});
}
Und hier der Aufruf im Code.
async function dcmbInit (id, dcmbDefinition, strDeviceAddress)
{
/* exp. 'alias.0.Gang_OG.Deckenspots.Lichtstärke.val' */
console.log("strDeviceAddress = " + strDeviceAddress);
if (strDeviceAddress !== undefined && strDeviceAddress !== null)
{
oValue = { iVal: 0 };
await GetState(strDeviceAddress + ".Lichtstärke", oValue);
console.log("dcmbInit: iValue = " + oValue.iVal);
}
return false;
}