コード例 #1
0
class SupplierTestComponent(BasePerfComp):
    #------------------------------------------------------------------------------
    def initialize(self):
        '''
        '''
        self.supplier = Supplier("perf channel")
        return

    #------------------------------------------------------------------------------
    def method(self):
        '''
        void method();
        '''
        profiler = Profiler()

        tString = ""
        for i in range(0, self.size):
            tString = tString + "*"

        joe = perftest.charSeqStruct(tString)

        for i in range(0, self.count):
            profiler.start()
            self.supplier.publishEvent(joe)
            profiler.stop()
            self.waitAwhile()

        profiler.fullDescription(
            "Event Channel Event of Size '" + str(self.size) +
            "' Bytes from within a CharacteristicComponent")
        return
コード例 #2
0
class SupplierTestComponent(BasePerfComp):
    #------------------------------------------------------------------------------
    def initialize(self):
        '''
        '''
        self.supplier = Supplier("perf channel")
        return
    #------------------------------------------------------------------------------
    def method(self):
        '''
        void method();
        '''
        profiler = Profiler()
        
        tString=""
        for i in range(0, self.size):
            tString = tString + "*"

        joe = perftest.charSeqStruct(tString)

        for i in range(0, self.count):
            profiler.start()
            self.supplier.publishEvent(joe)
            profiler.stop()
            self.waitAwhile()

        profiler.fullDescription("Event Channel Event of Size '" + str(self.size) + "' Bytes from within a CharacteristicComponent")
        return
コード例 #3
0
 def sendMessages(self):
    supplier = Supplier(perftest.NOTIFICATION_STRESS_CHANNEL_NAME)
    for i in range(0, self.numMessages):
       supplier.publishEvent(self.event)
       if(self.delayBetweenMessages > 0):
          sleep(self.delayBetweenMessages / 1000.)
    supplier.disconnect()
    return
コード例 #4
0
class AlarmPublisher(object):
    """
    This class provides the interface to the CORBA Notification Service used
    to send alarms to the LASER alarm server via a CORBA notification channel.
    """
    def __init__(self, topicName=None, component=None, domain=None):
        """
        Constructor

        Params:
        - topicName is the name of the notification channel to use
        - component is object generating the alarms (optional)
        - domain is the name of the domain of notification channels
          the channel belongs to. (optional)

        Returns: Nothing

        Raises:  Nothing
        """
        if domain is None:
            self.supplier = Supplier(topicName, component, ACS_NC_DOMAIN_ALARMSYSTEM)
        else:
            self.supplier = Supplier(topicName, component, domain)


    def __del__(self):
        """
        Destructor

        Params: None

        Returns: Nothing

        Raises:  Nothing
        """
        self.supplier.disconnect()
        self.supplier = None


    def publishAlarm(self, msg):
        """
        Send an alarm to the notification channel.

        Params:
        - msg is the alarm information to be sent

        Returns: Nothing

        Raises: Nothing
        """

        # The alarm notification channel expects ACSJMSMessageEntity structures to be
        # sent.  The XML form of the message is passed in the text field.  The
        # remaining fields are not used but must have default values set.
        emsg = ACSJMSMessageEntity_idl._0_com.cosylab.acs.jms.ACSJMSMessageEntity(msg.toXML(),0,False,"",0,0,[])
        self.supplier.publishEvent(simple_data=emsg)
コード例 #5
0
ファイル: CounterSupplier.py プロジェクト: ydc92546169/ACS
    def initialize(self):
        '''
        Override this method inherited from ComponentLifecycle
        '''

        self.LOGGER.logTrace("CounterSupplier.CounterSupplier")

        #Create a supplier
        self.LOGGER.logInfo('Creating an instance of Supplier')
        self.supplier = Supplier(COUNTER.CHANNELNAME_COUNTER)
