This commit is contained in:
gac-x12sa
2022-12-16 16:55:33 +01:00
commit 7f540c8ffa
12 changed files with 502 additions and 0 deletions

49
config/config.properties Normal file
View File

@@ -0,0 +1,49 @@
#Fri Dec 16 16:55:24 CET 2022
autoSaveScanData=true
simulation=false
dataScanSaveOutput=false
userAuthenticator=
dataScanSaveScript=false
notifiedTasks=
parallelInitialization=false
fdaSerialization=false
dataTransferPath=
saveConsoleSessionFiles=false
hostName=
disableEmbeddedAttributes=false
serverPort=8080
versionTrackingEnabled=true
dataPath={data}/{year}_{month}/{date}/{date}_{time}_{name}
serverEnabled=false
depthDimension=0
logLevel=Info
dataLayout=default
disableDataFileLogs=false
sessionHandling=Off
terminalEnabled=false
notificationLevel=Off
terminalPort=3579
dataTransferUser=
versionTrackingLogin=
noBytecodeFiles=false
versionTrackingRemote=
logDaysToLive=-1
logLevelConsole=Off
filePermissionsConfig=Default
scanStreamerPort=-1
dataScanSaveSetpoints=false
versionTrackingManual=false
dataTransferMode=Off
userManagement=false
instanceName=x12sa
dataServerPort=-1
hideServerMessages=false
dataScanReleaseRecords=false
dataScanPreserveTypes=false
dataScanFlushRecords=false
filePermissionsLogs=Default
logPath={logs}/{date}_{time}
filePermissionsScripts=Default
filePermissionsData=Default
dataProvider=h5
saveCommandStatistics=false

9
config/mail.properties Normal file
View File

@@ -0,0 +1,9 @@
#Fri Dec 16 16:32:36 CET 2022
port=0
usr=
auth=None
smsSuffix=@sms.switch.ch
host=
from=
to=
pwd=

View File

@@ -0,0 +1 @@
Eiger.java=enabled

136
config/preferences.json Normal file
View File

@@ -0,0 +1,136 @@
{
"fontShellPanel" : {
"name" : "Monospaced",
"style" : 0,
"size" : 13
},
"fontShellCommand" : {
"name" : "SansSerif",
"style" : 0,
"size" : 13
},
"fontOutput" : {
"name" : "Monospaced",
"style" : 0,
"size" : 13
},
"fontEditor" : {
"name" : "Monospaced",
"style" : 0,
"size" : 13
},
"fontPlotLabel" : {
"name" : "SansSerif",
"style" : 0,
"size" : 11
},
"fontPlotTick" : {
"name" : "SansSerif",
"style" : 0,
"size" : 10
},
"fontPlotTitle" : {
"name" : "SansSerif",
"style" : 1,
"size" : 13
},
"fontTerminal" : {
"name" : "Monospaced",
"style" : 0,
"size" : 14
},
"tabSize" : 4,
"contentWidth" : 0,
"editorBackground" : null,
"editorForeground" : null,
"simpleEditor" : false,
"hideEditorLineNumbers" : false,
"hideEditorContextMenu" : false,
"consoleLocation" : "Left",
"dataPanelLocation" : "Status",
"openDataFilesInDocTab" : false,
"noVariableEvaluationPropagation" : false,
"processingScripts" : [ ],
"asyncViewersUpdate" : false,
"asyncHistoryPlotsUpdate" : true,
"scanPlotDisabled" : false,
"scanTableDisabled" : false,
"cachedDataPanel" : false,
"dataExtensions" : "",
"dataSubFiles" : "",
"hideFileName" : false,
"showEmergencyStop" : false,
"showHomingButtons" : false,
"showJogButtons" : false,
"hideScanPanel" : false,
"hideOutputPanel" : false,
"showXScanFileBrowser" : false,
"showQueueBrowser" : false,
"backgroundRendering" : false,
"showImageStatusBar" : true,
"persistRendererWindows" : false,
"defaultRendererColormap" : "Grayscale",
"linePlot" : "ch.psi.pshell.plot.LinePlotJFree",
"matrixPlot" : "ch.psi.pshell.plot.MatrixPlotJFree",
"surfacePlot" : "null",
"timePlot" : "ch.psi.pshell.plot.TimePlotJFree",
"plotsDetached" : false,
"plotLayout" : "Vertical",
"quality" : "High",
"defaultPlotColormap" : "Temperature",
"markerSize" : 2,
"plotBackground" : null,
"gridColor" : null,
"outlineColor" : null,
"disableOffscreenBuffer" : false,
"defaultPanels" : [ {
"deviceClassName" : "ch.psi.pshell.epics.Scaler",
"panelClassName" : "ch.psi.pshell.swing.ScalerPanel"
}, {
"deviceClassName" : "ch.psi.pshell.epics.Scienta",
"panelClassName" : "ch.psi.pshell.swing.ScientaPanel"
}, {
"deviceClassName" : "ch.psi.pshell.device.Motor",
"panelClassName" : "ch.psi.pshell.swing.MotorPanel"
}, {
"deviceClassName" : "ch.psi.pshell.device.MasterPositioner",
"panelClassName" : "ch.psi.pshell.swing.MasterPositionerPanel"
}, {
"deviceClassName" : "ch.psi.pshell.device.ProcessVariable",
"panelClassName" : "ch.psi.pshell.swing.ProcessVariablePanel"
}, {
"deviceClassName" : "ch.psi.pshell.device.MotorGroup",
"panelClassName" : "ch.psi.pshell.swing.MotorGroupPanel"
}, {
"deviceClassName" : "ch.psi.pshell.device.DiscretePositioner",
"panelClassName" : "ch.psi.pshell.swing.DiscretePositionerPanel"
}, {
"deviceClassName" : "ch.psi.pshell.device.Camera",
"panelClassName" : "ch.psi.pshell.swing.CameraPanel"
}, {
"deviceClassName" : "ch.psi.pshell.device.Slit",
"panelClassName" : "ch.psi.pshell.swing.SlitPanel"
}, {
"deviceClassName" : "ch.psi.pshell.device.HistogramGenerator",
"panelClassName" : "ch.psi.pshell.swing.HistogramGeneratorPanel"
}, {
"deviceClassName" : "ch.psi.pshell.bs.Stream",
"panelClassName" : "ch.psi.pshell.swing.StreamPanel"
}, {
"deviceClassName" : "ch.psi.pshell.bs.StreamChannel",
"panelClassName" : "ch.psi.pshell.swing.StreamChannelPanel"
}, {
"deviceClassName" : "ch.psi.pshell.camserver.CamServerStream",
"panelClassName" : "ch.psi.pshell.swing.CamServerStreamPanel"
}, {
"deviceClassName" : "ch.psi.pshell.camserver.CamServerService",
"panelClassName" : "ch.psi.pshell.swing.CamServerServicePanel"
}, {
"deviceClassName" : "ch.psi.pshell.device.ReadonlyRegister$ReadonlyRegisterArray",
"panelClassName" : "ch.psi.pshell.swing.DeviceValueChart"
}, {
"deviceClassName" : "ch.psi.pshell.device.ReadonlyRegister$ReadonlyRegisterMatrix",
"panelClassName" : "ch.psi.pshell.swing.DeviceValueChart"
} ],
"scriptPopupDialog" : "None"
}

