Ejemplo n.º 1
0
def mapviewer_mapViewScaleChanged_handler(mapViewInstanceHandle, scale,
                                          isMinMax):
    global g_scale
    global step
    new_scale = int(scale)
    print("Scale: " + str(new_scale))
    print('Is min max: ' + str(int(isMinMax)))
    if step == TEST_STEP_SCALE:
        time.sleep(0.25)
        if g_scale > new_scale and isMinMax != MAPVIEWER_MIN:
            print("Zoom in")
            g_scale = new_scale
            MapViewerControl_interface.setMapViewScaleByDelta( \
                dbus.UInt32(sessionhandle), \
                dbus.UInt32(mapviewerhandle), \
                dbus.Int16(-1))
        else:
            if isMinMax != MAPVIEWER_MAX:
                print("Zoom out")
                g_scale = new_scale
                MapViewerControl_interface.setMapViewScaleByDelta( \
                    dbus.UInt32(sessionhandle), \
                    dbus.UInt32(mapviewerhandle), \
                    dbus.Int16(1))
            else:
                print('Test scale PASSED')
                next_step()
def test_scale(scale,isMinMax):
    global g_scale
    global g_scale_delta
    global g_heading_angle
    print("Scale: "+str(scale))
    print('Is min max: '+str(isMinMax))
    g_scale=scale
    if g_scale_delta==SCALE_DELTA_DECREASE:
        if isMinMax !=genivi.MAPVIEWER_MIN:
            print("Zoom in")
            g_mapviewercontrol_interface.SetMapViewScaleByDelta( \
                dbus.UInt32(g_mapviewer_sessionhandle), \
                dbus.UInt32(g_mapviewer_maphandle), \
                dbus.Int16(g_scale_delta))
            return True
        else:
            print("Zoom out")
            g_scale_delta=SCALE_DELTA_INCREASE
            g_mapviewercontrol_interface.SetMapViewScaleByDelta( \
                dbus.UInt32(g_mapviewer_sessionhandle), \
                dbus.UInt32(g_mapviewer_maphandle), \
                dbus.Int16(g_scale_delta))  
            return True
    else:
        if isMinMax !=genivi.MAPVIEWER_MAX:
            print("Zoom out")
            g_mapviewercontrol_interface.SetMapViewScaleByDelta( \
                dbus.UInt32(g_mapviewer_sessionhandle), \
                dbus.UInt32(g_mapviewer_maphandle), \
                dbus.Int16(g_scale_delta))
            return True
        else:
            print('Test scale PASSED')
            return False
def mapviewer_mapViewScaleChanged_handler(mapViewInstanceHandle, scale,
                                          isMinMax):
    global g_scale
    new_scale = int(scale)
    print("Scale: " + str(new_scale))
    print('Is min max: ' + str(int(isMinMax)))
    time.sleep(0.25)
    if g_scale > new_scale and new_scale != MIN_SCALE:
        print("Zoom in")
        g_scale = new_scale
        MapViewerControl_interface.setMapViewScaleByDelta( \
            dbus.UInt32(sessionhandle), \
            dbus.UInt32(mapviewerhandle), \
            dbus.Int16(1))
    else:
        if new_scale < MAX_SCALE:
            print("Zoom out")
            g_scale = new_scale
            MapViewerControl_interface.setMapViewScaleByDelta( \
                dbus.UInt32(sessionhandle), \
                dbus.UInt32(mapviewerhandle), \
                dbus.Int16(-1))
        else:
            print 'Test PASSED'
            MapViewerControl_interface.releaseMapViewInstance( \
                dbus.UInt32(sessionhandle), \
                dbus.UInt32(mapviewerhandle))
            session_interface.deleteSession(sessionhandle)
            loop.quit()