コード例 #6
0
    def __init__ (self):
        '''
        Constructor.
        
        Params:
        - handler
        
        Returns: Nothing
        
        Raises: ACSErrTypeCommonImpl.CORBAProblemExImpl on critical failures
        '''

        Supplier.__init__(self, acscommon.ARCHIVING_CHANNEL_NAME)
コード例 #7
0
ファイル: ArchiveSupplier.py プロジェクト: ydc92546169/ACS
    def __init__ (self):
        '''
        Constructor.
        
        Params:
        - handler
        
        Returns: Nothing
        
        Raises: ACSErrTypeCommonImpl.CORBAProblemExImpl on critical failures
        '''

        Supplier.__init__(self, acscommon.ARCHIVING_CHANNEL_NAME, None, acscommon.ACS_NC_DOMAIN_ARCHIVING)
コード例 #8
0
    def __init__(self, file_name):
        '''
        Constructor.

        Parameters:
        file_name - The name of a previously recorded event consumer session. 
                    This file should have been created with the EventRecorder
                    class.
        '''
        f = open(file_name)
        xml_doc = f.read()
        root_dom = parseString(xml_doc)

        self.events = []
        session_dom = root_dom.firstChild
        channel_name = session_dom.getAttribute('channel-name')

        self.supplier = Supplier(channel_name)

        for node in session_dom.childNodes:
            if node.nodeName == 'Event':
                event_name = node.getAttribute('event-name')
                # stringified event structure
                ses = self.restoreXMLEntities(str(node.firstChild.nodeValue))
                se = pickle.loads(ses) # event structure

                self.events.append(Event(self.supplier, str(event_name), se))
コード例 #9
0
ファイル: ArchiveSupplier.py プロジェクト: ydc92546169/ACS
    def publishEvent (self,
                      simple_data=None,
                      type_name=None,
                      event_name="",
                      se=None,
                      supplier_name=None):
        '''
        publishEvent is the one method developers have to use.


        Params:
        - simple_data is a user-defined IDL struct. If this parameter is not
        specified by the developer, se MUST be used.  99% of the time developers
        should specify the simple_data parameter and NOTHING ELSE!
        - type_name is literally the type_name field of a structured event. This
        is an optional parameter and should not be specified under normal
        circumstances. If unspecified, the name of the simple_data object is used.
        - event_name is the event_name field of the structured event. Not really
        useful.
        - se is a fully-defined structured event. If this parameter is specified,
        all other parameters will be completely ignored. A check is made to ensure
        that this object is really what it claims to be. This parameter is
        reserved for ACS internal usage.
        - suppier_name is the name of the supplier publishing the event. This
        parameter is reserved for ACS internal usage.

        Returns: Nothing

        Raises:
        - ACSErrTypeCommonImpl.CORBAProblemExImpl
        - ACSErrTypeCommonImpl.CouldntPerformActionExImpl
        - ACSErrTypeCommonImpl.TypeNotSupportedExImpl
        '''
        #Whoah, user passed in the entire structured event...I'm impressed.
        if se != None:
            Supplier.publishEvent(simple_data,type_name,event_name,se, supplier_name)
	
	#User didn't specify type_name.  Assume it's the name of the
        #repository ID. If that doesn't work either, must be a simple
        #CORBA type.
        if (type_name == None) and (simple_data != None):
            try:
                type_name = str(simple_data.__class__.__name__)
            except Exception, e:
                self.logger.logWarning(str(e))
                print_exc()
                type_name = str(CORBA.id(simple_data))
コード例 #10
0
    def publishEvent (self,
                      simple_data=None,
                      type_name=None,
                      event_name="",
                      se=None,
                      supplier_name=None):
        '''
        publishEvent is the one method developers have to use.


        Params:
        - simple_data is a user-defined IDL struct. If this parameter is not
        specified by the developer, se MUST be used.  99% of the time developers
        should specify the simple_data parameter and NOTHING ELSE!
        - type_name is literally the type_name field of a structured event. This
        is an optional parameter and should not be specified under normal
        circumstances. If unspecified, the name of the simple_data object is used.
        - event_name is the event_name field of the structured event. Not really
        useful.
        - se is a fully-defined structured event. If this parameter is specified,
        all other parameters will be completely ignored. A check is made to ensure
        that this object is really what it claims to be. This parameter is
        reserved for ACS internal usage.
        - suppier_name is the name of the supplier publishing the event. This
        parameter is reserved for ACS internal usage.

        Returns: Nothing

        Raises:
        - ACSErrTypeCommonImpl.CORBAProblemExImpl
        - ACSErrTypeCommonImpl.CouldntPerformActionExImpl
        - ACSErrTypeCommonImpl.TypeNotSupportedExImpl
        '''
        #Whoah, user passed in the entire structured event...I'm impressed.
        if se != None:
            Supplier.publishEvent(simple_data,type_name,event_name,se, supplier_name)
	
	#User didn't specify type_name.  Assume it's the name of the
        #repository ID. If that doesn't work either, must be a simple
        #CORBA type.
        if (type_name == None) and (simple_data != None):
            try:
                type_name = str(simple_data.__class__.__name__)
            except Exception, e:
                self.logger.logWarning(str(e))
                print_exc()
                type_name = str(CORBA.id(simple_data))
コード例 #11
0
    def __init__(self, topicName=None, component=None, domain=None):
        """
        Constructor

        Params:
        - topicName is the name of the notification channel to use
        - component is object generating the alarms (optional)
        - domain is the name of the domain of notification channels
          the channel belongs to. (optional)

        Returns: Nothing

        Raises:  Nothing
        """
        if domain is None:
            self.supplier = Supplier(topicName, component, ACS_NC_DOMAIN_ALARMSYSTEM)
        else:
            self.supplier = Supplier(topicName, component, domain)
コード例 #12
0
ファイル: CounterSupplier.py プロジェクト: ACS-Community/ACS
    def initialize(self):
        '''
        Override this method inherited from ComponentLifecycle
        '''

        self.LOGGER.logTrace("CounterSupplier.CounterSupplier")

        #Create a supplier
        self.LOGGER.logInfo('Creating an instance of Supplier')
        self.supplier = Supplier(COUNTER.CHANNELNAME_COUNTER)
コード例 #13
0
 def sendMessages(self):
     supplier = Supplier(perftest.NOTIFICATION_STRESS_CHANNEL_NAME)
     for i in range(0, self.numMessages):
         supplier.publishEvent(self.event)
         if (self.delayBetweenMessages > 0):
             sleep(self.delayBetweenMessages / 1000.)
     supplier.disconnect()
     return
コード例 #14
0
ファイル: TSupplier.py プロジェクト: ydc92546169/ACS
def main(argv):

	suppliers = []
	suppliers_params = []
	n_events = int(argv[0])
	wait_sec = int(argv[1])
	for ch in argv[2:]:
		ch = int(ch)
		channel = None
		if ch == 1:
			channel = TEST_NS_STATISTICS_SERVICE.CHANNEL_1
		elif ch == 2:
			channel = TEST_NS_STATISTICS_SERVICE.CHANNEL_2
		elif ch == 3:
			channel = TEST_NS_STATISTICS_SERVICE.CHANNEL_3
		elif ch == 4:
			channel = TEST_NS_STATISTICS_SERVICE.CHANNEL_4
		else:
			raise BaseException("Wrong channel. Must be between 1 and 4") 
		
		# Create a supplier
		suppliers.append(Supplier(channel))
		
		# Create the parameters of the supplier
		suppliers_params.append({'channel_id': ch})

	for j in xrange(0,n_events):
		for i in xrange(0,len(suppliers)):
			supplier = suppliers[i]
			channel_id = suppliers_params[i]['channel_id']
			data = TEST_NS_STATISTICS_SERVICE.Test1EventData(j, j, "%d Event in channel %d"%(j,channel_id))
			supplier.publishEvent(data)
			print "Published the event number %d to channel %d" % (j, channel_id)
			
	if wait_sec > 0:
		print "Wait %d seconds" % (wait_sec)
		sleep(wait_sec)
		
	print "Disconnect %d suppliers" % (len(suppliers))		
	for supplier in suppliers:
		supplier.disconnect()
