def initialize(self): Resource.initialize(self) self.port_dataCharIn = bulkio.InCharPort("dataCharIn") self.port_dataOctetIn = bulkio.InOctetPort("dataOctetIn") self.port_dataShortIn = bulkio.InShortPort("dataShortIn") self.port_dataUShortIn = bulkio.InUShortPort("dataUShortIn") self.port_dataLongIn = bulkio.InLongPort("dataLongIn") self.port_dataULongIn = bulkio.InULongPort("dataULongIn") self.port_dataLongLongIn = bulkio.InLongLongPort("dataLongLongIn") self.port_dataULongLongIn = bulkio.InULongLongPort("dataULongLongIn") self.port_dataFloatIn = bulkio.InFloatPort("dataFloatIn") self.port_dataDoubleIn = bulkio.InDoublePort("dataDoubleIn") self.port_dataFileIn = bulkio.InFilePort("dataFileIn") self.port_dataXMLIn = bulkio.InXMLPort("dataXMLIn") self.port_dataSDDSIn = bulkio.InSDDSPort("dataSDDSIn") self.port_dataCharOut = bulkio.OutCharPort("dataCharOut") self.port_dataOctetOut = bulkio.OutOctetPort("dataOctetOut") self.port_dataShortOut = bulkio.OutShortPort("dataShortOut") self.port_dataUShortOut = bulkio.OutUShortPort("dataUShortOut") self.port_dataLongOut = bulkio.OutLongPort("dataLongOut") self.port_dataULongOut = bulkio.OutULongPort("dataULongOut") self.port_dataLongLongOut = bulkio.OutLongLongPort("dataLongLongOut") self.port_dataULongLongOut = bulkio.OutULongLongPort( "dataULongLongOut") self.port_dataFloatOut = bulkio.OutFloatPort("dataFloatOut") self.port_dataDoubleOut = bulkio.OutDoublePort("dataDoubleOut") self.port_dataFileOut = bulkio.OutFilePort("dataFileOut") self.port_dataXMLOut = bulkio.OutXMLPort("dataXMLOut") self.port_dataSDDSOut = bulkio.OutSDDSPort("dataSDDSOut") self.port_propEvent = PropertyEventSupplier(self)
class PropertyChangeEvents(CF__POA.Resource, Resource): """ Example component to send property change events to an EventChannel port. """ myprop = simple_property(id_="myprop", type_="long", name="myprop", defvalue=0, mode="readwrite", action="external", kinds=("configure", "event")) anotherprop = simple_property(id_="anotherprop", type_="long", name="anotherprop", defvalue=0, mode="readwrite", action="external", kinds=("configure", )) propEvent = usesport(name="propEvent", repid="IDL:CosEventChannelAdmin/EventChannel:1.0", type_="data") seqprop = simpleseq_property(id_="seqprop", type_="float", defvalue=None, mode="readwrite", action="external", kinds=("configure", "event")) class SomeStruct(object): some_number = simple_property( id_="some_number", type_="double", ) some_string = simple_property( id_="some_string", type_="string", ) def __init__(self): """Construct an initialized instance of this struct definition""" for attrname, classattr in type(self).__dict__.items(): if type(classattr) == simple_property: classattr.initialize(self) def __str__(self): """Return a string representation of this structure""" d = {} d["some_number"] = self.some_number d["some_string"] = self.some_string return str(d) def isStruct(self): return True def getMembers(self): return [("some_number", self.some_number), ("some_string", self.some_string)] def __init__(self, identifier, execparams): Resource.__init__(self, identifier, execparams) def initialize(self): self.propEvent = PropertyEventSupplier(self) some_struct = struct_property(id_="some_struct", structdef=SomeStruct, configurationkind=("configure", "event"), mode="readwrite") structseq_prop = structseq_property(id_="structseq_prop", structdef=SomeStruct, defvalue=[], configurationkind=("configure", "event"), mode="readwrite") def start(self): self.myprop = 123 self.anotherprop = 123 self.seqprop = [1.0] self.some_struct.some_number = 123.0 tmp = self.SomeStruct() tmp.some_number = 2.0 tmp.some_string = "another string" newval = copy.deepcopy(self.structseq_prop) newval.append(tmp) self.structseq_prop = newval def runTest(self, testid, properties): if testid == 1061: # Ticket #1061: Ensure that if an eventable struct or struct sequence # has None for both the current and prior values, sendChangedPropertiesEvent # does not raise an exception. # Save values of struct and struct sequence properties saved_struct = copy.deepcopy(self.some_struct) saved_structseq = copy.deepcopy(self.structseq_prop) self.some_struct = None self.saved_structseq = None try: # Send two consecutive property change events so that the current # and saved values are both None. self.propEvent.sendChangedPropertiesEvent() self.propEvent.sendChangedPropertiesEvent() success = True except: success = False results = [CF.DataType('1061', any.to_any(success))] # Restore saved state self.some_struct = saved_struct self.saved_structseq = saved_structseq else: raise CF.TestableObject.UnknownTest('No test %d' % testid) return results
def initialize(self): self.propEvent = PropertyEventSupplier(self)
def initialize(self): ExecutableDevice.initialize(self) # Instantiate the default implementations for all ports on this component self.port_propEvent = PropertyEventSupplier(self)
class PropertyChangeEvents(CF__POA.Resource, Resource): """ Example component to send property change events to an EventChannel port. """ myprop = simple_property(id_="myprop", type_="long", name="myprop", defvalue=0, mode="readwrite", action="external", kinds=("configure","event")) anotherprop = simple_property(id_="anotherprop", type_="long", name="anotherprop", defvalue=0, mode="readwrite", action="external", kinds=("configure",)) propEvent = usesport(name="propEvent", repid="IDL:CosEventChannelAdmin/EventChannel:1.0", type_="data") seqprop = simpleseq_property(id_="seqprop", type_="float", defvalue=None, mode="readwrite", action="external", kinds=("configure","event") ) class SomeStruct(object): some_number = simple_property(id_="some_number", type_="double", ) some_string = simple_property(id_="some_string", type_="string", ) def __init__(self): """Construct an initialized instance of this struct definition""" for attrname, classattr in type(self).__dict__.items(): if type(classattr) == simple_property: classattr.initialize(self) def __str__(self): """Return a string representation of this structure""" d = {} d["some_number"] = self.some_number d["some_string"] = self.some_string return str(d) def isStruct(self): return True def getMembers(self): return [("some_number",self.some_number),("some_string",self.some_string)] def __init__(self, identifier, execparams): Resource.__init__(self, identifier, execparams) def initialize(self): self.propEvent = PropertyEventSupplier(self) some_struct = struct_property(id_="some_struct", structdef=SomeStruct, configurationkind=("configure","event"), mode="readwrite" ) structseq_prop = structseq_property(id_="structseq_prop", structdef=SomeStruct, defvalue=[], configurationkind=("configure","event"), mode="readwrite" ) def start(self): self.myprop = 123 self.anotherprop = 123 self.seqprop = [1.0] self.some_struct.some_number = 123.0 tmp = self.SomeStruct() tmp.some_number = 2.0 tmp.some_string = "another string" newval = copy.deepcopy(self.structseq_prop) newval.append(tmp) self.structseq_prop = newval def runTest(self, testid, properties): if testid == 1061: # Ticket #1061: Ensure that if an eventable struct or struct sequence # has None for both the current and prior values, sendChangedPropertiesEvent # does not raise an exception. # Save values of struct and struct sequence properties saved_struct = copy.deepcopy(self.some_struct) saved_structseq = copy.deepcopy(self.structseq_prop) self.some_struct = None self.saved_structseq = None try: # Send two consecutive property change events so that the current # and saved values are both None. self.propEvent.sendChangedPropertiesEvent() self.propEvent.sendChangedPropertiesEvent() success = True except: success = False results = [CF.DataType('1061', any.to_any(success))] # Restore saved state self.some_struct = saved_struct self.saved_structseq = saved_structseq else: raise CF.TestableObject.UnknownTest('No test %d' % testid) return results