Exemple #1
0
    def __init__(self, mpstate):
        self.param_received = {}
        self.paramchanged = {}
        self.event_queue = multiproc.Queue()
        self.event_queue_lock = multiproc.Lock()
        self.gui_event_queue = multiproc.Queue()
        self.gui_event_queue_lock = multiproc.Lock()

        self.close_window = multiproc.Semaphore()
        self.close_window.acquire()

        self.mpstate = mpstate
        self.mpstate.param_editor = self
        self.needs_unloading = False

        self.child = multiproc.Process(
            target=self.child_task,
            args=(self.event_queue, self.event_queue_lock,
                  self.gui_event_queue, self.gui_event_queue_lock,
                  self.close_window))
        self.child.start()

        self.event_thread = ParamEditorEventThread(self, self.event_queue,
                                                   self.event_queue_lock)
        self.event_thread.start()

        self.last_unload_check_time = time.time()
        self.unload_check_interval = 0.1  # seconds

        self.time_to_quit = False
        self.mavlink_message_queue = multiproc.Queue()
        self.mavlink_message_queue_handler = threading.Thread(
            target=self.mavlink_message_queue_handler)
        self.mavlink_message_queue_handler.start()
Exemple #2
0
    def __init__(self, mpstate):
        self.num_wps_expected = 0 #helps me to know if all my waypoints I'm expecting have arrived
        self.wps_received = {}

        self.event_queue = multiproc.Queue()
        self.event_queue_lock = multiproc.Lock()
        self.gui_event_queue = multiproc.Queue()
        self.gui_event_queue_lock = multiproc.Lock()

        self.close_window = multiproc.Semaphore()
        self.close_window.acquire()

        self.child = multiproc.Process(target=self.child_task,args=(self.event_queue,self.event_queue_lock,self.gui_event_queue,self.gui_event_queue_lock,self.close_window))
        self.child.start()

        self.event_thread = MissionEditorEventThread(self, self.event_queue, self.event_queue_lock)
        self.event_thread.start()

        self.mpstate = mpstate
        self.mpstate.miss_editor = self

        self.last_unload_check_time = time.time()
        self.unload_check_interval = 0.1 # seconds

        self.time_to_quit = False
        self.mavlink_message_queue = multiproc.Queue()
        self.mavlink_message_queue_handler = threading.Thread(target=self.mavlink_message_queue_handler)
        self.mavlink_message_queue_handler.start()
Exemple #3
0
        if platform.system() == "Windows":
            mm = mmap.mmap(filehandle.fileno(), data_len, None, mmap.ACCESS_READ)
        else:
            mm = mmap.mmap(filehandle.fileno(), data_len, mmap.MAP_PRIVATE, mmap.PROT_READ)

        # set the seek pointer
        offset = dict['_offset']
        mm.seek(offset)

        # update attributes
        self.__dict__.update(dict)

        # restore the mmap
        self._mm = mm  

mutex = multiproc.Lock()

class MPChildTask(object):
    '''Manage a MAVProxy child task
    
        MAVProxy child tasks typically require access to the dataflash
        or telemetry logs. For processes started using the `spawn`
        start method this requires the arguments to the child process
        to be pickleable, which is not the case for file handles and 
        memory mapped files. 

        This class provides two functions `wrap` and `unwrap` that are
        called before and after the parent spawns the child process,
        and in the child process itself before the public child task
        is called. Custom pickle functions and class wrappers / unwrappers
        should be placed in these two functions.