Пример #1
0
 def unloadModule(self, obj):
   if (obj == None):
     return
   try:
     self.userfn.callFunctions('shutdown')
     obj.shutdown()
     self.userfn.clearFunctions()
   except:
     pass
   try:
     for name in obj.getters:
       self.getters.pop(name)
       self.namespace.pop(name)
   except AttributeError:
     pass
   try:
     for name in obj.setters:
       self.setters.pop(name)
       self.namespace.pop(name)
   except AttributeError:
     pass
   try:
     obj.destroy()
   except AttributeError:
     pass # OK if modules have no cleanup code
   except:
     common.formerror()
Пример #2
0
 def unloadModule(self, obj):
     if (obj == None):
         return
     try:
         self.userfn.callFunctions('shutdown')
         obj.shutdown()
         self.userfn.clearFunctions()
     except:
         pass
     try:
         for name in obj.getters:
             self.getters.pop(name)
             self.namespace.pop(name)
     except AttributeError:
         pass
     try:
         for name in obj.setters:
             self.setters.pop(name)
             self.namespace.pop(name)
     except AttributeError:
         pass
     try:
         obj.destroy()
     except AttributeError:
         pass  # OK if modules have no cleanup code
     except:
         common.formerror()
Пример #3
0
def tk_update():
  """This function runs at the GUI_FPS frequency. It deals with alll asynchronous calls to the single-threaded GUI. It shouldn't be called directly, only added to the after queue once right before the mainloop statement in the Application object __init__"""
  start = time()
  size = tk_tasks.const_op(len)
  while size > 0:
    tk_tasks.lock.acquire()
    try:
      size = len(tk_tasks.val)
      if size:
        task = tk_tasks.val.popleft()
    finally:
      tk_tasks.lock.release()
      if size > 0:
#        try:
#          common.debug('> %s%s%s%s%s\n' % ('*Starting:',task.func_name,'from module',task.__module__,'*'))
#        except:
#          common.debug('> %s%s\n' % ('*starting:',task))
#        task()
#        try:
#          common.debug('> %s%s%s%s%s\n' % ('*Done:',task.func_name,'from module',task.__module__,'*'))
#        except:
#          common.debug('> %s%s\n' % ('*done:',task))
        try:
          task()
        except:
          print common.formerror()
      size -= 1
  # Not sure if I want to force these through unless I'm keeping the interface
  # held down myself.
  # tk.update()
  tk.after(int(GUI_FPMS_INVERSE), tk_update)
Пример #4
0
def tk_update():
    """This function runs at the GUI_FPS frequency. It deals with alll asynchronous calls to the single-threaded GUI. It shouldn't be called directly, only added to the after queue once right before the mainloop statement in the Application object __init__"""
    start = time()
    size = tk_tasks.const_op(len)
    while size > 0:
        tk_tasks.lock.acquire()
        try:
            size = len(tk_tasks.val)
            if size:
                task = tk_tasks.val.popleft()
        finally:
            tk_tasks.lock.release()
            if size > 0:
                #        try:
                #          common.debug('> %s%s%s%s%s\n' % ('*Starting:',task.func_name,'from module',task.__module__,'*'))
                #        except:
                #          common.debug('> %s%s\n' % ('*starting:',task))
                #        task()
                #        try:
                #          common.debug('> %s%s%s%s%s\n' % ('*Done:',task.func_name,'from module',task.__module__,'*'))
                #        except:
                #          common.debug('> %s%s\n' % ('*done:',task))
                try:
                    task()
                except:
                    print common.formerror()
            size -= 1
    # Not sure if I want to force these through unless I'm keeping the interface
    # held down myself.
    # tk.update()
    tk.after(int(GUI_FPMS_INVERSE), tk_update)
Пример #5
0
 def op(self, operation):
   self.lock.acquire()
   try:
     self.oldval = self.val
     self.val = operation(self.val)
   except:
     common.formerror()
   finally:
     self.lock.release()
   return self.oldval
Пример #6
0
 def const_op(self, operation):
   self.lock.acquire()
   try:
     val = operation(self.val)
   except:
     common.formerror()
   finally:
     self.lock.release()
   try:
     return val
   except:
     pass
Пример #7
0
  def step(self, dt):
    if self.output is not None:
      try:
        self.userfn.callFunctions('step')
        if self.sonarMonitor:
          self.sonarMonitor.update(self.output.storedsonars.get())
        if self.oscope: self.oscope.step()
        self.logstep()
        self.control.step(dt)
      except KeyError:
        common.formerror()
#        self.stopall()
      except:
        self.stopall()
Пример #8
0
  def step(self, dt):
    if self.output is not None:
      try:
        self.userfn.callFunctions('step')
        if self.sonarMonitor:
          self.sonarMonitor.update(self.output.storedsonars.get())
        if self.oscope: self.oscope.step()
        self.logstep()
        self.control.step(dt)
      except KeyError:
        common.formerror()
#        self.stopall()
      except:
        self.stopall()
Пример #9
0
 def logstep(self):
     if self.readfile:
         try:
             for pair in pickle.load(self.readfile):
                 self.cachedvalues[pair[0]].set(pair[1])
         except KeyError:
             app.alert("Log from an incompatible getter/setter interface")
             self.stopall()
         except EOFError:
             app.alert("Log Finished")
             self.stopall()
     else:
         for k in self.getters:
             try:
                 self.cachedvalues[k].set(self.getters[k]())
             except:
                 common.formerror()
     if self.writefile:
         pickle.dump([(k, self.cachedvalues[k].get())
                      for k in self.cachedvalues[k]], self.writefile)
Пример #10
0
 def logstep(self):
   if self.readfile:
     try:
       for pair in pickle.load(self.readfile):
         self.cachedvalues[pair[0]].set(pair[1])
     except KeyError:
       app.alert("Log from an incompatible getter/setter interface")
       self.stopall()
     except EOFError:
       app.alert("Log Finished")
       self.stopall()
   else:
     for k in self.getters:
       try:
         self.cachedvalues[k].set(self.getters[k]())
       except:
         common.formerror()
   if self.writefile:
     pickle.dump(map(lambda k: (k,self.cachedvalues[k].get()), 
                     self.cachedvalues[k]), 
                 self.writefile)
Пример #11
0
 def run(self):
   self.keepgoing = SharedVar(True)
   t = time()
   numCalls = 0
   startTime  = time()
   while self.keepgoing.get():
    dt = time()-t
    origt = t
    if dt < self.minstep:
      sleep(self.minstep-dt)
      t = time()
      try:
        numCalls += 1
        self.function(self.minstep)
      except:
        common.formerror()
    else:
      try:
        t = time()
        numCalls += 1
        self.function(dt)
      except:
        common.formerror()
Пример #12
0
 def destroy(self):
     try:
         self.braindestroy()
     except:
         formerror()
Пример #13
0
 def destroy(self):
   try:
     self.braindestroy()
   except:
     formerror()