Code Monkey home page Code Monkey logo

deviseghal's Introduction

EPICS Device Support for iseg Hardware Abstraction Layer

Introduction

The isegHAL library offers a string based application interface - API. The data collection from the iseg high voltage modules is done in background. All communication hand shake is handled by the isegHAL.

This module offers EPICS device support routines to use the isegHAL library within your EPICS applicaitons.

Build

Set pathes to EPICS_BASE and ISEGHAL in configure/RELEASE.local. The header files from isegHAL are searched in $ISEGHAL and $ISEGHAL/include, the shared object files in $ISEGHAL and $ISEGHAL/lib.

If the variable CHECK_TIMESTAMPS is defined in configure/RELEASE.local the device support will check if the isegHAL has updated the corresponding value within the last 30 seconds. If not the record is set to a TIMEOUT_ALARM.

Cross compiling

If you want to cross compile the devIsegHal module, the ISEGHAL variable should not be defined in configure/RELEASE.local. Instead only define EPICS_BASE in this file. ISEGHAL should be defined in configure/RELEASE.Common.{T_A} where {T_A} stands for the target architecture (e.g. linux-arm).

Usage

Connect to an interface with the isegHalServer

Before loading any records, devIsegHal has to connect to an interface with the isegHalServer daemon. This is done via the IOC shell command

isegHalConnect( "NAME", "INTERFACE" )

NAME is a user defined name, which is internally used to address this interface while INTERFACE is the actual name of the hardware interface from your operating system (e.g. "can0" for a CAN interface)

Records

To make a record use devIsegHal, set its DTYP field to "isegHAL". The INP or OUT link has the form "@OBJECT IF". Here OBJECT is a fully qualified object string for the item values provided by the isegHalServer and IF is the name of the interface as used with the isegHalConnect command mentioned above.

isegHAL provides its own timestamp of the last change of a value (timeStampLastChanged). To use this timestamp as timestamp of the record, the TSE field has to be set to -2

Example:

record( ai, "ISEG:0:0:2:VoltageMeasure" ) {
  field( DTYP, "isegHAL" )
  field( INP,  "@0.0.2.VoltageMeasure can0" )
  field( TSE,  "-2" )
}

If the EGU field is not set in the database, the unit-value from the corresponding IsegItemProperty is copied into this field during initialization.

Asynchronous Handling

It is possible that control parameters change during operation. For example, if a trip occures the corresponding setON bit in the channel control register will be set to 0. These changes are monitored by devIsegHal through a polling thread. Each output record (execpt for stringout records) is automatically registered to this thread and their values are checked for updates on the isegHAL. If a value has changed the VAL field and timestamp of the record will be set to the new values.

Setting the SCAN field of input records to I/O Intr will also register these records for the thread monitoring the values in isegHAL.

The thread goes through the list of registered records, checks each for an update, and then waits for 5 seconds. This waiting time can be modified using the IOC Shell Commands

Supported Record Types

Record type isegDataType
ai/ao records R4
bi/bo records BOOL
mbbiDirect records UI1 & UI4
longin/longout records UI1 & UI4
stringin/stringout records STR

Note: the maximum string length for stringin/out records is limited to 40 characters while the maximal length for the value of an IsegItemValue is 200. Thus only the first 39 characters of the IsegItemValue are copied to record's VAL field (plus Null-Character for string termination).

IOC Shell Commands

Currently there is only on command callable from the IOC shell.

devIsegHalSetOpt( "key", "value" )
Key Meaning Value
Intervall Change the intervall of the polling thread a value of 0 means no pause between two iterations of the list
LogLevel Change log level of isegHalServer see isegHal Manual

deviseghal's People

Contributors

bhill-slac avatar ffeldbauer avatar zumbruch avatar

Stargazers

 avatar

Watchers

 avatar  avatar

deviseghal's Issues

Error reading some values (and repeated, periodic warnings)

While trying to run this IOC outside of the iseg, I encountered a bunch of error messages. Some PVs update fine:

epics> dbgf ISEG:5230102:BitRate
DBR_LONG:           1000000   0xf4240

But not others, as seen in the log below. Maybe I am doing something wrong?

Also, the message "QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread" keeps getting printed periodically. I wonder if this is a problem with libisegHAL.

