esrf

Beamline Instrument Software Support
SPEC Macro documentation: [ Macro Index | BCU Home ]

XML_obj.mac
See other macros in category: All
Description:
    Some macros to handle spechardware objects manipulations
Documentation:
    DESCRIPTION
    To do

    DEPENDENCIES
    XML_utils.mac

Macros:
    c_newObj
    Usage: c_newObj (id)
    Creates a spechw object: Creates an associative array to store data, identified by <id>. If object was existing, overwrites it.
    returns 0 .

    c_getObj
    Usage: c_getObj (id)
    Creates a spechw object if was not already existing. If object was existing, uses it.
    returns 0 .

    c_delObj
    Usage: c_delObj (id)
    Kill spec hw object 'id'.
    returns 0 if OK
    returns -1 if NOT OK

    c_isObj
    Usage: c_isObj (id)
    Check if 'id' is a valid spechw object
    returns 1 if is a spechw object
    returns 0 if not

    c_getObjName
    Usage: c_getObjName (id)
    returns a string being the name of the associative array for the spechw object 'id'.
    returns this string name if OK
    returns "__error__" if NOT OK

    c_setObjProp
    Usage: c_setObjProp (id,key,value)
    Sets the key,value of a spechw object 'id'
    returns 0 if OK
    returns -1 if OK

    c_getObjProp
    Usage: c_getObjProp (id,key)
    returns the key value of a spechw object
    returns "__error__" if not OK

    c_delObjProp
    Usage: c_delObjProp (id,key)
    delete a key of a spechw object
    returns 0 if OK
    returns "__error__" if not OK

    c_showObj
    Usage: c_showObj (id)
    Dumps the spechw object (only local keys)
    returns 0 if OK
    returns -1 if NOT OK

    c_dumpObj
    Usage: c_dumpObj (id)
    Dumps the complete spechw object
    returns 0 if OK
    returns -1 if NOT OK

    c_hasObjProp
    Usage: c_hasObjProp (id,key)
    Checks if this is a key for that spechw object.
    returns 1 if found
    returns 0 if not found

    c_getObjKey
    Usage: c_getObjKey (id,value)
    In spechw object 'id', finds the 'first' key which value is 'value'.
    returns this key if found
    returns __error__ if not found

    c_countObjProp
    Usage: c_countObjProp (id)
    For a spechw object, returns the number of xxx["local][] elements.
    returns -1 in case of error

    c_loadMotorsByRole
    Usage: c_loadMotorsByRole (id,hwr_obj)
    For a spechw object 'id', it will realize
    - extraction of all the 'hwrid' values associated to the 'role' properties.
    - each 'hwrid' value is assumed to be a xml path to the description of a hardware motor.
    - extracts from each 'hwrid' value, the associated motor name by reading the 'specname' property.
    - for each, register as ' real' (which checks motor present in the spec configuration.
    - for each, finally, if motor present, creates a property 'role' with value being this motor name.
    returns 0 if OK
    returns -1 if NOT OK

    c_loadByProp
    Usage: c_loadByProp (id,hwr_obj)
    For a spechw object 'id', it will extract from the hardware object (hwr_obj)all the property/values that it will store in the object, plus the information to be able to write them back to the xml file
    returns 0 if OK
    returns -1 if NOT OK

    c_registerMotor
    Usage: c_registerMotor (id,motorname,type,name)
    registers this motor in spechw object 'id' property list 'allrealmotor' (if type 'real') or 'allmacromotor' (if type 'macro'). If type 'macro', checks that the motor in the config is a macromotor of type 'name'
    If the motor is not in the config, does not include it in the corresponding list, and returns -1
    - returns 0 if OK
    - returns -1 if NOT in the config
    - returns -2 if NOT macromotor of type 'name'
    - returns -3 if 'id' is not an object or 'type' undefined

    c_hasMotor
    Usage: c_hasMotor (id,motorname,type)
    checks if the motor was registered as 'type'
    - returns 1 if YES
    - returns 0 if NO

    c_writeObj
    Usage: c_writeObj (id,prop)
    writes a property of a spechw object to the corresponding xml file

    c_createEquipList
    Usage: c_createEquipList (id,hw_obj)
    This reads a hardware object being of a particular type: containing the list of controllers of that type for a spec session. This is typically for a macromotor modules definition in the spec configuration.
    It stores this information in the spechw object 'id' with key,value being 'numerical index',controller name
    returns 0 if OK
    returns -1 if NOT OK

Internal Macros:
    c_blocExtractByRole
    Usage: c_blocExtractByRole (id,hwr_obj)
    For a spechw object 'id', extract the information by role, from a hardware object (hwr_obj). It creates an associative array with all this information, for futher use by c_extractByRole macro.
    ACCESS TO XML file
    returns 0 if OK
    returns -1 if NOT OK

    c_extractByRole
    Usage: c_extractByRole (id,hwr_obj,role,att,flagw)
    For an spechw object 'id', extracts from a hardware object (hwr_obj), the 'att' value associated to role 'role'.
    This macro executes a c_blocExtractByRole if not already done.
    - if flagw is set to 1, it means that we should be able to write back to the xml file. for that: sets to the spechw object the useful info (xml path ..) and in particular,creates a local key 'role' with the value being the value of hardware attribute 'att'.
    returns the 'att' value if OK
    returns the string __error__ if NOT OK

    c_blocExtractByProp
    Usage: c_blocExtractByProp (id,hwr_obj)
    For a spechw object 'id', extract the information by property, from a hardware object (hwr_obj), at first level. It creates an associative array with all this information, for futher use by c_ExtractByProp macro.
    ACCESS TO XML file
    returns 0 if OK
    returns -1 if NOT OK

    c_extractByProp
    Usage: c_extractByProp (id,hwr_obj,prop,flagw)
    For an spechw object 'id', extracts from a hardware object (hwr_obj), the value of property 'prop.
    This macro executes a c_blocExtractByProp if not already done.
    - if flagw is set to 1, it means that we should be able to write back to the xml file. for that: sets to the spechw object the useful info (xml path ..) and in particular,creates a local key 'prop' with this value.
    returns the 'prop' value if OK
    returns the string __error__ if NOT OK

    dbgp
    Usage: dbgp
    writes as print does, if DEBUG has bit 0x80 selected

    concatstring
    Usage: concatstring (str1,str2)
    returns left pushing string str1 to str2 (setting a blank between them

    isonstring
    Usage: isonstring (str1,str2)
    str2 being a string of names separated by blanks, this macro checks if str1 is one of them. This macro differs from index as index looks at an occurence of str1 (possibly itself inside a string)

    is_ass
    Usage: is_ass (arr)
    Check if arr is an existing global associative array
    returns 1 if OK
    returns 0 if not

Filename: XML_obj.mac
Author:
Last mod.: 27/07/2005 16:57 by guijarro