コード例 #1
0
 def __init__(self, arm_home_value=0, arm_in_value=0, arm_out_value=0,
              actuator_home_value=30, baudrate=115200, actuator_up_value=20,
              actuator_clear_value=200, gado_port=None, arm_degrees_per_s=36,
              arm_time_overhead=0.5,**kargs):
     
     #Instantiate the logger
     loggerObj = Logger(__name__)
     self.logger = loggerObj.getLoggerInstance()
     
     #Grab settings
     self.arm_home_value = int(arm_home_value) if arm_home_value else 0
     self.arm_in_value = int(arm_in_value) if arm_in_value else 0
     self.arm_out_value = int(arm_out_value) if arm_out_value else 0
     
     self.actuator_home_value = int(actuator_home_value) if actuator_home_value else 20
     self.actuator_clear_value = int(actuator_clear_value) if actuator_clear_value else 200
     self.actuator_up_value = int(actuator_up_value) if actuator_up_value else 20
     
     self.baudrate = baudrate
     self.serialConnection = None
     
     self.current_arm_value = int(arm_home_value) if arm_home_value else 0
     self.current_actuator_value = int(actuator_up_value) if actuator_up_value else 20
     
     self.arm_time_overhead = arm_time_overhead
     self.arm_degrees_per_s = arm_degrees_per_s
コード例 #2
0
 def __init__(self, q_in, q_out):
     
     #Instantiate the logger
     loggerObj = Logger(self.__class__.__name__)
     self.logger = loggerObj.getLoggerInstance()
     
     # Load in the system-to-gui queue and the gui-to-system queue
     self.q_in = q_in
     self.q_out = q_out
     
     #Start the Gui's personal queue
     self.gui_q = Queue()
     self.t1 = GuiListener(q_in, self.gui_q, self)
     
     #Instantiate the root frame of the Gui
     self.root = Tk()
     
     #Set the title
     self.root.title("Gado Control Software")
     
     #Whenever the red x on the window is clicked, destroy the entire Gui
     self.root.protocol('WM_DELETE_WINDOW', self.destroy)
     
     #Initialize the master frame
     Frame.__init__(self, self.root)
コード例 #3
0
 def __init__(self, q, gui_q, gui):
     
     #Instantiate the logger
     loggerObj = Logger(self.__class__.__name__)
     self.logger = loggerObj.getLoggerInstance()
     
     self.gui_q = gui_q
     self.q = q
     self.gui = gui
     Thread.__init__(self)
コード例 #4
0
ファイル: Wizard.py プロジェクト: agusti/Project-Gado
 def __init__(self, q_in, q_out, message, args, callback):
     
     #Instantiate the logger
     loggerObj = Logger(self.__class__.__name__)
     self.logger = loggerObj.getLoggerInstance()
     
     self.q_in = q_in
     self.q_out = q_out
     self.message = message
     self.args = args
     self.callback = callback
     Thread.__init__(self)
コード例 #5
0
ファイル: main.py プロジェクト: agusti/Project-Gado
 def __init__(self, q_in, q_out):
     #Instantiate logger object
     loggerObj = Logger(self.__class__.__name__)
     self.logger = loggerObj.getLoggerInstance()
     
     #Load in queues
     self.q_in = q_in
     self.q_out = q_out
     
     self.logger.info("creating the gui")
     self.gui = GadoGui(q_in, q_out)
     Thread.__init__(self)
コード例 #6
0
ファイル: Webcam.py プロジェクト: ProjectGado/Project-Gado
 def __init__(self, webcam_name=None, webcam_id=None, **kargs):
     
     #Instantiate the logger
     loggerObj = Logger(__name__)
     self.logger = loggerObj.getLoggerInstance()
     
     self.device = None
     self.logger.debug('__init__ called with webcam_name=%s and webcam_id=%s' % (webcam_name, webcam_id))
     if webcam_name is not None:
         self.connect(device_name=webcam_name)
     elif webcam_id is not None:
         self.connect(device_number=webcam_id)
コード例 #7
0
 def __init__(self, manager, q_out, q_in, q_gui, new_set=None, delete_set=None):
     
     #Instantiate the logger
     loggerObj = Logger(__name__)
     self.logger = loggerObj.getLoggerInstance()
     
     self.manager = manager
     self.q_out = q_out
     self.q_in = q_in
     self.q_gui = q_gui
     self.new_set = new_set
     self.delete_set = delete_set
     Thread.__init__(self)
コード例 #8
0
ファイル: Webcam.py プロジェクト: agusti/Project-Gado
    def __init__(self, webcam_name=None, webcam_id=None, **kargs):

        #Instantiate the logger
        loggerObj = Logger(__name__)
        self.logger = loggerObj.getLoggerInstance()

        self.device = None
        self.logger.debug(
            '__init__ called with webcam_name=%s and webcam_id=%s' %
            (webcam_name, webcam_id))
        if webcam_name is not None:
            self.connect(device_name=webcam_name)
        elif webcam_id is not None:
            self.connect(device_number=webcam_id)
