[TransWarp] component path - property name dualism, does this make sense?

Phillip J. Eby pje at telecommunity.com
Mon Aug 18 12:35:27 EDT 2003


At 02:44 PM 8/18/03 +0200, Matthias Drochner wrote:

>The program is for controlling a spectrometer with some tens of
>mechanical axes, which can be grouped to logical units, or hidden
>by logical layers which perform unit conversions (or more complicated
>cristallographic calculations), or restrict movement.
>(This looks a lot like the "car" example in the tutorial...)
>Configuration data (limits, speeds, mapping to physical motor controllers)
>come from a special database in normal use, but each axis should be
>configurable to get its data from an ".ini" file for test reasons.
>
>If component bindings reflect the logical structure of the device, it
>seems natural for me to use this namespace to lookup configuration
>data. Now I get 2 problems:
>-the component path is not known at component class creation time
>-component and configuration paths are syntactically incompatible
>
>I'll append how I worked around so far.
>This doesn't look clean and pretty, so maybe I'm just missing
>the PEAKish way of accomplishing that?
>Or is it a bad idea to use component paths for configuration?

I don't know that it's a bad idea.  But PEAK currently only supports it 
cleanly via ZConfig.  In a ZConfig file, you can compose nested structures 
and specify values for individual attributes, etc.  Have you looked at 
ZConfig?  ZConfig lets you make configuration files that look like:

<Car>
Color Red
Drive 4wheel

     <Engine>
     Cylinders 8
     </Engine>

     <Wheel wheel1>
     Diameter 22in
     </Wheel>

     ...
</Car>

A schema written in XML describes the mappings from data values to data 
types, what fields are required/optional, etc.  PEAK can create objects 
from the sections using Component's 'fromZConfig' method.  Essentially, 
whenever a ZConfig file section ('<x></x>' block) corresponds to a PEAK 
component class, you can specify the component class' name in the schema, 
with '.fromZConfig' on the end of it.  So, ZConfig will call the 
'fromZConfig' class method of that class to create an instance of the 
component, loaded with the settings from the file.

Note that the "directive" names in the ZConfig file don't have to match 
your class' attribute names exactly.  You define the 
directiveName->attributeName mapping in the schema.

Is this closer to what you are trying to do?




More information about the PEAK mailing list