Wincc Softkey Program
Wincc Softkey Program
state. But your use case is very interesting. So I used a lot of expressions within the softkey tag and found a
solution to indicate an active or inactive status. You need bitmaps for that.
If we take a look at the manual machine there are bitmaps used. And that is what you can use at the
moment.
For the softkey tag is an attribute defined that assigns a bitmap to a softkey. This bitmap is left aligned. (I
do not know how to change it.) The bitmap on the softkey reduces the number of text characters depending
on the bitmap width. The text is moved in direction of the right border.
Disadvantage: You need separate menus to control it. No conditional instructions (if ) can be used to
changed the bitmap assignment within the softkey tag.
The bit set operation can be done within the soft-key tag. This tag seems to be a mix of properties and
executable instructions. You can add an operation tag to set your PLC bit. It must be written before the
navigation tag.
<navigation>main_pressed</navigation>
</softkey>
</menu>
During my tests I found out that the conditional, loop and functional instructions can be used to control the
script. These are executed in case if a button has been pressed. It does not work for properties during the
initialization.
Below you will find small script parts which use the different tags.
<let name="val">2</let>
…
…
…
<increment>
<op> val = val + 1 </op>
</increment>
<navigation>main_pressed</navigation>
</softkey>
------------------------------------------------------------------------------------------
<function_body name="print_text">
<print text="mb158 set" />
</function_body>
<navigation>main_pressed</navigation>
</softkey>
Yesterday I did not see the easy solution to change the bitmap and the caption text on a soft-key.
But after I send you the latest reply, I got the idea to manage the whole functionality into one menu. You
need an IF-condition around your softkey. Depending on the PLC bit you set the off / on text and bitmap.
Then you navigate to the same menu.
With these modifications you are able to manage more than one PLC bits with a soft-key row.
<if>
<condition>("PLC/mb158" & 1) == 0</condition>
<then>
<softkey POSITION="1" picture="f:\appl\red_led_off.bmp" >
<caption>Func.%nOff</caption>
<op> "PLC/mb158" = "PLC/mb158" | 1 </op>
<function name="print_text" />
<navigation>main</navigation>
</softkey>
</then>
<else>
<softkey POSITION="1" picture="f:\appl\red_led_on.bmp">
<caption>Func.%nOn</caption>
<op> "PLC/mb158" = "PLC/mb158" & (255 - 1)</op>
<function name="print_text" />
<navigation>main</navigation>
</softkey>
</else>
</if>
<!-- ----------------------------------------------------------------------------- -->
<if>
<condition>("PLC/mb158" & 2) == 0 </condition>
<then>
<softkey POSITION="2" picture="f:\appl\red_led_off.bmp" >
<caption>Func.2%nOff</caption>
<op> "PLC/mb158" = "PLC/mb158" | 2 </op>
<function name="print_text" />
<navigation>main</navigation>
</softkey>
</then>
<else>
<softkey POSITION="2" picture="f:\appl\red_led_on.bmp">
<caption>Func.2%nOn</caption>
<op> "PLC/mb158" = "PLC/mb158" & (255 - 2)</op>
<function name="print_text" />
<navigation>main</navigation>
</softkey>
</else>
</if>
<!-- ----------------------------------------------------------------------------- -->
</menu>
My fault. In was the opinion you need a switcher but in your previous message you mentioned the
SetBitWhilePressButton–function from WinCC. I do not know WinCC so I misinterpreted the set-while-
press-button function call. I guess you need a push button – right?
When we consider the key reaction of the 802d sl, we can find a repeat mode (see program editor; you can
keep the finger on the key and after a time all xxx ms a new character is shown) and an non repeat mode (if
you press a soft-key for instance G-function; The window is direct opened after the soft-key has been
pressed).
So, I am the opinion you will not get a pure key press and release status. You get a soft-key event created
by pressing the key but the release status is not delivered to the script.
During the execution of script instructions the soft-key shows the pressed face.