260 likes | 439 Views
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.
E N D
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 • Language is C • MECCA • builds and archives code • Libraries • CLIB • User libraries • Program testing facility • Skeleton program • Example programs (W1-W7)
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
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
Libraries • CLIB • Generic functionality • >2000 entry points • Runtime linking • User libraries • Generally more specific functionality • Few hundred entry points • Statically linked • Maintained in MECCA
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
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
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’
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)
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
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
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
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
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
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
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
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
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