Skip to content
Snippets Groups Projects
Commit 01506819 authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Add to/fromAron() for IceUtil::Time and move to correct namespace

parent 0ff4f3e4
No related branches found
No related tags found
1 merge request!228Resolve "Use armarx::Time as armem::Time instead of IceUtil::Time"
#include "armarx.h"
#include <IceUtil/Time.h>
#include <RobotAPI/libraries/aron/common/aron_conversions/core.h>
#include <RobotAPI/libraries/aron/common/aron_conversions/stl.h>
namespace armarx
void IceUtil::fromAron(const long& dto, IceUtil::Time& bo)
{
bo = IceUtil::Time::microSeconds(dto);
}
/* PackagePath */
void IceUtil::toAron(long& dto, const IceUtil::Time& bo)
{
dto = bo.toMicroSeconds();
}
void fromAron(const arondto::PackagePath& dto, PackagePath& bo)
{
bo = {dto.package, dto.path};
}
void toAron(arondto::PackagePath& dto, const PackagePath& bo)
{
const data::PackagePath icedto = bo.serialize();
dto.package = icedto.package;
dto.path = icedto.path;
}
void IceUtil::fromAron(const IceUtil::Time& dto, armarx::DateTime& bo)
{
bo = armarx::DateTime(armarx::Duration::MicroSeconds(dto.toMicroSeconds()));
}
void fromAron(const long& dto, IceUtil::Time& bo)
{
bo = IceUtil::Time::microSeconds(dto);
}
void IceUtil::toAron(IceUtil::Time& dto, const armarx::DateTime& bo)
{
dto = IceUtil::Time::microSeconds(bo.toMicroSecondsSinceEpoch());
}
void toAron(long& dto, const IceUtil::Time& bo)
{
dto = bo.toMicroSeconds();
}
void fromAron(const arondto::ClockType& dto, ClockType& bo)
{
switch (dto.value)
{
case arondto::ClockType::Realtime:
bo = ClockType::Realtime;
break;
case arondto::ClockType::Monotonic:
bo = ClockType::Monotonic;
break;
case arondto::ClockType::Virtual:
bo = ClockType::Virtual;
break;
case arondto::ClockType::Unknown:
bo = ClockType::Unknown;
break;
}
}
/* PackagePath */
void toAron(arondto::ClockType& dto, const ClockType& bo)
{
switch (bo)
{
case ClockType::Realtime:
dto = arondto::ClockType::Realtime;
break;
case ClockType::Monotonic:
dto = arondto::ClockType::Monotonic;
break;
case ClockType::Virtual:
dto = arondto::ClockType::Virtual;
break;
case ClockType::Unknown:
dto = arondto::ClockType::Unknown;
break;
}
}
void armarx::fromAron(const arondto::PackagePath& dto, PackagePath& bo)
{
bo = {dto.package, dto.path};
}
void fromAron(const arondto::Duration& dto, Duration& bo)
{
bo = Duration::MicroSeconds(dto.microSeconds);
}
void armarx::toAron(arondto::PackagePath& dto, const PackagePath& bo)
{
const data::PackagePath icedto = bo.serialize();
dto.package = icedto.package;
dto.path = icedto.path;
}
void toAron(arondto::Duration& dto, const Duration& bo)
{
dto.microSeconds = bo.toMicroSeconds();
}
void fromAron(const arondto::Frequency& dto, Frequency& bo)
void armarx::fromAron(const arondto::ClockType& dto, ClockType& bo)
{
switch (dto.value)
{
Duration cycleDuration;
fromAron(dto.cycleDuration, cycleDuration);
bo = Frequency(cycleDuration);
case arondto::ClockType::Realtime:
bo = ClockType::Realtime;
break;
case arondto::ClockType::Monotonic:
bo = ClockType::Monotonic;
break;
case arondto::ClockType::Virtual:
bo = ClockType::Virtual;
break;
case arondto::ClockType::Unknown:
bo = ClockType::Unknown;
break;
}
}
void toAron(arondto::Frequency& dto, const Frequency& bo)
void armarx::toAron(arondto::ClockType& dto, const ClockType& bo)
{
switch (bo)
{
arondto::Duration cycleDuration;
toAron(cycleDuration, bo.toCycleDuration());
dto.cycleDuration = cycleDuration;
case ClockType::Realtime:
dto = arondto::ClockType::Realtime;
break;
case ClockType::Monotonic:
dto = arondto::ClockType::Monotonic;
break;
case ClockType::Virtual:
dto = arondto::ClockType::Virtual;
break;
case ClockType::Unknown:
dto = arondto::ClockType::Unknown;
break;
}
}
void fromAron(const arondto::DateTime& dto, DateTime& bo)
{
Duration timeSinceEpoch;
fromAron(dto.timeSinceEpoch, timeSinceEpoch);
ClockType clockType;
fromAron(dto.clockType, clockType);
bo = DateTime(timeSinceEpoch, clockType, dto.hostname);
}
void armarx::fromAron(const arondto::Duration& dto, Duration& bo)
{
bo = Duration::MicroSeconds(dto.microSeconds);
}
void toAron(arondto::DateTime& dto, const DateTime& bo)
{
arondto::Duration timeSinceEpoch;
toAron(timeSinceEpoch, bo.toDurationSinceEpoch());
dto.timeSinceEpoch = timeSinceEpoch;
arondto::ClockType clockType;
toAron(clockType, bo.clockType());
dto.clockType = clockType;
dto.hostname = bo.hostname();
}
void armarx::toAron(arondto::Duration& dto, const Duration& bo)
{
dto.microSeconds = bo.toMicroSeconds();
}
void armarx::fromAron(const arondto::Frequency& dto, Frequency& bo)
{
Duration cycleDuration;
fromAron(dto.cycleDuration, cycleDuration);
bo = Frequency(cycleDuration);
}
} // namespace armarx
void armarx::toAron(arondto::Frequency& dto, const Frequency& bo)
{
arondto::Duration cycleDuration;
toAron(cycleDuration, bo.toCycleDuration());
dto.cycleDuration = cycleDuration;
}
void armarx::fromAron(const arondto::DateTime& dto, DateTime& bo)
{
Duration timeSinceEpoch;
fromAron(dto.timeSinceEpoch, timeSinceEpoch);
ClockType clockType;
fromAron(dto.clockType, clockType);
bo = DateTime(timeSinceEpoch, clockType, dto.hostname);
}
void armarx::toAron(arondto::DateTime& dto, const DateTime& bo)
{
arondto::Duration timeSinceEpoch;
toAron(timeSinceEpoch, bo.toDurationSinceEpoch());
dto.timeSinceEpoch = timeSinceEpoch;
arondto::ClockType clockType;
toAron(clockType, bo.clockType());
dto.clockType = clockType;
dto.hostname = bo.hostname();
}
......@@ -3,21 +3,27 @@
#include <ArmarXCore/core/PackagePath.h>
#include <ArmarXCore/core/time_minimal.h>
#include <IceUtil/Time.h>
#include <RobotAPI/libraries/aron/common/aron/PackagePath.aron.generated.h>
#include <RobotAPI/libraries/aron/common/aron/time.aron.generated.h>
#include <RobotAPI/libraries/aron/common/aron/framed.aron.generated.h>
namespace IceUtil
{
class Time;
void fromAron(const long& dto, IceUtil::Time& bo);
void toAron(long& dto, const IceUtil::Time& bo);
void fromAron(const IceUtil::Time& dto, armarx::DateTime& bo);
void toAron(IceUtil::Time& dto, const armarx::DateTime& bo);
}
namespace armarx
{
void fromAron(const arondto::PackagePath& dto, PackagePath& bo);
void toAron(arondto::PackagePath& dto, const PackagePath& bo);
void fromAron(const long& dto, IceUtil::Time& bo);
void toAron(long& dto, const IceUtil::Time& bo);
void fromAron(const arondto::ClockType& dto, ClockType& bo);
void toAron(arondto::ClockType& dto, const ClockType& bo);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment