Jump to content
Developer Wiki and Function Reference Links ×

Not Reporting Param State Changes


Sam Jones

Recommended Posts

I am under the impression that when a parameter is changed the result of 

ParamChangeFlag := vsoStateGetParamChng(PIOHan,ParamChangeWidget,ParamChangeIndex,OldParam);

should be true.

I have a PIO that fails to change the ParamChangeFlag  to true when a parameter changes.

 

My init event has the following code.

            kObjOnInitXProperties:        {5}
                BEGIN
                    Result := SetObjPropVS (kObjXPropHasUIOverride,True);
                    Result := SetObjPropVS(12, TRUE); {kObjXHasCustomWidgetVisibilities}
                    
                    SetPrefInt(590, 1 ); {kParametricEnableStateEventing}
                    Result := SetObjPropVS (18,TRUE);    {kObjXPropAcceptStates}
                    
                    Result := vsoInsertAllParams;

                    Result := SetObjPropVS(kObjXPropDataNameDisabled, TRUE);{kObjXPropDataNameDisabled}
                    SetPrefInt (590,1);    {varParametricEnableStateEventing,ResetStatesEvent}
                END;
 

Which should enable state eventing.  Does anyone have a clue as to what I missed or where I should look, because now

vsoStateGetParamChng(PIOHan,ParamChangeWidget,ParamChangeIndex,OldParam); 

always yields False whenever a parameter is changed in the OIP.,

Link to comment

Hi Sam,

   Do you have your call

           ParamChangeFlag := vsoStateGetParamChng(PIOHan, ParamChangeWidget, ParamChangeIndex, OldParam);

in Event 3 (kResetEventID)?

 

Everything else you have in your kObjOnInitXProperties event is what I have, though you call 

          SetPrefInt(590, 1 );    {kParametricEnableStateEventing}
twice, where I only call it once at the end of Event 5 (kObjOnInitXProperties). I doubt it makes a difference, but I don't know.

 

   Also, do you have "Event-Based" checked in the "Edit Plug-in Definition" dialog, Options tab?

 

   Lastly, I execute these 3 commands first before I enter the CASE statement testing the events:

      result := GetCustomObjectInfo(PIOName, PIOHand, recHand, wallHand);
      IsNew := IsNewCustomObject(PIOName);
      vsoGetEventInfo(theEvent, theMessage);

The first line makes sure the PIOHand variable is valid, and the third line returns the current EVENT.


Raymond

Link to comment

Raymond,

 

Thank you.  The kObjOnAddState event was indeed missing from the event case test; however putting it in did not solve my problem.  Nothing I can do it seems will yield 

ParamChangeFlag = True

Here is the guts of my main with the case event test.

 

        GetVersion(Major,Minor,Maintenance,Platform);
        GetUnits(Fraction,Display,Format,UPI,UnitName,SquareName);
        Result := GetCustomObjectInfo(PIOName,PIOHan,PIORec,WallHdl);
        vsoGetEventInfo(EventMessage, MsgData);
        OK := GetLocalizedPlugInName(PIOName,LocalPIOName);
        IsNew := IsNewCustomObject(PIOName);
        
        BoxBottom := 3 * UPI;

        CASE EventMessage OF

            kResetEventID:                {3}
                BEGIN
                    GetSymLoc3D(PIOHan, PIOX, PIOY, PIOZ);

                    ParamChangeFlag := vsoStateGetParamChng(PIOHan,ParamChangeWidget,ParamChangeIndex,OldParam);
AlrtDialog(concat('Event 3, kResetEventID  triggered', kcr,
                'ParamChangeFlag = ', ParamChangeFlag, kcr,
                'EventMessage = ', EventMessage));
                    IF (ParamChangeFlag=True) THEN 
                        BEGIN
                            {Do Stuff}
                         END; {IF (ParamChangeFlag=True) }
        
                    ParamChangeTrig := FALSE;
                    PIOChangeTrig := FALSE;
            
                    SetUp;
                    MainConstruct;

                    vsoStateClear(PIOHan );
                END;
        
            kObjOnAddState: {44}
                BEGIN
                    {This event is needed to track state changes}            
                    EventMessage := vsoStateAddCurrent(PIOHan, EventMessage);
                    ParamChangeFlag := vsoStateGetParamChng(PIOHan,ParamChangeWidget,ParamChangeIndex,OldParam);
