Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
labRemote
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
scipp
labRemote
Commits
2dc2492a
Commit
2dc2492a
authored
5 years ago
by
Karol Krizka
Browse files
Options
Downloads
Patches
Plain Diff
Remove EquipConf::autoconfigure.
parent
3dccc449
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/libEquipConf/EquipConf.cpp
+2
-107
2 additions, 107 deletions
src/libEquipConf/EquipConf.cpp
src/libEquipConf/EquipConf.h
+2
-13
2 additions, 13 deletions
src/libEquipConf/EquipConf.h
src/libEquipConf/input-hw.json
+0
-1
0 additions, 1 deletion
src/libEquipConf/input-hw.json
with
4 additions
and
121 deletions
src/libEquipConf/EquipConf.cpp
+
2
−
107
View file @
2dc2492a
...
...
@@ -29,21 +29,17 @@ EquipConf::EquipConf(const json& hardwareConfig)
setHardwareConfig
(
hardwareConfig
);
}
bool
EquipConf
::
setHardwareConfig
(
const
std
::
string
&
hardwareConfigFile
)
void
EquipConf
::
setHardwareConfig
(
const
std
::
string
&
hardwareConfigFile
)
{
//load JSON object from file
std
::
ifstream
i
(
hardwareConfigFile
);
i
>>
m_hardwareConfig
;
//determine missing parameters, if any and requested
return
autoConfigure
();
}
bool
EquipConf
::
setHardwareConfig
(
const
json
&
hardwareConfig
)
void
EquipConf
::
setHardwareConfig
(
const
json
&
hardwareConfig
)
{
//store JSON config file
m_hardwareConfig
=
hardwareConfig
;
//determine missing parameters, if any and requested
return
autoConfigure
();
}
json
EquipConf
::
getDeviceConf
(
const
std
::
string
&
label
)
...
...
@@ -68,112 +64,11 @@ json EquipConf::getChannelConf(const std::string& label)
// General private
////////////////////
bool
EquipConf
::
autoConfigure
()
{
//check for missing configuration
//
// version field required
if
(
not
m_hardwareConfig
.
contains
(
"version"
))
{
std
::
cerr
<<
"mandatory field 'version' missing from input configuration."
<<
std
::
endl
;
return
false
;
}
// check and store if autoconfiguration is enabled
bool
autoconfigure
(
false
);
if
(
m_hardwareConfig
.
contains
(
"options"
))
{
if
(
m_hardwareConfig
[
"options"
].
contains
(
"autoconfigure"
))
{
autoconfigure
=
m_hardwareConfig
[
"options"
][
"autoconfigure"
];
}
}
m_hardwareConfig
[
"options"
][
"autoconfigure"
]
=
autoconfigure
;
//
// Extract devices
//
// check hardware section exists
if
(
not
m_hardwareConfig
.
contains
(
"devices"
))
{
std
::
cerr
<<
"mandatory field 'hardware' missing from input configuration."
<<
std
::
endl
;
return
false
;
}
// check mandatory device properties and transform if needed
for
(
auto
&
hw
:
m_hardwareConfig
[
"devices"
].
items
())
{
//check hw type
if
(
not
hw
.
value
().
contains
(
"hw-type"
))
{
std
::
cerr
<<
"Missing required hardware type for: "
<<
hw
.
key
()
<<
". Ignoring"
<<
std
::
endl
;
continue
;
}
std
::
string
tmp_toLower
=
hw
.
value
()[
"hw-type"
];
std
::
transform
(
tmp_toLower
.
begin
(),
tmp_toLower
.
end
(),
tmp_toLower
.
begin
(),
::
tolower
);
hw
.
value
()[
"tw-type"
]
=
tmp_toLower
;
}
// loop over hardware and auto-configure it, if requested
//
bool
anyFailure
=
false
;
if
(
m_hardwareConfig
[
"options"
][
"autoconfigure"
])
{
for
(
auto
&
hw
:
m_hardwareConfig
[
"devices"
])
{
if
(
hw
[
"hw-type"
]
==
"ps"
)
{
//call specific PS auto-configuration
anyFailure
=
anyFailure
or
autoConfigurePS
(
hw
);
}
else
{
anyFailure
=
true
;
std
::
cerr
<<
"Unrecognized device type ("
<<
hw
[
"hw-type"
]
<<
") for device: "
<<
hw
[
"label"
]
<<
std
::
endl
;
continue
;
}
if
(
anyFailure
)
continue
;
}
}
// autoconfiguration
//
// Extract channels
//
if
(
m_hardwareConfig
.
contains
(
"channels"
))
{
// check channels section exists
// check mandatory device properties and transform if needed
for
(
auto
&
ch
:
m_hardwareConfig
[
"channels"
].
items
())
{
//check hw-type
if
(
not
ch
.
value
().
contains
(
"hw-type"
))
{
std
::
cerr
<<
"Missing required hw-type for: "
<<
ch
.
key
()
<<
". Ignoring"
<<
std
::
endl
;
continue
;
}
//check power-supply
if
(
not
ch
.
value
().
contains
(
"device"
))
{
std
::
cerr
<<
"Missing required device for: "
<<
ch
.
key
()
<<
". Ignoring"
<<
std
::
endl
;
continue
;
}
//check channel
if
(
not
ch
.
value
().
contains
(
"channel"
))
{
std
::
cerr
<<
"Missing required channel for: "
<<
ch
.
key
()
<<
". Ignoring"
<<
std
::
endl
;
continue
;
}
}
}
return
(
not
anyFailure
);
}
////////////////////
// Power-Supply
////////////////////
bool
EquipConf
::
autoConfigurePS
(
json
device
)
{
//if port is missing, scan usb first
//... @TODO: device discovery
std
::
cerr
<<
"Autoconfiguration of PowerSupply requested. Not yet implemented."
<<
std
::
endl
;
return
false
;
}
std
::
shared_ptr
<
IPowerSupply
>
EquipConf
::
getPowerSupply
(
const
std
::
string
&
name
)
{
//first check if an object with the same name/type is already available (was already instantiated)
...
...
This diff is collapsed.
Click to expand it.
src/libEquipConf/EquipConf.h
+
2
−
13
View file @
2dc2492a
...
...
@@ -40,12 +40,12 @@ public:
/** Set input hardware list file
* @param hardwareConfigFile input JSON file with list of hardware resrouces and options
*/
bool
setHardwareConfig
(
const
std
::
string
&
hardwareConfigFile
);
void
setHardwareConfig
(
const
std
::
string
&
hardwareConfigFile
);
/** Set input hardware list file
* @param hardwareConfig input JSON object with list of hardware resrouces and options
*/
bool
setHardwareConfig
(
const
json
&
hardwareConfig
);
void
setHardwareConfig
(
const
json
&
hardwareConfig
);
/** Get device JSON configuration
@param label device name
...
...
@@ -98,17 +98,6 @@ private:
/// Stored handles of PowerSupplyChannel pointers created
std
::
unordered_map
<
std
::
string
,
std
::
shared_ptr
<
PowerSupplyChannel
>>
m_listPowerSupplyChannel
;
/** Determine missing configuration of connected hardware, if possible.
Can as well perform some minimal validation of the input.
@return true if successful
*/
bool
autoConfigure
();
/** Auto-configuration for Power Supplies
* @param hw JSON hardware configuration for this device
*/
bool
autoConfigurePS
(
json
device
);
};
#endif
This diff is collapsed.
Click to expand it.
src/libEquipConf/input-hw.json
+
0
−
1
View file @
2dc2492a
...
...
@@ -2,7 +2,6 @@
"version"
:
"1.0"
,
"options"
:
{
"autoconfigure"
:
false
},
"devices"
:
{
...
...
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