def led_off(): BoardNum = 0 PortNum = UL.FIRSTPORTB Direction = UL.DIGITALOUT UL.cbDConfigPort (BoardNum, PortNum, Direction) DataValue = 0 UL.cbDOut(BoardNum, PortNum, DataValue)
def postFlip(self, args): if self.needToSendStimcode: #record the time at the first flip self.triggerTimes.append(self.timer.getTime()) #Tell CED to read stimcode #this costs 1.2ms (+/- 0.1ms). UL.cbDOut(self.boardNum,UL.FIRSTPORTB,0) #Only need to do this once per stim self.needToSendStimcode = False
def led_on(): BoardNum = 0 PortNum = UL.FIRSTPORTB Direction = UL.DIGITALOUT UL.cbDConfigPort (BoardNum, PortNum, Direction) DataValue = 1 UL.cbDOut(BoardNum, PortNum, DataValue) sound_1 = sound.SoundPyo(value='C', secs=0.5, octave=4, stereo=True, volume=1.0, loops=0, sampleRate=44100, bits=16, hamming=True, start=0, stop=-1, name='', autoLog=True) sound_1.play()
def toggle(self): if self.success: if self.dir==1: #OUT if self.currentState==self.HIGH: UL.cbDOut(0, self.port, self.LOW) self.currentState=self.LOW else: UL.cbDOut(0, self.port, self.HIGH) self.currentState=self.HIGH
def get_reward(PORTNUM): BoardNum = 0 PortNum = PORTNUM Direction = UL.DIGITALOUT UL.cbDConfigPort (BoardNum, PortNum, Direction) DataValue = 1 UL.cbDOut(BoardNum, PortNum, DataValue) time.sleep(.07) BoardNum = 0 PortNum = PORTNUM Direction = UL.DIGITALOUT UL.cbDConfigPort (BoardNum, PortNum, Direction) DataValue = 0 UL.cbDOut(BoardNum, PortNum, DataValue)
def preStim(self, args): stimNumber = args #record the stim number we're about to display self.stimCodes.append(stimNumber) #send stimcode to CED via measurement computing UL.cbDOut(self.boardNum,UL.FIRSTPORTA,stimNumber) UL.cbDOut(self.boardNum,UL.FIRSTPORTB,1) #wait for 2pt frame trigger self.waitForSerial() #Tell ourselves to send the signal the CED as soon as we flip self.needToSendStimcode = True
def get_reward(PORTNUM): print 'reward' BoardNum = 0 PortNum = PORTNUM Direction = UL.DIGITALOUT UL.cbDConfigPort (BoardNum, PortNum, Direction) DataValue = 1 UL.cbDOut(BoardNum, PortNum, DataValue) #sound_1 = sound.SoundPyo(value='C', secs=0.5, octave=4, stereo=True, volume=1.0, loops=0, sampleRate=44100, bits=16, hamming=True, start=0, stop=-1, name='', autoLog=True) #sound_1.play() time.sleep(.1) #time BoardNum = 0 PortNum = PORTNUM Direction = UL.DIGITALOUT UL.cbDConfigPort (BoardNum, PortNum, Direction) DataValue = 0 UL.cbDOut(BoardNum, PortNum, DataValue)
def preStim(self, args): stimNumber = args #send stimcode to CED via measurement computing UL.cbDOut(self.boardNum,UL.FIRSTPORTA,stimNumber) UL.cbDOut(self.boardNum,UL.FIRSTPORTB,1) #wait for 2pt frame trigger self.waitForSerial() self.triggerTimes.append(self.timer.getTime()) self.stimCodes.append(stimNumber) #Tell CED to read stimcode #this costs 1.2ms (+/- 0.1ms). UL.cbDOut(self.boardNum,UL.FIRSTPORTB,0)
def trigger(self, reset_time=-1): """Triggers a digital signal. :param reset_time: Time (in seconds) to pass until reset the value. \ If the reset_time will not set, the trigger will change \ the electrical voltage. :type reset_time: float. :returns: True if the signal was sent, False otherwise. :rtype: bool :raises: ValueError, ctypes.ArgumentError """ if reset_time < -1: raise ValueError("Invalid value: Value must positive") value = 0 if self.value == 255 else 255 if reset_time != -1: UL.cbDOut(self.board.id, self.id, value) sleep(reset_time) UL.cbDOut(self.board.id, self.id, self.value) else: UL.cbDOut(self.board.id, self.id, value) self.value = value return True
def Reset(): '''Set all digital channels (the entire port) to 0V output''' UL.cbDConfigPort(BoardNum, PortNum, UL.DIGITALOUT) UL.cbDOut(BoardNum, PortNum, 0)
def off(self): if self.success: if self.dir==1: #OUT self.currentState=self.LOW UL.cbDOut(0, self.port, self.LOW)
def on(self): #print 'ON: %s, %s' % (str(self.success),str(self.dir)) if self.success: if self.dir==1: #OUT self.currentState=self.HIGH UL.cbDOut(0, self.port, self.HIGH)
# Author: Andrew Straw import UniversalLibrary as UL BoardNum = 0 devNum = 0 FirstPort = 0 FirstPort = UL.cbGetConfig(UL.DIGITALINFO, BoardNum, devNum, UL.DIDEVTYPE, FirstPort) PortNum = UL.FIRSTPORTA Direction = UL.DIGITALOUT UL.cbDConfigPort(BoardNum, PortNum, Direction) DataValue = 0 UL.cbDOut(BoardNum, PortNum, DataValue) if FirstPort == UL.AUXPORT: devNum = 1 UL.cbGetConfig(UL.DIGITALINFO, BoardNum, devNum, UL.DIDEVTYPE, FirstPort) if FirstPort == UL.FIRSTPORTA: FirstBit = 0 elif FirstPort == UL.FIRSTPORTB: FirstBit = 8 elif FirstPort == UL.FIRSTPORTCL: FirstBit = 16 elif FirstPort == UL.FIRSTPORTCH: FirstBit = 20 else: FirstBit = 0
# disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the California Institute of Technology nor # the names of its contributors may be used to endorse or promote # products derived from this software without specific prior # written permission. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # Author: Andrew Straw import UniversalLibrary as UL BoardNum = 0 PortNum = UL.FIRSTPORTA Direction = UL.DIGITALOUT UL.cbDConfigPort(BoardNum, PortNum, Direction) DataValue = 0 UL.cbDOut(BoardNum, PortNum, DataValue)
def __init__(self, board, port_id, name, edit_dialog): super(PortDO, self).__init__(board, port_id, name) self.edit_dialog = edit_dialog self.value = 0 UL.cbDConfigPort(board.id, self.id, UL.DIGITALOUT) UL.cbDOut(self.board.id, self.id, self.value)