AlrtDialog(concat('Event 44, kObjOnAddState  triggered', kcr,
                'ParamChangeFlag = ', ParamChangeFlag, kcr,
                'EventMessage = ', EventMessage));
                END;

            kObjOnInitXProperties:        {5}
                BEGIN
                    Result := SetObjPropVS (kObjXPropHasUIOverride,True);
                    Result := SetObjPropVS(12, TRUE); {kObjXHasCustomWidgetVisibilities}
                    
                    SetPrefInt(590, 1 ); {kParametricEnableStateEventing}
                    Result := SetObjPropVS (18,TRUE);    {kObjXPropAcceptStates}
                    
                    Result := vsoInsertAllParams;

                    Result := SetObjPropVS(kObjXPropDataNameDisabled, TRUE);{kObjXPropDataNameDisabled}
                    SetPrefInt (590,1);    {varParametricEnableStateEventing,ResetStatesEvent}
                END;
        
            kObjOnWidgetPrep:    {41}
                BEGIN
                    WidgetPrep;
                END; {kObjOnWidgetPrep}
        
        END; {case}    
 

Link to comment

Hi Sam,

   I have only two suggestions which I've marked with comments in your code. Try them one at a time to see if either of them works. Then try them together if neither works. After that, I'm out of ideas. 

 

	GetVersion(Major,Minor,Maintenance,Platform);
	GetUnits(Fraction,Display,Format,UPI,UnitName,SquareName);
	Result := GetCustomObjectInfo(PIOName,PIOHan,PIORec,WallHdl);
	vsoGetEventInfo(EventMessage, MsgData);
	OK := GetLocalizedPlugInName(PIOName,LocalPIOName);
	IsNew := IsNewCustomObject(PIOName);

	BoxBottom := 3 * UPI;
	CASE EventMessage OF
		kResetEventID:		{ 3 }
			BEGIN
{ MOVE vsoStateGetParamChng LINE FROM EVENT 44 TO EVENT 3 }
				ParamChangeFlag := vsoStateGetParamChng(PIOHan,ParamChangeWidget,ParamChangeIndex,OldParam);

				GetSymLoc3D(PIOHan, PIOX, PIOY, PIOZ);
				ParamChangeFlag := vsoStateGetParamChng(PIOHan,ParamChangeWidget,ParamChangeIndex,OldParam);
			AlrtDialog(concat('Event 3, kResetEventID  triggered', kcr,
				'ParamChangeFlag = ', ParamChangeFlag, kcr,
				'EventMessage = ', EventMessage, kcr,
				'MsgData = ', MsgData));
				IF (ParamChangeFlag=True) THEN 
					BEGIN
						{Do Stuff}
					END;	{IF (ParamChangeFlag=True) }

				ParamChangeTrig := FALSE;
				PIOChangeTrig := FALSE;

				SetUp;
				MainConstruct;
				vsoStateClear(PIOHan );
			END;	{ 3 - kResetEventID }

		kObjOnAddState:		{ 44 }
			BEGIN
				{This event is needed to track state changes}
{ CHANGE EventMessage TO MsgData (x2) in following line }
				MsgData := vsoStateAddCurrent(PIOHan, MsgData);
			AlrtDialog(concat('Event 44, kObjOnAddState  triggered', kcr,
				'ParamChangeFlag = ', ParamChangeFlag, kcr,
				'EventMessage = ', EventMessage, kcr,
				'MsgData = ', MsgData));
			END;	{ 44 - kObjOnAddState }

		kObjOnInitXProperties:		{ 5 }
			BEGIN
				Result := SetObjPropVS (kObjXPropHasUIOverride,True);
				Result := SetObjPropVS(12, TRUE); {kObjXHasCustomWidgetVisibilities}
				
				SetPrefInt(590, 1 );		{kParametricEnableStateEventing}
				Result := SetObjPropVS (18,TRUE);    {kObjXPropAcceptStates}
				
				Result := vsoInsertAllParams;
				Result := SetObjPropVS(kObjXPropDataNameDisabled, TRUE);{kObjXPropDataNameDisabled}
				SetPrefInt (590,1);		{varParametricEnableStateEventing,ResetStatesEvent}
			END;	{ 5 }

		kObjOnWidgetPrep:    { 41 }
			BEGIN
				WidgetPrep;
			END;		{ 41 - kObjOnWidgetPrep }

	END;	{ case }    

 

Have a Merry Xmas, (or holiday of your choice),

Raymond

Link to comment

{ CHANGE EventMessage TO MsgData (x2) in following line } seems to be the key to the problem, and I have things working now.

 

What is "MsgData := vsoStateAddCurrent(PIOHan, MsgData);" reporting?  It would seem that the only statement needed on a 

"kObjOnAddState"

is

"MsgData := vsoStateAddCurrent(PIOHan, MsgData);"

Link to comment

Hi Sam,

   That's the change I thought would have the most impact on your problem, yet I'm not exactly sure what vsoStateAddCurrent() does under the hood. It's one of those things that works and I have not spent any time trying to figure out more about it. 

 

   As you surmised, that is the only statement I have under that event in all of my PIO's. If you ever find another example on how it's used differently, please let me know.

 

Happy New Year,

Raymond

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...