-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCorduroy_DAQ_traceplot.ipf
executable file
·440 lines (358 loc) · 16.7 KB
/
Corduroy_DAQ_traceplot.ipf
1
#pragma rtGlobals=2 // Use modern global access method.///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// CORDUROY_DAQ_traceplot// Please see READ-ME for relevant notes and information////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_ChanMon(ctrlName) : ButtonControl///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string ctrlName string thisDF = GetDataFolder(1) // What channel is this? string MonStateG = "root:DAQ:Classes:Displays:MonState_A"// Get the global state value and decide to start or stop NVAR MonState = $MonStateG // Call the monitorACQ function MonState = !MonState CORD_monACQ(MonState) string Titles = "monitor;pause" Button $ctrlName title=StringFromList(MonState,Titles) SetDataFolder thisDFEnd/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_monACQ(Flag)///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// variable Flag // Update the amp state CORD_ReadAmpState("Multiclamp700B",1) NVAR totalchan = root:DAQ:Classes:Displays:totalchan if(Flag) CtrlFIFO TheFIFO, start switch(totalchan) case 2: DAQmx_Scan /DEV="Dev1" FIFO="TheFIFO; 0, -5, 5, 1, 0; 1, -5, 5, 1, 0;" break case 4: DAQmx_Scan /DEV="Dev1" FIFO="TheFIFO; 0, -5, 5, 1, 0; 1, -5, 5, 1, 0; 2, -5, 5, 1, 0; 3, -5, 5, 1, 0;" break case 8: DAQmx_Scan /DEV="Dev1" FIFO="TheFIFO; 0, -5, 5, 1, 0; 1, -5, 5, 1, 0; 2, -5, 5, 1, 0; 3, -5, 5, 1, 0; 5, -5, 5, 1, 0; 6, -5, 5, 1, 0; 7, -5, 5, 1, 0; 8, -5, 5, 1, 0;" break case 1: DAQmx_Scan /DEV="Dev1" FIFO="TheFIFO; 0, -5, 5, 1, 0;" break endswitch else fDAQmx_ScanStop("Dev1") CtrlFIFO TheFIFO, stop endif End/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_MonResize(ctrlName) : ButtonControl///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string ctrlName variable index=0 string TmpGlbRef="" TmpGlbRef = "root:DAQ:Classes:Displays:Channel_A_ymin_gvar" NVAR yminG = $TmpGlbRef TmpGlbRef = "root:DAQ:Classes:Displays:Channel_A_ymax_gvar" NVAR ymaxG = $TmpGlbRef NVAR totalchan = root:DAQ:Classes:Displays:totalchan for(index=0;index<totalchan;index+=1) Chart TheChart, gain(index)=yminG Chart TheChart, offset(index)=ymaxG endfor End/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_MonStore(ctrlName) : ButtonControl///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string ctrlName string currDF = GetDataFolder(1) string ChannelList = "A;B;C;D;E;F;G;H" NVAR FIFOsize = root:DAQ:Classes:Displays:FIFOsize SetDataFolder root:DAQ:Classes:Displays:// Set up file naming string thisDF = GetDataFolder(1) SVAR baseName = root:DAQ:General:baseName NVAR FileCnt = root:DAQ:General:FileCnt string NextFile = "root:"+baseName+num2str(FileCnt) variable index=0 string TmpWaveName="", write_out_fifo="", MoveWaveString="" NVAR totalchan = root:DAQ:Classes:Displays:totalchan NVAR ChAscaling = root:DAQ:Classes:Amplifiers:Channel_A_scaling NVAR ChBscaling = root:DAQ:Classes:Amplifiers:Channel_B_scaling Make/N=4 scaling = {ChAscaling,ChBscaling,1,1} for(index=0;index<totalchan;index+=1) // Dump the data into temporary files (LOOP THROUGH TOTAL CHANNELS AND STORE THE DATA Make/O/N=(FIFOsize) temp_storeA write_out_fifo = "FIFO2Wave TheFIFO, chan"+StringFromList(index, ChannelList)+", temp_storeA" Execute write_out_fifo if(index<4) temp_storeA = temp_storeA / scaling[index] endif // Rename to the correct name within the current day's experiment stack if(index==0) NewDataFolder $NextFile endif MoveWaveString = NextFile+":Record"+StringFromList(index, ChannelList)+"0" MoveWave temp_storeA, $MoveWaveString endfor// Update the recording with some details about the acquisition CORD_UpdateELNdata(1) WAVE/T AmpSettings = root:ExpDetails:AmpSettings MoveWaveString = NextFile+":AmpSettings" Duplicate/O AmpSettings, $MoveWaveString WAVE/T ELNvalues = root:ExpDetails:ELNvalues ELNvalues[26] = "MonAcq" ELNvalues[27] = "" ELNvalues[29] = "" ELNvalues[30] = "" MoveWaveString = NextFile+":ELNvalues" Duplicate/O ELNvalues, $MoveWaveString WAVE/T ELNlabels = root:ExpDetails:ELNlabels MoveWaveString = NextFile+":ELNlabels" Duplicate/O ELNlabels, $MoveWaveString // Increment the file counter FileCnt += 1// Update panels to reflect new recording CORD_UpdateRecWaves() SetDataFolder thisDFEnd/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_MonRec(ctrlName) : ButtonControl///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string ctrlName // Update the amp state CORD_ReadAmpState("Multiclamp700B",1) NVAR totalchan = root:DAQ:Classes:Displays:totalchan string thisDF = GetDataFolder(1) // What channel is this? string RecStateG = "root:DAQ:Classes:Displays:RecState" string CurrRecG = "root:DAQ:Classes:Displays:CurrRec"// Get the global state value and decide to start or stop NVAR RecState = $RecStateG NVAR CurrRec = $CurrRecG SVAR baseName = root:DAQ:General:baseName // Set up to record to a new file if necessary RecState = !RecState CurrRec += 1 if(RecState) variable/G root:FIFOrefNUM NVAR FIFOrefNUM = root:FIFOrefNUM string Name = baseName+"CR"+num2str(CurrRec)+".crd" Open/P=DataPath FIFOrefNUM as Name CtrlFIFO TheFIFO, file=FIFOrefNUM CtrlFIFO TheFIFO, start switch(totalchan) case 2: DAQmx_Scan /DEV="Dev1" FIFO="TheFIFO; 0, -5, 5, 1, 0; 1, -5, 5, 1, 0;" break case 4: DAQmx_Scan /DEV="Dev1" FIFO="TheFIFO; 0, -5, 5, 1, 0; 1, -5, 5, 1, 0; 2, -5, 5, 1, 0; 3, -5, 5, 1, 0;" break case 8: DAQmx_Scan /DEV="Dev1" FIFO="TheFIFO; 0, -5, 5, 1, 0; 1, -5, 5, 1, 0; 2, -5, 5, 1, 0; 3, -5, 5, 1, 0; 5, -5, 5, 1, 0; 6, -5, 5, 1, 0; 7, -5, 5, 1, 0; 8, -5, 5, 1, 0;" break case 1: DAQmx_Scan /DEV="Dev1" FIFO="TheFIFO; 0, -5, 5, 1, 0;" break endswitch else fDAQmx_ScanStop("Dev1") CtrlFIFO TheFIFO, stop NVAR FIFOrefNUM = root:FIFOrefNUM Close FIFOrefNUM // Easiest reset is to recreate the FIFO to prevent a bad FIFO file reference CORD_CreateChart(totalchan) endif string Titles = "record;stop" Button $ctrlName title=StringFromList(RecState,Titles) SetDataFolder thisDFEnd/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_InitializeDisplays()///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Create global data folders that will need to be accessed by the panel NewDataFolder/O root:DAQ NewDataFolder/O root:DAQ:Classes NewDataFolder/O/S root:DAQ:Classes:Displays variable/G root:DAQ:Classes:Displays:totalchan = 2 variable/G root:DAQ:Classes:Displays:RecState = 0 variable/G root:DAQ:Classes:Displays:CurrRec = 0 End/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_DisplayChannels()///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string origDF = GetDataFolder(1)// Kill existing windows before launching new (if they exist) DoWindow/K Channel_A DoWindow/K Channel_B DoWindow/K Channel_C DoWindow/K Channel_D // Find out the number of channels total NVAR totalchan = root:DAQ:Classes:Displays:totalchan SetDataFolder root:DAQ:Classes:Displays// Create a wave of coordinates for all episodic display channels and launch Make/N=4/O Channel_A_coords, Channel_B_coords, Channel_C_coords, Channel_D_coords if(totalchan<4) Channel_A_coords = {380,0,980,300} Channel_B_coords = {380,370,980,670} CORD_DisplayChannel("A") CORD_DisplayChannel("B") else Channel_A_coords = {380,40,980,220} Channel_B_coords = {380,240,980,420} Channel_C_coords = {380,440,980,620} Channel_D_coords = {380,640,980,820} CORD_DisplayChannel("A") CORD_DisplayChannel("B") CORD_DisplayChannel("C") CORD_DisplayChannel("D") endif// Create the continuous (FIFO based) display CORD_CreateChart(totalchan) // Restore original data folder at end of function SetDataFolder origDF End //MenuDisplayChannel/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_DisplayChannel(channel)///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string channel// Some channel related variables that need to be created or referenced string MonState = "MonState_"+channel variable/G $MonState = 0 string/G ThisChannel = "Channel_"+channel string GetCoordsRef = ThisChannel+"_coords" Wave ThisChannelCoords = $GetCoordsRef string Width = ThisChannel+"_tlimit_gvar" variable/G $Width = 100 string YMin = ThisChannel+"_ymin_gvar" variable/G $YMin = 1 string YMax = ThisChannel+"_ymax_gvar" variable/G $YMax = 0 string Buffer = ThisChannel+"_buffer_gvar" variable/G $Buffer = 4 string StateName = ThisChannel+"_stateG" variable/G $StateName=1 // Launch the panel DoWindow/K $ThisChannel variable left = ThisChannelCoords[0] //root:DAQ:Classes:Displays:left variable top = ThisChannelCoords[1] //root:DAQ:Classes:Displays:top variable right = ThisChannelCoords[2] //root:DAQ:Classes:Displays:right variable bottom = ThisChannelCoords[3] //root:DAQ:Classes:Displays:bottom Display/W=(left,top,right,bottom)/K=1 as ThisChannel DoWindow/C $ThisChannel string tmp10 = "MonWave_"+channel KillWaves/Z $tmp10 Make/O/N=(2) $tmp10 SetScale/I x, 0, 1/20000, "s", $tmp10 AppendToGraph $tmp10 SetAxis bottom 0, 1 SetAxis left -100, 50 ModifyGraph live=1 // use oscilloscope mode for fast updating ModifyGraph /W=$ThisChannel cbRGB = (32125,33410,39321) // set background color end //DisplayChannel/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Function CORD_CreateChart(ChanNumber)///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// variable ChanNumber variable/G root:DAQ:Classes:Displays:FIFOsize = 200000 NVAR FIFOsize = root:DAQ:Classes:Displays:FIFOsize FIFOStatus/Q TheFIFO if(V_Flag>0) KillFIFO TheFIFO endif NewFIFO TheFIFO string name = "" variable index=0 switch(ChanNumber) case 2: NewFIFOChan/D TheFIFO, chanA, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanB, 0, 1, -1.5, 1.5, "V" break case 4: NewFIFOChan/D TheFIFO, chanA, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanB, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanC, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanD, 0, 1, -1.5, 1.5, "V" break case 8: NewFIFOChan/D TheFIFO, chanA, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanB, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanC, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanD, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanE, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanF, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanG, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanH, 0, 1, -1.5, 1.5, "V" break case 16: NewFIFOChan/D TheFIFO, chanA, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanB, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanC, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanD, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanE, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanF, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanG, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanH, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanI, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanJ, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanK, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanL, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanM, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanN, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanO, 0, 1, -1.5, 1.5, "V" NewFIFOChan/D TheFIFO, chanP, 0, 1, -1.5, 1.5, "V" break case 1: NewFIFOChan/D TheFIFO, chanA, 0, 1, -1.5, 1.5, "V" break endswitch CtrlFIFO TheFIFO, deltaT=0.00005 CtrlFIFO TheFIFO, size=FIFOsize SetDataFolder root:DAQ:Classes:Displays variable/G root:DAQ:Classes:Displays:FIFOsize = 200000 string Width = "Channel_A_tlimit_gvar" variable/G $Width = 100 string YMin = "Channel_A_ymin_gvar" variable/G $YMin = 1 string YMax = "Channel_A_ymax_gvar" variable/G $YMax = 0 variable dispX = str2num(StringFromList(3, StringByKey("SCREEN1", IgorInfo(0)),",")) variable dispY = str2num(StringFromList(4, StringByKey("SCREEN1", IgorInfo(0)),",")) DoWindow/F FifoPanel if (V_Flag!=0) DoWindow/K FifoPanel endif NewPanel/W=(dispX-1000,50,dispX-10,dispY-100)/K=1/N=FifoPanel as "Continuous Recording" ModifyPanel /W=FifoPanel cbRGB=(32125,33410,39321) //set background color SetDrawEnv fname="Verdana", fstyle=0, fsize=10, linefgc=(65278,55512,34438),textrgb=(65278,47802,17219) Button TheChart_ON pos={5,5},font="Arial",size={70,20}, proc=CORD_ChanMon, title="monitor", help={"Press to monitor the corresponding AD channel"} Button TheChart_STORE pos={85,5},font="Arial",size={70,20}, proc=CORD_MonStore, title="store" Button TheChart_REC pos={165,5},font="Arial",size={70,20}, proc=CORD_MonRec, title="record" SetVariable TheChart_TIME pos={250,8},size={133,20},title="Points Per Strip",font="Arial",fsize=10, limits={1,Inf,1},value=root:DAQ:Classes:Displays:Channel_A_tlimit_gvar SetVariable TheChart_GAIN pos={390,8},size={133,20},title="Gain",font="Arial",fsize=10, limits={1,Inf,1},value=root:DAQ:Classes:Displays:Channel_A_ymin_gvar SetVariable TheChart_OFF pos={530,8},size={133,20},title="Offset",font="Arial",fsize=10, limits={-Inf,Inf,0.01},value=root:DAQ:Classes:Displays:Channel_A_ymax_gvar Button TheChart_DORESIZE pos={680,5},font="Arial",size={70,20}, proc=CORD_Monresize, title="update" switch(ChanNumber) case 2: Chart TheChart, fifo=TheFIFO, pos={0,30}, size={990,dispY-170}, chans={0,1}, ppStrip=100, oMode=0, sMode=1, uMode=2, lineMode(0)=1, lineMode(1)=1, gridRGB=(50000,50000,65535) break case 4: Chart TheChart, fifo=TheFIFO, pos={0,30}, size={990,dispY-170}, chans={0,1,2,3}, ppStrip=100, oMode=0, sMode=1, uMode=2, lineMode(0)=1, lineMode(1)=1, gridRGB=(50000,50000,65535) break case 8: Chart TheChart, fifo=TheFIFO, pos={0,30}, size={990,dispY-170}, chans={0,1,2,3,4,5,6,7}, ppStrip=100, oMode=0, sMode=1, uMode=2, lineMode(0)=1, lineMode(1)=1, gridRGB=(50000,50000,65535) break case 16: Chart TheChart, fifo=TheFIFO, pos={0,30}, size={990,dispY-170}, chans={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}, ppStrip=100, oMode=0, sMode=1, uMode=2, lineMode(0)=1, lineMode(1)=1, gridRGB=(50000,50000,65535) break case 1: Chart TheChart, fifo=TheFIFO, pos={0,30}, size={990,dispY-170}, chans={0}, ppStrip=100, oMode=0, sMode=1, uMode=2, lineMode(0)=1, lineMode(1)=1, gridRGB=(50000,50000,65535) break endswitch End