예제 #1
0
파일: history.py 프로젝트: uh-joan/UHCore
    def addHistory(self, ruleName, imageBytes=None, imageType=None):
        """ updates the action history table, blocking until all data is retrieved and stored """
        """ returns true on successful update """

        from Robots.robotFactory import Factory

        cob = Factory.getCurrentRobot()
        dao = DataAccess()
        dateNow = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        location = dao.getRobotByName(cob.name)["locationId"]

        historyId = dao.saveHistory(dateNow, ruleName, location)

        if historyId > 0:
            dao.saveSensorHistory(historyId)

            if imageType == None:
                imageType = ActionHistory._defaultImageType

            if imageBytes == None:
                imageBytes = cob.getImage(retFormat=imageType)

            if imageBytes != None:
                dao.saveHistoryImage(historyId, imageBytes, imageType)

        return historyId > 0
예제 #2
0
    def addHistory(self, ruleName, imageBytes=None, imageType=None):
        """ updates the action history table, blocking until all data is retrieved and stored """
        """ returns true on successful update """

        from Robots.robotFactory import Factory
        cob = Factory.getCurrentRobot()
        dao = DataAccess()
        dateNow = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        location = dao.getRobotByName(cob.name)['locationId']

        historyId = dao.saveHistory(dateNow, ruleName, location)

        if (historyId > 0):
            dao.saveSensorHistory(historyId)

            if imageType == None:
                imageType = ActionHistory._defaultImageType

            if imageBytes == None:
                imageBytes = cob.getImage(retFormat=imageType)

            if imageBytes != None:
                dao.saveHistoryImage(historyId, imageBytes, imageType)

        return historyId > 0
예제 #3
0
    def addHistory(self, ruleName, imageBytes=None, imageType=None):
        
        cob = CareOBot()
        dao = DataAccess()
        dateNow = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        location = dao.getRobotByName(cob.name)['locationId']
        
        historyId = dao.saveHistory(dateNow, ruleName, location)
        
        if(historyId > 0):
            dao.saveSensorHistory(historyId)

            if imageType == None:
                imageType = ActionHistory._defaultImageType

            if imageBytes == None:
                imageBytes = cob.getImage(retFormat=imageType)

            if imageBytes != None:
                dao.saveHistoryImage(historyId, imageBytes, imageType)
        
        return historyId > 0
예제 #4
0
    def addHistoryComplete(self, ruleName, imageBytes=None, imageType=None, imageOverheadBytes=None, imageOverheadType=None):
        """ updates the action history table, blocking until all data is retrieved and stored """
        """ returns true on successful update """
        
        from Robots.robotFactory import Factory
        cob = Factory.getCurrentRobot()
        dao = DataAccess()
        dateNow = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        location = dao.getRobotByName(cob.name)['locationId']
        user = self._dao.users.getActiveUser['userId']

        historyId = dao.saveHistoryComplete(dateNow, ruleName, location, user)
        
        if(historyId > 0):
            #dao.saveSensorHistory(historyId)

            if imageType == None:
                imageType = ActionHistory._defaultImageType

            if imageBytes == None:
                imageBytes = cob.getImage(retFormat=imageType)

            if imageBytes != None:
                dao.saveHistoryImage(historyId, imageBytes, imageType)

            #the same but for the overhead camera image

            if imageOverheadType == None:
                imageOverheadType = ActionHistory._defaultImageType

            if imageOverheadBytes == None:
                imageOverheadBytes = cob.getImageOverhead(retFormat=imageOverheadType)

            if imageOverheadBytes != None:
                dao.saveHistoryImageOverhead(historyId, imageOverheadBytes, imageOverheadType)
        
        return historyId > 0