TwinCAT HMI new Internal Symbol from code

128 views Asked by At

Is there a way to create an Internal Symbol from code?

I tried using CodeBehind.ts with the following code:

module TcHmi {
    let destroyOnInitialized = TcHmi.EventProvider.register('onInitialized', (e, data) => {
        e.destroy();
        let newSymbol = new TcHmi.Symbol<Number>('%i%myNewNumber%/i%');
        newSymbol.write(10, (data) => {
            console.log('Result::' + data.value);
            console.log('Error::' + data.error);
            console.log('Details::Reason::' + data.details?.reason);
        });
    });
}

And this resulted in:

Result::undefined
Error::2002
Details::Reason::%i%myNewNumber%/i%:Failed to resolve schema definition.

I tried using:

TcHmi.System.Services.internalSymbolManager.add('myNewNumber', newSymbol);

But newSymbol does not implement IInternalSymbolItem, and I couldn't find anything that does.

And generally, from the documentation, internalSymbolManager should not be used by the users.

0

There are 0 answers