Exemple #1
0
    def load_pipette_values(self):
        """Load pipette values from data/pipette_calibrations.json
        """
        logger.debug('head.load_pipette_values called')
        old_values = FileIO.get_dict_from_json(
            os.path.join(self.dir_path,
                         'otone_data/pipette_calibrations.json'))
        logger.debug('old_values:\n')
        logger.debug(old_values)

        if self.PIPETTES is not None and len(self.PIPETTES) > 0:
            for axis in old_values:
                #for n in old_values[axis]:
                for k, v in old_values[axis].items():
                    self.PIPETTES[axis].__dict__[k] = v

                    # should include:
                    #  'resting'
                    #  'top'
                    #  'bottom'
                    #  'blowout'
                    #  'droptip'
                    #  'volume'
                    #  'theContainers'

            logger.debug('self.PIPETTES[{}]:\n\n'.format(axis))
            logger.debug(self.PIPETTES[axis])
        else:
            logger.debug(
                'head.load_pipette_values: No pipettes defined in PIPETTES')
Exemple #2
0
    def load_pipette_values(self):
        """Load pipette values from data/pipette_calibrations.json
        """
        if debug == True: FileIO.log('head.load_pipette_values called')
        old_values = FileIO.get_dict_from_json(os.path.join(self.dir_par_par_path,'otone_data/pipette_calibrations.json'))
        if debug == True: FileIO.log('old_values:\n',old_values,'\n')
        
        if self.PIPETTES is not None and len(self.PIPETTES) > 0:
            for axis in old_values:
                #for n in old_values[axis]:
                for k, v in old_values[axis].items():
                    self.PIPETTES[axis].__dict__[k] = v

                    # should include:
                    #  'resting'
                    #  'top'
                    #  'bottom'
                    #  'blowout'
                    #  'droptip'
                    #  'volume'
                    #  'theContainers'
            
            if debug == True: FileIO.log('self.PIPETTES[',axis,']:\n\n',self.PIPETTES[axis],'\n')
        else:
            if debug == True: FileIO.log('head.load_pipette_values: No pipettes defined in PIPETTES')
def instantiate_objects():
    """After connection has been made, instatiate the various robot objects
    """

    global perm_dir_path
    global dir_path

    logger.debug('instantiate_objects called')
    #get default json file
    def_start_protocol = FileIO.get_dict_from_json(
        os.path.join(dir_path, 'data/default_startup_protocol.json'))
    #FileIO.get_dict_from_json('/home/pi/PythonProject/default_startup_protocol.json')

    #instantiate the head
    head = Head(def_start_protocol['head'], publisher, perm_dir_path)
    logger.debug('head string: ')
    logger.debug(str(head))
    logger.debug('head representation: ')
    logger.debug(repr(head))
    #use the head data to configure the head
    head_data = {}
    head_data = prot_dict['head']  #extract the head section from prot_dict

    logger.debug("Head configured!")

    #instantiate the script keeper (sk)

    #instantiate the deck
    deck = Deck(def_start_protocol['deck'], publisher, perm_dir_path)
    logger.debug('deck string: ')
    logger.debug(str(deck))
    logger.debug('deck representation: ')
    logger.debug(repr(deck))

    runner = ProtocolRunner(head, publisher)

    #use the deck data to configure the deck
    deck_data = {}
    deck_data = prot_dict['deck']  #extract the deck section from prot_dict
    #    deck = RobotLib.Deck({})        #instantiate an empty deck
    deck.configure_deck(deck_data)  #configure the deck from prot_dict data
    logger.debug("Deck configured!")

    #do something with the Ingredient data
    ingr_data = {}
    ingr_data = prot_dict[
        'ingredients']  #extract the ingredient section from prot_dict
    ingr = Ingredients({})

    ingr.configure_ingredients(
        ingr_data)  #configure the ingredienets from prot_dict data
    logger.debug('Ingredients imported!')

    publisher.set_head(head)
    publisher.set_runner(runner)
    subscriber.set_deck(deck)
    subscriber.set_head(head)
    subscriber.set_runner(runner)
Exemple #4
0
 def container_depth_override(self, container_name, new_depth):
     containers = FileIO.get_dict_from_json(os.path.join(self.dir_path,'otone_data/containers.json'))
     if container_name in containers and new_depth is not None:
         if 'locations' in containers[container_name]:
             containers[container_name]['locations']['depth'] = new_depth
             self.save_containers(containers)
             self.publish_containers()
         else:
             logger.error('error in deck.container_depth_override, locations not in containers--> {}'.format(container_name))
def instantiate_objects():
    """After connection has been made, instatiate the various robot objects
    """

    global perm_dir_path
    global dir_path

    #get default json file
    def_start_protocol = FileIO.get_dict_from_json(os.path.join(dir_path,'data/default_startup_protocol.json'))
    #FileIO.get_dict_from_json('/home/pi/PythonProject/default_startup_protocol.json')


    #instantiate the head
    head = Head(def_start_protocol['head'], publisher, perm_dir_path)
    #use the head data to configure the head
    head_data = {}
    head_data = prot_dict['head']   #extract the head section from prot_dict


    #instantiate the script keeper (sk)


    #instantiate the deck
    deck = Deck(def_start_protocol['deck'], publisher, perm_dir_path)


    runner = ProtocolRunner(head, publisher)


    #use the deck data to configure the deck
    deck_data = {}
    deck_data = prot_dict['deck']   #extract the deck section from prot_dict
    #    deck = RobotLib.Deck({})        #instantiate an empty deck
    deck.configure_deck(deck_data)  #configure the deck from prot_dict data


    #do something with the Ingredient data
    ingr_data = {}
    ingr_data = prot_dict['ingredients'] #extract the ingredient section from prot_dict
    ingr = Ingredients({})

    ingr.configure_ingredients(ingr_data) #configure the ingredienets from prot_dict data


    publisher.set_head(head)
    publisher.set_runner(runner)
    subscriber.set_deck(deck)
    subscriber.set_head(head)
    subscriber.set_runner(runner)
Exemple #6
0
    def load_pipette_values(self):
        """Load pipette values from data/pipette_calibrations.json
        """
        logger.debug('loading pipette calibrations:')
        old_values = FileIO.get_dict_from_json(os.path.join(self.dir_path,'otone_data/pipette_calibrations.json'))
        logger.debug(old_values)
        
        if self.PIPETTES is not None and len(self.PIPETTES) > 0:
            for axis in old_values:
                #for n in old_values[axis]:
                for k, v in old_values[axis].items():
                    self.PIPETTES[axis].__dict__[k] = v

                    # should include:
                    #  'resting'
                    #  'top'
                    #  'bottom'
                    #  'blowout'
                    #  'droptip'
                    #  'volume'
                    #  'theContainers'
            
        else:
            logger.debug('head.load_pipette_values: No pipettes defined in PIPETTES')
Exemple #7
0
f = open(os.devnull, 'w')
sys.stdout = f
sys.stderr = f

from head import Head
from deck import Deck

from subscriber import Subscriber
from publisher import Publisher

from file_io import FileIO
from ingredients import Ingredients

from protocol_runner import ProtocolRunner

prot_dict = FileIO.get_dict_from_json(fname_default_protocol)

#VARIABLES

#declare globol objects here
head = None
deck = None
runner = None
subscriber = None
publisher = None
def_start_protocol = None
client_status = False
crossbar_status = False

