ARTS  2.4.0(git:4fb77825)
m_artstime.cc
Go to the documentation of this file.
1 /* Copyright (C) 2020
2  * Richard Larsson <larsson@mps.mpg.de>
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2, or (at your option) any
7  * later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17  * USA. */
18 
27 #include <thread>
28 
29 #include "matpackI.h"
30 #include "artstime.h"
31 #include "messages.h"
32 #include "sorting.h"
33 
34 
35 void timeNow(Time& time, const Verbosity&)
36 {
37  time = Time();
38 }
39 
40 
41 void Duration(Numeric& duration, const Time& t0, const Time& t1, const Verbosity&)
42 {
43  duration = std::chrono::duration_cast<TimeStep>(t1 - t0).count();
44 }
45 
46 
47 void Sleep(const Numeric& duration, const Verbosity&)
48 {
49  std::this_thread::sleep_for(TimeStep(duration));
50 }
51 
52 
53 void timeSleep(const Time& time, const Verbosity&)
54 {
55  std::this_thread::sleep_until(time.Data());
56 }
57 
58 
60 {
61  const Time time;
62  const Time localtime = Time(time.toStruct());
63  const Time gmtime = Time(time.toGMTStruct());
64  dt = std::chrono::duration_cast<TimeStep>(localtime - gmtime).count();
65 }
66 
67 
68 void timeOffset(Time& time, const Numeric& offset, const Verbosity&)
69 {
70  time += TimeStep(offset);
71 }
72 
73 
75 {
76  for (Time& time: time_grid)
77  timeOffset(time, offset, verbosity);
78 }
ARTS::Var::verbosity
Verbosity verbosity(Workspace &ws) noexcept
Definition: autoarts.h:7112
TimeStep
std::chrono::duration< Numeric > TimeStep
A duration of time, 1 full tick should be 1 second.
Definition: artstime.h:37
time_gridOffset
void time_gridOffset(ArrayOfTime &time_grid, const Numeric &offset, const Verbosity &verbosity)
WORKSPACE METHOD: time_gridOffset.
Definition: m_artstime.cc:74
LocalTimeOffset
void LocalTimeOffset(Numeric &dt, const Verbosity &)
WORKSPACE METHOD: LocalTimeOffset.
Definition: m_artstime.cc:59
matpackI.h
Implementation of Matrix, Vector, and such stuff.
artstime.h
Stuff related to time in ARTS.
Array
This can be used to make arrays out of anything.
Definition: array.h:108
messages.h
Declarations having to do with the four output streams.
Sleep
void Sleep(const Numeric &duration, const Verbosity &)
WORKSPACE METHOD: Sleep.
Definition: m_artstime.cc:47
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
Verbosity
Definition: messages.h:49
ARTS::Var::time
Time time(Workspace &ws) noexcept
Definition: autoarts.h:7043
timeSleep
void timeSleep(const Time &time, const Verbosity &)
WORKSPACE METHOD: timeSleep.
Definition: m_artstime.cc:53
Time
Class to handle time in ARTS.
Definition: artstime.h:40
ARTS::Group::Time
Time Time
Definition: autoarts.h:110
timeOffset
void timeOffset(Time &time, const Numeric &offset, const Verbosity &)
WORKSPACE METHOD: timeOffset.
Definition: m_artstime.cc:68
ARTS::Var::time_grid
ArrayOfTime time_grid(Workspace &ws) noexcept
Definition: autoarts.h:7050
Duration
void Duration(Numeric &duration, const Time &t0, const Time &t1, const Verbosity &)
WORKSPACE METHOD: Duration.
Definition: m_artstime.cc:41
sorting.h
Contains sorting routines.
timeNow
void timeNow(Time &time, const Verbosity &)
WORKSPACE METHOD: timeNow.
Definition: m_artstime.cc:35