console application programming

23
Console Application Programming Brian Hendricks

Upload: mirit

Post on 21-Jan-2016

36 views

Category:

Documents


1 download

DESCRIPTION

Console Application Programming. Brian Hendricks. 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. Development Environment. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Console Application Programming

Console Application Programming

Brian Hendricks

Page 2: Console Application Programming

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
Page 4: Console Application Programming

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

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

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

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

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

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

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

Program Skeleton Event Loop

Page 12: Console Application Programming

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

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

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

Database Dump Program (D80)

Page 16: Console Application Programming

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

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
Page 19: Console Application Programming

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

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

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

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

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