30s delay to load PA pen desciption when adding pen via Cicode

I'm using Eric Black's code from the toolbox area to add pens to my Process Analyst objects, however when adding pens, it takes 30s for the pen descriptions to show up....

Any ideas?

Code (I really wish this forum would have codeblock formatting..... It has removed all of the tab formats for your inconvenience:

[CODE]

INT FUNCTION PaAddPen(STRING sPaObjectName, STRING sPen, STRING sNameMode = "Comment", STRING sPenType = "Analog",
INT nPenColor = -1, STRING sPane = "0", INT nWidth = 0, INT nMode = 0, INT nHeight = -1, INT bNextPage = FALSE)

INT cModeAutoScale = 4;
INT cModeUnchecked = 8;
INT cModeNoPoints = 16;
INT cModeStacked = 32;
INT cQueCreate = 1;

OBJECT hPA;
OBJECT hPane;
OBJECT hPens;
OBJECT hPen;
INT nPane;
INT nNameMode;
INT nPenType;
INT nError;
INT nRequestMode;
INT nPen;
INT nUnused;

//Store arguments for display when PaDisplay is called
IF bNextPage = TRUE THEN
Enqueue(sPaObjectName, sPen, sNameMode, sPenType, nPenColor, sPane, nWidth, nMode, nHeight);
RETURN 0;
END

hPA = ObjectByName(sPaObjectName);
nError = IsError();
IF nError <> 0 THEN
RETURN mcErrNameNotExist;
END

hPane = GetPane(hPA, sPane);

//Set pen type
SELECT CASE sPenType
CASE "Digital", "4098"
nPenType = 4098;
CASE "Alarm", "4099"
nPenType = 4099;
CASE ELSE
nPenType = 4097;
END SELECT

//Set name mode
SELECT CASE sNameMode
CASE "Tag", "2"
nNameMode = 2;
CASE "Pen", "3"
nNameMode = 3;
CASE ELSE //"Comment"
nNameMode = 1;
END SELECT

// _ObjectCallMethod(hPA, "BlockUpdates"); //Allow multiple changes without screen flicker

//Create pen
hPens = _ObjectGetProperty(hPane, "Pens");
hPen = _ObjectCallMethod(hPens, "Create", nPenType, nNameMode);
_ObjectCallMethod(hPA, "UnBlockUpdates");
// _ObjectCallMethod(hPA, "BlockUpdates");
_ObjectSetProperty(hPen, "DataPoint", sPen);

//Set request mode. Matches first 2 bits of mode argument
nRequestMode = nMode BITAND 0x03;
_ObjectSetProperty(hPen, "RequestMode", nRequestMode);

IF ModeIs(nMode, cModeAutoScale) THEN
_ObjectSetProperty(hPen, "VerticalAxisAutoscale", TRUE);
END

IF ModeIs(nMode, cModeUnChecked) THEN
PenSetChecked(hPA, hPen, FALSE);
END

IF ModeIs(nMode, cModeNoPoints) THEN
_ObjectSetProperty(hPen, "PointsVisible", TRUE);
END

IF ModeIs(nMode, cModeStacked) THEN
_ObjectSetProperty(hPen, "Stacked", TRUE);
IF (nHeight >= 16) AND (nHeight <= 1000) THEN
_ObjectSetProperty(hPen, "Height", nHeight);
END
END

//Set pen color
IF nPenColor = -1 THEN
nPen = StrToInt(_ObjectGetProperty(hPens, "Count")) - 1;
nPenColor = nPenColors[nPen MOD 15];
END
_ObjectSetProperty(hPen, "LineColor", nPenColor);

//Set pen thickness
IF (nWidth > 1) AND (nWidth <= 8) THEN
_ObjectSetProperty(hPen, "LineWidth", nWidth);
END

_ObjectCallMethod(hPA, "UnBlockUpdates");

RETURN IsError();
END

[/CODE]

Parents
  • When you say 'the pen descriptions' take 30sec, what do you mean? There is an object tree column that has the pen name/comment, and optionally a separate Comment column and a Tagname column.

    The Object Tree column can display either the trend tag name or the trend comment or a custom name. By default, my Cicode tells Process Analyst to look up the tag comment and display that, but you can choose what to display with the sNameMode argument. It would help if you gave an example of the command you were using so I knew what arguments you had. It is possible PA may work faster if you set the name mode to "Tag".

    The built-in ProcessAnalystSetPen() function (which was created after I wrote my code) is hard-coded to use the tag name as the pen name.

Reply
  • When you say 'the pen descriptions' take 30sec, what do you mean? There is an object tree column that has the pen name/comment, and optionally a separate Comment column and a Tagname column.

    The Object Tree column can display either the trend tag name or the trend comment or a custom name. By default, my Cicode tells Process Analyst to look up the tag comment and display that, but you can choose what to display with the sNameMode argument. It would help if you gave an example of the command you were using so I knew what arguments you had. It is possible PA may work faster if you set the name mode to "Tag".

    The built-in ProcessAnalystSetPen() function (which was created after I wrote my code) is hard-coded to use the tag name as the pen name.

Children
No Data