Files
x07ma/script/tutorial/17_DirectEpicsAccess.py
2015-08-24 08:28:12 +02:00

37 lines
1.0 KiB
Python

"""
EPICS direct channel access.
EPICS devices implemented are included in PShell, package ch.psi.pshell.epics.
However direct channel access builtin functions are available.
"""
channel_name = "TESTIOC:TESTCALCOUT:Output"
#reading/writing to a channel
print (caget(channel_name))
caput(channel_name, 0.0)
#Put with no wait
caput(channel_name, 0.0)
print (caget(channel_name))
#waiting for a channel valur
cawait(channel_name, 0.0, timeout = 10.0)
#If many IO it is better to keep the same CA connection
channel = Channel(channel_name, 'd')
for i in range(100):
print channel.get()
#In order to use in a scan we need to implement Readable/Writable interfaces.
#A wripper device can be created as:
channel = create_channel_device(channel_name, 'd')
lscan(channel, ai2, 0, 10, 0.1)
#Or else we can use ch.psi.pshell.epics
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
channel = ChannelDouble("My Channel", channel_name)
channel.initialize()
lscan(channel, ai2, 0, 10, 0.1)