dm_create_cb()
Defines a callback function. Callbacks can be registered with create_parm() and create_item() function calls. For example:
create_item( ...list(dm_create_cb(...), dm_create_cb() ...)); create_parm(...list (dm_create_cb(...), dm_create_cb() ...));
Also, the callback function is invoked in the event of component/parameter activities. The cbFunction is called with the following protocol:
cbFunction (cbP, clientDataStr, callData)
Returns a callback function.
See also: pcb_get_mks(), pcb_set_mks(), pcb_get_form_value(), pcb_set_form_value(), pcb_get_string(), pcb_set_string(), Parameter Callbacks in the Design Kit Development manual.
Syntax:
dm_create_cb(cbType, cbFunctionNameStr, clientDataStr[, enableFlag]);
where
cbType is the type of callback function, where:
- PARM_DEFAULT_VALUE_CB = the callback function is called when the parm definition default value is needed in the pde program.
- PARM_MODIFIED_CB = the callback function is called when the parameter value is changed.
- ITEM_NETLIST_CB = the callback function is called when the instance of the component is netlisted.
- ITEM_PASTE_CB = the callback function is called when the instance of the component is pasted.
cbFunctionNameStr is the name of the cb function. This function takes three arguments: The first is the callback pointer (for program use only). The second is the clientDataStr. The third is calldata.
- For PARM_DEFAULT_VALUE_CB, the third argument, calldata, is the handle to the parameter definition. The return value of cbFunctionNameStr must be the actual parameter value. This can be created by prm().
- For PARM_MODIFIED_CB, the third argument, calldata, is to be passed as the first argument of pcb_get_mks(), pcb_get_form_value(), or pcb_get_string(). See these individual functions for more information. The return value cbFunctionNameStr must be the return value from pcb_set_mks(), pcb_set_form_value(), or pcb_set_string().
- For ITEM_NETLIST_CB, the third argument, calldata, is not used. The return value of cbFunctionNameStr must be the string that is output to the netlist.
- For ITEM_PASTE_CB, the third argument, calldata, is the instance handle and does not require anything to be returned.
clientDataStr is the client data in string format. This gets passed to the cb function as the second argument.
enableFlag is a flag, where TRUE = enable this function. If disabled, the callback function will not be invoked.
Example:
This example demonstrates how to specify a default value callback so the default value can be retrieved dynamically.
create_item( "myItem", "My Item", "MyItem", 0, "myitem", standard dialog, "*", ComponentNetlistFmt, "", componentAnnotFmt, "SYM_MyItem", no_artwork, NULL, ITEM_PREMITIVE_EX, create_parm( "Len", "Length", 0, "StdFormSet", LENGTH_UNIT, prm( "StdForm", "1.0 mil"), list( dm_create_cb(PARM_DEFAULT_VALUE_CB, "my_item_get_default_inductance_cb", "", TRUE)))); defun my_get_default_length_unit() { return "mil"; } defun my_item_get_default_inductance_cb(cbP, // callback handle - not used in this example clientDataStr, // not used in this example callData) // the parmDef - not used in this example { if(my_get_default_length_unit()=="mil") return prm("StdForm", "10 mil"); if(my_get_default_length_unit()=="mm") return prm("StdForm", "2 mm"); if(my_get_default_length_unit()=="um") return prm("StdForm", "1.0 um"); return prm("StdForm", "1.0 mil"); }
For examples using PARM_MODIFIED_CB, see pcb_get_mks(), pcb_set_mks(), pcb_get_form_value(), pcb_set_form_value(), pcb_set_string(), pcb_get_string(), and Parameter Callbacks in the Design Kit Development manual.
This example demonstrates the use of ITEM_PASTE_CB
#voc(SimCmd)
defun paste_item_measurement_cb (cbP, clientData, callData)
{
decl value, instName, designName, repType, parmName;
decl paramHandle, subParamHandle, meas, measList, newMeas;
//fputs(stderr, "n...paset_item_measurement_cb");
//fputs(stderr, identify_value(callData));
if (callData)
{
instName=db_get_instance_attribute (callData, INST_NAME);
designName=de_current_design_name();
repType= de_get_current_design_rep_type();
}
//fputs (stderr, strcat("instName=",identify_value (instName)));
paramHandle = db_get_instance_attribute(callData, INST_PARAM_HEAD);
parmName=db_get_parm_attribute(paramHandle, PARM_NAME);
paramHandle = db_first_parm(paramHandle);
subParamHandle = db_get_parm_attribute(paramHandle, PARM_VALUE_LIST);
subParamHandle = db_first_parm(subParamHandle);
/* Modified the first one only */
decl mIndex=0;
while (subParamHandle != NULL)
{
meas=db_get_parm_attribute(subParamHandle, PARM_VALUE_SVALUE);
//fputs (stderr, strcat("meas=",identify_value (meas)));
if (index(meas, "=") == -1)
return list(prm ("SingleTextLine", meas));
measList=parse(meas, "=");
meas = strcat(instName, " =", nth(1, measList));
//fputs (stderr, identify_value (meas));
if (meas)
de_update_inst_parm_value(designName, instName, parmName, mIndex, meas, repType);
break;
subParamHandle=db_next_parm(subParamHandle);
mIndex++;
}
newMeas=db_get_parm_attribute(subParamHandle, PARM_VALUE_SVALUE);
de_repaint_parm(newMeas, mIndex);
}
#voc()
Where Used:
Schematic
Privacy
Statement
|
Terms of Use
|
Legal |
Contact Us
|
© Agilent 2000-2008 ![]()