Ejemplo n.º 4
0
def translator(c, pack):
    """A translator for L{Change}s"""
    if pack:
        if isinstance(c.edit, Insertion):
            return dbus.Struct(
                (dbus.Int64(c.unique_id), dbus.Int64(c.parent), dbus.Int16(0),
                 dbus.Int64(c.edit.position), dbus.UTF8String(c.edit.text)),
                signature='xxnxs')
        elif isinstance(c.edit, Deletion):
            return dbus.Struct(
                (dbus.Int64(c.unique_id), dbus.Int64(c.parent), dbus.Int16(1),
                 dbus.Int64(c.edit.position), dbus.Int64(c.edit.length)),
                signature='xxnxx')
        elif isinstance(c.edit, Removal):
            return dbus.Struct(
                (dbus.Int64(c.unique_id), dbus.Int64(c.parent), dbus.Int16(2),
                 dbus.Int64(c.edit.position), dbus.Int64(c.edit.length)),
                signature='xxnxx')
        else:
            raise Unimplemented
    else:
        if c[2] == 0:
            ed = Insertion(int(c[3]), str(c[4]))
        elif c[2] == 1:
            ed = Deletion(int(c[3]), int(c[4]))
        elif c[2] == 2:
            ed = Removal(int(c[3]), int(c[4]))
        else:
            raise "unknown type"
        return Change(int(c[0]), int(c[1]), ed)
def test_rotate():    
    global g_angle
    if g_angle <   (ROTATE_MAX-ROTATE_INCREMENT):
        g_angle += ROTATE_INCREMENT
        g_mapviewercontrol_interface.SetMapViewRotation( \
            dbus.UInt32(g_mapviewer_sessionhandle), \
            dbus.UInt32(g_mapviewer_maphandle), \
            dbus.Int16(g_angle), \
            dbus.Int16(ROTATE_SPEED))
        return True
    else:
        print('Test rotate PASSED')
        return False
Ejemplo n.º 6
0
 def testBuildArgString(self):
     """Test that we correctly form argument strings from dbus.* types."""
     self.assertEquals(dbus_send._build_arg_string([dbus.Int16(42)]),
                       'int16:42')
     self.assertEquals(
         dbus_send._build_arg_string([dbus.Int16(42),
                                      dbus.Boolean(True)]),
         'int16:42 boolean:true')
     self.assertEquals(
         dbus_send._build_arg_string(
             [dbus.Int16(42),
              dbus.Boolean(True),
              dbus.String("foo")]), 'int16:42 boolean:true string:foo')
Ejemplo n.º 7
0
def routing_routeCalculationSuccessful_handler(routeHandle,unfullfilledPreferences):
    global g_guidance_active
    print ('Route Calculation Successfull: ' + str(routeHandle))
    #get route overview
    overview = g_routing_interface.GetRouteOverview(dbus.UInt32(g_route_handle),dbus.Array([dbus.Int32(genivi.TOTAL_DISTANCE),dbus.Int32(genivi.TOTAL_TIME)]))
    #retrieve distance 
    totalDistance = dbus.Struct(overview[dbus.Int32(genivi.TOTAL_DISTANCE)])
    print ('Total Distance: ' + str(totalDistance[1]/1000) + ' km')
    totalTime = dbus.Struct(overview[dbus.Int32(genivi.TOTAL_TIME)])
    m, s = divmod(totalTime[1], 60)
    h, m = divmod(m, 60)
    print ("Total Time: %d:%02d:%02d" % (h, m, s))
    #get route segments     GetRouteSegments(const uint32_t& routeHandle, const int16_t& detailLevel, const std::vector< DBusCommonAPIEnumeration >& valuesToReturn, const uint32_t& numberOfSegments, const uint32_t& offset, uint32_t& totalNumberOfSegments, std::vector< std::map< DBusCommonAPIEnumeration, DBusCommonAPIVariant > >& routeSegments)
    valuesToReturn = [dbus.Int32(genivi.ROAD_NAME),
    dbus.Int32(genivi.START_LATITUDE),
    dbus.Int32(genivi.END_LATITUDE),
    dbus.Int32(genivi.START_LONGITUDE),
    dbus.Int32(genivi.END_LONGITUDE),
    dbus.Int32(genivi.DISTANCE),
    dbus.Int32(genivi.TIME),
    dbus.Int32(genivi.SPEED)]
    numberOfSegments = NUMBER_OF_SEGMENTS
    detailLevel = 0
    offset = 0
    ret = g_routing_interface.GetRouteSegments(dbus.UInt32(g_route_handle),dbus.Int16(detailLevel),dbus.Array(valuesToReturn),dbus.UInt32(numberOfSegments),dbus.UInt32(offset))
    print ("Total number of segments: " + str(ret[0]) )
    #len(ret[1]) is size
    #ret[1][0][genivi.START_LATITUDE] is the start latitude
    g_guidance_active = True
