Adding a Column to Display

the Current Trend Value

 

A White Paper


Presented by:

Warwick Black


Abstract

This paper shows how to add a custom column to your ‘Object View’ part of your instance of ‘Process Analyst’.

 

Contacts

support@citect.com


First, You will need to define the Custom Column. This can be done at design time or runtime via Cicode. In this example, we have created the Column at design time.

 

Paste an instance of Process Analyst onto your graphics page:

 

 

Bring up the properties for that object, Click on the ‘Appearance’ tab, and click on the ‘Object View’ tab on the right hand side.

 

 

Click the NEW button, and fill out the details of your new column. Note the ‘Name ID’ as we will use this to refer to the column in our Cicode.

 

 

Click OK

 

Now check the box next to our newly created Column to enable it for the particular object we have created.

 

 

Now, for this instance I am going a step further. In order to toggle on and Off the automatic updating of the ‘Tag_Value’ Column, I am using a custom Process Analyst Toolbar Button.

 

We will create the button as follows: Click on the ‘ToolBars’ tab on the right hand side.

 


 

 

Add the button to the current toolbar, as above, and add the following Cicode event handler to process the button press:

 

 

//MODULE VARIABLES

REAL mrTrendTagData[1];
INT miRunLoop;
STRING msOldPageCount = "0";
STRING msNewPageCount = "0";
OBJECT mhProcessAnalyst;
OBJECT mhCommandSystem;
OBJECT mhCommand;

//Custom Button Event Handler

FUNCTION
start_AN202_CommandExecuted(OBJECT hThis, STRING sCommandId)
INT nPressed;
    SELECT CASE sCommandId
        
CASE "UpdateTagValue" 
                mhProcessAnalyst = ObjectByName("AN202");//AN OF P.A 
                //THIS IS TO DETERMINE IF THE BUTTON HAS BEEN TOGGLED ON OR OFF: 
                mhCommandSystem = _ObjectGetProperty(mhProcessAnalyst,"CommandSystem");
            
mhCommand=_ObjectCallMethod(mhCommandSystem,"get_ItemByID","UpdateTagValue");
            
nPresse =_ObjectGetProperty(mhCommand,"Pressed"); 
                IF nPressed = -1 THEN //IF THE BUTTON HAS BEEN TOGGLED ON..... 
                    miRunLoop = 1; //Set Flag for Timed Event 
                ELSE //IF THE BUTTON HAS BEEN TOGGLED OFF..... 
                    miRunLoop = 0; //Clear Flag for Timed Event 
                END 
    END SELECT
END

 

On the Citect page, create an ‘On Page Shown’ event, as shown below:

This ‘On Page Shown’ Event will call the following Cicode:

 

FUNCTION
Run_PA_Code(STRING PageName)
    
WHILE PageInfo(0)= PageName DO 
        IF miRunLoop = 1 THEN 
            SleepMS(500); //This puts in a suitable delay to limit PC resources used 
            CUSTOM_PA_UpdateTagValue(mhProcessAnalyst);
      
END 
    END
END

 

This will cause Citect to run through a loop as long as the current page is shown, however the part that updates the column values is governed by the condition of the flag ‘miRunLoop’ which is toggled on and off by our Custom button as we have previously defined.

Now, we add the Cicode to scroll through each Pen of every Pane of the ObjectView, and if they are a Trend Tag, then the current value of that Trend will be displayed in our Column.

//THIS FUNCTION WILL READ THROUGH ALL PANES AND PENS AND DISPLAY THE TREND TAG VALUE AT THE SPECIFIED INTERVAL

FUNCTION
CUSTOM_PA_UpdateTagValue(OBJECT hAnalyst)
OBJECT hObjectView,hObjectViewPaneItems,hObjectViewPenItems,hObjectViewItem,hObjectViewColumns,hPanes,hPane;
INT nPaneCount,nPaneIter;
OBJECT hPens,hPen;
INT nPenCount,nPenIter;
STRING sTrendTagName,sTagType;

   // Retrieve the Object View 
    hObjectView = _ObjectGetProperty(hAnalyst, "ObjectView");
   
hObjectViewPaneItems = _ObjectGetProperty(hObjectView , "Items");

    // Retrieve the panes 
    hPanes = _ObjectGetProperty(hAnalyst, "Panes");
   
nPaneCount = _ObjectGetProperty(hPanes, "Count");

 

   //Get Columns 
    hObjectViewColumns = _ObjectGetProperty(hObjectView , "Columns");

    FOR nPaneIter = 1 TO nPaneCount DO 
        // Get object view Item and sub Items collection corresponing to this Pane 
        hObjectViewItem = _ObjectCallMethod(hObjectViewPaneItems, "get_Item", nPaneIter);
      
hObjectViewPenItems = _ObjectGetProperty(hObjectViewItem, "Items");

        // Get the Pens collection (and count) corresponding to this pane 
        hPane = _ObjectCallMethod(hPanes, "get_Item", nPaneIter);
      
hPens = _ObjectGetProperty(hPane , "Pens");
      nPenCount = _ObjectGetProperty(hPens , "Count");

         FOR nPenIter = 1 TO nPenCount DO 
            // Get the matching Pen Item and ListView sub-item pair 
            hPen = _ObjectCallMethod(hPens, "get_Item", nPenIter );
         
hObjectViewItem = _ObjectCallMethod(hObjectViewPenItems, "get_Item", nPenIter );

            //Get the Trend Tag Name 
         sTrendTagName = _ObjectCallMethod(hPen, "GetInformation", "Tag")
        
ErrSet(1);
        
TrnGetTable(sTrendTagName, 0, 0, 1, mrTrendTagData,1);
         IF IsError() = 0 THEN //IF THE PEN IS NOT AN ALARM PEN, DISPLAY VALUE IN LIST 
                //Update our Column with this value 
                _ObjectCallMethod(hObjectViewItem,"PutField","Tag_Value",mrTrendTagData);
         
END 
            ErrSet(0);
        
//END 
         END 
    END
END

 

 

 

 

As we can see, we now have a Custom Column in our Object View that can update at a predetermined rate.

 

 

 

 

 

As we can see, we now have a Custom Column in our Object View that can update at a predetermined rate.

 

We also have the option to disable this option to reduce system load if required.

 


Here is the complete Cicode file required for the above example:

 

//MODULE VARIABLES

REAL mrTrendTagData[1];

INT miRunLoop;

STRING msOldPageCount = "0";

STRING msNewPageCount = "0";

OBJECT mhProcessAnalyst;

OBJECT mhCommandSystem;

OBJECT mhCommand;

 

//THIS IS AN EVENT CALLED WHEN A CUSTOM PROCESS ANAYLST TOGGLE BUTTON WITH A COMMANDID OF "UpdateTagValue" IS PRESSED

//THE "start_AN202" PART OF THE EVENT NAME MUST BE THE 'EVENT CLASS' OF YOU INSTANCE OF THE PROCESS ANALYST

FUNCTION

start_AN202_CommandExecuted(OBJECT hThis, STRING sCommandId)

INT nPressed;

SELECT CASE sCommandId

CASE "UpdateTagValue"

mhProcessAnalyst = ObjectByName("AN202"); //THIS IS THE AN OF OUR INSTANCE OF PROCESS ANALYST

//THIS IS TO DETERMINE IF THE BUTTON HAS BEEN TOGGLED ON OR OFF:

mhCommandSystem = _ObjectGetProperty(mhProcessAnalyst, "CommandSystem");

mhCommand = _ObjectCallMethod(mhCommandSystem, "get_ItemByID", "UpdateTagValue");

nPressed = _ObjectGetProperty(mhCommand, "Pressed")

 

IF nPressed = -1 THEN //IF THE BUTTON HAS BEEN TOGGLED ON.....

miRunLoop = 1; //Set Flag for Timed Event

ELSE //IF THE BUTTON HAS BEEN TOGGLED OFF.....

miRunLoop = 0; //Clear Flag for Timed Event

END

END SELECT

END

 

//THIS CALLS THE FUNCTION IN SUCH A WAY THAT IT WILL LOOP UNTIL THE PAGE IS CHANGED

FUNCTION

Run_PA_Code(STRING PageName)

WHILE PageInfo(0)= PageName DO

