Applies To:
  • CitectSCADA
  • CitectHMI

Summary:
We are finding that when we attempt to print trends, the 8th trend pen is truncated. (Trends do not fit in the printout).

Legend on the bottom of the print out, does not fit on the border that is drawn.

 

Solution:
You will notice this behaviour if your trend names and descriptions are too long. To resolve this you can reduce the number of characters in description field and trend names.

 

Another solution for this problem is to modify cicode in the include project.

WARNING: If you change the Include project we recommend that you take a backup of your changes as reinstalling or upgrading will overwrite your changes to the Include project.

Below is an example with instructions to do so.

The high level code that controls the printing of the trend plots is implemented almost entirely in cicode. Assuming that you are is using either the TrnPlot (found in GRAPH.CI) or the TrnPrint functions (TrnPrint calls TrnPlot). Both of these functions are defined in the include project and can be found by using the "Find User Function" dialog in the edit menu of project editor.

The original TrnPlot function is shown below.

================ START GRAPH.CI EXTRACT
INT
FUNCTION
TrnPlot(STRING sPrinter, INT nSamples, INT time1, REAL period1, STRING title,
INT hAn,
    STRING sTag1 = "", STRING sTag2 = "", STRING sTag3 = "", STRING sTag4 = "",
    STRING sTag5 = "", STRING sTag6 = "", STRING sTag7 = "", STRING sTag8 = "",
    INT Mode = PRINT_MODE_B_AND_W, STRING comment ="",
    STRING LoScale1 = "", STRING HiScale1 ="",
    STRING LoScale2 = "", STRING HiScale2 ="",
    STRING LoScale3 = "", STRING HiScale3 ="",
    STRING LoScale4 = "", STRING HiScale4 ="",
    STRING LoScale5 = "", STRING HiScale5 ="",
    STRING LoScale6 = "", STRING HiScale6 ="",
    STRING LoScale7 = "", STRING HiScale7 ="",
    STRING LoScale8 = "", STRING HiScale8 ="")

    INT error = 0;

    INT hPlot;

    INT txtLength;
    INT LegendLength;

    INT xTopLeft;
    INT yTopLeft;
    INT xBotRite;
    INT yBotRite;

    IF time1 = 0 THEN
        time1 = TimeCurrent();
    END

    IF period1 = 0 THEN
        period1 = TrnInfo(sTag1, 2);
    END

    _PltPensSet(sTag1, sTag2, sTag3, sTag4, sTag5, sTag6, sTag7, sTag8);

    _PltPenScaleSetAll( LoScale1, HiScale1,
        Loscale2, HiScale2,
        LoScale3, HiScale3,
        LoScale4, HiScale4,
        LoScale5, HiScale5,
        LoScale6, HiScale6,
        LoScale7, HiScale7,
        LoScale8, HiScale8);


    IF time1 <= 0 OR period1 <= 0 OR nSamples < 2
        OR _PltPensNumberGet() <= 0 THEN

        ErrLog("Error in TrnPlot: " +
            IntToStr(time1) + " " +
            RealToStr(period1, 12, 4) + " " +
            IntToStr(nSamples) + " " +
            sTag1 + " " +
            sTag2 + " " +
            sTag3 + " " +
            sTag4 + " " +
            sTag5 + " " +
            sTag6 + " " +
            sTag7 + " " +
            sTag8);

        ErrTrap(ERROR_INVALID_ARGUMENT, 0);
        return ERROR_INVALID_ARGUMENT;
    END

    hPlot = PlotOpen(-1,sPrinter,1);
    IF hPlot > BAD_HANDLE THEN

        error = _PltInit(hPlot);

        IF error <> 0 THEN
            return error;
        END

/* Plot Border */
        xTopLeft = xPage * 0.020;
        xBotRite = xPage * 0.980;
        yTopLeft = yPage * 0.020;
        yBotRite = yPage * 0.980;

        _PltBorder(hPlot, xTopLeft, yTopLeft, xBotRite, yBotRite);

/* Plot Title */
        txtLength = StrLength(title) * _PltFontWidthGet(FONT_BIG);
        _PltTitle(hPlot, title, (xTopLeft + xBotRite - txtLength) / 2, yPage * 0.10);

/* Plot Comment */
        txtLength = StrLength(comment) * _PltFontWidthGet(FONT_NORMAL);
        _PltComment(hPlot, comment, (xTopLeft + xBotRite - txtLength) / 2, yPage * 0.12);

/* Plot Trend */
        xTopLeft = xPage * LeftMargin;
        xBotRite = xPage * RiteMargin;
        yTopLeft = yPage * 0.15;
        yBotRite = yPage * 0.70;

        error = _PltTrend(hPlot, nSamples, time1, period1, 0, 0,
xTopLeft, yTopLeft, xBotRite, yBotRite, Mode, PLOT_TYPE_NORMAL, TRN_EVENT_TYPE,
hAn);

/* Plot Legend */
        LegendLength = (dx * 10) + (TEXT_LENGTH_LEGEND_TOT * _PltFontWidthGet(FONT_NORMAL)) + (dx * 2);
        xTopLeft = xPage / 2 - LegendLength / 2;
        xBotRite = xPage / 2 + LegendLength / 2;
        yTopLeft = yPage * 0.74;
        yBotRite = yTopLeft + (dy * (5 + nPens - 1));

        _PltLegend(hPlot, time1, period1, xTopLeft, yTopLeft, xBotRite, yBotRite, Mode);

        PlotClose(hPlot);
    END

    RETURN error;
END
================ END GRAPH.CI EXTRACT

Notice that certain areas of the page are reserved for different elements of the plot. e.g. The actual trend plot starts 15% down the page ("yTopLeft = yPage * 0.15;") and ends 70% down the page ("yBotRite = yPage * 0.70;").

The easiest solution is to modify the positioning of the plot and the legend in TrnPlot. With the trend tags defined in the demonstration picture we found that if the end point of the plot is placed 60% down the page and the legend is started 64% down the page then the legend will not be truncated. To do this change "Plot Trend" and "Plot Legend" sections to the following.

INT
FUNCTION
TrnPlot(STRING sPrinter, INT nSamples, INT time1, REAL period1, STRING title,
INT hAn,



/* Plot Trend */
        xTopLeft = xPage * LeftMargin;
        xBotRite = xPage * RiteMargin;
        yTopLeft = yPage * 0.15;
        yBotRite = yPage * 0.60;

        error = _PltTrend(hPlot, nSamples, time1, period1, 0, 0, xTopLeft, yTopLeft, xBotRite, yBotRite, Mode, PLOT_TYPE_NORMAL, TRN_EVENT_TYPE, hAn);

/* Plot Legend */
        LegendLength = (dx * 10) + (TEXT_LENGTH_LEGEND_TOT * _PltFontWidthGet(FONT_NORMAL)) + (dx * 2);
        xTopLeft = xPage / 2 - LegendLength / 2;
        xBotRite = xPage / 2 + LegendLength / 2;
        yTopLeft = yPage * 0.64;
        yBotRite = yTopLeft + (dy * (5 + nPens - 1));

        _PltLegend(hPlot, time1, period1, xTopLeft, yTopLeft, xBotRite, yBotRite, Mode);
END

Note: This will change the printing of all trends via the TrnPlot function. If this is not acceptable, parallel implementations of TrnPlot customised for the particular graph would be required (or at least some means of configuring the layout).

 

Keywords:
printout, truncated, Legend  

Attachments