$ LD_LIBRARY_PATH=/home/martins/workspace/diag-iseg/iseg-bin ./st.cmd 
#!../../bin/linux-x86_64/isegIoc
< envPaths
epicsEnvSet("IOC","ioc-iseg")
epicsEnvSet("TOP","/home/martins/workspace/devIsegHal")
epicsEnvSet("EPICS_BASE","/usr/lib/epics")
epicsEnvSet("ISEGHAL","/home/martins/workspace/diag-iseg/iseg-bin")
dbLoadDatabase("/home/martins/workspace/devIsegHal/dbd/isegIoc.dbd",0,0)
isegIoc_registerRecordDeviceDriver(pdbbase)
isegHalConnect "can0" "hal://192.168.1.101:1454/can0,user,pass"
using HAL version [1.1.2.8]
dbLoadRecords("/home/martins/workspace/devIsegHal/db/iseg_epics.db", "CONTROLLER_SN=5230102,port=can0,CAN_LINE=0,DEVICE_ID=1000,MODULE_ID=0,CHANNEL_ID=0")
iocInit()
Starting iocInit
############################################################################
## EPICS R3.15.7-3+0~20191126215846.15+debian10~1.gbp050662
## EPICS Base built Nov 26 2019
############################################################################
ISEG:5230102:ModuleNumber: Error while reading value 'ModuleNumber' from interface 'can0': '0' (Q: )
ISEG:5230102:ModuleNumber: Error parsing timestamp for 'ModuleNumber': 
ISEG:5230102:CycleCounter: Error while reading value 'CycleCounter' from interface 'can0': '0' (Q: )
ISEG:5230102:CycleCounter: Error parsing timestamp for 'CycleCounter': 
ISEG:5230102:0:0:SerialNumber: Error while reading item property '0.0.SerialNumber' (Q: )
ISEG:5230102:0:0:ChannelNumber: Error while reading item property '0.0.ChannelNumber' (Q: )
ISEG:5230102:0:0:SampleRate: Error while reading item property '0.0.SampleRate' (Q: )
ISEG:5230102:0:0:DigitalFilter: Error while reading item property '0.0.DigitalFilter' (Q: )
ISEG:5230102:0:0:EventMask: Error while reading item property '0.0.EventMask' (Q: )
ISEG:5230102:0:0:0:EventMask: Error while reading item property '0.0.0.EventMask' (Q: )
ISEG:5230102:0:0:0:DelayedTripAction: Error while reading item property '0.0.0.DelayedTripAction' (Q: )
ISEG:5230102:0:0:0:ExternalInhibitAction: Error while reading item property '0.0.0.ExternalInhibitAction' (Q: )
ISEG:5230102:0:0:VoltageRampSpeed: Error while reading item property '0.0.VoltageRampSpeed' (Q: )
Bad init_rec return value  PV: ISEG:5230102:0:0:VoltageRampSpeed ao: init_record

ISEG:5230102:0:0:CurrentRampSpeed: Error while reading item property '0.0.CurrentRampSpeed' (Q: )
Bad init_rec return value  PV: ISEG:5230102:0:0:CurrentRampSpeed ao: init_record

ISEG:5230102:0:0:0:VoltageSet: Error while reading item property '0.0.0.VoltageSet' (Q: )
Bad init_rec return value  PV: ISEG:5230102:0:0:0:VoltageSet ao: init_record

ISEG:5230102:0:0:0:CurrentSet: Error while reading item property '0.0.0.CurrentSet' (Q: )
Bad init_rec return value  PV: ISEG:5230102:0:0:0:CurrentSet ao: init_record

ISEG:5230102:0:0:0:VoltageBounds: Error while reading item property '0.0.0.VoltageBounds' (Q: )
Bad init_rec return value  PV: ISEG:5230102:0:0:0:VoltageBounds ao: init_record

ISEG:5230102:0:0:0:CurrentBounds: Error while reading item property '0.0.0.CurrentBounds' (Q: )
Bad init_rec return value  PV: ISEG:5230102:0:0:0:CurrentBounds ao: init_record

ISEG:5230102:0:0:0:VctCoefficient: Error while reading item property '0.0.0.VctCoefficient' (Q: )
Bad init_rec return value  PV: ISEG:5230102:0:0:0:VctCoefficient ao: init_record