#        pdb.set_trace()
    launch_guidance(routeHandle)
Ejemplo n.º 8
0
    def test(self):
        @privops._coerceDbusArgs
        def func(a):
            self.assert_(type(a) is int)
            return True

        self.assertEqual(func(dbus.Int16(12)), True)
Ejemplo n.º 9
0
def catchall_route_calculation_signals_handler(routeHandle, status, percentage):
    print 'Route Calculation: ' + str(int(percentage)) + ' %'
    if int(percentage) == 100:
        #get route overview
        overview = g_routing_interface.GetRouteOverview(dbus.UInt32(g_route_handle),dbus.Array([dbus.Int32(GENIVI_NAVIGATIONCORE_TOTAL_DISTANCE),dbus.Int32(GENIVI_NAVIGATIONCORE_TOTAL_TIME)]))
        #retrieve distance 
        totalDistance = dbus.Struct(overview[dbus.Int32(GENIVI_NAVIGATIONCORE_TOTAL_DISTANCE)])
        print 'Total Distance: ' + str(totalDistance[1]/1000) + ' km'
        totalTime = dbus.Struct(overview[dbus.Int32(GENIVI_NAVIGATIONCORE_TOTAL_TIME)])
        m, s = divmod(totalTime[1], 60)
        h, m = divmod(m, 60)
        print "Total Time: %d:%02d:%02d" % (h, m, s)
        #get route segments     GetRouteSegments(const uint32_t& routeHandle, const int16_t& detailLevel, const std::vector< DBusCommonAPIEnumeration >& valuesToReturn, const uint32_t& numberOfSegments, const uint32_t& offset, uint32_t& totalNumberOfSegments, std::vector< std::map< DBusCommonAPIEnumeration, DBusCommonAPIVariant > >& routeSegments)
        valuesToReturn = [dbus.Int32(GENIVI_NAVIGATIONCORE_ROAD_NAME),
        dbus.Int32(GENIVI_NAVIGATIONCORE_START_LATITUDE),
        dbus.Int32(GENIVI_NAVIGATIONCORE_END_LATITUDE),
        dbus.Int32(GENIVI_NAVIGATIONCORE_START_LONGITUDE),
        dbus.Int32(GENIVI_NAVIGATIONCORE_END_LONGITUDE),
        dbus.Int32(GENIVI_NAVIGATIONCORE_DISTANCE),
        dbus.Int32(GENIVI_NAVIGATIONCORE_TIME),
        dbus.Int32(GENIVI_NAVIGATIONCORE_SPEED)]
        ret = g_routing_interface.GetRouteSegments(dbus.UInt32(g_route_handle),dbus.Int16(0),dbus.Array(valuesToReturn),dbus.UInt32(500),dbus.UInt32(0))
	print "Total number of segments: " + str(ret[0]) 
        #len(ret[1]) is size
        #ret[1][0][GENIVI_NAVIGATIONCORE_START_LATITUDE] is the start latitude
#        pdb.set_trace()
        route = g_current_route + 1
        if route < routes.length:
            launch_route_calculation(route)
        else:
            for i in range(routes.length):
                g_routing_interface.DeleteRoute(dbus.UInt32(g_session_handle),dbus.UInt32(routes[i].getElementsByTagName("handle")[0].childNodes[0].data))
            g_session_interface.DeleteSession(dbus.UInt32(g_session_handle))
Ejemplo n.º 10
0
 def signal(self, value):
     self._prop_proxy.Set(self._iface_name,
                          'SignalStrength',
                          dbus.Int16(value),
                          reply_handler=self._success,
                          error_handler=self._failure)
     self._wait_for_async_op()
Ejemplo n.º 11
0
 def priority(self, value):
     self._prop_proxy.Set(self._iface_name,
                          'Priority',
                          dbus.Int16(value),
                          reply_handler=self._success,
                          error_handler=self._failure)
     self._wait_for_async_op()
