Functions | |
| CDI_EXPORT int | cdiRegisterBusCleanup (char *busName, int(*fcn)(int)) |
| registers the bus cleanup function used when CDI closes. | |
| CDI_EXPORT int | cdiRegisterBusHandler (char *busName, void(*fcn)(CdiRequestInfoBlk *)) |
| registers the bus handler dispatch function used for bus io. | |
| CDI_EXPORT int | cdiRegisterBusInitialization (char *busName, int(*fcn)(int, int, int, char *)) |
| registers a bus initialization function to be used by CDI when initializing the bus. | |
| CDI_EXPORT int | cdiRegisterBusScanner (char *busName, int(*fcn)(char *, char *, int)) |
| registers the bus scan function used for CDI diagnostics. | |
| CDI_EXPORT int | cdiRegisterCalibrationFunction (char *fcnName, double(*fcn)(double)) |
| registers a calibration function for use by CDI | |
| CDI_EXPORT int cdiRegisterBusCleanup | ( | char * | busName, | |
| int(*)(int) | fcn | |||
| ) |
registers the bus cleanup function used when CDI closes.
This routine will be called when CDI closes and allows the bus to free up resources, etc.
| busName | is the bus plug name to be used by database entries refering to this bus plug. | |
| fcn | is the address of the bus cleanup function to be called when CDI closes. The function must have the prototype int fcn(int line) and return '0' if the call was successful. The line parameter will contain the bus line which is being closed. |
#define BUSPLUG_NAME "SIMULATE" #ifdef WIN32 # define BUSPLG_EXPORT __declspec(dllexport) #else # define BUSPLG_EXPORT #endif BUSPLG_EXPORT void simulationHandler(CdiRequestInfoBlk *pReq) { // handle the request .... } // other functions follow suit ... int cdiInitSimulate(void) { int cc = 0; if ((cc=cdiRegisterBusFilter(BUSPLUG_NAME,filterSimulation)) != 0 ) goto err; if ((cc=cdiRegisterBusInitialization(BUSPLUG_NAME,initSimulation)) != 0 ) goto err; if ((cc=cdiRegisterBusHandler(BUSPLUG_NAME,simulationHandler)) != 0 ) goto err; if ((cc=cdiRegisterBusCleanup(BUSPLUG_NAME,exitSimulation)) != 0 ) goto err; if ((cc=cdiRegisterBusScanner(BUSPLUG_NAME,scanSimulationBus)) != 0 ) goto err; err: if (cc) { cdilog("%s : failure in bus registration SEDPC",erlst[cc]); } return cc; } #if defined(WIN32) BOOL WINAPI DllMain(HINSTANCE hInstDll,DWORD fdwReason,LPVOID lpvReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH: // DLL being loaded cdiInitSimulate(); break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: // DLL being unloaded break; } return (TRUE); } #elif defined(UNIX) __attribute__((constructor)) void cdiSimulateMain(void) { cdiInitSimulate(); return; } #endif
| CDI_EXPORT int cdiRegisterBusHandler | ( | char * | busName, | |
| void(*)(CdiRequestInfoBlk *) | fcn | |||
| ) |
registers the bus handler dispatch function used for bus io.
This is the principal dispatch routine used to commuicate with the hardware bus. All 'SEND' and 'RECV' activity flow through this routine. Any calls will provide the complete CdiRequestBlk defining the requested transaction, and it is the duty of the bus plug to process the request and return.
| busName | is the bus plug name to be used by database entries refering to this bus plug. | |
| fcn | is the address of the bus handler function to be called when CDI accesses the hardware bus. The function must have the prototype int fcn(CdiRequestBlk *reqBlk) and return '0' if the call was successful. The CDI Request Block will define the nature of the requested transaction in its entirety. All associated parameter lists will be provided within this structure. |
#define BUSPLUG_NAME "SIMULATE" #ifdef WIN32 # define BUSPLG_EXPORT __declspec(dllexport) #else # define BUSPLG_EXPORT #endif BUSPLG_EXPORT void simulationHandler(CdiRequestInfoBlk *pReq) { // handle the request .... } // other functions follow suit ... int cdiInitSimulate(void) { int cc = 0; if ((cc=cdiRegisterBusFilter(BUSPLUG_NAME,filterSimulation)) != 0 ) goto err; if ((cc=cdiRegisterBusInitialization(BUSPLUG_NAME,initSimulation)) != 0 ) goto err; if ((cc=cdiRegisterBusHandler(BUSPLUG_NAME,simulationHandler)) != 0 ) goto err; if ((cc=cdiRegisterBusCleanup(BUSPLUG_NAME,exitSimulation)) != 0 ) goto err; if ((cc=cdiRegisterBusScanner(BUSPLUG_NAME,scanSimulationBus)) != 0 ) goto err; err: if (cc) { cdilog("%s : failure in bus registration SEDPC",erlst[cc]); } return cc; } #if defined(WIN32) BOOL WINAPI DllMain(HINSTANCE hInstDll,DWORD fdwReason,LPVOID lpvReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH: // DLL being loaded cdiInitSimulate(); break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: // DLL being unloaded break; } return (TRUE); } #elif defined(UNIX) __attribute__((constructor)) void cdiSimulateMain(void) { cdiInitSimulate(); return; } #endif
| CDI_EXPORT int cdiRegisterBusInitialization | ( | char * | busName, | |
| int(*)(int, int, int, char *) | fcn | |||
| ) |
registers a bus initialization function to be used by CDI when initializing the bus.
After the CDI database has been read and processed, CDI will call any bus initialization routines which need to be called, so as to set up the hardware bus for hardware io.
| busName | is the bus plug name to be used by database entries refering to this bus plug. | |
| fcn | is the address of the bus initialization function to be called when CDI initializes the bus. The function must have the prototype int fcn(int busLine, int cdiLine, int numberDevices, char *parameterList) and return '0' if the initialization was successful. This initialization dispatch function will receive (according to the registered database entries) the bus line number (from the database), the CDI line number (a CDI internal line number), the total number of registered devices, and the parameter list (if any) supplied with the bus registration. |
#define BUSPLUG_NAME "SIMULATE" #ifdef WIN32 # define BUSPLG_EXPORT __declspec(dllexport) #else # define BUSPLG_EXPORT #endif BUSPLG_EXPORT void simulationHandler(CdiRequestInfoBlk *pReq) { // handle the request .... } // other functions follow suit ... int cdiInitSimulate(void) { int cc = 0; if ((cc=cdiRegisterBusFilter(BUSPLUG_NAME,filterSimulation)) != 0 ) goto err; if ((cc=cdiRegisterBusInitialization(BUSPLUG_NAME,initSimulation)) != 0 ) goto err; if ((cc=cdiRegisterBusHandler(BUSPLUG_NAME,simulationHandler)) != 0 ) goto err; if ((cc=cdiRegisterBusCleanup(BUSPLUG_NAME,exitSimulation)) != 0 ) goto err; if ((cc=cdiRegisterBusScanner(BUSPLUG_NAME,scanSimulationBus)) != 0 ) goto err; err: if (cc) { cdilog("%s : failure in bus registration SEDPC",erlst[cc]); } return cc; } #if defined(WIN32) BOOL WINAPI DllMain(HINSTANCE hInstDll,DWORD fdwReason,LPVOID lpvReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH: // DLL being loaded cdiInitSimulate(); break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: // DLL being unloaded break; } return (TRUE); } #elif defined(UNIX) __attribute__((constructor)) void cdiSimulateMain(void) { cdiInitSimulate(); return; } #endif
| CDI_EXPORT int cdiRegisterBusScanner | ( | char * | busName, | |
| int(*)(char *, char *, int) | fcn | |||
| ) |
registers the bus scan function used for CDI diagnostics.
This routine will be called when CDI closes and allows the bus to free up resources, etc.
| busName | is the bus plug name to be used by database entries refering to this bus plug. | |
| fcn | is the address of the bus scan function to be called when CDI issues a bus scan. It depends completely on the bus as to what consitutes a scan operation. The function must have the prototype int fcn(char *target,char *result,int resultBufferSize) and return '0' if the call was successful. The 'target' will simply be a character string giving the desired scan operation (e.g. 'crates', 'addresses'). The 'result' will likewise be a character string giving the results of the scan. 'resultBufferSize' gives the total string capacity of 'result', so that the bus plug can know note to overwrite the given buffer. |
#define BUSPLUG_NAME "SIMULATE" #ifdef WIN32 # define BUSPLG_EXPORT __declspec(dllexport) #else # define BUSPLG_EXPORT #endif BUSPLG_EXPORT void simulationHandler(CdiRequestInfoBlk *pReq) { // handle the request .... } // other functions follow suit ... int cdiInitSimulate(void) { int cc = 0; if ((cc=cdiRegisterBusFilter(BUSPLUG_NAME,filterSimulation)) != 0 ) goto err; if ((cc=cdiRegisterBusInitialization(BUSPLUG_NAME,initSimulation)) != 0 ) goto err; if ((cc=cdiRegisterBusHandler(BUSPLUG_NAME,simulationHandler)) != 0 ) goto err; if ((cc=cdiRegisterBusCleanup(BUSPLUG_NAME,exitSimulation)) != 0 ) goto err; if ((cc=cdiRegisterBusScanner(BUSPLUG_NAME,scanSimulationBus)) != 0 ) goto err; err: if (cc) { cdilog("%s : failure in bus registration SEDPC",erlst[cc]); } return cc; } #if defined(WIN32) BOOL WINAPI DllMain(HINSTANCE hInstDll,DWORD fdwReason,LPVOID lpvReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH: // DLL being loaded cdiInitSimulate(); break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: // DLL being unloaded break; } return (TRUE); } #elif defined(UNIX) __attribute__((constructor)) void cdiSimulateMain(void) { cdiInitSimulate(); return; } #endif
| CDI_EXPORT int cdiRegisterCalibrationFunction | ( | char * | fcnName, | |
| double(*)(double) | fcn | |||
| ) |
registers a calibration function for use by CDI
Bus actions 'SEND' and 'RECV' send and receive raw data to and from the hardware bus according to the bus format registered with the corresponding device. The raw data can be automatically calibrated (receive) or reverse calibrated (send) by CDI if calibration rules are specified. If the calibration rules are too complex to be dealt with be the systematically known rules set, then one can make use of a calibration function registered via this call.
| fcnName | is the function name in plain text to be stored in the CDI function library. | |
| fcn | is the address of the function to be called when the calibation rule is to be used. The function must take a one paramter as input (data type double) and return the calibrated parameter (also as data type double). |
#ifdef WIN32 # define FCN_EXPORT __declspec(dllexport) #else # define FCN_EXPORT #endif FCN_EXPORT double bit12sgn(double v) { short w = (short)v; short sgn = sgn = (w & 0x0800) == 0 ? 1 : -1; w &= 0x07ff; w *= sgn; return (double)w; } FCN_EXPORT double nib2exp(double v) { short w = (short)v; return (double)((w&0xfff) * pow(10,-((short)(w>>12)))); } void cdiRegisterFunctions(void) { cdiRegisterCalibrationFunction("bit12sgn",bit12sgn); cdiRegisterCalibrationFunction("nib2exp",nib2exp); } #if defined(WIN32) BOOL WINAPI DllMain(HINSTANCE hInstDll,DWORD fdwReason,LPVOID lpvReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH: // DLL being loaded cdiRegisterFunctions(); break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: // DLL being unloaded break; } return (TRUE); } #elif defined(UNIX) __attribute__((constructor)) void cdiCalibrateMain(void) { cdiRegisterFunctions(); return; } #endif
1.5.8