This is Sarojini.
I have few queries related to DynamicManagement class.
I want to create dynamic attributes by referring dynamicManager outside the tango generated class.
Is there any way to access dynamicManager(object of DynamicManagement class) outside the tango class.
If yes? then how to access?
Lets say you want to access DynamicManager object in Class XYZ which is not a TANGO Class. Create a parameterized constructor of Class XYZ, with DynamicManager object as one of the parameters. Example is shown below:
public class XYZ {
private String param1;
private DynamicManager dynamicManager;
public XYZ(String param1, DynamicManager dynamicManager) {
this.param1 = param1;
// use the local dynamicManager variable to add/remove attributes/commands
this.dynamicManager = dynamicManager;
}
.
.
.
}
In the init_device method of your TANGO Class, create an object of XYZ class. Example is shown below:
@Device
public class TangoClass {
protected static final Logger logger = LoggerFactory.getLogger(TangoClass.class);
protected static final XLogger xlogger = XLoggerFactory.getXLogger(TangoClass.class);
//========================================================
// Programmer's data members
//========================================================
/*----- PROTECTED REGION ID(TangoClass.variables) ENABLED START -----*/
// Put static variables here
/*----- PROTECTED REGION END -----*/ // TangoClass.variables
/*----- PROTECTED REGION ID(TangoClass.private) ENABLED START -----*/
// Put private variables here
XYZ objXYZ;
/*----- PROTECTED REGION END -----*/
@Init(lazyLoading = false)
public void initDevice() throws DevFailed {
xlogger.entry();
/*----- PROTECTED REGION ID(TangoClass.initDevice) ENABLED START -----*/
// Put your device initialization code here
objXYZ = new XYZ("Test param", dynamicManager);
.
.
.
}
.
.
.
}
This will address your problem.
However I’m not sure whether creating attributes dynamically outside the TANGO Class is as per the TANGO pattern or not. TANGO experts will shed some light on it.