コード例 #15
0
def supplyEventByInstance(component_name, channel_name, event_instance):
    '''
    Supplies an event to a notification channel.
    
    Parameters:
        component_name - name of the component publisihing the event
        channel_name - name of the channel the event should be published
        on
        event_instance - an instance of the IDL struct to publish
        
    Returns: Nothing
    
    Raises: ???
    '''
    #sanity check
    if _SUPPLIERS_DICT.has_key(channel_name) == False:
        _SUPPLIERS_DICT[channel_name] = Supplier(channel_name,
                                                 getComponent(component_name))

    _SUPPLIERS_DICT[channel_name].publishEvent(simple_data=event_instance,
                                               supplier_name=component_name)
コード例 #16
0
# 
#------------------------------------------------------------------------------
'''
This Python script is designed to provide the developer with a sample implementation
of an event Supplier.
'''
#--REGULAR IMPORTS-------------------------------------------------------------
from time import sleep
#--CORBA STUBS-----------------------------------------------------------------
import ACSCOURSE_MOUNT
#--ACS Imports-----------------------------------------------------------------
from Acspy.Nc.Supplier      import Supplier
#--GLOBALS---------------------------------------------------------------------

#------------------------------------------------------------------------------
if __name__ == "__main__":
    #Create a supplier
    g = Supplier(ACSCOURSE_MOUNT.MOUNT_CHANNEL)

    #Create an instance of our user-defined IDL structure
    h = ACSCOURSE_MOUNT.MountEventData(1.1, 2.2)

    #Send 50 distinct events
    for i in range(50):
        g.publishEvent(h)
        sleep(1)
    
    #Cleanly kill the supplier
    g.disconnect()
#------------------------------------------------------------------------------
コード例 #17
0
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
# MA 02111-1307  USA
#------------------------------------------------------------------------------
'''
'''
#--REGULAR IMPORTS-------------------------------------------------------------
from time import sleep
from sys  import argv
#--CORBA STUBS-----------------------------------------------------------------
import perftest
#--ACS Imports-----------------------------------------------------------------
from Acspy.Nc.Consumer import Consumer
from Acspy.Nc.Supplier import Supplier
#--GLOBALS---------------------------------------------------------------------
sup = Supplier("perf channel")

count = 0
magicNumber = long(argv[1])
#------------------------------------------------------------------------------
def eventHandler(someParam):
    '''
    '''
    global count
    count = count + 1    
    return
#------------------------------------------------------------------------------
if __name__ == "__main__":

    print 'Creating Consumer'
    g = Consumer("perf channel")
コード例 #18
0
        curr_t = datetime.datetime.now()
        print curr_t," ===  Published events at iteration %d" % (i)

    for i in range(len(suppliers)):
        print datetime.datetime.now()," ===  %d: %d exceptions caught" % (i,num_exceptions_thrown[i])
        print datetime.datetime.now()," ===  %d: %d events dropped" % (i,num_events_dropped[i])
        print datetime.datetime.now()," ===  %d: %d events sent" % (i,num_events_sent[i])
        print datetime.datetime.now()," ===  %d: Transitions: %s" % (i,str(transitions[i]))
        
            


#------------------------------------------------------------------------------

#create suppliers
g = Supplier(channel_name)
g.set_autoreconnect(autoreconnect)
#g_autorec = Supplier(channel_name)
#g_autorec.set_autoreconnect(True)

#create data to send
h = acsnc.EventDescription("no name",
                           17L,
                           17L)

publish_all_data([g], num_events, h)

for idx in range(len(transitions)):
    n_transitions = len(transitions[idx])
    if autoreconnect:
        if ns_restarted:
