Startup
This commit is contained in:
8
script/test/TestBool.py
Normal file
8
script/test/TestBool.py
Normal file
@@ -0,0 +1,8 @@
|
||||
#Creating a 1D dataset from an array
|
||||
path="group/data1"
|
||||
data1d = [True, False, False, True, True, False, False]
|
||||
save_dataset(path, data1d, 'z')
|
||||
|
||||
read =load_data(path)
|
||||
print read.tolist()
|
||||
assert data1d==read.tolist()
|
||||
4
script/test/TestChannel.py
Normal file
4
script/test/TestChannel.py
Normal file
@@ -0,0 +1,4 @@
|
||||
c=Channel("TESTIOC:TESTCALCOUT:Input")
|
||||
c.read()
|
||||
|
||||
append_dataset(path, data, index = None, type = d, shape = None)
|
||||
26
script/test/TestDel.py
Normal file
26
script/test/TestDel.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import java.lang.System as System
|
||||
import org.python.core.finalization.FinalizablePyObject as FinalizablePyObject
|
||||
import org.python.core.finalization.FinalizeTrigger as FinalizeTrigger
|
||||
import org.python.core.finalization.FinalizableBuiltin as FinalizableBuiltin
|
||||
import org.python.core.PyInstance as PyInstance
|
||||
#import org.python.core.PyFinalizableInstance as PyFinalizableInstance
|
||||
|
||||
class Employee(FinalizablePyObject):
|
||||
|
||||
def __init__(self):
|
||||
print('__init__')
|
||||
|
||||
def __del__(self):
|
||||
print("__del__", self)
|
||||
|
||||
def finalize(self): pass #TODO: if not overriden, __del__ is not called!!!
|
||||
|
||||
for i in range (100):
|
||||
obj = Employee()
|
||||
time.sleep(0.01)
|
||||
System.gc()
|
||||
|
||||
#del obj
|
||||
System.gc()
|
||||
|
||||
|
||||
21
script/test/TestDel2.py
Normal file
21
script/test/TestDel2.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import java.lang.System as System
|
||||
"""
|
||||
def x():
|
||||
c=Channel("TESTIOC:TESTCALCOUT:Input", alias = "asd")
|
||||
c=Channel("TESTIOC:TESTCALCOUT:Input")
|
||||
for i in range(1):
|
||||
x=Channel("TESTIOC:TESTCALCOUT:Input")
|
||||
|
||||
|
||||
x()
|
||||
|
||||
import java.lang.System as System
|
||||
"""
|
||||
System.gc()
|
||||
print "---"
|
||||
c=Channel("TESTIOC:TESTCALCOUT:Input")
|
||||
print "!!!"
|
||||
|
||||
#r=tscan(c,10,0.1)
|
||||
c=None
|
||||
System.gc()
|
||||
1
script/test/TestLscan.py
Normal file
1
script/test/TestLscan.py
Normal file
@@ -0,0 +1 @@
|
||||
r=lscan(out,(inp, sin, dp, arr1), 0,10, 10,print_scan=True)
|
||||
62
script/test/TestStdev.py
Normal file
62
script/test/TestStdev.py
Normal file
@@ -0,0 +1,62 @@
|
||||
from ijutils import *
|
||||
import ch.psi.pshell.imaging.Filter as Filter
|
||||
from ch.psi.pshell.imaging.Utils import *
|
||||
from ch.psi.pshell.imaging.Overlays import *
|
||||
import ch.psi.pshell.imaging.Pen as Pen
|
||||
|
||||
class MetricsFilter(Filter):
|
||||
def __init__(self, metrics):
|
||||
self.overlay = Text(Pen(java.awt.Color.GREEN.darker()), "", \
|
||||
java.awt.Font("Verdana", java.awt.Font.PLAIN, 12), java.awt.Point(20,20))
|
||||
self.metrics = metrics
|
||||
self.source = None
|
||||
self.renderer = None
|
||||
|
||||
def process(self, image, data):
|
||||
try:
|
||||
ip = load_array(data.array, data.width, data.height)
|
||||
msg = ""
|
||||
if self.metrics is not None:
|
||||
for metric in self.metrics:
|
||||
val = IJ.getValue(ip,metric)
|
||||
msg = msg + "%s = %1.4f\n" % (metric,val)
|
||||
self.overlay.update(msg)
|
||||
except:
|
||||
self.overlay.update(str(sys.exc_info()[1]))
|
||||
return image
|
||||
|
||||
def start(self, source, renderer=None):
|
||||
self.stop()
|
||||
self.source = source
|
||||
self.renderer = renderer if (renderer is not None) else show_panel(source)
|
||||
self.source.setFilter(self)
|
||||
self.renderer.addOverlay(self.overlay)
|
||||
|
||||
def stop(self):
|
||||
if self.renderer is not None:
|
||||
self.renderer.removeOverlay(self.overlay)
|
||||
if self.source is not None:
|
||||
self.source.setFilter(None)
|
||||
self.source = None
|
||||
self.renderer = None
|
||||
|
||||
filter_metrics = None
|
||||
|
||||
def start_metrics(metrics, source, renderer=None):
|
||||
global filter_metrics
|
||||
stop_metrics()
|
||||
filter_metrics = MetricsFilter(metrics)
|
||||
filter_metrics.start(source, renderer)
|
||||
|
||||
def stop_metrics():
|
||||
global filter_metrics
|
||||
if filter_metrics is not None:
|
||||
filter_metrics.stop()
|
||||
filter_metrics = None
|
||||
|
||||
metrics = ["Area", "Mean", "StdDev", "Mode", "Min", "Max", "X", "Y", "XM", "YM", "Perim.", "BX", "BY", "Width", "Height", "Major", "Minor", "Angle", "Circ.", "Feret", "IntDen", "Median", "Skew", "Kurt", "%Area", "RawIntDen", "Ch", "Slice", "Frame", "FeretX", "FeretY", "FeretAngle", "MinFeret", "AR", "Round", "Solidity", "MinThr", "MaxThr"]
|
||||
|
||||
#start_metrics (["StdDev"], src1)
|
||||
start_metrics (metrics, src1)
|
||||
time.sleep(5.0)
|
||||
stop_metrics()
|
||||
17
script/test/TestTab.py
Normal file
17
script/test/TestTab.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import ch.psi.utils.swing.TextEditor as TextEditor
|
||||
import ch.psi.pshell.ui.App as App
|
||||
|
||||
title="CXXC3"
|
||||
|
||||
editor = TextEditor();
|
||||
tabpane = App.getInstance().getMainFrame().getLeftTab();
|
||||
App.getInstance().getMainFrame().openComponent(title, editor, tabpane)
|
||||
for i in range(App.getInstance().getMainFrame().getLeftTab().getTabCount()):
|
||||
t=App.getInstance().getMainFrame().getLeftTab().getTabComponentAt(i)
|
||||
if t:
|
||||
if t.getLabel().getText() == title:
|
||||
for l in t.getLabel().getMouseListeners():
|
||||
print l
|
||||
t.getLabel().removeMouseListener(l)
|
||||
|
||||
|
||||
35
script/test/Testregion.py
Normal file
35
script/test/Testregion.py
Normal file
@@ -0,0 +1,35 @@
|
||||
def get_calc_group():
|
||||
return get_exec_pars().group + "calc/"
|
||||
|
||||
xx=None
|
||||
def after_readout(rec):
|
||||
global xx
|
||||
xx=rec
|
||||
print ("----")
|
||||
print rec[0],rec[1]
|
||||
print rec.getValue("sin"),rec.getValue("out")
|
||||
print rec.getValue(sin),rec.getValue(out)
|
||||
print rec.getSetpoint("inp"),rec.getSetpoint(inp),rec.getSetpoint(0)
|
||||
print rec.getPosition("inp"),rec.getPosition(inp),rec.getPosition(0)
|
||||
if get_exec_pars().persist: #This is not to write if "save=False” is set in the scan command
|
||||
if rec.index == 0:
|
||||
create_dataset(get_calc_group() + "Value1")
|
||||
append_dataset(get_calc_group() + "Value1", rec) #The calculated value
|
||||
|
||||
#set_exec_pars(layout="sf")
|
||||
|
||||
def before_region(i):
|
||||
print i
|
||||
|
||||
#r1 = rscan(inp, (sin,out) , [(0,5,5), (10,15,20), (20,25,5)] , 0.01, passes = 3, zigzag = True, before_region=before_region, after_read=after_readout)
|
||||
#set_attribute("/", "Test", 1)
|
||||
|
||||
r1 = rscan(inp, (sin,out,arr) , [(0,5,5), (10,15,20), (20,25,5)] , 0.01, passes = 3, zigzag = True)
|
||||
print r1.getReadable(sin)
|
||||
|
||||
"""
|
||||
r2 = rscan(inp, (sin,out,arr) , [(0,5,5), (10,15,20), (20,25,5)] , 0.01, passes = 3, zigzag = True, keep=False, setpoints=True)
|
||||
print r2.getReadable(sin)
|
||||
print r2.getPositions(inp)
|
||||
print r2.getSetpoints(inp)
|
||||
"""
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="1" failOnSensorError="true">
|
||||
<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="2" failOnSensorError="true">
|
||||
<notification>
|
||||
<recipient error="true" success="false">alexandre.gobbo@psi.ch</recipient>
|
||||
</notification>
|
||||
@@ -10,7 +10,7 @@
|
||||
<dimension zigzag="false" dataGroup="false">
|
||||
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinearPositioner" name="TESTIOC:TESTCALCOUT:Input" asynchronous="false" id="id278043">
|
||||
<start>0.0</start>
|
||||
<end>31.0</end>
|
||||
<end>3.0</end>
|
||||
<stepSize>0.1</stepSize>
|
||||
</positioner>
|
||||
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptAction">
|
||||
|
||||
Reference in New Issue
Block a user