0% found this document useful (0 votes)
84 views

Wincc Softkey Program

The document discusses using bitmaps and softkey tags to indicate an active or inactive status on a machine interface. It provides instructions for assigning bitmaps to softkeys to represent different states. Conditional instructions like "if" statements cannot be used to change the bitmap assignment within the softkey tag. The document also provides a potential solution to set a PLC bit when a softkey is pressed and reset it when the softkey is released, similar to the SetBitWhilePressButton function in WinCCFlex.

Uploaded by

scorpionking888
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views

Wincc Softkey Program

The document discusses using bitmaps and softkey tags to indicate an active or inactive status on a machine interface. It provides instructions for assigning bitmaps to softkeys to represent different states. Conditional instructions like "if" statements cannot be used to change the bitmap assignment within the softkey tag. The document also provides a potential solution to set a PLC bit when a softkey is pressed and reset it when the softkey is released, similar to the SetBitWhilePressButton function in WinCCFlex.

Uploaded by

scorpionking888
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

There is no attribute or property defined (could not find something in the documentation) to get the pressed

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.

Here are the Instructions:

<menu name = "main">


<open_form name = "main dialogue" />
<softkey POSITION="1" picture="f:\appl\red_led_off.bmp">
<caption>Func.%nOff</caption>
<navigation>main_pressed</navigation>
</softkey>
</menu>

<menu name = "main_pressed">


<open_form name = "main dialogue" />
<softkey POSITION="1" picture="f:\appl\red_led_on.bmp">
<caption>Func.%nOn</caption>
<navigation>main</navigation>
</softkey>
</menu>

I got it. Thank you very much.


I also wished to use function, as in WinCCFlex: SetBitWhilePressButton.
As though it to make?

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.

<menu name = "main">


<open_form name = "main dialogue" />

<softkey POSITION="1" picture="f:\appl\red_led_off.bmp">


<caption>Func.%nOff</caption>

<op> "PLC/mb158" = "PLC/mb158" | 1 </op>

<navigation>main_pressed</navigation>
</softkey>
</menu>

<menu name = "main_pressed">


<open_form name = "main dialogue" />
<softkey POSITION="1" picture="f:\appl\red_led_on.bmp">
<caption>Func.%nOn</caption>

<op> "PLC/mb158" = "PLC/mb158" & (255 - 1)</op>


<navigation>main</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>


<softkey POSITION="1" picture="f:\appl\red_led_off.bmp">


<caption>Func.%nOff</caption>
<if>
<condition> val == 1 </condition>
<then>
<op> "PLC/mb158" = "PLC/mb158" | 1 </op>
</then>
<else>
<op> "PLC/mb158" = "PLC/mb158" | 2 </op>
</else>
</if>
<navigation>main_pressed</navigation>
</softkey>
---------------------------------------------------------------------------------------------

<softkey POSITION="1" picture="f:\appl\red_led_off.bmp">


<caption>Func.%nOff</caption>
<for>
<init>
<op> val = 1 </op>
</init>
<condition> val < 16 </condition>

<increment>
<op> val = val + 1 </op>
</increment>

<op> "PLC/mb158" = "PLC/mb158" | val </op>


</for>
<navigation>main_pressed</navigation>
</softkey>
---------------------------------------------------------------------------------

<softkey POSITION="1" picture="f:\appl\red_led_off.bmp">


<caption>Func.%nOff</caption>
<op> val = 1 </op>
<while>
<condition> val < 16 </condition>
<op> "PLC/mb158" = "PLC/mb158" | val </op>
<op> val = val + 1 </op>
</while>

<navigation>main_pressed</navigation>
</softkey>

------------------------------------------------------------------------------------------

<function_body name="print_text">
<print text="mb158 set" />
</function_body>

<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_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.

(the function call is only for fun)

Script see below:

<menu name = "main">


<open_form name = "main dialogue" />

<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>

Thanks you for the help.


Your decisions are very beautiful.

But little bit another is necessary for me.


I wish to set bit in PLC while the softkey is pressed.
I wish to reset bit in PLC when the softkey is wrung out.

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.

What you can use is:


Soft-key is pressed (unknown when it will be released)
Interpreter runs into the script part
You can set the PLC-bit; <op> "PLC/mb158" = "PLC/mb158" | 1 </op>
Do something else
You reset the bit; <op> "PLC/mb158" = "PLC/mb158" & (255 - 1)</op>
Leave the script part (the soft-key is still pressed or already released)

During the execution of script instructions the soft-key shows the pressed face.

<op> "PLC/mb158" = "PLC/mb158" | 1 </op> equal to <op> "PLC/m158.0" = 1 </op>


<op> "PLC/mb158" = "PLC/mb158" & (255 - 1)</op> equal to <op> "PLC/m158.0" = 0 </op>

You might also like