Version 4 (modified by csa, 15 years ago) |
---|
The modules are used to provide information of different types to the user. All enabled modules are displayed in the top menu bellow the Search input. The current version of ADEI by default implements:
- WiKi? module provides user-defined information about the system and previews of charts
- Graph module is a main ADEI component providing data plots and easy navigation
- Control module provides access to the control information
It is possible to register new modules providing additional system-specific information. For this, it is necessary to create module file in ADEI modules/ subdirectory. This file should include 3 mandatory methods (the module prefix should be replaced with actual file name without php extension, called the module name. For example, for alarms module instead of $module_title, the $alarms_tittle should be used):
- The variable module_title contains the module name (as it should be shown to the users in menu):
$module_title = _("Title of the Module")
- The function moduleJS contains JavaScript? initialization code
- The function modulePage contains HTML code of the page
Since, the modules are normally dynamically updated during the ADEI execution. The real HTML context should not be set by modulesPage functions, but provided using services. The moduleJS function should initialize JavaScript? object which will take care of context updating and return the name of this object.
When the module is ready it should be enabled in the configuration file config.php (or in the appropriate setup if it should be used optionally).
The ADEI includes several JavaScript? classes providing standard use-cases. They are described bellow.
XML Module
This module uses an ADEI service generating XML content and XSLT stylesheet to update information on the page. The modulePage function should just define a single div element:
<div id="module_div" class="xml_module">Loading...</div>
The moduleJS function initializes new XMLMODULE object supplying the id of div created in modulePage function:
module_object = new XMLMODULE("module_div");
and returns the name of created object:
return "module_object";
Complete example of a module (alarms module):
$alarms_title = _("Alarms"); function alarmsJS() { echo 'alarms = new XMLMODULE("alarms_div");'; return "alarms"; } function alarmsPage() { echo '<div id="alarms_div" class="xml_module">Loading...</div>'; }
By default, the service module_name is used to obtain XML document and stylesheet module_name is used to covert XML into the HTML. The service should reside in the services/ subdirectory (read about creating services here). The XSLT stylesheet should be placed in the xslt folder. However, it is possible to have more elaborated service configuration. For that it is necessary to define special update service. This service should be created in services/update directory and be named module_name.php. It should contain a single function, called ADEIServiceGetUpdateInfo, which accept a REQUEST object as a parameter and return associative array with two elements:
- xml - specifying the full URL of update service along with all properties (the current options could be obtained and modified using GetQueryString? method of REQUEST object, see example bellow)
- xslt - specifying the name of XSLT stylesheet (without extension)
The function is executed on each update and, therefore, can dinamically select the appropriate service depending on some of request parameters.
Example, the alarams update service (it uses control.php service to get XML data and adds two additional parameters to the REQUEST properties):
function ADEIServiceGetUpdateInfo(REQUEST $req) { if ($req->CheckData()) { $query = $req->GetQueryString($extra = array( "target" => "alarms_summary", "time_format" => "text" )); return array( "xml" => "services/control.php?$query", "xslt" => "alarms" ); } return false; }