ISEG:5230102:0:0:0:DelayedTripTime: Error while reading item property '0.0.0.DelayedTripTime' (Q: )
Bad init_rec return value  PV: ISEG:5230102:0:0:0:DelayedTripTime ao: init_record

ISEG:5230102:0:0:VoltageLimit: Error while reading item property '0.0.VoltageLimit' (Q: )
ISEG:5230102:0:0:CurrentLimit: Error while reading item property '0.0.CurrentLimit' (Q: )
ISEG:5230102:0:0:Temperature: Error while reading item property '0.0.Temperature' (Q: )
ISEG:5230102:0:0:0:VoltageMeasure: Error while reading item property '0.0.0.VoltageMeasure' (Q: )
ISEG:5230102:0:0:0:CurrentMeasure: Error while reading item property '0.0.0.CurrentMeasure' (Q: )
ISEG:5230102:0:0:0:VoltageNominal: Error while reading item property '0.0.0.VoltageNominal' (Q: )
ISEG:5230102:0:0:0:CurrentNominal: Error while reading item property '0.0.0.CurrentNominal' (Q: )
ISEG:5230102:0:0:0:TemperatureExternal: Error while reading item property '0.0.0.TemperatureExternal' (Q: )
ISEG:5230102:0:0:Status: Error while reading item property '0.0.Status' (Q: )
ISEG:5230102:0:0:StatusLow: Error while reading item property '0.0.Status' (Q: )
ISEG:5230102:0:0:StatusHigh: Error while reading item property '0.0.Status' (Q: )
ISEG:5230102:0:0:EventStatus: Error while reading item property '0.0.EventStatus' (Q: )
ISEG:5230102:0:0:0:Status: Error while reading item property '0.0.0.Status' (Q: )
ISEG:5230102:0:0:0:EventStatus: Error while reading item property '0.0.0.EventStatus' (Q: )
ISEG:5230102:0:0:Control:doClear: Error while reading item property '0.0.Control:6' (Q: )
ISEG:5230102:0:0:Control:setFineAdjustment: Error while reading item property '0.0.Control:12' (Q: )
ISEG:5230102:0:0:Control:setKillEnable: Error while reading item property '0.0.Control:14' (Q: )
ISEG:5230102:0:0:Control:disableVoltageRampSpeedLimit: Error while reading item property '0.0.Control:16' (Q: )
ISEG:5230102:0:0:0:Control:setOn: Error while reading item property '0.0.0.Control:3' (Q: )
ISEG:5230102:0:0:0:Control:setEmergency: Error while reading item property '0.0.0.Control:5' (Q: )
ISEG:5230102:0:0:FirmwareRelease: Error while reading item property '0.0.FirmwareRelease' (Q: )
ISEG:5230102:0:0:FirmwareName: Error while reading item property '0.0.FirmwareName' (Q: )
ISEG:5230102:0:0:Article: Error while reading item property '0.0.Article' (Q: )
iocRun: All initialization complete
epics> QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread
QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread
QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread
QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread
QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread
QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread
...

Setting "debug" to "1" segfaults

Hi Florian,

I finally got around to test this device support outside of an iseg device. I followed your advice (setting ISEGHAL, creating symlinks to the headers, etc) and got the IOC to compile. However, if I try to set "debug" to "1", it segfaults:

$ LD_LIBRARY_PATH=/home/martins/workspace/diag-iseg/iseg-bin ./st.cmd 
#!../../bin/linux-x86_64/isegIoc
< envPaths
epicsEnvSet("IOC","ioc-iseg")
epicsEnvSet("TOP","/home/martins/workspace/devIsegHal")
epicsEnvSet("EPICS_BASE","/usr/lib/epics")
epicsEnvSet("ISEGHAL","/home/martins/workspace/diag-iseg/iseg-bin")
dbLoadDatabase("/home/martins/workspace/devIsegHal/dbd/isegIoc.dbd",0,0)
isegIoc_registerRecordDeviceDriver(pdbbase)
isegHalConnect "can0" "hal://192.168.1.101:1454/can0,user,pass"
using HAL version [1.1.2.8]
devIsegHalSetOpt "can0" "debug" "1"
Segmentation fault (core dumped)

The reason is because I inserted the devIsegHalSetOpt call before iocInit(), not after. At that point, myIsegHalThread is NULL.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.