In the Garage MIB, there is read-only object called, garageNumVehicles. As a developer of this Garage agent, you will need to add code to OnGet_GarageNumVehicles function. This function belongs to DGarageObjects class.
The code generator generated the following code for this function
// garageNumVehicles ::= garageObjects.2 [ND-GARAGE-MIB]
SNMP_ERRSTAT DGarageObjects::OnGet_GarageNumVehicles(tUint32 transactionId, tASN_INT& nVal)
nVal = m_nGarageNumVehicles;
The code generator has put code in this function so that agent can be compiled and run without additional code from a developer. It is a fully functional agent returning canned values for objects. The developer will need to insert his/her own code in this function to retrieve the number of cars in the garage. First off, NDRANDOMIZE _INT(m_nGarageNumVehicles),will be removed from the function. It may be replaced by a function call to retrieve the number of vehicles in the garage or there might be a separate thread running concurrently that periodically updates the m_nGarageNumVehicles variable. How it is done is left to the developer of the agent and architecture that best suits his/her agent.
‘NDRANDOMIZE_INT’ is only put in the ‘onGet’ functions if the syntax of the object is a number (e.g. INTEGER, Gauge, Counter etc.). If there are a large number of mib objects that are of similar type, it may be easier to just remove the _MBCS,XAB_RANDOM label from the project settings or not checking off ‘Change value on each request’ check off box in the step 5 of the wizard.
The next page of this tutorial covers "Inserting Code in OnSet functions". Please see the Quick Start - Inserting Code in OnSet functions for that page.