EPICS exampleCPP/powerSupply

2016.08.30

Abstract

powerSupply is an example of creating a service that requires a somewhat complicated top level PVStructure. Look at the code for details.

Table of Contents


Overview

This is an example of creating a service that requires a somewhat complicated top level PVStructure.

The example has a top level pvStructure:

structure
    alarm_t alarm
    time_t timeStamp
    structure power
        double value
    structure voltage
        double value
    structure current
        double value

It is designed to be accessed via a channelPutGet request. The client sets power.value and voltage.value When the record processes it computes current.value. In addition the timeStamp is set to the time when process is called.

Start Example

Start Server

The example can be run on linux as follows:

mrk> pwd
/home/epicsv4/master/exampleCPP/powerSupply
mrk> bin/$EPICS_HOST_ARCH/powerSupplyMain

To start powerSupply as part of a V3IOC:

mrk> pwd
/home/hg/exampleCPP/powerSupply/iocBoot/powerSupply
mrk> ../../../bin/$EPICS_HOST_ARCH/powerSupply st.cmd

Start Monitor

mrk> pwd
/home/epicsv4/master/exampleCPP/powerSupply
mrk> bin/$EPICS_HOST_ARCH/powerSupplyMonitor

Start Client

mrk> pwd
/home/epicsv4/master/exampleCPP/powerSupply
mrk> bin/$EPICS_HOST_ARCH/powerSupplyClient

NOTE: The client ends by requesting a voltage of 0. This results in the power supply record thowing an exception. This results in problems including the powerSupplyMonitor no longer updating. Needs investigation.

Directory Layout

The directory layout is:

powerSupply
    configure
       ExampleRELEASE.local
       ...
    src
       pv
           powerSupplyRecord.h
       powerSupplyRecord.cpp
       powerSupplyInclude.dbd
       powerSupplyMain.cpp
       powerSupplyClient.cpp
       powerSupplyMonitor.cpp
       powerSupplyRegister.cpp
       powerSupplyRegister.dbd
       
    ioc
       Db
          ...
       src
          powerSupplyInclude.dbd
          powerSupplyMain.cpp
   iocBoot
      powerSupply
         st.cmd
         ...
where
ExampleRELEASE.local
If you make a copy of powerSupply and use it to create a new server, This is the file that must be copied to RELEASE.local and edited.
powerSupplyRecord.h
The header file for powerSupplyRecord.
powerSupplyRecord.cpp
The powerSupplyRecord implementation.
powerSupplyMain.cpp
A main program that runs the example so that it can be accessed by a pvAccess client.
powerSupplyClient.cpp
Client code to test powerSupply
powerSupplyMonitor.cpp
Client code to monitor for changes in powerSupply
powerSupplyInclude.dbd
This has a register command so that the powerSupply can be started on a V3 IOC via iocsh.
powerSupplyRegister.cpp
This has the code to start the powerSupply via the following iocsh command.
powerSupplyCreateRecord powerSupply
         
Multiple commands can be issued to create multiple powerSupply records.
powerSupplyRegister.dbd
This is the file that is used to create the shell command powerSupplyCreateRecord.
ioc
This is for building a V3 IOC application.
ioc/Db
This has template files for creating V3 records.
ioc/src
The files for running a V3 IOC.
iocBoot/powerSupply
A place to start powerSupply as part of a V3IOC. It has a st.cmd file that starts the ioc and also starts pvAccess and the example.

If only a main program is desired then the directory layout is:

powerSupply
    configure
       ExampleRELEASE.local
       ...
    src
       pv
           powerSupplyRecord.h
       code
           powerSupplyRecord.cpp
           powerSupplyMain.cpp

Thus if only a main program is required the directory layout is simple.

Also many sites will want to build the src directory in an area separate from where the iocs are build.