Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
TOUZE Francois
PSPA
Commits
58fd6992
Commit
58fd6992
authored
Dec 16, 2019
by
TOUZE Francois
Browse files
docker containers creation: step1
parent
04934a23
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
4601 additions
and
5 deletions
+4601
-5
backend/aml/v0/cmt/requirements
backend/aml/v0/cmt/requirements
+3
-3
backend/json/v0/cmt/requirements
backend/json/v0/cmt/requirements
+2
-2
backend/pspa/v0/cmt/requirements
backend/pspa/v0/cmt/requirements
+1
-0
controller/cython-cpp/README
controller/cython-cpp/README
+6
-0
controller/cython-cpp/pspaclass.cpp
controller/cython-cpp/pspaclass.cpp
+176
-0
controller/cython-cpp/pspaclass.h
controller/cython-cpp/pspaclass.h
+31
-0
controller/cython-cpp/pspaclass.pxd
controller/cython-cpp/pspaclass.pxd
+19
-0
controller/cython-cpp/pypspaclass.cpp
controller/cython-cpp/pypspaclass.cpp
+4289
-0
controller/cython-cpp/pypspaclass.pyx
controller/cython-cpp/pypspaclass.pyx
+38
-0
controller/cython-cpp/setup.py
controller/cython-cpp/setup.py
+22
-0
controller/requirements.txt
controller/requirements.txt
+14
-0
No files found.
backend/aml/v0/cmt/requirements
View file @
58fd6992
...
...
@@ -2,15 +2,15 @@ package aml
macro
aml_home
""
\
Darwin
"/Users/touze/Public/aml-uap.hg"
\
Linux
"/accelerator-ml-code"
Linux
"/
usr/local/
accelerator-ml-code"
macro
aml_cppflags
""
\
Darwin
" -I $(aml_home)"
\
Linux
" -I $(aml_home) -I/
xerces-c-3.2.2/src
/xercesc"
Linux
" -I $(aml_home) -I/
usr/local/include
/xercesc"
macro
aml_linkopts
""
\
Darwin
" -L${aml_home}/lib/ -lantlr -luap -L/usr/local/lib -lxerces-c"
\
Linux
" -L${aml_home}/lib/ -luap -lantlr -L/usr/local/lib -lxerces-c"
path_append
DYLD_LIBRARY_PATH
"/usr/local/lib"
path_append
LD_LIBRARY_PATH
"/usr/local/lib"
path_append
LD_LIBRARY_PATH
"/usr/local/lib"
backend/json/v0/cmt/requirements
View file @
58fd6992
package
json
macro
json_home
""
\
Linux
"/json"
\
Linux
"/
usr/local/
json"
\
Darwin
"/usr/local/Cellar/nlohmann_json/3.1.2"
macro
json_cppflags
""
\
Linux
" -I/json/include"
\
Linux
" -I/
usr/local/
json/include"
\
Darwin
" -I/usr/local/include/nlohmann"
backend/pspa/v0/cmt/requirements
View file @
58fd6992
...
...
@@ -22,3 +22,4 @@ application cppcode cppcode.cpp $(PSPAROOT)/src/Core/dataManager.cpp
macro_append
ppal_dependencies
" pspa "
path_append
DYLD_LIBRARY_PATH
"${PSPAROOT}/${CMTCONFIG}"
path_append
LD_LIBRARY_PATH
"${PSPAROOT}/${CMTCONFIG}"
controller/cython-cpp/README
0 → 100644
View file @
58fd6992
how to wrap C++ with Cython.
Assuming you have Python, Cython, Git and a C++ compiler installed
$ python setup.py build_ext --inplace
controller/cython-cpp/pspaclass.cpp
0 → 100644
View file @
58fd6992
#include <iostream>
#include "cppcode.h"
#include "componentFactory.h"
#include "elementBeam.h"
#include "elementBend.h"
#include "elementCathode.h"
#include "elementDrift.h"
#include "elementKicker.h"
#include "elementLinac.h"
#include "elementMarker.h"
#include "elementMpole.h"
#include "elementOpole.h"
#include "elementQpole.h"
#include "elementRfCavity.h"
#include "elementSolenoid.h"
#include "elementSpole.h"
#include <nlohmann/json.hpp>
using
json
=
nlohmann
::
json
;
using
namespace
std
;
pspa
::
pspa
()
{
nameOfCase_
=
string
();
dataManager_
=
NULL
;
string
userDir
=
string
(
getenv
(
"PWD"
)
);
string
workingDir
=
string
(
getenv
(
"PWD"
)
);
dataManager_
=
new
dataManager
(
userDir
,
workingDir
,
nameOfCase_
);
registerAllElements
();
componentFactory
::
enregistrer
(
new
sector
(
dataManager_
)
);
}
pspa
::
pspa
(
string
basename
)
{
nameOfCase_
=
string
();
string
userDir
=
basename
+
"workZone/"
;
string
workingDir
=
basename
+
"pspa.git/softwares/"
;
dataManager_
=
new
dataManager
(
userDir
,
workingDir
,
nameOfCase_
);
registerAllElements
();
componentFactory
::
enregistrer
(
new
sector
(
dataManager_
)
);
}
pspa
::
pspa
(
string
userDir
,
string
workingDir
)
{
nameOfCase_
=
string
();
dataManager_
=
new
dataManager
(
userDir
,
workingDir
,
nameOfCase_
);
registerAllElements
();
componentFactory
::
enregistrer
(
new
sector
(
dataManager_
)
);
}
pspa
::~
pspa
(
void
)
{
//cout << "pspa destructor\n";
}
void
pspa
::
splitter
(
string
s
)
{
nameOfCase_
=
s
;
typeOfFile_
=
string
();
string
::
size_type
n1
=
nameOfCase_
.
rfind
(
'.'
);
if
(
n1
!=
string
::
npos
)
{
typeOfFile_
=
nameOfCase_
.
substr
(
n1
);
string
::
size_type
n2
=
nameOfCase_
.
length
()
-
typeOfFile_
.
length
();
nameOfCase_
=
nameOfCase_
.
substr
(
0
,
n2
);
}
//cout << "splitter::nameOfCase : " << nameOfCase_ << endl;
//cout << "spiltter::typeOfFile : " << typeOfFile_ << endl;
}
string
pspa
::
read
(
const
char
*
argv
)
{
//cout << "pspa read()\n";
string
fileName
(
argv
);
splitter
(
fileName
);
dataManager_
->
setnameOfCase
(
nameOfCase_
);
bool
status
=
true
;
if
(
typeOfFile_
==
".aml"
)
{
cout
<<
"pspa::AML format input file
\n
"
;
status
=
dataManager_
->
parseAMLFile
(
fileName
);
}
else
if
(
typeOfFile_
==
".madx"
)
{
cout
<<
"pspa::MAD-X format input file
\n
"
;
status
=
dataManager_
->
parseXFile
(
fileName
);
}
else
if
(
typeOfFile_
==
".json"
)
{
cout
<<
"pspa::JSON format input file
\n
"
;
status
=
dataManager_
->
parseJSONFile
(
fileName
);
}
else
if
(
typeOfFile_
==
".str"
)
{
cout
<<
"pspa::BETA format input file
\n\n
"
;
status
=
dataManager_
->
parseBETAFile
(
fileName
);
}
else
{
cout
<<
"pspa::Unknown file extension
\n
"
;
}
string
s
;
if
(
status
)
{
json
j
=
dataManager_
->
toJSONFormat
();
s
=
j
.
dump
(
-
1
,
' '
,
true
);
}
return
s
;
}
bool
pspa
::
execute
(
string
obj
)
{
if
(
!
dataManager_
)
return
false
;
auto
j
=
json
::
parse
(
obj
);
if
(
!
dataManager_
->
fromSimulate
(
j
))
{
cout
<<
"dataManager::fromSimulate failed
\n
"
;
return
false
;
}
bool
status
=
simulate
();
if
(
status
)
{
cout
<<
"pspa::simulation: success
\n
"
;
dataManager_
->
settingPlot
();
}
else
cout
<<
"pspa::simulation: failure
\n
"
;
return
status
;
}
bool
pspa
::
simulate
()
{
bool
coherent
=
dataManager_
->
areDataCoherent
();
if
(
!
coherent
)
{
cout
<<
"simulate:: error during the check of data consistency
\n
"
;
return
false
;
}
dataManager_
->
initializeExecution
();
bool
status
=
dataManager_
->
executeAll
();
return
status
;
}
void
pspa
::
setnameOfCase
(
string
s
)
{
if
(
!
dataManager_
)
return
;
dataManager_
->
setnameOfCase
(
s
);
}
void
pspa
::
printCase
(
void
)
{
cout
<<
"nameOfCase is "
<<
nameOfCase_
<<
endl
;
}
void
pspa
::
printJson
(
const
char
*
obj
)
{
cout
<<
"json output is "
<<
string
(
obj
)
<<
'\n'
;
}
void
pspa
::
registerAllElements
()
{
componentFactory
::
enregistrer
(
new
elementBeam
()
);
componentFactory
::
enregistrer
(
new
elementBend
()
);
componentFactory
::
enregistrer
(
new
elementCathode
()
);
componentFactory
::
enregistrer
(
new
elementDrift
()
);
componentFactory
::
enregistrer
(
new
elementKicker
()
);
componentFactory
::
enregistrer
(
new
elementLinac
()
);
componentFactory
::
enregistrer
(
new
elementMarker
()
);
componentFactory
::
enregistrer
(
new
elementMpole
()
);
componentFactory
::
enregistrer
(
new
elementOpole
()
);
componentFactory
::
enregistrer
(
new
elementQpole
()
);
componentFactory
::
enregistrer
(
new
elementRfCavity
()
);
componentFactory
::
enregistrer
(
new
elementSolenoid
()
);
componentFactory
::
enregistrer
(
new
elementSpole
()
);
}
controller/cython-cpp/pspaclass.h
0 → 100644
View file @
58fd6992
#ifndef __CPPCODE_H__
#define __CPPCODE_H__
#include "dataManager.h"
class
pspa
{
void
registerAllElements
();
void
splitter
(
string
);
dataManager
*
dataManager_
;
string
nameOfCase_
;
string
typeOfFile_
;
public:
pspa
();
pspa
(
string
);
pspa
(
string
,
string
);
~
pspa
();
string
read
(
const
char
*
);
bool
simulate
();
bool
execute
(
string
);
void
setnameOfCase
(
string
);
void
printCase
(
void
);
void
printJson
(
const
char
*
);
};
#endif //__CPPCODE_H__
controller/cython-cpp/pspaclass.pxd
0 → 100644
View file @
58fd6992
from
libcpp
cimport
bool
from
libcpp.string
cimport
string
cdef
extern
from
"pspaclass.cpp"
:
pass
# Declare the class with cdef
cdef
extern
from
"pspaclass.h"
:
cdef
cppclass
pspa
:
pspa
()
except
+
pspa
(
string
)
except
+
pspa
(
string
,
string
)
except
+
string
read
(
const
char
*
);
bool
simulate
();
bool
execute
(
string
);
void
setnameOfCase
(
string
);
void
printJson
(
const
char
*
)
void
printCase
()
\ No newline at end of file
controller/cython-cpp/pypspaclass.cpp
0 → 100644
View file @
58fd6992
This diff is collapsed.
Click to expand it.
controller/cython-cpp/pypspaclass.pyx
0 → 100644
View file @
58fd6992
# distutils: language = c++
from
pspaclass
cimport
pspa
from
libcpp.string
cimport
string
cdef
class
PyPspaClass
:
cdef
pspa
*
c_rect
# Hold a C++ instance which we're wrapping
def
__cinit__
(
self
):
self
.
c_rect
=
new
pspa
()
def
__cinit__
(
self
,
string
s
)
:
self
.
c_rect
=
new
pspa
(
s
)
def
__cinit__
(
self
,
string
s1
,
string
s2
)
:
self
.
c_rect
=
new
pspa
(
s1
,
s2
)
def
__dealloc__
(
self
):
del
self
.
c_rect
def
read
(
self
,
const
char
*
file
):
return
self
.
c_rect
.
read
(
file
)
def
simulate
(
self
):
return
self
.
c_rect
.
simulate
()
def
execute
(
self
,
string
s
):
return
self
.
c_rect
.
execute
(
s
)
def
setnameOfCase
(
self
,
string
s
):
return
self
.
c_rect
.
setnameOfCase
(
s
)
def
printCase
(
self
):
return
self
.
c_rect
.
printCase
()
def
printJson
(
self
,
const
char
*
j
):
return
self
.
c_rect
.
printJson
(
j
)
controller/cython-cpp/setup.py
0 → 100644
View file @
58fd6992
from
distutils.core
import
setup
from
distutils.extension
import
Extension
from
Cython.Build
import
cythonize
xtension
=
Extension
(
name
=
"pypspaclass"
,
sources
=
[
"pypspaclass.pyx"
,
"/home/pspa/backend/pspa/v0/src/Core/dataManager.cpp"
],
libraries
=
[
"pspa"
,
"uap"
,
"antlr"
,
"xerces-c"
],
include_dirs
=
[
"/home/pspa/backend/pspa/v0/src/Core"
,
"/home/pspa/backend/pspa/v0/src/KindOfElements"
,
"/usr/local/accelerator-ml-code"
,
"/usr/local/json/include"
],
library_dirs
=
[
"/home/pspa/backend/pspa/v0/Linux-x86_64"
,
"/usr/local/accelerator-ml-code/lib"
,
"/usr/local/lib"
]
)
setup
(
name
=
"pypspaclass"
,
ext_modules
=
cythonize
([
xtension
])
)
controller/requirements.txt
0 → 100644
View file @
58fd6992
certifi==2018.4.16
chardet==3.0.4
click==6.7
Cython==0.28.3
Flask==1.0.2
Flask-Cors==3.0.4
idna==2.6
itsdangerous==0.24
Jinja2==2.10
MarkupSafe==1.0
requests==2.18.4
six==1.11.0
urllib3==1.22
Werkzeug==0.14.1
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment