250 likes | 467 Views
Masanori Satoh/ KEK, Jan. 27-30, 2009 for EPICS seminar at RRCAT, Indore. EPICS on Windows How to install and Application example with hands-on. Some parts are quoted from Dr. Furukawa’s and Dr. Obina’s lecture materials. Why EPICS on Windows. EPICS on Windows Information:
E N D
Masanori Satoh/ KEK, Jan. 27-30, 2009 for EPICS seminar at RRCAT, Indore EPICS on WindowsHow to install and Application example with hands-on • Some parts are quoted from Dr. Furukawa’s and Dr. Obina’s lecture materials.
Why EPICS on Windows • EPICS on Windows Information: http://www.aps.anl.gov/epics/base/win32.php http://www-linac.kek.jp/jk/win32/ • Recently, many devices are running on Windows (2000, XP, Vista) . • Digital oscilloscope (Tektronix, Agilent, LeCroy,…) • Network Analyzer • Many other measurement instruments • etc.
EPICS IOC Example in KEK Linac • Tektronix Oscilloscope • DPO7104 for BPM-DAQ • Agilent Network Analyzer • E5061A for Vector voltmeter ( 571 MHz Phase)
Building EPICS on Windows: • Some possible environments • Cygwin • Unix-like environment • GNU tools • cygwin1.dll • Microsoft Visual C++ (VC6, 2005, .NET, 2008) • Commercial • Free version (Express Edition) • MinGW • Minimalist GNU for Windows • Free GNU C compiler • msvcrt.dll (Microsoft C) • Borland C++
Building EPICS on Windows: The simplest approach: Cygwin with the GCC compiler Recommend: Some Cygwin tools and Microsoft's commercial Visual C++ compiler (or free Visual C++ 2008 Express Edition). http://www.microsoft.com/express/vc/
What’s Cygwin? • Cygwin is a Linux-like environment for Windows. • A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing substantial Linux API functionality. • A collection of tools which provide Linux look and feel. • You can get it http://www.cygwin.com/
Cygwin Applications • Cygwin API • “Cygwin1.dll” provides function of POSIX system call. • Development of Windows-native Application is also Possible • Development of DLL is Possible • Most of the Open-Source tools on Unix are ported. • Fileutils, XXXutils, Compilers, Debuggers, Editors, Internet Clients, Interpreters, Dev. Tools, Doc. Tools. • Servers • Sshd, Apache (php, etc.), Squid, PostgreSQL, Xinetd, NFS,… • X11
What Is Visual Studio Express? • You can get it. http://www.microsoft.com/express/download/ • Visual C++, Visual Basic, Visual C#, SQL Server, Visual Web Developer. • Freeware • Limited functionality • But enough for common usage • Needs about 1 GB of disk space • You don’t need: MS Shilverlight Runtime MS SQL Server
How to Build EPICS on Windows (1) • Using Cygwin: • The simple way to build EPICS on Windows • Hits for Cygwin setup: • Very slow response for some download sites. • If you failed to download, try from other Websites . • Default install option does not include the important commands: cc, make, perl, etc
How to Build EPICS on Windows (1) • Install Cygwin:
How to Build EPICS on Windows (1) • Choose a download site. • If you failed, try from other download sites.
How to Build EPICS on Windows (1) • Select Packages you want. • At least, select cc, vim, make, Perl, and so on. • X11 is also available if you select.
How to Build EPICS on Windows (1) • Select Packages: • Editors • Vim, Emacs,… • Devel • make • gcc-g++, gcc-core • Perl • Other packages if you need
How to Build EPICS on Windows (1) • Set EPICS_HOST_ARCH environment var. • bash: export EPICS_HOST_ARCH=cygwin-x86 • csh: setenv EPICS_HOST_ARCH cygwin-x86 • c.f.) for MinGW, export EPICS_HOST_ARCH=win32-x86-mingw • Then, in the base directory • Just type “make” • Typically, it takes about 10 minutes. (Intel Core2 1.2 GHz, 2 GB RAM)
How to Build EPICS on Windows (2) • Cygwin tools and Microsoft's Visual Studio C++ compiler combination. • make, perl (Cygwin) • cl, link, (Visual Studio C++) • EPICS_HOST_ARCH: • bash: export EPICS_HOST_ARCH=win32-x86 • csh: setenv EPICS_HOST_ARCH win32-x86 • c.f.) for Borland compiler export EPICS_HOST_ARCH=win32-x86-borland
How to Build EPICS on Windows (2) • EPICS_HOST_ARCH variable: • You can set it as the Windows Environment Variable. • “Control Panel” => “System” => “System Property” => “Environment Variables” => “System variables”
How to Build EPICS on Windows (2) • You can find cygwin.bat file in c:\cygwin (default setting) or root directory you choosed. • In cygwin.bat file, add one line. @echo off C: chdir C:\cygwin\bin call "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat“ bash --login -i
How to Build EPICS on Windows (2) • Modify /etc/profile file PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:$PATH export PATH => PATH=$PATH:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin export PATH • You can check the path setting by “which” command. $ which link /cygdrive/c/Program Files/Microsoft Visual Studio 8/VC/BIN/link $ which cl /cygdrive/c/Program Files/Microsoft Visual Studio 8/VC/BIN/cl
Hands-on (1) • Build EPICS base on Windows • Use Cygwin • export EPICS_HOST_ARCH=cygwin-x86 • Use Visual Studio C++ and Cygwin(make, perl) • export EPICS_HOST_ARCH=win32-x86 • Modify the /etc/profile file • PATH= $PATH:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin
Hands-on (2) • Open a Cygwin command window • Check environment • printenv • printenv |grep EPICS • make –v • perl –v • cl
Hands-on (3) • Create an Example Application on Windows /home/username>mkdir testApp /home/username>cd testApp /home/username/testApp>makeBaseApp.pl -t example myexample /home/username/testApp>makeBaseApp.pl -i -t example myexample /home/username/testApp>make ..... wait for a while ..... /home/username/testApp>cd iocBoot\iocmyexample /home/username/testApp/iocBoot/iocmyexample>vi st.cmd ..... edit "st.cmd" ..... dbLoadRecords("db/dbExample1.db","user=username") dbLoadRecords("db/dbExample1.db","user=your_favorite_name") /home/username/testApp/iocBoot/iocmyexample>../../bin/win32-x86/example.exe st.cmd ..... open another cmd window, try caget, camonitor
Hits for Hands-on (3) • Set path configuration • /usr_epics_base_directory/bin/win32-x86 • e.g.) /epics/base-3.14.10/bin/win32-x86 • Modify .bashrc (bash), .cshrc (csh) • Or, Modify Environment Variables on Windows
How to use CA.DLL • Dynamic-Link Library (DLL) • Microsoft’s implementation of the shared library concept in the Windows operating systems • *.so (In Linux or other UNIX-like operating system) • Example: caClient by VBA macro • Visual Basic for Application • In KEK Linac, VBA is used for E5061A(Agilent) for Vector voltmeter.