Skip to content
Snippets Groups Projects
Commit 5d74bf64 authored by Christian Koernig's avatar Christian Koernig
Browse files

Improved example script

parent b286ee18
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ The low level communication is implemented in C++ and supports both Ethernet via ...@@ -7,6 +7,7 @@ The low level communication is implemented in C++ and supports both Ethernet via
The low level implementation is based on [previous work](https://github.com/ALBA-Synchrotron/AmptekPX5DS) at the ALBA synchrotron. However, the communication layer has been completely redesigned for more stability and added support for USB connections, circumventing the bottleneck of the low speed base-10 ethernet PHY of the hardware. The low level implementation is based on [previous work](https://github.com/ALBA-Synchrotron/AmptekPX5DS) at the ALBA synchrotron. However, the communication layer has been completely redesigned for more stability and added support for USB connections, circumventing the bottleneck of the low speed base-10 ethernet PHY of the hardware.
This code is meant to be a mostly drop-in replacement of the original Tango server, therefore the same server name and many commands & attributes are used. So far, the SCA channels and the MCS mode is not implemented, if those are needed, the original code should be used. This code is meant to be a mostly drop-in replacement of the original Tango server, therefore the same server name and many commands & attributes are used. So far, the SCA channels and the MCS mode is not implemented, if those are needed, the original code should be used.
Additionally, a basic simulator interface can be used during DAQ logic development if no hardware is available.
Prerequisites Prerequisites
------------- -------------
......
File moved
import AmptekHardwareInterface as ahi """Example script for the basic usage of the detector interface
"""
__author__ = "Christian Koernig"
import sys
import time
import matplotlib.pyplot as plt
import amptek_hardware_interface as ahi
# create the interface
amptek = ahi.AmptekHardwareInterface() amptek = ahi.AmptekHardwareInterface()
#amptek.connectUDP("192.168.1.10", 10001, 1)
# connect the intrerface via USB to the first DP5 device.
# To connect to a specific device, change the -1 to the serial number
# For basic tests, the simulator interface can be used, of no hardware is available.
# Use amptek.connectSimulator() instead
amptek.connectUSB(-1) amptek.connectUSB(-1)
print("ping")
print( amptek.Ping() )
# print("status")
# dat= amptek.readStatus(-1)
print( "fnished" )
amptek.GetSpectrum()
# Send a ping to test the connection
if amptek.Ping() :
print("Ping succeeded")
else:
print("Ping failed! Exited")
sys.exit()
# Print some common configuration values
config_names = ["RESC", "CLCK", "TPEA", "GAIF", "GAIN", "RESL", "TFLA", "TPFA", config_names = ["RESC", "CLCK", "TPEA", "GAIF", "GAIN", "RESL", "TFLA", "TPFA",
"PURE", "RTDE", "MCAS", "MCAC", "SOFF", "AINP", "INOF", "GAIA", "PURE", "RTDE", "MCAS", "MCAC", "SOFF", "AINP", "INOF", "GAIA",
"CUSP", "PDMD", "THSL", "TLLD", "THFA", "DACO", "DACF", "DACF", "CUSP", "PDMD", "THSL", "TLLD", "THFA", "DACO", "DACF", "DACF",
...@@ -16,8 +40,33 @@ config_names = ["RESC", "CLCK", "TPEA", "GAIF", "GAIN", "RESL", "TFLA", "TPFA", ...@@ -16,8 +40,33 @@ config_names = ["RESC", "CLCK", "TPEA", "GAIF", "GAIN", "RESL", "TFLA", "TPFA",
"PREC", "PRCL", "PRCH", "HVSE", "TECS", "PAPZ", "PAPS", "SCOE", "PREC", "PRCL", "PRCH", "HVSE", "TECS", "PAPZ", "PAPS", "SCOE",
"SCOT", "SCOG", "MCSL", "MCSH", "MCST", "AUO2", "TPMO", "GPED", "SCOT", "SCOG", "MCSL", "MCSH", "MCST", "AUO2", "TPMO", "GPED",
"GPGA", "GPMC", "MCAE", "VOLU", "CON1", "CON2"] "GPGA", "GPMC", "MCAE", "VOLU", "CON1", "CON2"]
print( "amptek.GetTextConfiguration( config_names )")
configs = amptek.GetTextConfiguration( config_names ) configs = amptek.GetTextConfiguration( config_names )
print(configs) for config in configs:
print(amptek.SerialNb()) print(config)
print("done")
\ No newline at end of file # prepare a 10 second acquisition
amptek.ClearSpectrum()
amptek.SetPresetAccumulationTime(4)
# start acquisition
amptek.Enable()
print("Acquisition started")
# check the current status and some status attributes every second until finished
while True:
time.sleep(1)
status = amptek.updateStatus(-1)
# test if finished
if not status.IsEnabled():
break
print("\rAccumulation Time: {:.2f}s, Fast Counts: {:d}, Slow Counts: {:d}".format( status.AccTime(), status.FastCount(), status.SlowCount() ), end="", flush=True)
print("Acquisition finished")
# plot finished spectrum
fig, ax = plt.subplots()
ax.plot( amptek.GetSpectrum() )
plt.show()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment