Advanced Search
HomeTechnical DocumentsTipsTivoliEnterprise Console › Listing Available TEC Templates/Predicates

Listing Available TEC Templates/Predicates

Sometimes when you are writing TEC rules it would be useful to know all the templates or predicates that are available in the version of the TEC you are currently using. This can be accomplished by adding a simple rule into your current rule base which will create an ASCII file which will list all predicates currently available.

Therefore this weeks tip explains this simple procedure.

The Rule

Create a file called templates.rls and add the following rule into the file.

Open in New Window
rulelist_templates:
(
    
event_event of_class 'TEC_Start',

    
reception_action:
    (
        
telling(_list),
        
tell('/tmp/templates.txt'),
        
listing,
        
told,
        
tell(_list)
    )
).
?>

Applying the Rule

  • Add the following line to the rule_sets file in the TEC_RULES directory of your rulebase.

rule_set(templates, 'templates.rls', active).

e.g.

rule_set(templates, 'templates.rls', active).
rule_set(forward, 'forward.rls', active).
rule_set(ov_default, 'ov_default.rls', active).
rule_set(log_default, 'log_default.rls', active).
rule_set(tecad_snaevent, 'tecad_snaevent.rls', inactive).

  • Compile the rule base.

wcomprules <rule_base>

  • Load the rule base.

wloadrb <rule_base>

  • Stop the event server.

wstopesvr

  • Start the Event Server.

wstartesvr

Viewing the file

Wait until the templates.txt file stops growing before attempting to open it, you can then view the listing of the templates in the file /tmp/templates.txt.

Part of the templates.txt file is shown below.

Open in New Window
forward_event_event ) :-
   
re_enqueue(forward_events,rule_engine_event ) .

get_global_var_groupkey _key _into _init ) :-
 ( 
recorded_groupkey _key _into ) -> true;
   
set_global_var_groupkey _key _init ),
       
_into  =  _init  ),
   ! .

set_global_var_groupkey _key _to ) :-
   
rerecord_groupkey _key _to ),
   
re_register_global_var_groupkey _key ),
   ! .

reset_global_grp_groupkey _to ) :-
   
recorded(re_global_vars_vars ),
   
maplist(re_set_group_groupkey _to ), _vars ),
   ! .

get_global_grp_groupkey _key _into ) :-
   
recorded(re_global_vars_vars ),
   
member([ _groupkey _key ], _vars ),
   
get_global_var_groupkey _key _into ,'') .

re_register_global_var_groupkey _key ) :-
   
recorded(re_global_vars_vars ),
 ( 
not_in_list([ _groupkey _key ], _vars ) -> front([ _groupkey key ], _var
   true 
) .

re_set_group_groupkey _to ,[ _groupkey _key ]) :-
   
set_global_var_groupkey _key _to ),
   ! .
?>

Once you have the list you can remove the rule from the rule base.