I am trying to use the fbOpenDialogExtended block from Visu Utils. My code works only a third of the time and I am not sure why...
FUNCTION_BLOCKFB_SeqChgMsgBxVAR_INPUTEND_VARVAR_OUTPUTEND_VARVARxOpenMessageDialog:BOOL;xStartTimer:BOOL;fbOpenMessageDialog:VU.FbOpenDialogExtended;MessageInfo:d01_MessageBox_VISU_STRUCT;seqChgTemp:INT;TON_0:TON;tonET:TIME;END_VARIFGVL_Visual.autoSeqNumber<>seqChgTempTHENCASEGVL_Visual.autoSeqNumberOF0:MessageInfo.sMessageTxt:='Sequence has been changed to Manual';MessageInfo.sBitmapID:='icons8-info-50';MessageInfo.sTitle:='Auto Sequence Change';xOpenMessageDialog:=TRUE;xStartTimer:=TRUE;1:MessageInfo.sMessageTxt:='Sequence has been changed to Auto Sequence 1 which includes door movement';MessageInfo.sBitmapID:='icons8-info-50';MessageInfo.sTitle:='Auto Sequence Change';xOpenMessageDialog:=TRUE;xStartTimer:=TRUE;2:MessageInfo.sMessageTxt:='Sequence has been changed to Auto Sequence 2 which is compaction only';MessageInfo.sBitmapID:='icons8-info-50';MessageInfo.sTitle:='Auto Sequence Change';xOpenMessageDialog:=TRUE;xStartTimer:=TRUE;END_CASEfbOpenMessageDialog(sDialogName:='d01_MessageBox',xModal:=TRUE,pTopLeftPosition:=0,itfClientFilter:=VU.Globals.AllClients,xExecute:=xOpenMessageDialog,pbyDialogInterfaceData:=ADR(MessageInfo),udiDialogInterfaceDataSize:=SIZEOF(MessageInfo));seqChgTemp:=GVL_Visual.autoSeqNumber;IFxOpenMessageDialogTHENxOpenMessageDialog:=FALSE;fbOpenMessageDialog.xExecute:=FALSE;END_IFEND_IFTON_0(IN:=xStartTimerANDNOTGVL_J1939.rgtJoystk_Btn8_0,PT:=T#30S);tonET:=TON_0.ET;IFTON_0.QTHENGVL_Visual.closePopup:=TRUE;xStartTimer:=FALSE;END_IF
Last edit: masmith1553 2022-08-09
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I found myself that I have to run the FB first with xExecute:= false, then run it again with Execute:= True and it works every time.
So in your scenario just try to stick this above your case statement or just after :
fbOpenMessageDialog(sDialogName := 'd01_MessageBox', xExecute:= false);
Maybe somebody else could tell us why it is like this.
π
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It's because the fbOpenMessageDialog function block is looking for a rising edge on the xExecute input.
This section:
IF xOpenMessageDialog THEN xOpenMessageDialog := FALSE; fbOpenMessageDialog.xExecute := FALSE;END_IF
doesn't actually run the function block, it just sets the xExecute input to false. But fbOpenMessageDialog doesn't actually run again until you change GVL_Visual.autoSeqNumber on line 1. But when it does run, it doesn't see a rising edge, because xExecute is TRUE, the same as it was the last time it ran. The function block hasn't actually seen the FALSE state of xExecute.
As surikan said above, you need to reset the input so it sees the rising edge on the next cycle. You could do it here
IF xOpenMessageDialog THEN xOpenMessageDialog := FALSE; //fbOpenMessageDialog.xExecute := FALSE; fbOpenMessageDialog(sDialogName := 'd01_MessageBox', xExecute:= FALSE); //this resets the input to false and runs the function block, so it sees the false state
I suspected that would be one reason for it, yet the provided example on forge does not include this.
In my experience if you do the reset after opening the dialog you still end up with having open twice after power cycle/ download/ online change, hence I suggested to do before
π
3
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I am trying to use the fbOpenDialogExtended block from Visu Utils. My code works only a third of the time and I am not sure why...
Last edit: masmith1553 2022-08-09
I found myself that I have to run the FB first with xExecute:= false, then run it again with Execute:= True and it works every time.
So in your scenario just try to stick this above your case statement or just after :
fbOpenMessageDialog(sDialogName := 'd01_MessageBox', xExecute:= false);
Maybe somebody else could tell us why it is like this.
It's because the fbOpenMessageDialog function block is looking for a rising edge on the xExecute input.
This section:
doesn't actually run the function block, it just sets the xExecute input to false. But fbOpenMessageDialog doesn't actually run again until you change GVL_Visual.autoSeqNumber on line 1. But when it does run, it doesn't see a rising edge, because xExecute is TRUE, the same as it was the last time it ran. The function block hasn't actually seen the FALSE state of xExecute.
As surikan said above, you need to reset the input so it sees the rising edge on the next cycle. You could do it here
This might explain the behaviour a bit better
https://help.codesys.com/webapp/behaviour_model;product=LibDevSummary;version=3.5.17.0
I suspected that would be one reason for it, yet the provided example on forge does not include this.
In my experience if you do the reset after opening the dialog you still end up with having open twice after power cycle/ download/ online change, hence I suggested to do before
Thank you for the responses, I was able get it working.