OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
PyTrackCmd.cpp
Go to the documentation of this file.
1 //
2 // Python API for TrackCmd
3 //
4 // Copyright (c) 2023, Chris Rogers, STFC Rutherford Appleton Laboratory, Didcot, UK
5 //
6 // This file is part of OPAL.
7 //
8 // OPAL 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 3 of the License, or
11 // (at your option) any later version.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
15 //
16 
18 #include "PyOpal/PyCore/Globals.h"
20 
21 #include "Track/TrackCmd.h"
22 
23 namespace PyOpal {
24 namespace PyTrackCmdNS {
25 
26 template <>
27 std::vector<PyOpalObjectNS::AttributeDef> PyOpalObjectNS::PyOpalObject<TrackCmd>::attributes = {
28  {"LINE", "line", "", PyOpalObjectNS::STRING},
29  {"BEAM", "beam", "", PyOpalObjectNS::STRING},
30  {"DT", "time_steps", "", PyOpalObjectNS::DOUBLE}, // array
31  {"DTSCINIT", "dt_space_charge", "", PyOpalObjectNS::DOUBLE},
32  {"DTAU", "dtau", "", PyOpalObjectNS::DOUBLE},
33  {"T0", "t0", "", PyOpalObjectNS::DOUBLE},
34  {"MAXSTEPS", "max_steps", "", PyOpalObjectNS::FLOAT_LIST},
35  {"STEPSPERTURN", "steps_per_turn", "", PyOpalObjectNS::DOUBLE},
36  {"ZSTART", "z_start", "", PyOpalObjectNS::DOUBLE},
37  {"ZSTOP", "z_stop", "", PyOpalObjectNS::FLOAT_LIST},
38  {"TIMEINTEGRATOR", "time_integrator", "", PyOpalObjectNS::PREDEFINED_STRING},
39  {"MAP_ORDER", "map_order", "", PyOpalObjectNS::DOUBLE},
40 };
41 
42 // Can't use the default PyObject execute function because we need to call
43 // setIsParseable to false (otherwise OPAL will try to parse it as an OPAL file)
45  std::shared_ptr<TrackCmd> objectPtr = cmd.getOpalShared();
46  objectPtr->setIsParseable(false);
47  objectPtr->execute();
48 }
49 
54  auto trackClass = trackCmd.make_class("Track");
55  trackClass.def("execute", &executeWrapper);
56 }
57 
58 } // PyTrackCmd
59 } // PyOpal
60 
void Initialise()
Definition: Globals.cpp:50
std::shared_ptr< C > getOpalShared()
Definition: PyOpalObject.h:286
boost::python::class_< PyC > make_class(const char *className)
Definition: PyOpalObject.h:745
void executeWrapper(PyOpalObjectNS::PyOpalObject< TrackCmd > &cmd)
Definition: PyTrackCmd.cpp:44