From c707e43e41e33aeb4e7cc6827a660069033b8dd7 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Thu, 5 Jul 2018 23:20:38 +0200 Subject: [PATCH] figth globals: curTipMask implementing https://github.com/qPCR4vir/robotevo/issues/8 introduce Instruction self.robot = Rbt.Robot.current to replace - Instruction_Base curTipMask to Rbt.tipsMask[self.robot.curArm().nTips] - arm Pipette.LiHa1 to self.robot.curArm(arm).index - Lab.def_LabW - Rbt.Robot.current to self.robot --- EvoScriPy/EvoMode.py | 1 + EvoScriPy/Instruction_Base.py | 24 ++++++------- EvoScriPy/Instructions.py | 64 +++++++++++++++++------------------ 3 files changed, 45 insertions(+), 44 deletions(-) diff --git a/EvoScriPy/EvoMode.py b/EvoScriPy/EvoMode.py index fbe4003..d142e46 100644 --- a/EvoScriPy/EvoMode.py +++ b/EvoScriPy/EvoMode.py @@ -176,6 +176,7 @@ def __init__(self, index, nTips , arms=None): self.set_as_current() def exec(self, instr): + assert (self.robot is instr.robot) self.set_as_current() instr.actualize_robot_state() diff --git a/EvoScriPy/Instruction_Base.py b/EvoScriPy/Instruction_Base.py index 6480441..accd939 100644 --- a/EvoScriPy/Instruction_Base.py +++ b/EvoScriPy/Instruction_Base.py @@ -82,6 +82,7 @@ class Instruction: def __init__(self, name): self.name = name self.arg = [] + self.robot = Rbt.Robot.current def validateArg(self): self.arg = [] @@ -136,8 +137,6 @@ def __init__(self, commandname): Device.__init__(self, "Te-MagS", commandname) -def_TipMask = 15 # todo revise. here? use Robot? -curTipMask = def_TipMask def_liquidClass = "Water free" #"Buffer free DITi 1000-AVR" # "AVR-Water free DITi 1000" # "Water free dispense DiTi 1000" def_vol = [0]*12 def_LoopOp = [] @@ -147,7 +146,7 @@ def __init__(self, commandname): class Pipette(Instruction): LiHa1 = 0 LiHa2 = 1 - def __init__(self, name, tipMask = curTipMask, + def __init__(self, name, tipMask = None, labware = None, spacing = 1, # todo how to use??? wellSelection = None, # todo how to use??? @@ -180,13 +179,14 @@ def __init__(self, name, tipMask = curTipMask, :param arm: """ Instruction.__init__(self, name) - self.tipMask=tipMask + self.robot.curArm(arm) + self.tipMask = tipMask if tipMask is not None else Rbt.tipsMask[self.robot.curArm().nTips] self.labware=labware or Lab.def_LabW # todo what def??? self.spacing = spacing self.loopOptions = LoopOptions self.RackName = RackName self.Well = Well - self.arm = arm + self.arm = self.robot.curArm().index # todo revise eliminate and use self.robot.curArm().index directly? # noOfLoopOptions, # loopName, # action, @@ -214,16 +214,16 @@ def exec(self, mode=None): class Pipetting(Pipette): - def __init__(self, name, tipMask = curTipMask, + def __init__(self, name, tipMask = None, liquidClass = def_liquidClass, volume = def_vol, - labware = Lab.def_LabW, # todo ?????? + labware = None, # todo ?????? spacing = 1, wellSelection= None, LoopOptions = def_LoopOp, RackName = None, Well = None, - arm = Pipette.LiHa1): + arm = None): Pipette.__init__(self, name, tipMask , labware , spacing , @@ -237,7 +237,7 @@ def __init__(self, name, tipMask = curTipMask, def validateArg(self): Pipette.validateArg(self) - nTips = Rbt.Robot.current.curArm().nTips # todo FIX arm is arg + nTips = self.robot.curArm().nTips # todo FIX arm is arg self.arg[1:1] = [string1(self.liquidClass)] + expr(nTips, self.volume).split() + [int(0)] * ( 12 - nTips) # arg 2, 3 - 14 return True @@ -247,12 +247,12 @@ def actualize_robot_state(self): pass def pipette_on_iRobot(self,action): - self.volume, self.tipMask = Rbt.Robot.current.pipette(action, self.volume, + self.volume, self.tipMask = self.robot.pipette(action, self.volume, self.labware, self.tipMask ) class DITIs(Instruction): - def __init__(self, name, tipMask=curTipMask, options=0, arm=Pipette.LiHa1): + def __init__(self, name, tipMask=None, options=0, arm=Pipette.LiHa1): """ :param name: str, instruction @@ -262,7 +262,7 @@ def __init__(self, name, tipMask=curTipMask, options=0, arm=Pipette.LiHa1): """ Instruction.__init__(self, name) self.options = options - self.tipMask = tipMask + self.tipMask = tipMask if tipMask is not None else Rbt.tipsMask[self.robot.curArm().nTips] self.arm = arm def validateArg(self): diff --git a/EvoScriPy/Instructions.py b/EvoScriPy/Instructions.py index 031bb73..c966a2e 100644 --- a/EvoScriPy/Instructions.py +++ b/EvoScriPy/Instructions.py @@ -17,7 +17,7 @@ class aspirate(Pipetting): """ A.15.4.1 Aspirate command (Worklist: Aspirate) A - 125 """ - def __init__(self, tipMask = curTipMask, + def __init__(self, tipMask = None, liquidClass = def_liquidClass, volume = def_vol, labware = None, @@ -26,7 +26,7 @@ def __init__(self, tipMask = curTipMask, LoopOptions = def_LoopOp, RackName = None, Well = None, - arm = Pipette.LiHa1): + arm = None): """ @@ -60,7 +60,7 @@ def action(): class dispense(Pipetting): """ A.15.4.2 Dispense (Worklist: Dispense) """ - def __init__(self, tipMask = curTipMask, + def __init__(self, tipMask = None, liquidClass = def_liquidClass, volume = def_vol, labware = None, @@ -69,7 +69,7 @@ def __init__(self, tipMask = curTipMask, LoopOptions = def_LoopOp, RackName = None, Well = None, - arm = Pipette.LiHa1): + arm = None): Pipetting.__init__(self, 'Dispense', tipMask, liquidClass, @@ -89,7 +89,7 @@ def action(): class mix(Pipetting): """ A.15.4.3 Mix (Worklist: Mix) """ - def __init__(self, tipMask = curTipMask, + def __init__(self, tipMask = None, liquidClass = def_liquidClass, volume = def_vol, labware = None, @@ -99,7 +99,7 @@ def __init__(self, tipMask = curTipMask, LoopOptions = def_LoopOp, RackName = None, Well = None, - arm = Pipette.LiHa1): + arm = None): Pipetting.__init__(self, 'Mix', tipMask, liquidClass, @@ -132,7 +132,7 @@ class wash_tips(Pipette): # TODO revise def values of arg, h DITIs several times to renew the system liquid column in the DITI adapters. This ensures maximum pipetting accuracy. """ - def __init__(self, tipMask = curTipMask, + def __init__(self, tipMask = None, WashWaste = None, WashCleaner = None, wasteVol = 100, @@ -147,7 +147,7 @@ def __init__(self, tipMask = curTipMask, atFrequency = 0, RackName = None, Well = None, - arm = Pipette.LiHa1): + arm = None): """ :param tipMask: @@ -217,7 +217,7 @@ def validateArg(self): return True class getDITI(DITIs): - def __init__(self, tipMask, type, options=0, arm= Pipette.LiHa1): + def __init__(self, tipMask, type, options=0, arm= None): """ A.15.4.5 Get DITIs (Worklist: GetDITI) ... The Get DITIs command is used to pick up DITIs (disposable tips) of the specified type from a DITI rack. Freedom EVOware keeps track of their position on the @@ -256,10 +256,10 @@ class getDITI2(DITIs): including the rack and the site (that is - the labware). It need a labware type and it know where to pick the next tip. """ - def __init__(self, tipMask = curTipMask, + def __init__(self, tipMask = None, LabwareTypeName = None, options = 0, - arm = Pipette.LiHa1, + arm = None, AirgapVolume = 0, AirgapSpeed = def_AirgapSpeed ): """ @@ -307,11 +307,11 @@ class dropDITI(Pipette): """ A.15.4.6 Drop DITIs command (Worklist: DropDITI). pag A - 130 and 15 - 14 """ - def __init__(self, tipMask = curTipMask, + def __init__(self, tipMask = None, labware = None, AirgapVolume= 0, AirgapSpeed = def_AirgapSpeed , - arm = Pipette.LiHa1): #, conditional=True): + arm = None): #, conditional=True): """ :param conditional: exec only if there are some tip to droop. :param tipMask: @@ -437,12 +437,12 @@ class pickUp_DITIs(Pipette): used and put back into a DITI rack with the Set DITIs Back command. You must specify the DITIs you want to pick up. """ - def __init__(self, tipMask = curTipMask, + def __init__(self, tipMask = None, labware = None, wellSelection= None, LoopOptions = def_LoopOp, type = None, - arm = Pipette.LiHa1, + arm = None, RackName = None, Well = None): Pipette.__init__(self, 'PickUp_DITIs', @@ -473,11 +473,11 @@ class pickUp_DITIs2(Pipette): used and put back into a DITI rack with the Set DITIs Back command. You must specify the DITIs you want to pick up. """ - def __init__(self, tipMask = curTipMask, + def __init__(self, tipMask = None, labware = None, wellSelection= None, LoopOptions = def_LoopOp, - arm = Pipette.LiHa1, # last parameter + arm = None, # last parameter RackName = None, Well = None): Pipette.__init__(self, 'PickUp_DITIs2', @@ -506,11 +506,11 @@ class set_DITIs_Back(Pipette): return used DITIs to specified positions on a DITI rack for later use. This command requires the Lower DITI Eject option. """ - def __init__(self , tipMask , #= curTipMask, + def __init__(self , tipMask , #= None, labware , #= None, wellSelection= None, LoopOptions = def_LoopOp, - arm = Pipette.LiHa1, + arm = None, RackName = None, Well = None): assert isinstance(labware, Lab.DITIrack) @@ -534,20 +534,20 @@ def actualize_robot_state(self): class pickUp_ZipTip(Pipette): # todo implement !!! """ A.15.4.10 Pickup ZipTip (Worklist: PickUp_ZipTip) """ - def __init__(self, tipMask = curTipMask ): + def __init__(self, tipMask = None ): Pipette.__init__(self, 'PickUp_ZipTip' ) assert False, "PickUp_ZipTip not implemented" class detect_Liquid(Pipetting): # todo get the results !!! """ A.15.4.11 Detect Liquid (Worklist: Detect_Liquid) """ - def __init__(self , tipMask = curTipMask, + def __init__(self , tipMask = None, liquidClass = def_liquidClass, labware = None, spacing = 1, wellSelection= None, LoopOptions = def_LoopOp, - arm = Pipette.LiHa1, + arm = None, RackName = None, Well = None, read = False): @@ -576,9 +576,9 @@ def exec(self, mode=None): class activate_PMP(Instruction): """ A.15.4.12 Activate PMP (Worklist: Activate_PMP) """ - def __init__(self, tipMask = curTipMask ): + def __init__(self, tipMask = None ): Instruction.__init__(self, "Activate_PMP") - self.tipMask = tipMask + self.tipMask = tipMask if tipMask is not None else Rbt.tipsMask[self.robot.curArm().nTips] def validateArg(self): Instruction.validateArg(self) @@ -591,9 +591,9 @@ def exec(self, mode=None): class deactivate_PMP(Instruction): """ A.15.4.13 Deactivate PMP (Worklist: Deactivate_PMP) """ - def __init__(self, tipMask = curTipMask ): + def __init__(self, tipMask = None ): Instruction.__init__(self, "Deactivate_PMP") - self.tipMask = tipMask + self.tipMask = tipMask if tipMask is not None else Rbt.tipsMask[self.robot.curArm().nTips] def validateArg(self): Instruction.validateArg(self) @@ -641,14 +641,14 @@ class moveLiha(Pipette ): global_z_travel = 4 # = global z-travel def __init__(self, zMove, zTarget, offset, speed, # arg 6,7,8,9 - tipMask = curTipMask, + tipMask = None, labware = None, spacing = 1, wellSelection= None, LoopOptions = def_LoopOp, RackName = None, Well = None, - arm = Pipette.LiHa1): + arm = None): """ :param zMove: int; type of movement: @@ -718,9 +718,9 @@ class active_Wash(Instruction): """ A.15.4.16 Active WashStation (Worklist: Active_Wash) """ - def __init__(self, wait = True, time=None, arm=Pipette.LiHa1 ): + def __init__(self, wait = True, time=None, arm=None ): Instruction.__init__(self, "Active_Wash") - self.arm = arm + self.arm = arm if arm is not None else self.robot.curArm().index self.time = time self.wait = wait @@ -743,14 +743,14 @@ def __init__(self, exportAll = True, formats = text_with_delimiters, delete = False, compress = False, - Raks=[], + Raks=None, # ????? significantStep = 1): Instruction.__init__(self, "Export") self.exportAll = exportAll self.formats = formats self.delete = delete self.compress = compress - self.Raks = Raks + self.Raks = Raks if Raks is not None else [] self.significantStep = significantStep