コード例 #9
0
 def __init__(self, q_in, q_out, recovered=False):
     
     #Instantiate the logger
     loggerObj = Logger(self.__class__.__name__)
     self.logger = loggerObj.getLoggerInstance()
     
     self.logger.info("Initializing the Gado System...")
     
     #Load up both queues
     self.q_in = q_in
     self.q_out = q_out
     
     #Grab the settings from gado.conf (If it exists) and place them into
     #a local object so that they can be used here
     self.load_settings()
     
     #If there are no settings (because there is no gado.conf)
     if not self.s:
         #Grab the default settings and load them into a newly created gado.conf
         export_settings(**default_settings())
         
         #Load those default settings to a local object
         self.load_settings()
         
         #Because there is no gado.conf, we're going to need to launch
         #the configuration wizard so that the user can enter their
         #personal settings
         add_to_queue(self.q_out, messages.LAUNCH_WIZARD)
         
         print 'gado_sys\tasked to launch the wizard'
     
     #Even if we do have a gado.conf file, the wizard has never been run
     #so it needs to get launched for the user's personal preferences
     elif 'wizard_run' in self.s and int(self.s['wizard_run']) == 0:
         add_to_queue(self.q_out, messages.LAUNCH_WIZARD)
         print 'gado_sys\tasked to launch the wizard2'
     
     #If this is the first time the logic thread has been run,
     #tell the gui thread that the system is ready for interactions
     else:
         print 'gado_sys\tnot asked for a wizard'
         if not recovered: add_to_queue(self.q_out, messages.READY)
     
     #Get an instance of the database and the database interface
     self.db = DBFactory(**self.s).get_db()
     self.dbi = DBInterface(self.db)
     
     #Init local vars
     self.selected_set = None
     self.started = False
コード例 #10
0
ファイル: main.py プロジェクト: agusti/Project-Gado
 def __init__(self, q_in, q_out, recovered=False):
     #Instantiate logger object
     loggerObj = Logger(self.__class__.__name__)
     self.logger = loggerObj.getLoggerInstance()
     
     #Load in the queues
     self.q_in = q_in
     self.q_out = q_out
     
     self.logger.info("intializing GadoSystem")
     
     self.gado_sys = GadoSystem(q_in, q_out, recovered)
     self.logger.debug("completed intializing GadoSystem")
     
     Thread.__init__(self)
コード例 #11
0
 def __init__(self, **kwargs):
     
     pythoncom.CoInitialize()
     
     #Instantiate the logger
     loggerObj = Logger(__name__)
     self.logger = loggerObj.getLoggerInstance()
     
     #Init all of the scanner objects
     self.deviceManager = win32com.client.Dispatch(DEVICE_MANAGER)
     self.wiaObject = win32com.client.Dispatch(COMMON_DIALOG)
     
     self.device = None
     self.scanDpi = DEFAULT_DPI
     self.scannerName = None
     
     #Try and push the settings from the conf file
     try:
         self.scanDpi = kwargs['image_back_dpi']
         self.scannerName = kwargs['scanner_name']
     except:
         self.logger.exception("Error while instantiating scanner with passed settings...\nScanner\tError: %s" % (sys.exc_info()[0]))
コード例 #12
0
def check_for_barcode(image_path, code='project gado'):
    loggerObj = Logger('check_for_barcode')
    logger = loggerObj.getLoggerInstance()

    args = ['lib\zbar\zbarimg.exe', '-q', image_path]
    cmd = ' '.join(args)
    logger.debug('checking for barcode "%s" with cmd: "%s"' % (code, cmd))
    print "CMD: %s" % (cmd)
    #Test code to make this runnable with py2exe
    if hasattr(sys.stderr, 'fileno'):
        procStdErr = sys.stderr
    elif hasattr(sys.stderr, '_file') and hasattr(sys.stderr._file, 'fileno'):
        proceStdErr = sys.stderr._file
    else:
        procStdErrPath = 'nul'
        procStdErr = file(procStdErrPath, 'a')

    proc = Popen(cmd, stdout=PIPE, stderr=procStdErr, shell=True)
    output, errors = proc.communicate()
    output = str(output)
    logger.debug('output: "%s"' % output)
    print 'functions\tcheck_for_barcode received: %s' % output
    print "barcode was %sfound" % ('' if output.find(code) >= 0 else 'not ')
    return (len(output) > 0) and (output.find(code) >= 0)
コード例 #13
0
ファイル: functions.py プロジェクト: ProjectGado/Project-Gado
def check_for_barcode(image_path, code='project gado'):
    loggerObj = Logger('check_for_barcode')
    logger = loggerObj.getLoggerInstance()
    
    args = ['lib\zbar\zbarimg.exe', '-q', image_path]
    cmd = ' '.join(args)
    logger.debug('checking for barcode "%s" with cmd: "%s"' % (code, cmd))
    print "CMD: %s" % (cmd)
    #Test code to make this runnable with py2exe
    if hasattr(sys.stderr, 'fileno'):
        procStdErr = sys.stderr
    elif hasattr(sys.stderr, '_file') and hasattr(sys.stderr._file, 'fileno'):
        proceStdErr = sys.stderr._file
    else:
        procStdErrPath = 'nul'
        procStdErr = file(procStdErrPath, 'a')
    
    proc = Popen(cmd, stdout=PIPE, stderr=procStdErr, shell=True)
    output, errors = proc.communicate()
    output = str(output)
    logger.debug('output: "%s"' % output)
    print 'functions\tcheck_for_barcode received: %s' % output
    print "barcode was %sfound" % ('' if output.find(code) >= 0 else 'not ')
    return (len(output) > 0) and (output.find(code) >= 0)
