示例#1
0
    def __init__(self, name):

        # Initialize logger
        self._log = logging.getLogger("EmonHub")

        # Initialise thread
        threading.Thread.__init__(self)
        self.setName(name)

        # Initialise settings
        self._defaults = {
            'pause': 'off',
            'interval': 0,
            'datacode': '0',
            'scale': '1',
            'timestamped': False,
            'targeted': False,
            'nodeoffset': '0',
            'pubchannels': [],
            'subchannels': [],
            'batchsize': '1'
        }

        self.init_settings = {}
        self._settings = {}

        # Initialize message queue
        self._sub_channels = {}
        self._pub_channels = {}

        # This line will stop the default values printing to logfile at start-up
        # unless they have been overwritten by emonhub.conf entries
        # comment out if diagnosing a startup value issue
        self._settings.update(self._defaults)

        # Initialize interval timer's "started at" timestamp
        self._interval_timestamp = 0

        buffer_type = "memory"
        buffer_size = 1000

        # Create underlying buffer implementation
        self.buffer = ehb.getBuffer(buffer_type)(name, buffer_size)

        # set an absolute upper limit for number of items to process per post
        # number of items posted is the lower of this item limit, buffer_size, or the
        # batchsize, as set in reporter settings or by the default value.
        self._item_limit = buffer_size

        # create a stop
        self.stop = False
    def __init__(self, reporterName, queue, buffer_type="memory", buffer_size=1000, **kwargs):
        """Create a server data buffer initialized with server settings."""

        # Initialize logger
        self._log = logging.getLogger("EmonHub")

        # Initialise thread
        threading.Thread.__init__(self)

        # Initialise settings	
        self.name = reporterName
        self.init_settings = {}
        self._defaults = {'pause': 'off', 'interval': '0', 'batchsize': '3'}
        self._settings = {}
        self._queue = queue
	self.logfilepath="/home/pi/data/logs/emonhub_rep_log.txt"
	logfile=open(self.logfilepath, "a")
	logfile.close()
	self.redis_DB = redis.StrictRedis(host='localhost', port=6379, db=0)	#Added for CIVIS project
	self.ApartmentID=self._getApartmentIDfromFile()				#Added for CIVIS project
	print "ApartmentID="+self.ApartmentID
	self.PositionID=self._getPositionIDfromFile()				#Added for CIVIS Project
	print "PositionID="+self.PositionID
	
	# This line will stop the default values printing to logfile at start-up
        # unless they have been overwritten by emonhub.conf entries
        # comment out if diagnosing a startup value issue
        self._settings.update(self._defaults)

        # Initialize interval timer's "started at" timestamp
        self._interval_timestamp = 0

        # Create underlying buffer implementation
        self.buffer = ehb.getBuffer(buffer_type)(reporterName, buffer_size, **kwargs)

        # set an absolute upper limit for number of items to process per post
        # number of items posted is the lower of this item limit, buffer_size, or the
        # batchsize, as set in reporter settings or by the default value.
        self._item_limit = buffer_size
        
        self._log.info("Set up reporter '%s' (buffer: %s | size: %s)"
                       % (reporterName, buffer_type, buffer_size))

        # Initialise a thread and start the reporter
        self.stop = False
        self.start()
示例#3
0
    def __init__(self,
                 reporterName,
                 queue,
                 buffer_type="memory",
                 buffer_size=1000,
                 **kwargs):
        """Create a server data buffer initialized with server settings."""

        # Initialize logger
        self._log = logging.getLogger("EmonHub")

        # Initialise thread
        threading.Thread.__init__(self)

        # Initialise settings
        self.name = reporterName
        self.init_settings = {}
        self._defaults = {'pause': 'off', 'interval': '0', 'batchsize': '1'}
        self._settings = {}
        self._queue = queue

        # This line will stop the default values printing to logfile at start-up
        # unless they have been overwritten by emonhub.conf entries
        # comment out if diagnosing a startup value issue
        self._settings.update(self._defaults)

        # Initialize interval timer's "started at" timestamp
        self._interval_timestamp = 0

        # Create underlying buffer implementation
        self.buffer = ehb.getBuffer(buffer_type)(reporterName, buffer_size,
                                                 **kwargs)

        # set an absolute upper limit for number of items to process per post
        # number of items posted is the lower of this item limit, buffer_size, or the
        # batchsize, as set in reporter settings or by the default value.
        self._item_limit = buffer_size

        self._log.info("Set up reporter '%s' (buffer: %s | size: %s)" %
                       (reporterName, buffer_type, buffer_size))

        # Initialise a thread and start the reporter
        self.stop = False
        self.start()
示例#4
0
    def __init__(self, reporterName, queue, buffer_type="memory", buffer_size=1000, **kwargs):
        """Create a server data buffer initialized with server settings."""

        # Initialize logger
        self._log = logging.getLogger("EmonHub")

        # Initialise thread
        threading.Thread.__init__(self)

        # Initialise settings
        self.name = reporterName
        self.init_settings = {}
        self._defaults = {'pause': 'off', 'interval': '0', 'batchsize': '1'}
        self._settings = {}
        self._queue = queue

        # This line will stop the default values printing to logfile at start-up
        # unless they have been overwritten by emonhub.conf entries
        # comment out if diagnosing a startup value issue
        self._settings.update(self._defaults)

        # Initialize interval timer's "started at" timestamp
        self._interval_timestamp = 0

        # Create underlying buffer implementation
        self.buffer = ehb.getBuffer(buffer_type)(reporterName, buffer_size, **kwargs)

        # set an absolute upper limit for number of items to process per post
        # number of items posted is the lower of this item limit, buffer_size, or the
        # batchsize, as set in reporter settings or by the default value.
        self._item_limit = buffer_size
        
        self._log.info("Set up reporter '%s' (buffer: %s | size: %s)"
                       % (reporterName, buffer_type, buffer_size))

        # Initialise a thread and start the reporter
        self.stop = False
        self.start()