Field Support Ideas. Tech-talk, 19 July 2007 Good Afternoon, I have now for the th time explained to some desperate EPICS newbie all the hoops one has.

Slides:



Advertisements
Similar presentations
Question Bank. Explain the syntax of if else statement? Define Union Define global and local variables with example Concept of recursion with example.
Advertisements

C Programming lecture 2 Beautiful programs Greek algorithms
CS 11 C track: lecture 7 Last week: structs, typedef, linked lists This week: hash tables more on the C preprocessor extern const.
C Language.
The C ++ Language BY Shery khan. The C++ Language Bjarne Stroupstrup, the language’s creator C++ was designed to provide Simula’s facilities for program.
Chapter 6 Type Checking. The compiler should report an error if an operator is applied to an incompatible operand. Type checking can be performed without.
Chapter 7 Process Environment Chien-Chung Shen CIS, UD
Dynamic Data Structures H&K Chapter 14 Instructor – Gokcen Cilingir Cpt S 121 (July 26, 2011) Washington State University.
VBA Modules, Functions, Variables, and Constants
. Templates. Example… A useful routine to have is void Swap( int& a, int &b ) { int tmp = a; a = b; b = tmp; }
1 Homework Turn in HW2 at start of next class. Starting Chapter 2 K&R. Read ahead. HW3 is on line. –Due: class 9, but a lot to do! –You may want to get.
Structure of a C program
Chapter 16 Templates. Copyright © 2006 Pearson Addison-Wesley. All rights reserved Learning Objectives  Function Templates  Syntax, defining 
PHYS 2020 Making Choices; Arrays. Arrays  An array is very much like a matrix.  In the C language, an array is a collection of variables, all of the.
Guide To UNIX Using Linux Third Edition
CSE 332: C++ program structure and development environment C++ Program Structure (and tools) Today we’ll talk generally about C++ development (plus a few.
Options for User Input Options for getting information from the user –Write event-driven code Con: requires a significant amount of new code to set-up.
POSIX: Files Introduction to Operating Systems: Discussion 1 Read Solaris System Interface Guide: Ch. 5.1 Basic File I/O.
Classes Representing Non-Trivial Objects. Problem Write a program that reads a temperature (either Fahrenheit or Celsius), and displays that same temperature.
Beginning C++ Through Game Programming, Second Edition by Michael Dawson.
Chapter 9 Defining New Types. Objectives Explore the use of member functions when creating a struct. Introduce some of the concepts behind object-oriented.
Names Variables Type Checking Strong Typing Type Compatibility 1.
Values, variables and types © Allan C. Milne v
C Programming Tutorial – Part I CS Introduction to Operating Systems.
COMPILERS Semantic Analysis hussein suleman uct csc3005h 2006.
C Tokens Identifiers Keywords Constants Operators Special symbols.
Functions, Pointers, Structures Keerthi Nelaturu.
Names and Scope. Scope Suppose that a name is used many times for different entities in text of the program, or in the course of execution. When the name.
Basic Java Syntax CSE301 University of Sunderland Harry R Erwin, PhD.
1 C - Memory Simple Types Arrays Pointers Pointer to Pointer Multi-dimensional Arrays Dynamic Memory Allocation.
1 1999/Ph 514: Record Support EPICS Record Support Marty Kraimer APS.
C# D1 CSC 298 Elements of C# code (part 2). C# D2 Writing a class (or a struct)  Similarly to Java or C++  Fields: to hold the class data  Methods:
COMPILERS Symbol Tables hussein suleman uct csc3003s 2007.
Learners Support Publications Classes and Objects.
More on Abstract Data Types Noah Mendelsohn Tufts University Web: COMP 40: Machine.
Week 9 - Monday.  What did we talk about last time?  Time  GDB.
EPICS record/device/driver Support many slides copied from
Data TypestMyn1 Data Types The type of a variable is not set by the programmer; rather, it is decided at runtime by PHP depending on the context in which.
Pointers: Basics. 2 What is a pointer? First of all, it is a variable, just like other variables you studied  So it has type, storage etc. Difference:
Classes Representing Non-Trivial Objects. Problem Write a program that reads a temperature (either Fahrenheit or Celsius), and displays that same temperature.
Introduction to C#. Why C#? Develop on the Following Platforms ASP.NET Native Windows Windows 8 / 8.1 Windows Phone WPF Android (Xamarin) iOS (Xamarin)
CS 376b Introduction to Computer Vision 01 / 23 / 2008 Instructor: Michael Eckmann.
C Functions Three major differences between C and Java functions: –Functions are stand-alone entities, not part of objects they can be defined in a file.
Lecture 3 Classes, Structs, Enums Passing by reference and value Arrays.
CPSC 252 The Big Three Page 1 The “Big Three” Every class that has data members pointing to dynamically allocated memory must implement these three methods:
Simple Classes. ADTs A specification for a real world data item –defines types and valid ranges –defines valid operations on the data. Specification is.
Slides created by: Professor Ian G. Harris Hello World #include main() { printf(“Hello, world.\n”); }  #include is a compiler directive to include (concatenate)
 2007 Pearson Education, Inc. All rights reserved C Arrays.
ENEE150 – 0102 ANDREW GOFFIN Project 4 & Function Pointers.
ICOM 4035 – Data Structures Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 2 – August 23, 2001.
A U.S. Department of Energy Office of Science Laboratory Operated by The University of Chicago Argonne National Laboratory Office of Science U.S. Department.
Array in C++ / review. An array contains multiple objects of identical types stored sequentially in memory. The individual objects in an array, referred.
Struct s (7.4) Used as data aggregates for an entity can be different types of data e.g. for student id, name, GPA, address,... Similar to classes, but.
Extra Recitations Wednesday 19:40-22:30 FENS L055 (tomorrow!) Friday 13:40-16:30 FENS L063 Friday 17: :30 FENS L045 Friday 19:40-22:30 FENS G032.
Chapter 17 – Templates. Function Templates u Express general form for a function u Example: template for adding two numbers Lesson 17.1 template Type.
Array and Pointers An Introduction Unit Unit Introduction This unit covers the usage of pointers and arrays in C++
1 Chapter 7 Pointers and C-Strings. 2 Objectives  To describe what a pointer is (§7.1).  To learn how to declare a pointer and assign a value to it.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
CPSC 252 ADTs and C++ Classes Page 1 Abstract data types (ADTs) An abstract data type is a user-defined data type that has: private data hidden inside.
Chapter 7 Process Environment Chien-Chung Shen CIS/UD
Lecture 9 Symbol Table and Attributed Grammars
User-Written Functions
A bit of C programming Lecture 3 Uli Raich.
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
Student Book An Introduction
Pass by Reference, const, readonly, struct
Classes and Objects.
EPICS Record/Device/Driver Support Interfaces
Java Programming Language
Week 9 - Monday CS222.
Presentation transcript:

Field Support Ideas

Tech-talk, 19 July 2007 Good Afternoon, I have now for the th time explained to some desperate EPICS newbie all the hoops one has to go through in order to create an array field for a new record type. This is starting to get on my nerves, the more so because I can't really tell them to go away and RTFM…. I dearly hope that with 3.15 there will be a dbd syntax for creating array fields. Ideally there should be a way to specify another field whose value at startup time determines the maximum number of elements. Life would be almost perfect if in addition the runtime number of elements could be specified in a similar way. It could be as simple as just one more (possible) property for a field value like, for instance, field(BLA,DBF_UCHAR) {... array(NELM,NORD) } which might optionally allow a literal number for the first argument (for a fixed size array) and where the second argument is optional (for arrays that don't change their number of elements at runtime). This would be a tremendously useful addition and would come at very low cost. It is even backward compatible. Frankly, I am amazed that something like this hasn't been done a long time ago. Cheers Ben (Franksen)

How do we solve this problem? …start by looking at the record support

Record support entry table typedef struct rset { long number; long (*report)(FILE fp, struct dbCommon * pRec); long (*init)(void); long (*init_record)( struct dbCommon *, int pass ); long (*process)( struct dbCommon * ); long (*special)( const struct dbAddr *paddr, int after ); long (*get_value)( struct dbCommon *, struct valueDes *p ); long (*cvt_dbaddr)( struct dbAddr * paddr ); long (*get_array_info)( const struct dbAddr *paddr, long *no_elements, long *offset); long (*put_array_info)( const struct dbAddr *paddr, long nRequest ); long (*get_units)(const struct dbAddr *paddr, char *units); long (*get_precision)(const struct dbAddr *paddr, long *precision); long (*get_enum_str)(const struct dbAddr *paddr, char * pbuffer); long (*get_enum_strs)(const struct dbAddr *paddr, struct dbr_enumStrs *p); long (*put_enum_str)(const struct dbAddr *paddr, const char * pbuffer); long (*get_graphic_double)(const struct dbAddr *paddr, struct dbr_grDouble *pgd); long (*get_control_double)(const struct dbAddr *paddr, struct dbr_ctrlDouble *pcd); long (*get_alarm_double)(const struct dbAddr *paddr,struct dbr_alDouble *p); } rset;