コード例 #14
0
ファイル: Wizard.py プロジェクト: agusti/Project-Gado
 def __init__(self, root, q_in, q_out, q_gui):
     
     #Instantiate the logger
     loggerObj = Logger(self.__class__.__name__)
     self.logger = loggerObj.getLoggerInstance()
     
     self.q_in = q_in # read by wizard
     self.q_out = q_out # goes to gado_sys
     self.q_gui = q_gui # goes to GadoGui
     self.root = root
     
     self.webcam_name = None
     
     self._last_time = time.time()
     
     #Define our custom fonts
     labelFont = tkFont.Font(family = "Helvetica", size = 14)
     textFont = tkFont.Font(family="Helvetica", size = 11)
     self.labelFont = labelFont
     self.textFont = textFont
     
     #Set base size requirements
     window = Toplevel(root)
     window.minsize(WINDOW_WIDTH, WINDOW_HEIGHT)
     #window.maxsize(WINDOW_WIDTH, WINDOW_HEIGHT)
     window.geometry("%dx%d+0+0" % (WINDOW_WIDTH, WINDOW_HEIGHT))
     self.window = window
     
     #List to hold all frames
     frameList = []
     self.frameList = frameList
     self.frame_idx = 0
     nextButtons = []
     self.nextButtons = nextButtons
     self.keyboardCallbacks = dict()
     
     frame, next_btn = self._frame_requirements()
     frameList.append(frame)
     nextButtons.append(next_btn)
     
     frame, next_btn = self._frame_welcome()
     frameList.append(frame)
     nextButtons.append(next_btn)
     
     frame, next_btn = self._frame_rotation()
     frameList.append(frame)
     nextButtons.append(next_btn)
     
     #'''
     frame, next_btn = self._frame_location(IN_PILE)
     frameList.append(frame)
     nextButtons.append(next_btn)
     self.keyboardCallbacks[len(frameList) - 1] = 'arm_in_value'
     
     frame, next_btn = self._frame_location(SCANNER)
     frameList.append(frame)
     nextButtons.append(next_btn)
     self.keyboardCallbacks[len(frameList) - 1] = 'arm_home_value'
     
     frame, next_btn = self._frame_location(SCANNER_HEIGHT)
     frameList.append(frame)
     nextButtons.append(next_btn)
     self.keyboardCallbacks[len(frameList) - 1] = 'actuator_home_value'
     
     frame, next_btn = self._frame_location(SCANNER_CLEAR)
     frameList.append(frame)
     nextButtons.append(next_btn)
     self.keyboardCallbacks[len(frameList) - 1] = 'actuator_clear_value'
     
     frame, next_btn = self._frame_location(OUT_PILE)
     frameList.append(frame)
     nextButtons.append(next_btn)
     self.keyboardCallbacks[len(frameList) - 1] = 'arm_out_value'
     
     frame, next_btn = self._frame_peripheral('webcam')
     frameList.append(frame)
     nextButtons.append(next_btn)
     
     frame, next_btn = self._frame_peripheral('scanner')
     frameList.append(frame)
     nextButtons.append(next_btn)
     
     frame, next_btn = self._frame_image_path()
     frameList.append(frame)
     nextButtons.append(next_btn)
     
     frame, next_btn = self._frame_done()
     frameList.append(frame)
     nextButtons.append(next_btn)
     
     self.currentFrame = frame
     self.frame_idx = -1
     
     window.protocol("WM_DELETE_WINDOW", self._quit)
     window.withdraw()
コード例 #15
0
ファイル: main.py プロジェクト: agusti/Project-Gado
        Thread.__init__(self)
    
    def run(self):
        self.logger.info("calling main loop on gado_sys")
        
        self.gado_sys.load()
        self.gado_sys.mainloop()
        
        self.logger.debug("finished main loop on gado_sys")
        
        
#Main program section
if __name__ == '__main__':
    
    #Instantiate logger object
    loggerObj = Logger(__name__)
    logger = loggerObj.getLoggerInstance()
    
    logger.info("Initializing Gado Robot Management Interface")
       
    #Initialize communications queues
    q_gui_to_sys = Queue()
    q_sys_to_gui = Queue()
    
    #Instantiate both the Gui and Logic threads
    t1 = GuiThread(q_sys_to_gui, q_gui_to_sys)
    t2 = LogicThread(q_gui_to_sys, q_sys_to_gui)
    
    #Start up both threads independently
    t1.start()
    t2.start()