Gets the last value

In the development of the SDK module, can I directly obtain the last value and time of the tag without queryhistory? For example, if the tag changes from 0 to 10, can I obtain the value 0 and time before 10 in the code

you can subscribe for tag change and keep in your module the previous value and timestamp

http://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.0/com/inductiveautomation/ignition/common/tags/model/TagManager.html

subscribeAsync

1 Like

i see

When I change value, why does it execute many times (3 times)

    public void tagChanged(TagChangeEvent tagChangeEvent) throws InvalidListenerException {
                    double random = Math.random();
                    logger.info("value:"+String.valueOf(tagChangeEvent.getValue()));
                    logger.info("随机数:"+String.valueOf(random));
                    logger.info("路劲"+String.valueOf(tagChangeEvent.getTagPath()));
                }