Record support entry table typedef struct rset { long number; long (*report)(FILE fp, struct dbCommon * pRec); long (*init)(void); long (*init_record)( struct dbCommon *, int pass ); long (*process)( struct dbCommon * ); long (*special)( const struct dbAddr *paddr, int after ); long (*get_value)( struct dbCommon *, struct valueDes *p ); long (*cvt_dbaddr)( struct dbAddr * paddr ); long (*get_array_info)( const struct dbAddr *paddr, long *no_elements, long *offset); long (*put_array_info)( const struct dbAddr *paddr, long nRequest ); long (*get_units)(const struct dbAddr *paddr, char *units); long (*get_precision)(const struct dbAddr *paddr, long *precision); long (*get_enum_str)(const struct dbAddr *paddr, char * pbuffer); long (*get_enum_strs)(const struct dbAddr *paddr, struct dbr_enumStrs *p); long (*put_enum_str)(const struct dbAddr *paddr, const char * pbuffer); long (*get_graphic_double)(const struct dbAddr *paddr, struct dbr_grDouble *pgd); long (*get_control_double)(const struct dbAddr *paddr, struct dbr_ctrlDouble *pcd); long (*get_alarm_double)(const struct dbAddr *paddr, struct dbr_alDouble *p); } rset; All the highlighted routines take a field pointer, rather a record pointer.

Field Support Provides default handling for common field type behaviours. Methods provided by a field support entry table, similar to record support. It is independent of the record type, and can take parameters passed in the dbd file. –Important to remember that parameters are per record type, not per record instance. At this point, I think field support should only access other fields in the current record, but not other records. In the current implementation, everything handled by offsets – types are checked at initialisation.

Progress so far Made all the changes required in base to support field support. Provided some helper routines to make field support easy to write. Written a default field support implementation that does all the “normal” things you would expect, and could replace most of the cvt_dbaddr, get_array_info, put_array_info, get_units get_precision, get_graphic_double, get_control_double and get_alarm double routines in base.