25
config/setup.properties Normal file
View File

@@ -0,0 +1,25 @@
#Fri Dec 16 16:32:34 CET 2022
scriptPath={home}/script
sessionsPath={outp}/sessions
configFileDevices={config}/devices.properties
xscanPath={script}
queuePath={script}
extensionsPath={home}/extensions
configPath={home}/config
configFileSessions={config}/sessions.properties
userSessionsPath={sessions}/user
dataPath={outp}/data
configFileVariables={config}/variables.properties
wwwPath={home}/www
logPath={outp}/log
configFile={config}/config.properties
configFileTasks={config}/tasks.properties
pluginsPath={home}/plugins
consoleSessionsPath={sessions}/console
libraryPath={script}; {script}/Lib
contextPath={outp}/context
configFilePlugins={config}/plugins.properties
devicesPath={home}/devices
configFileSettings={config}/settings.properties
imagesPath={outp}/images
scriptType=py

View File

@@ -0,0 +1,25 @@
#Fri Dec 16 16:50:04 CET 2022
spatialCalOffsetY=NaN
spatialCalOffsetX=NaN
colormapLogarithmic=false
scale=1.0
grayscale=false
spatialCalScaleX=NaN
spatialCalScaleY=NaN
colormapMax=NaN
rescaleOffset=0.0
roiWidth=-1
colormap=Grayscale
invert=false
colormapMin=NaN
rotation=0.0
rotationCrop=false
rescaleFactor=1.0
spatialCalUnits=mm
flipVertically=false
roiHeight=-1
flipHorizontally=false
colormapAutomatic=false
roiY=0
roiX=0
transpose=false

28
plugins/Eiger.form Normal file
View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="449" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="137" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Form>

66
plugins/Eiger.java Normal file
View File

@@ -0,0 +1,66 @@
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
/**
*
*/
public class Eiger extends Panel {
public Eiger() {
initComponents();
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
}
@Override
public void onStateChange(State state, State former) {
}
@Override
public void onExecutedFile(String fileName, Object result) {
}
@Override
protected void onTimer() {
}
@Override
protected void onLoaded() {
}
@Override
protected void onUnloaded() {
}
//Invoked by 'update()' to update components in the event thread
@Override
protected void doUpdate() {
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 449, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 137, Short.MAX_VALUE)
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}

138
script/devices/Array10.py Normal file
View File

