コード例 #1
0
ファイル: ao_single.tst.py プロジェクト: imrehg/meids
def GetAO(NoDev, NoSubDev, NoChannel):
    #Using range 0
    (iUnit, dMin, dMax, iMaxData) = meDriver.meQueryRangeInfo(NoDev, NoSubDev, 0)
    #Read from sub-device
    SingleDict = {
        'Device':   NoDev,
        'Subdevice':    NoSubDev,
        'Channel':  NoChannel,
        'Dir':      meDriver.ME_DIR_INPUT,
        'Value':    0,
        '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)
    print "Device [%d:%d/%d] GET:%f(0x%x)" % (NoDev, NoSubDev, NoChannel,  meDriver.meUtilityDigitalToPhysical(dMin, dMax, iMaxData, SingleList[0]['Value'], meDriver.ME_MODULE_TYPE_MULTISIG_NONE, 0),  SingleList[0]['Value'])
コード例 #2
0
ファイル: ai_stream.tst.py プロジェクト: imrehg/meids
def GetStreamAI(NoDev, NoSubDev):
    DataBlockSize = 0x10000
    DataReadSize = 0x1000
    AIBufSize = 0x400
    
    #Preaparing trigger list
    TrigList = {'AcqStartTrigType'	: meDriver.ME_TRIG_TYPE_SW,
                    'AcqStartTrigEdge'	: meDriver.ME_TRIG_EDGE_NONE,
                    'AcqStartTrigChan'	: meDriver.ME_TRIG_CHAN_DEFAULT,
                    'AcqStartTicks'	: long(66),
                    'ScanStartTrigType'	: meDriver.ME_TRIG_TYPE_TIMER,
                    'ScanStartTicks'	: long(66),
                    'ConvStartTrigType'	: meDriver.ME_TRIG_TYPE_TIMER,
                    'ConvStartTicks'	: long(33000),    #1kHz
                    'ScanStopTrigType'	: meDriver.ME_TRIG_TYPE_NONE,
                    'ScanStopCount'	: 0,
                    'AcqStopTrigType'	: meDriver.ME_TRIG_TYPE_COUNT,
                    'AcqStopCount'	: DataBlockSize,
                    'Flags'		: meDriver.ME_IO_STREAM_TRIGGER_TYPE_NO_FLAGS}
    #Preaparing config list
    ConfList = []
    ConfEntry = {'Channel': 0,
                    'StreamConfig': 0,
                    'Ref': meDriver.ME_REF_AI_GROUND,
                    'Flags': meDriver.ME_IO_STREAM_CONFIG_TYPE_NO_FLAGS}
    ConfList.append(ConfEntry)
    #Preaparing start list
    StartList = []
    StartEntry = {'Device': NoDev,
                 'Subdevice': NoSubDev,
                 'StartMode': meDriver.ME_START_MODE_BLOCKING,	#This is returning when stream STARTS!
                 'TimeOut': 0,
                 'Flags': meDriver.ME_IO_STREAM_START_TYPE_NO_FLAGS, 
                 'Errno': 0}
    StartList.append(StartEntry)

    #Preaparing stop list
    StopList = []
    StopEntry = {'Device': NoDev,
                    'Subdevice': NoSubDev,
                    'StopMode': meDriver.ME_STOP_MODE_IMMEDIATE,
                    'Flags': meDriver.ME_IO_STREAM_STOP_TYPE_NO_FLAGS,
                    'Errno': 0}
    StopList.append(StopEntry)

    #Using range 0
    (iUnit, dMin, dMax, iMaxData) = meDriver.meQueryRangeInfo(NoDev, NoSubDev, 0)
    
    meDriver.meIOResetSubdevice(NoDev, NoSubDev, meDriver.ME_VALUE_NOT_USED)
    #Configure
    print "Configure AI"
    meDriver.meIOStreamConfig(NoDev, NoSubDev, ConfList, TrigList, AIBufSize, meDriver.ME_IO_STREAM_CONFIG_NO_FLAGS)
    print "Start AI"
    meDriver.meIOStreamStart(StartList, meDriver.ME_IO_STREAM_START_NO_FLAGS)
    
    print "Work"
    totalCount = 0
    while (totalCount<DataBlockSize):
        #Read data (blocking mode)
        AIBufferCount=AIBufSize
        AIBuffer = meDriver.meIOStreamRead(NoDev, NoSubDev, meDriver.ME_READ_MODE_BLOCKING, AIBufferCount, meDriver.ME_IO_STREAM_READ_NO_FLAGS)
        #Show some samples
        print "\tSample 0x%x => %f" % (totalCount,  meDriver.meUtilityDigitalToPhysical( dMin, dMax, iMaxData, AIBuffer[0], meDriver.ME_MODULE_TYPE_MULTISIG_NONE, 0))
        totalCount = totalCount + len(AIBuffer)
    
    print "Stop AI"
    meDriver.meIOStreamStop(StopList, meDriver.ME_IO_STREAM_STOP_NO_FLAGS)
    print "AI stopped."