MCPcopy Create free account
hub / github.com/LabPy/lantz / eDigitalIn

Method eDigitalIn

lantz/drivers/labjack/_internal/u12.py:2009–2059  ·  view source on GitHub ↗

Name: U12.eDigitalIn(channel, idNum = None, demo = 0, readD=0) Args: See section 4.4 of the User's Guide Desc: This is a simplified version of DigitalIO that reads the state of one digital input. Also configures the requested pin to input and leav

(self, channel, idNum = None, demo = 0, readD=0)

Source from the content-addressed store, hash-verified

2007
2008
2009 def eDigitalIn(self, channel, idNum = None, demo = 0, readD=0):
2010 """
2011 Name: U12.eDigitalIn(channel, idNum = None, demo = 0, readD=0)
2012 Args: See section 4.4 of the User's Guide
2013 Desc: This is a simplified version of DigitalIO that reads the state of
2014 one digital input. Also configures the requested pin to input and
2015 leaves it that way.
2016
2017 >>> import u12
2018 >>> d = u12.U12()
2019 >>> d.eDigitalIn(0)
2020 {'state': 0, 'idnum': 1}
2021 """
2022
2023 # Check id num
2024 if idNum is None:
2025 idNum = self.id
2026
2027 if ON_WINDOWS:
2028 ljid = ctypes.c_long(idNum)
2029 state = ctypes.c_long(999)
2030
2031 ecode = staticLib.EDigitalIn(ctypes.byref(ljid), demo, channel, readD, ctypes.byref(state))
2032
2033 if ecode != 0: raise U12Exception(ecode)
2034
2035 return {"idnum":ljid.value, "state":state.value}
2036 else:
2037 oldstate = self.rawDIO()
2038
2039 if readD:
2040 if channel > 7:
2041 channel = channel-8
2042 direction = BitField(rawByte = int(oldstate['D15toD8Directions']))
2043 direction[7-channel] = 1
2044
2045 results = self.rawDIO(D15toD8Directions = direction, UpdateDigital = True)
2046
2047 state = results['D15toD8States'][7-channel]
2048
2049 else:
2050 direction = BitField(rawByte = int(oldstate['D7toD0Directions']))
2051 direction[7-channel] = 1
2052 results = self.rawDIO(D7toD0Directions = direction, UpdateDigital = True)
2053
2054 state = results['D7toD0States'][7-channel]
2055 else:
2056 results = self.rawDIO(IO3toIO0DirectionsAndStates = 255, UpdateDigital = True)
2057 state = results['IO3toIO0States'][3-channel]
2058
2059 return {"idnum" : self.id, "state" : state}
2060
2061 def eDigitalOut(self, channel, state, idNum = None, demo = 0, writeD=0):
2062 """

Callers 1

digital_in_outMethod · 0.45

Calls 3

rawDIOMethod · 0.95
U12ExceptionClass · 0.70
BitFieldClass · 0.70

Tested by

no test coverage detected