Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important information on the platform change.

cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

dynamic precision on displayed value

dynamic precision on displayed value

Anonymous
Not applicable

Hello all,

I try to design a Web HMI with the WebIQ HMI Designer. I want to have the precision (number of digits) on dsiplayed value according to a process variable. Is that possible?

We have different machines with different speed ranges. Sometimes we want to show 1 digit and sometimes 2 digits on speed value. We have a tag (INT) that tells number of digits.

Greetings

Börje

3 REPLIES 3

webiq-eg
Long-established Member

Hello, thanks for the question.
The decimal places can be set in two ways:
1.) Directly in the configuration of the widgets (e.g. iq-input-field or iq-text-display):

webiqeg_0-1629979057182.png

 


2.) When configuring the process variables in the Process Data Manager. If this variable is then used in a widget, this setting is used as the default:

webiqeg_1-1629979158655.png


Hope that answers your question.
Many greetings
webiq-eg

Anonymous
Not applicable

Hello

Yes, but I want it dynamic. Can you somehow have it dynamic and dependign on a tag vealue?

We have a tag that is 0 when we want 0 decimal places, 1 when we want 1 decimal places and so on.

webiq-eg
Long-established Member

Hello,
you can do it with a little Script, which you can embed into a 'LocalScrip' Widget. I enclosed an example app which demonstrates it and you can try it out.

 /**
     * Implements local-script run function.
     *
     * This function will be called each time a local-script will be enabled.
     *
     * @param {LocalScript} self instance reference of local-script control
     */
    module.run = function (self) {
        const im = shmi.requires("visuals.session.ItemManager");
        let tok = null,
            ctrl=null;
        ctrl = shmi.ctrl(".iq-text-display"); // get the reference to the Widget to apply the dynamic digit position
        if (ctrl) {
            // e.g. 'SInt' is the process data value to switch the digits
            // Subscribe 'SInt', this means the callback function will be called each time, the process value changes
            tok = im.subscribe(["SInt"], (name, value, type) => { 
                if (value) {
                    ctrl.config.precision = 4;
                } else {
                    ctrl.config.precision = 3;
                }
                ctrl.disable(); // reinitialize the Widget
                ctrl.enable();
            });
        } else {
            shmi.notify("Widget not found");
        }
        //Place your Code here

        /* called when this local-script is disabled */
        self.onDisable = function () {
            tok.unlisten(); // free the resources of the subscription
            self.run = false; /* from original .onDisable function of LocalScript control */
        };
    };

Hope that helps.
Regards webiq-eg

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist