timinghandler.cc

Go to the documentation of this file.
00001 
00003 
00004 //
00005 // Copyright (c) 1999-2004 California Institute of Technology
00006 // Copyright (c) 2004-2007 University of Southern California
00007 // Rob Peters <rjpeters at usc dot edu>
00008 //
00009 // created: Wed May 19 21:39:51 1999
00010 // commit: $Id: timinghandler.cc 10065 2007-04-12 05:54:56Z rjpeters $
00011 // $HeadURL: file:///lab/rjpeters/svnrepo/code/trunk/groovx/src/visx/timinghandler.cc $
00012 //
00013 // --------------------------------------------------------------------
00014 //
00015 // This file is part of GroovX.
00016 //   [http://ilab.usc.edu/rjpeters/groovx/]
00017 //
00018 // GroovX is free software; you can redistribute it and/or modify it
00019 // under the terms of the GNU General Public License as published by
00020 // the Free Software Foundation; either version 2 of the License, or
00021 // (at your option) any later version.
00022 //
00023 // GroovX is distributed in the hope that it will be useful, but
00024 // WITHOUT ANY WARRANTY; without even the implied warranty of
00025 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00026 // General Public License for more details.
00027 //
00028 // You should have received a copy of the GNU General Public License
00029 // along with GroovX; if not, write to the Free Software Foundation,
00030 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00031 //
00033 
00034 #ifndef GROOVX_VISX_TIMINGHANDLER_CC_UTC20050626084016_DEFINED
00035 #define GROOVX_VISX_TIMINGHANDLER_CC_UTC20050626084016_DEFINED
00036 
00037 #include "timinghandler.h"
00038 
00039 #include "io/ioproxy.h"
00040 #include "io/reader.h"
00041 #include "io/writer.h"
00042 
00043 #include "nub/ref.h"
00044 
00045 #include "visx/trialevent.h"
00046 
00047 #include "rutz/trace.h"
00048 #include "rutz/debug.h"
00049 GVX_DBG_REGISTER
00050 
00051 namespace
00052 {
00053   const io::version_id TIMINGHANDLER_SVID = 2;
00054 }
00055 
00057 //
00058 // TimingHandler creator method definitions
00059 //
00061 
00062 TimingHandler* TimingHandler::make()
00063 {
00064 GVX_TRACE("TimingHandler::make");
00065   return new TimingHandler;
00066 }
00067 
00068 TimingHandler::TimingHandler() :
00069   stimdur_start_id(0),
00070   timeout_start_id(0),
00071   iti_response_id(0),
00072   abortwait_abort_id(0)
00073 {
00074 GVX_TRACE("TimingHandler::TimingHandler");
00075   addEventByName("DrawEvent", IMMEDIATE, 0);
00076   stimdur_start_id = addEventByName("UndrawEvent", FROM_START, 2000);
00077   timeout_start_id = addEventByName("AbortTrialEvent", FROM_START, 4000);
00078   addEventByName("UndrawEvent", FROM_RESPONSE, 0);
00079   iti_response_id = addEventByName("EndTrialEvent", FROM_RESPONSE, 1000);
00080   abortwait_abort_id = addEventByName("EndTrialEvent", FROM_ABORT, 1000);
00081 }
00082 
00083 TimingHandler::~TimingHandler() throw()
00084 {
00085 GVX_TRACE("TimingHandler::~TimingHandler");
00086 }
00087 
00088 io::version_id TimingHandler::class_version_id() const
00089 {
00090 GVX_TRACE("TimingHandler::class_version_id");
00091  return TIMINGHANDLER_SVID;
00092 }
00093 
00094 void TimingHandler::read_from(io::reader& reader)
00095 {
00096 GVX_TRACE("TimingHandler::read_from");
00097 
00098   reader.ensure_version_id("TimingHandler", 2, "Try groovx0.8a4", SRC_POS);
00099 
00100   reader.read_base_class("TimingHdlr", io::make_proxy<TimingHdlr>(this));
00101 }
00102 
00103 void TimingHandler::write_to(io::writer& writer) const
00104 {
00105 GVX_TRACE("TimingHandler::write_to");
00106 
00107   writer.ensure_output_version_id("TimingHandler",
00108             TIMINGHANDLER_SVID, 2, "Try groovx0.8a4", SRC_POS);
00109 
00110   writer.write_base_class("TimingHdlr", io::make_const_proxy<TimingHdlr>(this));
00111 }
00112 
00113 int TimingHandler::getAbortWait() const
00114 {
00115   return getEvent(FROM_ABORT, abortwait_abort_id)->getDelay();
00116 }
00117 
00118 int TimingHandler::getInterTrialInterval() const
00119 {
00120   return getEvent(FROM_RESPONSE, iti_response_id)->getDelay();
00121 }
00122 
00123 int TimingHandler::getStimDur() const
00124 {
00125   return getEvent(FROM_START, stimdur_start_id)->getDelay();
00126 }
00127 
00128 int TimingHandler::getTimeout() const
00129 {
00130   return getEvent(FROM_START, timeout_start_id)->getDelay();
00131 }
00132 
00133 void TimingHandler::setAbortWait(int msec)
00134 {
00135   getEvent(FROM_ABORT, abortwait_abort_id)->setDelay(msec);
00136 }
00137 
00138 void TimingHandler::setInterTrialInterval(int msec)
00139 {
00140   getEvent(FROM_RESPONSE, iti_response_id)->setDelay(msec);
00141 }
00142 
00143 void TimingHandler::setStimDur(int msec)
00144 {
00145   getEvent(FROM_START, stimdur_start_id)->setDelay(msec);
00146 }
00147 
00148 void TimingHandler::setTimeout(int msec)
00149 {
00150   getEvent(FROM_START, timeout_start_id)->setDelay(msec);
00151 }
00152 
00153 static const char __attribute__((used)) vcid_groovx_visx_timinghandler_cc_utc20050626084016[] = "$Id: timinghandler.cc 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00154 #endif // !GROOVX_VISX_TIMINGHANDLER_CC_UTC20050626084016_DEFINED

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:49:42 2008 by Doxygen version 1.5.5.