lnls-sol / py4syn

Python For Synchrotron
Other
18 stars 10 forks source link

Motor soft limit checking has something wrong #4

Closed marciodo closed 8 years ago

marciodo commented 8 years ago

from py4syn.epics.MotorClass import Motor mtop = Motor("SOL11:SIM:m1", "mtop") mtop.getHighLimitValue() 105.0 mtop.getLowLimitValue() -100.0 mtop.getValue() 33.0 mtop.setAbsolutePosition(101) mtop.getValue() 101.0 mtop.setAbsolutePosition(200)

Nothing happens, as expected. But for now on:

mtop.setAbsolutePosition(90) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.5/site-packages/Py4Syn-0.3.0+27.g1be90d1-py3.5.egg/py4syn/epics/MotorClass.py", line 550, in setAbsolutePosition Exception: Can't move motor motor 1 (SOL11:SIM:m1) to desired position: 90, Movement beyond soft limits

Nothing works from this point: absolute/relative movements inside the soft limits and position redefinition inside soft limits. One must move the motor using caput in a terminal and, after that, Py4Syn starts to move motors again.

hdante commented 8 years ago

I have a patch for this from December, but tests suggested it was not correct. I'll post them next week.

hdante commented 8 years ago

Nothing happens, as expected. But for now on:

It should have raised an exception.

hhslepicka commented 8 years ago

@marciodo Good catch! I thought that this was covered but unfortunately we were basing the software limits on the LVIO which will be 1 even when we want to move on the opposite direction.

@hdante I fixed this issue with this first approach. Please let me know if you see any problem.

I tested with simMotors, more tests are required.

hhslepicka commented 8 years ago
((py4syn)) ➜  test python test.py
105.0
-100.0
0.0
101.0
exception:  Can't move motor motor 1 (HHS:m1) to desired position: 200, Target beyond value for software high limit.

test.py is:

from py4syn.epics.MotorClass import Motor
mtop = Motor("HHS:m1", "mtop")
print(mtop.getHighLimitValue())
#105.0
print(mtop.getLowLimitValue())
#-100.0
print(mtop.getValue())
#0
mtop.setAbsolutePosition(101, waitComplete=True)
print(mtop.getValue())
#101.0
try:
    mtop.setAbsolutePosition(200)
except Exception as e:
    print("exception: ", e)
# Nothing happens, as expected. But for now on:
mtop.setAbsolutePosition(90)
marciodo commented 8 years ago

I tested and it seems it is ok, now.