@@ -0,0 +1,138 @@
import org.zeromq.ZMQ as ZMQ
import org.zeromq.ZMQ.Socket as Socket
import json
class Array10Array(ReadonlyAsyncRegisterBase, ReadonlyRegisterArray):
def getSize(self):
return 0 if (self.take() is None) else len(self.take())
def set(self, data):
self.onReadout(data)
class Array10Matrix(ReadonlyAsyncRegisterBase, ReadonlyRegisterMatrix):
def getWidth(self):
return 0 if (self.take() is None) else len(self.take()[0])
def getHeight(self):
return 0 if (self.take() is None) else len(self.take())
def set(self, data, shape):
if (data is not None) and (shape is not None):
self.onReadout(Convert.reshape(data, shape))
class Array10(DeviceBase, Readable, Cacheable, Readable.ReadableType):
def __init__(self, name, address, modulo_array=1, modulo_matrix=1, mode=ZMQ.PULL):
""" Device implementing communication with over Array10.
Args:
name(str): device name
address(str): address of stream
modulo_array(int, default=1): if defined create child device that holds the data array subsampled by this value.
modulo_matrix(int, default=1): if defined create child device that holds the 2d image subsampled by this value.
"""
super(Array10, self).__init__(name)
self.address = address
self.mode = mode
self.context = None
self.socket = None
self.running = False
self.header=None
self.data=None
self.array_dev=None
self.matrix_dev=None
self.message_count=0
if modulo_array is not None:
self.array_dev = Array10Array(self.name + "_array" )
self.addChild(self.array_dev)
self.array_dev.modulo = modulo_array
else:
self.array_dev = None
if modulo_matrix is not None:
self.matrix_dev = Array10Matrix(self.name + "_matrix" )
self.addChild(self.matrix_dev)
self.matrix_dev.modulo = modulo_matrix
else:
self.matrix_dev = None
def doInitialize(self):
self.stop()
self.header=None
self.data=None
self.message_count=0
self.start()
def start(self):
if self.running==False:
self.getLogger().info("Starting");
self.running = True
self.task = fork(self.rx_thread)
def stop(self):
if self.running:
self.getLogger().info("Stopping");
self.running = False
ret = join(self.task)
def rx_thread(self):
self.getLogger().info("Enter rx thread");
try:
self.context = ZMQ.context(1)
self.socket = self.context.socket(self.mode)
self.socket.connect(self.address)
while self.running:
header = self.socket.recv(ZMQ.NOBLOCK)
if (header is not None):
try:
self.header=json.loads(''.join(chr(i) for i in header))
self.data = self.socket.recv()
if self.data is not None:
self.setCache({"header":self.header, "data":self.data}, None)
self.message_count=self.message_count+1
if self.array_dev is not None:
if self.message_count % self.array_dev.modulo == 0:
self.array_dev.set(self.data)
if self.matrix_dev is not None:
if self.message_count % self.matrix_dev.modulo == 0:
shape = self.header.get("shape", None)
if shape: shape=(shape[1],shape[0]) #TODO: FIXME
self.matrix_dev.set(self.data, shape)
continue
except Exception as e:
print e
time.sleep(0.01)
except Exception as e:
print e
finally:
if self.socket:
self.socket.close()
if self.context:
self.context.term()
self.getLogger().info("Quit rx thread");
def doClose(self):
"""Close the channel.
"""
self.stop()
super(Array10, self).doClose()
#Readable interface
def read(self):
self.waitCacheChange(-1)
return self.take()
#Testing
#add_device(Array10("a10", "tcp://localhost:1234", modulo_array=1, modulo_matrix=10), True)
#add_device(a10.array_dev, True)
#add_device(a10.matrix_dev, True)
#add_device(RegisterMatrixSource("src_a10", a10.matrix_dev), True)

3
script/local.groovy Normal file
View File

@@ -0,0 +1,3 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// Deployment specific global definitions - executed after startup.groovy
///////////////////////////////////////////////////////////////////////////////////////////////////

4
script/local.js Normal file
View File

@@ -0,0 +1,4 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// Deployment specific global definitions - executed after startup.js
///////////////////////////////////////////////////////////////////////////////////////////////////

18
script/local.py Normal file
View File

@@ -0,0 +1,18 @@
###################################################################################################
# Deployment specific global definitions - executed after startup.py
###################################################################################################
import requests
# Definitions
DETECTOR_ADDRESS = "tcp://localhost:1234"
DETECTOR_IMAGE_MODULO = 1
# Devices
run("devices/Array10")
add_device(Array10("eiger", DETECTOR_ADDRESS, modulo_array=1, modulo_matrix=DETECTOR_IMAGE_MODULO), True)
add_device(eiger.array_dev, True)
add_device(eiger.matrix_dev, True)
add_device(RegisterMatrixSource("src_a10", eiger.matrix_dev), True)