Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ApplicationCore
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
Container Registry
Model registry
Operate
Environments
Terraform modules
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
ChimeraTK Mirror
ApplicationCore
Commits
ecffe22e
Commit
ecffe22e
authored
1 year ago
by
Martin Christoph Hierholzer
Browse files
Options
Downloads
Patches
Plain Diff
fix: setAndWrite() used wrong VersionNumber
parent
118a6b72
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/ArrayAccessor.h
+12
-2
12 additions, 2 deletions
include/ArrayAccessor.h
include/ScalarAccessor.h
+12
-2
12 additions, 2 deletions
include/ScalarAccessor.h
tests/executables_src/testVersionPropagation.cc
+73
-0
73 additions, 0 deletions
tests/executables_src/testVersionPropagation.cc
with
97 additions
and
4 deletions
include/ArrayAccessor.h
+
12
−
2
View file @
ecffe22e
...
...
@@ -39,6 +39,7 @@ namespace ChimeraTK {
bool
writeDestructively
(
ChimeraTK
::
VersionNumber
versionNumber
)
=
delete
;
void
writeIfDifferent
(
const
std
::
vector
<
UserType
>&
newValue
,
VersionNumber
versionNumber
,
DataValidity
validity
)
=
delete
;
void
setAndWrite
(
const
std
::
vector
<
UserType
>&
newValue
,
VersionNumber
versionNumber
)
=
delete
;
bool
write
();
...
...
@@ -46,6 +47,8 @@ namespace ChimeraTK {
void
writeIfDifferent
(
const
std
::
vector
<
UserType
>&
newValue
);
void
setAndWrite
(
const
std
::
vector
<
UserType
>&
newValue
);
protected:
friend
class
InversionOfControlAccessor
<
ArrayAccessor
<
UserType
>>
;
...
...
@@ -175,13 +178,20 @@ namespace ChimeraTK {
if
(
!
std
::
equal
(
newValue
.
begin
(),
newValue
.
end
(),
this
->
get
()
->
accessChannel
(
0
).
begin
())
||
this
->
getVersionNumber
()
==
VersionNumber
(
nullptr
)
||
targetMetaDataPropagatingDecorator
->
getTargetValidity
()
!=
this
->
getOwner
()
->
getDataValidity
())
{
operator
=
(
newValue
);
this
->
write
();
setAndWrite
(
newValue
);
}
}
/********************************************************************************************************************/
template
<
typename
UserType
>
void
ArrayAccessor
<
UserType
>::
setAndWrite
(
const
std
::
vector
<
UserType
>&
newValue
)
{
operator
=
(
newValue
);
this
->
write
();
}
/********************************************************************************************************************/
template
<
typename
UserType
>
ArrayAccessor
<
UserType
>::
ArrayAccessor
(
Module
*
owner
,
const
std
::
string
&
name
,
VariableDirection
direction
,
std
::
string
unit
,
size_t
nElements
,
UpdateMode
mode
,
const
std
::
string
&
description
,
...
...
This diff is collapsed.
Click to expand it.
include/ScalarAccessor.h
+
12
−
2
View file @
ecffe22e
...
...
@@ -39,6 +39,7 @@ namespace ChimeraTK {
bool
write
(
ChimeraTK
::
VersionNumber
versionNumber
)
=
delete
;
bool
writeDestructively
(
ChimeraTK
::
VersionNumber
versionNumber
)
=
delete
;
void
writeIfDifferent
(
UserType
newValue
,
VersionNumber
versionNumber
,
DataValidity
validity
)
=
delete
;
void
setAndWrite
(
UserType
newValue
,
VersionNumber
versionNumber
)
=
delete
;
bool
write
();
...
...
@@ -46,6 +47,8 @@ namespace ChimeraTK {
void
writeIfDifferent
(
UserType
newValue
);
void
setAndWrite
(
UserType
newValue
);
protected:
friend
class
InversionOfControlAccessor
<
ScalarAccessor
<
UserType
>>
;
...
...
@@ -172,13 +175,20 @@ namespace ChimeraTK {
// corresponds to the last written data validity for this PV.
if
(
this
->
get
()
->
accessData
(
0
,
0
)
!=
newValue
||
this
->
getVersionNumber
()
==
VersionNumber
(
nullptr
)
||
targetMetaDataPropagatingDecorator
->
getTargetValidity
()
!=
this
->
getOwner
()
->
getDataValidity
())
{
operator
=
(
newValue
);
this
->
write
();
setAndWrite
(
newValue
);
}
}
/********************************************************************************************************************/
template
<
typename
UserType
>
void
ScalarAccessor
<
UserType
>::
setAndWrite
(
UserType
newValue
)
{
operator
=
(
newValue
);
this
->
write
();
}
/********************************************************************************************************************/
template
<
typename
UserType
>
ScalarAccessor
<
UserType
>::
ScalarAccessor
(
Module
*
owner
,
const
std
::
string
&
name
,
VariableDirection
direction
,
std
::
string
unit
,
UpdateMode
mode
,
const
std
::
string
&
description
,
const
std
::
unordered_set
<
std
::
string
>&
tags
)
...
...
This diff is collapsed.
Click to expand it.
tests/executables_src/testVersionPropagation.cc
+
73
−
0
View file @
ecffe22e
...
...
@@ -125,6 +125,79 @@ BOOST_AUTO_TEST_CASE(versionPropagation_testPushTypeReadLatest) {
BOOST_CHECK
(
application
.
group1
.
pushModule
.
getCurrentVersionNumber
()
==
moduleVersion
);
}
BOOST_AUTO_TEST_SUITE_END
()
/*********************************************************************************************************************/
/*********************************************************************************************************************/
BOOST_AUTO_TEST_SUITE
()
struct
ThePushModule
:
ChimeraTK
::
ApplicationModule
{
using
ChimeraTK
::
ApplicationModule
::
ApplicationModule
;
ChimeraTK
::
ScalarPushInput
<
int
>
pushInput
{
this
,
"/theVariable"
,
""
,
""
};
std
::
promise
<
void
>
p
;
void
mainLoop
()
override
{
p
.
set_value
();
}
};
struct
TheOutputModule
:
ChimeraTK
::
ApplicationModule
{
using
ChimeraTK
::
ApplicationModule
::
ApplicationModule
;
ChimeraTK
::
ScalarOutput
<
int
>
output
{
this
,
"/theVariable"
,
""
,
""
};
void
prepare
()
{
output
.
write
();
}
std
::
promise
<
void
>
p
;
void
mainLoop
()
override
{
p
.
set_value
();
}
};
struct
TheTestApplication
:
ChimeraTK
::
Application
{
using
ChimeraTK
::
Application
::
Application
;
~
TheTestApplication
()
override
{
shutdown
();
}
ThePushModule
pm
{
this
,
"pm"
,
""
};
TheOutputModule
om
{
this
,
"om"
,
""
};
};
/*********************************************************************************************************************/
BOOST_AUTO_TEST_CASE
(
versionPropagation_testSetAndWrite
)
{
std
::
cout
<<
"versionPropagation_testSetAndWrite"
<<
std
::
endl
;
TheTestApplication
app
(
"app"
);
ChimeraTK
::
TestFacility
test
(
app
,
false
);
test
.
runApplication
();
app
.
pm
.
p
.
get_future
().
wait
();
app
.
om
.
p
.
get_future
().
wait
();
ChimeraTK
::
VersionNumber
theVersion
;
app
.
om
.
setCurrentVersionNumber
(
theVersion
);
app
.
om
.
output
.
setAndWrite
(
42
);
app
.
pm
.
pushInput
.
read
();
BOOST_CHECK
(
app
.
pm
.
getCurrentVersionNumber
()
==
theVersion
);
}
/*********************************************************************************************************************/
BOOST_AUTO_TEST_CASE
(
versionPropagation_testWriteIfDifferent
)
{
std
::
cout
<<
"versionPropagation_testWriteIfDifferent"
<<
std
::
endl
;
TheTestApplication
app
(
"app"
);
ChimeraTK
::
TestFacility
test
(
app
,
false
);
test
.
runApplication
();
app
.
pm
.
p
.
get_future
().
wait
();
app
.
om
.
p
.
get_future
().
wait
();
ChimeraTK
::
VersionNumber
theVersion
;
app
.
om
.
setCurrentVersionNumber
(
theVersion
);
app
.
om
.
output
.
writeIfDifferent
(
42
);
app
.
pm
.
pushInput
.
read
();
BOOST_CHECK
(
app
.
pm
.
getCurrentVersionNumber
()
==
theVersion
);
}
/*********************************************************************************************************************/
BOOST_AUTO_TEST_SUITE_END
()
...
...
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