Explain Experiment Classes and Objects
Classes and Objects
A most useful feature of Explain™ is its implementation of classes. An Explain class is a complex data type. The class describes how the data are stored, accessed, and modified. It is therefore more than just a storage location for the data. An object is a particular instance of a class. For example, Joe and Al are both GUYS. Joe and Al are two objects; GUYS is a class.
Classes and objects are features that Explain inherited from its Smalltalk grandparent. If you’ve never seen an object-oriented language, the concepts may seem strange. (In traditional languages data don’t know how to modify or print themselves!) Once they master the ideas, most programmers find them easy to use and find they provide real advantages.
Let’s look at a quick example before getting into the details. Real experiments are a little more complicated than the one shown below.
class CURVE
cfunction New callin “CurveNew”
ifunction Run callin “CurveRun”
ifunction Printl callin “CurvePrintl”
class VRAMP
cfunction New callin “VrampNew”
license Signal callin “RampSignal”
function Main()
; Create a ramp generator
Signal = VRAMP.New(“SIGNAL”, Pstat, 1.0, 5.0, 0.010, 1.0)
; Specify the Signal for use with the Pstat object
Pstat.SetSignal(Signal)
; Create a curve to be run.
Crv = CURVE.New(“CURVE”, Pstat)
; Run the curve
Status = Crv.Run()
; Print the results to the output file
Crv.Printl()
Refer back to this script as we describe Classes and Objects.
Classes
Think of a class as a definition. It defines how objects of that class behave.
In the sample script , there are two classes, a CURVE class, and a VRAMP class. CURVE defines data-acquisition and display objects. When an experiment runs, data are stored in a CURVE object. A CURVE object displays itself on the screen as a real-time plot. A VRAMP object is a signal generator that scans applied voltage between two points.
Each class has a list of functions which can be applied either to the class or to objects created from the class. You won’t see the actual data layout as you would in a C-language structure or Pascal Record. That information is hidden. You can only see the various functions used to create or access the object. You must rely on these functions to either modify an object or access values within it.
There are three types of functions contained in a class:
These are indicated by the keywords cfunction, ifunction, and license, respectively. Each of these is discussed in its corresponding topic section.
Objects
The actual item which is created and manipulated is an object. Each object is created as an instance of a specific class. In Explain, we don’t have objects defined by more than one class. Objects have areas of storage assigned to them. They have a specific lifetime which we describe in other help sections.
Comments are closed.