<?xml version="1.0" ?>
<!DOCTYPE config [
  <!ELEMENT config (notes, modes, delegates, FSWinputs) >

  <!ELEMENT modes (notes?, mode*) >
  <!ELEMENT delegates (notes?, delegate*) >
  <!ELEMENT FSWinputs  (notes?, FSWinput*) >

  <!ELEMENT notes (#PCDATA) >

<!-- 
   regList may be used to document the registers or register fields
   "belonging" to a particular parameter, when this concept is appropriate.
 -->
  <!ELEMENT regList (#PCDATA) >

  <!ELEMENT mode (delegateRef+) >
  <!ATTLIST mode name CDATA #REQUIRED >

  <!ELEMENT delegateRef EMPTY>
  <!ATTLIST delegateRef ref IDREF #REQUIRED>

  <!ELEMENT delegate (notes, (parm | parmGroup)+) >
  <!ATTLIST delegate name CDATA #REQUIRED
                     id   ID    #REQUIRED
                     TLA  NMTOKEN #IMPLIED
                     out   IDREF     #IMPLIED >

  <!ELEMENT parm (notes?, regList?) >
  <!ATTLIST parm    name    CDATA #REQUIRED
                    TLA     NMTOKEN #IMPLIED
                    out     IDREF     #IMPLIED
                    reqd  (yes | no)  "yes" >

  <!ELEMENT parmGroup (notes?, parm+) >
  <!ATTLIST parmGroup    name    CDATA #REQUIRED
                         TLA     NMTOKEN #IMPLIED
                         out     IDREF     #IMPLIED>

  <!ELEMENT FSWinput (notes?)>
  <!ATTLIST FSWinput service (LATC | LCI | CDM | PIG) #REQUIRED
                     id   ID #REQUIRED>

] >

<config>
  <notes>Information (now somewhat refactored) on the whiteboard after 
         morning meeting of Aug. 8.  
         File contains a list of operating modes, followed by a list
         of &lt;delegates&gt; (in the MOOT sense;
         see e.g. http://www.slac.stanford.edu/exp/glast/ground/notes/moot/moot21july05.shtml) 
         and a list of &lt;FSWinputs&gt;.

  </notes>
<!-- For convenience, dtd is reproduced below, but not guaranteed to be
up to date.  See file source for the real thing. 
  <!ELEMENT config (notes, modes, delegates, outfiles) >

  <!ELEMENT modes (notes?, mode*) >
  <!ELEMENT delegates (notes?, delegate*) >
  <!ELEMENT FSWinputs  (notes?, FSWinputs*) >

  <!ELEMENT notes (#PCDATA) >

 
   regList may be used to document the registers or register fields
   "belonging" to a particular parameter, when this concept is appropriate.

  <!ELEMENT regList (#PCDATA) >

  <!ELEMENT mode (delegateRef+) >
  <!ATTLIST mode name CDATA #REQUIRED >

  <!ELEMENT delegateRef EMPTY>
  <!ATTLIST delegateRef ref IDREF #REQUIRED>

  <!ELEMENT delegate (notes, (parm | parmGroup)+) >
  <!ATTLIST delegate name CDATA #REQUIRED
                     id   ID    #REQUIRED
                     TLA  NMTOKEN #IMPLIED
                     out   IDREF     #IMPLIED >

  <!ELEMENT parm (notes?, regList?) >
  <!ATTLIST parm    name    CDATA #REQUIRED
                    TLA     NMTOKEN #IMPLIED
                    out     IDREF     #IMPLIED
                    reqd  (yes | no)  "yes" >

  <!ELEMENT parmGroup (notes?, parm+) >
  <!ATTLIST parmGroup    name    CDATA #REQUIRED
                         TLA     NMTOKEN #IMPLIED
                         out     IDREF     #IMPLIED>

  <!ELEMENT FSWinput (notes?)>
  <!ATTLIST FSWinput service (LATC | LCI | CDM) #REQUIRED
                     id   ID #REQUIRED>


-->
  <modes>
    <mode name="Physics">
       <delegateRef ref="HSK" />
       <delegateRef ref="LTC" />
       <delegateRef ref="EBM" />
       <delegateRef ref="Timing" />
       <delegateRef ref="Trigger" />
       <delegateRef ref="EFC" />
       <delegateRef ref="ACD" />
       <delegateRef ref="CAL" />
       <delegateRef ref="TKR" />
       <delegateRef ref="Power"  />
     </mode>
    <mode name="CI">
       <delegateRef ref="HSK" />
       <delegateRef ref="LTC" />
       <delegateRef ref="EBM" />
       <delegateRef ref="Timing" />
       <delegateRef ref="Trigger" />
       <delegateRef ref="EFC" />
       <delegateRef ref="ACD" />
       <delegateRef ref="CAL" />
       <delegateRef ref="TKR" />
       <delegateRef ref="Power"  />
       <delegateRef ref="LCI"  />
     </mode>
  </modes>
  <delegates>
    <notes>A &lt;delegate&gt; may have arbitrary collections of &lt;parm&gt; 
         and &lt;parmGroup&gt; children; a &lt;parmGroup&gt; may also have
         &lt;parm&gt; and &lt;parmGroup&gt; children, so the hierarchy
         under a &lt;delegate&gt; may be to arbitrary depth. 

         The smallest possible number of &lt;parm&gt;s should be used,
         subject to the following conditions: 1)
 information belonging to
         a single &lt;parm&gt; must all be destined for the same FSW
         input and 2) validity lifetime of all information encompassed 
         in a single &lt;parm&gt; should be approximately the same
         3) all information belonging to a single &lt;parm&gt; should
         come from "the same place".
    </notes>
    <delegate name="Housekeeping" TLA="HSK"  id="HSK" out="LHKout">
      <notes>Configuration parameters for LAT housekeeping</notes>
      <parm name="schedule" />
    </delegate>

    <delegate name="LAT Charge Injection" id="LCI" TLA="LCI">
      <notes>Configuration for charge injection calibrations.  May also 
           be enhanced to handle timing scans. This is the only delegate
           which allows registers to be set dynamically and
           repeatedly under program control.  Other delegates concerned
           with registers ask to set them once.</notes>
      <parm name="CAL_calib" out="LCI_CALout" reqd="no" >
        <notes>Can concatenate descriptions of multiple scans in
               a single calibration, but there is no easy way to 
               express that here.  If calibrations are typically done
               by running several scans in sequence, it may be a lost
               cause to try to specify it all here.  Would be better
               to just let CAL_calib take a single value, which is a
               reference to a file containing all the details.  
               Same would go for ACD and TKR calibrations.
        </notes>
      </parm>
      <parm name="TKR_calib" out="LCI_TKRout" reqd="no" />
      <parm name="ACD_calib" out="LCI_ACDout" reqd="no" />
    </delegate>

    <delegate name="LAT Thermal Control" TLA="LTC" id="LTC" out="LTCout" >
      <notes>Thermal control parameters.  
           Since input values all go into the same
           FSW file and probably tend to have the same lifetime,
           just need one &lt;parm&gt; element</notes>
      <parm name="thermal" />
<!--  More detailed description might be something like
      <parm name="sampling" />
      <parm name="conversion constants" />
      <parm name="mappings" />
      <parm name="limits" />
-->
    </delegate>

    <delegate name="Event Builder Module" TLA="EBM" id="EBM" out="EBMout" >
      <notes>
           There isn't much here and it should hardly change.</notes>
      <parm name="cpumask">
        <notes>Not sure this belongs here; may belong under PIG</notes>
      </parm>
      <parm name="SSR prefix" />
    </delegate>

    <delegate name="Timing" id="Timing">
      <notes>Output for this one will be scattered among different LATC 
           output files.
      </notes>
      <parmGroup name="TKR timing">
        <parm name="TKR tack delay" out="TEMout" reqd="no">
          <regList>tkr_trgseq, tack_delay field</regList>
        </parm>
        <parm name="trg_align" out="TCCout" reqd="no" >
          <regList>TCC tcc_trg_align register, both fields (shape_time,
                  primitive_align</regList>
        </parm>
      </parmGroup>
      <parmGroup name="CAL timing" >
        <parm name="CAL tack delay" out="TEMout" reqd="no" >
          <regList>cal_trgseq, tack_delay field</regList>
        </parm>
        <parm name="CRC delays" out="CRCout" reqd="no" >
          <regList>delay_1, delay_2, delay_3 in CRC</regList>
        </parm>
        <parm name="cal_align" out="CCCout" reqd="no">
          <regList>all fields within CCC trg_alignment register</regList>
        </parm>
      </parmGroup>
      <parm name="GEM timing" >
        <notes>Doesn't seem to be anything here</notes>
      </parm>
      <parm name="ACD timing" out="AEMout" >
        <notes>Is the one AEM register all that's needed?</notes>
        <regList>AEM trgseq register</regList>
      </parm>
      <parm name="PIG settings" out="PIGout" >
        <notes> Various timeout and delay registers are set by PIG
                since they should only need to be set once after
                everything is powered up and network is established.
        </notes>
        <regList>AEM timeout register, various ARC registers (see
             lrd_aem.xml), TEM configuration register, CCC event_timeouts
             register, TCC event_timeouts</regList>
      </parm>
      <parm name="Timing defaults" out="DFTout" >
        <regList>tkr_trgseq and cal_trgseq tack_delay fields (TEM).
                 tcc_trg_align register (TCC).
                 delay_1, delay_2, delay_3 (CRC).
                 ccc_trg_alignemnt (CCC).
        </regList>
      </parm>
    </delegate>

    <delegate name="Trigger" id="Trigger" out="GEMout" >
      <notes>Could this just be one parm?  Or will these things
           routinely change independently?</notes>
      <parm name="Regions Of Interest" TLA="ROI" >
        <regList>All registers in ROI component of GEM; names
                 are of form r_ijk_pqr or just r_ijk</regList>
      </parm>
      <parm name="window enable">
        <notes>this one was questionable (paranthesized)</notes>
        <regList>Registers in WIN component of GEM: window_width
                and window_open_mask
        </regList>
      </parm>
      <parm name="trigger engines">
        <notes>Configuration for each of the 16 engines includes at least TAM 
               and mappings.  TAM determines prescale, form of CAL
               readout, use/non-use of calstrobe, etc.</notes>
        <regList>Registers in the TAM component of GEM, named
                   engine_i, 0&lt;= i &lt; f  (oxf, that is); all fields.
                   Also 
                  perhaps the mapping in SCH ("scheduler registers") of
                 conditions to engines is what's meant.
                 </regList>
      </parm>
      <parm name="trigger enables">
        <notes>I'm making this one up, based on lrd and GEM document -
             seems not to be included elsewhere</notes>
        <regList>TIE in lrd-speak, or registers described in 
           section 2.9, "Input enable registers", of GEM document.
        </regList>
      </parm>
    </delegate>

    <delegate name="Physics parameters (event filter, others)" 
             id="EFC" TLA="EFC" >
      <notes>Output must be handled by CDM.  How many pieces are there? 

             Most likely will be moving cal gains and peds to CAL delegate;
             acd gains and peds to ACD delegate.
      </notes>
      <parm name="cal gains" />
      <parm name="cal peds" />
      <parm name="acd gains" />
      <parm name="acd peds" />
      <parmGroup name="filters" >
        <notes>n instances of the parms below.
           However, we might want to combine the whole thing
           in a single &lt;parm&gt; if all this stuff tends to
           change - or not change - on the same time scale; that
           is, in that case it might as well all be specified
           in a single file </notes>
        <parm name="filter parms" />
        <parm name="sampling parms" />
        <parm name="status parms" />
      </parmGroup>
      <parm name="GRB parms" />
    </delegate>

    <delegate name="Anti-coincidence Detector" id="ACD" TLA="ACD" >
      <notes>Output for this one will be split among different
           LATC files plus a little PIG.

           All broadcast (default) values have been gathered
           together in a single &lt;parm&gt;, the assumption
           being that none of them are likely to change very
           frequently.
      </notes>
      <parm name="membership" out="PIGout" >
        <notes>
          Has to be consistent with specifications in Power delegate
        </notes>
        <regList>PIG_acd_on(off) command.  Also PIG (I believe) controls 
                 power state of free boards by means of AEM power_up and 
                 power_down registers.
        </regList>
      </parm>
      <parmGroup name="masks" >
        <notes>
               Exceptional only.
        </notes>
        <parm name="Freeboard masking" out="AEMout">
           <notes>No bcast version since there is only one AEM.
              However, if LATC AEM output is lumped together with
              DFT, might consider moving this to the "ACD default" parm     
           </notes>
           <regList>data_mask field in aem_configuration reg. of AEM</regList>
        </parm>
        <parm name="pha, veto masking (exceptional)" out="ARCout" reqd="no">
          <regList>pha enable and veto enable register exceptional 
                   values</regList>
        </parm>
      </parmGroup>
      <parmGroup name="thresholds" >
        <parm name="lo exceptional" out="AFEout" reqd="no">
          <notes>Maybe should combine this parameter with the next one</notes>
          <regList>Veto DAC register and veto vernier register?</regList>
        </parm>
        <parm name="hi (CNO) exceptional" TLA="CNO" out="AFEout" reqd="no">
          <notes>Is HLD the right register for this? </notes>
          <regList>AFE HLD threshold registers</regList>
        </parm>
        <parm name="data thresholds exceptional" out="ARCout" reqd="no">
          <regList>PHA threshold registers</regList>
        </parm>
      </parmGroup>
      <parmGroup name="voltages" >
        <parm name="Bias exceptional" TLA="Op" out="AFEout" reqd="no" >
           <regList>AFE bias DAC registers</regList>
        </parm>
        <parm name="SAA" out="PIGout"  reqd="no" >
          <regList>ARC SSA and hvbs registers</regList>
        </parm>
      </parmGroup>
      <parm name="RC trimming exceptional" out="ARCout" reqd="no">
        <regList>Seems to correspond to Max PHA enable register</regList>
      </parm>
      <parm name="ACD defaults" out="DFTout" >
          <regList>pha enable and veto enable registers (ARC),
                   pha thresholds (ARC),
                   veto DAC register and veto vernier register (AFE)
                   HLD threshold register                      (AFE)
                   Operating bias voltage                      (AFE)
                   Max PHA enable register                     (ARC)
          </regList>
      </parm>

    </delegate>

    <delegate name="Calorimeter" id="CAL" TLA="CAL" >
      <notes>Output for this one will be split among different
           LATC files + a little PIG.
           All LATC defaults go in a single parameter.
      </notes>
      <parm name="membership" out="PIGout">
        <notes>
         TEM on/off state will be controlled within Power delegate.
         But there is a separate Calorimeter on/off field in the 
         TIC power supply register which is handled by PIG and
         might logically be specified here.
        </notes>
        <regList>calorimeter field in TIC power supply register;
              PIG_calorimeter_on(off) command</regList>
      </parm>
      <parmGroup name="exceptional masks" >
        <notes>Will need to change over time.  </notes>
        <parm name="Cal TEM data exceptional" out="TEMout" reqd="no" >
          <notes>Exceptional values, if any.
          </notes>
          <regList>TEM data masking register.</regList>
        </parm>
        <parm name="Cal TEM trigger exceptional" out="TICout" reqd="no" >
          <notes>Exceptional values, if any.
          </notes>
          <regList>TEM GTIC cal input mask register (enable/disable
                  a layer).</regList>
        </parm>
        <parm name="CCC masks exceptional" out="CCCout" reqd ="no" > 
          <notes>Exceptional values, if any, layer masking, output
            of cable controllers.
          </notes>
          <regList>CCC layer mask registers, controller output enable
              field of configuration register
          </regList>
        </parm>
        <parm name="CFE enables exceptional" out="CFEout" reqd="no" >
           <regList> CFE config 1 le_trigger_enable, he_trigger_enable.
              config 0 le_rng_enable, he_rng_enable fields.
              Other config 0 fields, such as OVERWRITE, FIRST_RNG,
              USE_FRST_RNG, having to do with range selection.

           </regList>
        </parm>
      </parmGroup>
      <parm name="FIFO depths exceptional" out="CCCout" reqd="no" >
        <regList>CCC configuration register, data_fifo,error_fifo and
                 diag_sum_fifo fields</regList>
      </parm>
      <parm name="thresholds exceptional" out="CFEout" reqd="no" >
        <regList> CFE registers FLE_DAC, FHE_DAC, LOG_ACPT,
                  RNG_ULD_DAC (range select threshold?)</regList>
      </parm>
      <parm name="bias voltages exceptional" out="TICout" reqd="no" >
        <regList>TIC cal bias dac</regList>
      </parm>
      <!-- parm name="RC trimming" >
        <notes>seems not to be any such thing for calorimeter</notes>
      </parm -->
      <parm name="calorimeter defaults" out="DFTout" reqd="yes">
         <notes>Includes defaults for all categories above:  masks,
                FIFO depths, thresholds, bias voltages.
                 TEM data masking register and the layer mask registers.
                 Note both data masking and trigger masking may be
                 specified here.</notes>
          <regList>
              Data masking register (TEM);
              cal input mask register (enable/disable a layer) (GTIC);
              layer mask registers  (CCC);
              controller output enable field of config. register (CCC);
              config 1 le_trigger_enable, he_trigger_enable fields (CFE);
              config 0 le_rng_enable, he_rng_enable fields (CFE);
              Other config 0 fields, such as OVERWRITE, FIRST_RNG,
              USE_FRST_RNG, having to do with range selection (CFE);
              fifo fields in config. register (CCC);
              threshold registers  (CFE);
              cal bias dac (TIC)
               </regList>
        </parm>


    </delegate>

    <delegate name="Tracker" id="TKR" TLA="TKR" >
      <notes>Output for this one will be split among different
           LATC files.
           Put all defaults in a single parameter, in hopes that
           they all are extremely stable.
           </notes>
      <parm name="membership" out="PIGout">
        <notes>
         TEM on/off state will be controlled within Power delegate.
         But there is a separate Tracker on/off field in the 
         TIC power supply register which is handled by PIG and
         might logically be specified here.
        </notes>
        <regList>Tracker field in TIC power supply register;
                PIG_tracker_on(off) command</regList>

      </parm>
      <parmGroup name="masks" >
        <notes>Will need to change over time.
                Is there anything from TRC which goes here?</notes>
        <parm name="trigger masks" out="TICout" reqd="no">
          <regList>GTIC layer enables and output masks</regList>
        </parm>
        <parm name="TKR TEM data exceptional" out="TEMout" reqd="no">
           <regList>TEM data masking register</regList>
        </parm>
        <parm name="TCC masks" out="TCCout" reqd="no">
          <regList>Input mask register, configuration register
             (output_enable field; maybe also cable_length field)</regList>
        </parm>
        <parm name="TFE masks" out="TFEout" reqd="no">
          <regList>data_mask, trg_enable</regList>
        </parm>
      </parmGroup>
      <parm name="splits" out="SPTout" reqd="no" >
        <notes>Will need to change over time</notes>
        <regList>low, high registers
        </regList>
      </parm>
      <parm name="FIFO depths" out="TCCout" reqd="no" >
        <regList>Config register, fifo fields for summary/diag and TOT,
                 error and data
        </regList>
      </parm>
      <parm name="thresholds" out="TDCout" reqd="no">
         <regList>
            tfe_dac, threshold field
         </regList>
      </parm>
      <parm name="bias voltages" out="TICout" reqd="no" >
        <regList>tkr_bias_dac register </regList>
      </parm>
      <parm name="RC trimming" out="TRCout" reqd="no">
        <notes>regList is a guess</notes>
        <regList>csr fields size_write_en and size (TRC)</regList>
      </parm>
      <parm name="Three-in-a-row" TLA="TIR" reqd="no">
        <notes>This is maybe already covered under masks/trigger masks
        </notes>
      </parm> 
      <parm name="Tracker defaults" reqd="yes">
        <regList>
          layer enables, output mask (GTIC)
          tkr_bias_dac register (TIC).
          data masking (TEM).
          input mask register, configuration register (TCC).
          csr fields for RC trimming (TRC).
          Config register, fifo fields for summary/diag and TOT, 
          error and data (TCC).
          tfe_dac, threshold field (TDC).
          low, high registers (SPT).
          
        </regList>
      </parm>
    </delegate>

    <delegate name="Power" id="Power" >
      <notes>This delegate is different from the others in that it is
            not handled by FMX; hence there is no associated &lt;FSWinput&gt;. 
            MOOT might not be involved in establishing a 
            particular state, but it might be involved in tracking 
            the state. May want to lump all this stuff together in
            one parameter.
            </notes>
      <parmGroup name="primaryRedundant" >
         <notes>For several objects a choice must be made whether to
               use the primary or redundant unit (or neither or both,
                if it makes sense). List below is not
               exhaustive.</notes>
         <parm name="mainfeed" />
         <parm name="PDU" />
         <parm name="SIU" />
      </parmGroup>
      <parm name="TEMSpower" >
        <notes>Which ones are on?  How to keep consistency with
               what's specified in CAL and TKR delegates?</notes>
      </parm>
      <parm name="ACDpower" />
      <parm name="EPUSpower" >
         <notes>Same comments as for TEMSpower: keep track of which
             are on.  May want separate parameter for each EPU.</notes>
      </parm>

    </delegate>

  </delegates>

  <FSWinputs>
    <notes>  An &lt;FSWinput&gt; represents one
         of the kinds of files to be input to a FSW service. These
         should almost map 1-1 to files output by FSW. LATC
         outputs 15 different kinds of files, by last count. LCI outputs
         one kind, and CDM will ultimately transform all other kinds
         of input (housekeeping, event filter parameters,...)
    </notes>
    <FSWinput id="LHKout" service="CDM">
      <notes>Single output for LAT Housekeeping parameters</notes>
    </FSWinput>



    <FSWinput id="GEMout" service="LATC">
    </FSWinput>


    <FSWinput id="AEMout" service="LATC">
    </FSWinput>

    <FSWinput id="ARCout" service="LATC">
      <notes>For ACD readout controller registers</notes>
    </FSWinput>

    <FSWinput id="AFEout" service="LATC">
      <notes>For ACD front-end registers</notes>
    </FSWinput>

    <FSWinput id="TEMout" service="LATC">
    </FSWinput>
    <FSWinput id="TICout" service="LATC">
      <notes>For Trigger Interface Control registers</notes>
    </FSWinput>

    <FSWinput id="CCCout" service="LATC">
      <notes>For Calorimeter Cable Controller registers</notes>
    </FSWinput>

    <FSWinput id="CRCout" service="LATC">
      <notes>For Calorimeter Readout Controller registers</notes>
    </FSWinput>

    <FSWinput id="CFEout" service="LATC">
      <notes>For Calorimeter Front-End registers</notes>
    </FSWinput>

  
    <FSWinput id="TCCout" service="LATC">
      <notes>For Tracker Cable Controller registers</notes>

    </FSWinput>

    <FSWinput id="TRCout" service="LATC">
      <notes>For Tracker Readout Controller registers</notes>

    </FSWinput>

    <FSWinput id="SPTout" service="LATC">
      <notes>Guessing this is for Tracker splits </notes>
    </FSWinput>

    <FSWinput id="TFEout" service="LATC">
      <notes>For Tracker Front-End registers</notes>

    </FSWinput>

    <FSWinput id="TDCout" service="LATC">
      <notes>For Tracker Digital Converter registers</notes>

    </FSWinput>

    <FSWinput id="DFTout" service="LATC">
      <notes>FSW output binary contains values for one each of the 
             register classes (GEM, AEB, ARC, AFE,...)
      </notes>
    </FSWinput>

    <FSWinput id="LCI_CALout" service="LCI">
      <notes>CAL charge injection config. </notes>
    </FSWinput>
    <FSWinput id="LCI_TKRout" service="LCI">
      <notes>TKR charge injection config. </notes>
    </FSWinput>
    <FSWinput id="LCI_ACDout" service="LCI">
      <notes>ACD charge injection config. </notes>
    </FSWinput>

    <FSWinput id="LTCout" service="CDM">
      <notes>Single output for Thermal Control parameters</notes>
    </FSWinput>

    <FSWinput id="EBMout" service="CDM">
      <notes>Need to check that there really is such a thing as an output
           file dedicated to EBM</notes>
    </FSWinput>
    <FSWinput id="PIGout" service="PIG">
      <notes>
      </notes>
    </FSWinput>

  </FSWinputs>
</config>

  




  
