def __init__(self, id=None, enable=MNRLDefs.ENABLE_ON_ACTIVATE_IN, report=False, reportEnable=MNRLDefs.ENABLE_ALWAYS, inputDefs=[], outputDefs=[], attributes={}): self.id = id if enable not in [ MNRLDefs.ENABLE_ALWAYS, MNRLDefs.ENABLE_ON_ACTIVATE_IN, MNRLDefs.ENABLE_ON_START_AND_ACTIVATE_IN, MNRLDefs.ENABLE_ON_LAST ]: raise mnrlerror.EnableError(enable) self.enable = enable self.report = report if reportEnable not in [ MNRLDefs.ENABLE_ALWAYS, MNRLDefs.ENABLE_ON_LAST ]: raise mnrlerror.ReportEnableError(reportEnable) self.reportEnable = reportEnable #validate input ports self.inputDefs = self.__validate_ports(inputDefs, "input") #validate output ports self.outputDefs = self.__validate_ports(outputDefs, "output") self.attributes = attributes
def toMNRLEnable(en): if en == MNRLDefs.ENABLE_ON_ACTIVATE_IN: return "onActivateIn" elif en == MNRLDefs.ENABLE_ON_START_AND_ACTIVATE_IN: return "onStartAndActivateIn" elif en == MNRLDefs.ENABLE_ALWAYS: return "always" elif en == MNRLDefs.ENABLE_ON_LAST: return "onLast" else: raise mnrlerror.EnableError(en)
def fromMNRLEnable(en): if en == "onActivateIn": return MNRLDefs.ENABLE_ON_ACTIVATE_IN elif en == "onStartAndActivateIn": return MNRLDefs.ENABLE_ON_START_AND_ACTIVATE_IN elif en == "onLast": return MNRLDefs.ENABLE_ON_LAST elif en == "always": return MNRLDefs.ENABLE_ALWAYS else: raise mnrlerror.EnableError(en)