def test_adjacent_is_set(self): main_area = Area('main', '') adjacent_area = Area('North Area', '') main_area.addAdjacent(adjacent_area) self.assertEqual(main_area.adjacents.__len__(), 1) self.assertEqual(main_area.adjacents.pop(), adjacent_area) self.assertEqual(adjacent_area.adjacents.__len__(), 1) self.assertEqual(adjacent_area.adjacents.pop(), main_area)
def __init__(self, filesSpecPool = None, hostname = None, login = None, sshPrivateKeyPath = None, password = None): Area.__init__(self, hostname = hostname, login = login, sshPrivateKeyPath = sshPrivateKeyPath, password = password) self.__filesSpecPool = filesSpecPool
def add_area(self, name=None, level=None, difficulty=None, description=None): new_area = Area(name=name, level=level, difficulty=difficulty, description=description) self.areas.append(new_area) return new_area
def main(): address_old = 'localhost' port_old = 27017 address_new = '123.56.65.17' port_new = 27017 Area.insert_area(address_old, port_old, address_new, port_new) WeatherTranslation.insert_weather_translation(address_new, port_new) Policy.insert_policy(address_new, port_new) # RecommendHistory.insert_recommend_history(address_new, port_new) PolicyMap.insert_policy_map(address_new, port_new) News.insert_news(address_new, port_new) print("OK")
def __init__(self): self.message = Message() self.game_on = True self.client = mqtt.Client() print("Server created") self.handle_methods() self.client.connect("127.0.0.1") self.subscribe_on_topics() self.state = GameState.waiting print "--- Game waiting for players ---" self.id_to_sub = {} self.area = Area() self.vis = Visualiser(self.area) # thread logic thread = Thread(target=self.game_loop, args=()) thread.start() self.client.loop_forever()
def __init__(self, handle): """Initialize the OficinaActivity object. @param self @param handle """ activity.Activity.__init__(self, handle) self.max_participants = 1 logging.debug('Starting Paint activity (Oficina)') self.fixed = Gtk.Fixed() self._width = Gdk.Screen.width() self._height = Gdk.Screen.height() self.fixed.show() self.fixed.modify_bg(Gtk.StateType.NORMAL, style.COLOR_WHITE.get_gdk_color()) self.textview = Gtk.TextView() self.textview.set_events(Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.POINTER_MOTION_HINT_MASK | Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK | Gdk.EventMask.BUTTON_MOTION_MASK | Gdk.EventMask.TOUCH_MASK) self.textview.connect('event', self.__textview_event_cb) self.textview.connect("motion_notify_event", self.__textview_mouse_move_cb) self.fixed.put(self.textview, 0, 0) # These attributes are used in other classes, so they should be public self.area = Area(self) self.area.show() self.fixed.put(self.area, 0, 0) self.board = BulletinBoard(self) self.fixed.put(self.board.fixed, 0, 0) self._sw = Gtk.ScrolledWindow() self._sw.set_kinetic_scrolling(False) self._sw.show() self._sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.set_canvas(self._sw) self.toolset_intialize_from_journal() toolbar_box = DrawToolbarBox(self) toolbar_box.toolbar.insert(self.board.button, -1) #toolbar_box.toolbar.insert(self.board.share_button, -1) #toolbar_box.toolbar.insert(self.board.button, -1) self.board.button.show() toolbar_box.show_all() #self.board.box_button.hide() #self.board.share_button.hide() self.connect("key_press_event", self.key_press) # setup self.area only once def map_cp(widget): def size_allocate_cb(widget, allocation): widget.disconnect(self._setup_handle) self.area.setup(allocation.width, allocation.height) self.center_area() self.canvas.add_with_viewport(self.fixed) # to remove the border, we need set the shadowtype # in the viewport child of the scrolledwindow self.canvas.get_children()[0].set_shadow_type(Gtk.ShadowType.NONE) self.disconnect(self._setup_handle) self._setup_handle = self._sw.connect('size_allocate', size_allocate_cb) self._setup_handle = self.connect('map', map_cp) # Handle screen rotation Gdk.Screen.get_default().connect('size-changed', self._configure_cb)
class OficinaActivity(activity.Activity): def __init__(self, handle): """Initialize the OficinaActivity object. @param self @param handle """ activity.Activity.__init__(self, handle) self.max_participants = 1 logging.debug('Starting Paint activity (Oficina)') self.fixed = Gtk.Fixed() self._width = Gdk.Screen.width() self._height = Gdk.Screen.height() self.fixed.show() self.fixed.modify_bg(Gtk.StateType.NORMAL, style.COLOR_WHITE.get_gdk_color()) self.textview = Gtk.TextView() self.textview.set_events(Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.POINTER_MOTION_HINT_MASK | Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK | Gdk.EventMask.BUTTON_MOTION_MASK | Gdk.EventMask.TOUCH_MASK) self.textview.connect('event', self.__textview_event_cb) self.textview.connect("motion_notify_event", self.__textview_mouse_move_cb) self.fixed.put(self.textview, 0, 0) # These attributes are used in other classes, so they should be public self.area = Area(self) self.area.show() self.fixed.put(self.area, 0, 0) self.board = BulletinBoard(self) self.fixed.put(self.board.fixed, 0, 0) self._sw = Gtk.ScrolledWindow() self._sw.set_kinetic_scrolling(False) self._sw.show() self._sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.set_canvas(self._sw) self.toolset_intialize_from_journal() toolbar_box = DrawToolbarBox(self) toolbar_box.toolbar.insert(self.board.button, -1) #toolbar_box.toolbar.insert(self.board.share_button, -1) #toolbar_box.toolbar.insert(self.board.button, -1) self.board.button.show() toolbar_box.show_all() #self.board.box_button.hide() #self.board.share_button.hide() self.connect("key_press_event", self.key_press) # setup self.area only once def map_cp(widget): def size_allocate_cb(widget, allocation): widget.disconnect(self._setup_handle) self.area.setup(allocation.width, allocation.height) self.center_area() self.canvas.add_with_viewport(self.fixed) # to remove the border, we need set the shadowtype # in the viewport child of the scrolledwindow self.canvas.get_children()[0].set_shadow_type(Gtk.ShadowType.NONE) self.disconnect(self._setup_handle) self._setup_handle = self._sw.connect('size_allocate', size_allocate_cb) self._setup_handle = self.connect('map', map_cp) # Handle screen rotation Gdk.Screen.get_default().connect('size-changed', self._configure_cb) def _configure_cb(self, event): ''' Rotate the drawing after a screen rotation ''' width = Gdk.Screen.width() height = Gdk.Screen.height() if (self._width > self._height) != (width > height): GObject.timeout_add(100, self.area.rotate_right, self.area) self._width = width self._height = height def key_press(self, widget, event): print event.keyval if event.keyval == 45: self.area.change_line_size(-1) if event.keyval == 43: self.area.change_line_size(1) def read_file(self, file_path): '''Read file from Sugar Journal.''' logging.debug('reading file %s, mimetype: %s, title: %s', file_path, self.metadata['mime_type'], self.metadata['title']) self.area.load_from_file(file_path) def size_allocate_cb(widget, allocation): logging.error('read file size allocate') self.fixed.disconnect(self._setup_handle) width = self.area.drawing_canvas_data.get_width() height = self.area.drawing_canvas_data.get_height() if self.area.drawing_canvas is None: self.area.setup(width, height) # The scrolled window is confused with a image of the same size # of the canvas when the toolbars popup and the scrolls # keep visible. if height > allocation.height or width > allocation.width: self.canvas.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) else: self.canvas.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.center_area() self.canvas.add_with_viewport(self.fixed) # to remove the border, we need set the shadowtype # in the viewport child of the scrolledwindow self.canvas.get_children()[0].set_shadow_type(Gtk.ShadowType.NONE) self.canvas.get_children()[0].set_border_width(0) self.disconnect(self._setup_handle) self._setup_handle = self.fixed.connect('size_allocate', size_allocate_cb) # disassociate with journal entry to avoid overwrite (SL #1771) if self.metadata['mime_type'] != "image/png": self._jobject.object_id = None last_point_posi = self.metadata['title'].rfind('.') if last_point_posi > -1: title = self.metadata['title'][0:last_point_posi] + '.png' self.metadata['title'] = title logging.error('title: %s', self.metadata['title']) def write_file(self, file_path): '''Save file on Sugar Journal. ''' width, height = self.area.get_size_request() logging.debug('writting %s w=%s h=%s' % (file_path, width, height)) if self.area.text_in_progress: self.area.d.text(self.area, 0, 0) self.area.getout() self.area.drawing_canvas.write_to_png(file_path) self.metadata['mime_type'] = 'image/png' self.metadata['state'] = json.dumps(self.area.tool) logging.debug('Wrote metadata[\'state\']: %s', self.metadata['state']) def _get_area_displacement(self): """Return the point to use as top left corner in order to move the drawing area and center it on the canvas. """ canvas_width = self.canvas.get_allocation().width canvas_height = self.canvas.get_allocation().height area_width, area_height = self.area.get_size_request() # Avoid 'x' and 'y' to be outside the screen x = max(0, (canvas_width - area_width) / 2) y = max(0, (canvas_height - area_height) / 2) return x, y def center_area(self): x, y = self._get_area_displacement() self.fixed.move(self.area, x, y) def move_textview(self, dx, dy): x, y = self._get_area_displacement() self.fixed.move(self.textview, x + dx, y + dy) def toolset_intialize_from_journal(self): try: self.area.tool = json.loads(self.metadata['state']) logging.debug('self.area.tool %s', self.area.tool) except Exception as e: logging.error("exception %s", e) def __textview_event_cb(self, widget, event): if event.type in (Gdk.EventType.TOUCH_BEGIN, Gdk.EventType.TOUCH_CANCEL, Gdk.EventType.TOUCH_END, Gdk.EventType.BUTTON_PRESS, Gdk.EventType.BUTTON_RELEASE): x = int(event.get_coords()[1]) y = int(event.get_coords()[2]) if event.type in (Gdk.EventType.TOUCH_BEGIN, Gdk.EventType.BUTTON_PRESS): self._initial_textview_touch_x = x self._initial_textview_touch_y = y elif event.type in (Gdk.EventType.TOUCH_END, Gdk.EventType.BUTTON_RELEASE): # be sure the textview don't have a selection pending # and put the cursor at the end of the text text_buf = self.textview.get_buffer() end_text_iter = text_buf.get_end_iter() text_buf.select_range(end_text_iter, end_text_iter) def __textview_mouse_move_cb(self, widget, event): x = event.x y = event.y if event.get_state() & Gdk.ModifierType.BUTTON1_MASK: dx = x - self._initial_textview_touch_x dy = y - self._initial_textview_touch_y tv_alloc = self.textview.get_allocation() self.move_textview(tv_alloc.x + dx, tv_alloc.y + dy)
def listar(): session.rows = [] session.areas = Area.find({}).as_list() return dict(areas=session.areas)
def __init__(self): super(MainWindow, self).__init__() # Abrimos una conexion a la base de datos co = Conexion() # instanciamos a la BD arr_con = co.obtenerConexion() # traemos el arreglo de las credenciales ####### INSTANCIAMOS LAS CLASES DE LA INTERFAZ ####### # instanciamos los botones self.bot = Botones(arr_con) self.pac = Paciente(arr_con) self.ort = Ortodoncista(arr_con) self.are = Area(arr_con) ###################################################### self.zoom = 0.0 self.contenedorImagen = QtGui.QLabel() self.contenedorImagen.setBackgroundRole(QtGui.QPalette.Base) self.contenedorImagen.setSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Ignored) self.contenedorImagen.setScaledContents(True) self.desplazamientoArea = QtGui.QScrollArea() self.desplazamientoArea.setBackgroundRole(QtGui.QPalette.Dark) self.desplazamientoArea.setWidget(self.contenedorImagen) lblSna = QtGui.QLabel('SNA:') self.txtSna = QtGui.QLabel('ANB:') lblSnb = QtGui.QLabel('SNB:') self.txtSnb = QtGui.QLabel('SND:') lblAnb = QtGui.QLabel('82') self.txtAnb = QtGui.QLabel('82') lblSnd = QtGui.QLabel('82') self.txtSnd = QtGui.QLabel('82') # CONTENEDORES ######################## resultadosLayout = QtGui.QVBoxLayout() resultadosLayout.addWidget(lblSna) resultadosLayout.addWidget(self.txtSna) resultadosLayout.addWidget(lblSnb) resultadosLayout.addWidget(self.txtSnb) resultadosLayout2 = QtGui.QVBoxLayout() resultadosLayout2.addWidget(lblAnb) resultadosLayout2.addWidget(self.txtAnb) resultadosLayout2.addWidget(lblSnd) resultadosLayout2.addWidget(self.txtSnd) unionResultados = QtGui.QHBoxLayout() unionResultados.addLayout(resultadosLayout) unionResultados.addLayout(resultadosLayout2) self.resultadosGroup = QtGui.QGroupBox('Resultados') self.resultadosGroup.setLayout(unionResultados) self.__estadoAgregar = True self.resultadosGroup.setVisible(self.__estadoAgregar) # self.scene = AreaDibujo() # self.scene.setSceneRect(QtCore.QRectF(0, 0, 300, 300)) # # self.scene.addWidget(self.desplazamientoArea) # # self.scene.setBackgroundBrush(QtCore.Qt.blue) # self.view = QtGui.QGraphicsView(self.scene) # self.view.setRenderHint(QtGui.QPainter.Antialiasing) self.crearAtajos() self.crearMenus() self.widgetPrincipal() self.conexionesEventos() self.setCentralWidget(self.pestania) self.setWindowTitle('Mediciones dentales')
class MainWindow(QtGui.QMainWindow): def __init__(self): super(MainWindow, self).__init__() # Abrimos una conexion a la base de datos co = Conexion() # instanciamos a la BD arr_con = co.obtenerConexion() # traemos el arreglo de las credenciales ####### INSTANCIAMOS LAS CLASES DE LA INTERFAZ ####### # instanciamos los botones self.bot = Botones(arr_con) self.pac = Paciente(arr_con) self.ort = Ortodoncista(arr_con) self.are = Area(arr_con) ###################################################### self.zoom = 0.0 self.contenedorImagen = QtGui.QLabel() self.contenedorImagen.setBackgroundRole(QtGui.QPalette.Base) self.contenedorImagen.setSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Ignored) self.contenedorImagen.setScaledContents(True) self.desplazamientoArea = QtGui.QScrollArea() self.desplazamientoArea.setBackgroundRole(QtGui.QPalette.Dark) self.desplazamientoArea.setWidget(self.contenedorImagen) lblSna = QtGui.QLabel('SNA:') self.txtSna = QtGui.QLabel('ANB:') lblSnb = QtGui.QLabel('SNB:') self.txtSnb = QtGui.QLabel('SND:') lblAnb = QtGui.QLabel('82') self.txtAnb = QtGui.QLabel('82') lblSnd = QtGui.QLabel('82') self.txtSnd = QtGui.QLabel('82') # CONTENEDORES ######################## resultadosLayout = QtGui.QVBoxLayout() resultadosLayout.addWidget(lblSna) resultadosLayout.addWidget(self.txtSna) resultadosLayout.addWidget(lblSnb) resultadosLayout.addWidget(self.txtSnb) resultadosLayout2 = QtGui.QVBoxLayout() resultadosLayout2.addWidget(lblAnb) resultadosLayout2.addWidget(self.txtAnb) resultadosLayout2.addWidget(lblSnd) resultadosLayout2.addWidget(self.txtSnd) unionResultados = QtGui.QHBoxLayout() unionResultados.addLayout(resultadosLayout) unionResultados.addLayout(resultadosLayout2) self.resultadosGroup = QtGui.QGroupBox('Resultados') self.resultadosGroup.setLayout(unionResultados) self.__estadoAgregar = True self.resultadosGroup.setVisible(self.__estadoAgregar) # self.scene = AreaDibujo() # self.scene.setSceneRect(QtCore.QRectF(0, 0, 300, 300)) # # self.scene.addWidget(self.desplazamientoArea) # # self.scene.setBackgroundBrush(QtCore.Qt.blue) # self.view = QtGui.QGraphicsView(self.scene) # self.view.setRenderHint(QtGui.QPainter.Antialiasing) self.crearAtajos() self.crearMenus() self.widgetPrincipal() self.conexionesEventos() self.setCentralWidget(self.pestania) self.setWindowTitle('Mediciones dentales') def abrir(self): self.bot.abrir() self.cargar() def actualizarCambios(self): self.zoomMasAct.setEnabled(not self.tamanoVentanaAct.isChecked()) self.zoomMenosAct.setEnabled(not self.tamanoVentanaAct.isChecked()) self.tamanoNormalAct.setEnabled(not self.tamanoVentanaAct.isChecked()) def ajustarDesplazamientoBarra(self, barra, valor): barra.setValue(int(valor * barra.value() + ((valor - 1) * barra.pageStep()/2))) def cambioTab(self, indice): if indice==0: # diagnostico self.bot.actualizar() elif indice==1: # paciente self.pac.actualizar() elif indice==2: # ortodoncista self.ort.actualizar() elif indice==3: # area self.are.actualizar() def cargar(self): if self.bot.imagen!=None: print 'Ruta:', self.bot.rutaImagen ### # Se comentarizaron estas lineas porque tira error ### # self.scene.addWidget(QtGui.QPixmap.fromImage(self.bot.imagen)) self.contenedorImagen.setPixmap(QtGui.QPixmap.fromImage(self.bot.imagen)) self.zoom = 1.0 self.tamanoVentanaAct.setEnabled(True) self.actualizarCambios() if not self.tamanoVentanaAct.isChecked(): self.contenedorImagen.adjustSize() ##### clase: Botones #### def conexionesEventos(self): self.bot.btnCargarImagen.clicked[bool].connect(self.cargar) self.pestania.currentChanged.connect(self.cambioTab) def crearAtajos(self): self.abrirAct = QtGui.QAction("&Abrir...", self, shortcut="Ctrl+O", triggered=self.abrir) self.salirAct = QtGui.QAction("&Salir de TESIS", self, shortcut="Ctrl+Q", triggered=self.close) self.zoomMasAct = QtGui.QAction("&Aumentar zoom (25%)", self, shortcut="Ctrl++", enabled=False, triggered=self.zoomMas) self.zoomMenosAct = QtGui.QAction("&Disminuir zoom (25%)", self, shortcut="Ctrl+-", enabled=False, triggered=self.zoomMenos) self.tamanoNormalAct = QtGui.QAction("&Tamano normal", self, shortcut="Ctrl+S", enabled=False, triggered=self.tamanoNormal) self.tamanoVentanaAct = QtGui.QAction("&Ancho de ventana", self, enabled=False, checkable=True, shortcut="Ctrl+F", triggered=self.tamanoVentana) def crearMenus(self): self.menuArchivo = QtGui.QMenu("&Archivo", self) self.menuArchivo.addAction(self.abrirAct) self.menuArchivo.addSeparator() self.menuArchivo.addAction(self.salirAct) self.menuVisualizacion = QtGui.QMenu("&Visualizacion", self) self.menuVisualizacion.addAction(self.zoomMasAct) self.menuVisualizacion.addAction(self.zoomMenosAct) self.menuVisualizacion.addAction(self.tamanoNormalAct) self.menuVisualizacion.addSeparator() self.menuVisualizacion.addAction(self.tamanoVentanaAct) self.menuBar().addMenu(self.menuArchivo) self.menuBar().addMenu(self.menuVisualizacion) def tamanoNormal(self): self.contenedorImagen.adjustSize() self.zoom = 1.0 def tamanoVentana(self): tamanoVentana = self.tamanoVentanaAct.isChecked() self.desplazamientoArea.setWidgetResizable(tamanoVentana) if not tamanoVentana: self.tamanoNormal() self.actualizarCambios() def widgetPrincipal(self): self.pestania = QtGui.QTabWidget() divisor = QtGui.QSplitter(QtCore.Qt.Horizontal) divisor.addWidget(self.bot.wig) divisor.addWidget(self.desplazamientoArea) divisor.addWidget(self.resultadosGroup) # divisor.setSizes([200, 500]) # divisor.addWidget(self.view) divisor2 = QtGui.QSplitter(QtCore.Qt.Horizontal) divisor2.addWidget(self.pac.wig) divisor3 = QtGui.QSplitter(QtCore.Qt.Horizontal) divisor3.addWidget(self.ort.wig) divisor4 = QtGui.QSplitter(QtCore.Qt.Horizontal) divisor4.addWidget(self.are.wig) self.pestania.addTab(divisor, 'Diagnostico') self.pestania.addTab(divisor2, 'Pacientes') self.pestania.addTab(divisor3, 'Ortodoncistas') self.pestania.addTab(divisor4, 'Areas') def zoomImagen(self, valor): self.zoom *= valor self.contenedorImagen.resize(self.zoom * self.contenedorImagen.pixmap().size()) self.ajustarDesplazamientoBarra(self.desplazamientoArea.horizontalScrollBar(), valor) self.ajustarDesplazamientoBarra(self.desplazamientoArea.verticalScrollBar(), valor) self.zoomMasAct.setEnabled(self.zoom < 3.0) self.zoomMenosAct.setEnabled(self.zoom > 0.333) def zoomMas(self): self.zoomImagen(1.25) def zoomMenos(self): self.zoomImagen(0.8)
################### MAIN #################### # some initialization procedures pygame.init() bot = Bot() # initializes the screen, window name and the key repeater # if the key is held the key is repeated size = width, height = 300, 440 screen = pygame.display.set_mode((width, height)) pygame.display.set_caption('TETRIS') pygame.key.set_repeat(75) while 1: # build a matrix for from the width and height area = Area(width - 100, height) # initializes the shape queue (first number is current shape, second is upcoming) # randomizes the shape color shape_queue = [] for i in range(5): shape_queue.append(randint(0,6)) shape_color=(randint(1,255), randint(1,255), randint(1,255)) # creates a new shape: 0 is the shape id shape = Shape(shape_color, shape_queue[0]) # init Heads up Display hud = Hud(width, height) gameOver=Gameover(width,height,area.score)
def main(): address_old = 'localhost' port_old = 27017 address_new = '192.168.6.254' port_new = 37017 print("convert label type data") LabelType.insert_label_type(address_new, port_new) print("convert area data") Area.insert_area(address_old, port_old, address_new, port_new) print("convert label data") Label.convert_label(address_old, port_old, address_new, port_new) # 城市表 依赖新导入的Label表,需保证City前导入Label print("convert city data") City.convert_city(address_old, port_old, address_new, port_new) print("convert weather data") Weather.convert_weather(address_old, port_old, address_new, port_new, Weather.collection_old, Weather.collection_new, Weather.params_map) # 特别注意 weather_history 表依赖于当前的 weather 表 print("create weather_history data") WeatherHistory.create_weather_history(address_new, port_new, address_new, port_new, WeatherHistory.collection_old, WeatherHistory.collection_new, WeatherHistory.params_map) print("convert pgc data") Pgc.convert_pgc(address_old, port_old, address_new, port_new) print("convert label data") Label.convert_label(address_old, port_old, address_new, port_new) print("convert attraction data") Attraction.convert_attraction(address_old, port_old, address_new, port_new, Attraction.collection_old, Attraction.collection_new, Attraction.params_map) print("convert restaurant data") Restaurant.convert_restaurant(address_old, port_old, address_new, port_new, Restaurant.collection_old, Restaurant.collection_new, Restaurant.params_map) print("convert shopping data") Shopping.convert_shopping(address_old, port_old, address_new, port_new, Shopping.collection_old, Shopping.collection_new, Shopping.params_map) print("convert activity data") Activity.convert_activity(address_old, port_old, address_new, port_new, Activity.collection_old, Activity.collection_new, Activity.params_map) print("convert recommendBynamic data") # RecommendDynamic.convert_recommendDynamic(address_old, port_old, address_new, port_new,RecommendDynamic.collection_old, # RecommendDynamic.collection_new, RecommendDynamic.params_map) print("convert plan data") Plan.convert_plan(address_old, port_old, address_new, port_new, Plan.collection_old, Plan.collection_new, Plan.params_map) print("convert brand data") Brand.convert_brand(address_old, port_old, address_new, port_new, Brand.collection_old, Brand.collection_new, Brand.params_map) print("OK")
def explore(room): # Move to a new area, returns area object # initialize room.current_area if it does not exsist if not room.current_area: room.current_area = Area() # Test output print "Exploring (moving to a new location) ..." # Beep to indicate begining of explore step buzzer = Buzzer() buzzer.play(5) # Create new area and move objects new_area = Area() move = Move() # Make sure move is set as a real move (performed by robot) move.type = "Real" # Link it to the previous object new_area.previous.append(room.current_area.name) # Initial position set to position of previous area move.initial_pos = room.current_area.pos # Vector of movement used move = get_move_vector(move) # Break down movement vector into motion primitives that robot can execute move.getMotionPlan() for (direction, amount) in move.primitives: print "Moving " + str(direction) + " " + str(amount) # moveBot(direction, amount, params.p['MOTOR_PWR']) # Get final position by summing initial position and delta move.final_pos = [init + delt for init, delt in zip(move.initial_pos, move.delta)] # TODO: put a kalman filter on the movement. Use camera and sonar as # truth? Not sure here # # Test print # print "Describing move in explore function" move.describe() # Update location of new area to final position of move new_area.pos = move.final_pos # Add move to new area's dictionary of moves new_area.moves_performed[room.current_area.name] = move # Redirect current area to this new_area room.current_area = new_area # Localize bot in new area # new_area.localize # # Test print # print "Describing new_area in explore function" # new_area.describe() # Append new_area to room room.areas.append(new_area) # Return updated room object return room