Ejemplo n.º 1
0
    def __init__ (self, host=None, port=None, stlport=None):
                 
        self.HOST = host if host is not None else DEFAULT_HOST
        self.PORT = port if port is not None else DEFAULT_PORT
        self.STLPORT = stlport if stlport is not None else DEFAULT_STILLS_PORT

        self.USERNANE = "root"
        self.PASSWORD = "******"
        self.DWN_STATE = False
        self.REC_STATE = False
        self.RDY_STATE = False

        self.MSG_COLOUR = 0 #initiate with white
        self.MSG_NODEBUG = False
        
        #try to assing the correct colour to the camera name:
        
        if len(DicDevicesColours) is 0:
            colourChosed = self.MSG_COLOUR #with only one camera, camera name always stay in white in messages
        elif len(DicDevicesColours) is 8:
            print_CASUAL(self,"STOP TRYING TO CONNECT CAMERAS TO THIS COMPUTER! are you mad?!")
        elif len(DicDevicesColours) > 7:
            colourChosed = random.randrange(0,7,1)
        else:
            breaker = False
            while True:
                colourChosed = random.randrange(0,7,1)
                for k in DicDevicesColours:
                    if colourChosed == DicDeviceColours[k]:
                        breaker = True
                        break
                if breaker:
                    break
        
        DicDevicesColours[self.HOST] = colourChosed
        
        self.MSG_COLOUR = colourChosed
Ejemplo n.º 2
0
    def __init__(self,
                 host=None,
                 port=None,
                 stlport=None,
                 path=None,
                 parmFile=None):

        self.HOST = host if host is not None else DEFAULT_HOST
        self.PORT = port if port is not None else DEFAULT_PORT
        self.STLPORT = stlport if stlport is not None else DEFAULT_STILLS_PORT
        self.PATH = path if path is not None else DEFAULT_PATH
        self.PARM_FILE = parmFile if parmFile is not None else DEFAULT_PARM_FILE

        self.USERNAME = "******"
        self.PASSWORD = "******"
        self.DWN_STATE = False
        self.REC_STATE = False
        self.RDY_STATE = False
        self.AUTO_EXP_STATE = True  #the dafault beheviour
        self.AUTO_WB_STATE = True  #the dafault beheviour
        self.AUTO_CONFG = True

        self.MSG_DEVICE_COLOUR = 0  #initiate with white
        self.MSG_NODEBUG = True

        self.DIC_SETTINGS = {}

        #try to assing the correct colour to the camera name:
        print_CASUAL(self, "DicDevicesColours is: " + str(DicDevicesColours))
        if len(DicDevicesColours) is 0:
            colourChosed = self.MSG_DEVICE_COLOUR  #with only one camera, camera name always stay in white in messages
        elif len(DicDevicesColours) is 8:
            print_CASUAL(
                self,
                "STOP TRYING TO CONNECT CAMERAS TO THIS COMPUTER! are you mad?!"
            )
        #elif len(DicDevicesColours) > 7:
        else:
            colourChosed = random.randrange(0, 7, 1)
        """else:
            breaker = False
            while True:
                colourChosed = random.randrange(0,7,1)
                for k in DicDevicesColours:
                    if colourChosed == DicDevicesColours[k]:
                        breaker = True
                        break
                if breaker:
                    break
        """
        print_CASUAL(self, "DicDevicesColours is: " + str(DicDevicesColours))
        if DicDevicesColours[self.HOST] is colourChosed:
            pass
        else:
            DicDevicesColours[self.HOST] = colourChosed
        self.MSG_DEVICE_COLOUR = colourChosed
Ejemplo n.º 3
0
    def __init__ (self, host=None, port=None, stlport=None, path=None, parmFile=None):
                 
        self.HOST = host if host is not None else DEFAULT_HOST
        self.PORT = port if port is not None else DEFAULT_PORT
        self.STLPORT = stlport if stlport is not None else DEFAULT_STILLS_PORT
        self.PATH = path if path is not None else DEFAULT_PATH
        self.PARM_FILE = parmFile if parmFile is not None else DEFAULT_PARM_FILE

        

        self.USERNAME = "******"
        self.PASSWORD = "******"
        self.DWN_STATE = False
        self.REC_STATE = False
        self.RDY_STATE = False
        self.AUTO_EXP_STATE = True #the dafault beheviour
        self.AUTO_WB_STATE = True #the dafault beheviour
        self.AUTO_CONFG = True

        self.MSG_DEVICE_COLOUR = 0 #initiate with white
        self.MSG_NODEBUG = True
        
        self.DIC_SETTINGS = {}
        
        #try to assing the correct colour to the camera name:
        print_CASUAL(self, "DicDevicesColours is: " + str(DicDevicesColours))
        if len(DicDevicesColours) is 0:
            colourChosed = self.MSG_DEVICE_COLOUR #with only one camera, camera name always stay in white in messages
        elif len(DicDevicesColours) is 8:
            print_CASUAL(self,"STOP TRYING TO CONNECT CAMERAS TO THIS COMPUTER! are you mad?!")
        #elif len(DicDevicesColours) > 7:
        else:
            colourChosed = random.randrange(0,7,1)
        """else:
            breaker = False
            while True:
                colourChosed = random.randrange(0,7,1)
                for k in DicDevicesColours:
                    if colourChosed == DicDevicesColours[k]:
                        breaker = True
                        break
                if breaker:
                    break
        """
        print_CASUAL(self, "DicDevicesColours is: " + str(DicDevicesColours))
        if DicDevicesColours[self.HOST] is colourChosed:
            pass
        else:
            DicDevicesColours[self.HOST] = colourChosed
        self.MSG_DEVICE_COLOUR = colourChosed
