There is a python file named BasePlat.py which contain something like this:
class BasePlatform(SimObj):
type = 'BasePlatform'
size = Param.Int(100, "Number of entries")
class Type1(BasePlatform):
type = 'Type1'
cxx_class = 'Type1'
Now this file is used in another file named BaseModel.py
from BasePlat import BasePlatform
class BaseModel(ModelObj):
type = 'BaseModel'
delay = Param.Int(50, "delay")
platform = Param.BasePlatform(NULL, "platform")
These file define the parameters. In another file inst.py, some models are instantiated and I can modify the parameters. For example I can define two models with different delays.
class ModelNumber1(BaseModel):
delay = 10
class ModelNumber2(BaseModel):
delay = 15
However I don’t know how can I reach size parameter in BasePlatform. I want something like this (this is not a true code):
class ModelNumber1(BaseModel):
delay = 10
platform = Type1
**platform.size = 5**
class ModelNumber2(BaseModel):
delay = 15
platform = Type1
**platform.size = 8**
How can I do that?
The attributes you are defining are at class level, which means that every instance of that class will share the same objects (which are instantiated at definition time).
If you want
ModelNumber1andModelNumber2to have differentplatforminstances, you have to override their definition. Something like this:Edit the
BasePlatformclass definition with something like this:If you don’t have access to the
BasePlatformdefinition, you can still subclass it asMyOwnBasePlatformand customize the__init__method.