Ejemplo n.º 12
0
 def get_properties(self):
     properties = dict()
     properties['Type'] = self.ad_type
     if self.service_uuids is not None:
         properties['ServiceUUIDs'] = dbus.Array(self.service_uuids,
                                                 signature='s')
     if self.solicit_uuids is not None:
         properties['SolicitUUIDs'] = dbus.Array(self.solicit_uuids,
                                                 signature='s')
     if self.manufacturer_data is not None:
         properties['ManufacturerData'] = dbus.Dictionary(
             self.manufacturer_data, signature='qv')
     if self.service_data is not None:
         properties['ServiceData'] = dbus.Dictionary(self.service_data,
                                                     signature='sv')
     if self.local_name is not None:
         properties['LocalName'] = dbus.String(self.local_name)
     if self.include_tx_power:
         properties['Includes'] = dbus.Array(["tx-power"], signature='s')
     if self.data is not None:
         properties['Data'] = dbus.Dictionary(self.data, signature='yv')
     if self.min_interval is not None:
         properties['MinInterval'] = dbus.UInt32(self.min_interval)
     if self.max_interval is not None:
         properties['MaxInterval'] = dbus.UInt32(self.max_interval)
     if self.tx_power is not None:
         properties['TxPower'] = dbus.Int16(self.tx_power)
     if self.appearance is not None:
         properties['Appearance'] = dbus.UInt16(self.appearance)
     if self.discoverable is not None:
         properties['Discoverable'] = dbus.Boolean(self.discoverable)
     return {LE_ADVERTISEMENT_IFACE: properties}
Ejemplo n.º 13
0
 def GetInputsState(self):
     result = dbus.Array()
     for slot in self.inputs:
         in_state = self.inputs[slot].get_inputs()
         for i in range(0, GPIO_board.NUM_GPIO):
             result.append((dbus.Int16(GPIO_board.NUM_GPIO * slot + i),
                            dbus.Boolean((in_state >> i) & 0x01)))
     if (result == []): result = [-1]
     return dbus.Array(sorted(result))
Ejemplo n.º 14
0
def AddDevice(self, adapter_device_name, device_address, alias):
    '''Convenience method to add a Bluetooth device

    You have to specify a device address which must be a valid Bluetooth
    address (e.g. 'AA:BB:CC:DD:EE:FF'). The alias is the human-readable name
    for the device (e.g. as set on the device itself), and the adapter device
    name is the device_name passed to AddAdapter.

    This will create a new, unpaired and unconnected device.

    Returns the new object path.
    '''
    device_name = 'dev_' + device_address.replace(':', '_').upper()
    adapter_path = '/org/bluez/' + adapter_device_name
    path = adapter_path + '/' + device_name

    if adapter_path not in mockobject.objects:
        raise dbus.exceptions.DBusException(
            'Adapter %s does not exist.' % adapter_device_name,
            name=BLUEZ_MOCK_IFACE + '.NoSuchAdapter')

    properties = {
        'UUIDs': dbus.Array([], signature='s', variant_level=1),
        'Blocked': dbus.Boolean(False, variant_level=1),
        'Connected': dbus.Boolean(False, variant_level=1),
        'LegacyPairing': dbus.Boolean(False, variant_level=1),
        'Paired': dbus.Boolean(False, variant_level=1),
        'Trusted': dbus.Boolean(False, variant_level=1),
        'RSSI': dbus.Int16(-79, variant_level=1),  # arbitrary
        'Adapter': dbus.ObjectPath(adapter_path, variant_level=1),
        'Address': dbus.String(device_address, variant_level=1),
        'Alias': dbus.String(alias, variant_level=1),
        'Name': dbus.String(alias, variant_level=1),
    }

    self.AddObject(path,
                   DEVICE_IFACE,
                   # Properties
                   properties,
                   # Methods
                   [
                       ('CancelPairing', '', '', ''),
                       ('Connect', '', '', ''),
                       ('ConnectProfile', 's', '', ''),
                       ('Disconnect', '', '', ''),
                       ('DisconnectProfile', 's', '', ''),
                       ('Pair', '', '', ''),
                   ])

    manager = mockobject.objects['/']
    manager.EmitSignal(OBJECT_MANAGER_IFACE, 'InterfacesAdded',
                       'oa{sa{sv}}', [
                           dbus.ObjectPath(path),
                           {DEVICE_IFACE: properties},
                       ])

    return path
