Ejemplo n.º 1
0
	def set_value(self, newvalue):
		r = self._proxy.SetValue(wrap_dbus_value(newvalue))

		# instead of just saving the value, go to the dbus and get it. So we have the right type etc.
		if r == 0:
			self._refreshcachedvalue()

		return r
Ejemplo n.º 2
0
	def set_value(self, newvalue):
		r = self._proxy.SetValue(wrap_dbus_value(newvalue))

		# instead of just saving the value, go to the dbus and get it. So we have the right type etc.
		if r == 0:
			self._refreshcachedvalue()

		return r
Ejemplo n.º 3
0
	def local_set_value(self, newvalue):
		if self._value == newvalue:
			return

		self._value = newvalue

		changes = {}
		changes['Value'] = wrap_dbus_value(newvalue)
		changes['Text'] = self.GetText()
		self.PropertiesChanged(changes)
Ejemplo n.º 4
0
	def local_set_value(self, newvalue):
		if self._value == newvalue:
			return

		self._value = newvalue

		changes = {}
		changes['Value'] = wrap_dbus_value(newvalue)
		changes['Text'] = self.GetText()
		self.PropertiesChanged(changes)
Ejemplo n.º 5
0
	def _get_tree_dict(self, path, get_text=False):
		logging.debug("_get_tree_dict called for %s" % path)
		r = {}
		px = path
		if not px.endswith('/'):
			px += '/'
		for p, item in self._dbusobjects.items():
			if p.startswith(px):
				v = item.GetText() if get_text else wrap_dbus_value(item.local_get_value())
				r[p[len(px):]] = v
		logging.debug(r)
		return r
Ejemplo n.º 6
0
	def _get_tree_dict(self, path, get_text=False):
		logging.debug("_get_tree_dict called for %s" % path)
		r = {}
		px = path
		if not px.endswith('/'):
			px += '/'
		for p, item in self._dbusobjects.items():
			if p.startswith(px):
				v = item.GetText() if get_text else wrap_dbus_value(item.local_get_value())
				r[p[len(px):]] = v
		logging.debug(r)
		return r
Ejemplo n.º 7
0
	def set_value(self, serviceName, objectPath, value):
		# Check if the D-Bus object referenced by serviceName and objectPath is registered. There is no
		# necessity to do this, but it is in line with previous implementations which kept VeDbusItemImport
		# objects for registers items only.
		service = self.servicesByName.get(serviceName, None)
		if service is None:
			return -1
		if objectPath not in service['paths']:
			return -1
		# We do not catch D-Bus exceptions here, because the previous implementation did not do that either.
		return self.dbusConn.call_blocking(serviceName, objectPath,
				   dbus_interface='com.victronenergy.BusItem',
				   method='SetValue', signature=None,
				   args=[wrap_dbus_value(value)])
Ejemplo n.º 8
0
	def set_value(self, serviceName, objectPath, value):
		# Check if the D-Bus object referenced by serviceName and objectPath is registered. There is no
		# necessity to do this, but it is in line with previous implementations which kept VeDbusItemImport
		# objects for registers items only.
		service = self.servicesByName.get(serviceName, None)
		if service is None:
			return -1
		if objectPath not in service['paths']:
			return -1
		# We do not catch D-Bus exceptions here, because the previous implementation did not do that either.
		return self.dbusConn.call_blocking(serviceName, objectPath,
		                                   dbus_interface='com.victronenergy.BusItem',
		                                   method='SetValue', signature=None,
		                                   args=[wrap_dbus_value(value)])
Ejemplo n.º 9
0
	def set_value_async(self, serviceName, objectPath, value,
			reply_handler=None, error_handler=None):
		service = self.servicesByName.get(serviceName, None)
		if service is not None:
			if objectPath in service['paths']:
				self.dbusConn.call_async(serviceName, objectPath,
					dbus_interface='com.victronenergy.BusItem',
					method='SetValue', signature=None,
					args=[wrap_dbus_value(value)],
					reply_handler=reply_handler, error_handler=error_handler)
				return

		if error_handler is not None:
			error_handler(TypeError('Service or path not found, '
						'service=%s, path=%s' % (serviceName, objectPath)))
    def set_value_async(self,
                        serviceName,
                        objectPath,
                        value,
                        reply_handler=None,
                        error_handler=None):
        service = self.servicesByName.get(serviceName, None)
        if service is not None:
            if objectPath in service.paths:
                self.dbusConn.call_async(
                    serviceName,
                    objectPath,
                    dbus_interface='com.victronenergy.BusItem',
                    method='SetValue',
                    signature=None,
                    args=[wrap_dbus_value(value)],
                    reply_handler=reply_handler,
                    error_handler=error_handler)
                return

        if error_handler is not None:
            error_handler(
                TypeError('Service or path not found, '
                          'service=%s, path=%s' % (serviceName, objectPath)))
Ejemplo n.º 11
0
 def _set_dbus_value(self, service, path, value):
     value = wrap_dbus_value(value)
     return self._dbus_conn.call_blocking(service, path, None, 'SetValue',
                                          'v', [value])
Ejemplo n.º 12
0
	def GetValue(self):
		return wrap_dbus_value(self._value)
Ejemplo n.º 13
0
	def GetValue(self):
		return wrap_dbus_value(self._value)