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

using MAP function

using MAP function

RobotART_Walter
Long-established Member

Hello,

I am trying to use the MAP function to convert an INT value to text and display this with an label.

However, I am a bit lost. I cannot seem to get it working. 

My localized text looks like this:

RobotART_Walter_0-1678197734253.png

My label looks like this:

RobotART_Walter_1-1678197813633.png

This doesnt work, the label still shows the INTvalue:

RobotART_Walter_0-1678198977083.png

 

Is it possible what I am trying to do and if yes what am I doing wrong? 

Thank you in advance!

 

 

3 REPLIES 3

webiq-sk
Frequent Contributor

There's no need to do some complex mapping which doesn't even work there as you seem to assume behavior that is not documented and neither intended nor working in that area. The map function is defined in "15.3.3. Use Of Numeric Status Info In Alarm Texts" in the manual and as such works with alarms texts, but this is not an alarm text.

The correct way with WebIQ would to be setup the options in the IQ Label widget you're already using to map the values to texts/localizations.

 

RobotART_Walter
Long-established Member

Thank you!

I was not aware that I could do it that way. 

It works perfecty!

There is also another possibility, which is especially interesting when it is necessary to convert a lot of numbers into texts.

e.g. If the PLC sends status messages as numbers, which should be displayed as text in the active language.

  • PLC sets interger variable iStatus
  • Range of iStatus 0-100
  • Define localisation variables "Status000" - "Status100"
    • Status000:  "Stopped"
    • Status001:  "Prepering"
    • Status002:  "Running"
    •        :
    • Status100:  "Done"
  • Define and use function localize (see article Integer-in-hex-notation )
/**
 * returns the translation for the localization variable whose name is created dynamically
 * @param {string} sPrefix 
 * @param {int} iValue 
 * @returns translation text defined by inputs
 * @example
 // java script
    console.log(cxt.localize("state", 1)) // returns value of localization var: state001
    // usage in iq-text where items[0] is an integer
    <%= localize("state", items[0].value) %>
    */
localize(sPrefix, iValue) {
    return shmi.localize("${" + sPrefix + ("" + iValue).padStart(3, "0") + "}")
}

 

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