Simple Channel Access Example for WIN32



EPICS Extensions Channel Access for WIN32

Pre-compiled Version


Compiling EPICS on cygwin32 (Windows95/NT)



Simple Channel Access Example for WIN32


Introduction

The purpose here is to provide a simple example to demonstate how to build channel access executable for WIN32 system.
The system requirements:
       - Cygnus's latest gnu-win32 distribution, available from
           http://www.cygnus.com/misc/gnu-win32/ (release b19 or later)
       - Microsoft visual C++ 6.0
To properly set up the cygnus WIN32 window please refer the example given in Development WIN32 Setup. A user need to modify the WIN32.BAT to reflect the path of user's software installations.

Run the WIN32.BAT will pop up a DOS command window and provide gnu-win32 commands at user finger tip. Then at the cygnus WIN32 prompt, a user can use the unix like commands to perform simple make to create executables.

Download Simple Example

ezee.zip - A simple channel access example for WIN32

Extract the ezee.zip under the desired directory, e.g. C:\jbaEpics\ezee directory. It consists four files and a header directory h.

	ezee.c   -  a simple CA program reading PV values
	makefile - a simple makefile to create ezee.exe and install
		   ezee.exe to the executable search path
	ca.dll   - the channel access DLL created for WIN32
	ca.lib   - the channel access library created for WIN32
	h        - header directory include all the header files used by
                   the channel access client
A user may need to modify the makefile to reflect the correct installation of the cygnus WIN32 tools and the final output executable installation destination path.

Create & Test Simple Example

Start up the WIN32.BAT file window, at the window prompt a user can use the unix shell commands to go to the directory where ezee was extracted. Use pwd to verify the current working directory, use ls to list the file contents, and use the cd command to goto the C:\jbaEpics\ezee directory.

The steps for create, test, and install ezee.exe under the C:\jbaEpics\ezee directory is given below:

1)To create ezee.exe

	make

2)To test ezee.exe with any PV name from IOC

	ezee chademoai1

3)To install ezee.exe to destination path

	make install

Pre-compiled Version


Introduction

This package contains few EPICS extensions channel access tools and pre-compiled CA libraries and DLL files required for running CA tools on the window system. The library and DLL file are prepared on a W95 system. The executables have been tested on W95 and W98 and are working on both system.

Download

The EPICS base used is R3.13.0.beta12 in following zip files:
    jbaEpics.zip - EPICS extensions tools, EXEs and DLLs built for WIN32 
	(only including channel access clients built from the
	ezca, ca, ezcaScan, eacaIDL, idl sub-directories 
	and the ca.dll, com.dll caRepeater.exe from the base\bin\WIN32.)

    EpicsBaseBin.zip - The Complete set of files from the EPICS base\bin\WIN32 
	(normally user does not need to download this file.)

The information about various IDL programs for viewing scan data can be obtained from EPICS / IDL extensions tools.

Installation

It is assumed that the user will not try to build his/her own EPICS CA extension application. Otherwise the BASE, and EXTENSIONS tree sturcture similar to the CVS control at APS must be used.

User can install the pre-compiled version by WinZip program simply by extracting files from the jbaEpics.zip in the directory he prefers. The C:\JBAEPICS root directory is recommanded here then everything should work fine without modification, all the EPICS CA EXE tools and DLL files will be installed below this root directory. Two sub-directories BASE\BIN and EXTENSIONS\BIN will be created under the JBAEPICS root directory.

	Extract the CA tools from the  
	jbaEpics.zip to C:\JBAEPICS directory.
In case the complete set of BASE tools and DLLs for WIN32 are desired, then
	Extract the files from the  
	EpicsBaseBin.zip to C:\JBAEPICS\BASE\BIN directory.
The WinZip program will automatically create the WIN32 directory below the BIN directory and install all EXE and DLL files in the WIN32 directory.

Requirements

The user has to modify the autoexec.bat file in the C:\ directory. The batch file must contain the following lines in order to access the CA executables or dll files.
	SET EPICS_EXTENSIONS=C:\JBAEPICS\EXTENSIONS
	SET PATH=%PATH%;C:\JBAEPICS\BASE\BIN\WIN32;c:\JBAEPICS\EXTENSIONS\BIN\WIN32
	SET EZCA_IDL_SHARE=C:\JBAEPICS\EXTENSIONS\BIN\WIN32\ezcaIDL.dll

This will properly set up the environment for accessing the EPICS tools. At the DOS window prompt, a user should be able to access executables of the EPICS commands released by this html.