IF miRunLoop = 1 THEN

SleepMS(500); //This puts in a suitable delay to limit PC resources used

CUSTOM_PA_UpdateTagValue(mhProcessAnalyst);

END

END

END

 

//THIS FUNCTION WILL READ THROUGH ALL PANES AND PENS AND DISPLAY THE TREND TAG VALUE AT THE SPECIFIED INTERVAL

FUNCTION

CUSTOM_PA_UpdateTagValue(OBJECT hAnalyst)

OBJECT hObjectView,hObjectViewPaneItems,hObjectViewPenItems,hObjectViewItem,hObjectViewColumns,hPanes,hPane;

INT nPaneCount,nPaneIter;

OBJECT hPens,hPen;

INT nPenCount,nPenIter;

STRING sTrendTagName,sTagType;

 

// Retrieve the Object View

hObjectView = _ObjectGetProperty(hAnalyst, "ObjectView");

hObjectViewPaneItems = _ObjectGetProperty(hObjectView , "Items");

 

// Retrieve the panes

hPanes = _ObjectGetProperty(hAnalyst, "Panes");

nPaneCount = _ObjectGetProperty(hPanes, "Count");

 

//Get Columns

hObjectViewColumns = _ObjectGetProperty(hObjectView , "Columns");

 

FOR nPaneIter = 1 TO nPaneCount DO

// Get object view Item and sub Items collection corresponing to this Pane

hObjectViewItem = _ObjectCallMethod(hObjectViewPaneItems, "get_Item", nPaneIter);

hObjectViewPenItems = _ObjectGetProperty(hObjectViewItem, "Items");

 

// Get the Pens collection (and count) corresponding to this pane

hPane = _ObjectCallMethod(hPanes, "get_Item", nPaneIter);

hPens = _ObjectGetProperty(hPane , "Pens");

nPenCount = _ObjectGetProperty(hPens , "Count");

 

FOR nPenIter = 1 TO nPenCount DO

// Get the matching Pen Item and ListView sub-item pair

hPen = _ObjectCallMethod(hPens, "get_Item", nPenIter );

hObjectViewItem = _ObjectCallMethod(hObjectViewPenItems, "get_Item", nPenIter );

 

//Get the Trend Tag Name

sTrendTagName = _ObjectCallMethod(hPen, "GetInformation", "Tag");

 

ErrSet(1);

TrnGetTable(sTrendTagName, 0, 0, 1, mrTrendTagData,1)

IF IsError() = 0 THEN //IF THE PEN IS NOT AN ALARM PEN, DISPLAY VALUE IN LIST

//Update our Column with this value

_ObjectCallMethod(hObjectViewItem,"PutField","Tag_Value",mrTrendTagData);

END

ErrSet(0);

//END

END

END

END

Disclaimer

Disclaimer of All Warranties
SCHNEIDER ELECTRIC (AUSTRALIA) PTY LTD DISCLAIMS ANY AND ALL WARRANTIES WITH RESPECT TO SCHNEIDER ELECTRIC (AUSTRALIA) PTY LTD PRODUCTS AND THE RELATED DOCUMENTATION, WHETHER EXPRESS OR IMPLIED, INCLUDING SPECIFICALLY THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A GENERAL OR PARTICULAR PURPOSE. CITECTSCADA AND THE RELATED DOCUMENTATION ARE PROVIDED "AS IS," AND YOUR COMPANY UNDERSTANDS THAT IT ASSUMES ALL RISKS OF THEIR USE, QUALITY, AND PERFORMANCE.

Disclaimer of Liability
YOUR COMPANY AGREES AND ACKNOWLEDGES THAT SCHNEIDER ELECTRIC (AUSTRALIA) PTY LTD SHALL HAVE NO LIABILITY WHATSOEVER TO YOUR COMPANY FOR ANY PROBLEMS IN OR CAUSED BY SCHNEIDER ELECTRIC (AUSTRALIA) PTY LTD PRODUCTS OR THE RELATED DOCUMENTATION, WHETHER DIRECT, INDIRECT, INCIDENTAL, SPECIAL, OR CONSEQUENTIAL (INCLUDING LOSS OF PROFITS).

 

 

Attachments