Ejemplo n.º 1
0
    def sendBlocks(self, initialVal, lastVal, changeVal, period):
        '''
        Python implementation of IDL method.
        '''
        
        self.LOGGER.logInfo("called...")
        
        
        #Send the events
        self.LOGGER.logInfo("Ready to send NC events...")
        myString = "Python supplier"
        val = initialVal
        eventCount = 0

        while val < lastVal:
            if val < changeVal:
                flag = False
            else:
                flag = True
            
            self.supplier.publishEvent(COUNTER.statusBlockEvent(COUNTER.ON, myString, val, lastVal, changeVal, flag, period))
            eventCount = eventCount + 1
            self.LOGGER.logInfo("Counting ongoing with period %.3fs up to %d, now %d" % (period,  lastVal, val) )
            val = val + 1
            sleep(period)
        
        # Tell consumers this is the last event
        myString = "Last event from Python supplier"
        self.supplier.publishEvent(COUNTER.statusBlockEvent(COUNTER.OFF, myString, lastVal, lastVal, changeVal, True, period))
        eventCount = eventCount + 1
        self.LOGGER.logInfo("Counter stopped, last value %d" % val)


        return eventCount
Ejemplo n.º 2
0
    def sendBlocks(self, initialVal, lastVal, changeVal, period):
        '''
        Python implementation of IDL method.
        '''

        self.LOGGER.logInfo("called...")

        #Send the events
        self.LOGGER.logInfo("Ready to send NC events...")
        myString = "Python supplier"
        val = initialVal
        eventCount = 0

        while val < lastVal:
            if val < changeVal:
                flag = False
            else:
                flag = True

            self.supplier.publishEvent(
                COUNTER.statusBlockEvent(COUNTER.ON, myString, val, lastVal,
                                         changeVal, flag, period))
            eventCount = eventCount + 1
            self.LOGGER.logInfo(
                "Counting ongoing with period %.3fs up to %d, now %d" %
                (period, lastVal, val))
            val = val + 1
            sleep(period)

        # Tell consumers this is the last event
        myString = "Last event from Python supplier"
        self.supplier.publishEvent(
            COUNTER.statusBlockEvent(COUNTER.OFF, myString, lastVal, lastVal,
                                     changeVal, True, period))
        eventCount = eventCount + 1
        self.LOGGER.logInfo("Counter stopped, last value %d" % val)

        return eventCount
Ejemplo n.º 3
0
        changeVal = lastVal
        
    #Create a supplier
    LOGGER.logInfo('Creating an instance of Supplier')
    g = Supplier(COUNTER.CHANNELNAME_COUNTER)

    #Send the events
    LOGGER.logInfo("Ready to send NC events...")
    val = initVal

    while val < lastVal:
        if val < changeVal:
            flag = False
        else:
            flag = True
	g.publishEvent(COUNTER.statusBlockEvent(COUNTER.ON, myString, val, lastVal, changeVal, flag, period))
        LOGGER.logInfo("Counting ongoing with period %.3fs up to %d, now %d" % (period,  lastVal, val) )
        val = val + 1
        sleep(period)
        
    # Tell consumers this is the last event
    g.publishEvent(COUNTER.statusBlockEvent(COUNTER.OFF, myString, lastVal, lastVal, changeVal, True, period))
    LOGGER.logInfo("Counter stopped, last value %d" % val)
    # As this will be the main process in the tat-test, we should take care that we
    # don't exit earlier than the consumer process has had an opportunity to log
    # whatever it wants before exiting - tat will stop collecting output as
    # soon as the main process stops. A simple short sleep should be enough.
    sleep(1)
    
    LOGGER.logInfo("Events all done . . . exiting")
    #cleanly disconnect from the channel