From 3e81092c683c9aa6b506506e7ec285ce89398cd9 Mon Sep 17 00:00:00 2001 From: Malin E Date: Tue, 19 Apr 2022 11:26:16 +0200 Subject: [PATCH] Add duration to pointing event --- .../scene/solarsystem/missions/jwst/point_jwst.asset | 5 ++++- include/openspace/events/event.h | 7 +++++-- src/events/event.cpp | 9 +++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/data/assets/scene/solarsystem/missions/jwst/point_jwst.asset b/data/assets/scene/solarsystem/missions/jwst/point_jwst.asset index 365afff99e..3f148a78f3 100644 --- a/data/assets/scene/solarsystem/missions/jwst/point_jwst.asset +++ b/data/assets/scene/solarsystem/missions/jwst/point_jwst.asset @@ -1,12 +1,15 @@ local point_jwst = { Identifier = "event.jwst.point", Name = "Point JWST", + Command = [[ local ra local dec + local duration if is_declared("args") then ra = args.Ra dec = args.Dec + duration = args.Duration else return end @@ -128,7 +131,7 @@ local point_jwst = { openspace.setPropertyValueSingle( 'Scene.JWSTModel.Rotation.Rotation', { JWSTAngles[1], JWSTAngles[2], 0.0}, - 3.0 + duration ) ]], Documentation = [[ diff --git a/include/openspace/events/event.h b/include/openspace/events/event.h index e7cdcc3907..8b2c31b410 100644 --- a/include/openspace/events/event.h +++ b/include/openspace/events/event.h @@ -380,17 +380,20 @@ struct EventSessionRecordingPlayback : public Event { /** * This event is created when a request for pointing the JWST model to a Ra Dec coordinate * in the sky is issued. The event contains information about the sky coordinate to point - * the JWST towards. + * the JWST towards and an optional argument for the duration it should do the pointing. * * \param Ra The Ra part of the sky coordinate in decimal degrees to point the JWST to * \param Dec The Dec part of the sky coordinate in decimal degrees to point the JWST to + * \param Duration The duration of time in seconds that the telescope should redirect + * itself to the coordinate. Default is 3 seconds */ struct EventPointJwstRequested : public Event { static const Type Type = Event::Type::PointJwstRequested; - EventPointJwstRequested(double ra_, double dec_); + EventPointJwstRequested(double ra_, double dec_, double duration_ = 3.0); const double ra; const double dec; + const double duration; }; /** diff --git a/src/events/event.cpp b/src/events/event.cpp index 46f5a80207..65bfe9c34b 100644 --- a/src/events/event.cpp +++ b/src/events/event.cpp @@ -173,7 +173,10 @@ void log(int i, const EventSessionRecordingPlayback& e) { void log(int i, const EventPointJwstRequested& e) { ghoul_assert(e.type == EventPointJwstRequested::Type, "Wrong type"); - LINFO(fmt::format("[{}] PointJwstRequested: Ra: {}, Dec: {}", i, e.ra, e.dec)); + LINFO(fmt::format( + "[{}] PointJwstRequested: Ra: {}, Dec: {}, Duration: {}", i, e.ra, e.dec, + e.duration + )); } void log(int i, const CustomEvent& e) { @@ -423,6 +426,7 @@ ghoul::Dictionary toParameter(const Event& e) { case Event::Type::PointJwstRequested: d.setValue("Ra", static_cast(e).ra); d.setValue("Dec", static_cast(e).dec); + d.setValue("Duration", static_cast(e).duration); break; case Event::Type::Custom: d.setValue( @@ -605,10 +609,11 @@ EventSessionRecordingPlayback::EventSessionRecordingPlayback(State state_) , state(state_) {} -EventPointJwstRequested::EventPointJwstRequested(double ra_, double dec_) +EventPointJwstRequested::EventPointJwstRequested(double ra_, double dec_, double duration_) : Event(Type) , ra(ra_) , dec(dec_) + , duration(duration_) {} CustomEvent::CustomEvent(std::string_view subtype_, std::string_view payload_)