示例#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
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
 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
 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
示例#5
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)
示例#6
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))
示例#7
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))
示例#8
0
#!/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()

示例#9
0
#!/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()
示例#10
0
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
###############################################################################
'''
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()
示例#12
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()
#------------------------------------------------------------------------------
#--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()
#------------------------------------------------------------------------------







#--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()
#------------------------------------------------------------------------------
        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
示例#16
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"
示例#17
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
示例#18
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()
'''
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()
示例#20
0
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
示例#21
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()