cleaned debug output in execmacro
DRIVERS:
alternative version of picoforce driver
+ INPUT
+ merged (partially) libinput (so far in hooke_cli)
+ OUTLET
+ merged liboutlet
0.8.3
return
print 'Contour length: ',params[0]*(1.0e+9),' nm'
+ to_dump='contour '+self.current.path+' '+str(params[0]*(1.0e+9))+' nm'
+ self.outlet.push(to_dump)
if len(params)==2: #if we did choose 2-value fit
print 'Persistent length: ',params[1]*(1.0e+9),' nm'
+ to_dump='persistent '+self.current.path+' '+str(params[1]*(1.0e+9))+' nm'
+ self.outlet.push(to_dump)
#add the clicked points in the final PlotObject
clickvector_x, clickvector_y=[], []
peak_location,peak_size=self.has_peaks(defplots,abs_devs)
print 'Found '+str(len(peak_location))+' peaks.'
+ to_dump='peaks '+self.current.path+' '+str(len(peak_location))
+ self.outlet.push(to_dump)
#print peak_location
#if no peaks, we have nothing to plot. exit.
points=self._measure_N_points(N=2)
zpiezo=abs(points[0].graph_coords[1]-points[1].graph_coords[1])
print str(zpiezo*(10**9))+' nm'
+ to_dump='zpiezo '+self.current.path+' '+str(zpiezo*(10**9))+' nm'
+ self.outlet.push(to_dump)
else:
print 'This command makes no sense for a non-force clamp experiment.'
points=self._measure_N_points(N=2)
defl=abs(points[0].graph_coords[1]-points[1].graph_coords[1])
print str(defl*(10**12))+' pN'
+ to_dump='deflection '+self.current.path+' '+str(defl*(10**12))+' pN'
+ self.outlet.push(to_dump)
else:
print 'This command makes no sense for a non-force clamp experiment.'
dt=abs(points[1].graph_coords[0]-points[0].graph_coords[0])
print 'dZ: ',dz,' nm'
print 'dT: ',dt,' s'
+ to_dump='step '+self.current.path+' '+'dZ: '+str(dz)+' nm'+' dT: '+str(dt)+' s'
+ self.outlet.push(to_dump)
else:
print 'This command makes no sense for a non-force clamp experiment.'
\ No newline at end of file
else:
dx,unitx,dy,unity=self._delta(set=1)
print str(dx*(10**9))+' nm'
+ to_dump='distance '+self.current.path+' '+str(dx*(10**9))+' nm'
+ self.outlet.push(to_dump)
def do_force(self,args):
return
dx,unitx,dy,unity=self._delta(set=1)
print str(dy*(10**12))+' pN'
+ to_dump='force '+self.current.path+' '+str(dy*(10**12))+' pN'
+ self.outlet.push(to_dump)
def do_forcebase(self,args):
avg=np.mean(to_average)
forcebase=abs(y-avg)
print str(forcebase*(10**12))+' pN'
+ to_dump='forcebase '+self.current.path+' '+str(forcebase*(10**12))+' pN'
+ self.outlet.push(to_dump)
def plotmanip_flatten(self, plot, current, customvalue=False):
# Outputs the relevant slope parameter
print 'Slope:'
print str(parameters[0])
+ to_dump='slope '+self.current.path+' '+str(parameters[0])
+ self.outlet.push(to_dump)
# Makes a vector with the fitted parameters and sends it to the GUI
xtoplot=parameters[2]
<!-- To comment something, put dashes and ! like here -->
<config>
<!-- Internal variabls. -->
- <display ext="1" colour_ext="None" ret="1" colour_ret="None" correct="1" colour_correct="None" contact_point="0" medfilt="0" xaxes="0" yaxes="0" flatten="1" temperature="293" auto_fit_points="50" auto_slope_span="20" auto_delta_force="10" fc_showphase="0" fc_showimposed="0" fc_interesting="0"/>
+ <display ext="1" colour_ext="None" ret="1" colour_ret="None" correct="1" colour_correct="None" contact_point="0" medfilt="0" xaxes="0" yaxes="0" flatten="1" temperature="293" auto_fit_points="10" auto_slope_span="10" auto_delta_force="10" fc_showphase="0" fc_showimposed="0" fc_interesting="0"/>
<!--
The following section defines your own work directory. Substitute your work directory.
-->
<workdir>
- insert directory
+ /home/glacierre/hooke/
</workdir>
<!--
<!--superimpose/ -->
<generalvclamp/>
<massanalysis/>
+ <viewer/>
<!-- tutorial/ -->
<macro/>
</plugins>
This section defines which drivers have to be loaded by Hooke.
-->
<drivers>
- <picoforce/>
+ <picoforcealt/>
<!-- hemingclamp/ -->
<csvdriver/>
<!-- tutorialdriver/ -->
from libhooke import * #FIXME
import libhookecurve as lhc
+import libinput as linp
+import liboutlet as lout
+
from libhooke import WX_GOOD
from libhooke import HOOKE_VERSION
self.playlist_saved=0
self.playlist_name=''
self.notes_saved=1
+
+ #create outlet
+ self.outlet=lout.Outlet()
#Data that must be saved in the playlist, related to the whole playlist (not individual curves)
self.playlist_generics={}
def do_loadlist(self, args):
#checking for args: if nothing is given as input, we warn and exit.
while len(args)==0:
- args=raw_input('File to load?')
+ args=linp.alphainput('File to load?','',0,[])
arglist=args.split()
play_to_load=arglist[0]
def do_genlist(self,args):
#args list is: input path, output name
if len(args)==0:
- args=raw_input('Input files?')
+ args=linp.alphainput('Input files?','',1,[])
arglist=args.split()
list_path=arglist[0]
Syntax: savelist [filename]
'''
while len(args)==0:
- args=raw_input('Input files?')
+ args=linp.alphainput('Output files?','',1,[])
output_filename=args
'''
if filename=='':
- filename=raw_input('Jump to?')
+ filename=linp.alphainput('Jump to?','',0,[])
filepath=os.path.abspath(filename)
print filepath
c+=1
except IndexError:
#We've found the end of the list.
- answer=raw_input('Curve not found in playlist. Add it to list?')
+ answer=linp.alphainput('Curve not found in playlist. Add it to list?','y',0,[])
if answer.lower()[0]=='y':
try:
self.do_addtolist(filepath)
x,unitx,y,unity=self._point()
print str(x)+' '+unitx
print str(y)+' '+unity
-
+ to_dump='point '+self.current.path+' '+str(x)+' '+unitx+', '+str(y)+' '+unity
+ self.outlet.push(to_dump)
def do_close(self,args=None):
dest=0
if args=='':
- name=raw_input('Filename?')
+ name=linp.alphainput('Filename?',self.current.path+'.png',0,[])
else:
args=args.split()
name=args[0]
whichplot=0
args=args.split()
if len(args)==0:
- filename=raw_input('Filename?')
+ filename=linp.alphainput('Filename?',self.current.path+'.txt',0,[])
else:
- filename=args[0]
+ filename=linp.checkalphainput(args[0],self.current.path+'.txt',[])
try:
whichplot=int(args[1])
except:
def do_notelog(self,args):
if len(args)==0:
- args=raw_input('Notelog filename?')
+ args=linp.alphainput('Notelog filename?','notelog.txt',0,[])
note_lines='Notes taken at '+time.asctime()+'\n'
for item in self.current_list:
def do_copylog(self,args):
if len(args)==0:
- args=raw_input('Destination directory?')
+ args=linp.alphainput('Destination directory?','',0,[]) #TODO default
mydir=os.path.abspath(args)
if not os.path.isdir(mydir):
except OSError:
print 'OSError. Cannot copy file. Perhaps you gave me a wrong directory?'
+#OUTLET management
+
+
+ def do_outlet_show(self,args):
+ self.outlet.printbuf()
+
+ def do_outlet_undo(self, args):
+ print 'Erasing last entry'
+ self.outlet.pop()
+
+ def do_outlet_delete(self, args):
+ if len(args)==0:
+ print 'Index needed!, use outlet_show to know it'
+ else:
+ self.outlet.delete(args)
+
+
+
+
#OS INTERACTION COMMANDS
#-----------------
we_exit='N'
if (not self.playlist_saved) or (not self.notes_saved):
- we_exit=raw_input('You did not save your playlist and/or notes. Exit?')
+ we_exit=linp.alphainput('You did not save your playlist and/or notes. Exit?','n',0,[])
else:
- we_exit=raw_input('Exit?')
+ we_exit=linp.alphainput('Exit?','y',0,[])
if we_exit[0].upper()=='Y':
wx.CallAfter(self.frame.Close)
+
+
if __name__ == '__main__':
mycli=HookeCli(0)
- mycli.cmdloop()
\ No newline at end of file
+ mycli.cmdloop()
--- /dev/null
+#!/usr/bin/env python
+
+'''
+Input check routines.
+
+Copyright (C) 2008 Alberto Gomez-Casado (University of Twente).
+
+This program is released under the GNU General Public License version 2.
+'''
+
+def alphainput (message, default, repeat, valid):
+ if default and not repeat:
+ print 'Enter for default: '+str(default)
+ reply=raw_input(message)
+ if len(valid)>0:
+ if reply in valid:
+ return reply
+ else:
+ if repeat==1:
+ while reply not in valid:
+ reply=raw_input('You should enter any of these: '+ str(valid) +'\n'+ message)
+ return reply
+ else:
+ return default
+ else:
+ if len(reply)>0:
+ return reply
+ else:
+ if not repeat:
+ return default
+ else:
+ while len(reply)==0:
+ print 'Try again'
+ reply=raw_input(message)
+ return reply
+
+
+
+def checkalphainput (test, default, valid):
+#useful when input was taken form command args
+ if len(valid)>0:
+ if test in valid:
+ return test
+ else:
+ return default
+ else:
+ #TODO: raise exception?
+ if len(test)>0:
+ return test
+ else:
+ return default
+
+
+def numinput(message, default, repeat, limits):
+ if default and not repeat:
+ print 'Enter for default: '+str(default)
+ reply=raw_input(message)
+ if reply:
+ reply=int(reply)
+ if len(limits)==2:
+ high=int(limits.pop())
+ low=int(limits.pop())
+ if reply>=low and reply <= high:
+ return reply
+ else:
+ if repeat==1:
+ while reply<low or reply>high :
+ reply=raw_input('You should enter values between: '+ str(low)+' and '+str(high) +'\n'+ message)
+ if reply:
+ reply=int(reply)
+ return reply
+ else:
+ return default
+ else:
+ if len(reply)>0:
+ return int(reply)
+ else:
+ if not repeat:
+ return default
+ else:
+ while len(reply)==0:
+ print 'Try again'
+ reply=raw_input(message)
+ return reply
+
+def checknuminput(test,default,limits):
+ if len(limits)==2:
+ high=int(limits.pop())
+ low=int(limits.pop())
+ if test>=low and test <= high:
+ return int(test)
+ else:
+ return default
+ else:
+ if len(test)>0:
+ return int(test)
+ else:
+ return default
+
--- /dev/null
+#!/usr/bin/env python
+
+'''
+Basic outlet object
+
+Copyright (C) 2008 Alberto Gomez-Casado (University of Twente).
+
+This program is released under the GNU General Public License version 2.
+'''
+
+
+import re
+
+
+class Outlet(object):
+
+ def __init__(self):
+ self.buffer=[]
+ self.relations=[]
+
+ def push(self, args):
+ self.buffer.append(args)
+
+ def pop(self, args):
+ return self.buffer.pop();
+
+ def printbuf(self):
+ j=1;
+ for i in self.buffer:
+ print j, i
+ j=j+1
+
+ def delete(self, number):
+ if len(self.buffer)>int(number)-1 and int(number)>0:
+ self.buffer.pop(int(number)-1)
+
+ def empty(self):
+ self.buffer=[]
+
+ def read_last(self):
+ return self.buffer[len(self.buffer)-1]
+
+ def read_first(self):
+ return self.buffer[0]
+
+ def read_type(self,dtype):
+ aux=[]
+ index=0
+ if dtype=='all':
+ return self.buffer
+ for i in self.buffer:
+ if re.match(dtype+'*',i):
+ aux.append(i)
+ return aux
+
+
--- /dev/null
+#!/usr/bin/env python
+
+'''
+Basic Viewer and ascii saver examples
+
+Copyright (C) 2008 Alberto Gomez-Casado (University of Twente).
+
+This program is released under the GNU General Public License version 2.
+'''
+
+
+import liboutlet as lout
+
+class Viewer(object):
+ source=[]
+ data=[]
+ dtype='all'
+ action=[]
+
+
+ def setdtype(self, dt):
+ self.dtype=dt
+
+ def show(self):
+ self.source.printbuf()
+
+ def getdata(self):
+ self.data=self.source.read_type(self.dtype)
+
+
+
+class Ascii(Viewer):
+
+ def __init__(self,outref):
+ self.source=outref
+ self.action=self.dump
+
+ def dump(self):
+ self.getdata()
+ destination=raw_input('Enter filename:')
+ destfile=open(destination,'w+')
+ destfile.write('\n'.join(self.data))
+ destfile.close()
+
--- /dev/null
+#!/usr/bin/env python
+
+'''
+Viewer test case
+
+Copyright (C) 2008 Alberto Gomez-Casado (University of Twente).
+
+This program is released under the GNU General Public License version 2.
+'''
+
+
+import libviewer as lview
+
+class viewerCommands:
+
+ def _plug_init(self):
+ self.viewerlist=[]
+
+
+ def do_vwnew(self,args):
+ self.viewerlist.append(lview.Ascii(self.outlet))
+ dt=raw_input('What type of data will this viewer handle? (force/distance/all)')
+ print dt
+ self.viewerlist[-1].setdtype(dt)
+
+
+ def do_vwaction(self,args):
+ '''
+ triggers default action of viewer number n (default 0)
+ '''
+
+ if len(args)==0:
+ args=0
+ self.viewerlist[int(args)].action()