Ejemplo n.º 15
0
def Braitenberg():
    global distance
    #get the values of the sensors
    network.GetVariable("thymio-II",
                        "prox.horizontal",
                        reply_handler=get_prox_reply,
                        error_handler=get_variables_error)

    #print the proximity sensors value in the terminal
    #print proxSensorsVal[0],proxSensorsVal[1],proxSensorsVal[2],proxSensorsVal[3],proxSensorsVal[4]

    #Parameters of the Braitenberg, to give weight to each wheels
    leftWheel = [-0.01, -0.005, -0.0001, 0.006, 0.015]
    rightWheel = [0.012, +0.007, -0.0002, -0.0055, -0.011]

    #Braitenberg algorithm
    totalLeft = 0
    totalRight = 0
    for i in range(5):
        totalLeft = totalLeft + (proxSensorsVal[i] * leftWheel[i])
        totalRight = totalRight + (proxSensorsVal[i] * rightWheel[i])

    #add a constant speed to each wheels so the robot moves always forward
    totalRight = reverse * (totalRight + speed)
    totalLeft = reverse * (totalLeft + speed)

    #print in terminal the values that is sent to each motor
    print "totalLeft"
    print totalLeft
    print "totalRight"
    print totalRight

    #send motor value to the robot
    network.SetVariable("thymio-II", "motor.left.target", [totalLeft])
    network.SetVariable("thymio-II", "motor.right.target", [totalRight * -1])

    realSpeed = totalLeft

    network.GetVariable("thymio-II",
                        "motor.left.speed",
                        reply_handler=get_speed_reply,
                        error_handler=get_variables_error)
    print dbArray
    for i in dbArray:
        if type(i) == type(dbus.Int16(0)):
            print "trouve la valeur : "
            print int(i)
            realSpeed = int(i)
    #On retire la distance parcourue (proprtionnelle a l'unite de mesure du thymio), *0.1 car la boucle est iteree toutes les 0.1 secondes
    distance -= reverse * (realSpeed) * 36 / 48 * 0.1 * 0.5
    print distance
    if (distance < 1):
        network.SetVariable("thymio-II", "motor.left.target", [0])
        network.SetVariable("thymio-II", "motor.right.target", [0])
        loop.quit()
        return False
    return True
Ejemplo n.º 16
0
 def GetOutputsState(self):
     result = []
     for slot in self.outputs:
         out_states = self.outputs[slot].get_outputs()
         for i in range(0, GPIO_board.NUM_GPIO):
             #state = self.outputs[slot].get_output(i)
             result.append((dbus.Int16(GPIO_board.NUM_GPIO * slot + i),
                            bool((out_states >> i) & 0x01)))
     if (result == []): result = [-1]
     return dbus.Array(sorted(result))
Ejemplo n.º 17
0
    def testCollections(self):
        self.assertEqual(
            utils.coerceDbusType(
                dbus.Struct(
                    (dbus.String('x'), dbus.String('y'), dbus.String('z')))),
            ('x', 'y', 'z'))

        self.assertEqual(
            utils.coerceDbusType(
                dbus.Array([dbus.Int16(12),
                            dbus.Int16(13),
                            dbus.Int16(14)])), [12, 13, 14])

        self.assertEqual(
            utils.coerceDbusType(
                dbus.Dictionary({
                    dbus.Int16(12): dbus.String('foo'),
                    dbus.Int16(13): dbus.String('bar')
                })), {
                    12: 'foo',
                    13: 'bar'
                })
Ejemplo n.º 18
0
def str_operate(fd,str_input,fun):
    MAX_LEN=30
    # integer_str_num=0
    # remainder_str_num=0
    temp_fd = dbus.Int16(fd)
    str_len = len(str_input)
    integer_str_num = str_len / MAX_LEN
    remainder_str_num = str_len % MAX_LEN

    for i in range(0, integer_str_num, 1):
        start_pos = i * MAX_LEN
        end_pos = i * MAX_LEN + MAX_LEN
        temp_str = str_input[start_pos:end_pos]
        # temp_fd=dbus.Int16(fd)
        temp_data_buf = dbus.String(temp_str)

        temp_buff_size=dbus.Int16(MAX_LEN)
        fun(temp_fd,temp_data_buf,temp_buff_size)
    if remainder_str_num>0:
        temp_str = str_input[integer_str_num * MAX_LEN:integer_str_num * MAX_LEN + remainder_str_num]
        temp_data_buf = dbus.String(temp_str)
        temp_buff_size = dbus.Int16(remainder_str_num)
        fun(temp_fd, temp_data_buf, temp_buff_size)
