Custom code in the auto-gen java class

Hi Frank

I have 3 questions

  1. In the DocsIfMib.getDocsIfCmtsCmStatusValueLastUpdate(), the default auto-gen behavior is to get the

return (TimeTicks) super.getValue(idxDocsIfCmtsCmStatusValueLastUpdate)

However, we hope to achieve the result is to get the

agent.getAgentConfigManager().getSNMPv2MIB().getUpTime() - getDocsIfCmtsCmStatusValueLastUpdate()

Is it possible to make change in the template to handle the question 1 situation? For example, when see DocsIfCmtsCmStatusValueLastUpdate attribute, then generate agent.getAgentConfigManager().getSNMPv2MIB().getUpTime() - getDocsIfCmtsCmStatusValueLastUpdate() instead.

  1. If question 1 is a No, then what is the best way to maintain custom code in the auto-gen classes so they will not be overwritten in the future generation?

Thanks
Agnes

Hi Agnes,
The original auto-gen code is as below.

    public TimeTicks getDocsIfCmtsCmStatusValueLastUpdate() {
    //--AgentGen BEGIN=docsIfCmtsCmStatusEntry::getDocsIfCmtsCmStatusValueLastUpdate
    //--AgentGen END
      return (TimeTicks) super.getValue(idxDocsIfCmtsCmStatusValueLastUpdate);
    }  

I think what you pasted above, is the modified code from our colleague Sophia.

Thanks Steven, I have modified my questions.
Frank, could you shed the light on how we can better maintain the custom change for the auto-gen classes?

Hi,

You can put your code into the protected areas (between //--AgentGen BEGIN and //--AgentGen END) as described in the AgenPro documentation:

public TimeTicks getDocsIfCmtsCmStatusValueLastUpdate() {
//--AgentGen BEGIN=docsIfCmtsCmStatusEntry::getDocsIfCmtsCmStatusValueLastUpdate
// place your code here:
if (true) {
   return myValue;
}
//--AgentGen END
  return (TimeTicks) super.getValue(idxDocsIfCmtsCmStatusValueLastUpdate);
}  

BTW, the code

agent.getAgentConfigManager().getSNMPv2MIB().getUpTime() - getDocsIfCmtsCmStatusValueLastUpdate()

does not make any sense to me. Please check if you understand the LastUpdate mechanism! It should be a constant value that returns the value of sysUpTime at the time the object (row) was changed the last time.

Thanks Frank. I will bring up the lastUpdate issue to my colleague.