Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OPOSSUM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
phelix
rust
OPOSSUM
Commits
bfa75023
Commit
bfa75023
authored
1 year ago
by
Udo Eisenbarth
Browse files
Options
Downloads
Patches
Plain Diff
Add "name" property to spectrometer
code cleanup
parent
13268718
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#7710
passed
1 year ago
Stage: test
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main.rs
+3
-7
3 additions, 7 deletions
src/main.rs
src/nodes/spectrometer.rs
+17
-2
17 additions, 2 deletions
src/nodes/spectrometer.rs
src/optical.rs
+3
-3
3 additions, 3 deletions
src/optical.rs
with
23 additions
and
12 deletions
src/main.rs
+
3
−
7
View file @
bfa75023
...
...
@@ -24,11 +24,7 @@ fn main() {
fn
read_and_parse_model
(
path
:
&
Path
)
->
Result
<
OpticScenery
>
{
print!
(
"
\n
Reading model..."
);
let
contents
=
fs
::
read_to_string
(
path
)
.map_err
(|
e
|
{
OpossumError
::
Console
(
format!
(
"cannot read file {} : {}"
,
path
.display
(),
e
))
OpossumError
::
Console
(
format!
(
"cannot read file {} : {}"
,
path
.display
(),
e
))
})
?
;
let
scenery
:
OpticScenery
=
serde_json
::
from_str
(
&
contents
)
.map_err
(|
e
|
{
OpossumError
::
OpticScenery
(
format!
(
"error while parsing model file: {}"
,
e
))
...
...
@@ -39,8 +35,8 @@ fn read_and_parse_model(path: &Path) -> Result<OpticScenery> {
fn
do_it
()
->
Result
<
()
>
{
let
opossum_args
=
Args
::
try_from
(
PartialArgs
::
parse
())
?
;
let
mut
scenery
=
read_and_parse_model
(
&
opossum_args
.file_path
)
?
;
let
mut
scenery
=
read_and_parse_model
(
&
opossum_args
.file_path
)
?
;
let
mut
dot_path
=
opossum_args
.report_directory
.clone
();
dot_path
.push
(
opossum_args
.file_path
.file_stem
()
.unwrap
());
dot_path
.set_extension
(
"dot"
);
...
...
This diff is collapsed.
Click to expand it.
src/nodes/spectrometer.rs
+
17
−
2
View file @
bfa75023
...
...
@@ -27,7 +27,6 @@ pub enum SpectrometerType {
/// Ocean Optics HR2000
HR2000
,
}
#[derive(Default)]
/// (ideal) spectrometer
///
/// It normally measures / displays the spectrum of the incoming light.
...
...
@@ -45,13 +44,29 @@ pub struct Spectrometer {
spectrometer_type
:
SpectrometerType
,
props
:
Properties
,
}
fn
create_default_props
()
->
Properties
{
let
mut
props
=
Properties
::
default
();
props
.set
(
"name"
,
"spectrometer"
.into
());
props
}
impl
Default
for
Spectrometer
{
fn
default
()
->
Self
{
Self
{
light_data
:
Default
::
default
(),
spectrometer_type
:
Default
::
default
(),
props
:
create_default_props
(),
}
}
}
impl
Spectrometer
{
/// Creates a new [`Spectrometer`] of the given [`SpectrometerType`].
pub
fn
new
(
spectrometer_type
:
SpectrometerType
)
->
Self
{
Spectrometer
{
light_data
:
None
,
spectrometer_type
,
props
:
Properties
::
default
(),
props
:
create_
default
_props
(),
}
}
/// Returns the meter type of this [`Spectrometer`].
...
...
This diff is collapsed.
Click to expand it.
src/optical.rs
+
3
−
3
View file @
bfa75023
...
...
@@ -67,11 +67,11 @@ pub trait Optical: Dottable {
Err
(
OpossumError
::
Other
(
"cannot cast to group"
.into
()))
}
/// Return the properties of this [`Optical`].
///
///
/// Return all properties of an optical node. Note, that some properties might be read-only.
fn
properties
(
&
self
)
->
&
Properties
;
/// Set a property of this [`Optical`].
///
///
/// Set a property of an optical node. This property must already exist (e.g. defined in new() / default() functions of the node).
///
/// # Errors
...
...
@@ -89,7 +89,7 @@ pub trait Optical: Dottable {
Ok
(())
}
/// Return a JSON representation of the current state of this [`Optical`].
///
///
/// This function must be overridden for generating output in the analysis report. Mainly detector nodes use this feature.
/// The default implementation is to return a JSON `null` value.
fn
report
(
&
self
)
->
serde_json
::
Value
{
...
...
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