From 44537ad0d9c34e002c4a3ee7501ee83b00c00004 Mon Sep 17 00:00:00 2001 From: Enrico Faulhaber Date: Wed, 31 Aug 2016 10:20:07 +0200 Subject: [PATCH] split epics related devices into epics.py also split the configfile: test.cfg for normal playing around epics.cfg for playing with epics Change-Id: Id91042fbbdcb6972b1493419960667b39f56f17e --- etc/epics.cfg | 11 ++++++++++ etc/test.cfg | 12 +++++++---- src/devices/epics.py | 51 ++++++++++++++++++++++++++++++++++++++++++++ src/devices/test.py | 19 ----------------- 4 files changed, 70 insertions(+), 23 deletions(-) create mode 100644 etc/epics.cfg create mode 100644 src/devices/epics.py diff --git a/etc/epics.cfg b/etc/epics.cfg new file mode 100644 index 0000000..029fe1b --- /dev/null +++ b/etc/epics.cfg @@ -0,0 +1,11 @@ +[server] +bindto=0.0.0.0 +bindport=10767 +interface = tcp +framing=eol +encoding=text + +[device epicspv] +class=devices.epics.EPICS_PV +sensor="test_sensor" +max_rpm="very high" diff --git a/etc/test.cfg b/etc/test.cfg index eac6fae..c466791 100644 --- a/etc/test.cfg +++ b/etc/test.cfg @@ -16,7 +16,11 @@ maxheaterpower=10 class=devices.test.Temp sensor="X34598T7" -[device epicspv] -class=devices.test.EPICS_PV -sensor="test_sensor" -max_rpm="very high" +[device T2] +class=devices.demo.CoilTemp +sensor="X34598T8" + +[device T3] +class=devices.demo.CoilTemp +sensor="X34598T9" + diff --git a/src/devices/epics.py b/src/devices/epics.py new file mode 100644 index 0000000..d819a3a --- /dev/null +++ b/src/devices/epics.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# ***************************************************************************** +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Module authors: +# Enrico Faulhaber +# ***************************************************************************** + +"""testing devices""" + +import random + +from devices.core import Readable, Driveable, PARAM + + +try: + from epics import PV +except ImportError: + PV=None + + +class EPICS_PV(Driveable): + """pyepics test device.""" + + PARAMS = { + 'sensor': PARAM("Sensor number or calibration id", + validator=str, readonly=True), + 'max_rpm': PARAM("Maximum allowed rpm", + validator=str, readonly=True), + } + + def read_value(self, maxage=0): + p1 = PV('testpv.VAL') + return p1.value + + def write_target(self, target): + p1 = PV('test.VAL') + p1.value = target diff --git a/src/devices/test.py b/src/devices/test.py index 15bb4c6..0fe4ce2 100644 --- a/src/devices/test.py +++ b/src/devices/test.py @@ -26,8 +26,6 @@ import random from devices.core import Readable, Driveable, PARAM from validators import floatrange -from epics import PV - class LN2(Readable): """Just a readable. @@ -76,20 +74,3 @@ class Temp(Driveable): pass -class EPICS_PV(Driveable): - """pyepics test device.""" - - PARAMS = { - 'sensor': PARAM("Sensor number or calibration id", - validator=str, readonly=True), - 'max_rpm': PARAM("Maximum allowed rpm", - validator=str, readonly=True), - } - - def read_value(self, maxage=0): - p1 = PV('testpv.VAL') - return p1.value - - def write_target(self, target): - p1 = PV('test.VAL') - p1.value = target