While writing Tcl scripts, it is important to keep in mind that the same script works interactively (with the GUI) and in Replay mode.
Scripts that are hooked up to the tasks in the process must be name spaced. The Process Manager engine creates the namespace and the modules must be in that namespace. ::hw::pmgr::${::hw::pmgr::namespace}::DisplayWnd {} For example, Process Manager expects the functions shown above to exist in the namespace shown. |
There are four main procedures expected in the Tcl script, which are expected to do the following tasks: DisplayWnd
proc ::hw::pmgr::${::hw::pmgr::namespace}::DisplayWnd {} variable mainWnd; variable id; variable m_strFileName; set mynamespace ::hw::pmgr::${::hw::pmgr::namespace};
if {[WndExists] == 0} CreateWnd "HWPM -- Load Template" "Import"
# Create all the UI components set txtFileName [entry $mainWnd.txtFileName -font [hwt::AppFont] \ -textvariable ${mynamespace}::m_strFileName -width 60]
. . .
#Get the data from the DataModel and update the UI GetDataFromDataModel; } return 0; }
SetDataInDataModel
· Checks to see if any of the member variable values have changed from what is currently in the DataModel.
proc ::hw::pmgr::${::hw::pmgr::namespace}::SetDataInDataModel {} variable mainWnd; variable id; variable m_strFileName;
set nDataChanged 0;
# Set all the data from the UI into the data model. # As we set, check if the data has changed
#Set the HM filename in the data model if {$m_strFileName != \ [::hw::pmgr::PmgrGetData $id ${id}::HM_FILENAME]} ::hw::pmgr::PmgrSetData $id ${id}::HM_FILENAME $m_strFileName; set nDataChanged 1; }
if {$nDataChanged == 0} RestoreOriginalState; }; } GetDataFromDataModel · Get data from the DataModel and initialize the member variables. · If the value of the data from the DataModel is "", initialize the member variable with default value. proc ::hw::pmgr::${::hw::pmgr::namespace}::GetDataFromDataModel {} variable mainWnd; variable id; variable m_strFileName;
#Get the HM filename in the data model set m_strFileName [::hw::pmgr::PmgrGetData $id ${id}::HM_FILENAME]; if {$m_strFileName == ""} set m_ strFileName "D:/altair/demos/hm/bumper.hm" } } Exec · This is the heart of the module and will do whatever needs to be done by the module.
|
CreateWnd· This method will create a window with the Apply, Next, Prev, Cancel buttons.
WndExists · Will be implemented in the future.
RestoreOriginalState · This method will restore the (completion) state of the task to what it was prior to you visiting/revisiting the task.
variable id · This variable is set as the name of the task.
Variable mainWnd · The CreateWnd method sets this variable.
####################################################################### # Create the UI components in the window ####################################################################### proc ::hw::pmgr::${::hw::pmgr::namespace}::DisplayWnd {} variable mainWnd; variable id;
if {[WndExists] == 0} CreateWnd "HWPM -- Load Template" "Apply"
# Add other components to the UI set lblTpl [label $mainWnd.lblwip -text "Madymo template:" \ -font [hwt::AppFont] -anchor w]; set txtfldMadFileName [entry $mainWnd.madymofile \ -font [hwt::AppFont] -width 60] set btnMadFBrowser [button $mainWnd.fb -text " Browse... " \ -command "::hw::pmgr::${::hw::pmgr::namespace}::OnBrowseMadymoFile" \ -font [hwt::AppFont]]; pack $ lblTpl $txtfldMadFileName $btnMadFBrowser \ -side left -padx 5 -pady 5
#Get the data from the DataModel and update the UI GetDataFromDataModel } return 0; } |