The EZCA_IDL_SHARE environment variable is required for accessing channel access functions defined in the ezcaIDL.dll in running IDL program.

Package File Contents

Only the EPICS files interface with CA protocal are listed below:

BIN Directory DLL & EXE Files

	DLL From BASE
	Com.dll - Database Common DLL
	ca.dll - Channel Access DLL

	EXE From BASE
	caRepeater.exe

	DLL From EXTENSIONS
	ezca.dll - EZCA DLL
	ezcaIDL.dll - EZCA DLL for IDL Interface 
	ezcaScan.dll - Array & Scan Record EZCA DLL
	Lca.dll - Local Channel Access DLL

	EXE From EXTENSIONS
	caget.exe - get channel value(s) for PV(s)
	caput.exe - set value(s) for PV(s)
	caGet1.exe - get PV array values as string
	caPut1.exe - set PV array values to IOC
	caInfo1.exe - get PV array Info (float / double)

Usage Examples

Two executable examples: caget and caput are shown below. As long as the BIN directory, where the CA tools are installed, is included in the window search path, the CA tools should be accessible from the DOS window prompt. The command syntax on W95 generated by the command is given below.

caget


Usage:  caget [-n] [-t] [-f n] [-e n] [-w sec] pv_name

This command read a value or array of values from one or more IOC channels.

        -n   returns numerical value instead of string for DBR_ENUM field
        -t   Terse mode, process variable name not returned
      -f n   Use f format, n specifies number of digits after the decimal point
      -e n   Use e format, n specifies number of digits after the decimal point
    -w sec   Wait time, specifies bigger time out, default is 1.0 second
     -# no   The number 'no' specifies the number of values to be returned for
             an array record. If this option is not used then the whole array
             is returned. The first returned number is the size of the array ,
             then it is followed with the array of values obtained.
   pv_name   a single or a list of PV names from IOC

   Examples:   caget  pv_name
               caget  pv_name1 pv_name2 pv_name3

caput

Usage:  caput [-t] [-s] [-w sec] [--] pv_name  pv_value

This command writes a value or array of values to a channel.
It can also write an array of single values to an array of channels.

        -t   Terse mode, only the successfully put value is returned
        -s   pv_value entered as database defined enumeral string
    -w sec   Wait time, specifies bigger time out, default is 1 second
        -m   this option specified the input value string is 
             a comma separated values for a waveform record 
   pv_name   requested database process variable name
             (multiple PV names must be seperated by comma no space)
   pv_value  new value to put to IOC
             (multiple PV values must be seperated by comma no space)

  Examples:    caput  pv_name  pv_value
               caput  pv_name1,pv_name2   pv_value1,pv_value2
               caput -m  pv_name  v1,v2,v3,...



Compiling EPICS on cygwin32 (Windows95/NT)


Introduction

This document only shows the build of EPICS 3.13.0beta12 / EPICS 3.13.1 extensions tools in the ezca, idl, ezcaScan, ezcaIDL sub-directories on W95. For newer release EPICS 3.14 or later this methods may need major rework on W95 due to changes in 3.14.

Only the base and the above mentioned extension sub-directories are compiled and installed on WIN32 subdriectory. I only tried the EPICS 3.13.0beta12 on W95 and had built it based on the instruction given in the following paragraphs.

The Cygnus beta19 release of the GNU-win32 tools and Perl 5.0 or later are used to compile the EPICS base and extensions for the cygwin32 Host. The infomation below is based on the information provided by Janet Anderson (dated Sept 15, 1998) on instruction of building EPICS 3.12.0beta12 for WIN32.

System Software Requirements

Right now this port of EPICS to cygwin32 it is possible to compile the EPICS for the cygwin32 Host using Cygnus' beta19 release of the GNU-win32 tools. The cygwin32 provides the UNIX shell commands interface at the DOS window.
To build EPICS on Win95 or NT using cygwin32, we need

       - EPICS base distribution, R 3.13.0beta12
       - Cygnus's latest gnu-win32 distribution, available from
           http://www.cygnus.com/misc/gnu-win32/ ( release b19 or later) 
       - Perl,version 5.003 or later, available from
            http://www.perl.com/pub 
       - Microsoft visual C++ 6.0

Optional items
       - CVS, version 1.9 or later, available from
            http://cvshome.org
                  windows-nt  - cvs-1.9.10.tar.gz
                                patch.exe
                                win32gnu.dll
       - vim ( Vi IMproved), version 4.5 or later, available from
           http://www.vim.org

