1 /* 2 * nest_timeconverter.cpp 3 * 4 * This file is part of NEST. 5 * 6 * Copyright (C) 2004 The NEST Initiative 7 * 8 * NEST is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation, either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * NEST is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with NEST. If not, see <http://www.gnu.org/licenses/>. 20 * 21 */ 22 23 #include "nest_timeconverter.h" 24 25 // Includes from nestkernel: 26 #include "nest_time.h" 27 28 namespace nest 29 { 30 TimeConverter()31TimeConverter::TimeConverter() 32 { 33 OLD_TICS_PER_STEP = Time::get_tics_per_step(); 34 OLD_TICS_PER_MS = Time::get_tics_per_ms(); 35 } 36 37 Time from_old_steps(long s_old) const38TimeConverter::from_old_steps( long s_old ) const 39 { 40 if ( s_old == Time::LIM_NEG_INF.steps or s_old == Time::LIM_POS_INF.steps ) 41 { 42 return Time( Time::step( s_old ) ); 43 } 44 double ms = s_old * OLD_TICS_PER_STEP / OLD_TICS_PER_MS; 45 return Time::ms( ms ); 46 } 47 48 Time from_old_tics(tic_t t_old) const49TimeConverter::from_old_tics( tic_t t_old ) const 50 { 51 if ( t_old == Time::LIM_NEG_INF.tics or t_old == Time::LIM_POS_INF.tics ) 52 { 53 return Time( Time::tic( t_old ) ); 54 } 55 double ms = t_old / OLD_TICS_PER_MS; 56 return Time::ms( ms ); 57 } 58 } 59