impedance measurements
This script was made to do impedance measurements with an hardware that suddenly borke... :( I think it will not be useful for anyone!
#!/usr/bin/python
''' This is the text frontend to impedance measurements using EiFraExp class.
To start it in interactive mode, go to the program folder and type 'impedance'. It will read
non-asked setting from eifra_cnf.py
Optional arguments:
? Will show this message
mode='mode string' Will start this program in the mode 'mode'. Valid mode strings are:
'i' Interactive mode, (default)
'q' Quiet mode. Will read all data from config file.
! Note: if the cfg file is in the same directory, you can omit the path and specify only
file name. Otherwise, write the entire path!
'''
from erc import *
from sys import path, argv
print str(argv)
from os.path import basename, dirname, exists
from time import time
import os
if '?' in argv:
print ''' This is the text frontend to impedance measurements using EiFraExp class.
To start it in interactive mode, go to the program folder and type 'impedance.py'. It will read
non-asked setting from eifra_cnf.py
Optional arguments:
? Will show this message
Valid argument strings are:
'q' Quiet mode. Will read all data from config file.
'r' Read-only mode.Useful if you made a manual measurament and want to save the results as
specified in config file.
cfg='/path/to/cfg/file'
! Note: if the cfg file is in the same directory, you can omit the path and specify only
file name. Otherwise, write the entire path!
'''
cfg='eifra_cnf.py'
pth=None
for opt in argv:
if 'cfg=' in opt:
opt=opt.replace('cfg=','').replace('\'','')
while inpt not in ['','y','yes',1]:
if exists(opt):
cfgf=basename(opt)
pth=dirname(opt)
else:
cfgf='eifra_cnf'
inpt=raw_input('Cfg file not found. Please enter another file path, or press return to use eifra_cnf.py')
if 'mode=' in opt:
mode=opt.replace('mode=','').replace('\'','')
else:
mode='i'
cfgf=cfg.replace('.py','')
path+=['/home/daniele/prg',pth]
cmd="from "+cfgf+' import loops, hd, mysql, mycomment';exec(cmd)
exp=EiFraExp()
if 'q' not in argv:
exp.setup(cfg=cfgf)
else:
exp.setup(cfg=cfgf,set=0)
if 'r' not in argv:
exp.send_ei()
exp.send_custom_ei()
exp.send_fra()
exp.send_custom_fra()
for loop in range(loops):
print 'Loop number '+str(loop+1)
exp.loop(num=loop+1)
print 'Reading buffer...'
sleep(3)
r=exp.read_buffer()
print exp.data
print '\a\a\a'
#print 'Done. Plotting the result.'
else:
print "Read only mode"
print "Reading the buffer.."
exp.send_ei()
r=exp.read_buffer()
if r==0:
print 'Saving data as specifyed in config file.'
dsm=DataStorageManager(cfgf,exp)
if hd==1:
dsm.store2f()
if mysql==1:
if mycomment==None:
mycomment=raw_input('Type a comment for this record: ')
dsm.store2my()
#exp.fra.wrt('TT0')
else:
print r
print 'Impossible to save data. Something went wrong. Read the output for more info. '