Ejemplo n.º 4
0
    def set_default_settings(self, XMLparmFile):

        import xml.etree.ElementTree as ElTree

        changes = False
        error = False
        currentParmsDic = {}
        sendParmsDic = {}
        maxLengthWan = 0
        maxLengthCam = 0

        self.AUTO_CONFG = True

        

        try:
            print_DEBUG(self,"obre el 'try' amb XMLparmFile:" + XMLparmFile) #debug
            tree = ElTree.parse(XMLparmFile)
            print_DEBUG(self,"crea el 'tree'") #debug
            root = tree.getroot()
            rint_DEBUG(self,"pren l'arrel") #debug
            print_DEBUG(self,"'tree' is:" + str(tree)) #debug
            print_DEBUG(self,"'root' is" + str(root)) #debug
        except:
            print_ERROR(self,"Something went wrong while parsing " + XMLparmFile)
            error = True
        else:
            for child in tree.iter():
                for c in child:
                    self.DIC_SETTINGS[c.tag] = c.text

        keyListWan = self.DIC_SETTINGS.keys()

        if error is not True:

            self.get_parameters(self.DIC_SETTINGS,self.PATH,"camera_settings")

            try:
                tree = ElTree.parse(os.path.join(DESTPATH,"camera_settings.xml"))
                root = tree.getroot()
                print_DEBUG(self,"'tree' is:" + str(tree)) #debug
                print_DEBUG(self,"'root' is" + str(root)) #debug
            except:
                print_ERROR(self,"Something went wrong while parsing 'camera_settings.xml'")
                error = True
            else:
                for child in tree.iter():
                    for c in child:
                        currentParmsDic[c.tag] = c.text

            keyListCam = currentParmsDic.keys()

        if error is not True:

            wanVal = ""
            camVal = ""
            w = 0
            maxLengthWan = len(keyListWan)
            print_DEBUG(self,"'maxLengthWan' is: " + str(maxLengthWan)) #debug
            maxLengthCam = len(keyListCam)
            print_DEBUG(self,"'maxLengthCam' is: " + str(maxLengthCam)) #debug
            for w in range(maxLengthWan):
                wanVal = keyListWan[w]
                c = 0
                for c in range(maxLengthCam):
                    camVal = keyListCam[c]
                    if (wanVal == camVal):
                        if (self.DIC_SETTINGS[wanVal] == currentParmsDic[camVal]):
                            print_DEBUG(self,wanVal + " is " + self.DIC_SETTINGS[wanVal] + " on both dictionaries")
                            break
                        else:
                            #TODO add a pooliong system, which will allow multi-threading
                            sendParmsDic[wanVal] = self.DIC_SETTINGS[wanVal]
                            changes = True
                    c = c + 1
                w = w + 1

        else:
            print_ERROR(self,"The process failed and will end unsuccessfully")
            return

        if changes:
            set_parameters(sendParmsDic)
            print_CASUAL(self,"All new values uploaded to the camera")
        else:
            print_CASUAL(self,"No values uploaded to the camera")

        #set_parameters(self.DIC_SETTINGS)
    
        if self.DIC_SETTINGS["AUTOEXP_ON"] == 1:
            self.AUTO_EXP_STATE = False
        else:
            self.AUTO_EXP_STATE = True

        if self.DIC_SETTINGS["WB_EN"] == 1:
            self.AUTO_WB_STATE = False
        else:
            self.AUTO_WB_STATE = True

        self.AUTO_CONFG = False
