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
  • Hi Nick,

    Seems like it might be the result of the lack of Cluster context.
    Could you try calling PaAddPen with sPen = "MyCluster.Trend" ?

    This works for me, however only when I have the PA on display, calling :
    PaAddPen("_templatePA1", "Cluster1.LOOP_1_PV", "", "", -1, "", 0, 0, -1, TRUE);
    PaAddPen("_templatePA1", "Cluster1.LOOP_2_SP", "", "", -1, "", 0, 0, -1, TRUE);
    PaDisplay("SinglePA", "Blank");

    Still has the delay, not sure why.
Reply
  • Hi Nick,

    Seems like it might be the result of the lack of Cluster context.
    Could you try calling PaAddPen with sPen = "MyCluster.Trend" ?

    This works for me, however only when I have the PA on display, calling :
    PaAddPen("_templatePA1", "Cluster1.LOOP_1_PV", "", "", -1, "", 0, 0, -1, TRUE);
    PaAddPen("_templatePA1", "Cluster1.LOOP_2_SP", "", "", -1, "", 0, 0, -1, TRUE);
    PaDisplay("SinglePA", "Blank");

    Still has the delay, not sure why.
Children
No Data