Пример #1
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 digital output sub-devices
                    meNoSubdevices = meDriver.meQuerySubdeviceByType(meNoDevices, meNoSubdevices, meDriver.ME_TYPE_DO, meDriver.ME_SUBTYPE_ANY)
                    SetDO(meNoDevices, meNoSubdevices,  "DO")
                    meNoSubdevices = meNoSubdevices + 1
            except meDriver.error:
                pass
            try:
                meNoSubdevices = 0
                while meNoSubdevices < meNumberSubdevices:
                    #Get all digital input/output sub-devices
                    meNoSubdevices = meDriver.meQuerySubdeviceByType(meNoDevices, meNoSubdevices, meDriver.ME_TYPE_DIO, meDriver.ME_SUBTYPE_ANY)
                    SetDO(meNoDevices, meNoSubdevices,  "DIO")
                    meNoSubdevices = meNoSubdevices + 1
            except meDriver.error:
                pass

    except meDriver.error, Val:
        print sys.exc_info()
        print Val
Пример #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
Пример #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