• Main Page
  • Related Pages
  • Data Structures
  • Files
  • File List
  • Globals

llcontrol.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  *
00003  * File: llcontrol.h
00004  *
00005  * $RCSfile: llcontrol.h,v $
00006  * 
00007  * Copyright (C) 2001 D-TACQ Solutions Ltd
00008  * not to be used without owner's permission
00009  *
00010  * Description:
00011  *     application implementing the LOW LATENCY CONTROL feture
00012  *
00013  * $Id: llcontrol.h,v 1.1.4.17 2009/09/29 13:09:14 pgm Exp $
00014  * $Log: llcontrol.h,v $
00015  * Revision 1.1.4.17  2009/09/29 13:09:14  pgm
00016  * RFM emulation (not complete)
00017  *
00018  * Revision 1.1.4.16  2009/04/02 13:19:01  pgm
00019  * docs away
00020  *
00021  * Revision 1.1.4.15  2009/03/28 18:47:39  pgm
00022  * sync2VAO32 take 1
00023  *
00024  * Revision 1.1.4.14  2006/02/23 21:56:40  pgm
00025  * remove unwanted statics
00026  *
00027  * Revision 1.1.4.13  2006/01/15 11:18:18  pgm
00028  * SYNC_2V
00029  *
00030  * Revision 1.1.4.12  2006/01/09 13:40:31  pgm
00031  * SYNC_2V mode implemented
00032  *
00033  * Revision 1.1.4.11  2005/12/07 10:21:15  pgm
00034  * *** empty log message ***
00035  *
00036  * Revision 1.1.4.10  2005/12/06 21:22:40  pgm
00037  * ACQ216HS channels=2 pulls in antiphase
00038  *
00039  * Revision 1.1.4.9  2005/12/06 18:11:31  pgm
00040  * ACQ216HS (ChannelMask) option
00041  *
00042  * Revision 1.1.4.8  2005/11/04 17:26:18  pgm
00043  * *** empty log message ***
00044  *
00045  * Revision 1.1.4.7  2005/10/03 15:03:48  pgm
00046  * acq216 llc with prams
00047  *
00048  * Revision 1.1.4.6  2005/09/25 20:31:50  pgm
00049  * blocklen
00050  *
00051  * Revision 1.1.4.5  2005/08/11 10:02:24  pgm
00052  * SYNC_ECM - init host side slave memory areas
00053  *
00054  * Revision 1.1.4.4  2005/08/01 11:10:24  pgm
00055  * V2 part 1 running - local status, no hbpoll - ECM 100 acheived
00056  *
00057  * Revision 1.1.4.3  2004/12/09 22:31:57  pgm
00058  * microsecond timestamps do the BIZ - ECM20 here we go
00059  *
00060  * Revision 1.1.4.2  2004/12/09 12:58:34  pgm
00061  * various attempts at repartitioning for speed
00062  *
00063  * Revision 1.1.4.1  2004/11/04 07:13:13  pgm
00064  * merged multicard case
00065  *
00066  * Revision 1.1.2.7  2004/09/26 19:50:58  pgm
00067  * *** empty log message ***
00068  *
00069  * Revision 1.1.2.6  2004/09/26 11:32:39  pgm
00070  * multiboard tstats pollstats in
00071  *
00072  * Revision 1.1.2.5  2004/09/25 21:16:28  pgm
00073  * multiboard case runs
00074  *
00075  * Revision 1.1.2.4  2004/09/25 11:53:03  pgm
00076  * first pass multi done - check it works for n==1
00077  *
00078  * Revision 1.1.2.3  2004/09/25 09:12:35  pgm
00079  * *** empty log message ***
00080  *
00081  * Revision 1.1.2.2  2004/09/25 09:08:31  pgm
00082  * first UI/test split
00083  *
00084  * Revision 1.1.2.1  2004/09/25 08:46:04  pgm
00085  * *** empty log message ***
00086  *
00087  * Revision 1.1.2.1  2004/09/25 08:44:47  pgm
00088  * *** empty log message ***
00089  *
00090  */
00091 
00092 
00093 /** @file llcontrol.h shared data structs for llcontrol. */
00094 
00095 #ifndef __LLCONTROL_H__
00096 #define __LLCONTROL_H__
00097 
00098 extern int verbose;
00099 extern int G_quit;
00100 
00101 #define MAXTEST 12
00102 
00103 /** defines resources dedicated to each card. */
00104 struct Card {
00105         int slot;
00106         struct MU* mbx;           /* mapping to mailboxes on card */
00107         struct DmaBuffer* buf;    /* mapping of host-side buffer  */
00108 
00109         unsigned tlatch;
00110         unsigned sync_2v_offset_status_hsbt;
00111 };
00112 
00113 /** defines timing of the shot. */
00114 struct TimingStats {
00115         int iter;         /** iteration. */
00116         u32 tlatch;       /** Tlatch: time the adc was clocked at. */
00117         u32 tinst;        /** Tinst: time the counter was read at. */
00118         u32 tprocess;     /** Process time on target */
00119         int hb_poll;      /** Host buffer poll count.
00120                            *  first card, indicates amount of slack time
00121                            * other cards, should be small 
00122                            */
00123         int target_poll;  /* expect to be 1 for each card, a big number 
00124                              indicates that hb_poll mechanism failed */
00125         u32 test_points[MAXTEST];
00126 };
00127 
00128 
00129 
00130 #define ACQ196_BIGBUF_AREA 0x1000000  /* 16MB buffer assigned to each card */
00131 #define MAXCARDS 16
00132 #define MAXAO32  6                    /** Max AO32 Slave Cards */
00133 
00134 /** defines a test [shot] . */
00135 struct TestDescription {
00136         enum Mode { 
00137                 M_NULL,                 /**< null test                  */
00138                 M_SCM,                  /**< Soft Clock Master          */
00139                 M_ECS,                  /**< External Clock Slave       */
00140                 M_ECM,                  /**< ECM External Clock Master  */
00141                 M_SYNC_ECM,             /**< ECM, sync AO update        */
00142                 M_SYNC_2V,              /**< ECM, 2 Vector sync         */
00143                 M_SYNC_2VAO32,          /**< ECM, 2 Vector sync + AO32 cards */
00144                 M_MEASURE_BRIDGE,       /**< measure bridge latency     */
00145                 M_SYNC_2VRFM            /**< M_SYNC_2V, monitor at remote */
00146         } mode;
00147         
00148         struct ARG {
00149                 int interval;    /**< SCM: usecs delay  */
00150                 int divisor;     /**< ECM: external clock divisor       */
00151         }
00152                 arg;
00153         int iter;              /**< current iteration #                 */
00154             
00155         int iterations;        /**< #samples to acquire                 */
00156         int decimation;        /**< {0..15} (0 won't do much!)          */
00157         int overwrite;         /**< NOT append                          */
00158         const char*outfname;    /**< root name of output file (if output rqd)*/
00159         int do_work;           /**< do work (like read data in RT)      */
00160         int clkpos;            /**< 1=> clock positive edge             */
00161         int trpos;             /**< 1=> trigger positive edge           */
00162         int internal_loopback; 
00163         int min_latency_test;   /**< trim for abs minimum latency       */
00164 
00165         int mask_ints;         /**< optionally mask interrupts          */
00166         int mask_ints_mask;
00167 
00168         int ncards;
00169         struct Card cards[MAXCARDS];
00170 
00171         struct TimingStats* stats_buf[MAXCARDS];
00172 
00173         void* work_buf[MAXCARDS];
00174 
00175         int channels;
00176         int samples;                 /* # samples per capture, default:1 */
00177         int sample_size;
00178         int hb_polling;
00179 
00180         int update_dacs;
00181         char* dac_data_file;
00182         char* dac_data;
00183         int dac_data_samples;
00184         int dac_cursor;
00185 
00186         int feedback;
00187         int feedback_channel;
00188 
00189         int tlog;                      /* log times if set */
00190         const char* tlog_binfile;      /* to this file     */
00191         int sample_offset;             /* bytes to incr tgt point each smpl */
00192 
00193         int hardware_gate_off;         /* gate off is using by hardware, so
00194                                         * don't poll for it */
00195         u32 V2_BUFS[8]; 
00196 
00197         int ao32_count;
00198         int ao32_ids[MAXAO32];
00199 
00200         struct LLC200_INIT *llc200_init;
00201         int llc200_init_count;
00202         int acq216hs_ch12ch34_bonding;
00203 };
00204 
00205 #define LLC200_INIT_SZ sizeof(struct LLC200_INIT)
00206 
00207 #define V2_NOBUF 1   /**< no buffer required,  0 offset may be valid! */
00208 
00209 #define IS_SYNC_2V(mode) \
00210         ((mode) == M_SYNC_2V || (mode) == M_SYNC_2VAO32 || \
00211                 (mode) == M_SYNC_2VRFM)
00212 /*
00213  * define iterator for cards, assumes icard is a volatile variable
00214  * this is _much_ better represented in C++, see htstream for example
00215  */
00216 
00217 /*
00218  * iterator variable must be in scope for each call:
00219  */
00220 #define EACHCARD_INIT int icard
00221 
00222 #define EACHCARD(td) (&(td)->cards[icard])
00223 #define EACHMBX(td) ((td)->cards[icard].mbx)
00224 #define EACHBUF(td) ((td)->cards[icard].buf)
00225 #define EACHSLOT(td) ((td)->cards[icard].slot)
00226 
00227 /*
00228  * This is the iterator. WARNING: unsafe bracketing, easy to misuse!
00229  */
00230 #define FOREACHCARD for (icard = 0; icard != td->ncards; ++icard)
00231 
00232 #define FIRSTCARD(td) (&(td)->cards[0])
00233 #define FIRSTMBX(td) ((td)->cards[0].mbx)
00234 #define FIRSTBUF(td) ((td)->cards[0].buf)
00235 #define FIRSTSLOT(td) ((td)->cards[0].slot)
00236 
00237 #define THIS_CARD icard
00238 #define MASTER  (icard == 0)
00239 
00240 /* 
00241  * Core module EXPORTS these functions: 
00242  */
00243 
00244 int runTest( struct TestDescription* td );
00245 void setupAbortHandler( struct TestDescription* td );
00246 void setupMonitor( int millisec );
00247 void initCardResource(struct Card* card);
00248 
00249 
00250 
00251 /*
00252  * Code module IMPORTS these functions
00253  */
00254 
00255 
00256 static inline int td_sample_size(struct TestDescription* td)
00257 {
00258         return td->sample_size;
00259 //      return td->channels * sizeof(short);
00260 }
00261 static inline int td_dss(struct TestDescription* td)
00262 {
00263         return td_sample_size(td) * td->iterations;
00264 }
00265 
00266 
00267 static inline int isAcq216(void) {
00268         return getenv("ACQ216") != 0 || getenv("ACQ216HS") != 0;
00269 }
00270 static inline int isAcq216HS(void) {
00271         return getenv("ACQ216HS") != 0;
00272 }
00273 
00274 
00275 void updateTimingStats(
00276         struct TimingStats* buffer, int iter, struct TimingStats* stats); 
00277 #endif

Generated on Wed Jan 5 2011 for llcontrol by  doxygen 1.7.1