Ejemplo n.º 5
0
def setupCamera_1():
    changes = False
    error = False
    wantedParmsDic = {}
    cameraParmsDic = {}
    sendParmsDic = {}
    maxLengthWan = 0
    maxLengthCam = 0

    try:
        camera1
    except NameError:
        camera1 = ElpAPI.core(HOST1) #creates camera only if it doesn't exists before
    else:
        print_CASUAL(camera1,"'camera1' object already created")
    
    try:
        tree = ElTree.parse(os.path.join(DESTPATH,"wanted_settings1.xml"))
        root = tree.getroot()
    except:
        print_ERROR(camera1,"Something went wrong while parsing 'wanted_settings.xml'")
        error = True
    else:
        for child in tree.iter():
            for c in child:
                wantedParmsDic[c.tag] = c.text
        #created a dictionary from known sources.
        keyListWan = wantedParmsDic.keys()

    camera1.get_parameters(wantedParmsDic,DESTPATH,"camera_settings1") 
    #download the camera settings using the dictionary as a reference.
    try:
        tree = ElTree.parse(os.path.join(DESTPATH,"camera_settings1.xml"))
        root = tree.getroot()
        print_DEBUG(camera1,"'tree' is:" + str(tree)) #debug
        print_DEBUG(camera1,"'root' is" + str(root)) #debug
    except:
        print_ERROR(camera1,"Something went wrong while parsing 'camera_settings1.xml'")
        error = True
    else:
        for child in tree.iter():
            for c in child:
                cameraParmsDic[c.tag] = c.text
                camera1.implant_camera_setting(c.tag, c.text)
        #created a new dictionary with the settings the camera is using.7

        #download_settings(camera, wantedParmsDic, cameraParmsDic)
        #download_settings(camera1, wantedParmsDic)
        keyListCam = cameraParmsDic.keys()
        #keyListCam = camera.DIC_SETTINGS.keys()
        #keyListCam = camera1.gather_camera_settings()


    if error is not True: 
        
        wanVal = ""
        camVal = ""
        w = 0
        maxLengthWan = len(keyListWan)
        print_DEBUG(camera1,"'maxLengthWan' is: " + str(maxLengthWan)) #debug
        maxLengthCam = len(keyListCam)
        print_DEBUG(camera1,"'maxLengthCam' is: " + str(maxLengthCam)) #debug
        for w in range(maxLengthWan):
            wanVal = keyListWan[w]
            c = 0
            for c in range(maxLengthCam):
                camVal = keyListCam[c]
                if (wanVal == camVal):
                    if (wantedParmsDic[wanVal] == cameraParmsDic[camVal]):
                        print_DEBUG(camera1,wanVal + " is " + wantedParmsDic[wanVal] + " on both dictionaries")
                        break
                    else:
                        #TODO add a pooliong system, which will allow multi-threading
                        sendParmsDic[wanVal] = wantedParmsDic[wanVal]
                        changes = True
                c = c + 1
            w = w + 1
    else:
        print_ERROR(camera1,"The process failed and will end unsuccessfully")
        return

    if changes:
        camera1.set_parameters(sendParmsDic)
        print_CASUAL(camera1,"All new values uploaded to the camera")
    else:
        print_CASUAL(camera1,"No values uploaded to the camera")
Ejemplo n.º 6
0
    def set_default_settings(self, XMLparmFile):

        import xml.etree.ElementTree as ElTree

        changes = False
        error = False
        currentParmsDic = {}
        sendParmsDic = {}
        maxLengthWan = 0
        maxLengthCam = 0

        self.AUTO_CONFG = True

        try:
            print_DEBUG(self,
                        "obre el 'try' amb XMLparmFile:" + XMLparmFile)  #debug
            tree = ElTree.parse(XMLparmFile)
            print_DEBUG(self, "crea el 'tree'")  #debug
            root = tree.getroot()
            rint_DEBUG(self, "pren l'arrel")  #debug
            print_DEBUG(self, "'tree' is:" + str(tree))  #debug
            print_DEBUG(self, "'root' is" + str(root))  #debug
        except:
            print_ERROR(self,
                        "Something went wrong while parsing " + XMLparmFile)
            error = True
        else:
            for child in tree.iter():
                for c in child:
                    self.DIC_SETTINGS[c.tag] = c.text

        keyListWan = self.DIC_SETTINGS.keys()

        if error is not True:

            self.get_parameters(self.DIC_SETTINGS, self.PATH,
                                "camera_settings")

            try:
                tree = ElTree.parse(
                    os.path.join(DESTPATH, "camera_settings.xml"))
                root = tree.getroot()
                print_DEBUG(self, "'tree' is:" + str(tree))  #debug
                print_DEBUG(self, "'root' is" + str(root))  #debug
            except:
                print_ERROR(
                    self,
                    "Something went wrong while parsing 'camera_settings.xml'")
                error = True
            else:
                for child in tree.iter():
                    for c in child:
                        currentParmsDic[c.tag] = c.text

            keyListCam = currentParmsDic.keys()

        if error is not True:

            wanVal = ""
            camVal = ""
            w = 0
            maxLengthWan = len(keyListWan)
            print_DEBUG(self,
                        "'maxLengthWan' is: " + str(maxLengthWan))  #debug
            maxLengthCam = len(keyListCam)
            print_DEBUG(self,
                        "'maxLengthCam' is: " + str(maxLengthCam))  #debug
            for w in range(maxLengthWan):
                wanVal = keyListWan[w]
                c = 0
                for c in range(maxLengthCam):
                    camVal = keyListCam[c]
                    if (wanVal == camVal):
                        if (self.DIC_SETTINGS[wanVal] ==
                                currentParmsDic[camVal]):
                            print_DEBUG(
                                self,
                                wanVal + " is " + self.DIC_SETTINGS[wanVal] +
                                " on both dictionaries")
                            break
                        else:
                            #TODO add a pooliong system, which will allow multi-threading
                            sendParmsDic[wanVal] = self.DIC_SETTINGS[wanVal]
                            changes = True
                    c = c + 1
                w = w + 1

        else:
            print_ERROR(self, "The process failed and will end unsuccessfully")
            return

        if changes:
            set_parameters(sendParmsDic)
            print_CASUAL(self, "All new values uploaded to the camera")
        else:
            print_CASUAL(self, "No values uploaded to the camera")

        #set_parameters(self.DIC_SETTINGS)

        if self.DIC_SETTINGS["AUTOEXP_ON"] == 1:
            self.AUTO_EXP_STATE = False
        else:
            self.AUTO_EXP_STATE = True

        if self.DIC_SETTINGS["WB_EN"] == 1:
            self.AUTO_WB_STATE = False
        else:
            self.AUTO_WB_STATE = True

        self.AUTO_CONFG = False
Ejemplo n.º 7
0
def setupCamera():
    changes = False
    error = False
    wantedParmsDic = {}
    cameraParmsDic = {}
    sendParmsDic = {}
    maxLengthWan = 0
    maxLengthCam = 0

    #autoKillSwitch.go() #TODO all this stuff is reserverd for the future
    #autoResolution.go() #TODO the same above
    #autoColourt.go() #TODO add a colour selection system, the same above
    try:
        camera
    except NameError:
        camera = ElpAPI.core(
            HOST)  #creates camera only if it doesn't exists before
    else:
        print_CASUAL(camera, "'camera' object already created")

    try:
        tree = ElTree.parse(os.path.join(DESTPATH, "wanted_settings.xml"))
        root = tree.getroot()
    except:
        print_ERROR(
            camera, "Something went wrong while parsing 'wanted_settings.xml'")
        error = True
    else:
        for child in tree.iter():
            for c in child:
                wantedParmsDic[c.tag] = c.text
        #created a dictionary from known sources.
        keyListWan = wantedParmsDic.keys()

    camera.get_parameters(wantedParmsDic, DESTPATH, "camera_settings")
    #download the camera settings using the dictionary as a reference.
    try:
        tree = ElTree.parse(os.path.join(DESTPATH, "camera_settings.xml"))
        root = tree.getroot()
        print_DEBUG(camera, "'tree' is:" + str(tree))  #debug
        print_DEBUG(camera, "'root' is" + str(root))  #debug
    except:
        print_ERROR(
            camera, "Something went wrong while parsing 'camera_settings.xml'")
        error = True
    else:
        for child in tree.iter():
            for c in child:
                cameraParmsDic[c.tag] = c.text
        #created a new dictionary with the settings the camera is using.
        keyListCam = cameraParmsDic.keys()

    if error is not True:

        wanVal = ""
        camVal = ""
        w = 0
        maxLengthWan = len(keyListWan)
        print_DEBUG(camera, "'maxLengthWan' is: " + str(maxLengthWan))  #debug
        maxLengthCam = len(keyListCam)
        print_DEBUG(camera, "'maxLengthCam' is: " + str(maxLengthCam))  #debug
        for w in range(maxLengthWan):
            wanVal = keyListWan[w]
            c = 0
            for c in range(maxLengthCam):
                camVal = keyListCam[c]
                if (wanVal == camVal):
                    if (wantedParmsDic[wanVal] == cameraParmsDic[camVal]):
                        print_DEBUG(
                            camera, wanVal + " is " + wantedParmsDic[wanVal] +
                            " on both dictionaries")
                        break
                    else:
                        #TODO add a pooliong system, which will allow multi-threading
                        sendParmsDic[wanVal] = wantedParmsDic[wanVal]
                        changes = True
                c = c + 1
            w = w + 1
    else:
        print_ERROR(camera, "The process failed and will end unsuccessfully")
        return

    if changes:
        camera.set_parameters(sendParmsDic)
        print_CASUAL(camera, "All new values uploaded to the camera")
    else:
        print_CASUAL(camera, "No values uploaded to the camera")