def getROI(self): wRoiX0 = wintypes.WORD() wRoiY0 = wintypes.WORD() wRoiX1 = wintypes.WORD() wRoiY1 = wintypes.WORD() err = self.f_getROI(self.hcam, byref(wRoiX0), byref(wRoiY0), byref(wRoiX1), byref(wRoiY1)) return (err, (wRoiX0.value, wRoiY0.value, wRoiX1.value, wRoiY1.value))
def addBuffer(self, imageFirst, imageLast, buffer_number, xres, yres, bpp): dwImageFirst = wintypes.DWORD(imageFirst) dwImageLast = wintypes.DWORD(imageLast) sBuf = wintypes.SHORT(buffer_number) wXRes = wintypes.WORD(xres) wYRes = wintypes.WORD(yres) wBPP = wintypes.WORD(bpp) return self.f_add(self.hcam, dwImageFirst, dwImageLast, sBuf, wXRes, wYRes, wBPP)
def getImage(self, segment, imageFirst, imageLast, buffer_number, xres, yres, bpp): wseg = wintypes.WORD(segment) dwFirst = wintypes.DWORD(imageFirst) dwLast = wintypes.DWORD(imageLast) sBuf = wintypes.SHORT(buffer_number) wXRes = wintypes.WORD(xres) wYRes = wintypes.WORD(yres) wBPP = wintypes.WORD(bpp) return self.f_getImage(self.hcam, wseg, dwFirst, dwLast, sBuf, wXRes, wYRes, wBPP)
def get_library_version(split=False): if split: major = wintypes.WORD(0) minor = wintypes.WORD(0) release = wintypes.WORD(0) build = wintypes.WORD(0) ret = virtualMIDIGetVersion(ctypes.byref(major), ctypes.byref(minor), ctypes.byref(release), ctypes.byref(build)) return (major.value, minor.value, release.value, build.value) ret = virtualMIDIGetVersion(None, None, None, None) return ret
def FillConsoleOutputAttribute( std_handle: wintypes.HANDLE, attributes: int, length: int, start: WindowsCoordinates, ) -> int: """Sets the character attributes for a specified number of character cells, beginning at the specified coordinates in a screen buffer. Args: std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer. attributes (int): Integer value representing the foreground and background colours of the cells. length (int): The number of cells to set the output attribute of. start (WindowsCoordinates): The coordinates of the first cell whose attributes are to be set. Returns: int: The number of cells whose attributes were actually set. """ num_cells = wintypes.DWORD(length) style_attrs = wintypes.WORD(attributes) num_written = wintypes.DWORD(0) _FillConsoleOutputAttribute( std_handle, style_attrs, num_cells, start, byref(num_written) ) return num_written.value
def changeColor(color, defaultBg=True, background=0): handle = windll.kernel32.GetStdHandle(-11) csbi = CONSOLE_SCREEN_BUFFER_INFO() if defaultBg: GetConsoleScreenBufferInfo(handle, byref(csbi)) background = csbi.wAttributes & 0x0070 color = color | background color = wintypes.WORD(color) SetConsoleTextAttribute(handle, color)
def FillConsoleOutputAttribute(stream_id, attr, length, start): ''' FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten )''' handle = _GetStdHandle(stream_id) attribute = wintypes.WORD(attr) length = wintypes.DWORD(length) num_written = wintypes.DWORD(0) # note that this is hard-coded for ANSI (vs wide) bytes. return _FillConsoleOutputAttribute(handle, attribute, length, start, byref(num_written))
def CalGetConstants(self, channel, gain, AdcRange): """Retrieves the calibration constants from the currently selected calibration table chosen by the daqCalSelectCalTable function.""" gainConstant = wt.WORD(0) offsetConstant = ct.c_short(0) err = daq.daqCalGetConstants( self.handle, wt.WORD(channel), gain, AdcRange, ct.pointer(gainConstant), ct.pointer(offsetConstant), ) if err != 0: raise DaqError(err) return gainConstant.value, offsetConstant.value
def AdcSetTrig(self, triggerSource, rising, level, hysteresis, channel): """Configures the device for enhanced triggering""" level = wt.WORD(level) hysteresis = wt.DWORD(hysteresis) channel = wt.DWORD(channel) err = daq.daqAdcSetTrig(self.handle, triggerSource, rising, level, hysteresis, channel) if err != 0: raise DaqError(err)
def DacWt(self, deviceType, chan, dataVal): """Sets the output value of a local or expansion DAC channel""" #Very specific to the daqboard2k series...should be fixed #Setup so you can just pass a voltage in. if dataVal >= 10.0: dataVal = 65535 if dataVal <= -10.0: dataVal = 0 else: dataVal = (dataVal + 10.0) / (20.0 / 65535) err = daq.daqDacWt(self.handle, deviceType, chan, wt.WORD(int(dataVal))) if err != 0: raise DaqError(err)
def camlinkSetParams(self, xres, yres): wXRes = wintypes.WORD(xres) wYRes = wintypes.WORD(yres) return self.f_camlink(self.hcam, wXRes, wYRes)
def getRecordingState(self): state = wintypes.WORD() err = self.f_getrecord(self.hcam, byref(state)) return state.value
def setRecordingState(self, state): # state = 0x0001 to run; 0x0000 to stop # return self.f_record(self.hcam, wintypes.WORD(state))
def getRecorderSubmode(self): wMode = wintypes.WORD() err = self.f_getrecordersubmode(self.hcam, byref(wMode)) return (err, wMode.value)
def getStorageMode(self): wMode = wintypes.WORD() err = self.f_getstoragemode(self.hcam, byref(wMode)) return (err, wMode.value)
def FillConsoleOutputAttribute(handle, attr, length, start): attribute = wintypes.WORD(attr) length = wintypes.DWORD(length) return _FillConsoleOutputAttribute(handle, attribute, length, start, byref(wintypes.DWORD()))
def setROI(self, x0, y0, x1, y1): return self.f_setROI(self.hcam, wintypes.WORD(x0), wintypes.WORD(y0), wintypes.WORD(x1), wintypes.WORD(y1))
def setDelayExposureTime(self, delay, exposure, delay_base, exp_base): return self.f_settimes(self.hcam, wintypes.DWORD(delay), wintypes.DWORD(exposure), wintypes.WORD(delay_base), wintypes.WORD(exp_base))
def AdcRd(handle, chan, sample, gain, flags): sample_WORD = wt.WORD() CHK(daq.daqAdcRd(handle, chan, ct.byref(sample_WORD), gain, flags)) return sample_WORD.value