User Tools

Site Tools


plc:plc_show_custom_message_box:old_version

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

plc:plc_show_custom_message_box:old_version [2019/05/17 09:54] (current)
ivan created
Line 1: Line 1:
 +=====Showing a custom message box in older software=====
  
 +In [[plc:​plc_gas_cutting_implementation|previous article]] we showed how to implement oxyfuel gas cutting procedure. Preheat process in gas cutting can last 30-120 seconds. It is convenient to have on screen message that shows preheat progress. Let's add message box with preheat progress countdown for gas cutting.
 +
 +Global variables 9100-9163 are reserved to show/hide enumerated Popup message box.
 +Writing "​1"​ to register (9100+N) will show Message Box #N on the main screen. Writing "​0"​ will hide the Message Box.
 +
 +Content for message box #0...#63 defined in cnc-variables.xml configuraton file by item **cnc-popup-message-0** ... **cnc-popup-message-15** ​
 +
 +<code xml>
 +<value name="​cnc-popup-message-0" ​
 +  header="​Preheat Countdown"​ footer="​sec"​ message="​%d" ​
 +  headerHeight="​60"​ footerHeight="​30"​ width="​300"​ height="​150"​
 +  fontSize="​60"​ headerFontSize="​30"​ footerFontSize="​20" ​
 +  timeout="​5"​ dest="​cnc-gvariable-99"​ K="​0.001">​0</​value>​
 +</​code>​
 +
 +Message box contains 3 lines. Lines defined by attributes **header** (top line), **message** (middle line), **footer** (bottom line). Font size for each line defines by attributes **headerFontSize**,​ **fontSize** and **footerFontSize**
 +
 +Line height for each line defined by attributes **headerHeight**,​ **height** and **footerHeight**.
 +
 +Attributes **width** and **height** define message box width and height in pixels.
 +Popup Messagebox will be automatically hidden if variable value was not changed longer than time defined in **timeout** attribute.
 +
 +Parameter value can be printed in Message Box. To print a value - 
 +  * Message attribute should contain C-style contains format line (ie "​%d",​ "​%7.3f"​)
 +  * Attribute **dest** should define variable number ​
 +  * Attribute **K** defines scale ratio.
 +
 +For example if 
 +  * message="​%d"​
 +  * dest="​cnc-gvariable-99" ​
 +  * K="​0.001"​
 +
 +Variable #99 value multiplied by K-ratio will be printed: if variable value is 95000, value **95** will be shown.
 +
 +{{plc:​mycnc-eco-popup-message-01.png}}
 +
 +Source code to show Message Popup is 
 +<code c>
 +  gvarset(9100,​1); ​ //show the Message Box
 +  portset(OUTPUT_OXY_HEAT_HI);​ //turn ON preheat Valve
 +  timer=time_preheat;​
 +  break_heating=1;​ //​Set Heating variable. ​
 +  //if the value will be clearen outside of PLC, abort Preheat procedure
 +  do {
 +    timer--;
 +    if (portget(6)!=0) //​if start key is pressed - start piercing
 +      {
 + timer=0;​ //​exit from heating
 +      };
 +    if (break_heating==0) ​  //if start key is pressed - start piercing
 +      {
 + timer=0;​  ​   //exit from heating
 +      };
 +    if ((timer&​0xff)==0)
 +      {
 + gvarset(99,​timer);​ //update Countdown value every 256msec
 +      };
 +   ​}while(timer>​0); ​       //Preheat loop
 +
 +  gvarset(9100,​0); ​        //​hide Message Box
 +</​code>​
plc/plc_show_custom_message_box/old_version.txt ยท Last modified: 2019/05/17 09:54 by ivan