def device_report_event()

in leda_python/deviceMbus.py [0:0]


    def device_report_event(self, name, report_info):
        '''
		:param name: 事件名称
		:param report_info: 携带信息,其格式为key-value形式的json串, 如上报事件:
			{
				"params": {
					"value" : {
					  "key1":"value1",
					  "key2":"value2"
					},
					"time" : 1524448722000
				  }
			 }
		:return:
		'''

        if (None == self.deviceMbusHandle):
            _logger.warning("device(%s) can't report event unless online ", self.cloud_id)
            raise exception.LedaReportEventException("device(%s) can't report event unless online" % (self.cloud_id))

        if ((False == isinstance(report_info, str)) or (False == isinstance(name, str))):
            raise exception.LedaReportEventException(
                "device(%s):device_report_event,params type is invalid" % (self.cloud_id))

        if (len(name) > mbusConfig.STRING_NAME_MAX_LEN):
            raise exception.LedaReportEventException(
                "device(%s):device_report_event,params name is too long(%s)" % (len(name)))

        srcWKN = self.deviceMbusHandle.getName()
        srcInterface = srcWKN
        srcObjectPath = "/" + srcInterface.replace(".", "/")

        self.deviceMbusHandle.unicastSignal(srcObjectPath, srcInterface, mbusConfig.DMP_SUB_WKN, 's', name, report_info)

        _logger.info("Device(%s): report event(%s): %s" % (self.cloud_id, name, report_info))