Esempio n. 1
0
def SetDO(NoDev, NoSubDev, Name):
    #Get number of lines
    meNumberChannels = meDriver.meQueryNumberChannels(NoDev, NoSubDev)
    #Get CAPS (capability flags)
    meCAPS = meDriver.meQuerySubdeviceCaps(NoDev, NoSubDev)
    #Configure output type
    if (meCAPS & meDriver.ME_CAPS_DIO_SINK_SOURCE) == meDriver.ME_CAPS_DIO_SINK_SOURCE:
        #User has to shows hardware configuration
        DIO_Output_Type = GetOutputType(NoDev, NoSubDev, Name)
    else:
        #Use default
        DIO_Output_Type = meDriver.ME_SINGLE_CONFIG_DIO_OUTPUT

    #Configure sub-device for output
    meDriver.meIOSingleConfig(NoDev, NoSubDev, 0, DIO_Output_Type, meDriver.ME_REF_NONE, meDriver.ME_TRIG_CHAN_NONE, meDriver.ME_TRIG_TYPE_NONE, meDriver.ME_TRIG_EDGE_NONE, meDriver.ME_IO_SINGLE_NO_FLAGS)
    for meNoChannels in range(meNumberChannels):
        #Write to sub-device
        SingleDict = {
            'Device':   NoDev,
            'Subdevice':    NoSubDev,
            'Channel':  0,
            'Dir':      meDriver.ME_DIR_OUTPUT,
            'Value':    0x01 << meNoChannels,
            'TimeOut':  meDriver.ME_VALUE_NOT_USED,
            'Flags':    meDriver.ME_IO_SINGLE_TYPE_NO_FLAGS,
            'Errno':    0
        }
        SingleList = [SingleDict]
        meDriver.meIOSingle(SingleList, meDriver.ME_IO_SINGLE_NO_FLAGS)
        #Read back
        GetDO(NoDev, NoSubDev, Name)
        time.sleep(1)
Esempio n. 2
0
def main():
    try:
        #Initialization of driver
        meDriver.meOpen(meDriver.ME_OPEN_NO_FLAGS)
        #Get library version
        LibVer = meDriver.meQueryVersionLibrary()
        LibVer_Special = LibVer / 0x1000000
        LibVer_API = LibVer / 0x10000
        LibVer_Relase = LibVer / 0x100
        LibVer_Compilation = LibVer
        print "Library version is %02x.%02x.%02x.%02x" % (LibVer_Special%0xFF, LibVer_API&0xFF, LibVer_Relase&0xFF, LibVer_Compilation&0xFF)
        #Get main driver version
        DrvVer = meDriver.meQueryVersionMainDriver()
        DrvVer_Special = DrvVer / 0x1000000
        DrvVer_API = DrvVer / 0x10000
        DrvVer_Relase = DrvVer / 0x100
        DrvVer_Compilation = DrvVer
        print "Main driver version is %02x.%02x.%02x.%02x" % (DrvVer_Special&0xFF, DrvVer_API&0xFF, DrvVer_Relase&0xFF, DrvVer_Compilation&0xFF)
        #Get number of registered devices
        meNumberDevices = meDriver.meQueryNumberDevices()
        print "%i devices in system" % (meNumberDevices)
        print
        for meNoDevices in range(meNumberDevices):
            meNumberSubdevices = meDriver.meQueryNumberSubdevices(meNoDevices)
            try:
                meNoSubdevices = 0
                while meNoSubdevices<meNumberSubdevices:
                    #Get all analog input sub-devices
                    meNoSubdevices = meDriver.meQuerySubdeviceByType(meNoDevices, meNoSubdevices, meDriver.ME_TYPE_AI, meDriver.ME_SUBTYPE_ANY)
                    try:
                        meNumberChannels = meDriver.meQueryNumberChannels(meNoDevices,  meNoSubdevices)
                    except meDriver.error:
                        meNumberChannels = 0
                    for meNoChannels in range(meNumberChannels):
                        #Do test for each channel
                        GetAI(meNoDevices, meNoSubdevices,   meNoChannels)
                    meDriver.meIOResetSubdevice(meNoDevices, meNoSubdevices, meDriver.ME_VALUE_NOT_USED)
                    meNoSubdevices = meNoSubdevices + 1
            except meDriver.error:
                pass

    except meDriver.error, Val:
        print sys.exc_info()
        print Val
