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
b358e9a4
Commit
b358e9a4
authored
5 years ago
by
Nadeem Shehzad
Browse files
Options
Downloads
Patches
Plain Diff
moved testProcessVariableRecovery to separate soruce file.
parent
2183d162
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/executables_src/testDeviceInitialisationHandler.cc
+0
-121
0 additions, 121 deletions
tests/executables_src/testDeviceInitialisationHandler.cc
with
0 additions
and
121 deletions
tests/executables_src/testDeviceInitialisationHandler.cc
+
0
−
121
View file @
b358e9a4
...
...
@@ -16,8 +16,6 @@
#include
<stdlib.h>
#include
"check_timeout.h"
#include
"ApplicationModule.h"
#include
"ArrayAccessor.h"
using
namespace
boost
::
unit_test_framework
;
namespace
ctk
=
ChimeraTK
;
...
...
@@ -43,28 +41,6 @@ void initialiseReg3(ctk::DeviceModule* dev) {
dev
->
device
.
write
<
int32_t
>
(
"/REG3"
,
dev
->
device
.
read
<
int32_t
>
(
"/REG2"
)
+
5
);
}
struct
TestModule
:
public
ctk
::
ApplicationModule
{
using
ctk
::
ApplicationModule
::
ApplicationModule
;
ctk
::
ScalarPushInput
<
int32_t
>
trigger
{
this
,
"trigger"
,
""
,
"This is my trigger."
};
ctk
::
ScalarOutput
<
int32_t
>
scalarOutput
{
this
,
"scalarOutput"
,
""
,
"Here I write a scaler"
};
ctk
::
ArrayOutput
<
int32_t
>
arrayOutput
{
this
,
"arrayOutput"
,
""
,
4
,
"Here I write an array"
};
void
mainLoop
()
override
{
while
(
true
)
{
trigger
.
read
();
scalarOutput
=
int32_t
(
trigger
);
scalarOutput
.
write
();
for
(
uint
i
=
0
;
i
<
4
;
i
++
){
arrayOutput
[
i
]
=
int32_t
(
trigger
);
}
arrayOutput
.
write
();
}
}
};
/* dummy application */
struct
TestApplication
:
public
ctk
::
Application
{
TestApplication
()
:
Application
(
"testSuite"
)
{}
...
...
@@ -73,107 +49,10 @@ struct TestApplication : public ctk::Application {
void
defineConnections
()
{}
// the setup is done in the tests
ctk
::
ControlSystemModule
cs
;
ctk
::
DeviceModule
dev
{
this
,
deviceCDD
,
&
initialiseReg1
};
TestModule
applicationModule
{
this
,
"testModule"
,
"The test module"
};
};
/*********************************************************************************************************************/
BOOST_AUTO_TEST_CASE
(
testProcessVariableRecovery
)
{
std
::
cout
<<
"testProcessVariableRecovery"
<<
std
::
endl
;
TestApplication
app
;
app
.
dev
.
connectTo
(
app
.
cs
);
app
.
applicationModule
.
connectTo
(
app
.
cs
);
//Connect PVs directly to device
app
.
cs
(
"scalarOutput"
)
>>
app
.
dev
(
"/REG1"
);
app
.
cs
(
"arrayOutput"
)
>>
app
.
dev
(
"/AREA1"
);
ctk
::
TestFacility
test
;
test
.
runApplication
();
//app.dumpConnections();
//Check default hardware values.
ctk
::
Device
dummy
;
dummy
.
open
(
deviceCDD
);
auto
reg1
=
dummy
.
getScalarRegisterAccessor
<
int32_t
>
(
"/REG1"
);
reg1
.
readLatest
();
BOOST_CHECK_EQUAL
(
reg1
,
42
);
auto
area1
=
dummy
.
getOneDRegisterAccessor
<
int32_t
>
(
"/AREA1"
);
area1
.
readLatest
();
for
(
auto
values
:
area1
)
{
BOOST_CHECK_EQUAL
(
values
,
0
);
}
//Initialized device registers through process variable.
auto
trigger
=
test
.
getScalar
<
int32_t
>
(
"/trigger"
);
trigger
=
100
;
trigger
.
write
();
test
.
stepApplication
();
//Add some zzz to make sure that changes propagate.
usleep
(
1000000
);
//Verify that the device registers are updated.
reg1
.
readLatest
();
BOOST_CHECK_EQUAL
(
reg1
,
100
);
area1
.
readLatest
();
for
(
auto
values
:
area1
)
{
BOOST_CHECK_EQUAL
(
values
,
100
);
}
auto
dummyBackend
=
boost
::
dynamic_pointer_cast
<
ExceptionDummy
>
(
ctk
::
BackendFactory
::
getInstance
().
createBackend
(
deviceCDD
));
//Device should be functional.
BOOST_CHECK_EQUAL
(
dummyBackend
->
isFunctional
(),
1
);
//Set the device to throw.
dummyBackend
->
throwExceptionWrite
=
true
;
dummyBackend
->
throwExceptionOpen
=
true
;
//Add some zzz to make sure condition is set.
usleep
(
1000000
);
//Verify device is in not functional anymore.
BOOST_CHECK_EQUAL
(
dummyBackend
->
isFunctional
(),
0
);
//Set write exception to false so that device registers can be set to 0.
dummyBackend
->
throwExceptionWrite
=
false
;
//Set dummy registers to 0.
app
.
dev
.
device
.
write
<
int32_t
>
(
"/REG1"
,
0
);
std
::
vector
<
int32_t
>
array
=
{
0
,
0
,
0
,
0
};
app
.
dev
.
device
.
write
<
int32_t
>
(
"/AREA1"
,
array
);
//Add some zzz for wait.
usleep
(
1000000
);
//Verify that the device registers are updated.
reg1
.
readLatest
();
BOOST_CHECK_EQUAL
(
reg1
,
0
);
area1
.
readLatest
();
for
(
auto
values
:
area1
)
{
BOOST_CHECK_EQUAL
(
values
,
0
);
}
//Set device back to normal.
dummyBackend
->
throwExceptionOpen
=
false
;
//Let's wait for some time to make sure device is ready.
usleep
(
1000000
);
//Verify if the device is ready.
BOOST_CHECK_EQUAL
(
dummyBackend
->
isFunctional
(),
1
);
//DeviceModule should have the correct values now.
reg1
.
readLatest
();
BOOST_CHECK_EQUAL
(
reg1
,
100
);
area1
.
readLatest
();
for
(
auto
values
:
area1
)
{
BOOST_CHECK_EQUAL
(
values
,
100
);
}
}
BOOST_AUTO_TEST_CASE
(
testBasicInitialisation
)
{
std
::
cout
<<
"testBasicInitialisation"
<<
std
::
endl
;
TestApplication
app
;
...
...
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