コード例 #19
0
ファイル: supplier.py プロジェクト: normansaez/scripts
#!/usr/bin/env python

from Acspy.Nc.Supplier import Supplier
from time import sleep
import acsnc

<<<<<<< HEAD
#channelName = "CONTROL_SYSTEM"
=======
>>>>>>> 07e962d7853ac0fea4be44e5d6acb5d48556170a
channelName = "BD_ERR_PROP"
supplier = Supplier(channelName)


for x in range(0,10000):
    h = acsnc.EventDescription("mysupplier", x, x)
    supplier.publishEvent(h)
    sleep(0.1)
    print x

supplier.disconnect()

コード例 #20
0
'''
#--REGULAR IMPORTS-------------------------------------------------------------
from time import sleep
#--CORBA STUBS-----------------------------------------------------------------
import FRIDGE
#--ACS Imports-----------------------------------------------------------------
from Acspy.Nc.Supplier      import Supplier
from Acspy.Common.Log       import getLogger
#--GLOBALS---------------------------------------------------------------------
LOGGER = getLogger("FridgeNCSupplier")
#------------------------------------------------------------------------------
if __name__ == "__main__":

    #Create a supplier
    LOGGER.logInfo('Creating an instance of Supplier')
    g = Supplier(FRIDGE.CHANNELNAME_FRIDGE)

    #Create an instance of our user-defined IDL structure
    h = FRIDGE.temperatureDataBlockEvent(3.7, FRIDGE.ATREF)

    #Send 50 events
    LOGGER.logInfo("Ready to send NC events...")
    for i in range(50):
        g.publishEvent(simple_data=h)
        #Really just used for testing purposes
        sleep(1)
    
    LOGGER.logInfo("Events all done . . . exiting")
    #cleanly disconnect from the channel
    g.disconnect()
#------------------------------------------------------------------------------
コード例 #21
0
#!/usr/bin/env python

from Acspy.Nc.CommonNC import CommonNC
from Acspy.Nc.Supplier import Supplier
import datacapEx
from datacapEx import ExecBlockProcessedEvent, DataCapturerId, ExecBlockStartedEvent, ScanStartedEvent
import asdmEX

s = Supplier('pyTest-NC')

name = 'DATACAP1'
s.publishEvent(name)

sessionId = asdmEX.IDLEntityRef('SessionId', 'X1', 'SID', '1.0')
sb = asdmEX.IDLEntityRef('SB1', 'X1', 'SB1', '1.0')
dcId = DataCapturerId(name, 'arrayId', sessionId, sb)

execBlockId = asdmEX.IDLEntityRef('ExecBlockId', 'X1', 'SB1', '1.0')
d = ExecBlockProcessedEvent(dcId, 'statu', execBlockId, 0)
s.publishEvent(d)

execId = asdmEX.IDLEntityRef('4', '3', '2', '1')
execBlockId = asdmEX.IDLEntityRef('1', '2', '3', '4')
sse = ScanStartedEvent(execId, "something", 4,
                       [datacapEx.LAST, datacapEx.LAST], 0)
s.publishEvent(sse)

execId = "23"
execBlockEntityRef = asdmEX.IDLEntityRef(execId, "X00000000", "0", "0")
sbId = asdmEX.IDLEntityRef(execId, "X00000000", "0", "0")
arrayId = "1"
コード例 #22
0
ファイル: pySupplier.py プロジェクト: normansaez/scripts
#!/usr/bin/env python

#import CORBA Stubs
import TEST

from Acspy.Nc.Supplier import Supplier

import time

if __name__ == "__main__":
	g = Supplier(TEST.TEST_CHANNELNAME)
	for i in range(100):
		print "Sending Message " + str(i)
		msg = TEST.TestLog("Message number " + str(i))
		g.publishEvent(msg)
		time.sleep(0.5)
	g.disconnect()
コード例 #23
0
        elif opt in ("-h", "--help"):      
            usage()                     
            sys.exit()                  
        elif opt in ("-i", "--initVal"): 
            initVal = int(arg)               
        elif opt in ("-l", "--lastVal"): 
            lastVal = int(arg)               
        elif opt in ("-p", "--period"): 
            period = float(arg)               

    if not changeValSet:
        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)
        
コード例 #24
0
ファイル: CounterSupplier.py プロジェクト: ACS-Community/ACS
class CounterSupplier(COUNTER__POA.CounterSupplier,  #CORBA stubs for IDL interface
                ACSComponent,  #Base IDL interface
                ContainerServices,  #Developer niceties
                ComponentLifecycle):  #HLA stuff
    '''
    Simple component implementation provided as a reference for developers.
    '''
    

    def __init__(self):
        '''
        Just call superclass constructors here.
        '''
        ACSComponent.__init__(self)
        ContainerServices.__init__(self)

        self.LOGGER = getLogger("CounterSupplier")
        #LOGGER.logInfo('Passed through __init__')
        return
    #------------------------------------------------------------------------------
    #--Override ComponentLifecycle methods-----------------------------------------
    #------------------------------------------------------------------------------
    def initialize(self):
        '''
        Override this method inherited from ComponentLifecycle
        '''

        self.LOGGER.logTrace("CounterSupplier.CounterSupplier")

        #Create a supplier
        self.LOGGER.logInfo('Creating an instance of Supplier')
        self.supplier = Supplier(COUNTER.CHANNELNAME_COUNTER)


    #------------------------------------------------------------------------------
    def cleanUp(self):
        '''
        Override this method inherited from ComponentLifecycle
        '''

        if self.name == None:
            self.LOGGER.logInfo("Stopping main ...") 
        else:
            self.LOGGER.logInfo("Destroying " + self.name + "...") 

        #cleanly disconnect from the channel
        self.supplier.disconnect()
        
    #------------------------------------------------------------------------------
    #--Implementation of IDL methods-----------------------------------------------
    #------------------------------------------------------------------------------
    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
コード例 #25
0
 def initialize(self):
     '''
     '''
     self.supplier = Supplier("perf channel")
     return
コード例 #26
0
#!/usr/bin/env python

from Acspy.Nc.CommonNC        import CommonNC
from Acspy.Nc.Supplier        import Supplier
import datacapEx
from datacapEx import ExecBlockProcessedEvent, DataCapturerId, ExecBlockStartedEvent, ScanStartedEvent
import asdmEX

s = Supplier('pyTest-NC')

name = 'DATACAP1'
s.publishEvent(name)

sessionId = asdmEX.IDLEntityRef('SessionId','X1','SID','1.0')
sb = asdmEX.IDLEntityRef('SB1','X1','SB1','1.0')
dcId = DataCapturerId (name, 'arrayId', sessionId, sb)

execBlockId = asdmEX.IDLEntityRef('ExecBlockId','X1','SB1','1.0')
d = ExecBlockProcessedEvent( dcId, 'statu', execBlockId, 0)
s.publishEvent(d)

execId = asdmEX.IDLEntityRef('4','3','2', '1')
execBlockId = asdmEX.IDLEntityRef('1','2','3','4')
sse = ScanStartedEvent(execId, "something", 4, [datacapEx.LAST, datacapEx.LAST],0)
s.publishEvent(sse)

execId = "23"
execBlockEntityRef = asdmEX.IDLEntityRef(execId,"X00000000","0","0")
sbId   = asdmEX.IDLEntityRef(execId,"X00000000","0","0")
arrayId = "1"
time = 100
コード例 #27
0
#-----------------------------------------------------------------------------
# Wait 10 seconds to ensure the Notify Service is restarted
lm("==========================  Restart the Notify Service and wait some time to allow consumers reconnecting again"
   )
call(["acspyExecNotifyService.sh", "NotifyEventChannelFactory", "RESTART"])
sleep(15)
lm("==========================  At this point the Notify Service should have been restarted and all consumers reconnected"
   )

#------------------------------------------------------------------------------
# Create a supplier and send events
n_events = 20
lm("==========================  Create a supplier and send %d events" %
   (n_events))
s = Supplier(channel_name)
s.set_autoreconnect(True)
h = acsnc.EventDescription("no name", 17L, 17L)
send_events(s, h, n_events)

#------------------------------------------------------------------------------
# Wait and check the number of events received
lm("==========================  Events sent. Wait 5 seconds")
sleep(5)
assert_n_events_received((n_events * num_consumers), n_events_received)

#------------------------------------------------------------------------------
# Suspend consumers
lm("==========================  Suspend consumers")
for c in consumers:
    c.suspend()
コード例 #28
0
ファイル: CounterSupplier.py プロジェクト: ydc92546169/ACS
class CounterSupplier(
        COUNTER__POA.CounterSupplier,  #CORBA stubs for IDL interface
        ACSComponent,  #Base IDL interface
        ContainerServices,  #Developer niceties
        ComponentLifecycle):  #HLA stuff
    '''
    Simple component implementation provided as a reference for developers.
    '''
    def __init__(self):
        '''
        Just call superclass constructors here.
        '''
        ACSComponent.__init__(self)
        ContainerServices.__init__(self)

        self.LOGGER = getLogger("CounterSupplier")
        #LOGGER.logInfo('Passed through __init__')
        return

    #------------------------------------------------------------------------------
    #--Override ComponentLifecycle methods-----------------------------------------
    #------------------------------------------------------------------------------
    def initialize(self):
        '''
        Override this method inherited from ComponentLifecycle
        '''

        self.LOGGER.logTrace("CounterSupplier.CounterSupplier")

        #Create a supplier
        self.LOGGER.logInfo('Creating an instance of Supplier')
        self.supplier = Supplier(COUNTER.CHANNELNAME_COUNTER)

    #------------------------------------------------------------------------------
    def cleanUp(self):
        '''
        Override this method inherited from ComponentLifecycle
        '''

        if self.name == None:
            self.LOGGER.logInfo("Stopping main ...")
        else:
            self.LOGGER.logInfo("Destroying " + self.name + "...")

        #cleanly disconnect from the channel
        self.supplier.disconnect()

    #------------------------------------------------------------------------------
    #--Implementation of IDL methods-----------------------------------------------
    #------------------------------------------------------------------------------
    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
コード例 #29
0
 def initialize(self):
     '''
     '''
     self.supplier = Supplier("perf channel")
     return
コード例 #30
0
###############################################################################
'''
Tests the Python Supplier.
'''
###############################################################################
from Acspy.Nc.Supplier import Supplier
from sys import argv
from time import sleep
import acsnc

class MyEventCallback:
    def eventDropped(self,event):
        print "Callback object says that event has been dropped"
    def eventSent(self,event):
        print "Callback object says that event has been sent"

#create supplier
g = Supplier(str(argv[1]))
#create data to send
h = acsnc.EventDescription("no name",
                           17L,
                           17L)

#send variable number of events
for i in range(int(argv[2])):
    g.publishEvent(h,event_callback=MyEventCallback())
    sleep(1)

#disconnect
g.disconnect()
コード例 #31
0
    for i in range(len(suppliers)):
        print datetime.datetime.now(), " ===  %d: %d exceptions caught" % (
            i, num_exceptions_thrown[i])
        print datetime.datetime.now(), " ===  %d: %d events dropped" % (
            i, num_events_dropped[i])
        print datetime.datetime.now(), " ===  %d: %d events sent" % (
            i, num_events_sent[i])
        print datetime.datetime.now(), " ===  %d: Transitions: %s" % (
            i, str(transitions[i]))


#------------------------------------------------------------------------------

#create suppliers
g = Supplier(channel_name)
g.set_autoreconnect(autoreconnect)
#g_autorec = Supplier(channel_name)
#g_autorec.set_autoreconnect(True)

#create data to send
h = acsnc.EventDescription("no name", 17L, 17L)

publish_all_data([g], num_events, h)

for idx in range(len(transitions)):
    n_transitions = len(transitions[idx])
    if autoreconnect:
        if ns_restarted:
            if n_transitions != 0 and n_transitions != 2:
                print datetime.datetime.now(
コード例 #32
0
'''
#--REGULAR IMPORTS-------------------------------------------------------------
from time import sleep
#--CORBA STUBS-----------------------------------------------------------------
import FRIDGE
#--ACS Imports-----------------------------------------------------------------
from Acspy.Nc.Supplier import Supplier
from Acspy.Common.Log import getLogger
#--GLOBALS---------------------------------------------------------------------
LOGGER = getLogger("FridgeNCSupplier")
#------------------------------------------------------------------------------
if __name__ == "__main__":

    #Create a supplier
    LOGGER.logInfo('Creating an instance of Supplier')
    g = Supplier(FRIDGE.CHANNELNAME_FRIDGE)

    #Create an instance of our user-defined IDL structure
    h = FRIDGE.temperatureDataBlockEvent(3.7, FRIDGE.ATREF)

    #Send 50 events
    LOGGER.logInfo("Ready to send NC events...")
    for i in range(50):
        g.publishEvent(simple_data=h)
        #Really just used for testing purposes
        sleep(1)

    LOGGER.logInfo("Events all done . . . exiting")
    #cleanly disconnect from the channel
    g.disconnect()
