Files
ncs/script/tutorial/17_DirectEpicsAccess.py
boccioli_m 79e9aac763 Startup
2015-09-02 10:39:31 +02:00

31 lines
942 B
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()
lscan(channel, (ai2,channel), 0, 10, 0.1)
#The channel class implements Readable and Writable and therefore can be used in scans
lscan(channel, ai2, 0, 10, 0.1)
#Or else we can use a Device
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
channel = ChannelDouble("My Channel", channel_name)
channel.initialize()