CSIS3820.cpp

Go to the documentation of this file.
00001 /*
00002                     GNU GENERAL PUBLIC LICENSE
00003                        Version 2, June 1991
00004 
00005  Copyright (C) 1989, 1991 Free Software Foundation, Inc.
00006                        59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00007  Everyone is permitted to copy and distribute verbatim copies
00008  of this license document, but changing it is not allowed.
00009 
00010                             Preamble
00011 
00012   The licenses for most software are designed to take away your
00013 freedom to share and change it.  By contrast, the GNU General Public
00014 License is intended to guarantee your freedom to share and change free
00015 software--to make sure the software is free for all its users.  This
00016 General Public License applies to most of the Free Software
00017 Foundation's software and to any other program whose authors commit to
00018 using it.  (Some other Free Software Foundation software is covered by
00019 the GNU Library General Public License instead.)  You can apply it to
00020 your programs, too.
00021 
00022   When we speak of free software, we are referring to freedom, not
00023 price.  Our General Public Licenses are designed to make sure that you
00024 have the freedom to distribute copies of free software (and charge for
00025 this service if you wish), that you receive source code or can get it
00026 if you want it, that you can change the software or use pieces of it
00027 in new free programs; and that you know you can do these things.
00028 
00029   To protect your rights, we need to make restrictions that forbid
00030 anyone to deny you these rights or to ask you to surrender the rights.
00031 These restrictions translate to certain responsibilities for you if you
00032 distribute copies of the software, or if you modify it.
00033 
00034   For example, if you distribute copies of such a program, whether
00035 gratis or for a fee, you must give the recipients all the rights that
00036 you have.  You must make sure that they, too, receive or can get the
00037 source code.  And you must show them these terms so they know their
00038 rights.
00039 
00040   We protect your rights with two steps: (1) copyright the software, and
00041 (2) offer you this license which gives you legal permission to copy,
00042 distribute and/or modify the software.
00043 
00044   Also, for each author's protection and ours, we want to make certain
00045 that everyone understands that there is no warranty for this free
00046 software.  If the software is modified by someone else and passed on, we
00047 want its recipients to know that what they have is not the original, so
00048 that any problems introduced by others will not reflect on the original
00049 authors' reputations.
00050 
00051   Finally, any free program is threatened constantly by software
00052 patents.  We wish to avoid the danger that redistributors of a free
00053 program will individually obtain patent licenses, in effect making the
00054 program proprietary.  To prevent this, we have made it clear that any
00055 patent must be licensed for everyone's free use or not licensed at all.
00056 
00057   The precise terms and conditions for copying, distribution and
00058 modification follow.
00059 
00060                     GNU GENERAL PUBLIC LICENSE
00061    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
00062 
00063   0. This License applies to any program or other work which contains
00064 a notice placed by the copyright holder saying it may be distributed
00065 under the terms of this General Public License.  The "Program", below,
00066 refers to any such program or work, and a "work based on the Program"
00067 means either the Program or any derivative work under copyright law:
00068 that is to say, a work containing the Program or a portion of it,
00069 either verbatim or with modifications and/or translated into another
00070 language.  (Hereinafter, translation is included without limitation in
00071 the term "modification".)  Each licensee is addressed as "you".
00072 
00073 Activities other than copying, distribution and modification are not
00074 covered by this License; they are outside its scope.  The act of
00075 running the Program is not restricted, and the output from the Program
00076 is covered only if its contents constitute a work based on the
00077 Program (independent of having been made by running the Program).
00078 Whether that is true depends on what the Program does.
00079 
00080   1. You may copy and distribute verbatim copies of the Program's
00081 source code as you receive it, in any medium, provided that you
00082 conspicuously and appropriately publish on each copy an appropriate
00083 copyright notice and disclaimer of warranty; keep intact all the
00084 notices that refer to this License and to the absence of any warranty;
00085 and give any other recipients of the Program a copy of this License
00086 along with the Program.
00087 
00088 You may charge a fee for the physical act of transferring a copy, and
00089 you may at your option offer warranty protection in exchange for a fee.
00090 
00091   2. You may modify your copy or copies of the Program or any portion
00092 of it, thus forming a work based on the Program, and copy and
00093 distribute such modifications or work under the terms of Section 1
00094 above, provided that you also meet all of these conditions:
00095 
00096     a) You must cause the modified files to carry prominent notices
00097     stating that you changed the files and the date of any change.
00098 
00099     b) You must cause any work that you distribute or publish, that in
00100     whole or in part contains or is derived from the Program or any
00101     part thereof, to be licensed as a whole at no charge to all third
00102     parties under the terms of this License.
00103 
00104     c) If the modified program normally reads commands interactively
00105     when run, you must cause it, when started running for such
00106     interactive use in the most ordinary way, to print or display an
00107     announcement including an appropriate copyright notice and a
00108     notice that there is no warranty (or else, saying that you provide
00109     a warranty) and that users may redistribute the program under
00110     these conditions, and telling the user how to view a copy of this
00111     License.  (Exception: if the Program itself is interactive but
00112     does not normally print such an announcement, your work based on
00113     the Program is not required to print an announcement.)
00114 
00115 These requirements apply to the modified work as a whole.  If
00116 identifiable sections of that work are not derived from the Program,
00117 and can be reasonably considered independent and separate works in
00118 themselves, then this License, and its terms, do not apply to those
00119 sections when you distribute them as separate works.  But when you
00120 distribute the same sections as part of a whole which is a work based
00121 on the Program, the distribution of the whole must be on the terms of
00122 this License, whose permissions for other licensees extend to the
00123 entire whole, and thus to each and every part regardless of who wrote it.
00124 
00125 Thus, it is not the intent of this section to claim rights or contest
00126 your rights to work written entirely by you; rather, the intent is to
00127 exercise the right to control the distribution of derivative or
00128 collective works based on the Program.
00129 
00130 In addition, mere aggregation of another work not based on the Program
00131 with the Program (or with a work based on the Program) on a volume of
00132 a storage or distribution medium does not bring the other work under
00133 the scope of this License.
00134 
00135   3. You may copy and distribute the Program (or a work based on it,
00136 under Section 2) in object code or executable form under the terms of
00137 Sections 1 and 2 above provided that you also do one of the following:
00138 
00139     a) Accompany it with the complete corresponding machine-readable
00140     source code, which must be distributed under the terms of Sections
00141     1 and 2 above on a medium customarily used for software interchange; or,
00142 
00143     b) Accompany it with a written offer, valid for at least three
00144     years, to give any third party, for a charge no more than your
00145     cost of physically performing source distribution, a complete
00146     machine-readable copy of the corresponding source code, to be
00147     distributed under the terms of Sections 1 and 2 above on a medium
00148     customarily used for software interchange; or,
00149 
00150     c) Accompany it with the information you received as to the offer
00151     to distribute corresponding source code.  (This alternative is
00152     allowed only for noncommercial distribution and only if you
00153     received the program in object code or executable form with such
00154     an offer, in accord with Subsection b above.)
00155 
00156 The source code for a work means the preferred form of the work for
00157 making modifications to it.  For an executable work, complete source
00158 code means all the source code for all modules it contains, plus any
00159 associated interface definition files, plus the scripts used to
00160 control compilation and installation of the executable.  However, as a
00161 special exception, the source code distributed need not include
00162 anything that is normally distributed (in either source or binary
00163 form) with the major components (compiler, kernel, and so on) of the
00164 operating system on which the executable runs, unless that component
00165 itself accompanies the executable.
00166 
00167 If distribution of executable or object code is made by offering
00168 access to copy from a designated place, then offering equivalent
00169 access to copy the source code from the same place counts as
00170 distribution of the source code, even though third parties are not
00171 compelled to copy the source along with the object code.
00172 
00173   4. You may not copy, modify, sublicense, or distribute the Program
00174 except as expressly provided under this License.  Any attempt
00175 otherwise to copy, modify, sublicense or distribute the Program is
00176 void, and will automatically terminate your rights under this License.
00177 However, parties who have received copies, or rights, from you under
00178 this License will not have their licenses terminated so long as such
00179 parties remain in full compliance.
00180 
00181   5. You are not required to accept this License, since you have not
00182 signed it.  However, nothing else grants you permission to modify or
00183 distribute the Program or its derivative works.  These actions are
00184 prohibited by law if you do not accept this License.  Therefore, by
00185 modifying or distributing the Program (or any work based on the
00186 Program), you indicate your acceptance of this License to do so, and
00187 all its terms and conditions for copying, distributing or modifying
00188 the Program or works based on it.
00189 
00190   6. Each time you redistribute the Program (or any work based on the
00191 Program), the recipient automatically receives a license from the
00192 original licensor to copy, distribute or modify the Program subject to
00193 these terms and conditions.  You may not impose any further
00194 restrictions on the recipients' exercise of the rights granted herein.
00195 You are not responsible for enforcing compliance by third parties to
00196 this License.
00197 
00198   7. If, as a consequence of a court judgment or allegation of patent
00199 infringement or for any other reason (not limited to patent issues),
00200 conditions are imposed on you (whether by court order, agreement or
00201 otherwise) that contradict the conditions of this License, they do not
00202 excuse you from the conditions of this License.  If you cannot
00203 distribute so as to satisfy simultaneously your obligations under this
00204 License and any other pertinent obligations, then as a consequence you
00205 may not distribute the Program at all.  For example, if a patent
00206 license would not permit royalty-free redistribution of the Program by
00207 all those who receive copies directly or indirectly through you, then
00208 the only way you could satisfy both it and this License would be to
00209 refrain entirely from distribution of the Program.
00210 
00211 If any portion of this section is held invalid or unenforceable under
00212 any particular circumstance, the balance of the section is intended to
00213 apply and the section as a whole is intended to apply in other
00214 circumstances.
00215 
00216 It is not the purpose of this section to induce you to infringe any
00217 patents or other property right claims or to contest validity of any
00218 such claims; this section has the sole purpose of protecting the
00219 integrity of the free software distribution system, which is
00220 implemented by public license practices.  Many people have made
00221 generous contributions to the wide range of software distributed
00222 through that system in reliance on consistent application of that
00223 system; it is up to the author/donor to decide if he or she is willing
00224 to distribute software through any other system and a licensee cannot
00225 impose that choice.
00226 
00227 This section is intended to make thoroughly clear what is believed to
00228 be a consequence of the rest of this License.
00229 
00230   8. If the distribution and/or use of the Program is restricted in
00231 certain countries either by patents or by copyrighted interfaces, the
00232 original copyright holder who places the Program under this License
00233 may add an explicit geographical distribution limitation excluding
00234 those countries, so that distribution is permitted only in or among
00235 countries not thus excluded.  In such case, this License incorporates
00236 the limitation as if written in the body of this License.
00237 
00238   9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time.  Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
00239 
00240 Each version is given a distinguishing version number.  If the Program
00241 specifies a version number of this License which applies to it and "any
00242 later version", you have the option of following the terms and conditions 
00243 either of that version or of any later version published by the Free Software 
00244 Foundation.  If the Program does not specify a version number of this License,
00245  you may choose any version ever published by the Free Software Foundation.
00246 
00247   10. If you wish to incorporate parts of the Program into other free
00248 programs whose distribution conditions are different, write to the author to 
00249 ask for permission.  For software which is copyrighted by the Free Software 
00250 Foundation, write to the Free Software Foundation; we sometimes make 
00251 exceptions for this.  Our decision will be guided by the two goals of 
00252 preserving the free status of all derivatives of our free software and of 
00253 promoting the sharing and reuse of software generally.
00254 
00255                             NO WARRANTY
00256 
00257   11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
00258 THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN 
00259 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE 
00260 THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, 
00261 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
00262 FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND 
00263 PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, 
00264 YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
00265 
00266   12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 
00267 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 
00268 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 
00269 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 
00270 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO 
00271 LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR 
00272 THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 
00273 EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 
00274 DAMAGES.
00275 
00276                      END OF TERMS AND CONDITIONS '
00277 */
00278 
00279 #include <config.h>
00280 
00281 #include "CSIS3820.h"
00282 #include <string>
00283 #include <stdio.h>
00284 #include <stdlib.h>
00285 
00286 #ifdef HAVE_STD_NAMESPACE
00287 using namespace std;
00288 #endif
00289 
00290 
00291 static const int ModuleSize(0xb00);
00292 
00293 
00294 // Below are register offsets into the module:
00295 
00296                                 // CSR
00297 static const unsigned long CSR(0);
00298 static const unsigned int  LEDOn(1);
00299 static const unsigned int  LEDOff(0x10000);
00300 static const unsigned int  LEDIsOnMask(1);
00301 static const unsigned int  ISARMED(0x1000000);
00302 static const unsigned int  SCALERENABLED(0x10000);
00303 static const unsigned int  MCSENABLED(0x40000);
00304 static const unsigned int  ENABLEREFPULSER(0x40);
00305 static const unsigned int  DISABLEREFPULSER(0x400000);
00306 static const unsigned int  ENABLETESTPULSER(0x30);
00307 static const unsigned int  DISABLETESTPULSER(0x300000);
00308 static const unsigned int  REFPULSERON(0x40);
00309 static const unsigned int  TESTPULSERON(0X30);
00310 
00311                                 // Module Id/Firmware register
00312 
00313 static const unsigned long IdAndFirmware(0x4);
00314                                 // The id part of the register:
00315 static const unsigned int  IDShift(16);
00316 static const unsigned int  IDMask(0xffff); // After shift that is.
00317                                 // The revlevel part:
00318 static const unsigned int  REVMask(0xff);  // Revision fields 8bits
00319 static const unsigned int  MAJORShift(8); 
00320 
00321 
00322                                // Acquisition mode register
00323 
00324 static const unsigned int ACQMode(0x100);
00325 static const unsigned int OperatingModeMask(0x70000000);
00326 static const unsigned int InputModeMask(0x0070000);
00327 static const unsigned int LatchModeMask(0x00000070);
00328 static const unsigned int NONCLEARINGMODE(1);
00329 
00330                                 //  Reset key register.
00331 
00332 static const unsigned int RESET(0x400);
00333 
00334                                 // Clear channels key register.
00335 
00336 static const unsigned int CLEAR(0x40c);   //???
00337 
00338                                 // Latch key register...
00339 
00340 static const unsigned int LATCH(0x410);
00341 
00342                                 // Arm key register...
00343 
00344 static const unsigned int ARM(0x414);
00345 
00346 
00347                                 // key registers to enable/disable.
00348 
00349 static const unsigned int ENABLE(0x418);
00350 static const unsigned int DISABLE(0x41c);
00351 
00352 
00353                                 // The scaler counters:
00354 
00355 static const unsigned int SHADOWCOUNTERS(0x800); // Shadow regs.
00356 static const unsigned int COUNTERS(0xa00);  // Live counters.
00357 static const unsigned int ChannelCount(32); // # channels.
00358 
00379 CSIS3820::CSIS3820(unsigned long base, int crate) throw (string) :
00380   CModule32(base, ModuleSize, crate)
00381 {
00382 
00383   ULong_t ModuleInfo = getModuleInfo();
00384 
00385   int     id         = ((ModuleInfo >> IDShift) & IDMask);
00386 
00387   if(id != 0x3820) {
00388     ThrowString("CSIS3820::CSIS3820",
00389               "Base address does not point to an SIS3820 module");
00390   }
00391   Reset();
00392 
00393   // Setup the module to default mode:
00394 
00395   
00396 
00397 }
00398 
00403 double
00404 CSIS3820::getRevision() const
00405 {
00406   int id = getModuleInfo();
00407   
00408   int minor = id & REVMask;
00409   int major = ((id >> MAJORShift) && REVMask);
00410   char versionstring[100];
00411   sprintf(versionstring, "%d.%d", major, minor);
00412   return atof(versionstring);
00413 }
00414 
00418 int
00419 CSIS3820::getModuleInfo() const
00420 {
00421   return peek(IdAndFirmware);
00422 }
00427 void
00428 CSIS3820::LightOn() const
00429 {
00430   setCSR(LEDOn);
00431 }
00436 void
00437 CSIS3820::LightOff() const
00438 {
00439   setCSR(LEDOff);
00440 }
00441 
00448 unsigned int
00449 CSIS3820::getCsr() const 
00450 {
00451   return peek(CSR);
00452 }
00457 unsigned long
00458 CSIS3820::getAcqMode() const
00459 {
00460   return peek(ACQMode);
00461 }
00467 void
00468 CSIS3820::Reset() const
00469 {
00470   Key(RESET);
00471 }
00472 
00491 void
00492 CSIS3820::setOperatingMode(CSIS3820::OperatingMode mode)  const
00493   throw (string)
00494 {
00495   const char* pLeader("CSIS3820::setOperatingMode");
00496   switch (mode) {
00497   case LatchingScaler:
00498     {
00499       unsigned long  
00500         CurrentMode = getAcqMode();
00501       CurrentMode   = (CurrentMode & ~getOperatingMode()) | mode;
00502       setAcqMode(CurrentMode);
00503     }
00504     break;
00505   case MultiChannelScaler:
00506     ThrowString(pLeader, 
00507                 "MultiChannel mode  unsupported at this time.");
00508   case HistogrammingScaler:
00509     ThrowString(pLeader,
00510                 "Histogramming mode unsupported at this time");
00511   case RamTestScaler:
00512     ThrowString(pLeader,
00513                 "Ramtest mode unsupported at this time");
00514     
00515   default:
00516     ThrowString(pLeader,
00517                 "Unknown operating mode requested");
00518   }
00519 }
00523 CSIS3820::OperatingMode
00524 CSIS3820::getOperatingMode() const
00525 {
00526   unsigned long CurrentMode = getAcqMode();
00527   CurrentMode &= OperatingModeMask;
00528   return static_cast<OperatingMode>(CurrentMode);
00529 }
00530 
00582 void
00583 CSIS3820::setInputMode(CSIS3820::InputMode mode) const throw (string)
00584 {
00585   const char* pLeader("CSIS3820::setInputMode");
00586   switch (mode) {
00587     // Valid modes:
00588   case NoInputs:
00589   case InputLatchInhibitLatch:
00590   case InputLatchInhibitAllAndLatch:
00591   case InputLatchInhibitAll:
00592   case InhibitGroups:
00593   case InputLNEHiscal:
00594     {
00595       unsigned long current = getAcqMode();
00596       current = (current & ~getInputMode()) | mode;
00597       setAcqMode(current);
00598     }
00599     break;
00600   case InputLNEInhAllExtClear:
00601     if (getRevision() >= 1.08) {
00602       unsigned long current = getAcqMode();
00603       current = (current & ~getInputMode()) | mode;
00604       setAcqMode(current);
00605     }
00606     else {
00607       ThrowString(pLeader,"InputLNEInhAllExtClear requires FW rewv 1.5 and above.");
00608     }
00609     break;
00610     // unimplemented modes.
00611   case InputReserved7:
00612     
00613     ThrowString(pLeader,
00614                 "Unimplemented input mode requested (InputReserved*)");
00615     // Unknown mode:
00616   default:
00617     ThrowString(pLeader,
00618                 "Unrecognized input mode requested");
00619   }
00620 }
00621 
00630 CSIS3820::InputMode
00631 CSIS3820::getInputMode() const
00632 {
00633   unsigned long mode = getAcqMode();
00634   mode &= InputModeMask;
00635   return static_cast<InputMode>(mode);
00636 }
00637 
00662 void
00663 CSIS3820::setLatchSource(LNESource mode) const
00664   throw (string)
00665 {
00666 
00667   const char* pLeader("CSIS3820::SetLatchSource");
00668 
00669   switch (mode) {
00670     // supported modes.
00671   case LatchVMEOnly:
00672   case LatchFP:
00673   case Latch10Mhz:
00674 
00675     {
00676       unsigned long acqmode = getAcqMode();
00677       acqmode    = (acqmode & ~getLatchSource()) | mode;
00678       setAcqMode(acqmode);
00679     }
00680     break;
00681 
00682     // unsupported modes.
00683 
00684   case LatchChannelN:
00685   case LatchPresetN:
00686   case LatchReserved5:
00687   case LatchReserved6:
00688   case LatchReserved7:
00689     ThrowString(pLeader,
00690                 "Unsupported latch mode.");
00691 
00692     // unrecognized mode.
00693 
00694   default:
00695     ThrowString(pLeader,
00696                 "Unrecognized latch mode ");
00697   }
00698   
00699 }
00703 CSIS3820::LNESource
00704 CSIS3820::getLatchSource() const
00705 {
00706   unsigned long mode = getAcqMode();
00707   return static_cast<LNESource>(mode & LatchModeMask);
00708 }
00709 
00715 void
00716 CSIS3820::Arm() const
00717 {
00718   Key(ARM);
00719 }
00720 
00724 bool
00725 CSIS3820::isArmed() const
00726 {
00727   unsigned int csr = getCsr();
00728   return ((csr & ISARMED) != 0);
00729 
00730 }
00734 void
00735 CSIS3820::Enable() const
00736 {
00737   Key(ENABLE);
00738 
00739 }
00743 void 
00744 CSIS3820::Disable() const
00745 {
00746   Key(DISABLE);
00747 }
00754 bool
00755 CSIS3820::isEnabled() const
00756 {
00757   unsigned int csr = getCsr();
00758   return ((csr & (SCALERENABLED | MCSENABLED)) != 0);
00759 }
00760 
00766 void
00767 CSIS3820::EnableReferencePulser() const
00768 {
00769   setCSR(ENABLEREFPULSER);
00770 }
00776 void 
00777 CSIS3820::DisableReferencePulser() const
00778 {
00779   setCSR(DISABLEREFPULSER);
00780 }
00788 bool
00789 CSIS3820::isReferencePulserEnabled() const
00790 {
00791   unsigned int csr = getCsr();
00792   return ((csr & REFPULSERON) != 0);
00793 }
00794 
00795 
00801 void
00802 CSIS3820::EnableTestCounter() const
00803 {
00804   setCSR(ENABLETESTPULSER);
00805 }
00809 void 
00810 CSIS3820::DisableTestCounter() const
00811 {
00812   setCSR(DISABLETESTPULSER);
00813 }
00820 bool
00821 CSIS3820::isTestCounterOn() const
00822 {
00823   unsigned int csr = getCsr();
00824   return ((csr & TESTPULSERON) == TESTPULSERON); // not simple bits.
00825 }
00830 void
00831 CSIS3820::ClearChannels() const
00832 {
00833   Key(CLEAR);
00834 }
00841 void 
00842 CSIS3820::DisableClearOnLatch() const
00843 {
00844   unsigned long mode = getAcqMode();
00845   mode |= NONCLEARINGMODE;
00846   setAcqMode(mode);
00847 }
00853 void
00854 CSIS3820::EnableClearOnLatch() const
00855 {
00856   unsigned long mode = getAcqMode();
00857   mode &= ~NONCLEARINGMODE;
00858   setAcqMode(mode);
00859 }
00860 
00879 unsigned long
00880 CSIS3820::ReadChannel(unsigned int num) const
00881 {
00882 
00883   ValidChannel(num, "CSIS3820::ReadChannel");
00884   return peek(ChannelOffset(COUNTERS, num));
00885 
00886 }
00887 
00894 void
00895 CSIS3820::ReadAllChannels(unsigned long* buffer) const
00896 {
00897   for(unsigned int i =0; i < ChannelCount; i++) {
00898     *buffer++ = ReadChannel(i);
00899   }
00900 }
00907 void
00908 CSIS3820::Latch() const
00909 {
00910   Key(LATCH);
00911 }
00932 unsigned long
00933 CSIS3820:: ReadLatchedChannel(unsigned int num) const
00934 {
00935   ValidChannel( num, "CSIS3820::ReadLatchedChannel");
00936   return peek(ChannelOffset(SHADOWCOUNTERS,num));
00937 
00938 }
00947 void
00948 CSIS3820:: ReadAllLatchedChannels(unsigned long* buffer) const
00949 {
00950   for(int i =0; i < ChannelCount; i++) {
00951     *buffer++ = ReadLatchedChannel(i);
00952   }
00953 }
00961 void
00962 CSIS3820:: LatchAndRead(unsigned long* buffer) const
00963 {
00964   Latch();
00965   ReadAllLatchedChannels(buffer);
00966 }
00968 
00973 void
00974 CSIS3820::setAcqMode(unsigned long value) const
00975 {
00976   poke(value, ACQMode);
00977 }
00978 
00982 void
00983 CSIS3820::setCSR(unsigned int long data) const
00984 {
00985   poke(data, CSR);
00986 }
00997 void
00998 CSIS3820::ValidChannel(unsigned int chan, 
00999                        const char *pWhere) throw (string)
01000 {
01001   if(chan >= ChannelCount) {
01002     char msg[100];
01003     sprintf(msg, "Channel %d is out of range must be in [0,32)",
01004             chan);
01005     ThrowString(pWhere, msg);
01006   }
01007 }
01018 unsigned long
01019 CSIS3820:: ChannelOffset(unsigned long base, 
01020                                      unsigned int  chan)
01021 {
01022   return base + chan*sizeof(unsigned long);
01023 }

Generated on Wed Sep 17 08:38:09 2008 for NSCL Device support. by  doxygen 1.5.1