Hi there!
Are there any possibility to generate popup SmartHMI windows like a picture below from KRL? Maybe it's a kind of dialog window?
KSS 8.5~8.6
Thanks!
Hi there!
Are there any possibility to generate popup SmartHMI windows like a picture below from KRL? Maybe it's a kind of dialog window?
KSS 8.5~8.6
Thanks!
not exactly, but you could get similar thing using dialog. note that dialog must have at least one button or it will not show up, and if button is clicked, dialog will go away. so you need to display it again as long as "busy" is in progress and remove it when not busy.
In KRL, the SET_KRLDLG function is passed the message text, an array of text values for each button, some parameters, and passes back an integer "handle" attached to the dialog box that SET_KRLDLG pops up.
Normally, the pop-up only clears when one of the buttons is pressed, but it's also possible to clear the pop-up from inside your program using CLR_KRLMSG (Handle Variable).
In "raw" KRL, something like:
nDialogMsgHandle=SET_KRLDLG(_Msg, _MsgPar[], _MsgSoftKey[], FI_MsgOpt)
WAIT FOR Clear_KrlMsg(nDialogMsgHandle)
I've never tried creating a Dialog pop-up with no buttons, but you could give it a shot. If it doesn't work for some reason, you could simply create one button and put your program into a loop that keeps popping the pop-up back up until the program is satisfied.
The MsgDialog subroutine in the MsgLib library (located in the SYSTEM directory of your robot) is a good example of Dialog, although it doesn't support clearing the pop-up programmatically.
I once made a modified version of MsgDialog that would allow my program to clear pop-ups based on either a SmartPad button being pressed, or on a value being sent from the PLC -- the PLC HMI "echoed" the SmartPad application messages, so the robot had to accept responses from either source.
DEF Dialog (FO_nAnswer:OUT,FI_chText[]:IN,FI_chModule[]:IN,FI_chTextPar[]:IN,FI_chDialogSK1[]:IN,FI_chDialogSK2[]:IN,FI_chDialogSK3[]:IN,FI_chDialogSK4[]:IN,FI_chDialogSK5[]:IN,FI_chDialogSK6[]:IN,FI_chDialogSK7[]:IN,FI_bNoBrakes:IN, FI_nMsgNr:IN,FI_MsgOpt:IN)
;FOLD HEADER
; Modified from stock MsgLib Dialog-message subroutine
; Adds capacity for both local and remote dialog response buttons
; Use O_ and I_ outputs and inputs that must be configured in the .DAT file of this module
;ENDFOLD (HEADER)
;FOLD DECLARATIONS
DECL KrlMsg_T _Msg
DECL KrlMsgPar_T _MsgPar[3]
DECL KrlMsgOpt_T FI_MsgOpt
DECL KrlMsgOpt_T _DummyMsgOpt
DECL KrlMsgDlgSK_T _MsgSoftKey[7]
DECL INT _nCount, _nLength, _nHandle, FO_nAnswer, FI_nMsgNr
DECL BOOL FI_bNoBrakes
DECL BOOL _bRet
DECL CHAR FI_chText[], FI_chModule[], FI_chTextPar[], FI_chDialogSK1[], FI_chDialogSK2[], FI_chDialogSK3[], FI_chDialogSK4[], FI_chDialogSK5[], FI_chDialogSK6[], FI_chDialogSK7[]
DECL CHAR _chMsg[255], _chMsgToPLC[300], _chConvertedMsg[255], _chTextPar[45]
DECL BOOL _bReplyFromPLC
DECL STATE_T _State
DECL INT _nOffset
DECL BOOL _bReplyFromSmartPad
DECL BOOL _bMessageReceivedByPLC
;ENDFOLD (DECLARATIONS)
;FOLD EXECUTABLE
O_MessageCode = 0 ; clear output
_bReplyFromPLC = FALSE
_bReplyFromSmartPad = FALSE
FO_nAnswer = 0
; check that there are no lingering PLC inputs
WAIT FOR (I_OperatorButton == 0)
; Handle undefined Options variable
ON_ERROR_PROCEED
_DummyMsgOpt=FI_MsgOpt
IF ($ERR.Number<>0) THEN
FI_MsgOpt.VL_Stop=TRUE ;DEFAULT setting TRUE
FI_MsgOpt.Clear_P_Reset=TRUE
FI_MsgOpt.Log_To_DB=FALSE
ERR_CLEAR($ERR)
ELSE
ERR_RAISE($ERR)
ENDIF
;Creates default values in case of none availability
FI_MsgOpt=CheckOfMsgOpt(FI_MsgOpt)
_Msg.Nr=1
ERR_CLEAR($ERR)
ON_ERROR_PROCEED
_Msg.Nr=FI_nMsgNr
_nLength=STRLEN(FI_chText[])
IF _nLength>0 THEN
IF _nLength>80 THEN
_nLength=80
ENDIF
FOR _nCount=1 TO _nLength
_Msg.Msg_txt[_nCount]=FI_chText[_nCount]
_chConvertedMsg[_nCount] = FI_chText[_nCount]
; Convert %1 to %s for SWrite to include text parameter in msg to HMI
IF (_nCount > 1) THEN
IF ((_chConvertedMsg[_nCount-1] == "%") AND (_chConvertedMsg[_nCount] == "1")) THEN
_chConvertedMsg[_nCount] = "s"
ENDIF
ENDIF
ENDFOR
; SWrite will fail if last character is %
IF (_chConvertedMsg[_nCount-1] == "%") THEN
_chConvertedMsg[_nCount-1] = " "
ENDIF
ELSE
_Msg.Msg_txt[]="parameter FI_chText[] is missing"
ENDIF
_nLength=STRLEN(FI_chModule[])
IF _nLength>0 THEN
IF _nLength>24 THEN
_nLength=24
ENDIF
FOR _nCount=1 TO _nLength
_Msg.Modul[_nCount]=FI_chModule[_nCount]
ENDFOR
ELSE
_Msg.Modul[]="Appl"
ENDIF
ERR_CLEAR($ERR)
ON_ERROR_PROCEED
_nLength=STRLEN(FI_chDialogSK1[])
IF $ERR.Number==0 THEN
IF _nLength > 0 THEN
IF _nLength>24 THEN
_nLength=24
ENDIF
_MsgSoftKey[7].Sk_Type = #KEY
FOR _nCount=1 TO _nLength
_MsgSoftKey[7].Sk_txt[_nCount] = FI_chDialogSK1[_nCount]
ENDFOR
ENDIF
ELSE
FOR _nCount=1 TO 24
_MsgSoftKey[7].Sk_txt[_nCount] = " "
ENDFOR
ENDIF
ERR_CLEAR($ERR)
ON_ERROR_PROCEED
_nLength=STRLEN(FI_chDialogSK2[])
IF $ERR.Number==0 THEN
_nLength=STRLEN(FI_chDialogSK2[])
IF _nLength > 0 THEN
IF _nLength>24 THEN
_nLength=24
ENDIF
_MsgSoftKey[6].Sk_Type = #KEY
FOR _nCount=1 TO _nLength
_MsgSoftKey[6].Sk_txt[_nCount] = FI_chDialogSK2[_nCount]
ENDFOR
ENDIF
ELSE
FOR _nCount=1 TO 24
_MsgSoftKey[6].Sk_txt[_nCount] = " "
ENDFOR
ENDIF
ERR_CLEAR($ERR)
ON_ERROR_PROCEED
_nLength=STRLEN(FI_chDialogSK3[])
IF $ERR.Number==0 THEN
_nLength=STRLEN(FI_chDialogSK3[])
IF _nLength > 0 THEN
IF _nLength>24 THEN
_nLength=24
ENDIF
_MsgSoftKey[5].Sk_Type = #KEY
FOR _nCount=1 TO _nLength
_MsgSoftKey[5].Sk_txt[_nCount] = FI_chDialogSK3[_nCount]
ENDFOR
ENDIF
ELSE
FOR _nCount=1 TO 24
_MsgSoftKey[5].Sk_txt[_nCount] = " "
ENDFOR
ENDIF
ERR_CLEAR($ERR)
ON_ERROR_PROCEED
_nLength=STRLEN(FI_chDialogSK4[])
IF $ERR.Number==0 THEN
_nLength=STRLEN(FI_chDialogSK4[])
IF _nLength > 0 THEN
IF _nLength>24 THEN
_nLength=24
ENDIF
_MsgSoftKey[4].Sk_Type = #KEY
FOR _nCount=1 TO _nLength
_MsgSoftKey[4].Sk_txt[_nCount] = FI_chDialogSK4[_nCount]
ENDFOR
ENDIF
ELSE
FOR _nCount=1 TO 24
_MsgSoftKey[4].Sk_txt[_nCount] = " "
ENDFOR
ENDIF
ERR_CLEAR($ERR)
ON_ERROR_PROCEED
_nLength=STRLEN(FI_chDialogSK5[])
IF $ERR.Number==0 THEN
_nLength=STRLEN(FI_chDialogSK5[])
IF _nLength > 0 THEN
IF _nLength>24 THEN
_nLength=24
ENDIF
_MsgSoftKey[3].Sk_Type = #KEY
FOR _nCount=1 TO _nLength
_MsgSoftKey[3].Sk_txt[_nCount] = FI_chDialogSK5[_nCount]
ENDFOR
ENDIF
ELSE
FOR _nCount=1 TO 24
_MsgSoftKey[3].Sk_txt[_nCount] = " "
ENDFOR
ENDIF
ERR_CLEAR($ERR)
ON_ERROR_PROCEED
_nLength=STRLEN(FI_chDialogSK6[])
IF $ERR.Number==0 THEN
_nLength=STRLEN(FI_chDialogSK6[])
IF _nLength > 0 THEN
IF _nLength>24 THEN
_nLength=24
ENDIF
_MsgSoftKey[2].Sk_Type = #KEY
FOR _nCount=1 TO _nLength
_MsgSoftKey[2].Sk_txt[_nCount] = FI_chDialogSK6[_nCount]
ENDFOR
ENDIF
ELSE
FOR _nCount=1 TO 24
_MsgSoftKey[2].Sk_txt[_nCount] = " "
ENDFOR
ENDIF
ERR_CLEAR($ERR)
ON_ERROR_PROCEED
_nLength=STRLEN(FI_chDialogSK7[])
IF $ERR.Number==0 THEN
_nLength=STRLEN(FI_chDialogSK7[])
IF _nLength > 0 THEN
IF _nLength>24 THEN
_nLength=24
ENDIF
_MsgSoftKey[1].Sk_Type = #KEY
FOR _nCount=1 TO _nLength
_MsgSoftKey[1].Sk_txt[_nCount] = FI_chDialogSK7[_nCount]
ENDFOR
ENDIF
ELSE
FOR _nCount=1 TO 24
_MsgSoftKey[1].Sk_txt[_nCount] = " "
ENDFOR
ENDIF
_nLength=STRLEN(FI_chTextPar[])
IF _nLength>0 THEN
IF _nLength>26 THEN
_nLength=26
ENDIF
FOR _nCount=1 TO _nLength
_MsgPar[1].Par_Txt[_nCount]=FI_chTextPar[_nCount]
_chTextPar[_nCount] = FI_chTextPar[_nCount]
ENDFOR
_MsgPar[1].Par_type=#Value
ENDIF
; Write text variable into Message
_nOffset = 0
SWRITE(_chMsgToPLC[], _State, _nOffset, _chConvertedMsg[], _chTextPar[])
; Steering logic
bDialogToPLC = (($EXT OR $AUT) AND (NOT bPlcSim))
bDialogToSmartPad = TRUE ; NOT $EXT
; bDialogToSmartPad = ((($EXT OR $AUT) AND NOT I_ClearToLeaveStandstill) OR $T1 OR $T2)
; Send dialog and buttons to PLC
IF bDialogToPLC THEN
WAIT FOR NOT (I_DialogReceived OR I_DialogResend)
REPEAT
;UserDialogToPLC(_chMsgToPLC[], _Msg.Modul[],_MsgSoftKey[1].SK_TXT[],_MsgSoftKey[2].SK_TXT[],_MsgSoftKey[3].SK_TXT[],_MsgSoftKey[4].SK_TXT[],_MsgSoftKey[5].SK_TXT[],_MsgSoftKey[6].SK_TXT[],_MsgSoftKey[7].SK_TXT[],_Msg.Nr )
O_MessageCode = nMessageCodeMemory ; transmit message code
REPEAT
PULSE(O_DialogSent, TRUE, 0.1)
UNTIL(I_DialogReceived OR I_DialogResend)
IF I_DialogResend THEN
O_DialogSent = FALSE
WAIT FOR NOT (I_DialogResend)
ENDIF
UNTIL I_DialogReceived
O_DialogSent = FALSE
WAIT FOR NOT (I_DialogReceived)
ENDIF
;Send Dialog and Buttons to SmartPad
IF bDialogToSmartPad THEN
nDialogMsgHandle=SET_KRLDLG(_Msg, _MsgPar[], _MsgSoftKey[], FI_MsgOpt)
ELSE
MsgState(nDialogMsgHandle, "Operator Dialog Message on Cell HMI", "Dialog")
ENDIF
ERR_CLEAR($ERR)
ON_ERROR_PROCEED
FI_bNoBrakes=FI_bNoBrakes
IF NOT($ERR.Number==0) THEN
FI_bNoBrakes=FALSE
ENDIF
; Wait for either SmartPad button or button code input via FieldBus
REPEAT
WAIT SEC 0.2
_bReplyFromSmartPad = (bDialogToSmartPad AND NOT Exists_KrlDlg (nDialogMsgHandle, FO_nAnswer) AND (FO_nAnswer > 0))
_bReplyFromPLC = (bDialogToPLC AND NOT (I_OperatorButton == 0))
IF _bReplyFromPLC THEN
SWITCH UserButton (I_OperatorButton)
CASE #Invalid
_bReplyFromPLC = FALSE
DEFAULT
; leave _bReplyFromPLC alone
ENDSWITCH
ENDIF
UNTIL (_bReplyFromPLC or _bReplyFromSmartPad)
; Reply recieved from PLC
IF _bReplyFromPLC THEN
; If loop exited due to remote PLC input
FO_nAnswer = I_OperatorButton
O_MessageCode = 0 ; clear Message output
WAIT FOR (I_OperatorButton == 0) ; wait for PLC acknowledgement
;MsgNotify("Reply From PLC %1", "Dialog", FO_nAnswer)
WAIT SEC 1.0 ; Debounce
; Clear SmartPad message
WAIT FOR Clear_KrlMsg(nDialogMsgHandle)
ELSE
; Reply received from SmartPad
IF _bReplyFromSmartPad THEN
; Loop was exited due to SmartPad button
; FO_nAnswer was set by Exists_KrlDlg()
; MsgNotify("Reply From SmartPad %1", "Dialog", FO_nAnswer)
O_MessageCode = 0 ; clear Message output
ENDIF
ENDIF
IF FI_bNoBrakes THEN
PTP $AXIS_ACT
ENDIF
;ENDFOLD (EXECUTABLE)
END
Display More
does it need to be a popup? status message would be perfect for this
Panic mode, SkyeFire, thank a lot for quick answer. I've understood that have no easy way to generate the popup window.
In KRL, the SET_KRLDLG function is passed the message text, an array of text values for each button, some parameters, and passes back an integer "handle" attached to the dialog box that SET_KRLDLG pops up.
Normally, the pop-up only clears when one of the buttons is pressed, but it's also possible to clear the pop-up from inside your program using CLR_KRLMSG (Handle Variable).
Yes, i know how the SET_KRLDG function works. And my first think was about it. Thank you for good example i will investigate that!
does it need to be a popup? status message would be perfect for this
Yes it need to be a popup. I want to block any activity from User-s during my function is executed.
Yes it need to be a popup. I want to block any activity from User-s during my function is executed.
attempting to block "any activity" is going to be difficult. you may have to define what the "any activity" really is. popup does not prevent user from using (or letting go) of enabling switch, turning mode switch or pressing anything that is not on screen. creating and removing custom popup is not really a big deal, it is just that it would need a bit more than just KRL if it need to look certain way (without button). the bigger question what is it that you are trying to prevent.