Process Analyst Control

Hello all,

I want do add a new button in toolbar of the Process Analyst Control.

I have been looking at help to sse how it was done but i dont know how to do: "If necessary, enter a new ID for the command. This ID can be used in Cicode to determine which command has been triggered or to find a specific command in the Citect SCADA system."

Can anyone help?

Thanks a lot

  • You can find the built-in command IDs on the help page: Runtime Client Tools > Process Analyst > Customize Process Analyst > ICommand Interface

    If you want to create a button to trigger a built-in command, use one of those IDs, like "Citect_Command_ToggleVerticalScrollLock". Or, if you are creating your own command, make up your own command ID. The ICommandSystem.Create help page shows a sample custom ID like "Custom_CommandID1" and says it must not begin with "Citect_".

    Here's a code snippet I had from somewhere. Maybe it will get you started.

    //ToolbarButtonType_Push = 0 
    //ToolbarButtonType_Toggle = 1 
    //ToolbarButtonType_Separator = 2 
    PRIVATE INT FUNCTION CreateCustomCommandButton(OBJECT oPA, STRING sID, STRING sTooltip, OBJECT oToolbar, INT nButtonType = 0, INT nPrivilege = 0)
    	OBJECT	oCommandSystem;
    	OBJECT	oCommand;
    	OBJECT	oToolbarButtons;
    	STRING	sIconFile;
    	STRING	sCommandID = "Custom_Command_" + sID;
    	
    	ErrSet(1);
    	
    	oToolbarButtons = _ObjectGetProperty(oToolbar, "Buttons");
    	oCommandSystem = _ObjectGetProperty(oPA, "CommandSystem");
    	oCommand = _ObjectCallMethod(oCommandSystem,"get_ItemById", sCommandID);
    	
    	//Create command object if needed	
    	IF ObjectIsValid(oCommand) = FALSE THEN
    		sIconFile = PathToStr("[RUN]:" + sID + ".ico");
    		oCommand = _ObjectCallMethod(oCommandSystem, "Create", sCommandID, nButtonType, sTooltip, sIconFile, nPrivilege);
    	END
    	
    	//Add button to toolbar
    	IF ObjectIsValid(oCommand) = TRUE THEN
    		_ObjectCallMethod(oToolbarButtons, "Add", sCommandID);
    	END
    
    	RETURN IsError();
    END
    

    Your other option is to go to the Properties window and add the button through the user interface. If you save the view, the button will be saved as part of the view. If you don't use views or you have too many existing views to edit manually, then doing it through Cicode may be better.

    If you are creating a new custom command, you will have to create a Cicode function to run when the CommandExecuted event triggers. See the Runtime Client Tools > Process Analyst > Customize Process Analyst > CommandExecuted [Event] help page.

  • hello,

    I create a button like in the Citect Process Analyst Control:

    ID: CMD_InserirGrafico
    Tooltip: xpto
    ICON: xpto.ico
    Button: Enabled

    And create a function:

    FUNCTION Graficos_AN38_CommandExecuted(OBJECT hPA, STRING commandId)
    SELECT CASE commandId
    CASE "CMD_InserirGrafico"
    TrendSelectPenNovo(hPA);
    END SELECT
    END

    where Graficos_AN38 is the event Class.

    When i run the project and press the button it doesnt work. I put a break point in the function and it never stop there.

    Any tip?
  • Your setup looks OK. I tried the same thing.

    I set the event class Graficos_AN38:

    I created a Cicode event handler to write any command names to the Kernel window:

    FUNCTION Graficos_AN38_CommandExecuted(OBJECT processAnalyst, STRING commandId)
         TraceMsg("CommandExecuted " + CommandID);
    END

    In the runtime I created your button:

    I added the button to the main toolbar.

    When I executed various toolbar commands (including yours), they showed up in the kernel window:

    Do you see any difference between my setup and yours? Make sure you don't have any extra spaces, like in the Event Class. Maybe try my test event handler and try the built-in toolbar buttons to see if they trigger it.