Common Module Example
The code to enable this menu for the Analog Status tag is as follows:
{=========================== AnalogStatus\Common ===========================}
{ This module handles the common actions associated with all drawing }
{ modules for this point. It will be called by all external drawing }
{ modules. }
{===========================================================================}
(
Left { Area occupied by the drawing object };
Bottom;
Right;
Top;
DisableTrend { Flag to disable trend windows };
DisableNavigation { Flag to disable navigator menu };
DisableTooltip { Flag to disable tool tips };
)
[
PROTECTED TrendPopupDisable { Trend popup Disabled flag };
PROTECTED pNavActive { Pointer to user session nav active flag };
PROTECTED DisableTools { Flag, TRUE if tools are to be disabled };
]
Init [
{ Run functions here to reduce Common state module load }
If Watch(1) Common;
[
pNavActive = &\GetUserSession().NavActive;
]
]
Common [
{ Disable some tools if we're in an editing window or a preview }
DisableTools = TRUE(ParentWindow().Editing);
{*************************************************************************}
{ "Post-it" note section }
{*************************************************************************}
WinTooltipCtrl(Left, Bottom, Right, Top,
WTTS_FLAG_TRACKINACTIVE + (PickValid(\NoBalloonTips, 0) ? 0 : WTTS_FLAG_BALLOON),
GetPhrase(\Description),
\System.ShrinkTagName(\Name, #TOOLTIP_MAX_TITLE_LENGTH, Invalid, Invalid, TRUE),
Invalid,
\ShowTip && ! *pNavActive && PickValid(! DisableTooltip, 1),
\TipFont\Value);
{*************************************************************************}
{ Navigator menu section }
{ Only run the SecurityCheck if trends haven't been disabled by other }
{ parameters. }
{*************************************************************************}
TrendPopupDisable = ! PickValid(((True(DisableTrend) || False(\AITrendEnable))
? Invalid
: \SecurityManager).SecurityCheck(\SecurityManager.PrivBitHDVAccess, 1), 0)
|| True(DisableTrend) || False(\AITrendEnable);
((DisableTools || True(DisableNavigation)) ? Invalid : Self)\Navigator(
TRUE { Disabling is done in the call, not parameters },
Left, Bottom, Right, Top { Target area for opening - same as
the GUI statement area. },
{ Menu line 1 } "HelpLabel", Invalid, 0, "HelpLaunch",
{ Menu line 2 } "--", Invalid, 0, Invalid,
{ Menu line 3 } True(\AlarmStatusLo.IsShelved)
? "UnShelveLowAlarmLabel"
: "ShelveLowAlarmLabel", Invalid, !Valid(\AlarmStatusLo)
? TRUE
: \SecurityManager.PrivBitAlarmShelve,
\LowAlarmNavData,
{ Menu line 4 } True(\AlarmStatusHi.IsShelved)
? "UnShelveHighAlarmLabel"
: "ShelveHighAlarmLabel", Invalid, !Valid(\AlarmStatusHi)
? TRUE
: \SecurityManager.PrivBitAlarmShelve,
\HighAlarmNavData,
{ Menu line 5 } "InhibitLowAlarmLabel", &(\InhibitLo), !Valid(\PriorityLo)
? TRUE
: \SecurityManager.PrivBitAlarmInhibit, Invalid,
{ Menu line 6 } "InhibitHighAlarmLabel", &(\InhibitHi), !Valid(\PriorityHi)
? TRUE
: \SecurityManager.PrivBitAlarmInhibit, Invalid,
{ Menu line 7 } "AlarmSettingsLabel", Invalid, \SecurityManager.PrivBitAlarmInhibit, 3,
{ Menu line 8 } "ViewAlarmsLabel", Invalid, \SecurityManager.PrivBitAlarmPageAccess, "TagAlarmList",
{ Menu line 9 } "--", Invalid, 0, Invalid,
{ Menu line 10} "ManualDataLabel", Invalid, \SecurityManager.PrivBitManualData, 5 { Quality tab },
{ Menu line 11} "LoggingDeadbandLabel" Invalid, \SecurityManager.PrivBitManualData, 7 { Historian tab },
{ Menu line 12} "QuestionableLabel", &(\Questionable), \SecurityManager.PrivBitQuestionable, Invalid,
{ Menu line 13} "PlotDataLabel", Invalid, TrendPopupDisable, "TrendPicked",
{ Menu line 14} "--", Invalid, 0, Invalid,
{ Menu line 15} "PropertiesLabel", Invalid, 0, Invalid);
{*************************************************************************}
{ Trend window pop-up section }
{*************************************************************************}
((DisableTools || True(TrendPopupDisable)) ? Invalid : Self)\PkTrend(Left, Bottom, Right, Top, \Root, TRUE);
]
{ End of AnalogStatus\Common }