Update of /cvsroot/nsclspectcl/SpecTcl/TreeParam In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15978 Modified Files: Tag: SpecTcl-3-0_developmentreally CTreeVariableCommand.cpp Makefile.am SpectrumGenerator.tcl TreeVariableCommandTests.cpp Added Files: Tag: SpecTcl-3-0_developmentreally TclGrammerApp.cpp Log Message: Completed development Index: CTreeVariableCommand.cpp =================================================================== RCS file: /cvsroot/nsclspectcl/SpecTcl/TreeParam/Attic/CTreeVariableCommand.cpp,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** CTreeVariableCommand.cpp 15 Apr 2005 13:46:17 -0000 1.1.2.1 --- CTreeVariableCommand.cpp 16 Apr 2005 18:47:14 -0000 1.1.2.2 *************** *** 253,265 **** string name(argv[0]); ! string units(argv[1]); double value; try { ! value = rInterp.ExprDouble(argv[2]); } catch(...) { rResult = "Failed to parse value for treevariable -set needed a double and got : "; ! rResult += argv[2]; rResult += "\n"; rResult += Usage(); --- 253,265 ---- string name(argv[0]); ! string units(argv[2]); double value; try { ! value = rInterp.ExprDouble(argv[1]); } catch(...) { rResult = "Failed to parse value for treevariable -set needed a double and got : "; ! rResult += argv[1]; rResult += "\n"; rResult += Usage(); Index: Makefile.am =================================================================== RCS file: /cvsroot/nsclspectcl/SpecTcl/TreeParam/Attic/Makefile.am,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** Makefile.am 15 Apr 2005 15:37:49 -0000 1.1.2.1 --- Makefile.am 16 Apr 2005 18:47:15 -0000 1.1.2.2 *************** *** 68,70 **** ! libTreeParam_la_LDFLAGS = -version-info $(SOVERSION):0 \ No newline at end of file --- 68,76 ---- ! libTreeParam_la_LDFLAGS = -version-info $(SOVERSION):0 ! ! SCRIPTDEST = $(prefix)/Script ! install-exec-local: ! $(mkinstalldirs) $(SCRIPTDEST) ! $(INSTALL_PROGRAM) *.tcl $(SCRIPTDEST) ! --- NEW FILE: TclGrammerApp.cpp --- /* GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 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. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS ' */ static const char* Copyright = "(C) Copyright Michigan State University 2008, All rights reserved"; // Class: CTclGrammerApp /* Change Log: $Log: TclGrammerApp.cpp,v $ Revision 1.1.2.1 2005/04/16 18:47:15 ron-fox Completed development Revision 5.1.2.2 2005/03/15 17:28:52 ron-fox Add SpecTcl Application programming interface and make use of it in spots. Revision 5.1.2.1 2004/12/15 17:24:09 ron-fox - Port to gcc/g++ 3.x - Recast swrite/sread in terms of tcl[io]stream rather than the kludgy thing I had done of decoding the channel fd. This is both necessary due to g++ 3.x's runtime and nicer too!. Revision 5.1 2004/11/29 16:56:12 ron-fox Begin port to 3.x compilers calling this 3.0 Revision 4.16.4.2 2004/09/24 11:43:18 ron-fox - Add member function to get the multitestsource so the user program can add other sources, select different sources than the default etc. - Correct a defect in SetupTestDataSource.. it had created a local m_pMultiTestSource that hid the member data and therefore prevented it from being fetched or used. Revision 4.16.4.1 2004/04/12 16:37:32 ron-fox - Use etc for etc stuff with link named Etc rather than the other way around. - Extract all Makefile definitions into separate include files so the user makefile becomes less variable with time. Revision 4.16 2003/11/07 22:10:34 ron-fox Remove attempts to include sysinfo.h Revision 4.15 2003/08/27 15:45:31 ron-fox - Converted comments to Doxygen - Create the sink pipeline in TclGrammerApp.cpp rather than relying on global construction /initialization to get it done when we want it. (removed frmo Globals.cpp). Revision 4.14 2003/08/25 16:25:32 ron-fox Initial starting point for merge with filtering -- this probably does not generate a goo spectcl build. Revision 4.13 2003/08/25 16:11:01 ron-fox Get consistent merge with kanayo's development stuff Revision 4.12 2003/07/18 15:05:33 kanayo Continuing modifications for event filtering. Revision 4.11 2003/07/03 21:24:05 kanayo Continuing modifications for event filtering. Revision 4.10 2003/04/16 19:01:44 kanayo Modification for home directory (~) expansion using $HOME. Revision 4.9 2003/04/02 18:50:09 ron-fox Uncomment registration of filter command */ ////////////////////////// FILE_NAME.cpp ///////////////////////////////////////////////////// #include <config.h> #include "TclGrammerApp.h" #include <limits.h> #include <assert.h> #include "TCLHistogrammer.h" #include "TestFile.h" #include "MultiTestSource.h" #include "TCLApplication.h" #include "TCLVariable.h" #include "TCLProcessor.h" #include "TKRunControl.h" #include "NSCLBufferDecoder.h" #include "Globals.h" #include "RunControlPackage.h" #include "ParameterPackage.h" #include "SpectrumPackage.h" #include "DataSourcePackage.h" #include "GatePackage.h" #include "FilterCommand.h" #include "EventSinkPipeline.h" #include "TCLAnalyzer.h" #include "XamineEventHandler.h" #include "SpecTcl.h" #include <CTreeParameterCommand.h> #include <CTreeVariableCommand.h> #include <CTreeParameter.h> #include <CTreeVariable.h> #include <histotypes.h> #include <buftypes.h> #include <string> #include <Iostream.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <histotypes.h> #include <buftypes.h> #include <string> #include <stdio.h> #include <stdlib.h> #if defined(Darwin) #include <sys/syslimits.h> #endif #if defined(CYGWIN) extern "C" void cygwin_conv_to_full_win32_path(const char *path, char *win32_path); #endif #include "TCLAnalyzer.h" #ifdef HAVE_STD_NAMESPACE using namespace std; #endif // File scoped unbound variables: static const UInt_t knParameterCount = 256; static const UInt_t knEventListSize = 256; static const UInt_t knDisplaySize = 8; static const char* kpInstalledBase = INSTALLED_IN; // Preprocessor def. static const char* kpAppInitSubDir = "/etc"; static const char* kpAppInitFile = "/SpecTclInit.tcl"; static const char* kpUserInitFile = "/SpecTclRC.tcl"; // Static attribute storage and initialization for CTclGrammerApp // Constructors, destructors and other replacements for compiler cannonicals: /*! Constructing a CTclGrammerApp is what glues the library called SpecTcl into the program called SpecTcl. */ CTclGrammerApp::CTclGrammerApp() : CTCLApplication(), m_nDisplaySize(knDisplaySize), m_nParams(knParameterCount), m_nListSize(knEventListSize), m_pAnalyzer(0), m_pHistogrammer(0), m_pDecoder(0), m_pRunControl(0), m_pXamineEvents(0), m_pRunControlPackage(0), m_pParameterPackage(0), m_pSpectrumPackage(0), m_pDataSourcePackage(0), m_pGatePackage(0), m_RCFile(string("tcl_rcFielname"), kfFALSE), m_TclDisplaySize(string("DisplayMegabytes"), kfFALSE), m_TclParameterCount(string("ParameterCount"), kfFALSE), m_TclEventListSize(string("EventListSize"), kfFALSE), m_pMultiTestSource((CMultiTestSource*)kpNULL) { if(gpEventSource != (CFile*)kpNULL) { if(gpEventSource->getState() == kfsOpen) { gpEventSource->Close(); } delete gpEventSource; gpEventSource = (CFile*)kpNULL; } } // Destructor: /*! Since exit singals exit from the application (SpecTcl), and since I've now got some order issues which result in core dumps on cleanup, We'll try not deleting any of the members. */ CTclGrammerApp::~CTclGrammerApp() { } // Functions for class CTclGrammerApp /*! Add an event processor to the list of event processors maintained by SpecTcl's analyzer. This can only be safely called at the time or after the time that CreateAnalysisPipeline is called, since prior to that there's no assurance that the analyzer has been instantiated. \param rEventProcessor (in): Reference to the event processor to add to the pipeline */ void CTclGrammerApp::RegisterEventProcessor(CEventProcessor& rEventProcessor, const char* name) { SpecTcl* api = SpecTcl::getInstance(); api->AddEventProcessor(rEventProcessor, name); } // Function: // void BindTCLVariables(CTCLInterpreter& rInterp) // Operation Type: // Operation /* Purpose: Called to bind variables to the TCL interpreter used by SpecTcl. This member can be overidden, however for SpecTcl to work correctly it must be overridden as an extension, that is there should be as the first action a call to: CTclGrammerApp::BindTCLVariables */ void CTclGrammerApp::BindTCLVariables(CTCLInterpreter& rInterp) { // The following variables are bound to the interpreter passed as a // parameter: // // m_RCFile - Name of early init file. // m_TclDisplaySize - Number of megabytes of display storage. // m_ParameterCount - Guess at largest parameter number which will be stuffed // m_TclEventListSize - Number of event batched for analysis. CTCLVariable HomeDir(string("SpecTclHome"), kfFALSE); HomeDir.Bind(rInterp); #ifdef HAVE_WINDOWS_H // For CYGWIN, we need to modify the name so that it is the NT path // since our Tcl/Tk is unaware that Cygwin exists. char Win32Path[PATH_MAX+1]; cygwin_conv_to_full_win32_path(kpInstalledBase, Win32Path); // // Convert the \'s to /'s. // for(int i = 0; i < strlen(Win32Path); i++) { if(Win32Path[i] == '\\') Win32Path[i] = '/'; } HomeDir.Set(Win32Path); #else HomeDir.Set((char*)kpInstalledBase); #endif m_RCFile.Bind(rInterp); m_TclDisplaySize.Bind(rInterp); m_TclParameterCount.Bind(rInterp); m_TclEventListSize.Bind(rInterp); } // Function: // void SourceLimitScripts(CTCLInterpreter& rInterpreter) // Operation Type: // Behavior /*! Sources initialization scripts. The scripts sourced at this point in time are intended to allow additional variables to be defined and set as well as limits etc. It is not safe to do arbitrary SpecTcl commands at this point. Additional 'functional' scripts can be sourced from an overridden operator() Note that the default implementation can be overridden, however it sources scripts which set various limit variables and therefore an override should include the code: \param rInterpreter (in): Reference to the interpreter that will be used to source the scripts. */ void CTclGrammerApp::SourceLimitScripts(CTCLInterpreter& rInterpreter) { // The script being run is intended to set initial values // for all of the variables which are required by later stages // of initialization e.g. DisplayMegabytes. The scripts are searched for // and run from the following locations (in the order given): // $SpecTclHome/Scripts // ~ // . try { // Try from SpecTcl library dir. string AppFilename(kpInstalledBase); AppFilename += kpAppInitSubDir; AppFilename += kpAppInitFile; rInterpreter.EvalFile(AppFilename); } catch(...) { // Errors are silently ignored. } if(getenv("HOME")) { // Need home env variable. try { // Try from user's home dir: string AppFilename(getenv("HOME")); AppFilename += kpAppInitFile; rInterpreter.EvalFile(AppFilename); } catch(...) { } } try { // Try the cwd. string AppFilename("."); AppFilename += kpAppInitFile; rInterpreter.EvalFile(AppFilename); } catch(...) { } } // Function: // void SetLimits() // Operation Type: // Behavior /*! Based on script variables etc. set limits and other statically defined variables. The default implementation uses this to set the final values for the size of the display subsystem shared memory, the parameter array size and the size of the event list. If this method is overridden, you should call the base class functionality to ensure that SpecTcl is properly started: */ void CTclGrammerApp::SetLimits() { UInt_t nResult; // The following members can be updated if the corresponding variables // have been created/modified: // m_nDisplaySize - # megabytes display memory (DisplayMegabytes). // m_nParams - Number of parameters in an event (ParameterCount). // m_nListSize - # events in a histogramming batch (EventListSize). // By this time the initial RC files have been run. UpdateUInt(m_TclDisplaySize, m_nDisplaySize); UpdateUInt(m_TclParameterCount, m_nParams); UpdateUInt(m_TclEventListSize, m_nListSize); } // Function: // void CreateHistogrammer() // Operation Type: // Behavior /*! Sets up the initial data sink configuration of spectcl. SpecTcl supports an ordered set of processors that take unpacked event lists and operate on them to produce the desired analysis. By default, Spectcl always an initial default entry in this <em> event sink pipeline, </em> a histogrammer. This function creates the pipeline, hooks it into the program superstructure, creates the histogrammer and inserts it in the pipeline. */ void CTclGrammerApp::CreateHistogrammer() { gpEventSinkPipeline = new CEventSinkPipeline; m_pHistogrammer = new CTCLHistogrammer(gpInterpreter, m_nDisplaySize*kn1M); gpEventSink = m_pHistogrammer; gpEventSinkPipeline->AddEventSink(*m_pHistogrammer, "::Histogrammer"); } // Function: // void SelectDisplayer(UInt_t nDisplaysize, CHistogrammer& rHistogrammer) // Operation Type: // Behavior /*! Selects the displayer and hooks it into the histogrammer. Note: In the current architecture, this selection is hardwired, however in the future, we will support turning on and off displayers, null displayers and so on and this member function will be useful at that time. \param nDisplaySize (in) The size of the display shared memory in mbytes. \param rHistogrammer (in) A reference to the histogrammer object. */ void CTclGrammerApp::SelectDisplayer(UInt_t nDisplaysize, CHistogrammer& rHistogrammer) { // We need to set up the Xamine event handler however: m_pXamineEvents = new CXamineEventHandler(gpInterpreter, (CHistogrammer*)gpEventSink); } // Function: // void SetupTestDataSource() // Operation Type: // Behavior /*! Sets up a test (internal) data source. The default behavior is to create fixed length event with some gaussian distributions for parameters. This source is used by SpecTcl developers to test functionality without referring to real data. Note that an eventsource is currently necessary to create and setup the run control object. */ void CTclGrammerApp::SetupTestDataSource() { // Uses a singleton map with at least the default test, // but also possibly named user-defined test distributions. m_pMultiTestSource = CMultiTestSource::GetInstance(); m_pMultiTestSource->useDefaultTestSource(); } // Function: // void CreateAnalyzer(CEventSink* pSink) // Operation Type: // Behavioral /*! Creates a data analyzer. The histogrammer in gpEventSink is set as the analyzer's event sink. Note that by default a CTclAnalyzer is created. \param pSink (in) The event sink to which unpacked event lists are sent. */ void CTclGrammerApp::CreateAnalyzer(CEventSink* pSink) { // A TCLAnalyzer is created as the analyzer m_pAnalyzer = new CTclAnalyzer(*gpInterpreter, m_nParams, m_nListSize); gpAnalyzer = m_pAnalyzer; // The histogrammer is hooked to the analyzer as an event sink: //m_pAnalyzer->AttachSink(*gpEventSink); m_pAnalyzer->AttachSink(*gpEventSinkPipeline); } // Function: // void SelectDecoder(CAnalyzer& rAnalyzer) // Operation Type: // Behavioral /*! Selects the initial Buffer decoder to be associated with the data stream. The default is to instantiate an NSCLBufferDecoder, connect it to the global pointer: gpBufferDecoder and in turn to the analyzer. Now switches on the attach command can select a buffer decoder. \param rAnalyzer [modified] The analyzer object that is being fed raw data. */ void CTclGrammerApp::SelectDecoder(CAnalyzer& rAnalyzer) { // An NSCL Buffer decoder is produced, saved and hooked to the analyzer: m_pDecoder = new CNSCLBufferDecoder; gpBufferDecoder = m_pDecoder; rAnalyzer.AttachDecoder(*m_pDecoder); } // Function: // void CreateAnalysisPipeline(CAnalyzer& rAnalyzer) // Operation Type: // Behavioral /*! This must be provided by the subclass. The experimenter must set up the analysis pipeline which manages the data received from the data source. This pipeline consists of an ordered set of CEventProcessor derived objects. Therefore this member function is abstract. \param rAnalyzer[modified] The analyzer in which the pipeline is being created. (NOTE: g++ allows us to 'implement' an abstract member, however the member is still treated as abstract externally. We may need to yank this function definition with later compiler versions. */ void CTclGrammerApp::CreateAnalysisPipeline(CAnalyzer& rAnalyzer) {} // Function: // void AddCommands(CTCLInterpreter& rInterp) // Operation Type: // Behavioral /*! Registers the commands and command packages which make up SpecTcl. Note that the default method registers the standard SpecTcl commands. If an override is supplied to add user commands, you must invoke the base class function at some point: \param rInterp [modified] The interpreter on which the commands are being registered. */ void CTclGrammerApp::AddCommands(CTCLInterpreter& rInterp) { // All of the 'standard' SpecTcl commands are organized as packages // of related commands. These packages are not Tcl packages but are just // groups of commands which share a common set of services provided // by a containing class. m_pRunControlPackage = new CRunControlPackage(&rInterp); m_pRunControlPackage->Register(); m_pRunControlPackage->InitializeRunState(); cerr << m_pRunControlPackage->getSignon() << endl; // Tacit assumption that the event sink is a histogrammer m_pParameterPackage = new CParameterPackage(&rInterp, (CTCLHistogrammer*)gpEventSink); m_pParameterPackage->Register(); cerr << m_pParameterPackage->getSignon() << endl; m_pSpectrumPackage = new CSpectrumPackage(&rInterp, (CHistogrammer*)gpEventSink); m_pSpectrumPackage->Register(); cerr << m_pSpectrumPackage->getSignon() << endl; m_pDataSourcePackage = new CDataSourcePackage(&rInterp); m_pDataSourcePackage->Register(); cerr << m_pDataSourcePackage->getSignon() << endl; m_pGatePackage = new CGatePackage(&rInterp, (CHistogrammer*)gpEventSink); m_pGatePackage->Register(); cerr << m_pGatePackage->getSignon() << endl; // For Filter command. CFilterCommand* pFilterCommand = new CFilterCommand(rInterp); pFilterCommand->Bind(rInterp); pFilterCommand->Register(); cerr << "Filter command (c) 2003 NSCL written by Kanayo Orji\n"; // Create the tree parameter package commands and bind any variables // that have been defined: CTreeParameterCommand* pTreeParamCommand = new CTreeParameterCommand; CTreeVariableCommand* pTreeVariableCommand = new CTreeVariableCommand; CTreeVariable::BindVariables(*(getInterpreter())); cerr << "Tree parameter/variable command " << CTreeParameter::TreeParameterVersion; cerr << " (c) Copyright 2005 NSCL written by Daniel Bazin, Ron Fox\n"; cerr.flush(); } // Function: // void SetupRunControl() // Operation Type: // /*! Setup the run control management. Run control in this case means managing the events that can indicate data readiness, enabling and disabling this. */ void CTclGrammerApp::SetupRunControl() { // We use a Tk run control. That's able to make use of the Tk // event loop processing software: // We use the globals in case some functions have been overridden. m_pRunControl = new CTKRunControl(gpInterpreter, *gpAnalyzer, *gpEventSource); gpRunControl = m_pRunControl; } // Function: // void SourceFunctionalScripts(CTCLInterpreter& rInterp) // Operation Type: // Behavioral /*! This function provides an opportunity to source scripts which perform functional operations either in spectcl or in other (e.g. Tk, Blt) packages which are now all hooked together properly. We'll try to locate SpecTclRC.tcl first in ~ and then in . \note Changed behavior... used to only look in ~ All found ones will be run in the order found. \param rInterp [in]: The interpreter that will execute these scripts. */ void CTclGrammerApp::SourceFunctionalScripts(CTCLInterpreter& rInterp) { try { // First run the ~ script: if(getenv("HOME")) { string RCFilename(getenv("HOME")); RCFilename += kpUserInitFile; rInterp.EvalFile(RCFilename); } } catch (...) { } try { string RCFilename("."); RCFilename += kpUserInitFile; rInterp.EvalFile(RCFilename); } catch (...) { } } // Function: // int operator()() // Operation Type: // Entry point /*! Called when the tcl interpreter starts up. The base functionality is to call the action member functions (e.g. CreateAnalyzer) in the appropriate order. This can be extended by overriding and delegating the operation to the base class or by writing an entirely new startup scheme as desired. */ int CTclGrammerApp::operator()() { // Fetch and setup the interpreter member/global pointer. gpInterpreter = getInterpreter(); // Bind any variables to Tcl: BindTCLVariables(*gpInterpreter); // Source limit setting scripts: SourceLimitScripts(*gpInterpreter); // Based on all of this set the final startup limits/values: SetLimits(); // Create the histogrammer event sink: CreateHistogrammer(); // Setup the histogram displayer: SelectDisplayer(m_nDisplaySize, *((CHistogrammer*)gpEventSink)); // Setup the test data source: SetupTestDataSource(); // No longer done. By default, no source is to be set so that users aren't mistakenly fooled by test data. // Create an analyzer and hook the histogrammer to it. //CreateAnalyzer(gpEventSink); CreateAnalyzer(gpEventSinkPipeline); // Setup the buffer decoder: SelectDecoder(*gpAnalyzer); // Setup the command packages: AddCommands(*gpInterpreter); // the run control objects. SetupRunControl(); // Setup the user's analysis pipeline: CreateAnalysisPipeline(*gpAnalyzer); CTreeParameter::BindParameters(); // Needed by treeparameter. // Finally the user may have some functional setup scripts they want // to run. By the time these are run, SpecTcl is essentially completely // set up. SourceFunctionalScripts(*gpInterpreter); return TCL_OK; } // Function: // static void UpdateUInt(CTCLVariable& rVar, UInt_t& rValue) // Operation Type: // Utility. void CTclGrammerApp::UpdateUInt(CTCLVariable& rVar, UInt_t& rValue) { int nResult; const char* pValue(rVar.Get(TCL_LEAVE_ERR_MSG|TCL_GLOBAL_ONLY)); if(pValue) { if(sscanf(pValue, "%ud", &nResult) > 0) { rValue = nResult; } else { // Value not unsigned complain and no update cerr << "The value of the Tcl variable " << rVar.getVariableName(); cerr << " is " << pValue; cerr << " which does not decode to an unsigned int.\n"; cerr << "SpecTcl will ignore this value and use its internal default.\n"; cerr.flush(); } } // No update. } Index: SpectrumGenerator.tcl =================================================================== RCS file: /cvsroot/nsclspectcl/SpecTcl/TreeParam/Attic/SpectrumGenerator.tcl,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** SpectrumGenerator.tcl 15 Apr 2005 13:52:15 -0000 1.1.2.1 --- SpectrumGenerator.tcl 16 Apr 2005 18:47:15 -0000 1.1.2.2 *************** *** 1132,1145 **** foreach tree $treeList { if {[treeparameter -check [lindex $tree 0]]} { ! append changedTreeList [treeparameter -list [lindex $tree 0]] } } set treeparameterList $changedTreeList - set treeList [treevariable -list] set changedTreeList "" foreach tree $treeList { if {[treevariable -check [lindex $tree 0]]} { ! append changedTreeList [treevariable -list [lindex $tree 0]] } } --- 1132,1144 ---- foreach tree $treeList { if {[treeparameter -check [lindex $tree 0]]} { ! append changedTreeList [treeparameter -list [lindex $tree 0]] " " } } set treeparameterList $changedTreeList set treeList [treevariable -list] set changedTreeList "" foreach tree $treeList { if {[treevariable -check [lindex $tree 0]]} { ! append changedTreeList [treevariable -list [lindex $tree 0]] " " } } *************** *** 1148,1151 **** --- 1147,1151 ---- # 12/16/04: Do not write deleted gates to file set rawList [gate -list] + set gateList ""; # It's possible to have 0 gates foreach g $rawList { set t [lindex $g 2] Index: TreeVariableCommandTests.cpp =================================================================== RCS file: /cvsroot/nsclspectcl/SpecTcl/TreeParam/Attic/TreeVariableCommandTests.cpp,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** TreeVariableCommandTests.cpp 15 Apr 2005 13:46:18 -0000 1.1.2.1 --- TreeVariableCommandTests.cpp 16 Apr 2005 18:47:15 -0000 1.1.2.2 *************** *** 340,344 **** TreeVarCommandTest::SetProperties() { ! char* argv[4] = {"nosuch", "mm", "aaaaa", "extra"}; int status = m_pCommand->SetProperties(*m_pInterp, *m_pResult, --- 340,344 ---- TreeVarCommandTest::SetProperties() { ! char* argv[4] = {"nosuch", "aaaa", "mm", "extra"}; int status = m_pCommand->SetProperties(*m_pInterp, *m_pResult, *************** *** 352,356 **** ! argv[0] = "inidiv"; status = m_pCommand->SetProperties(*m_pInterp, *m_pResult, 3, argv); EQMSG("Invalid fp value", TCL_ERROR , status); --- 352,356 ---- ! argv[0] = "indiv"; status = m_pCommand->SetProperties(*m_pInterp, *m_pResult, 3, argv); EQMSG("Invalid fp value", TCL_ERROR , status); *************** *** 359,363 **** argv[0] = "nosuch"; ! argv[2] = "55.55"; status = m_pCommand->SetProperties(*m_pInterp, *m_pResult, 3, argv); EQMSG("Invalid variable name", TCL_ERROR, status); --- 359,363 ---- argv[0] = "nosuch"; ! argv[1] = "55.55"; status = m_pCommand->SetProperties(*m_pInterp, *m_pResult, 3, argv); EQMSG("Invalid variable name", TCL_ERROR, status); *************** *** 374,378 **** // Set via command dispatch: ! char* cmdargv[5] = {"treevariable", "-set", "indiv", "in", "2.22"}; status = (*m_pCommand)(*m_pInterp, *m_pResult, 5, cmdargv); EQMSG("indiv good set via dispatch", TCL_OK, status); --- 374,378 ---- // Set via command dispatch: ! char* cmdargv[5] = {"treevariable", "-set", "indiv", "2.22", "in"}; status = (*m_pCommand)(*m_pInterp, *m_pResult, 5, cmdargv); EQMSG("indiv good set via dispatch", TCL_OK, status); |