Field support entry table typedef struct { long number; long (*report)(FILE fp, struct dbFldDes * dbFldDes); long (*init)(void); void * (*init_field)( struct dbBase * dbbase, struct dbFldDes *); long (*init_record)( struct dbCommon *, struct dbFldDes * dbFldDes, int pass ); long (*special)( const struct dbAddr *paddr, int after ); long (*cvt_dbaddr)( struct dbAddr * paddr ); long (*get_array_info)( const struct dbAddr *paddr, long *no_elements, long *offset); long (*put_array_info)( const struct dbAddr *paddr, long nRequest ); long (*get_units)(const struct dbAddr *paddr, char *units); long (*get_precision)(const struct dbAddr *paddr, long *precision); long (*get_enum_str)(const struct dbAddr *paddr, char * pbuffer); long (*get_enum_strs)(const struct dbAddr *paddr, struct dbr_enumStrs *p); long (*put_enum_str)(const struct dbAddr *paddr, const char * pbuffer); long (*get_graphic_double)(const struct dbAddr *paddr, struct dbr_grDouble *pgd); long (*get_control_double)(const struct dbAddr *paddr, struct dbr_ctrlDouble *pcd); long (*get_alarm_double)(const struct dbAddr *paddr,struct dbr_alDouble *p); } fldSup_SET;

Field support processing If field support is defined and there is an appropriate entry in the field support table the routine is called. If field support is not defined, or if there is no entry in the field support table then the record support routine is called. If the field routine returns with failure then the record support routine is also called. If both field and record support routines report failure, then recGbl default routines are called, if necessary.

Example of field support in a dbd file field(BLA,DBF_NOACCESS) { … special(SPC_DBADDR) fldSup(fldSupDefault_fset) fldSup_type(UCHAR) fldSup_nelm(NELM) fldSup_nord(NORD) extra("void * val") } This is the equivalent of Ben Franksen’s example in the tech-talk posting. fldSup_ prefix is ugly for something which is really a sub structure, but it doesn’t break the dbd file syntax and so existing applications (e.g. vdct) don’t have to change. It’s a bit more verbose than Ben’s, but probably acceptable.

A more complete example field(VAL,DBF_NOACCESS) { prompt("Value") asl(ASL0) special(SPC_DBADDR) fldSup(fldSupDefault_fset) fldSup_bptr(BPTR) fldSup_type(FTVL) fldSup_nelm(NELM) fldSup_nord(NORD) fldSup_prec(PREC) fldSup_units(furlongs) fldSup_hopr(HOPR) fldSup_lopr(LOPR) fldSup_drvh(HOPR) fldSup_drvl(LOPR) fldSup_hihi(HOPR) fldSup_high(HOPR) fldSup_low(LOPR) fldSup_lolo(LOPR) pp(TRUE) extra("void * val") } Parameters can either be other fields in the record (e.g. PREC) or constants (e.g. furlongs). If you leave out fldSup_ declarations then the corresponding field support routine returns S_db_noRSET and defaults are used.

dbStatic field support helper routines fldSupParamId fldSupParamAdd( fldSupParamId pFldSup, char * name, char * value ); long fldSupParamFree(fldSupParamId pFldSup); char * fldSupParamGet(fldSupParamId pFldSup, const char * name ); long fldSupParamNth( fldSupParamId pFldSup, const unsigned int n, char ** name, char ** value); These just maintain a linked list of name-value pairs, so they can regurgitated or queried at a later time. Not to be accessed after runtime initialisation

Field support structures Field support structures stored in dbFldDes: –Field support entry table. –Name-value pairs generated by dbStatic and available at initialisation. –Pointer to a private runtime structure dbFldDes can be accessed at run-time through dbAddr

Field support runtime helpers dbFldLookup( dbFldDes * pFldDes, char * name, type, int offset ); –Used at initialisation to check types and to get the record offset of other fields in the record. void * dbFldSupPvt( DBADDR dbAddr ); –Returns field support private structure. void * dbFldPtr( DBADDR dbAddr, offset ); –Returns a pointer to another field in a record given an offset. (prossibly a macro).

Pros and Cons Cons: –Fairly significant change –May be some more (or less) additional overhead if used. Pros –Can provide simple support for arrays. –Backwards compatible – can be done now. –Can possibly provide support for dynamic strings. –Makes it more probable that better meta-data support is provided because it is easier to do. –Avoids a big switch statement in support routines. Status –At present this has been submitted to base, but should only be viewed as a prototype implementation.