Skip to content

jonathan/pyiocinstall

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

Installation

epics base 3.14 has to be installed(tested with epics base-3.14.12.5) as well as python2.7

Install requirements according to requirements.pdf (or the html-version 'index.html').

Enter pythonIoc directory. Change the location to the EPICS_BASE in configure/RELEASE

make

Getting Started

Setting up the IOC

Create a file 'run' and write the following into it:

#!/bin/sh
cd "$(dirname "$0")"
path/to/pythonIocDirectory/pythonIoc startup.py "$@"

Create a file 'versions.py' and write the following into it:

from pkg_resources import require

require('cothread>=2.9')
require('epicsdbbuilder')

Create a file 'startup.py' and write the following into it:

import sys
DEBUG = 'D' in sys.argv[1:]
if DEBUG:
    sys.path.append('/scratch/local/python-debug')
    sys.path.append('/home/mga83/epics/cothread')
    sys.path.append('/home/mga83/epics/iocbuilder')
else:
    import versions

import cothread
from softioc import softioc, builder, pvlog

from iocdatabase import *

builder.LoadDatabase()
softioc.iocInit()

softioc.interactive_ioc(globals())

Create a file 'iocdatabase.py'. In this file you initialize the PV's you want to have in your Ioc.

At first import the iocbuilder module

from softioc.builder import *

Add the following function:

def on_update(value):
        print 'on_update', repr(value)

And set the device name e.g 'ENIGMA_V2'

SetDeviceName('ENIGMA_V2')

Now you can start initializing the PV's The basic syntax is:

varname = function('PV_name', initial_value=value, on_update = on_update)

The name of the function depends on the data type of the PV

Floating point numbers:

eg_ai = aOut('test_float', initial_value=12.23, on_update = on_update)

Long integer:

eg_long = longOut('test_long', initial_value=2017, on_update = on_update)

String:

eg_string = stringOut('test_string', initial_value='test string', on_update = on_update)

Waveform:

eg_wf = WaveformOut("test_wf", datatype = float, length = 100,on_update=on_update)

Bool:

eg_bool = boolOut('test_bool', 'True', 'False', initial_value= True, on_update = on_update)

You can replace 'True' and 'False' with any String you want. eg '0' and '1'

eg_bool = boolOut('test_bool', '0', '1', initial_value= True, on_update = on_update)

The initial value can be 'False' or 'True' and 0 or 1 respectively for the first or the second state

If you want a PV which can have more than two states, you can use the mbb type:

eg_mbb = mbbOut ('test_mbb', 'this', 'is', 'an','example',initial_value = 1, on_update = on_update)

The initial value is the index from the set values starting with 0 as the first value.

Work with the IOC

Start the IOC with executing the 'run' file. Now you can set or get the PV values. The general syntax is caget DeviceName:PVname e.g. caget ENIGMA_V2:test_float or caput ENIGMA_V2:test_long 244

A more in-depth Documentation can be found in 'pythonioc/docs'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published