Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nptool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
np
nptool
Commits
695a5517
Commit
695a5517
authored
7 years ago
by
Adrien Matta
Browse files
Options
Downloads
Patches
Plain Diff
* Addind missing file for Elog support
parent
176eb23e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
NPLib/Core/CMakeLists.txt
+1
-1
1 addition, 1 deletion
NPLib/Core/CMakeLists.txt
NPLib/Core/NPElog.cxx
+101
-0
101 additions, 0 deletions
NPLib/Core/NPElog.cxx
NPLib/Core/NPElog.h
+59
-0
59 additions, 0 deletions
NPLib/Core/NPElog.h
with
161 additions
and
1 deletion
NPLib/Core/CMakeLists.txt
+
1
−
1
View file @
695a5517
...
@@ -2,4 +2,4 @@ add_custom_command(OUTPUT TAsciiFileDict.cxx COMMAND ../scripts/build_dict.sh T
...
@@ -2,4 +2,4 @@ add_custom_command(OUTPUT TAsciiFileDict.cxx COMMAND ../scripts/build_dict.sh T
add_custom_command
(
OUTPUT NPVDetectorDict.cxx COMMAND ../scripts/build_dict.sh NPVDetector.h NPVDetectorDict.cxx NPVDetector.rootmap libNPCore.so NPCoreLinkdef.h
)
add_custom_command
(
OUTPUT NPVDetectorDict.cxx COMMAND ../scripts/build_dict.sh NPVDetector.h NPVDetectorDict.cxx NPVDetector.rootmap libNPCore.so NPCoreLinkdef.h
)
add_library
(
NPCore SHARED NPCore.cxx NPVAnalysis.cxx NPAnalysisFactory.cxx NPCalibrationManager.cxx NPOptionManager.cxx RootOutput.cxx RootInput.cxx TAsciiFile.cxx TAsciiFileDict.cxx NPDetectorManager.cxx NPVDetector.cxx NPVDetectorDict.cxx NPVSpectra.cxx NPDetectorFactory.cxx NPSpectraServer.cxx NPInputParser.cxx NPImage.cxx NPElog.cxx
)
add_library
(
NPCore SHARED NPCore.cxx NPVAnalysis.cxx NPAnalysisFactory.cxx NPCalibrationManager.cxx NPOptionManager.cxx RootOutput.cxx RootInput.cxx TAsciiFile.cxx TAsciiFileDict.cxx NPDetectorManager.cxx NPVDetector.cxx NPVDetectorDict.cxx NPVSpectra.cxx NPDetectorFactory.cxx NPSpectraServer.cxx NPInputParser.cxx NPImage.cxx NPElog.cxx
)
target_link_libraries
(
NPCore
${
ROOT_LIBRARIES
}
)
target_link_libraries
(
NPCore
${
ROOT_LIBRARIES
}
)
install
(
FILES NPCore.h NPVAnalysis.h NPAnalysisFactory.h NPCalibrationManager.h NPOptionManager.h RootInput.h RootOutput.h TAsciiFile.h NPDetectorManager.h NPVDetector.h NPGlobalSystemOfUnits.h NPPhysicalConstants.h NPSystemOfUnits.h NPVSpectra.h NPDetectorFactory.h NPSpectraServer.h NPInputParser.h NPImage.h DESTINATION
${
CMAKE_INCLUDE_OUTPUT_DIRECTORY
}
)
install
(
FILES NPCore.h NPVAnalysis.h NPAnalysisFactory.h NPCalibrationManager.h NPOptionManager.h RootInput.h RootOutput.h TAsciiFile.h NPDetectorManager.h NPVDetector.h NPGlobalSystemOfUnits.h NPPhysicalConstants.h NPSystemOfUnits.h NPVSpectra.h NPDetectorFactory.h NPSpectraServer.h NPInputParser.h NPImage.h
NPElog.h
DESTINATION
${
CMAKE_INCLUDE_OUTPUT_DIRECTORY
}
)
This diff is collapsed.
Click to expand it.
NPLib/Core/NPElog.cxx
0 → 100644
+
101
−
0
View file @
695a5517
/*****************************************************************************
* Copyright (C) 2009-2016 this file is part of the NPTool Project *
* *
* For the licensing terms see $NPTOOL/Licence/NPTool_Licence *
* For the list of contributors see $NPTOOL/Licence/Contributors *
*****************************************************************************/
/*****************************************************************************
* Original Author: Adrien Matta contact address: matta@lpccaen.in2p3.fr *
* *
* Creation Date : 9 May 2017 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class make an interface to the elog command line *
* The elog CLI must be installed on the system for this class to work *
* The interface is designed to help create elog entry from within nptool *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
#include
<iostream>
#include
"NPElog.h"
#include
"NPCore.h"
#include
"NPInputParser.h"
#include
"NPOptionManager.h"
////////////////////////////////////////////////////////////////////////////////
NPL
::
Elog
::
Elog
(){
}
////////////////////////////////////////////////////////////////////////////////
NPL
::
Elog
::~
Elog
(){
}
////////////////////////////////////////////////////////////////////////////////
void
NPL
::
Elog
::
ReadConfiguration
(
std
::
string
filename
){
int
verbose
=
NPOptionManager
::
getInstance
()
->
GetVerboseLevel
();
NPL
::
InputParser
parser
(
filename
);
std
::
vector
<
NPL
::
InputBlock
*>
block
=
parser
.
GetAllBlocksWithToken
(
"elog"
);
if
(
block
.
size
()
!=
1
){
NPL
::
SendWarning
(
"NPL::Elog"
,
"Elog configuration file has wrong formatting"
);
return
;
}
std
::
vector
<
std
::
string
>
token
=
{
"host"
,
"port"
,
"port"
,
"ssl"
,
"logbook"
,
"username"
,
"password"
};
if
(
!
block
[
0
]
->
HasTokenList
(
token
)){
NPL
::
SendWarning
(
"NPL::Elog"
,
"Elog configuration file has wrong formatting"
);
return
;
}
if
(
verbose
)
std
::
cout
<<
"//// Elog Configuration "
<<
std
::
endl
;
m_host
=
block
[
0
]
->
GetString
(
"host"
);
m_port
=
block
[
0
]
->
GetString
(
"port"
);
m_ssl
=
block
[
0
]
->
GetString
(
"ssl"
);
m_logbook
=
block
[
0
]
->
GetString
(
"logbook"
);
m_username
=
block
[
0
]
->
GetString
(
"username"
);
m_password
=
block
[
0
]
->
GetString
(
"password"
);
std
::
vector
<
NPL
::
InputBlock
*>
attributes
=
parser
.
GetAllBlocksWithToken
(
"attribute"
);
unsigned
int
size
=
attributes
.
size
();
for
(
unsigned
int
i
=
0
;
i
<
size
;
i
++
){
if
(
attributes
[
i
]
->
HasToken
(
"values"
))
m_AttributesValues
[
attributes
[
i
]
->
GetMainValue
()]
=
attributes
[
i
]
->
GetVectorString
(
"values"
);
}
}
////////////////////////////////////////////////////////////////////////////////
bool
NPL
::
Elog
::
CheckServer
(){
// to be done
return
true
;
}
////////////////////////////////////////////////////////////////////////////////
bool
NPL
::
Elog
::
CheckEntry
(
std
::
vector
<
std
::
string
>&
attributes
,
std
::
vector
<
std
::
string
>&
val
){
return
true
;
}
////////////////////////////////////////////////////////////////////////////////
bool
NPL
::
Elog
::
CreateEntry
(
std
::
vector
<
std
::
string
>&
attributes
,
std
::
vector
<
std
::
string
>&
val
,
std
::
string
message
,
std
::
vector
<
std
::
string
>
attachement
){
if
(
CheckEntry
(
attributes
,
val
)){
std
::
string
cmd
=
"elog -h "
+
m_host
+
" -p "
+
m_port
+
" -s "
+
m_ssl
;
cmd
+=
" -u "
+
m_username
+
" "
+
m_password
;
cmd
+=
" -l "
+
m_logbook
;
unsigned
int
size
=
attributes
.
size
();
for
(
unsigned
int
i
=
0
;
i
<
size
;
i
++
)
cmd
+=
" -a "
+
attributes
[
i
]
+
"="
+
val
[
i
];
cmd
+=
"
\"
"
+
message
+
"
\"
"
;
size
=
attachement
.
size
();
for
(
unsigned
int
i
=
0
;
i
<
size
;
i
++
){
cmd
+=
" -f "
+
attachement
[
i
];
}
int
code
=
system
(
cmd
.
c_str
());
}
return
true
;
}
This diff is collapsed.
Click to expand it.
NPLib/Core/NPElog.h
0 → 100644
+
59
−
0
View file @
695a5517
#ifndef NPELOG_H
#define NPELOG_H
/*****************************************************************************
* Copyright (C) 2009-2016 this file is part of the NPTool Project *
* *
* For the licensing terms see $NPTOOL/Licence/NPTool_Licence *
* For the list of contributors see $NPTOOL/Licence/Contributors *
*****************************************************************************/
/*****************************************************************************
* Original Author: Adrien Matta contact address: matta@lpccaen.in2p3.fr *
* *
* Creation Date : 9 May 2017 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class make an interface to the elog command line *
* The elog CLI must be installed on the system for this class to work *
* The interface is designed to help create elog entry from within nptool *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
#include
<string>
#include
<vector>
#include
<map>
namespace
NPL
{
class
Elog
{
public:
Elog
();
~
Elog
();
public:
// Read the elog configuration file in nptool format
void
ReadConfiguration
(
std
::
string
filename
);
// check if the server is reachable
bool
CheckServer
();
// Check the submitted entry match the required grammar (all attribute filled correctly)
bool
CheckEntry
(
std
::
vector
<
std
::
string
>&
attributes
,
std
::
vector
<
std
::
string
>&
val
);
// Submit the entry
bool
CreateEntry
(
std
::
vector
<
std
::
string
>&
attributes
,
std
::
vector
<
std
::
string
>&
val
,
std
::
string
message
,
std
::
vector
<
std
::
string
>
attachement
=
std
::
vector
<
std
::
string
>
());
private:
// Login configuration
std
::
string
m_host
;
std
::
string
m_port
;
std
::
string
m_ssl
;
std
::
string
m_logbook
;
std
::
string
m_username
;
std
::
string
m_password
;
private:
// attribute and their possible values
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>
>
m_AttributesValues
;
public:
// Accessort to the define attributes and their default value
inline
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>
>
GetAttributesValues
()
{
return
m_AttributesValues
;};
};
}
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment