def cleanup(self, database, saveid, **kwargs):
        '''
        Function to run at 'cleanup' time, after the FSM has finished executing. See riglib.experiment.Experiment.cleanup
        This 'cleanup' method remotely stops the plexon file recording and then links the file created to the database ID for the current TaskEntry
        '''
        # Stop recording
        import comedi
        import time

        com = comedi.comedi_open("/dev/comedi0")
        comedi.comedi_dio_bitfield2(com, 0, 16, 16, 16)

        super(RelayPlexon, self).cleanup(database, saveid, **kwargs)

        # Sleep time so that the plx file has time to save cleanly
        time.sleep(2)
        dbname = kwargs['dbname'] if 'dbname' in kwargs else 'default'
        if self.plexfile is not None:
            if dbname == 'default':
                database.save_data(self.plexfile, "plexon", saveid, True,
                                   False)
            else:
                database.save_data(self.plexfile,
                                   "plexon",
                                   saveid,
                                   True,
                                   False,
                                   dbname=dbname)
        else:
            print(
                '\n\nPlexon file not found properly! It will have to be manually linked!\n\n'
            )
    def cleanup(self, database, saveid, **kwargs):
        '''
        Function to run at 'cleanup' time, after the FSM has finished executing. See riglib.experiment.Experiment.cleanup
        This 'cleanup' method remotely stops the plexon file recording and then links the file created to the database ID for the current TaskEntry
        '''
        # Stop recording
        import comedi
        import config
        import time

        com = comedi.comedi_open("/dev/comedi0")
        comedi.comedi_dio_bitfield2(com, 0, 16, 16, 16)

        super(RelayPlexon, self).cleanup(database, saveid, **kwargs)

        # Sleep time so that the plx file has time to save cleanly
        time.sleep(2)
        dbname = kwargs['dbname'] if 'dbname' in kwargs else 'default'
        if self.plexfile is not None:
            if dbname == 'default':
                database.save_data(self.plexfile, "plexon", saveid, True, False)
            else:
                database.save_data(self.plexfile, "plexon", saveid, True, False, dbname=dbname)
        else:
            print '\n\nPlexon file not found properly! It will have to be manually linked!\n\n'
 def _start_interpulse_period(self):
     super(TTLStimulation, self)._start_interpulse_period()
     subdevice = 0
     write_mask = 0x800000
     val = 0x000000
     base_channel = 0
     comedi.comedi_dio_bitfield2(self.com, subdevice, write_mask, val, base_channel)
Ejemplo n.º 4
0
 def _end_pulse(self):
     subdevice = 0
     write_mask = 0x800000
     val = 0x000000
     base_channel = 0
     comedi.comedi_dio_bitfield2(self.com, subdevice, write_mask, val,
                                 base_channel)
Ejemplo n.º 5
0
 def _start_interpulse_period(self):
     super(TTLStimulation, self)._start_interpulse_period()
     subdevice = 0
     write_mask = 0x800000
     val = 0x000000
     base_channel = 0
     comedi.comedi_dio_bitfield2(self.com, subdevice, write_mask, val,
                                 base_channel)
	def __init__(self, *args, **kwargs):
		#self.com = comedi.comedi_open('/dev/comedi0')
		super(stimulus_pulse, self).__init__(*args, **kwargs)
		subdevice = 0
		write_mask = 0x800000
		val = 0x000000
		base_channel = 0
		comedi.comedi_dio_bitfield2(self.com, subdevice, write_mask, val, base_channel)
    def _start_pulse(self):
        '''
        At the start of the stimulation state, send TTL pulse
        '''

        #super(TTLStimulation, self)._start_pulse()
        subdevice = 0
        write_mask = 0x800000
        val = 0x800000
        base_channel = 0
        comedi.comedi_dio_bitfield2(self.com, subdevice, write_mask, val, base_channel)
        self.pulse_count = self.pulse_count + 1
 def pulse(self,ts):
     #super(stimulus_pulse, self).pulse()
     subdevice = 0
     write_mask = 0x800000
     val = 0x000000
     base_channel = 0
     while ts < 0.4:
         val = 0x800000
         comedi.comedi_dio_bitfield2(self.com, subdevice, write_mask, val, base_channel)
     else:
         val = 0x000000
         comedi.comedi_dio_bitfield2(self.com, subdevice, write_mask, val, base_channel)
Ejemplo n.º 9
0
    def _start_pulse(self):
        '''
        At the start of the stimulation state, send TTL pulse
        '''

        #super(TTLStimulation, self)._start_pulse()
        subdevice = 0
        write_mask = 0x800000
        val = 0x800000
        base_channel = 0
        comedi.comedi_dio_bitfield2(self.com, subdevice, write_mask, val,
                                    base_channel)
        self.pulse_count = self.pulse_count + 1
    def pre_init(cls, saveid=None):
        '''
        Run prior to starting the task to remotely start recording from the plexon system
        '''
        if saveid is not None:
            import comedi
            import time

            com = comedi.comedi_open("/dev/comedi0")
            # stop any recording
            comedi.comedi_dio_bitfield2(com, 0, 16, 16, 16)
            time.sleep(0.1)
            # start recording
            comedi.comedi_dio_bitfield2(com, 0, 16, 0, 16)

            time.sleep(3)
            super(RelayPlexon, cls).pre_init(saveid=saveid)
    def run(self):
        '''
        Code to execute immediately prior to the beginning of the task FSM executing, or after the FSM has finished running.
        See riglib.experiment.Experiment.run(). This 'run' method stops the NIDAQ sink after the FSM has stopped running.
        '''
        try:
            super(RelayPlexon, self).run()
        finally:
            # Stop the NIDAQ sink
            self.nidaq.stop()

            # Remotely stop the recording on the plexon box
            import comedi
            import time
            com = comedi.comedi_open("/dev/comedi0")
            time.sleep(0.5)
            comedi.comedi_dio_bitfield2(com, 0, 16, 16, 16)
    def run(self):
        '''
        Code to execute immediately prior to the beginning of the task FSM executing, or after the FSM has finished running. 
        See riglib.experiment.Experiment.run(). This 'run' method stops the NIDAQ sink after the FSM has stopped running.
        '''
        try:
            super(RelayPlexon, self).run()
        finally:
            # Stop the NIDAQ sink
            self.nidaq.stop()

            # Remotely stop the recording on the plexon box
            import comedi
            import config
            import time
            com = comedi.comedi_open("/dev/comedi0")
            time.sleep(0.5)
            comedi.comedi_dio_bitfield2(com, 0, 16, 16, 16)            
Ejemplo n.º 13
0
    def _end_reward(self):
        '''
        After the reward state has elapsed, turn off the solenoid

        Parameters
        ----------
        None

        Returns
        -------
        None
        '''
        import comedi
        subdevice = 0
        write_mask = 0x800000
        val = 0x000000
        base_channel = 0
        comedi.comedi_dio_bitfield2(self.com, subdevice, write_mask, 0x000000, base_channel)
    def pre_init(cls, saveid=None):
        '''
        Run prior to starting the task to remotely start recording from the plexon system
        '''
        if saveid is not None:
            import comedi
            import config
            import time

            com = comedi.comedi_open("/dev/comedi0")
            # stop any recording
            comedi.comedi_dio_bitfield2(com, 0, 16, 16, 16)
            time.sleep(0.1)
            # start recording
            comedi.comedi_dio_bitfield2(com, 0, 16, 0, 16)

            time.sleep(3)
            super(RelayPlexon, cls).pre_init(saveid=saveid)
Ejemplo n.º 15
0
    def _start_reward(self):
        '''
        At the start of the reward state, turn on the solenoid

        Parameters
        ----------
        None

        Returns
        -------
        None
        '''
        import comedi
        super(TTLReward, self)._start_reward()
        self.reportstats['Reward #'] = self.reportstats['Reward #'] + 1
        subdevice = 0
        write_mask = 0x800000
        val = 0x800000
        base_channel = 0
        comedi.comedi_dio_bitfield2(self.com, subdevice, write_mask, val, base_channel)
        self.reward_start = self.get_time() - self.start_time
    def run(self):
        '''
        Code to execute immediately prior to the beginning of the task FSM executing, or after the FSM has finished running. 
        See riglib.experiment.Experiment.run(). This 'run' method stops the NIDAQ sink after the FSM has finished running
        '''

        try:
            super(RelayBlackrock, self).run()
        finally:
            self.nidaq.stop()

            # Remotely stop the recording on the blackrock box
            import comedi
            import config
            import time
            com = comedi.comedi_open("/dev/comedi0")
            time.sleep(0.5)
            # strobe pin should already be low

            # set last data pin ("D15"; 16th pin) low
            comedi.comedi_dio_bitfield2(com, 0, 1, 0, 15)

            # set strobe pin high
            comedi.comedi_dio_bitfield2(com, 0, 1, 1, 16)

            # set strobe pin low
            comedi.comedi_dio_bitfield2(com, 0, 1, 0, 16)
Ejemplo n.º 17
0
    def run(self):
        '''
        Code to execute immediately prior to the beginning of the task FSM executing, or after the FSM has finished running. 
        See riglib.experiment.Experiment.run(). This 'run' method stops the NIDAQ sink after the FSM has finished running
        '''

        try:
            super(RelayBlackrock, self).run()
        finally:
            self.nidaq.stop()

            # Remotely stop the recording on the blackrock box
            import comedi
            import config
            import time
            com = comedi.comedi_open("/dev/comedi0")
            time.sleep(0.5)
            # strobe pin should already be low

            # set last data pin ("D15"; 16th pin) low
            comedi.comedi_dio_bitfield2(com, 0, 1, 0, 15)

            # set strobe pin high
            comedi.comedi_dio_bitfield2(com, 0, 1, 1, 16)

            # set strobe pin low
            comedi.comedi_dio_bitfield2(com, 0, 1, 0, 16)
    def pre_init(cls, saveid=None):
        if saveid is not None:
            import comedi
            import config
            import time

            com = comedi.comedi_open("/dev/comedi0")
            # set strobe pin low
            comedi.comedi_dio_bitfield2(com, 0, 1, 0, 16)

            # set last data pin ("D15"; 16th pin) high
            comedi.comedi_dio_bitfield2(com, 0, 1, 1, 15)

            # set strobe pin high
            comedi.comedi_dio_bitfield2(com, 0, 1, 1, 16)

            # set strobe pin low
            comedi.comedi_dio_bitfield2(com, 0, 1, 0, 16)

            time.sleep(3)
            super(RelayPlexon, cls).pre_init(saveid=saveid)
Ejemplo n.º 19
0
    def pre_init(cls, saveid=None):
        if saveid is not None:
            import comedi
            import config
            import time

            com = comedi.comedi_open("/dev/comedi0")
            # set strobe pin low
            comedi.comedi_dio_bitfield2(com, 0, 1, 0, 16)

            # set last data pin ("D15"; 16th pin) high
            comedi.comedi_dio_bitfield2(com, 0, 1, 1, 15)

            # set strobe pin high
            comedi.comedi_dio_bitfield2(com, 0, 1, 1, 16)

            # set strobe pin low
            comedi.comedi_dio_bitfield2(com, 0, 1, 0, 16)

            time.sleep(3)
            super(RelayPlexon, cls).pre_init(saveid=saveid)
Ejemplo n.º 20
0
import comedi
import time

com = comedi.comedi_open("/dev/comedi0")

for i in range(6):
    # set strobe pin low
    comedi.comedi_dio_bitfield2(com, 0, 1, 0, 16)
    time.sleep(1)

    # set strobe pin high
    comedi.comedi_dio_bitfield2(com, 0, 1, 1, 16)
    time.sleep(1)
import comedi
import time

com = comedi.comedi_open("/dev/comedi0")

# start (or resume) recording
print 'starting recording'

# set strobe pin low
comedi.comedi_dio_bitfield2(com, 0, 1, 0, 16)

# set last data pin ("D15"; 16th pin) high
comedi.comedi_dio_bitfield2(com, 0, 1, 1, 15)

# set strobe pin high
comedi.comedi_dio_bitfield2(com, 0, 1, 1, 16)

# set strobe pin low
comedi.comedi_dio_bitfield2(com, 0, 1, 0, 16)


print 'waiting for 5 seconds...'
time.sleep(5)

# stop recording
print 'stopping recording'

# strobe pin should already be low

# set last data pin ("D15"; 16th pin) low
comedi.comedi_dio_bitfield2(com, 0, 1, 0, 15)
import comedi
import time
com = comedi.comedi_open("/dev/comedi0")
time.sleep(0.010)
print "starting file recording"
comedi.comedi_dio_bitfield2(com,0,16,0,16)
print "Sleeping for 10 seconds"
import time
time.sleep(10)
print "Stopping file recording"
comedi.comedi_dio_bitfield2(com, 0, 16, 16, 16)
Ejemplo n.º 23
0
import comedi
import time

com = comedi.comedi_open("/dev/comedi0")

nchan = comedi.comedi_get_n_channels(com, 0)
print "found comedi system with %d channels" % nchan

for i in range(nchan):
	comedi.comedi_dio_config(com, 0, i, comedi.COMEDI_OUTPUT)

for i in range(4):
	comedi.comedi_dio_bitfield2(com, 0, 1, 1, 0)
	time.sleep(1)

	comedi.comedi_dio_bitfield2(com, 0, 1, 0, 0)
	time.sleep(1)
Ejemplo n.º 24
0
 def get_data(self):
     return comedi.comedi_dio_bitfield2(self.device, self.subdevice, self.write_mask, 0, self.base_channel)
Ejemplo n.º 25
0
 def put_data(self,data):
     comedi.comedi_dio_bitfield2(self.device, self.subdevice, self.write_mask, data, self.base_channel)
Ejemplo n.º 26
0
 def __del__(self):
     """Set output bits low when closing."""
     comedi.comedi_dio_bitfield2(self.device, self.subdevice, self.write_mask, 0, self.base_channel)
 def _end_pulse(self):
     subdevice = 0
     write_mask = 0x800000
     val = 0x000000
     base_channel = 0
     comedi.comedi_dio_bitfield2(self.com, subdevice, write_mask, val, base_channel)