Download local copy of cygnus and Perl

The local copy of cygnus release b19 and perl version 5.003 are available from the following links:
	Download  cygnus release 19
	Download  Perl 5.003 

Download WinZip Files - EPICS R3.13.0beta12

For building EPICS R3.13.0beta12 on WIN32 system, I have prepared two window distribution files: epicsBase.zip and epicsExtensions.zip. The extensions distribultion only includes CA clients supported by me, they are ezca, ezcaScan, ezcaIDL, idl and ca source sub-directories.
	download EpicsExtensions.zip to C:\JBAEPICS
	download EpicsBase.zip to C:\JBAEPICS\base
The epicsBase.zip file contains the required base sub-directories and the built version of ca.dll and ca.lib based on EPICS 3.12.0beta12 for WIN32 system. The epicsExtensions.zip file contains the source release for the extensions directory and startup directory. In principle the epicsExtensions.zip file should also work with EPICS 3.13.1 release or newer version.

Build Base Instruction

The information for building EPICS base on the WIN32 system is provided here just for reference. A user should be able to bypass this section completely.

The following build instruction for EPICS base was obtained from Janet Anderson on Sept 15,1998. It is assumed that gz file was downloaded from the EPICS software release. The [epicsBaseReleaseDir] below should be the directory where you want to installed the EPICS base. In this document C:\JBAEPICS\BASE is recommanded.


1) Install the gnu-win32 development tools
------------------------------------------
    Download cdk.exe, to get the developemnt tools
    First move out of the way any older versions of gnuwin32
    Run cdk.exe and follow the install instructions.

    Don't forget to create a \tmp dir and setup the \bin dir.
     (Create a \temp dir if you install cvs.)
        mkdir \tmp
        mkdir \temp
        mkdir \bin
        cd \bin
        copy C:\cygnus\b19\H-i386-cygwin32\bin\sh.exe sh.exe

   Install the b19.1 bug fix update to the Cygwin32 library.

   (Optional: Install the GNU-WIN32 compiler replacement from
    the ECGS project)

2) Install the perl distribution
--------------------------------
        pw32i316.exe    (Execute and follow instructions)

3) Install the epics base distribution  
--------------------------------------
   (Only if other than R3.13.0.beta12 is desired) 

        mkdir [epicsBaseReleaseDir]
        chdir [epicsBaseReleaseDir]
        cp [dirname]\[basereleasename].gz .
        gunzip -d [basereleasename].gz
        chmod +w -R *
    
4) Set environment variables and path using cygwin32.bat
-------------------------------------------------------------
        Edit cygwin32.bat changing paths if necessary
        cd [epicsBaseReleaseDir]\startup
        cygwin32.bat

5) Set site specific parms in epics base\config files
-----------------------------------------------------
        cd [epicsBaseReleaseDir]\base\config
        Edit CONFIG_SITE* files

6) Build epics base
-------------------
        cd [epicsBaseReleaseDir]\base
        make

7) Create an EPICS application area (note forward slashes on perl cmd)
---------------------------------------------------------------------
        mkdir [epicsappdir]
        cd [epicsappdir]
        perl [epicsBaseReleaseDir]/bin/cygwin32/makeBaseApp.pl -l
        perl [epicsBaseReleaseDir]/bin/cygwin32/makeBaseApp.pl -t example exampl

WIN32 EPICS Compilation

I only ported the EPICS extensions under ezca, ezcaScan, ezcaIDL, idl sub-directories to PC. The purpose here only demonstates a typical setup for the EPICS compilation on the W95 PC.
The EPICS BASE is installed under C:\jbaEpics\base
The EPICS extensions is installed under C:\jbaEpics\extensions
The cygwin32 beta 19 is installed under C:\cygnus\B19
The PERL is installed under C:\perl 

Development WIN32 Setup

I created the batch file WIN32.BAT which is a modified version of cygwin32.bat and it should reflect the appropriate setup of the actual installation of each software mentioned above. The WIN32.BAT file will start a DOS window and setup the window environment for building EPICS extension tools. The WIN32.BAT file is stored under C:\jbaEpics\startup directory
	WIN32 Compilation Window Setup
	- Edit the batch file WIN32.BAT in C:\jbaEpics\startup directory
	- Create a shortcut link and place on the desktop and rename to WIN32
	- Modify the WIN32 Icon properties by right click the mouse:
		Select the Properties Menu
		Select the Program Tablet
		Make sure the following are true: 
		Cmd line: 	C:\jbaEpics\startup\WIN32.BAT
		Working:  	C:\jbaEpics\extensions
		Close on exit:  is checked.
		Change Icon     Use Microsoft DOS Icon
