Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fe-vmm-tbl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
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
Code review analytics
Issue 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
nice
dev-epics-modules
fe-vmm-tbl
Commits
5dfd02ae
Commit
5dfd02ae
authored
2 months ago
by
Marco Filho
Browse files
Options
Downloads
Patches
Plain Diff
Style: run pre-commit
parent
1796e5fa
No related branches found
No related tags found
1 merge request
!7
Major refactor
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
vmmTblApp/src/Utils.cpp
+36
-38
36 additions, 38 deletions
vmmTblApp/src/Utils.cpp
vmmTblApp/src/Utils.h
+4
-4
4 additions, 4 deletions
vmmTblApp/src/Utils.h
vmmTblApp/src/vmm_tbl.cpp
+88
-129
88 additions, 129 deletions
vmmTblApp/src/vmm_tbl.cpp
vmmTblApp/src/vmm_tbl.h
+8
-9
8 additions, 9 deletions
vmmTblApp/src/vmm_tbl.h
with
136 additions
and
180 deletions
vmmTblApp/src/Utils.cpp
+
36
−
38
View file @
5dfd02ae
#include
<bits/stdc++.h>
#include
"Utils.h"
#include
"Utils.h"
#include
<bits/stdc++.h>
/**
/**
* @brief Gets index of number in vector.
* @brief Gets index of number in vector.
* @param vec Vector to find number in
* @param vec Vector to find number in
* @param function number to find.
* @param function number to find.
* @return -1 if number is not found. -2 if number is repeated. Index of element if number is found.
* @return -1 if number is not found. -2 if number is repeated. Index of element if number is found.
**/
**/
int
VecUtils
::
getIndex
(
std
::
vector
<
int
>&
vec
,
int
function
){
int
VecUtils
::
getIndex
(
std
::
vector
<
int
>&
vec
,
int
function
)
{
int
c
=
std
::
count
(
vec
.
begin
(),
vec
.
end
(),
function
);
if
(
c
==
0
)
return
-
1
;
if
(
c
>
1
)
return
-
2
;
int
c
=
std
::
count
(
vec
.
begin
(),
vec
.
end
(),
function
);
auto
it
=
std
::
find
(
vec
.
begin
(),
vec
.
end
(),
function
);
if
(
c
==
0
)
return
-
1
;
if
(
c
>
1
)
return
-
2
;
auto
it
=
std
::
find
(
vec
.
begin
(),
vec
.
end
(),
function
);
if
(
it
!=
vec
.
end
())
return
std
::
distance
(
vec
.
begin
(),
it
);
if
(
it
!=
vec
.
end
())
return
std
::
distance
(
vec
.
begin
(),
it
);
return
-
1
;
return
-
1
;
}
}
/**
/**
...
@@ -30,34 +28,34 @@ int VecUtils::getIndex(std::vector<int>& vec, int function){
...
@@ -30,34 +28,34 @@ int VecUtils::getIndex(std::vector<int>& vec, int function){
* @param vmm_index reference to put the vmm index in.
* @param vmm_index reference to put the vmm index in.
* @return -1 if number is not found. -2 if number is repeated. 0 if number is found.
* @return -1 if number is not found. -2 if number is repeated. 0 if number is found.
**/
**/
int
VecUtils
::
getIndex
(
std
::
vector
<
std
::
vector
<
int
>>&
vec
,
int
function
,
int
&
hyb_index
,
int
&
vmm_index
)
{
int
VecUtils
::
getIndex
(
std
::
vector
<
std
::
vector
<
int
>>&
vec
,
int
function
,
int
&
hyb_index
,
int
&
vmm_index
)
{
hyb_index
=
-
1
;
hyb_index
=
-
1
;
vmm_index
=
-
1
;
vmm_index
=
-
1
;
int
occurrences
=
0
;
int
occurrences
=
0
;
for
(
size_t
i
=
0
;
i
<
vec
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
vec
.
size
();
++
i
)
{
auto
&
subvec
=
vec
[
i
];
auto
&
subvec
=
vec
[
i
];
auto
it
=
std
::
find
(
subvec
.
begin
(),
subvec
.
end
(),
function
);
auto
it
=
std
::
find
(
subvec
.
begin
(),
subvec
.
end
(),
function
);
if
(
it
!=
subvec
.
end
())
{
if
(
it
!=
subvec
.
end
())
{
++
occurrences
;
++
occurrences
;
if
(
occurrences
>
1
)
{
if
(
occurrences
>
1
)
{
hyb_index
=
-
2
;
hyb_index
=
-
2
;
vmm_index
=
-
2
;
vmm_index
=
-
2
;
return
-
2
;
// Duplicated
return
-
2
;
// Duplicated
}
}
hyb_index
=
static_cast
<
int
>
(
i
);
hyb_index
=
static_cast
<
int
>
(
i
);
vmm_index
=
static_cast
<
int
>
(
std
::
distance
(
subvec
.
begin
(),
it
));
vmm_index
=
static_cast
<
int
>
(
std
::
distance
(
subvec
.
begin
(),
it
));
}
}
}
}
if
(
occurrences
==
0
)
{
if
(
occurrences
==
0
)
{
hyb_index
=
-
1
;
hyb_index
=
-
1
;
vmm_index
=
-
1
;
vmm_index
=
-
1
;
return
-
1
;
// Not found
return
-
1
;
// Not found
}
}
return
0
;
// Found exactly once
return
0
;
// Found exactly once
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
vmmTblApp/src/Utils.h
+
4
−
4
View file @
5dfd02ae
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
#include
<vector>
#include
<vector>
namespace
VecUtils
{
namespace
VecUtils
{
int
getIndex
(
std
::
vector
<
int
>&
,
int
function
);
int
getIndex
(
std
::
vector
<
int
>
&
,
int
function
);
int
getIndex
(
std
::
vector
<
std
::
vector
<
int
>>&
,
int
function
,
int
&
hyb_index
,
int
&
vmm_index
);
int
getIndex
(
std
::
vector
<
std
::
vector
<
int
>>
&
,
int
function
,
int
&
hyb_index
,
int
&
vmm_index
);
}
}
// namespace VecUtils
\ No newline at end of file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
vmmTblApp/src/vmm_tbl.cpp
+
88
−
129
View file @
5dfd02ae
#include
"vmm_tbl.h"
#include
"vmm_tbl.h"
/** Constructor for the VMMTbl class */
/** Constructor for the VMMTbl class */
VMMTbl
::
VMMTbl
(
RMM
*
rmm
,
const
char
*
FENPortName
,
int
ring
,
int
node
,
int
hybrids
)
VMMTbl
::
VMMTbl
(
RMM
*
rmm
,
const
char
*
FENPortName
,
int
ring
,
int
node
,
int
hybrids
)
:
asynPortDriver
(
FENPortName
,
0
,
:
asynPortDriver
(
FENPortName
,
0
,
asynInt8ArrayMask
|
asynInt32Mask
|
asynInt64Mask
|
asynDrvUserMask
|
asynFloat64Mask
|
asynOctetMask
,
// Interfaces that we implement
asynInt8ArrayMask
|
asynInt32Mask
|
asynInt64Mask
|
asynDrvUserMask
|
asynFloat64Mask
|
asynInt8ArrayMask
|
asynInt64Mask
|
asynInt32ArrayMask
|
asynFloat64Mask
|
asynInt32Mask
|
asynOctetMask
,
// Interfaces that do callbacks
asynOctetMask
,
// Interfaces that we implement
ASYN_MULTIDEVICE
|
ASYN_CANBLOCK
,
1
,
/* ASYN_CANBLOCK=1, ASYN_MULTIDEVICE=1, autoConnect=1 */
asynInt8ArrayMask
|
asynInt64Mask
|
asynInt32ArrayMask
|
asynFloat64Mask
|
asynInt32Mask
|
0
,
0
)
asynOctetMask
,
// Interfaces that do callbacks
{
ASYN_MULTIDEVICE
|
ASYN_CANBLOCK
,
1
,
/* ASYN_CANBLOCK=1, ASYN_MULTIDEVICE=1, autoConnect=1 */
0
,
0
)
{
pVmmAPI
=
FrontEndFactory
::
createAndRegister
<
VMMAPI
>
(
pVmmAPI
=
rmm
->
getRMMAPI
(),
FrontEndFactory
::
createAndRegister
<
VMMAPI
>
(
rmm
->
getRMMAPI
(),
ring
,
node
,
"VmmTbl"
,
vmm_tbl_register_map
,
hybrids
);
ring
,
node
,
"VmmTbl"
,
vmm_tbl_register_map
,
hybrids
);
createEpicsParams
();
createEpicsParams
();
rmm
->
updateTopologyPvs
(
ring
,
node
,
"vmmTbl"
);
rmm
->
updateTopologyPvs
(
ring
,
node
,
"vmmTbl"
);
}
}
asynStatus
VMMTbl
::
readInt32
(
asynUser
*
pasynUser
,
epicsInt32
*
value
)
{
asynStatus
VMMTbl
::
readInt32
(
asynUser
*
pasynUser
,
epicsInt32
*
value
)
{
...
@@ -49,7 +43,7 @@ asynStatus VMMTbl::readInt32(asynUser *pasynUser, epicsInt32 *value) {
...
@@ -49,7 +43,7 @@ asynStatus VMMTbl::readInt32(asynUser *pasynUser, epicsInt32 *value) {
goto
endOfReadInt32
;
goto
endOfReadInt32
;
}
}
//Search for parameter in all parameter vectors. If found, execute correct function for specific hybrid.
//
Search for parameter in all parameter vectors. If found, execute correct function for specific hybrid.
param_index
=
VecUtils
::
getIndex
(
vmmHybSkew_
,
function
);
param_index
=
VecUtils
::
getIndex
(
vmmHybSkew_
,
function
);
if
(
param_index
>=
0
)
{
if
(
param_index
>=
0
)
{
result
=
this
->
pVmmAPI
->
getSkew
(
param_index
,
tmp_val_uint8
);
result
=
this
->
pVmmAPI
->
getSkew
(
param_index
,
tmp_val_uint8
);
...
@@ -92,18 +86,16 @@ asynStatus VMMTbl::readInt32(asynUser *pasynUser, epicsInt32 *value) {
...
@@ -92,18 +86,16 @@ asynStatus VMMTbl::readInt32(asynUser *pasynUser, epicsInt32 *value) {
goto
endOfReadInt32
;
goto
endOfReadInt32
;
}
}
endOfReadInt32
:
endOfReadInt32
:
if
(
param_index
<
0
)
{
if
(
param_index
<
0
)
{
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to find parameter %d.
\n
"
,
driverName
,
__FUNCTION__
,
"%s:%s: Failed to find parameter %d.
\n
"
,
function
);
driverName
,
__FUNCTION__
,
function
);
*
value
=
0
;
*
value
=
0
;
return
asynError
;
return
asynError
;
}
}
if
(
result
!=
vmmSuccess
)
{
if
(
result
!=
vmmSuccess
)
{
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to adequately read parameter: %d.
\n
"
,
driverName
,
"%s:%s: Failed to adequately read parameter: %d.
\n
"
,
__FUNCTION__
,
function
);
driverName
,
__FUNCTION__
,
function
);
status
=
asynError
;
status
=
asynError
;
}
}
...
@@ -111,25 +103,20 @@ asynStatus VMMTbl::readInt32(asynUser *pasynUser, epicsInt32 *value) {
...
@@ -111,25 +103,20 @@ asynStatus VMMTbl::readInt32(asynUser *pasynUser, epicsInt32 *value) {
callParamCallbacks
();
callParamCallbacks
();
return
status
;
return
status
;
}
}
asynStatus
VMMTbl
::
readOctet
(
asynUser
*
pasynUser
,
char
*
value
,
asynStatus
VMMTbl
::
readOctet
(
asynUser
*
pasynUser
,
char
*
value
,
size_t
nChars
,
size_t
*
nActual
,
int
*
eomReason
)
{
size_t
nChars
,
size_t
*
nActual
,
asynStatus
status
=
asynSuccess
;
int
*
eomReason
)
{
asynStatus
status
=
asynSuccess
;
vmmStatus
result
;
vmmStatus
result
;
int
function
=
pasynUser
->
reason
;
int
function
=
pasynUser
->
reason
;
std
::
string
read
=
""
;
std
::
string
read
=
""
;
/* If this parameter belongs to a base class call its method */
/* If this parameter belongs to a base class call its method */
if
(
function
<
FIRST_VMM_PARAM
)
{
if
(
function
<
FIRST_VMM_PARAM
)
{
return
asynPortDriver
::
readOctet
(
pasynUser
,
value
,
nChars
,
nActual
,
eomReason
);
return
asynPortDriver
::
readOctet
(
pasynUser
,
value
,
nChars
,
nActual
,
eomReason
);
}
}
//Search for parameter in all parameter vectors. If found, execute correct function for specific hybrid.
//
Search for parameter in all parameter vectors. If found, execute correct function for specific hybrid.
int
param_index
=
VecUtils
::
getIndex
(
vmmHybFwVersion_
,
function
);
int
param_index
=
VecUtils
::
getIndex
(
vmmHybFwVersion_
,
function
);
if
(
param_index
>=
0
)
{
if
(
param_index
>=
0
)
{
result
=
this
->
pVmmAPI
->
readFwVersion
(
param_index
,
read
);
result
=
this
->
pVmmAPI
->
readFwVersion
(
param_index
,
read
);
...
@@ -148,16 +135,15 @@ asynStatus VMMTbl::readOctet(asynUser *pasynUser, char *value,
...
@@ -148,16 +135,15 @@ asynStatus VMMTbl::readOctet(asynUser *pasynUser, char *value,
goto
endOfReadOctet
;
goto
endOfReadOctet
;
}
}
endOfReadOctet
:
endOfReadOctet
:
if
(
param_index
<
0
)
{
if
(
param_index
<
0
)
{
value
[
0
]
=
'\0'
;
value
[
0
]
=
'\0'
;
*
nActual
=
1
;
*
nActual
=
1
;
return
asynError
;
return
asynError
;
}
}
if
(
result
!=
vmmSuccess
)
{
if
(
result
!=
vmmSuccess
)
{
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to adequately read parameter: %d.
\n
"
,
driverName
,
"%s:%s: Failed to adequately read parameter: %d.
\n
"
,
__FUNCTION__
,
function
);
driverName
,
__FUNCTION__
,
function
);
status
=
asynError
;
status
=
asynError
;
}
}
size_t
copy_size
=
std
::
min
(
read
.
size
(),
nChars
);
size_t
copy_size
=
std
::
min
(
read
.
size
(),
nChars
);
...
@@ -169,93 +155,84 @@ asynStatus VMMTbl::readOctet(asynUser *pasynUser, char *value,
...
@@ -169,93 +155,84 @@ asynStatus VMMTbl::readOctet(asynUser *pasynUser, char *value,
callParamCallbacks
();
callParamCallbacks
();
return
status
;
return
status
;
}
}
asynStatus
VMMTbl
::
createParamAndStoreInVector
(
std
::
string
paramName
,
asynParamType
typ
,
asynStatus
VMMTbl
::
createParamAndStoreInVector
(
std
::
string
paramName
,
asynParamType
typ
,
std
::
vector
<
int
>*
vectorToStore
){
std
::
vector
<
int
>
*
vectorToStore
)
{
int
paramIndex
;
int
paramIndex
;
asynStatus
status
=
createParam
(
paramName
.
c_str
(),
typ
,
&
paramIndex
);
asynStatus
status
=
createParam
(
paramName
.
c_str
(),
typ
,
&
paramIndex
);
if
(
status
!=
asynSuccess
)
{
if
(
status
!=
asynSuccess
)
{
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to create paramter %s.
\n
"
,
driverName
,
__FUNCTION__
,
"%s:%s: Failed to create paramter %s.
\n
"
,
paramName
.
c_str
());
driverName
,
__FUNCTION__
,
paramName
.
c_str
());
return
asynError
;
return
asynError
;
}
}
vectorToStore
->
push_back
(
paramIndex
);
vectorToStore
->
push_back
(
paramIndex
);
return
asynSuccess
;
return
asynSuccess
;
}
}
asynStatus
VMMTbl
::
createEpicsParams
()
{
asynStatus
VMMTbl
::
createEpicsParams
()
{
createParam
(
"REG_BANK_VERSION"
,
asynParamInt32
,
&
vmmRegBankVersion
);
createParam
(
"REG_BANK_VERSION"
,
asynParamInt32
,
&
vmmRegBankVersion
);
createParam
(
"VMM_FEN_ACQUIRE"
,
asynParamInt32
,
&
vmmAcquire_
);
createParam
(
"VMM_FEN_ACQUIRE"
,
asynParamInt32
,
&
vmmAcquire_
);
createParam
(
"VMM_FEN_ACQUIRING"
,
asynParamInt32
,
&
vmmIsAcquiring_
);
createParam
(
"VMM_FEN_ACQUIRING"
,
asynParamInt32
,
&
vmmIsAcquiring_
);
createParam
(
"IOC_MESSAGE"
,
asynParamOctet
,
&
IOCMessage
);
createParam
(
"IOC_MESSAGE"
,
asynParamOctet
,
&
IOCMessage
);
std
::
tuple
<
std
::
string
,
asynParamType
,
std
::
vector
<
int
>*>
std
::
tuple
<
std
::
string
,
asynParamType
,
std
::
vector
<
int
>
*>
hyb_params_to_create
[
7
]
=
{
hyb_params_to_create
[
7
]
=
{
{
"_FW_VERSION"
,
asynParamOctet
,
&
vmmHybFwVersion_
},
{
"_FW_VERSION"
,
asynParamOctet
,
&
vmmHybFwVersion_
},
{
"_ID"
,
asynParamOctet
,
&
vmmHybId_
},
{
"_ID"
,
asynParamOctet
,
&
vmmHybId_
},
{
"_GEOPOS"
,
asynParamOctet
,
&
vmmHybGeoPos_
},
{
"_GEOPOS"
,
asynParamOctet
,
&
vmmHybGeoPos_
},
{
"_LINK_STATUS"
,
asynParamInt32
,
&
vmmHybLinkStatus_
},
{
"_LINK_STATUS"
,
asynParamInt32
,
&
vmmHybLinkStatus_
},
{
"_SKEW"
,
asynParamInt32
,
&
vmmHybSkew_
},
{
"_SKEW"
,
asynParamInt32
,
&
vmmHybSkew_
},
{
"_WIDTH"
,
asynParamInt32
,
&
vmmHybWidth_
},
{
"_WIDTH"
,
asynParamInt32
,
&
vmmHybWidth_
},
{
"_POLARITY"
,
asynParamInt32
,
&
vmmHybPolarity_
}};
{
"_POLARITY"
,
asynParamInt32
,
&
vmmHybPolarity_
}};
std
::
ostringstream
param_name
;
std
::
ostringstream
param_name
;
for
(
int
hyb
=
0
;
hyb
<
this
->
pVmmAPI
->
getNumHybrids
(
true
);
hyb
++
)
{
for
(
int
hyb
=
0
;
hyb
<
this
->
pVmmAPI
->
getNumHybrids
(
true
);
hyb
++
)
{
for
(
const
auto
&
hyb_param
:
hyb_params_to_create
)
{
for
(
const
auto
&
hyb_param
:
hyb_params_to_create
){
const
std
::
string
&
key
=
std
::
get
<
0
>
(
hyb_param
);
const
std
::
string
&
key
=
std
::
get
<
0
>
(
hyb_param
);
asynParamType
typ
=
std
::
get
<
1
>
(
hyb_param
);
asynParamType
typ
=
std
::
get
<
1
>
(
hyb_param
);
std
::
vector
<
int
>
*
vec
=
std
::
get
<
2
>
(
hyb_param
);
std
::
vector
<
int
>
*
vec
=
std
::
get
<
2
>
(
hyb_param
);
createParamAndStoreInVector
(
"HYB_"
+
std
::
to_string
(
hyb
)
+
key
,
typ
,
vec
);
createParamAndStoreInVector
(
"HYB_"
+
std
::
to_string
(
hyb
)
+
key
,
typ
,
vec
);
}
}
std
::
vector
<
int
>
SC
,
SL
,
ST
,
STH
,
SM
,
SD
,
SMX
,
ADCIDX
,
ADCVAL
;
std
::
vector
<
int
>
SC
,
SL
,
ST
,
STH
,
SM
,
SD
,
SMX
,
ADCIDX
,
ADCVAL
;
for
(
int
vmm
=
0
;
vmm
<
VMMS_PER_HYBRID
;
vmm
++
)
{
for
(
int
vmm
=
0
;
vmm
<
VMMS_PER_HYBRID
;
vmm
++
)
{
param_name
.
str
(
""
);
param_name
.
str
(
""
);
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SC"
;
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SC"
;
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
SC
);
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
SC
);
param_name
.
str
(
""
);
param_name
.
str
(
""
);
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SL"
;
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SL"
;
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
SL
);
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
SL
);
param_name
.
str
(
""
);
param_name
.
str
(
""
);
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_ST"
;
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_ST"
;
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
ST
);
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
ST
);
param_name
.
str
(
""
);
param_name
.
str
(
""
);
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_STH"
;
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_STH"
;
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
STH
);
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
STH
);
param_name
.
str
(
""
);
param_name
.
str
(
""
);
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SM"
;
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SM"
;
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
SM
);
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
SM
);
param_name
.
str
(
""
);
param_name
.
str
(
""
);
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SD"
;
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SD"
;
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
SD
);
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
SD
);
param_name
.
str
(
""
);
param_name
.
str
(
""
);
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SMX"
;
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SMX"
;
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
SMX
);
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
SMX
);
param_name
.
str
(
""
);
param_name
.
str
(
""
);
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_ANALOGMON"
;
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_ANALOGMON"
;
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt32
,
&
ADCIDX
);
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt32
,
&
ADCIDX
);
param_name
.
str
(
""
);
param_name
.
str
(
""
);
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_ADCVAL"
;
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_ADCVAL"
;
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt32
,
&
ADCVAL
);
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt32
,
&
ADCVAL
);
}
}
this
->
vmmSC_
.
push_back
(
SC
);
this
->
vmmSC_
.
push_back
(
SC
);
...
@@ -267,14 +244,12 @@ asynStatus VMMTbl::createEpicsParams() {
...
@@ -267,14 +244,12 @@ asynStatus VMMTbl::createEpicsParams() {
this
->
vmmSMX_
.
push_back
(
SMX
);
this
->
vmmSMX_
.
push_back
(
SMX
);
this
->
vmmADCIDX_
.
push_back
(
ADCIDX
);
this
->
vmmADCIDX_
.
push_back
(
ADCIDX
);
this
->
vmmADCVAL_
.
push_back
(
ADCVAL
);
this
->
vmmADCVAL_
.
push_back
(
ADCVAL
);
}
}
return
asynSuccess
;
return
asynSuccess
;
}
}
asynStatus
VMMTbl
::
writeInt32
(
asynUser
*
pasynUser
,
epicsInt32
value
)
{
asynStatus
VMMTbl
::
writeInt32
(
asynUser
*
pasynUser
,
epicsInt32
value
)
{
asynStatus
status
=
asynSuccess
;
asynStatus
status
=
asynSuccess
;
vmmStatus
vmm_stat
=
vmmSuccess
;
vmmStatus
vmm_stat
=
vmmSuccess
;
bool
is_acquiring
;
bool
is_acquiring
;
...
@@ -286,7 +261,6 @@ asynStatus VMMTbl::writeInt32(asynUser *pasynUser, epicsInt32 value) {
...
@@ -286,7 +261,6 @@ asynStatus VMMTbl::writeInt32(asynUser *pasynUser, epicsInt32 value) {
}
}
if
(
function
==
vmmAcquire_
)
{
if
(
function
==
vmmAcquire_
)
{
vmm_stat
=
this
->
pVmmAPI
->
isAcquiring
(
is_acquiring
);
vmm_stat
=
this
->
pVmmAPI
->
isAcquiring
(
is_acquiring
);
if
(
is_acquiring
==
(
bool
)
value
)
{
if
(
is_acquiring
==
(
bool
)
value
)
{
setStringParam
(
IOCMessage
,
"Set to acquire/stop but already acquiring/stopped."
);
setStringParam
(
IOCMessage
,
"Set to acquire/stop but already acquiring/stopped."
);
...
@@ -296,10 +270,9 @@ asynStatus VMMTbl::writeInt32(asynUser *pasynUser, epicsInt32 value) {
...
@@ -296,10 +270,9 @@ asynStatus VMMTbl::writeInt32(asynUser *pasynUser, epicsInt32 value) {
}
}
goto
endOfWriteInt32
;
goto
endOfWriteInt32
;
}
}
//Search for parameter in all parameter vectors. If found, execute correct function for specific hybrid.
//
Search for parameter in all parameter vectors. If found, execute correct function for specific hybrid.
param_index
=
VecUtils
::
getIndex
(
vmmHybSkew_
,
function
);
param_index
=
VecUtils
::
getIndex
(
vmmHybSkew_
,
function
);
if
(
param_index
>=
0
)
{
if
(
param_index
>=
0
)
{
vmm_stat
=
this
->
pVmmAPI
->
setSkew
(
param_index
,
value
);
vmm_stat
=
this
->
pVmmAPI
->
setSkew
(
param_index
,
value
);
...
@@ -324,7 +297,7 @@ asynStatus VMMTbl::writeInt32(asynUser *pasynUser, epicsInt32 value) {
...
@@ -324,7 +297,7 @@ asynStatus VMMTbl::writeInt32(asynUser *pasynUser, epicsInt32 value) {
goto
endOfWriteInt32
;
goto
endOfWriteInt32
;
}
}
endOfWriteInt32
:
endOfWriteInt32
:
if
(
param_index
<
0
)
{
if
(
param_index
<
0
)
{
status
=
asynError
;
status
=
asynError
;
}
}
...
@@ -334,15 +307,13 @@ asynStatus VMMTbl::writeInt32(asynUser *pasynUser, epicsInt32 value) {
...
@@ -334,15 +307,13 @@ asynStatus VMMTbl::writeInt32(asynUser *pasynUser, epicsInt32 value) {
callParamCallbacks
();
callParamCallbacks
();
return
status
;
return
status
;
}
}
asynStatus
VMMTbl
::
readInt8Array
(
asynUser
*
pasynUser
,
epicsInt8
*
value
,
size_t
nElements
,
size_t
*
nIn
){
asynStatus
VMMTbl
::
readInt8Array
(
asynUser
*
pasynUser
,
epicsInt8
*
value
,
size_t
nElements
,
size_t
*
nIn
)
{
int
function
,
hyb_index
,
vmm_index
,
found_param
=
-
10
,
status
=
0
;
int
function
,
hyb_index
,
vmm_index
,
found_param
=
-
10
,
status
=
0
;
uint8_t
data_int
;
uint8_t
data_int
;
bool
data
;
bool
data
;
const
char
*
paramName
;
const
char
*
paramName
;
function
=
pasynUser
->
reason
;
function
=
pasynUser
->
reason
;
getParamName
(
function
,
&
paramName
);
getParamName
(
function
,
&
paramName
);
...
@@ -412,11 +383,10 @@ asynStatus VMMTbl::readInt8Array(asynUser *pasynUser, epicsInt8 *value, size_t n
...
@@ -412,11 +383,10 @@ asynStatus VMMTbl::readInt8Array(asynUser *pasynUser, epicsInt8 *value, size_t n
goto
endOfReadInt8Array
;
goto
endOfReadInt8Array
;
}
}
endOfReadInt8Array
:
endOfReadInt8Array
:
if
(
found_param
!=
0
)
{
if
(
found_param
!=
0
)
{
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to find paramter %s, index %d.
\n
"
,
driverName
,
"%s:%s: Failed to find paramter %s, index %d.
\n
"
,
__FUNCTION__
,
paramName
,
function
);
driverName
,
__FUNCTION__
,
paramName
,
function
);
*
nIn
=
0
;
*
nIn
=
0
;
return
asynError
;
return
asynError
;
}
}
...
@@ -424,21 +394,17 @@ asynStatus VMMTbl::readInt8Array(asynUser *pasynUser, epicsInt8 *value, size_t n
...
@@ -424,21 +394,17 @@ asynStatus VMMTbl::readInt8Array(asynUser *pasynUser, epicsInt8 *value, size_t n
*
nIn
=
nElements
;
*
nIn
=
nElements
;
if
(
status
)
{
if
(
status
)
{
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to get paramter %s, index %d.
\n
"
,
driverName
,
"%s:%s: Failed to get paramter %s, index %d.
\n
"
,
__FUNCTION__
,
paramName
,
function
);
driverName
,
__FUNCTION__
,
paramName
,
function
);
return
asynError
;
return
asynError
;
}
}
return
asynSuccess
;
return
asynSuccess
;
}
}
asynStatus
VMMTbl
::
writeInt8Array
(
asynUser
*
pasynUser
,
epicsInt8
*
value
,
size_t
nElements
)
asynStatus
VMMTbl
::
writeInt8Array
(
asynUser
*
pasynUser
,
epicsInt8
*
value
,
size_t
nElements
)
{
{
int
function
,
hyb_index
,
vmm_index
,
status
=
0
,
found_param
=
-
10
;
int
function
,
hyb_index
,
vmm_index
,
status
=
0
,
found_param
=
-
10
;
const
char
*
paramName
;
const
char
*
paramName
;
function
=
pasynUser
->
reason
;
function
=
pasynUser
->
reason
;
getParamName
(
function
,
&
paramName
);
getParamName
(
function
,
&
paramName
);
...
@@ -501,58 +467,51 @@ asynStatus VMMTbl::writeInt8Array(asynUser *pasynUser, epicsInt8 *value, size_t
...
@@ -501,58 +467,51 @@ asynStatus VMMTbl::writeInt8Array(asynUser *pasynUser, epicsInt8 *value, size_t
goto
endOfWriteInt8Array
;
goto
endOfWriteInt8Array
;
}
}
endOfWriteInt8Array
:
endOfWriteInt8Array
:
status
|=
(
int
)
doCallbacksInt8Array
(
value
,
nElements
,
function
,
0
);
// Comparing different statuses, yes.
status
|=
(
int
)
doCallbacksInt8Array
(
value
,
nElements
,
function
,
0
);
// Comparing different statuses, yes.
if
(
found_param
!=
0
)
{
if
(
found_param
!=
0
)
{
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to find paramter %s, index %d.
\n
"
,
driverName
,
"%s:%s: Failed to find paramter %s, index %d.
\n
"
,
__FUNCTION__
,
paramName
,
function
);
driverName
,
__FUNCTION__
,
paramName
,
function
);
return
asynError
;
return
asynError
;
}
}
if
(
status
)
{
if
(
status
)
{
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to set paramter %s.
\n
"
,
driverName
,
__FUNCTION__
,
"%s:%s: Failed to set paramter %s.
\n
"
,
paramName
);
driverName
,
__FUNCTION__
,
paramName
);
return
asynError
;
return
asynError
;
}
}
return
asynSuccess
;
return
asynSuccess
;
}
}
extern
"C"
{
extern
"C"
{
static
void
VMMTblConfig
(
const
char
*
RMMPortName
,
const
char
*
FENPortName
,
int
ring
,
int
hybrids
)
{
static
void
VMMTblConfig
(
const
char
*
RMMPortName
,
const
char
*
FENPortName
,
int
ring
,
int
hybrids
)
{
int
node
=
0
;
// VMM use always only the Node 0
int
node
=
0
;
// VMM use always only the Node 0
RMM
*
pRMM
;
RMM
*
pRMM
;
pRMM
=
(
RMM
*
)
findAsynPortDriver
(
RMMPortName
);
pRMM
=
(
RMM
*
)
findAsynPortDriver
(
RMMPortName
);
if
(
pRMM
!=
nullptr
)
{
if
(
pRMM
!=
nullptr
)
{
new
VMMTbl
(
pRMM
,
FENPortName
,
ring
,
node
,
hybrids
);
new
VMMTbl
(
pRMM
,
FENPortName
,
ring
,
node
,
hybrids
);
}
else
{
}
else
{
std
::
cerr
<<
"Error: Failed to find RMM for port "
<<
RMMPortName
<<
std
::
endl
;
std
::
cerr
<<
"Error: Failed to find RMM for port "
<<
RMMPortName
<<
std
::
endl
;
}
}
}
}
static
const
iocshArg
configArg0
=
{
"RMM Port name"
,
iocshArgString
};
static
const
iocshArg
configArg0
=
{
"RMM Port name"
,
iocshArgString
};
static
const
iocshArg
configArg1
=
{
"Front End Port Name"
,
iocshArgString
};
static
const
iocshArg
configArg1
=
{
"Front End Port Name"
,
iocshArgString
};
static
const
iocshArg
configArg2
=
{
"Ring"
,
iocshArgInt
};
static
const
iocshArg
configArg2
=
{
"Ring"
,
iocshArgInt
};
static
const
iocshArg
configArg3
=
{
"Hybrids"
,
iocshArgInt
};
static
const
iocshArg
configArg3
=
{
"Hybrids"
,
iocshArgInt
};
static
const
iocshArg
*
const
configArgs
[]
=
{
&
configArg0
,
static
const
iocshArg
*
const
configArgs
[]
=
{
&
configArg0
,
&
configArg1
,
&
configArg2
,
&
configArg3
};
&
configArg1
,
&
configArg2
,
&
configArg3
};
static
const
iocshFuncDef
configFuncDef
=
{
"VMMTblConfig"
,
4
,
configArgs
};
static
const
iocshFuncDef
configFuncDef
=
{
"VMMTblConfig"
,
4
,
configArgs
};
static
void
configCallFunc
(
const
iocshArgBuf
*
args
)
{
static
void
configCallFunc
(
const
iocshArgBuf
*
args
)
{
VMMTblConfig
(
args
[
0
].
sval
,
args
[
1
].
sval
,
args
[
2
].
ival
,
args
[
3
].
ival
);
VMMTblConfig
(
args
[
0
].
sval
,
args
[
1
].
sval
,
args
[
2
].
ival
,
args
[
3
].
ival
);
}
}
static
void
VMMTblRegister
(
void
)
{
static
void
VMMTblRegister
(
void
)
{
iocshRegister
(
&
configFuncDef
,
configCallFunc
);
iocshRegister
(
&
configFuncDef
,
configCallFunc
);
}
}
epicsExportRegistrar
(
VMMTblRegister
);
epicsExportRegistrar
(
VMMTblRegister
);
}
// end extern "C"
}
// end extern "C"
\ No newline at end of file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
vmmTblApp/src/vmm_tbl.h
+
8
−
9
View file @
5dfd02ae
#pragma once
#pragma once
#include
"rmm.h"
#include
"VMMAPI.h"
#include
"Utils.h"
#include
"Utils.h"
#include
"VMMAPI.h"
#include
"rmm.h"
/* Struct to hold Hyb, VMM and epics parameter values */
/* Struct to hold Hyb, VMM and epics parameter values */
struct
ParamValues
{
struct
ParamValues
{
...
@@ -12,21 +12,20 @@ struct ParamValues {
...
@@ -12,21 +12,20 @@ struct ParamValues {
/** Class definition for the VMMTbl class */
/** Class definition for the VMMTbl class */
class
VMMTbl
:
public
asynPortDriver
{
class
VMMTbl
:
public
asynPortDriver
{
public:
public:
VMMTbl
(
RMM
*
rmm
,
const
char
*
FENPortName
,
int
ring
,
int
node
,
int
hybrids
);
VMMTbl
(
RMM
*
rmm
,
const
char
*
FENPortName
,
int
ring
,
int
node
,
int
hybrids
);
/* Epics parameter management */
/* Epics parameter management */
asynStatus
createEpicsParams
();
asynStatus
createEpicsParams
();
virtual
asynStatus
writeInt32
(
asynUser
*
pasynUser
,
epicsInt32
value
);
virtual
asynStatus
writeInt32
(
asynUser
*
pasynUser
,
epicsInt32
value
);
// virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
// virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
virtual
asynStatus
writeInt8Array
(
asynUser
*
pasynUser
,
epicsInt8
*
value
,
size_t
nElements
);
virtual
asynStatus
writeInt8Array
(
asynUser
*
pasynUser
,
epicsInt8
*
value
,
size_t
nElements
);
virtual
asynStatus
readInt8Array
(
asynUser
*
pasynUser
,
epicsInt8
*
value
,
size_t
nElements
,
size_t
*
nIn
);
virtual
asynStatus
readInt8Array
(
asynUser
*
pasynUser
,
epicsInt8
*
value
,
size_t
nElements
,
size_t
*
nIn
);
virtual
asynStatus
readInt32
(
asynUser
*
pasynUser
,
epicsInt32
*
value
);
virtual
asynStatus
readInt32
(
asynUser
*
pasynUser
,
epicsInt32
*
value
);
virtual
asynStatus
readOctet
(
asynUser
*
pasynUser
,
char
*
value
,
size_t
maxChars
,
size_t
*
nActual
,
int
*
eomReason
);
virtual
asynStatus
readOctet
(
asynUser
*
pasynUser
,
char
*
value
,
size_t
maxChars
,
size_t
*
nActual
,
int
*
eomReason
);
asynStatus
createParamAndStoreInVector
(
std
::
string
paramName
,
asynParamType
typ
,
asynStatus
createParamAndStoreInVector
(
std
::
string
paramName
,
asynParamType
typ
,
std
::
vector
<
int
>
*
vectorToStore
);
std
::
vector
<
int
>*
vectorToStore
);
protected:
protected:
int
vmmRegBankVersion
;
int
vmmRegBankVersion
;
#define FIRST_VMM_PARAM vmmRegBankVersion
#define FIRST_VMM_PARAM vmmRegBankVersion
int
vmmSelectMonitorVMM0_
;
int
vmmSelectMonitorVMM0_
;
...
@@ -54,7 +53,7 @@ protected:
...
@@ -54,7 +53,7 @@ protected:
std
::
vector
<
std
::
vector
<
int
>>
vmmADCIDX_
;
std
::
vector
<
std
::
vector
<
int
>>
vmmADCIDX_
;
std
::
vector
<
std
::
vector
<
int
>>
vmmADCVAL_
;
std
::
vector
<
std
::
vector
<
int
>>
vmmADCVAL_
;
private:
private:
static
constexpr
const
char
*
driverName
=
"VMMTbl"
;
static
constexpr
const
char
*
driverName
=
"VMMTbl"
;
std
::
shared_ptr
<
VMMAPI
>
pVmmAPI
;
std
::
shared_ptr
<
VMMAPI
>
pVmmAPI
;
};
};
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