Ejemplo n.º 19
0
	def set_scan_filter(self, filter):
		f = dict()

		if filter['uuids'] is not None:
			f['UUIDs'] = dbus.Array(filter['uuids'], signature='s')
		if filter['rssi'] is not None and filter['pathloss'] is None:
			f['RSSI'] = dbus.Int16(filter['rssi'])
		if filter['pathloss'] is not None and filter['rssi'] is None:
			f['Pathloss'] = dbus.UInt16(filter['pathloss'])
		if filter['transport'] is not None:
			f['Transport'] = dbus.String(filter['transport'])
		if filter['duplicate'] is not None:
			f['DuplicateData'] = dbus.Boolean(filter['duplicate'])

		self.if_adapter.SetDiscoveryFilter(f)
Ejemplo n.º 20
0
    def can_set_parameter(self,can_name,baud_rates,status,loop):
        baud_rates_1=int(baud_rates)*1000
        temp_name = dbus.String(can_name)
        temp_baud_rates = dbus.Int64(baud_rates_1)
        temp_baud_status = dbus.Int16(status)
        temp_loop = dbus.String(loop)
        #temp_ret=BaseMessage_DBus.iface.setCanPort(temp_name, temp_baud_rates,temp_baud_status,temp_loop)

        '''
        <arg name="can_configure" type="s" direction="out"/> 
        char *device_name, int fd, int bitrate, char  *loop
        '''
        tmp_ret,temp_param= BaseMessage_DBus.iface.setCanPort(temp_name, temp_baud_rates, temp_baud_status, temp_loop)
        temp_ret=int(tmp_ret)
        return temp_ret, temp_param
Ejemplo n.º 21
0
    def TestVariant(self, v, modify):

        if modify:
            if type(v) == dbus.Boolean:
                ret = False
            elif type(v) == dbus.Dictionary:
                ret = {}
                for i in v:
                    ret[i] = v[i] * 2
            elif type(v) == dbus.Struct:
                ret = ["other struct", dbus.Int16(100)]
            else:
                ret = v * 2
        else:
            ret = v
        return (type(v))(ret)
Ejemplo n.º 22
0
    def test_convert(self):
        """test converting from dbus types to python types"""

        if sys.version_info[0] == 2:
            str_type = unicode
        else:
            str_type = str

        tests = ((dbus.Boolean(True), bool), (dbus.Byte(10), int),
                 (dbus.Int16(10), int), (dbus.Int32(10), int),
                 (dbus.Int64(10), int), (dbus.UInt16(10), int),
                 (dbus.UInt32(10), int), (dbus.UInt64(10), int),
                 (dbus.Double(10.01), float), (dbus.String('test'), str_type),
                 (dbus.ObjectPath('/path/to/stuff'),
                  str_type), (dbus.Signature('uu'),
                              str_type), (dbus.Dictionary({1: 1}),
                                          dict), (dbus.Struct((1, )), tuple))

        for test in tests:
            self.assertIsInstance(convert(test[0]), test[1])
Ejemplo n.º 23
0
                        "org.freedesktop.DBus.ObjectManager")
    objects = om.GetManagedObjects()
    for path, interfaces in objects.items():
        if "org.bluez.Device1" in interfaces:
            devices[path] = interfaces["org.bluez.Device1"]

    scan_filter = dict()

    if options.uuids:
        uuids = []
        uuid_list = options.uuids.split(',')
        for uuid in uuid_list:
            uuids.append(uuid)

        scan_filter.update({"UUIDs": uuids})

    if options.rssi:
        scan_filter.update({"RSSI": dbus.Int16(options.rssi)})

    if options.pathloss:
        scan_filter.update({"Pathloss": dbus.UInt16(options.pathloss)})

    if options.transport:
        scan_filter.update({"Transport": options.transport})

    adapter.SetDiscoveryFilter(scan_filter)
    adapter.StartDiscovery()

    mainloop = GObject.MainLoop()
    mainloop.run()
Ejemplo n.º 24
0
 def priority(self, value):
     self._prop_proxy.Set(self._iface_name, 'Priority', dbus.Int16(value))
Ejemplo n.º 25
0
 def signal(self, value):
     self._prop_proxy.Set(self._iface_name, 'SignalStrength',
                          dbus.Int16(value))
