Fraxinus  2023.01.05-dev+develop.0da12
An IGT application
cxIGTLinkConversionBase.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
12 
13 namespace cx
14 {
15 
16 QDateTime IGTLinkConversionBase::decode_timestamp(igtl::MessageBase* msg)
17 {
18  // get timestamp from igtl second-format:
19  igtl::TimeStamp::Pointer timestamp = igtl::TimeStamp::New();
20  msg->GetTimeStamp(timestamp);
21  double timestampMS = timestamp->GetTimeStamp() * 1000;
22  return QDateTime::fromMSecsSinceEpoch(timestampMS);
23 }
24 
25 void IGTLinkConversionBase::encode_timestamp(QDateTime ts, igtl::MessageBase* msg)
26 {
27  igtl::TimeStamp::Pointer timestamp;
28  timestamp = igtl::TimeStamp::New();
29  double grabTime = 1.0 / 1000 * (double) ts.toMSecsSinceEpoch();
30  timestamp->SetTime(grabTime);
31  msg->SetTimeStamp(timestamp);
32 }
33 
34 
35 } // namespace cx
Namespace for all CustusX production code.