DevMethodInitialise is called by the application after the device has been created. It is used to retrieve the device related parameters from the database and to do the active (i.e. physical device related) initialisation of the device.
The device initialise method should have following calling syntax -
static long object_initialise(DevServer ds, long *error)
Here is an example device initialise method (for the AGPowerSupplyClass) -
/*====================================================================== Function: static long object_initialise() Description: initialise a AGPowerSupply object. This involves retrieving all resources for this device from the resource database. Arg(s) In: AGPowerSupply *name - name of object. Arg(s) Out: long *error - pointer to error code (in case of failure) =======================================================================*/ static long object_initialise(ps,error) AGPowerSupply ps; long *error; { printf("arrived in object_initialise()\n"); /* * initialise powersupply with values defined in database */ res_table[0].resource_adr = &(ps->devserver.state); res_table[1].resource_adr = &(ps->powersupply.set_val); res_table[2].resource_adr = &(ps->powersupply.channel); res_table[3].resource_adr = &(ps->powersupply.n_ave); res_table[4].resource_adr = &(ps->powersupply.conv_unit); res_table[5].resource_adr = &(ps->powersupply.set_offset); res_table[6].resource_adr = &(ps->powersupply.read_offset); res_table[7].resource_adr = &(ps->powersupply.set_u_limit); res_table[8].resource_adr = &(ps->powersupply.set_l_limit); res_table[9].resource_adr = &(ps->powersupply.polarity); if(db_getresource(ps->devserver.name,res_table,res_tab_size,error)) { printf("class_initialise(): db_getresource() failed, error %d\n",error); return(DS_NOTOK); } else { printf("initial values after searching the static database for %s\n\n", ps->devserver.name); printf("state D_LONG_TYPE %6d\n",ps->devserver.state); printf("set_val D_FLOAT_TYPE %6.0f\n",ps->powersupply.set_val); printf("channel D_SHORT_TYPE %6d\n",ps->powersupply.channel); printf("n_ave D_SHORT_TYPE %6d\n",ps->powersupply.n_ave); printf("conv_unit D_STRING_TYPE %6s\n",ps->powersupply.conv_unit); printf("set_offset D_FLOAT_TYPE %6.0f\n",ps->powersupply.set_offset); printf("read_offset D_FLOAT_TYPE %6.0f\n",ps->powersupply.read_offset); printf("set_u_limit D_FLOAT_TYPE %6.0f\n",ps->powersupply.set_u_limit); printf("set_l_limit D_FLOAT_TYPE %6.0f\n",ps->powersupply.set_l_limit); printf("polarity D_SHORT_TYPE %6d\n",ps->powersupply.polarity); /* * interpret the initial state of the powersupply */ if (ps->devserver.state == 1) { printf("switching ON\n"); dev_on(ps,NULL,NULL,error); /* * if switched ON then set the current too */ dev_setvalue(ps,&(ps->powersupply.set_val),NULL,error); } else { printf("switching OFF\n"); /* * default is to assume the powersupply is OFF */ dev_off(ps,NULL,NULL,error); } } return(DS_OK); }