Ejemplo n.º 26
0
        1: "a",
        2: "b"
    },
    {
        "a": 1,
        "b": 2
    },  #{"a":(1,"B")},
    {
        1: 1.1,
        2: 2.2
    },
    [[1, 2, 3], [2, 3, 4]],
    [["a", "b"], ["c", "d"]],
    True,
    False,
    dbus.Int16(-10),
    dbus.UInt16(10),
    'SENTINEL',
    #([1,2,3],"c", 1.2, ["a","b","c"], {"a": (1,"v"), "b": (2,"d")})
]

NAME = "org.freedesktop.DBus.TestSuitePythonService"
IFACE = "org.freedesktop.DBus.TestSuiteInterface"
OBJECT = "/org/freedesktop/DBus/TestSuitePythonObject"


class TestDBusBindings(unittest.TestCase):
    def setUp(self):
        self.bus = dbus.SessionBus()
        self.remote_object = self.bus.get_object(NAME, OBJECT)
        self.remote_object_follow = self.bus.get_object(
if round(lat1, 4) != round(lat2, 4):
    print '\nTest Failed:' + str(round(lat1, 4)) + '!=' + str(round(lat2,
                                                                    4)) + '\n'

if round(lon1, 4) != round(lon2, 4):
    print '\nTest Failed:' + str(round(lon1, 4)) + '!=' + str(round(lon2,
                                                                    4)) + '\n'

if round(alt1, 4) != round(alt2, 4):
    print '\nTest Failed:' + str(round(alt1, 4)) + '!=' + str(round(alt2,
                                                                    4)) + '\n'

ret = MapViewerControl_interface.getMapViewScale(dbus.UInt32(mapviewerhandle))
print('Scale: ' + str(int(ret[0])))
print('Is min max: ' + str(int(ret[1])))

g_scale = int(ret[0])

time.sleep(0.25)

print 'Zoom in'
MapViewerControl_interface.setMapViewScaleByDelta(dbus.UInt32(sessionhandle),
                                                  dbus.UInt32(mapviewerhandle),
                                                  dbus.Int16(1))

#main loop
gobject.timeout_add(TIME_OUT, timeout)
loop = gobject.MainLoop()
loop.run()
Ejemplo n.º 28
0
 def set(self, var, vals):
     self.network.SetVariable(node, var, [dbus.Int16(x) for x in vals])
     return self
Ejemplo n.º 29
0
                "package" % pkg)

    if not _dbus_bindings.__file__.startswith(builddir):
        raise Exception("DBus modules (%s) are not being picked up from the "
                "package" % _dbus_bindings.__file__)

test_types_vals = [1, 12323231, 3.14159265, 99999999.99,
                 "dude", "123", "What is all the fuss about?", "*****@*****.**",
                 '\\u310c\\u310e\\u3114', '\\u0413\\u0414\\u0415',
                 '\\u2200software \\u2203crack', '\\xf4\\xe5\\xe8',
                 [1,2,3], ["how", "are", "you"], [1.23,2.3], [1], ["Hello"],
                 (1,2,3), (1,), (1,"2",3), ("2", "what"), ("you", 1.2),
                 {1:"a", 2:"b"}, {"a":1, "b":2}, #{"a":(1,"B")},
                 {1:1.1, 2:2.2}, [[1,2,3],[2,3,4]], [["a","b"],["c","d"]],
                 True, False,
                 dbus.Int16(-10), dbus.UInt16(10), 'SENTINEL',
                 #([1,2,3],"c", 1.2, ["a","b","c"], {"a": (1,"v"), "b": (2,"d")})
                 ]

NAME = "org.freedesktop.DBus.TestSuitePythonService"
IFACE = "org.freedesktop.DBus.TestSuiteInterface"
OBJECT = "/org/freedesktop/DBus/TestSuitePythonObject"

# A random string that we should not transmit on the bus as a result of
# the NO_REPLY flag
SHOULD_NOT_HAPPEN = u'a1c04a41-cf98-4923-8487-ddaeeb3f02d1'


class TestDBusBindings(unittest.TestCase):
    def setUp(self):
        self.bus = dbus.SessionBus()
Ejemplo n.º 30
0
 def py2_dbus_int16(self, prop):
     return dbus.Int16(prop)