#------------------------------------------------------------------------------
コード例 #33
0
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
# MA 02111-1307  USA
#
# @(#) $Id: acspyTestSupplier.py,v 1.1 2005/06/15 20:16:48 dfugate Exp $
###############################################################################
'''
Tests the Python Supplier.
'''
###############################################################################
from Acspy.Nc.Supplier import Supplier
from sys import argv
from time import sleep
import acsnc

#create supplier
g = Supplier(str(argv[1]))
#create data to send
h = acsnc.EventDescription("no name",
                           17L,
                           17L)

#send variable number of events
for i in range(int(argv[2])):
    g.publishEvent(h)
    sleep(1)

#disconnect
g.disconnect()
コード例 #34
0
'''
Tests the Python Supplier.
'''
###############################################################################
from Acspy.Nc.Supplier import Supplier
from sys import argv
from time import sleep
import acsnc


class MyEventCallback:
    def eventDropped(self, event):
        print "Callback object says that event has been dropped"

    def eventSent(self, event):
        print "Callback object says that event has been sent"


#create supplier
g = Supplier(str(argv[1]))
#create data to send
h = acsnc.EventDescription("no name", 17L, 17L)

#send variable number of events
for i in range(int(argv[2])):
    g.publishEvent(h, event_callback=MyEventCallback())
    sleep(1)

#disconnect
g.disconnect()
コード例 #35
0
ファイル: errorSupplierTest.py プロジェクト: ydc92546169/ACS
#!/usr/bin/env python
from Acspy.Clients.SimpleClient import PySimpleClient
from Acspy.Common.Err import ACSError
from Acspy.Common import TimeHelper
from Acspy.Nc.Supplier import Supplier
from time import sleep, time
import bulkdata

c = PySimpleClient()
supplier = Supplier(bulkdata.CHANNELNAME_ERR_PROP)
#print bulkdata.BAD_SENDER
#print bulkdata.BAD_RECEIVER
#print bulkdata.OK
print "I will send events ..."
flow = "00"
for x in range(0, 10000):
    timestamp = TimeHelper.TimeUtil().epoch2py(TimeHelper.getTimeStamp())
    h = bulkdata.errorStatusBlock(flow, bulkdata.BAD_RECEIVER, timestamp)
    #    if x % 2 == 0:
    #        h.status = bulkdata.OK
    supplier.publishEvent(h)
    sleep(0.1)
    print(x, h)

supplier.disconnect()