Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CryoCooler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Software Control System
Tango devices
Temperature
CryoCooler
Commits
af7efbc3
Commit
af7efbc3
authored
Apr 8, 2019
by
Sonia Minolli
Browse files
Options
Downloads
Patches
Plain Diff
Add mutex for communication data protection (TANGODEVIC-1965)
parent
a6b4cd2e
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
pom.xml
+1
-0
1 addition, 0 deletions
pom.xml
src/CryoCoolerInterface.cpp
+33
-21
33 additions, 21 deletions
src/CryoCoolerInterface.cpp
src/CryoCoolerInterface.h
+26
-24
26 additions, 24 deletions
src/CryoCoolerInterface.h
with
60 additions
and
45 deletions
pom.xml
+
1
−
0
View file @
af7efbc3
...
...
@@ -45,6 +45,7 @@
<dependency>
<groupId>
fr.soleil.lib
</groupId>
<artifactId>
PLCServerProxy-${aol}-${library}-${mode}
</artifactId>
<version>
3.1.1-SNAPSHOT
</version>
</dependency>
</dependencies>
<scm>
...
...
This diff is collapsed.
Click to expand it.
src/CryoCoolerInterface.cpp
+
33
−
21
View file @
af7efbc3
...
...
@@ -209,17 +209,7 @@ namespace CryoCooler_ns
{
//DEBUG_STREAM << "CryoCoolerInterface::process_message handling TASK_PERIODIC msg" << std::endl;
//- code relative to the task's periodic job goes here
this
->
com_error
=
hwp
->
get_com_error
();
this
->
com_success
=
hwp
->
get_com_success
();
this
->
com_error
+=
hwp_wr
->
get_com_error
();
this
->
com_success
+=
hwp_wr
->
get_com_success
();
//- comm state/status
this
->
com_status
=
hwp_wr
->
get_com_status
();
this
->
com_state
=
hwp_wr
->
get_com_state
();
//- last error
this
->
last_error
=
hwp_wr
->
get_last_error
();
this
->
periodic_job_i
();
}
break
;
...
...
@@ -270,6 +260,7 @@ namespace CryoCooler_ns
}
catch
(...)
{
yat
::
AutoMutex
<
yat
::
Mutex
>
guard
(
this
->
m_com_lock
);
this
->
com_status
=
hwp_wr
->
get_com_status
();
this
->
com_state
=
hwp_wr
->
get_com_state
();
this
->
last_error
=
hwp_wr
->
get_last_error
();
...
...
@@ -314,6 +305,7 @@ namespace CryoCooler_ns
}
catch
(...)
{
yat
::
AutoMutex
<
yat
::
Mutex
>
guard
(
this
->
m_com_lock
);
this
->
com_status
=
hwp_wr
->
get_com_status
();
this
->
com_state
=
hwp_wr
->
get_com_state
();
this
->
last_error
=
hwp_wr
->
get_last_error
();
...
...
@@ -349,6 +341,7 @@ namespace CryoCooler_ns
}
catch
(...)
{
yat
::
AutoMutex
<
yat
::
Mutex
>
guard
(
this
->
m_com_lock
);
this
->
com_status
=
hwp_wr
->
get_com_status
();
this
->
com_state
=
hwp_wr
->
get_com_state
();
this
->
last_error
=
hwp_wr
->
get_last_error
();
...
...
@@ -381,6 +374,7 @@ namespace CryoCooler_ns
}
catch
(...)
{
yat
::
AutoMutex
<
yat
::
Mutex
>
guard
(
this
->
m_com_lock
);
this
->
com_status
=
hwp_wr
->
get_com_status
();
this
->
com_state
=
hwp_wr
->
get_com_state
();
this
->
last_error
=
hwp_wr
->
get_last_error
();
...
...
@@ -412,6 +406,7 @@ namespace CryoCooler_ns
}
catch
(...)
{
yat
::
AutoMutex
<
yat
::
Mutex
>
guard
(
this
->
m_com_lock
);
this
->
com_status
=
hwp_wr
->
get_com_status
();
this
->
com_state
=
hwp_wr
->
get_com_state
();
this
->
last_error
=
hwp_wr
->
get_last_error
();
...
...
@@ -443,19 +438,21 @@ namespace CryoCooler_ns
if
(
byte_offset
>
max_offset
)
{
yat
::
AutoMutex
<
yat
::
Mutex
>
guard
(
this
->
m_com_lock
);
this
->
com_state
=
HWProxy_ns
::
HWP_SOFTWARE_ERROR
;
this
->
com_status
=
"HWP_SOFTWARE_ERROR"
;
std
::
stringstream
s
;
s
<<
"CryoCoolerInterface::get_real Offset out of range trying to read a REAL "
<<
" at offset "
<<
byte_offset
<<
std
::
endl
;
this
->
last_error
=
s
.
str
();
Tango
::
Except
::
throw_exception
(
static_cast
<
const
char
*>
(
"OUT_OF_RANGE"
),
static_cast
<
const
char
*>
(
s
.
str
().
c_str
()),
static_cast
<
const
char
*>
(
"CryoCoolerInterface::get_real"
));
_CPTC
(
"OUT_OF_RANGE"
),
_CPTC
(
s
.
str
().
c_str
()),
_CPTC
(
"CryoCoolerInterface::get_real"
));
}
if
(
!
hwp
)
{
yat
::
AutoMutex
<
yat
::
Mutex
>
guard
(
this
->
m_com_lock
);
this
->
com_state
=
HWProxy_ns
::
HWP_SOFTWARE_ERROR
;
this
->
com_status
=
"HWP_SOFTWARE_ERROR"
;
std
::
stringstream
s
;
...
...
@@ -473,6 +470,7 @@ namespace CryoCooler_ns
}
catch
(...)
{
yat
::
AutoMutex
<
yat
::
Mutex
>
guard
(
this
->
m_com_lock
);
this
->
com_state
=
HWProxy_ns
::
HWP_SOFTWARE_ERROR
;
this
->
com_status
=
"HWP_SOFTWARE_ERROR"
;
std
::
stringstream
s
;
...
...
@@ -503,19 +501,21 @@ namespace CryoCooler_ns
if
(
byte_offset
>
max_offset
)
{
yat
::
AutoMutex
<
yat
::
Mutex
>
guard
(
this
->
m_com_lock
);
this
->
com_state
=
HWProxy_ns
::
HWP_SOFTWARE_ERROR
;
this
->
com_status
=
"HWP_SOFTWARE_ERROR"
;
std
::
stringstream
s
;
s
<<
"CryoCoolerInterface::get_int Offset out of range trying to read an INT "
<<
" at offset "
<<
byte_offset
<<
std
::
endl
;
this
->
last_error
=
s
.
str
();
Tango
::
Except
::
throw_exception
(
static_cast
<
const
char
*>
(
"OUT_OF_RANGE"
),
static_cast
<
const
char
*>
(
s
.
str
().
c_str
()),
static_cast
<
const
char
*>
(
"CryoCoolerInterface::get_int "
));
_CPTC
(
"OUT_OF_RANGE"
),
_CPTC
(
s
.
str
().
c_str
()),
_CPTC
(
"CryoCoolerInterface::get_int "
));
}
if
(
!
hwp
)
{
yat
::
AutoMutex
<
yat
::
Mutex
>
guard
(
this
->
m_com_lock
);
this
->
com_state
=
HWProxy_ns
::
HWP_SOFTWARE_ERROR
;
this
->
com_status
=
"HWP_SOFTWARE_ERROR"
;
std
::
stringstream
s
;
...
...
@@ -534,6 +534,7 @@ namespace CryoCooler_ns
}
catch
(...)
{
yat
::
AutoMutex
<
yat
::
Mutex
>
guard
(
this
->
m_com_lock
);
this
->
com_state
=
HWProxy_ns
::
HWP_SOFTWARE_ERROR
;
this
->
com_status
=
"HWP_SOFTWARE_ERROR"
;
std
::
stringstream
s
;
...
...
@@ -565,19 +566,21 @@ namespace CryoCooler_ns
if
(
byte_offset
>
max_offset
)
{
yat
::
AutoMutex
<
yat
::
Mutex
>
guard
(
this
->
m_com_lock
);
this
->
com_state
=
HWProxy_ns
::
HWP_SOFTWARE_ERROR
;
this
->
com_status
=
"HWP_SOFTWARE_ERROR"
;
std
::
stringstream
s
;
s
<<
"CryoCoolerInterface::get_bool Offset out of range trying to read a BOOL "
<<
" at offset "
<<
byte_offset
<<
"."
<<
bit_offset
<<
std
::
endl
;
this
->
last_error
=
s
.
str
();
Tango
::
Except
::
throw_exception
(
static_cast
<
const
char
*>
(
"OUT_OF_RANGE"
),
static_cast
<
const
char
*>
(
s
.
str
().
c_str
()),
static_cast
<
const
char
*>
(
"CryoCoolerInterface::get_bool"
));
_CPTC
(
"OUT_OF_RANGE"
),
_CPTC
(
s
.
str
().
c_str
()),
_CPTC
(
"CryoCoolerInterface::get_bool"
));
}
if
(
!
hwp
)
{
yat
::
AutoMutex
<
yat
::
Mutex
>
guard
(
this
->
m_com_lock
);
this
->
com_state
=
HWProxy_ns
::
HWP_SOFTWARE_ERROR
;
this
->
com_status
=
"HWP_SOFTWARE_ERROR"
;
std
::
stringstream
s
;
...
...
@@ -596,6 +599,7 @@ namespace CryoCooler_ns
}
catch
(...)
{
yat
::
AutoMutex
<
yat
::
Mutex
>
guard
(
this
->
m_com_lock
);
this
->
com_state
=
HWProxy_ns
::
HWP_SOFTWARE_ERROR
;
this
->
com_status
=
"HWP_SOFTWARE_ERROR"
;
std
::
stringstream
s
;
...
...
@@ -613,11 +617,16 @@ namespace CryoCooler_ns
//-----------------------------------------------
void
CryoCoolerInterface
::
periodic_job_i
(
void
)
{
yat
::
AutoMutex
<
yat
::
Mutex
>
guard
(
this
->
m_com_lock
);
long
l_com_error
=
0
;
long
l_com_success
=
0
;
if
(
hwp
)
{
l_com_success
+=
hwp
->
get_com_success
();
l_com_error
+=
hwp
->
get_com_error
();
this
->
com_state
=
hwp
->
get_com_state
();
if
(
com_state
==
HWProxy_ns
::
HWP_COMMUNICATION_ERROR
)
{
this
->
com_status
=
hwp
->
get_com_status
();
...
...
@@ -629,8 +638,10 @@ namespace CryoCooler_ns
//- hwp_wr is alive
if
(
hwp_wr
)
{
l_com_success
+=
hwp_wr
->
get_com_success
();
l_com_error
+=
hwp_wr
->
get_com_error
();
this
->
com_state
=
hwp_wr
->
get_com_state
();
if
(
com_state
==
HWProxy_ns
::
HWP_COMMUNICATION_ERROR
)
{
this
->
com_status
=
hwp_wr
->
get_com_status
();
...
...
@@ -638,6 +649,7 @@ namespace CryoCooler_ns
return
;
}
}
this
->
com_success
=
l_com_success
;
this
->
com_error
=
l_com_error
;
}
...
...
This diff is collapsed.
Click to expand it.
src/CryoCoolerInterface.h
+
26
−
24
View file @
af7efbc3
...
...
@@ -105,6 +105,8 @@ namespace CryoCooler_ns
//- periodic job
void
periodic_job_i
(
void
);
//- mutex for communication data protection
yat
::
Mutex
m_com_lock
;
};
}
...
...
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