Esempio n. 3
0
def main():
    try:
        #Initialization of ME-iDS
        meDriver.meOpen(meDriver.ME_OPEN_NO_FLAGS)
        #Get library version
        LibVer = meDriver.meQueryVersionLibrary()
        LibVer_Special = LibVer / 0x1000000
        LibVer_API = LibVer / 0x10000
        LibVer_Relase = LibVer / 0x100
        LibVer_Compilation = LibVer
        print "Library version is %02x.%02x.%02x.%02x" % (LibVer_Special%0xFF, LibVer_API&0xFF, LibVer_Relase&0xFF, LibVer_Compilation&0xFF)
        #Get number of registered devices
        meNumberDevices = meDriver.meQueryNumberDevices()
        if meNumberDevices > 0:
            #Get main driver version
            DrvVer = meDriver.meQueryVersionMainDriver()
            DrvVer_Special = DrvVer / 0x1000000
            DrvVer_API = DrvVer / 0x10000
            DrvVer_Relase = DrvVer / 0x100
            DrvVer_Compilation = DrvVer
            print "Main driver version is %02x.%02x.%02x.%02x" % (DrvVer_Special&0xFF, DrvVer_API&0xFF, DrvVer_Relase&0xFF, DrvVer_Compilation&0xFF)
            print "%i devices detected by driver system" % (meNumberDevices)

            for meNoDevices in range(meNumberDevices):
                #For each device get: 
                # - device name
                # - device description
                # - driver name
                # - driver version
                # - number sub-devices
                print
                print "Device %i:" % (meNoDevices)
                print "========="
                print "Device name is %s" % (meDriver.meQueryNameDevice(meNoDevices))
                print "Driver name is %s" % (meDriver.meQueryNameDeviceDriver(meNoDevices))
                print "Device description: %s" % (meDriver.meQueryDescriptionDevice(meNoDevices))
                DrvVer = meDriver.meQueryVersionDeviceDriver(meNoDevices)
                DrvVer_Special = DrvVer / 0x1000000
                DrvVer_API = DrvVer / 0x10000
                DrvVer_Relase = DrvVer / 0x100
                DrvVer_Compilation = DrvVer
                print "Device driver version is %02x.%02x.%02x.%02x" % (DrvVer_Special&0xFF, DrvVer_API&0xFF, DrvVer_Relase&0xFF, DrvVer_Compilation&0xFF)

                meNumberSubdevices = meDriver.meQueryNumberSubdevices(meNoDevices)
                for meNoSubdevices in range(meNumberSubdevices):
                    #For each sub-device get: 
                    # - type
                    # - sub-type
                    (meType, meSubType) = meDriver.meQuerySubdeviceType(meNoDevices, meNoSubdevices)
                    print "\tSubdevice %d is of type %s (0x%X) and subtype %s (0x%X)" % (meNoSubdevices, typeDevice[meType], meType , typeSubdevice[meSubType], meSubType);
                    print "\t\tSubdevice %d has %d channels" % (meNoSubdevices, meDriver.meQueryNumberChannels(meNoDevices, meNoSubdevices));
                    if (meType == meDriver.ME_TYPE_AI) or (meType == meDriver.ME_TYPE_AO):
                        #For  AI and AO sub-device get number ranges 
                        meNumberRanges = meDriver.meQueryNumberRanges(meNoDevices, meNoSubdevices, meDriver.ME_UNIT_ANY);
                        print "\t\tSubdevice %d has %d ranges:" % (meNoSubdevices, meNumberRanges);
                        for meNoRanges in range(meNumberRanges):
                            (meUnit,  meMin,  meMax,  meMax_data) = meDriver.meQueryRangeInfo(meNoDevices, meNoSubdevices,  meNoRanges)
                            print "\t\t\tRange %d: Unit = 0x%X, Min = %lf, Max = %lf, Max Data = %d" %(meNoRanges, meUnit,  meMin,  meMax,  meMax_data);

    except meDriver.error, Val:
        print sys.exc_info()
        print Val