cyber_effects_cmd_register()
Abstract
Registers a supported effect with a node’s cyber-effects manager.
Syntax
cyber_effects_cmd_register (mgr_ptr, cmd_category, cmd_index, module, process, cmd_proc, cancel_proc, intrpt_code, client_state_vptr)
| Argument | Type | Description |
|---|---|---|
mgr_ptr |
CyberT_Effect_Mgr* |
Cyber-effects manager on which to register effect. The handle can be obtained by calling cyber_effects_mgr_handle_get(). |
cmd_category |
int |
Value assigned to identify the effect category. Defined categories are: 0–General 1–IP Client modules can add new category values. |
cmd_index |
int |
Integer value that uniquely identifies the effect within a given category |
module |
Objid |
Object ID of the client module |
process |
Prohandle |
Process ID of the client process registering the effect |
cmd_proc |
CyberT_Effect_Proc_Ptr |
Pointer to callback procedure that implements the effect within the client module |
cancel_proc |
CyberT_Effect_Proc_Ptr |
Pointer to callback procedure that implements cancellation of the effect within the client module |
intrpt_code |
int |
Interrupt code value that the client module/process wants to receive when the effect is commanded by the cyber-effects manager |
client_state_vptr |
void* |
A local memory in the client module/process that can be used to store information that represents the initial state of any data used by the effect. It is passed in the model_data_vptr argument of CyberT_Effect_Proc_Ptr. For example, this can be used within cancel_proc to help cancel the effect. |
Return Type
void
no return value
Header
cyber_effects.h
Example
From ip_rte_central_cpu function block:
double one_over_service_rate; /* Number of packets handled by routing processor per second */
static void
ip_rte_routing_processor_info_init (void)
{
...
/* Cyber Effects settings. */
effects_mgr_ptr = cyber_effects_mgr_handle_get ();
/* If a Cyber Effects manager is present in the node... */
if (effects_mgr_ptr != OPC_NIL)
{
// Allocate memory to store any data to undo the effects if needed.
effects_cancel_data_ptr = op_prg_mem_alloc (sizeof(Ip_Central_Cpu_Effect_State));
effects_cancel_data_ptr->one_over_service_rate_backup = one_over_service_rate;
/* Register Cyber Effects available at this process model. */
cyber_effects_cmd_register
(effects_mgr_ptr,
CyberC_IP, // Effect Category.
CyberC_Decrease_Fwd_Rate, // Effect: Decrease IP forwarding rate.
own_id, // Client module ID.
own_prohandle, // Client process handle.
cyber_effect_change_service_rate_to_cmd_proc, // Effect callback
cyber_effect_change_service_rate_to_cancel_cmd_proc, // Cancel callback
CMD_INTRPT_CODE_CHANGE_FWD_RATE, // Interrupt code number to receive when this process is interrupted to execute this effect.
effects_cancel_data_ptr // Data to undo the effect (used by cancel proc if needed).
);
...
}
}
Details
This function is called by a module client of the cyber effects framework in order to register an effect implemented by that module. After the effect has been registered, the module can be notified by the cyber-effects manager if and when the execution of such an effect is required.
It is important to confirm that the node contains a cyber-effects manager module before registering an effect.