Note that the click of the WIN32 Icon will start the WIN32.BAT and automatically set the working directory as the C:\jbaEpics\extensions. And a user can enter the UNIX alike command on the DOS prompt of the WIN32 window.

Construct EPICS Base

The epicsBase.zip file contains the minimum set of EPICS R3.13.0.beta12 base directory files required for building CA clients for WIN32 system. Download and unzip of epicsBase.zip file to c:\jbaEpics\base will construct the EPICS base INCLUDE, CONFIG, BIN and LIB directories for the WIN32 system.

Use the epicsBase.zip file, no EPICS base compilation is required.

Build EPICS Extensions

Start WIN32.BAT by click the WIN32 Icon on desktop or run the win32.bat from the c:\jbaEpics\startup directory. It will pop up a DOS window and let the user use the cynwin32 UNIX shell commands at the prompt. The default working directory will be c:\jbaEpics\extensions.

Following steps will build the EPICS extensions sub-directories: ezca, ezcaScan, ezcaIDL, and idl.

	At the Microsoft DOS WIN32 window prompt :
		pwd	
		cd src/ezca
       	 	make
		cd ../ezcaScan
       	 	make
		cd ../ezcaIDL
       	 	make
		cd ../idl
       		make
	

List of WIN32.BAT File

@ECHO OFF
set path=
set include=
set lib=
REM    --------------- WIN95 -------------------
set PATH=C:\WINDOWS;C:\WINDOWS\COMMAND

REM    --------------- EPICS ------------------------
set HOST_ARCH=WIN32
set PATH=%PATH%;C:\jbaEpics\base\bin\WIN32
set PATH=%PATH%;C:\jbaEpics\extensions\bin\WIN32

REM    --------------- DJGPP tools, make, etc.--------
REM set DJGPP=C:\DJGPP\DJGPP.ENV
REM set PATH=C:\DJGPP\BIN;%PATH%

REM    ------------ cygWIN32 unix tools, make, etc.-----
REM     need grep from here NOT from cvs directory
REM     some tools need a tmp directory
set PATH=%PATH%;.;..
REM REM  set PATH=%PATH%;c:\bin;c:\gnuwin32\b18\h-i386-cygwin32\bin
set PATH=%PATH%;c:\bin;c:\cygnus\B19\h-i386-cygwin32\bin
set MAKEFLAGS=-w
set MAKE_MODE=unix

REM    --------------- CVS ---------------------------
rem set CVSROOT=/cvsroot
set LOGNAME=cha
REM         rcs needs a c:\temp directory
REM 
rem set PATH=%PATH%;C:\cyclic\cvs-1.9\bin


REM    --------------- Epics Channel Access ----------

REM the following line works !!!!!
REM set EPICS_CA_ADDR_LIST=164.54.9.255
set EPICS_CA_ADDR_LIST=164.54.52.116 164.54.53.255

REM set EPICS_CA_AUTO_CA_ADDR_LIST=YES
REM set EPICS_CA_CONN_TMO=30.0
REM set EPICS_CA_BEACON_PERIOD=15.0
REM set EPICS_CA_REPEATER_PORT=5065
REM set EPICS_CA_SERVER_PORT=5064
REM set EPICS_TS_MIN_WEST=420

REM    --------------- perl ------------------------
REM set PERLLIB=C:\perl\lib
set PATH=%path%;C:\perl\bin

REM    --------------- JAVA -------------------
REM  set CLASSPATH=.;c:\jdk1.1.3\lib\classes.zip;
rem set PATH=%PATH%;C:\jdk1.1.6\bin
rem set CLASSPATH=C:\jbaEpics\extensions\javalib

REM    --------------- Visual c++ ------------------

REM set PATH=%PATH%;c:\msdev\bin;
REM set PATH=%PATH%;c:\Progra~1\DevStudio\VX\bin;
REM call c:\Progra~1\DevStudio\VC\bin\vcvars32.bat
REM call c:\msdev\bin\vcvars32.bat m68k

REM ----- Visual c++ 5.0 ---------
call c:\jbaEpics\vcvars32.bat m68k
REM ----- Visual c++ 4.2 ---------
REM call c:\msdev\bin\vcvars32.bat m68k

REM    -----------------------------------------------
sh