Transported values in a change must be converted first.
As this is only relevant for the exotic "scaled" and "blob"
datatypes, this was not detected yet.
- add tests
- suppress warning PytestUnhandledThreadExceptionWarning in tests
+ change import_value methods to raise no other exceptions than
WrongTypeError and RangeError
+ simplify Command.do: as import_value already raises the
appropriate error, no more try/except is needed
Change-Id: I299e511468dc0fcecff4c20cf8a917da38b70786
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/32743
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
Transported values in a change must be converted first.
As this is only relevant for the exotic "scaled" and "blob"
datatypes, this was not detected yet.
- add tests
- suppress warning PytestUnhandledThreadExceptionWarning in tests
+ change import_value methods to raise no other exceptions than
WrongTypeError and RangeError
+ simplify Command.do: as import_value already raises the
appropriate error, no more try/except is needed
Change-Id: I299e511468dc0fcecff4c20cf8a917da38b70786
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/32743
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
- StringIO.writeline sends a command and does not expect a reply
- StringIO.multicomm and BytesIO.multicomm is improved in order
to insert individual delays in between lines and individual
noreply flags
+ fix a bug in tutorial_t_control
+ improve readability of frappy.lib.classdoc.indent_description
Change-Id: I9dea113e19147684ec41aca5267a79816bbf202c
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/32267
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
latexpdf fails with error message "Too deply nested".
We want to avoid reducing the nesting level of doc strings
in frappy.lib.classdoc (less nice output) or a level of
nesting in method doc strings.
- latex removed from Jenkinsfile
- added support for rst2pdf
Change-Id: Ieb3355ef506e636e7e43a726c68327e3b1154469
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/32406
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
Split module handling code from the dispatcher.
The new class for managing Modules is called SecNode.
* change logging to no longer need a reference to modobj
* modules get a reference to the secnode obj instead of the
dispatcher
* intermediate usage fixes for frappy_psi/sea
Change-Id: Ifee4bb47aa7a4508bb4a47c9a5873b7e2d5faf67
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/32249
Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
- frappy_psi.channelswitcher: use isBusy instead of checking value and target
- frappy_psi.ls372: remove underflow mechanism
- frappy_psi.parmod.SwitchDriv: switch the controlled module also when not buys
in SecopClient.disconnect joinng the reconnect thread may take
up to 10 s, because of the time.sleep(10) call in the reconnect
thread.
change the _shutdown attribute from bool to an Event, and
use Event.wait instead of time.sleep
Change-Id: Icea6a14ad73df0b3d26ef45806f4c05e6bf18492
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/32137
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
in the previous version FloatRange(max=100) was neither working
properly nor complaining, because the maxval=None default was
overriding the value for max.
possible fixes:
- raise an error when min/max used as argument (confusing for
the programmer, as it is a property)
- allow both versions minval/maxval and min/max (more code)
- use min/max and a pylint directive here (the only thing to
take care is not to use the min/max builtin in __init__)
this change uses the last option for the fix
Change-Id: Iff0e0c4d0d7b165003bdeffa67a93a1cd7f29eea
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/31982
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
reading back the target does not work properly, because
a) the readback value might be delayed
b) there is no command to read back the target, SETP?1
is returning the working setpoint, which might be distinct
in case of a ramp
Change-Id: I0da2dbfc1a8ddbecbae6d0456ff64e008bc56336
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/31983
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
the reasonly class frappy_psi.parmod.Par represents a parameter
or a component of a tuple parameter
Change-Id: I47208c9d7a6fc377cd56b82cc6a9e8cdb433fe8e
on shutdown, time.sleep(10) is blocking the reconnect thread.
change the _shutdown attribute from bool to an Event, and
use Event.wait instead of time.sleep
Change-Id: Icea6a14ad73df0b3d26ef45806f4c05e6bf18492
- when driving a module with <module>(<target>),
keyboard interrupt should send stop()
- make sure keyboard interrupt does not only stop
the current driving, but also skips other code
on the same command line
Change-Id: Ib4d2c4111dc0f23bf07385065766fb9b4a611454
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/31926
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
restarting the phytron motor without prior stop leads
to funny behaviour.
- send stop before restart
- stop motor when moving but status not busy
- restart when motor drives the wrong way
+ better status text when stopping
Change-Id: I82cd59297b3c79a354a4eeb5ba03fc65bedf755f
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/31929
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
for host name without port, None was used for the port
leading to a confusing error message
- do not call parse_host_port with None as defaultport argument
- improve error message when connection fails
+ fix an error in last line of parse_ipv6_host_and_port
+ fix some issues breaking PEP 8 rules
Change-Id: I437360be96449c164f0080e3c60f1685825d4780
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/31911
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
- in SEA, it is not guaranteed that the is_running state is set
before the run command returns. as a consequence, we have to
wait in SeaDrivable.write_target for is_running being set
- syncio has always to be reconnected after asynio
Change-Id: Ia46cff11de86868ce0627faaf6f776282bd7a8f4
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/31631
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
the _connect was sometimes started in parallel from
startModules and the first call to doPoll.
remove the first one, and protect the second one
with a lock
Change-Id: I079439e150efd5d005130cef475f6326f933ecbd
adds a generic solution for creating parameters with struct datatype
with their members linked to individual parameters.
main use case: ctrlpars
read_*/write_* methods are either created for the main (structed)
parameter based on the corresponding methods of the individual
parameters or the methods for the individual parameters are created
based on the methods of the main parameter
+ disable pylint use-dict-literal
Change-Id: I7f1d9fb3d3b2226b548c2999bbfebe2ba5ac285e
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/31405
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
add module which scans a connection and registers new devices depending
on the answer.
* change module initialization to demand-based
* move code from server to dispatcher
- remove intermediate step in Attached __get__
TODO:
factor out dispatcher (regards to playground)
discuss factoring out of module creation code from server AND
dispatcher
Change-Id: I7af959b99a84c291c526aac067a4e2bf3cd741d4
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/31470
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Georg Brandl <g.brandl@fz-juelich.de>
Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
%d accepts floats and other things, so manual fixes are needed after
conversion.
After flynt -ll 2000 --aggressive, each was manually checked if the
casts with int() are needed.
Two statements are still missing in ls370res
Change-Id: I2651ddbe60695aa19582882a97d0f71bcb05c1ef
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30901
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
- treat validation errors of the result of write_ and read_ messages
properly
- add info about the called read_* and write_ methods to the error
message, in case the error is not raised in the outmost method
- as subsequent errors in poll functions are logged only once, log an
info when a poll function succeeds again
- remove DiscouragedConversion error
Change-Id: Ib66e001cc95de8225751a1464a92594c369ceb3f
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30788
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
* add optional parameter for ValueType: validator
used for checking, if a value meets a criteria (e.g. is dict)
+ InternalParameter, which is not exported and can hold any python value
Change-Id: If39a7a4a8019f2aa1a930e42cbef4fca59163b78
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30787
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
- include all secop errors from spec
- add doc strings
- make conversion to and from error report nicer
- move all error classes to frappy.errors
- rename errors clashing with built-in errors
Change-Id: I4d882173b020cd4baf862c5891375b691e67e24a
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30721
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
- check for <param>_min and <param>_max
- customized checks with check_<param> method
the inherited customized check functions are all called in
a sequence, with the possibilty to return True to quit earlier,
no need to use super calls here
Change-Id: I903081abbbad2586c1e8237e303abaa3683ac419
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30632
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
'Done' was introduced in order to suppress unneccessary
duplicate updates. However, since super calls on access methods are
allowed, it is not nice when such a method returns Done, as this
is not automagically replaced by the current parameter value.
As a consequence:
- using Done is discouraged, but not (yet) removed in all code
- the 'omit_unchanged_within' property is moved from Module to an
internal Parameter property 'update_unchanged'
- its default is moved from a SEC node property to generalConfig
- the 'update_unchanged' parameter property may be set to
'never' for parameters where duplicate updates make no sense
- this property might be set to 'always', for measurements, where
even unchanged values taken from HW should be transmitted
Change-Id: I2847c983ca09c2c4098e402edd08d0c96c3913f4
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30672
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
- use Datatype.format_value to convert all values
- frappy.client.ProxyClient: use CacheItem instead of 3-tuple
- CacheItem has built in formatting
- adapt gui to use it instead of stopgap
As it is now easy to convert to string including values, it may
be better to move the unit in the modulewidget into the value field.
This would simplyfy the code.
Change-Id: I5c06da4a24706fcbc83ebcbf8c0ea6a8eb6d7890
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30680
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
- remove legacy feature proposals
- add Feature.featureName (in case not matching ptyhon class name)
Change-Id: I7a09fc5e24067b2fde5d2c04523bc5d2172e714b
allow to define default settings on the IO class:
- a default 'port' may be given for tcp
- defaults like 'baudrate' or 'parity' might be given
for serial connections
this avoids explicit settings in the config file in case
the settings can not be changed or have a typical value
other than the defaults in serial.Serial
Change-Id: I990f47d63e785f8cc48c4af197944a8eebe91fb4
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30555
Reviewed-by: Georg Brandl <g.brandl@fz-juelich.de>
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
- proxy: remote parameter status should overddide datatype from
ProxyModule.status
- ppms: create PpmsDrivable instead of importing from
(PpmsBase, Drivable). Order matters for status parameter!
- update cfg files
Change-Id: If8fc263cffb903d8b3c1a93a089dcac3597d13a0
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30512
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
json values were not converted properly, resulting in integers
instead of enums at the client side
+ add log.debug in rx thread
Change-Id: Ifc3c3b28540eb6a516d77387a3f83711f34b7480
add tutorial for Berlin hands-on workshop
+ improve the documentation (hints for structure welcome)
+ remove 'optional' parameter property
(is not yet used - should not appear in doc)
+ added test property in frappy_demo.cryo alters Parameter class
('test' property appears in Parameter doc)
Change-Id: I3ea08f955a92f72451fd23a5ff00d1185c7fb00e
use mro for status code inheritance
- as a consequence, the decorator class 'StatusCode' is now a
decorator function 'status_code'. snake case is anyway more
common for decorators.
- adapt tests
+ fix an error message
Change-Id: Ib409b963c51e0fe807397ff1d73d77d0147b8580
- watch is now a command, not a module method
- finish watching with ctrl-C
- watching an io module logs communication
- add bin/frappy-cli to start interactive client
+ remove sorted function from StructOf.format_value
Change-Id: I7dd707473e4534f2d39c5d6afc533c2d872380f8
- fixed this for 'read', 'change' and 'do' message
+ fix an error in frappy.client.SecopClient closing the connection
when the identifier is None
fixes: #4672
Change-Id: Iaba0f9ed86b6eb6ef7588403ba640ded552dded6
fast_interval might be 0, indicating to poll as fast as possible
- this should not throw a zero division error
Change-Id: I26e18f5a656c943b906c6ffff65361e1fcf16d50
A value given in config overrides values read from the persistent data file.
To let the loaded parameter have precedence, configure a default only.
The write_<param> method of a persistent parameter is now always called
on startup.
- add tests for persistent behaviour
+ simplify Modules.writeInitParams: remove started_callback argument
Change-Id: I08b49de52e9d9a2ed0918018eb2fe538141a4f5e
- make 'value' a Parameter property instead of an attribute
- use 'value' instead of 'default' property for setting
the initial value in the config file
- removal of initwrite parameter property
this change is the basis of a better implementation
for change 30041 (PersistentParam property 'override_cfg')
Change-Id: I2b82bdd54c2dacb87dcd2b3472004d2f0a730cf0
After 29724, the change in frappy_demo/modules.py from 30183 which was
made to run 'make demo' without errors can be reverted.
Change-Id: I00a6f512304a3159c10e44aef670ac0edd4703d7
* Add python config for test and demo server
* Remove old configs
* Fix issue with slow start of test server
Change-Id: If0e576f4e4dda8b03489fdbb79b209dfcdca29ff
- use Datatype.validate for converting and checking limits
(used also in properties)
- Datatype.__call__ converts and validates, but without checking
limits (used in setter)
- Datatype.validate may be used to add missing optional struct elements
from previous value (used in Dispatcher._setParameterValue)
- remove problematic range check
+ use shorter formula for converting float to int in ScaledInteger
(leftover from python2 compatibility)
+ improve error messages (strip very long repr(value))
Change-Id: Ib85736fe558ec3370ebce4e1c43f957e3bb0497c
The text part of the error report contains the original error
class - convert it to the frappy error class, if possible.
This makes the error messages on the client nicer, as the
error class would be duplicated in the error message on the
client side.
Change-Id: If2e0c3eb15ac2dd1b80a851ff42e4076557a325d
values return from read_* methods should be converted
from string to float on float parameters
+ fix some wording
Change-Id: Ic80010c6fbe3eef23483ff69c8a43e25afb8bb6a
- Change Configuration format to be python-based.
- move config logic to frappy/config.py
- Add first py-config: cryo_cfg.py
- Adapt test to new expected config format
Change-Id: Iaec484e0e1e21ebbb1e5c74b53be6231329ddf71
With the current implementation, we run into a deadlock with the lock
from the state machine interfering with the accessLock on the module.
We can not wait for the state machine to finish while having the
accessLock locked by write_target. As a consequence, when restarting
the state machine we should not wait, but remember the state function
to call and postpone the restart after the cleanup has finished.
For this, we want to know the status before calling the state function.
- create HasState mixin, using doPoll for driving the machine
- StatusCode decorator for assigning a status to a state function
- remove the state machines 'threaded' option
- 'Retry' is now a unique value instead of a class. The retry period
is determined by the (fast) poll interval.
- return 'Finish' instead of None for finishing the machine. returning
None for state function is now an error, as this might happen
easily inadvertently.
Change-Id: Icb31367442f10e98be69af3e05a84f12ce5cc966
- use python 3.9 (3.9 bullseyse)
- add latex-fonts-extra to fix missing tgtermes.sty
- in bullseye python3-pytango has been renamend to python3-tango
(https://packages.debian.org/stable/python/python3-tango)
Change-Id: I06c8d8e432644f657057d14bbe754f28e2c10dd4
- SECoP modules are accessible as objects in the main python module
- parameters are accessed as attributes of these objects
- __repr__ is used for listing all parameters
- __call__ is used for 'change target and wait until no more busy'
typically used from a python interpreter or in a jupyter notebook
Change-Id: Idb55684eeff6d1262e5d1517a3ff934f1c1bf208
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/28980
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
- repeated errors on poller are only once logged (per poll
function / read_* method)
- during exception handling, silent=True on a SECoP error indicates
that the error is already logged
+ fix the name of HardwareError
+ add test for consistency of SECoPErrors
+ catch socket.timeout in AsynTcp
Change-Id: I9df6c775cc19553b22a4d6e39591092adf7ff9a1
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/28139
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
in secop.proxy the callers modules method announceUpdate is
called from an other thread while the accessLock is locked,
creating a deadlock. solve this by creating an other lock
'updateLock' for the update.
+ add status parameter even to non-Readable proxy modules,
in order to indicate a failed connection
+ fix an error in secop_psi/softcal.py
Change-Id: Iae7c6d5a74001150a47aa9dc99209c15d972cd5e
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/28130
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
- safe_current: current limit for unlimited move
- move_limit: max. angle to move with high current > safe_current
- direct axis parameter access is not exported by default
- support for home switch
- allow use without encoder
- automatic reset for motors in a configuration, where the motor
current is deliberatly low for a limited torque
- improved error message on driving failures
Change-Id: I25f8516905a2c4c3cda09d091d5a43004ec6dc6f
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/28029
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This valve needs 8 turns to open. As the encoder forgets
the number if turns on power cycle, a home switch is
mounte, which engages during the last turn when closing.
The final close position is determined by closing the valve
with a defined motor current/torque.
+ fix an issue in StateMachine.start: the first cycle
must be called after the new state is assigned
Change-Id: I34cd05d10d97b043f9e3126310943b74ee727382
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/28030
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
When several poller threads are using the same io, the resposivity
of client requests is reduced, as every thread first finishes
its pending communication requests, before it is the turn of the
request thread. This is solved by using one common poller thread
for all modules sharing the same communicator.
+ fix an issue with overriding a property with a parameter, as
this is the case for pollperiod (cfg was applied to property
instead of overriding parameter)
+ separate setFastPoll arguments into flag and fast interval
+ fix missing announceUpdate call when read function fails
+ fix mechanism for triggering polls after an io connection
reconnected again.
Change-Id: I1115a61fae3de80d18416e61f40b52a0eebb637c
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/28021
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
- write method may be used internally on a readonly parameter
+ add IDLE, WARN, BUSY and ERROR to secop.core
+ secop.datatype.EnumType: allow 'self' as member name
+ secop.lib.statemachine: log Restart and Stop exceptions only on debug level
+ secop_psi.ccu4.CCU4: explicit conversion to float
+ secop.proxy: remove superfluos and erroneous make_secop_error
Change-Id: I2f13d31ceacd2bde65eab64f8eae4225556c18f5
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/27963
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
- Attached checks now for proper base class
- fixes an error in Attached: attached saved in attachedModules
dict instead on the Attached object (which sits on the class!)
+ fix: in testonly mode errors must be logged before returning
+ fix: use repr of exception in poll to check for repeated errors
Change-Id: I141fa107fed48e58b55ddf1e071987656c0f618f
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/27913
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
- remove secop.poller and basic poller
- regular polls for 'important' parameters done by method doPoll
- all other parameters are polled slower (slowInterval) and
with lower priority (only one at a time when main poll is due)
- nopoll decorator for read_* to disable poll
- enablePoll attribute (default True) for disabling polling a module
- fast polls may be implemented by means of a statemachine
- configurable slow poll interval
+ allow a Parameter to override a Property (parameter
Readable.pollinterval overrides Module.pollinterval)
Change-Id: Ib1b3453041a233678b7c4b4add22ac399670e447
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/27832
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
a quite simple, but powerful state machine
There is not need to subclass StateMachine, but use an instance
of it. The code typically lives on methods of an other class.
Features:
- store any variables (except already defined attributes) on the state
- actions handle the conditions to stay or initiate a transition
by calling the state machines goto method
- a state machine might run endlessly or finish in a None action.
- it may be started or restarted
- a cleanup function for handling exceptions and for stop or restart
- support for time dependent features
Change-Id: I86b86ed1f25d04e305237edb99206912b068aedf
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/27593
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
A common problematic practice is, to declare the value parameter
with the same FloatRange than the target. Because of measurement
errors, a value might be near, but outside the limit.
In order to avoid this, we force the programmer to declare a
bigger range for the value than for the target, or to
explicitly disable this check on a module property.
It is also fine to declare the value without limits.
This behavior may be disabled via command line option or in the
general config file. For simplicity, FloatRanges inside data
structures are not considered.
+ above command line option is also used to disable the error
handling on a string to float conversion
+ log appropriate error message for string to float conversion
Change-Id: Ib78ea1fb7c821442bf5847030573c8c27822dea5
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/27574
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
a read method should not reply on the automatic conversion
of the return value from string to a number.
- transitional solution with generalConfig.lazy_numer_validation
+ changing slighly generalInit mechanism: for above feature
generalConfig.init is not required to be called (i.e. when
used on the client side)
Change-Id: Ibecce1a45669273c105932acdc0908de55bfd1b9
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/27516
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
modules with a couple of parameters with similar read_* or
write_* methods may handle them by generic methods wrapped
with decorators ReadHandler / WriteHandler
The trinamic driver is included in this change for demonstrating
how it works.
In a further step, the special handling for the iohandler stuff can
be moved away from secop.server and secop.params, using this feature.
+ fix problem on startup of trinamic driver (needs MultiEvent.queue)
+ some other small fixes
+ apply recommended functools.wraps for wrapping
Change-Id: Ibfeff9209f53c47194628463466cee28366e17ac
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/27460
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
- bin/secop-server options -v and -q applied to console logger only
- level for logfile taken from general config
- option for automatic deletion of old logfiles
- added 'comlog' level (between debug and info)
This allows to run the servers by default with 'comlog' level on
the logfiles, which helps a lot for analyzing very rare communication
errors in retrospect.
to avoid spamming of the normal log files, comlog data is stored
separately, one file per communicator
+ redesign of remote logging (no more need of LoggerAdapter)
Change-Id: Ie156a202b1e7304e50bbe830901bc75872f6ffe2
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/27427
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
fix 2 problems:
- in case the window is smaller than the pollinterval, isAtTarget might be False
for up to the timeout delay
- in case the history is shorter than the window, and the ramp is fast enough to miss
any points during ramp, isAtTarget is True before the window time is reached.
This happens because the history is reset on write_target
+ do not wait when target is not changed (by more than precision)
tested!
Change-Id: Ia4ff4378fe91fa93be50168b2883a20b49ebfb6a
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/27159
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
- fix CommandType.__repr__
- secop/modules.py: command properties are allowed to be configured:
- section 2: remove comment and rename
- section 3: all accessible properties should be checked
- command description should be inherited also when taken from docstring
- move test for command inheritance to test_modules.py
- added tests to check for valid properties of commands
Change-Id: Ic7795e305048625558e415ece099e6824df6e2c4
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/27135
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
Correct inheritance has to follow the MRO, not only consider
the direct base classes.
Patchset 3: changed only tests, indicating that we need to change the code
Following patchsets include a major change in params.py and
modules.py. The parameter properties for inheritance, corresponding
mainly to the constructor arguments have to be stored separately
from the property values including inherited stuff.
Change-Id: Ibcbccb6abcc22e7e2d91df8f70ef64226684d8cc
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/26805
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
- nodestatechange callback must appear after the online attribute
is changed
- IntRange: move range validation outside of try except
- fixes on some error names
- well defined error message 'no such class' in secop.lib.get_class
- try again 4 times when starting Tcp Server on EADDRINUSE
- fix error handling
Change-Id: I4eee9b79ea8173936b9f5193b87e006ac8fca827
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/26171
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
- wrong unit for 'ramp'
- disable Setposition for TemperatureController
- write_target should return the new target
- AnalogInput should not crash initialisation if reading the unit fails
- convert super(...) calls to py3 style super()
- use proper exception chaining
- NamedDigital*put: mapping may already be a dict.
Change-Id: I03ce5f29581dcb3b33466771e7a8b8dd4b1e2bdb
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/25960
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Tested-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Config errors are collected first, and raised after processing
all modules. This is more user friendly.
+ remove redundant check for predefined accessibles in modules.py
+ fixed error handling for exporting parameters in params.py
+ fixed handling of bare attributes overwriting properties
+ fixed race condition in writeInitParams
Change-Id: I894bda291ab85ccec3d771c4903393c808af0a2a
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/25128
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
- a new wrapper for a read function is not only to be created when
the a new read method is in the class dict, but also when
it is inherited, but not yet wrapped
- a handler must not be ignored, when a write method is inherited
- a proxy class must not call checkProperties
+ remove trailing spaces in tutorial_helevel.rst
Change-Id: I16024c14232ea200db91a1bc07ec23326219ab68
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/25093
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
- removed secop/metaclass.py
- moved code from ModuleMeta to modules.HasAccessibles.__init_subclass__
- reworked properties:
assignment obj.property = value now always allowed
- reworked Parameters and Command to be true descriptors
- Command must now be solely used as decorator
- renamed 'usercommand' to 'Command'
- command methods no longer start with 'do_'
- reworked mechanism to determine accessible order:
the attribute paramOrder, if given, determines order of accessibles
+ fixed some issues makeing the IDE more happy
+ simplified code for StatusType and added a test for it
Change-Id: I8045cf38ee6f4d4862428272df0b12a7c8abaca7
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/25049
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
- flatten hierarchy (some links do not work when using folders)
- add a tutorial for programming a simple driver
- clean description using inspect.cleandoc
+ fix a bug with 'unit' pseudo property in a Parameter used as override
Change-Id: I31ddba5d516d1ee5e785e28fbd79fca44ed23f5e
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/25000
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
New Syntax:
- define properties and parameters as class attributes directly
instead of items in class attribute dicts
- define commands with decorator @usercommand(...)
- old syntax is still supported for now
still to do (with decreasing priority):
- turn parameters into descriptors (vs. creating getters/setters)
- migrate all existing code to new syntax
- get rid of or reduce code in metaclasses using __set_name__ and
__init_subclass__ instead, including a fix for allowing py < 3.6
Change-Id: Id47e0f89c506f50c40fa518b01822c6e5bbf4e98
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/24991
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
- when applying overrides with reorder=True, take ctr from Override,
else copy from the cloned Accesible. This did not work properly
- reworked:
- replaced CountedObj class by object_counter
- accessibles created by a copy or by applying Overrides
do not need fresh counted values
- adjusted tests
Change-Id: Id2fcf1ab1295aa1ea80ea81ae8cd02d36f86e969
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/24926
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
with handlers, a parameter from the cfg file which is not the
first of parameters with the same handler were not written.
fix: write_<param> method is called for all parameters in
<module>.writeDict even if there is no poll entry.
with this fix, when a parameter has the property initwrite=True,
the write_<param> method is called even when <param>
is not polled and even when <module>.pollerClass is None
Change-Id: I9b397deb5b20709fc4fa7c860c85b251a204c7f6
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/23995
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
2020-09-29 07:52:59 +02:00
51 changed files with 1506 additions and 2918 deletions
"""Get the name of the currently selected actuator
Parameters
axisNo Axis number (0 ... 2)
Returns
name Name of the actuator
"""
withself._lock:
returnself._hw.getActuatorName(axisNo)
defgetActuatorType(self,axisNo):
"""Get the type of the currently selected actuator
Parameters
axisNo Axis number (0 ... 2)
Returns
type_ Type of the actuator {0: linear, 1: goniometer, 2: rotator}
"""
withself._lock:
returnself._hw.getActuatorType(axisNo)
defgetAmplitude(self,axisNo):
"""Reads back the amplitude parameter of an axis.
Parameters
axisNo Axis number (0 ... 2)
Returns
amplitude Amplitude V
"""
withself._lock:
returnself._hw.getAmplitude(axisNo)
defgetAxisStatus(self,axisNo):
"""Reads status information about an axis of the device.
Parameters
axisNo Axis number (0 ... 2)
Returns
connected Output: If the axis is connected to a sensor.
enabled Output: If the axis voltage output is enabled.
moving Output: If the axis is moving.
target Output: If the target is reached in automatic positioning
eotFwd Output: If end of travel detected in forward direction.
eotBwd Output: If end of travel detected in backward direction.
error Output: If the axis' sensor is in error state.
"""
withself._lock:
returnself._hw.getAxisStatus(axisNo)
defgetFrequency(self,axisNo):
"""Reads back the frequency parameter of an axis.
Parameters
axisNo Axis number (0 ... 2)
Returns
frequency Output: Frequency in Hz
"""
withself._lock:
returnself._hw.getFrequency(axisNo)
defgetPosition(self,axisNo):
"""Retrieves the current actuator position. For linear type actuators the position unit is m; for goniometers and rotators it is degree.
Parameters
axisNo Axis number (0 ... 2)
Returns
position Output: Current position [m] or [°]
"""
withself._lock:
returnself._hw.getPosition(axisNo)
defmeasureCapacitance(self,axisNo):
"""Performs a measurement of the capacitance of the piezo motor and returns the result. If no motor is connected, the result will be 0. The function doesn't return before the measurement is complete; this will take a few seconds of time.
Parameters
axisNo Axis number (0 ... 2)
Returns
cap Output: Capacitance [F]
"""
withself._lock:
returnself._hw.measureCapacitance(axisNo)
defselectActuator(self,axisNo,actuator):
"""Selects the actuator to be used for the axis from actuator presets.
Parameters
axisNo Axis number (0 ... 2)
actuator Actuator selection (0 ... 255)
0: ANPg101res
1: ANGt101res
2: ANPx51res
3: ANPx101res
4: ANPx121res
5: ANPx122res
6: ANPz51res
7: ANPz101res
8: ANR50res
9: ANR51res
10: ANR101res
11: Test
Returns
None
"""
withself._lock:
returnself._hw.selectActuator(axisNo,actuator)
defsetAmplitude(self,axisNo,amplitude):
"""Sets the amplitude parameter for an axis
Parameters
axisNo Axis number (0 ... 2)
amplitude Amplitude in V, internal resolution is 1 mV
Returns
None
"""
withself._lock:
returnself._hw.setAmplitude(axisNo,amplitude)
defsetAxisOutput(self,axisNo,enable,autoDisable):
"""Enables or disables the voltage output of an axis.
Parameters
axisNo Axis number (0 ... 2)
enable Enables (1) or disables (0) the voltage output.
autoDisable If the voltage output is to be deactivated automatically when end of travel is detected.
"""Sets the DC level on the voltage output when no sawtooth based motion is active.
Parameters
axisNo Axis number (0 ... 2)
voltage DC output voltage [V], internal resolution is 1 mV
Returns
None
"""
withself._lock:
returnself._hw.setDcVoltage(axisNo,voltage)
defsetFrequency(self,axisNo,frequency):
"""Sets the frequency parameter for an axis
Parameters
axisNo Axis number (0 ... 2)
frequency Frequency in Hz, internal resolution is 1 Hz
Returns
None
"""
withself._lock:
returnself._hw.setFrequency(axisNo,frequency)
defsetTargetPosition(self,axisNo,target):
"""Sets the target position for automatic motion, see ANC_startAutoMove. For linear type actuators the position unit is m, for goniometers and rotators it is degree.
Parameters
axisNo Axis number (0 ... 2)
target Target position [m] or [°]. Internal resulution is 1 nm or 1 µ°.
Returns
None
"""
withself._lock:
returnself._hw.setTargetPosition(axisNo,target)
defsetTargetRange(self,axisNo,targetRg):
"""Defines the range around the target position where the target is considered to be reached.
Parameters
axisNo Axis number (0 ... 2)
targetRg Target range [m] or [°]. Internal resulution is 1 nm or 1 µ°.
Returns
None
"""
withself._lock:
returnself._hw.setTargetRange(axisNo,targetRg)
defstartAutoMove(self,axisNo,enable,relative):
"""Switches automatic moving (i.e. following the target position) on or off
Parameters
axisNo Axis number (0 ... 2)
enable Enables (1) or disables (0) automatic motion
relative If the target position is to be interpreted absolute (0) or relative to the current position (1)
assertmodcls.stop.func.__doc__# stop method needs a doc string
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.