Example #1
0
 def adjustTokens(self, transitionItemObject, acquired, emitted):
     preserved = {}
     emittedNames = {}
     for tokenName in emitted.keys():
         emittedNames[tokenName] = tokenName
     for token in acquired:
         if not token.getName() in emittedNames:
             self.petriNet.getTokenList().remove(token)
         else:
             preserved[token.getName()] = token
             token.setProperty("prevTransition", self.getName())
     # create or re-emit the required number of tokens with inherited or transition specified properties
     for stateName in emittedNames.keys():
         if not stateName in preserved:
             properties = {}
             properties["prevTransition"] = self.getName()
             tokenSpec = emitted[stateName]
             for i in xrange(tokenSpec[1]):
                 token = Token(stateName, properties, None)
                 self.petriNet.getTokenList().addToken(token)  # implies unlock
         properties = {}
         tokens = self.petriNet.getTokenList().getTokensByOwnerAndSpec(
             stateName, transitionItemObject, properties, lockedState=True
         )
         properties = emitted[stateName][0]
         for prop, value in properties.items():
             for token in tokens:
                 token.setProperty(prop, value)
Example #2
0
    def run(self):
        super(Lims, self).runSimulate()
        # Do the work

        # post processing
        properties = {}
        tokens = self.getTokenList().getTokensByOwnerAndSpec("ap", self, properties, lockedState=True)
        if tokens == None or len(tokens) == 0:
            utils.logTrace("No Assay Plate barcode")
        tokenApInProcess = tokens[0]
        barcodeAP = tokenApInProcess.getProperty("barcodeAP")
        properties = {}
        tokens = self.getTokenList().getTokensByOwnerAndSpec("sp", None, properties, lockedState=False)
        numreq = 3
        for token in tokens:
            color = token.getProperty("color")
            if color == "free":
                token.setProperty("barcodeAP", barcodeAP)
                token.setProperty("prevTransition", "lims")
                token.setProperty("color", "reserved")
                numreq -= 1
                if numreq <= 0:
                    break

        # Complete transition
        super(Lims, self).complete()
        utils.log("Exit " + self.getName() + " " + repr(os.getpid()) + " " + threading.currentThread().getName())
        exit()