#Import and setup autobahn WAMP peer
from autobahn.asyncio import wamp, websocket
def instantiate_objects():
    """After connection has been made, instatiate the various robot objects
    """
    FileIO.log('instantiate_objects called')
    #get default json file
    def_start_protocol = FileIO.get_dict_from_json(os.path.join(dir_path,'data/default_startup_protocol.json'))
    #FileIO.get_dict_from_json('/home/pi/PythonProject/default_startup_protocol.json')


    #instantiate the head 
    head = Head(def_start_protocol['head'], publisher)
    if debug == True:
        FileIO.log('head string: ', str(head))
        FileIO.log('head representation: ', repr(head))
    #use the head data to configure the head
    head_data = {}
    head_data = prot_dict['head']   #extract the head section from prot_dict
    #    head = RobotLib.Head({})        #instantiate an empty head
    #head.configure_head(head_data)  #configure the head from prot_dict data
    if debug == True:
        FileIO.log ("Head configured!")


    #instantiate the script keeper (sk)
    the_sk = ScriptKeeper(publisher)


    #instantiate the deck
    deck = Deck(def_start_protocol['deck'], publisher)
    if debug == True:
        FileIO.log('deck string: ', str(deck))
        FileIO.log('deck representation: ', repr(deck))


    runner = ProtocolRunner(head, publisher)

    
    #use the deck data to configure the deck
    deck_data = {}
    deck_data = prot_dict['deck']   #extract the deck section from prot_dict
    #    deck = RobotLib.Deck({})        #instantiate an empty deck
    deck.configure_deck(deck_data)  #configure the deck from prot_dict data
    if debug == True:
        FileIO.log ("Deck configured!")


    #do something with the Ingredient data
    ingr_data = {}
    ingr_data = prot_dict['ingredients'] #extract the ingredient section from prot_dict
    ingr = Ingredients({}) 
    
    ingr.configure_ingredients(ingr_data) #configure the ingredienets from prot_dict data
    if debug == True:
        FileIO.log('Ingredients imported!')
        FileIO.log('this is a test') 


    publisher.set_head(head)
    publisher.set_runner(runner)
    subscriber.set_deck(deck)
    subscriber.set_head(head)
    subscriber.set_runner(runner)


    @asyncio.coroutine
    def periodically_send_ip_addresses():
        """Coroutine that periodically sends information to browser
        """
        if debug == True and verbose == True: FileIO.log('periodically_send_ip_addresses called')
        while True:
            if debug == True and verbose == True: FileIO.log('periodically_send_ip_addresses again...')
            yield from asyncio.sleep(2)
            stuff = yield from sk.per_data()
            session_factory._myAppSession.publish('com.opentrons.robot_to_browser_ctrl',json.dumps(stuff,sort_keys=True,indent=4,separators=(',',': ')))


    asyncio.Task(periodically_send_ip_addresses())
print('fname_data: ', fname_data)
print('fname_default_containers: ', fname_default_containers)
print('fname_data_containers: ', fname_data_containers)


if not os.path.isdir(fname_data):
    os.makedirs(fname_data)
#if not os.path.exists(fname_data_containers):
open(fname_data_containers,"w+")
shutil.copy(fname_default_containers, fname_data_containers)

if not os.path.exists(fname_data_calibrations):
    open(fname_data_calibrations,"w+")
    shutil.copy(fname_default_calibrations, fname_data_calibrations)

prot_dict = FileIO.get_dict_from_json(fname_default_protocol)



#Import and setup autobahn WAMP peer
from autobahn.asyncio import wamp, websocket

class WampComponent(wamp.ApplicationSession):
    """WAMP application session for OTOne (Overrides protocol.ApplicationSession - WAMP endpoint session)
    """

    def onConnect(self):
        """Callback fired when the transport this session will run over has been established.
        """
        self.join(u"ot_realm")
Exemple #10
0
 def get_containers(self):
     containers = FileIO.get_dict_from_json(os.path.join(self.dir_path,'otone_data/containers.json'))
     return containers
Exemple #11
0
 def get_containers(self):
     if debug == True: FileIO.log('deck.get_containers called')
     containers = FileIO.get_dict_from_json(os.path.join(self.dir_par_par_path,'otone_data/containers.json'))
     return containers
Exemple #12
0
 def get_containers(self):
     logger.debug('deck.get_containers called')
     containers = FileIO.get_dict_from_json(os.path.join(self.dir_path,'otone_data/containers.json'))
     return containers