Download - Console Application Programming
![Page 1: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/1.jpg)
Console Application Programming
Brian Hendricks
![Page 2: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/2.jpg)
Getting Started
• On the web– New user help
• adcon.fnal.gov/controls/clib/new_user.html
– Library help• adcon.fnal.gov/controls/libraries.html
• Console introduction area (cns_intro)– Skeleton program– Help files
![Page 3: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/3.jpg)
![Page 4: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/4.jpg)
Development Environment
• Language is C• MECCA
– builds and archives code
• Libraries– CLIB– User libraries
• Program testing facility• Skeleton program• Example programs (W1-W7)
![Page 5: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/5.jpg)
Guidelines
• Application style guide– describes user interface expectations in terms of
both appearance and functionality– adcon.fnal.gov/controls/clib/application_style_guide.html
• Application programming guidelines– describes standard coding practices– adcon.fnal.gov/controls/clib/application_guidelines.html
![Page 6: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/6.jpg)
MECCA
• Works on a single directory• Handles compiling and linking• Supports testing environment• Archives operational code• Simple command line interface
– mecca/copy {program} (copy from archive)– mecca/dev {program} (build test version)– mecca {program} (build and release)
• Maintains history and keeper information
![Page 7: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/7.jpg)
Libraries
• CLIB– Generic functionality
– >2000 entry points
– Runtime linking
• User libraries– Generally more specific functionality
– Few hundred entry points
– Statically linked
– Maintained in MECCA
![Page 8: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/8.jpg)
Testing Environment
• Z index page– Allows access to all users (unless protected)
– Cleaned up at 3 AM every day
– mecca/dev and @build_z_page support it
• Debugger– Command line and windowed versions
– Help at adcon.fnal.gov/controls/clib/intro_debugger.html
![Page 9: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/9.jpg)
Testing Environment (contd)
• Redirection– Redirect data acquisition to a memory model
• Settings locks
• CLIB Peeker (D22)– View inner workings of CLIB routines
• DPM Peeker (D3)– View data acquisition requests
![Page 10: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/10.jpg)
Skeleton Program
• Basic paradigm is infinite event handling loop• Events are served by calls to ‘window_intype’
– Initialization (occurs once)
– Periodic (15 Hz)
– Keyboard (mouse clicks)
– Termination (occurs once)
• Alternative is ‘window_intype_loop_c’
![Page 11: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/11.jpg)
Program Skeleton Event Loop
![Page 12: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/12.jpg)
A Word About ACNET Devices…
• Fundamental organizational block of control system information
• Configuration data in central database• Power supply paradigm• Consists of properties
– smallest addressable unit of data– reading, setting, digital status, digital control, analog
alarm, digital alarm
• Properties can be atomic values, arrays, or structures (default length vs. maximum length)
![Page 13: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/13.jpg)
ACNET Devices (contd)
• Addressed by an 8 character ASCII name or an integer key called a device index
• ACNET device access protocols– RETDAT for reading properties– SETDAT for setting properties
• Setting property can be read as well as set
• Digital control property can only be set
![Page 14: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/14.jpg)
ACNET Devices (contd)
• Devices can be grouped as families or linked as siblings
• Front ends return only “raw” data• Scaling routines convert raw data to
primary units (volts) or common (engineering) units
• Database dump program (D80) displays fairly complete information about devices
![Page 15: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/15.jpg)
Database Dump Program (D80)
![Page 16: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/16.jpg)
Anatomy of a Library Routine Help Entry
• Functional description of routine• List of arguments with data types
– {name}.{data type}.{passing mechanism}
• Description of each argument• Description of returned status (if applicable)• Required header file(s)• Related functions• Usage example
![Page 17: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/17.jpg)
Anatomy of a Library Routine Help Entry (continued)
• Arguments having the type ‘.ch.d’ can be passed either by descriptor or by reference
• Arguments enclosed in square brackets are optional
• Default values of optional arguments should be listed– Zero is NOT the universal default value
![Page 18: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/18.jpg)
![Page 19: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/19.jpg)
CLIB Functional Groups
• dio_xxx – Data I/O– supports reading/setting devices– supports reading device database information– typically uses device index/property addressing– maintains usage/error statistics
• db_xxx – DataBase access– accesses relational database
![Page 20: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/20.jpg)
CLIB Functional Groups (continued)
• window_xxx – alphanumeric window access– row/column addressing
• wn_xxx – graphic WiNdow access– views created in unitary coordinate system– each view has its own internal coordinate system
• error_xxx– displays/logs error and informational messages
• str_xxx – STRing functions– adds to C RTL string support
![Page 21: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/21.jpg)
User Libraries
• ul_cbsaux – CLIB auxiliary routines– BPM support– GPIB support– waveform generator support
• ul_physlib – generic physics routines– contains ‘Numerical Recipes in C’ routines
• ul_model – lattice database access
![Page 22: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/22.jpg)
User Libraries (continued)
• ul_pasa and ul_net – networking support
• ul_scopes – GPIB scope support
• ul_sequencer – Sequencer interface routines
• ul_windowlib– additional window_xxx routines
• ul_dialoglib – special user dialogs
![Page 23: Console Application Programming](https://reader036.vdocuments.site/reader036/viewer/2022062301/56815058550346895dbe59e2/html5/thumbnails/23.jpg)
BPMUTI
• Part of ul_cbsaux• General BPM support for all accelerators• Key routines
– bpm_machine_c – select BPM system– bpm_get_data_c – read BPM data– blm_get_data_c – read BLM data– bpm_plot_data – makes BPM plots
• Based upon configuration database• Supports BPM file system