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
Branches containing commit
No related tags found
Tags containing commit
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
<bits/stdc++.h>
/**
* @brief Gets index of number in vector.
* @param vec Vector to find number in
* @param function number to find.
* @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
);
if
(
c
==
0
)
return
-
1
;
if
(
c
>
1
)
return
-
2
;
auto
it
=
std
::
find
(
vec
.
begin
(),
vec
.
end
(),
function
);
auto
it
=
std
::
find
(
vec
.
begin
(),
vec
.
end
(),
function
);
if
(
it
!=
vec
.
end
())
return
std
::
distance
(
vec
.
begin
(),
it
);
return
-
1
;
if
(
it
!=
vec
.
end
())
return
std
::
distance
(
vec
.
begin
(),
it
);
return
-
1
;
}
/**
...
...
@@ -30,34 +28,34 @@ int VecUtils::getIndex(std::vector<int>& vec, int function){
* @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.
**/
int
VecUtils
::
getIndex
(
std
::
vector
<
std
::
vector
<
int
>>&
vec
,
int
function
,
int
&
hyb_index
,
int
&
vmm_index
)
{
hyb_index
=
-
1
;
vmm_index
=
-
1
;
int
occurrences
=
0
;
for
(
size_t
i
=
0
;
i
<
vec
.
size
();
++
i
)
{
auto
&
subvec
=
vec
[
i
];
auto
it
=
std
::
find
(
subvec
.
begin
(),
subvec
.
end
(),
function
);
if
(
it
!=
subvec
.
end
())
{
++
occurrences
;
if
(
occurrences
>
1
)
{
hyb_index
=
-
2
;
vmm_index
=
-
2
;
return
-
2
;
// Duplicated
}
hyb_index
=
static_cast
<
int
>
(
i
);
vmm_index
=
static_cast
<
int
>
(
std
::
distance
(
subvec
.
begin
(),
it
));
}
int
VecUtils
::
getIndex
(
std
::
vector
<
std
::
vector
<
int
>>&
vec
,
int
function
,
int
&
hyb_index
,
int
&
vmm_index
)
{
hyb_index
=
-
1
;
vmm_index
=
-
1
;
int
occurrences
=
0
;
for
(
size_t
i
=
0
;
i
<
vec
.
size
();
++
i
)
{
auto
&
subvec
=
vec
[
i
];
auto
it
=
std
::
find
(
subvec
.
begin
(),
subvec
.
end
(),
function
);
if
(
it
!=
subvec
.
end
())
{
++
occurrences
;
if
(
occurrences
>
1
)
{
hyb_index
=
-
2
;
vmm_index
=
-
2
;
return
-
2
;
// Duplicated
}
hyb_index
=
static_cast
<
int
>
(
i
);
vmm_index
=
static_cast
<
int
>
(
std
::
distance
(
subvec
.
begin
(),
it
));
}
}
if
(
occurrences
==
0
)
{
hyb_index
=
-
1
;
vmm_index
=
-
1
;
return
-
1
;
// Not found
}
if
(
occurrences
==
0
)
{
hyb_index
=
-
1
;
vmm_index
=
-
1
;
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 @@
#include
<vector>
namespace
VecUtils
{
namespace
VecUtils
{
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
<
int
>
&
,
int
function
);
int
getIndex
(
std
::
vector
<
std
::
vector
<
int
>>
&
,
int
function
,
int
&
hyb_index
,
int
&
vmm_index
);
}
\ No newline at end of file
}
// namespace VecUtils
\ 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"
/** Constructor for the VMMTbl class */
VMMTbl
::
VMMTbl
(
RMM
*
rmm
,
const
char
*
FENPortName
,
int
ring
,
int
node
,
int
hybrids
)
:
asynPortDriver
(
FENPortName
,
0
,
asynInt8ArrayMask
|
asynInt32Mask
|
asynInt64Mask
|
asynDrvUserMask
|
asynFloat64Mask
|
asynOctetMask
,
// Interfaces that we implement
asynInt8ArrayMask
|
asynInt64Mask
|
asynInt32ArrayMask
|
asynFloat64Mask
|
asynInt32Mask
|
asynOctetMask
,
// Interfaces that do callbacks
ASYN_MULTIDEVICE
|
ASYN_CANBLOCK
,
1
,
/* ASYN_CANBLOCK=1, ASYN_MULTIDEVICE=1, autoConnect=1 */
0
,
0
)
{
pVmmAPI
=
FrontEndFactory
::
createAndRegister
<
VMMAPI
>
(
rmm
->
getRMMAPI
(),
ring
,
node
,
"VmmTbl"
,
vmm_tbl_register_map
,
hybrids
);
VMMTbl
::
VMMTbl
(
RMM
*
rmm
,
const
char
*
FENPortName
,
int
ring
,
int
node
,
int
hybrids
)
:
asynPortDriver
(
FENPortName
,
0
,
asynInt8ArrayMask
|
asynInt32Mask
|
asynInt64Mask
|
asynDrvUserMask
|
asynFloat64Mask
|
asynOctetMask
,
// Interfaces that we implement
asynInt8ArrayMask
|
asynInt64Mask
|
asynInt32ArrayMask
|
asynFloat64Mask
|
asynInt32Mask
|
asynOctetMask
,
// Interfaces that do callbacks
ASYN_MULTIDEVICE
|
ASYN_CANBLOCK
,
1
,
/* ASYN_CANBLOCK=1, ASYN_MULTIDEVICE=1, autoConnect=1 */
0
,
0
)
{
pVmmAPI
=
FrontEndFactory
::
createAndRegister
<
VMMAPI
>
(
rmm
->
getRMMAPI
(),
ring
,
node
,
"VmmTbl"
,
vmm_tbl_register_map
,
hybrids
);
createEpicsParams
();
rmm
->
updateTopologyPvs
(
ring
,
node
,
"vmmTbl"
);
}
asynStatus
VMMTbl
::
readInt32
(
asynUser
*
pasynUser
,
epicsInt32
*
value
)
{
...
...
@@ -49,7 +43,7 @@ asynStatus VMMTbl::readInt32(asynUser *pasynUser, epicsInt32 *value) {
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
);
if
(
param_index
>=
0
)
{
result
=
this
->
pVmmAPI
->
getSkew
(
param_index
,
tmp_val_uint8
);
...
...
@@ -92,18 +86,16 @@ asynStatus VMMTbl::readInt32(asynUser *pasynUser, epicsInt32 *value) {
goto
endOfReadInt32
;
}
endOfReadInt32
:
endOfReadInt32
:
if
(
param_index
<
0
)
{
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to find parameter %d.
\n
"
,
driverName
,
__FUNCTION__
,
function
);
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to find parameter %d.
\n
"
,
driverName
,
__FUNCTION__
,
function
);
*
value
=
0
;
return
asynError
;
}
if
(
result
!=
vmmSuccess
)
{
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to adequately read parameter: %d.
\n
"
,
driverName
,
__FUNCTION__
,
function
);
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to adequately read parameter: %d.
\n
"
,
driverName
,
__FUNCTION__
,
function
);
status
=
asynError
;
}
...
...
@@ -111,25 +103,20 @@ asynStatus VMMTbl::readInt32(asynUser *pasynUser, epicsInt32 *value) {
callParamCallbacks
();
return
status
;
}
asynStatus
VMMTbl
::
readOctet
(
asynUser
*
pasynUser
,
char
*
value
,
size_t
nChars
,
size_t
*
nActual
,
int
*
eomReason
)
{
asynStatus
status
=
asynSuccess
;
asynStatus
VMMTbl
::
readOctet
(
asynUser
*
pasynUser
,
char
*
value
,
size_t
nChars
,
size_t
*
nActual
,
int
*
eomReason
)
{
asynStatus
status
=
asynSuccess
;
vmmStatus
result
;
int
function
=
pasynUser
->
reason
;
int
function
=
pasynUser
->
reason
;
std
::
string
read
=
""
;
/* If this parameter belongs to a base class call its method */
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
);
if
(
param_index
>=
0
)
{
result
=
this
->
pVmmAPI
->
readFwVersion
(
param_index
,
read
);
...
...
@@ -148,16 +135,15 @@ asynStatus VMMTbl::readOctet(asynUser *pasynUser, char *value,
goto
endOfReadOctet
;
}
endOfReadOctet
:
endOfReadOctet
:
if
(
param_index
<
0
)
{
value
[
0
]
=
'\0'
;
*
nActual
=
1
;
return
asynError
;
}
if
(
result
!=
vmmSuccess
)
{
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to adequately read parameter: %d.
\n
"
,
driverName
,
__FUNCTION__
,
function
);
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to adequately read parameter: %d.
\n
"
,
driverName
,
__FUNCTION__
,
function
);
status
=
asynError
;
}
size_t
copy_size
=
std
::
min
(
read
.
size
(),
nChars
);
...
...
@@ -169,93 +155,84 @@ asynStatus VMMTbl::readOctet(asynUser *pasynUser, char *value,
callParamCallbacks
();
return
status
;
}
asynStatus
VMMTbl
::
createParamAndStoreInVector
(
std
::
string
paramName
,
asynParamType
typ
,
std
::
vector
<
int
>*
vectorToStore
){
std
::
vector
<
int
>
*
vectorToStore
)
{
int
paramIndex
;
asynStatus
status
=
createParam
(
paramName
.
c_str
(),
typ
,
&
paramIndex
);
if
(
status
!=
asynSuccess
)
{
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to create paramter %s.
\n
"
,
driverName
,
__FUNCTION__
,
paramName
.
c_str
());
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to create paramter %s.
\n
"
,
driverName
,
__FUNCTION__
,
paramName
.
c_str
());
return
asynError
;
}
vectorToStore
->
push_back
(
paramIndex
);
return
asynSuccess
;
}
asynStatus
VMMTbl
::
createEpicsParams
()
{
createParam
(
"REG_BANK_VERSION"
,
asynParamInt32
,
&
vmmRegBankVersion
);
createParam
(
"VMM_FEN_ACQUIRE"
,
asynParamInt32
,
&
vmmAcquire_
);
createParam
(
"VMM_FEN_ACQUIRING"
,
asynParamInt32
,
&
vmmIsAcquiring_
);
createParam
(
"IOC_MESSAGE"
,
asynParamOctet
,
&
IOCMessage
);
std
::
tuple
<
std
::
string
,
asynParamType
,
std
::
vector
<
int
>*>
hyb_params_to_create
[
7
]
=
{
{
"_FW_VERSION"
,
asynParamOctet
,
&
vmmHybFwVersion_
},
{
"_ID"
,
asynParamOctet
,
&
vmmHybId_
},
{
"_GEOPOS"
,
asynParamOctet
,
&
vmmHybGeoPos_
},
{
"_LINK_STATUS"
,
asynParamInt32
,
&
vmmHybLinkStatus_
},
{
"_SKEW"
,
asynParamInt32
,
&
vmmHybSkew_
},
{
"_WIDTH"
,
asynParamInt32
,
&
vmmHybWidth_
},
{
"_POLARITY"
,
asynParamInt32
,
&
vmmHybPolarity_
}};
std
::
tuple
<
std
::
string
,
asynParamType
,
std
::
vector
<
int
>
*>
hyb_params_to_create
[
7
]
=
{
{
"_FW_VERSION"
,
asynParamOctet
,
&
vmmHybFwVersion_
},
{
"_ID"
,
asynParamOctet
,
&
vmmHybId_
},
{
"_GEOPOS"
,
asynParamOctet
,
&
vmmHybGeoPos_
},
{
"_LINK_STATUS"
,
asynParamInt32
,
&
vmmHybLinkStatus_
},
{
"_SKEW"
,
asynParamInt32
,
&
vmmHybSkew_
},
{
"_WIDTH"
,
asynParamInt32
,
&
vmmHybWidth_
},
{
"_POLARITY"
,
asynParamInt32
,
&
vmmHybPolarity_
}};
std
::
ostringstream
param_name
;
for
(
int
hyb
=
0
;
hyb
<
this
->
pVmmAPI
->
getNumHybrids
(
true
);
hyb
++
)
{
for
(
const
auto
&
hyb_param
:
hyb_params_to_create
){
const
std
::
string
&
key
=
std
::
get
<
0
>
(
hyb_param
);
for
(
const
auto
&
hyb_param
:
hyb_params_to_create
)
{
const
std
::
string
&
key
=
std
::
get
<
0
>
(
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
);
}
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
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SC"
;
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SC"
;
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
SC
);
param_name
.
str
(
""
);
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SL"
;
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SL"
;
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
SL
);
param_name
.
str
(
""
);
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_ST"
;
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_ST"
;
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
ST
);
param_name
.
str
(
""
);
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_STH"
;
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_STH"
;
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
STH
);
param_name
.
str
(
""
);
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SM"
;
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SM"
;
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
SM
);
param_name
.
str
(
""
);
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SD"
;
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SD"
;
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
SD
);
param_name
.
str
(
""
);
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SMX"
;
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_SMX"
;
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt8Array
,
&
SMX
);
param_name
.
str
(
""
);
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_ANALOGMON"
;
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_ANALOGMON"
;
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt32
,
&
ADCIDX
);
param_name
.
str
(
""
);
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_ADCVAL"
;
param_name
<<
"HYB_"
<<
hyb
<<
"_"
<<
vmm
<<
"_ADCVAL"
;
createParamAndStoreInVector
(
param_name
.
str
(),
asynParamInt32
,
&
ADCVAL
);
}
this
->
vmmSC_
.
push_back
(
SC
);
...
...
@@ -267,14 +244,12 @@ asynStatus VMMTbl::createEpicsParams() {
this
->
vmmSMX_
.
push_back
(
SMX
);
this
->
vmmADCIDX_
.
push_back
(
ADCIDX
);
this
->
vmmADCVAL_
.
push_back
(
ADCVAL
);
}
return
asynSuccess
;
}
asynStatus
VMMTbl
::
writeInt32
(
asynUser
*
pasynUser
,
epicsInt32
value
)
{
asynStatus
status
=
asynSuccess
;
vmmStatus
vmm_stat
=
vmmSuccess
;
bool
is_acquiring
;
...
...
@@ -286,7 +261,6 @@ asynStatus VMMTbl::writeInt32(asynUser *pasynUser, epicsInt32 value) {
}
if
(
function
==
vmmAcquire_
)
{
vmm_stat
=
this
->
pVmmAPI
->
isAcquiring
(
is_acquiring
);
if
(
is_acquiring
==
(
bool
)
value
)
{
setStringParam
(
IOCMessage
,
"Set to acquire/stop but already acquiring/stopped."
);
...
...
@@ -296,10 +270,9 @@ asynStatus VMMTbl::writeInt32(asynUser *pasynUser, epicsInt32 value) {
}
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
);
if
(
param_index
>=
0
)
{
vmm_stat
=
this
->
pVmmAPI
->
setSkew
(
param_index
,
value
);
...
...
@@ -324,7 +297,7 @@ asynStatus VMMTbl::writeInt32(asynUser *pasynUser, epicsInt32 value) {
goto
endOfWriteInt32
;
}
endOfWriteInt32
:
endOfWriteInt32
:
if
(
param_index
<
0
)
{
status
=
asynError
;
}
...
...
@@ -334,15 +307,13 @@ asynStatus VMMTbl::writeInt32(asynUser *pasynUser, epicsInt32 value) {
callParamCallbacks
();
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
;
uint8_t
data_int
;
bool
data
;
const
char
*
paramName
;
const
char
*
paramName
;
function
=
pasynUser
->
reason
;
getParamName
(
function
,
&
paramName
);
...
...
@@ -412,11 +383,10 @@ asynStatus VMMTbl::readInt8Array(asynUser *pasynUser, epicsInt8 *value, size_t n
goto
endOfReadInt8Array
;
}
endOfReadInt8Array
:
endOfReadInt8Array
:
if
(
found_param
!=
0
)
{
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to find paramter %s, index %d.
\n
"
,
driverName
,
__FUNCTION__
,
paramName
,
function
);
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to find paramter %s, index %d.
\n
"
,
driverName
,
__FUNCTION__
,
paramName
,
function
);
*
nIn
=
0
;
return
asynError
;
}
...
...
@@ -424,21 +394,17 @@ asynStatus VMMTbl::readInt8Array(asynUser *pasynUser, epicsInt8 *value, size_t n
*
nIn
=
nElements
;
if
(
status
)
{
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to get paramter %s, index %d.
\n
"
,
driverName
,
__FUNCTION__
,
paramName
,
function
);
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to get paramter %s, index %d.
\n
"
,
driverName
,
__FUNCTION__
,
paramName
,
function
);
return
asynError
;
}
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
;
const
char
*
paramName
;
const
char
*
paramName
;
function
=
pasynUser
->
reason
;
getParamName
(
function
,
&
paramName
);
...
...
@@ -501,58 +467,51 @@ asynStatus VMMTbl::writeInt8Array(asynUser *pasynUser, epicsInt8 *value, size_t
goto
endOfWriteInt8Array
;
}
endOfWriteInt8Array
:
status
|=
(
int
)
doCallbacksInt8Array
(
value
,
nElements
,
function
,
0
);
// Comparing different statuses, yes.
endOfWriteInt8Array
:
status
|=
(
int
)
doCallbacksInt8Array
(
value
,
nElements
,
function
,
0
);
// Comparing different statuses, yes.
if
(
found_param
!=
0
)
{
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to find paramter %s, index %d.
\n
"
,
driverName
,
__FUNCTION__
,
paramName
,
function
);
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to find paramter %s, index %d.
\n
"
,
driverName
,
__FUNCTION__
,
paramName
,
function
);
return
asynError
;
}
if
(
status
)
{
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to set paramter %s.
\n
"
,
driverName
,
__FUNCTION__
,
paramName
);
asynPrint
(
pasynUserSelf
,
ASYN_TRACE_ERROR
,
"%s:%s: Failed to set paramter %s.
\n
"
,
driverName
,
__FUNCTION__
,
paramName
);
return
asynError
;
}
return
asynSuccess
;
}
extern
"C"
{
static
void
VMMTblConfig
(
const
char
*
RMMPortName
,
const
char
*
FENPortName
,
int
ring
,
int
hybrids
)
{
int
node
=
0
;
// VMM use always only the Node 0
RMM
*
pRMM
;
pRMM
=
(
RMM
*
)
findAsynPortDriver
(
RMMPortName
);
if
(
pRMM
!=
nullptr
)
{
new
VMMTbl
(
pRMM
,
FENPortName
,
ring
,
node
,
hybrids
);
}
else
{
std
::
cerr
<<
"Error: Failed to find RMM for port "
<<
RMMPortName
<<
std
::
endl
;
}
static
void
VMMTblConfig
(
const
char
*
RMMPortName
,
const
char
*
FENPortName
,
int
ring
,
int
hybrids
)
{
int
node
=
0
;
// VMM use always only the Node 0
RMM
*
pRMM
;
pRMM
=
(
RMM
*
)
findAsynPortDriver
(
RMMPortName
);
if
(
pRMM
!=
nullptr
)
{
new
VMMTbl
(
pRMM
,
FENPortName
,
ring
,
node
,
hybrids
);
}
else
{
std
::
cerr
<<
"Error: Failed to find RMM for port "
<<
RMMPortName
<<
std
::
endl
;
}
}
static
const
iocshArg
configArg0
=
{
"RMM Port name"
,
iocshArgString
};
static
const
iocshArg
configArg1
=
{
"Front End Port Name"
,
iocshArgString
};
static
const
iocshArg
configArg2
=
{
"Ring"
,
iocshArgInt
};
static
const
iocshArg
configArg3
=
{
"Hybrids"
,
iocshArgInt
};
static
const
iocshArg
configArg0
=
{
"RMM Port name"
,
iocshArgString
};
static
const
iocshArg
configArg1
=
{
"Front End Port Name"
,
iocshArgString
};
static
const
iocshArg
configArg2
=
{
"Ring"
,
iocshArgInt
};
static
const
iocshArg
configArg3
=
{
"Hybrids"
,
iocshArgInt
};
static
const
iocshArg
*
const
configArgs
[]
=
{
&
configArg0
,
&
configArg1
,
&
configArg2
,
&
configArg3
};
static
const
iocshArg
*
const
configArgs
[]
=
{
&
configArg0
,
&
configArg1
,
&
configArg2
,
&
configArg3
};
static
const
iocshFuncDef
configFuncDef
=
{
"VMMTblConfig"
,
4
,
configArgs
};
static
const
iocshFuncDef
configFuncDef
=
{
"VMMTblConfig"
,
4
,
configArgs
};
static
void
configCallFunc
(
const
iocshArgBuf
*
args
)
{
VMMTblConfig
(
args
[
0
].
sval
,
args
[
1
].
sval
,
args
[
2
].
ival
,
args
[
3
].
ival
);
}
static
void
configCallFunc
(
const
iocshArgBuf
*
args
)
{
VMMTblConfig
(
args
[
0
].
sval
,
args
[
1
].
sval
,
args
[
2
].
ival
,
args
[
3
].
ival
);
}
static
void
VMMTblRegister
(
void
)
{
iocshRegister
(
&
configFuncDef
,
configCallFunc
);
}
static
void
VMMTblRegister
(
void
)
{
iocshRegister
(
&
configFuncDef
,
configCallFunc
);
}
epicsExportRegistrar
(
VMMTblRegister
);
}
// end extern "C"
\ No newline at end of file
epicsExportRegistrar
(
VMMTblRegister
);
}
// end extern "C"
\ 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
#include
"rmm.h"
#include
"VMMAPI.h"
#include
"Utils.h"
#include
"VMMAPI.h"
#include
"rmm.h"
/* Struct to hold Hyb, VMM and epics parameter values */
struct
ParamValues
{
...
...
@@ -12,21 +12,20 @@ struct ParamValues {
/** Class definition for the VMMTbl class */
class
VMMTbl
:
public
asynPortDriver
{
public:
VMMTbl
(
RMM
*
rmm
,
const
char
*
FENPortName
,
int
ring
,
int
node
,
int
hybrids
);
public:
VMMTbl
(
RMM
*
rmm
,
const
char
*
FENPortName
,
int
ring
,
int
node
,
int
hybrids
);
/* Epics parameter management */
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
writeInt8Array
(
asynUser
*
pasynUser
,
epicsInt8
*
value
,
size_t
nElements
);
virtual
asynStatus
readInt8Array
(
asynUser
*
pasynUser
,
epicsInt8
*
value
,
size_t
nElements
,
size_t
*
nIn
);
virtual
asynStatus
readInt32
(
asynUser
*
pasynUser
,
epicsInt32
*
value
);
virtual
asynStatus
readOctet
(
asynUser
*
pasynUser
,
char
*
value
,
size_t
maxChars
,
size_t
*
nActual
,
int
*
eomReason
);
asynStatus
createParamAndStoreInVector
(
std
::
string
paramName
,
asynParamType
typ
,
std
::
vector
<
int
>*
vectorToStore
);
asynStatus
createParamAndStoreInVector
(
std
::
string
paramName
,
asynParamType
typ
,
std
::
vector
<
int
>
*
vectorToStore
);
protected:
protected:
int
vmmRegBankVersion
;
#define FIRST_VMM_PARAM vmmRegBankVersion
int
vmmSelectMonitorVMM0_
;
...
...
@@ -54,7 +53,7 @@ protected:
std
::
vector
<
std
::
vector
<
int
>>
vmmADCIDX_
;
std
::
vector
<
std
::
vector
<
int
>>
vmmADCVAL_
;
private:
private:
static
constexpr
const
char
*
driverName
=
"VMMTbl"
;
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