예제 #1
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))
 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
예제 #3
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)
예제 #4
0
    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)
예제 #5
0
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()
예제 #6
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)
예제 #7
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()
#------------------------------------------------------------------------------
예제 #8
0
 def initialize(self):
     '''
     '''
     self.supplier = Supplier("perf channel")
     return
예제 #9
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()
예제 #10
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(
예제 #11
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"
예제 #12
0
#!/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()