def initialize(self): """ This is called by the framework immediately after your component registers with the NameService. In general, you should add customization here and not in the __init__ constructor. If you have a custom port implementation you can override the specific implementation here with a statement similar to the following: self.some_port = MyPortImplementation() """ Resource.initialize(self) self.port_a = CxPortBULKIODataFloatIn_i("a", maxsize=self.DEFAULT_QUEUE_SIZE) self.port_b = CxPortBULKIODataFloatIn_i("b", maxsize=self.DEFAULT_QUEUE_SIZE) self.port_out = CxPortBULKIODataFloatOut_i("out") #take care of the requested imports #we are supporting both syntax for imports #IE - "import x" and "from x import *" #this allows users to use either math.cos or just cos #and they will both work self.globals = {} self.oldA = [] self.oldB = [] self.useA = False self.useB = False #call this in case we already have a good equation self.sri = None self.streamID = None self.firsttime = True self.addPropertyChangeListener("import", self.propChange_import) self.addPropertyChangeListener("equation", self.propChange_equation)
def initialize(self): Resource.initialize(self) # Instantiate the default implementations for all ports on this component self.port_inputPort = PortBULKIODataFloatIn_i(self, "inputPort", self.DEFAULT_QUEUE_SIZE) self.port_outputPort = PortBULKIODataFloatOut_i(self, "outputPort")
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)
def initialize(self): Resource.initialize(self) # Instantiate the default implementations for all ports on this component self.port_comp_resource_in = PortCFResourceIn_i(self, "comp_resource_in") self.port_comp_resource_out = PortCFResourceOut_i(self, "comp_resource_out")
def initialize(self): Resource.initialize(self) # Instantiate the default implementations for all ports on this component self.port_dataDouble = PortBULKIODataDoubleIn_i(self, "dataDouble", self.DEFAULT_QUEUE_SIZE) self.port_dataFloat = PortBULKIODataFloatOut_i(self, "dataFloat")
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)
def initialize(self): Resource.initialize(self) # Instantiate the default implementations for all ports on this component self.port_dataShort_in = PortBULKIODataShortIn_i(self, "dataShort_in", self.DEFAULT_QUEUE_SIZE) self.port_dataShort_out = PortBULKIODataShortOut_i(self, "dataShort_out")
def __init__(self, identifier, execparams): loggerName = execparams['NAME_BINDING'].replace('/', '.') Resource.__init__(self, identifier, execparams, loggerName=loggerName) self._pid = None self.execparams = " ".join(["%s %s" % x for x in execparams.items()]) command = "python" args = [command, "components/CommandWrapperSubProcess/executables/FirstChild.py"] sp = subprocess.Popen(args, executable=command, cwd=os.getcwd())
def __init__(self, identifier, execparams): loggerName = (execparams['NAME_BINDING'].replace('/', '.')).rsplit("_", 1)[0] Resource.__init__(self, identifier, execparams, loggerName=loggerName) self.process_thread = None # self.auto_start is deprecated and is only kept for API compatability # with 1.7.X and 1.8.0 components. This variable may be removed # in future releases self.auto_start = False
def initialize(self): Resource.initialize(self) # Instantiate the default implementations for all ports on this component self.port_a = PortBULKIODataDoubleIn_i(self, "a", self.DEFAULT_QUEUE_SIZE) self.port_b = PortBULKIODataDoubleIn_i(self, "b", self.DEFAULT_QUEUE_SIZE) self.port_out = PortBULKIODataDoubleOut_i(self, "out")
def initialize(self): Resource.initialize(self) # Instantiate the default implementations for all ports on this component self.port_comp_resource_in = PortCFResourceIn_i( self, "comp_resource_in") self.port_comp_resource_out = PortCFResourceOut_i( self, "comp_resource_out")
def __init__(self, identifier, execparams): loggerName = (execparams['NAME_BINDING'].replace('/', '.')).rsplit("_", 1)[0] Resource.__init__(self, identifier, execparams, loggerName=loggerName) self.threadControlLock = threading.RLock() self.process_thread = None # self.auto_start is deprecated and is only kept for API compatability # with 1.7.X and 1.8.0 components. This variable may be removed # in future releases self.auto_start = False
def start(self): self.threadControlLock.acquire() try: Resource.start(self) if self.process_thread == None: self.process_thread = ProcessThread(target=self.process, pause=self.PAUSE) self.process_thread.start() finally: self.threadControlLock.release()
def __init__(self, *args, **kwargs): Resource.__init__(self, *args, **kwargs) # Ignore normal termination signals to ensure that the process is # orphaned when the parent is terminated; start_component() normally # establishes handlers for these before creating the component instance signal.signal(signal.SIGINT, signal.SIG_IGN) signal.signal(signal.SIGTERM, signal.SIG_IGN) signal.signal(signal.SIGQUIT, signal.SIG_IGN)
def initialize(self): Resource.initialize(self) self.toTest = TestUsesPort() self.fromOther = TestProvidesPort(self._get_identifier() + "/resource_in") self.toPropSet = PropSetUsesPort() self.eventSupplier = EventSupplierPort() self.eventConsumer = EventConsumerPort(self._onPush) self.toDomainManager = DomainManagerUsesPort() self.toDeviceManager = DeviceManagerUsesPort()
def releaseObject(self): try: self.stop() except Exception: self._log.exception("Error stopping") self.threadControlLock.acquire() try: Resource.releaseObject(self) finally: self.threadControlLock.release()
def __init__(self, identifier, execparams): loggerName = execparams['NAME_BINDING'].replace('/', '.') Resource.__init__(self, identifier, execparams, propertydefs=PROPERTIES, loggerName=loggerName) self._props["execparams"] = " ".join( ["%s %s" % x for x in execparams.items()]) self._pid = None
def start(self): self._log.debug("start()") if self.get_commandAlive() == False: command = self._props["command"] args = copy.copy(self._props["args"]) args.insert(0, command) self._log.debug("start %s %r", command, args) self._pid = os.spawnv(os.P_NOWAIT, command, args) self._log.debug("spawned %s", self._pid) Resource.start(self)
def stop(self): # Technically not thread-safe but close enough for now process_thread = self.process_thread self.process_thread = None if process_thread != None: process_thread.stop() process_thread.join(self.TIMEOUT) if process_thread.isAlive(): raise CF.Resource.StopError(CF.CF_NOTSET, "Processing thread did not die") Resource.stop(self)
def __init__(self, identifier, execparams): loggerName = execparams['NAME_BINDING'].replace('/', '.') Resource.__init__(self, identifier, execparams, loggerName=loggerName) self._pid = None self.execparams = " ".join(["%s %s" % x for x in execparams.items()]) command = "python" args = [ command, "components/CommandWrapperSubProcess/executables/FirstChild.py" ] sp = subprocess.Popen(args, executable=command, cwd=os.getcwd())
def __init__(self, identifier, execparams): loggerName = (execparams['NAME_BINDING'].replace('/', '.')).rsplit("_", 1)[0] Resource.__init__(self, identifier, execparams, loggerName=loggerName) ThreadedComponent.__init__(self) # self.auto_start is deprecated and is only kept for API compatibility # with 1.7.X and 1.8.0 components. This variable may be removed # in future releases self.auto_start = False # Instantiate the default implementations for all ports on this component self.port_DomainManager_out = PortCFDomainManagerOut_i(self, "DomainManager_out")
def __init__(self, identifier, execparams): loggerName = (execparams["NAME_BINDING"].replace("/", ".")).rsplit("_", 1)[0] Resource.__init__(self, identifier, execparams, loggerName=loggerName) ThreadedComponent.__init__(self) # self.auto_start is deprecated and is only kept for API compatibility # with 1.7.X and 1.8.0 components. This variable may be removed # in future releases self.auto_start = False # Instantiate the default implementations for all ports on this component self.port_dataFloat_out = bulkio.OutFloatPort("dataFloat_out") self.port_dataShort_out = bulkio.OutShortPort("dataShort_out")
def __init__(self, identifier, execparams): loggerName = (execparams['NAME_BINDING'].replace('/', '.')).rsplit("_", 1)[0] Resource.__init__(self, identifier, execparams, loggerName=loggerName) ThreadedComponent.__init__(self) # self.auto_start is deprecated and is only kept for API compatibility # with 1.7.X and 1.8.0 components. This variable may be removed # in future releases self.auto_start = False # Instantiate the default implementations for all ports on this component self.port_dataFloat_out = bulkio.OutFloatPort("dataFloat_out") self.port_dataShort_out = bulkio.OutShortPort("dataShort_out")
def __init__(self, identifier, execparams): loggerName = (execparams['NAME_BINDING'].replace('/', '.')).rsplit("_", 1)[0] Resource.__init__(self, identifier, execparams, loggerName=loggerName) ThreadedComponent.__init__(self) # self.auto_start is deprecated and is only kept for API compatibility # with 1.7.X and 1.8.0 components. This variable may be removed # in future releases self.auto_start = False # Instantiate the default implementations for all ports on this component self.port_a = bulkio.InFloatPort("a", maxsize=self.DEFAULT_QUEUE_SIZE) self.port_b = bulkio.InFloatPort("b", maxsize=self.DEFAULT_QUEUE_SIZE) self.port_out = bulkio.OutFloatPort("out")
def initialize(self): Resource.initialize(self) self.prop1 = "MyDefault1" self.prop2.append("1") self.prop2.append("2") self.prop2.append("3") self.struct.field1 = "StructDefault" self.struct.field2 = 100 self.struct.field3 = 1.0 self.multicasts.append(TestPythonProps.MulticastAddress("127.0.0.1", 123)) self.multicasts.append(TestPythonProps.MulticastAddress("127.0.0.1", 456))
def stop(self): self.threadControlLock.acquire() try: process_thread = self.process_thread self.process_thread = None if process_thread != None: process_thread.stop() process_thread.join(self.TIMEOUT) if process_thread.isAlive(): raise CF.Resource.StopError(CF.CF_NOTSET, "Processing thread did not die") Resource.stop(self) finally: self.threadControlLock.release()
def __init__(self, identifier, execparams): loggerName = (execparams['NAME_BINDING'].replace('/', '.')).rsplit("_", 1)[0] Resource.__init__(self, identifier, execparams, loggerName=loggerName) ThreadedComponent.__init__(self) # self.auto_start is deprecated and is only kept for API compatibility # with 1.7.X and 1.8.0 components. This variable may be removed # in future releases self.auto_start = False # Instantiate the default implementations for all ports on this component self.port_dataSDDS_in = bulkio.InSDDSPort("dataSDDS_in") self.port_dataVITA49_in = bulkio.InVITA49Port("dataVITA49_in") self.port_dataFloat_in = bulkio.InFloatPort("dataFloat_in", maxsize=self.DEFAULT_QUEUE_SIZE) self.port_dataSDDS_out = bulkio.OutSDDSPort("dataSDDS_out") self.port_dataVITA49_out = bulkio.OutVITA49Port("dataVITA49_out") self.addPropertyChangeListener('connectionTable',self.updated_connectionTable)
def initialize(self): Resource.initialize(self) # Instantiate the default implementations for all ports on this component self.port_dataChar = bulkio.OutCharPort("dataChar") self.port_dataFile = bulkio.OutFilePort("dataFile") self.port_dataShort = bulkio.OutShortPort("dataShort") self.port_dataUlong = bulkio.OutULongPort("dataUlong") self.port_dataUlongLong = bulkio.OutULongLongPort("dataUlongLong") self.port_dataUshort = bulkio.OutUShortPort("dataUshort") self.port_dataXML = bulkio.OutXMLPort("dataXML") self.port_dataLong = bulkio.OutLongPort("dataLong") self.port_dataLongLong = bulkio.OutLongLongPort("dataLongLong") self.port_dataOctet = bulkio.OutOctetPort("dataOctet") self.port_dataFloat = bulkio.OutFloatPort("dataFloat") self.port_dataSDDS = bulkio.OutSDDSPort("dataSDDS") self.port_dataDouble = bulkio.OutDoublePort("dataDouble")
def __init__(self, identifier, execparams): loggerName = (execparams['NAME_BINDING'].replace('/', '.')).rsplit("_", 1)[0] Resource.__init__(self, identifier, execparams, loggerName=loggerName) ThreadedComponent.__init__(self) # self.auto_start is deprecated and is only kept for API compatibility # with 1.7.X and 1.8.0 components. This variable may be removed # in future releases self.auto_start = False # Instantiate the default implementations for all ports on this component self.port_dataSDDS_in = bulkio.InSDDSPort("dataSDDS_in") self.port_dataVITA49_in = bulkio.InVITA49Port("dataVITA49_in") self.port_dataFloat_in = bulkio.InFloatPort( "dataFloat_in", maxsize=self.DEFAULT_QUEUE_SIZE) self.port_dataSDDS_out = bulkio.OutSDDSPort("dataSDDS_out") self.port_dataVITA49_out = bulkio.OutVITA49Port("dataVITA49_out") self.addPropertyChangeListener('connectionTable', self.updated_connectionTable)
def stop(self): self._log.debug("stop()") try: if self.get_commandAlive() == True: for sig, timeout in self.STOP_SIGNALS: try: os.kill(self._pid, sig) except OSError: self._pid = None return if timeout != None: giveup_time = time.time() + timeout while os.waitpid(self._pid, os.WNOHANG) == (0,0): time.sleep(0.1) if time.time() > giveup_time: break else: # Wait until there is a response os.waitpid(self._pid, 0) self._pid = None finally: Resource.stop(self)
class BasicAC_python_impl1_base(CF__POA.Resource, Resource): # These values can be altered in the __init__ of your derived class PAUSE = 0.0125 # The amount of time to sleep if process return NOOP TIMEOUT = 5.0 # The amount of time to wait for the process thread to die when stop() is called DEFAULT_QUEUE_SIZE = 100 # The number of BulkIO packets that can be in the queue before pushPacket will block def __init__(self, identifier, execparams): loggerName = execparams['NAME_BINDING'].replace('/', '.') Resource.__init__(self, identifier, execparams, loggerName=loggerName) self.process_thread = None def initialize(self): Resource.initialize(self) # Instantiate the default implementations for all ports on this component self.port_resourceOut = PortCFResourceOut_i(self, "resourceOut") def start(self): Resource.start(self) self.process_thread = ProcessThread(target=self.process, pause=self.PAUSE) self.process_thread.start() def process(self): """The process method should process a single "chunk" of data and then return. This method will be called from the processing thread again, and again, and again until it returns FINISH or stop() is called on the component. If no work is performed, then return NOOP""" raise NotImplementedError def stop(self): # Technically not thread-safe but close enough for now process_thread = self.process_thread self.process_thread = None if process_thread != None: process_thread.stop() process_thread.join(self.TIMEOUT) if process_thread.isAlive(): raise CF.Resource.StopError(CF.CF_NOTSET, "Processing thread did not die") Resource.stop(self) def releaseObject(self): try: self.stop() except Exception, e: self._log.exception("Error stopping: " + str(e)) Resource.releaseObject(self)
def initialize(self): Resource.initialize(self)
def start(self): Resource.start(self) ThreadedComponent.startThread(self, pause=self.PAUSE)
def start(self): self.prop_short += 1 # FOR NOW, A CRAPPY TEST TO SEE IF REFRESH WORKS Resource.start(self) pipe_on() pipe_start()
def releaseObject(self): try: self.stop() except Exception: self._log.exception("Error stopping") Resource.releaseObject(self)
def initialize(self): Resource.initialize(self) # Instantiate the default implementations for all ports on this component self.port_propEvent = PropertyEventSupplier(self)
def initialize(self): Resource.initialize(self) # Instantiate the default implementations for all ports on this component self.port_dataFloat_in = bulkio.InFloatPort("dataFloat_in", maxsize=self.DEFAULT_QUEUE_SIZE) self.port_dataFloat_out = bulkio.OutFloatPort("dataFloat_out")
def stop(self): if not ThreadedComponent.stopThread(self, self.TIMEOUT): raise CF.Resource.StopError(CF.CF_NOTSET, "Processing thread did not die") Resource.stop(self)
def __init__(self, identifier, execparams): Resource.__init__(self, identifier, execparams) self.received_messages = []
def initialize(self): Resource.initialize(self) # Instantiate the default implementations for all ports on this component self.port_output = PortCFPropertySetOut_i(self, "output")
def __init__(self, identifier, execparams): Resource.__init__(self, identifier, execparams)
def stop(self): Resource.stop(self) pipe_off() pipe_wait()
def start(self): Resource.start(self) if self.process_thread == None: self.process_thread = ProcessThread(target=self.process, pause=self.PAUSE) self.process_thread.start()