Tuesday, October 30, 2012

Cicode- SCADA


/*This function will draw a scale to the left of a Bar near the X Y location the calling Advanced Animation with the following command IF StrToInt(PageInfo(7))=0 THEN Scale1();END
Color = Color number of the Scale (see Help - Color Names and Numbers)
Div   = Number of Divisions to place on the Scale*/


FUNCTION
_DspBarScale(String sColor="Black",INT Div=5)

    INT     hAn;
    INT hPlot;
    INT X;
    INT Y;
    INT Top;
    INT Left;
    INT Bottom;
    INT Right;
    INT AN;
    INT I;
    INT PlotAn;

    AN=DspGetAnCur();                   !Get Calling An
    DspAnGetPos(AN, X, Y);                  !Get position of Calling An
    hAn=DspGetNearestAn(X, Y)
    WHILE (DspAnInfo(hAn, 0) <> "2") AND (I < 60) DO    !Check if bar found within 60 Pixels
        I=I+1;
        hAn=DspGetNearestAn(X+I, Y);            !Get handle of nearest An
    END
    IF DspAnInfo(hAn, 0)= "2" THEN              !Check if bar found
       
        DspGetAnExtent(hAn, Top, Left, Bottom, Right);      !Get boundary of Nearest An
        PlotAn = DspAnNewRel(hAn, -5, 0);               !Creat new An
        hPlot = PlotOpen(PlotAn, "Display", 1);
        PlotGrid(hPlot, 2, 0, Top-Bottom, 2, 0, 1, Transparent, 1, Transparent, 1, Dark_Grey, Transparent, 0);
        PlotScaleMarker(hPlot, 0, 0, Div, 1, sColor, 1);
        PlotClose(hPlot);
    ELSE
        prompt("@(Scale-can't find bar)");
    END
END

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.