Exemplo n.º 1
0
    def setUser(self, char_value, **kw):
        """
        | Sets the User for the Engine, and all workers.
        | Is called when the PV changes
        | Checks new user value against previous user
        | If matching values, nothing occurs
        | Calls newUser(user) if it is a new user
        
        Args:
            char_value (string): String value of the PV, should be the full path to the image locations relative to epics
            **kw (dict): remaining values returned from epics
            
        """
        self.logger.info("User Change Event")

        # user = getUser(char_value)

        if self.experimentFolderOn:
            print "Experiment folder on"
            experiment = getString(char_value, -2)
            user = getString(char_value, -3)

            print "EXPERIMENT : %s" % experiment
            print "USER : %s" % user

            # Test user change
            if testStringChange(user, self.previousUser):
                print "USER CHANGE, SO YES experiment CHANGE \nRUN user.change with experiment!"
                self.previousUser = user
                self.previousExperiment = experiment
                self.newUser1()

            else:
                print "NO USER CHANAGE"

                print "BETTER CHECK IF USER CHANGED!"
                if testStringChange(experiment, self.previousExperiment):
                    print "EXPERUIMENT CHANGE!"
                    self.previousExperiment = experiment
                    self.newExperiment()
                else:
                    print "Nothing changed, user nor experiment"
                    pass

        # experiment filder is off, onlty just againse user
        else:
            print "exerpimetn folder off, on;y check user"
            user = getString(char_value, -2)
            print "USER: %s" % user

            if testStringChange(user, self.previousUser):
                print "USER HAS CHANGED, run new user"
                self.previousUser = user
                self.newUser1()

            else:
                print "NO USER CHANGE DO NOTHING"
                pass

        """    
    def setUser(self, char_value, **kw):
        """
        | Sets the User for the Engine, and all workers.
        | Is called when the PV changes
        | Checks new user value against previous user
        | If matching values, nothing occurs
        | Calls newUser(user) if it is a new user
        
        Args:
            char_value (string): String value of the PV, should be the full path to the image locations relative to epics
            \*\*kw (dict): remaining values returned from epics
            
        """
        
        #user = getUser(char_value)
        
        if self.experimentFolderOn:
            experimentFolder = getString(char_value, -2)
            user = getString(char_value, -3)
        else:
            experimentFolder = ""
            user = getString(char_value, -2)

        if self.previousUser != user or self.previousExperiment != experimentFolder:
            self.logger.info("Experiment Change Event\n----------------------------------------")
            self.previousUser = user; self.previousExperiment = experimentFolder
            self.setupExperiment(user, experimentFolder)