Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tango-ds
DeviceClasses
Acquisition
2D
AGIPD
Commits
b5e97a0e
Commit
b5e97a0e
authored
Dec 09, 2016
by
Yuelong Yu
Browse files
microcontroller tests
parent
e6889406
Changes
5
Hide whitespace changes
Inline
Side-by-side
agipdmc/AGIPDMC.cpp
View file @
b5e97a0e
...
...
@@ -154,6 +154,8 @@ void AGIPDMC::delete_device()
int
*
nRet
;
m_thData
->
join
((
void
**
)
&
nRet
);
m_vlLTCCTemperatures
.
clear
();
/*----- PROTECTED REGION END -----*/
// AGIPDMC::delete_device
delete
[]
attr_Temperature1_read
;
...
...
@@ -187,6 +189,9 @@ void AGIPDMC::init_device()
/*----- PROTECTED REGION ID(AGIPDMC::init_device_before) ENABLED START -----*/
// Initialization before get_device_property() call
// if(attr_Temperature1_read != NULL)
// delete_device();
/*----- PROTECTED REGION END -----*/
// AGIPDMC::init_device_before
...
...
@@ -692,22 +697,9 @@ void AGIPDMC::start_uc()
{
DEBUG_STREAM
<<
"AGIPDMC::StartUC() - "
<<
device_name
<<
endl
;
/*----- PROTECTED REGION ID(AGIPDMC::start_uc) ENABLED START -----*/
// Add your own code
// if(m_nOpMode != -1)
// {
// Tango::Except::throw_exception((const char *)""
// ,"Please call power up cycle in sequence."
// ,(const char *)"");
// }
// else
// {
SetState
(
Tango
::
MOVING
);
{
omni_mutex_lock
l
(
m_mtxData
);
m_nOpMode
=
1
;
}
//}
SetStatus
(
"Starting microcontroller..."
);
RunCycle
(
1
);
/*----- PROTECTED REGION END -----*/
// AGIPDMC::start_uc
...
...
@@ -723,23 +715,11 @@ void AGIPDMC::start_master_fpga()
{
DEBUG_STREAM
<<
"AGIPDMC::StartMasterFPGA() - "
<<
device_name
<<
endl
;
/*----- PROTECTED REGION ID(AGIPDMC::start_master_fpga) ENABLED START -----*/
// if(m_nOpMode != 1)
// {
// Tango::Except::throw_exception((const char *)""
// ,"Please call power up cycle in sequence."
// ,(const char *)"");
// }
// else
// {
// Add your own code
SetState
(
Tango
::
MOVING
);
{
omni_mutex_lock
l
(
m_mtxData
);
m_nOpMode
=
2
;
}
//}
SetStatus
(
"Starting Master FPGA..."
);
RunCycle
(
2
);
/*----- PROTECTED REGION END -----*/
// AGIPDMC::start_master_fpga
}
//--------------------------------------------------------
...
...
@@ -766,8 +746,13 @@ void AGIPDMC::start_auxand_analog_voltage()
{
omni_mutex_lock
l
(
m_mtxData
);
m_nOpMode
=
3
;
WriteAttr
<
Tango
::
DevShort
>
(
"AUX"
,
1
);
WriteAttr
<
Tango
::
DevShort
>
(
"OpMode"
,
m_nOpMode
);
}
// }
SetStatus
(
"Starting AUX and analog voltage..."
);
RunCycle
(
3
);
/*----- PROTECTED REGION END -----*/
// AGIPDMC::start_auxand_analog_voltage
...
...
@@ -783,21 +768,9 @@ void AGIPDMC::start_vaccum_and_analog_cards()
{
DEBUG_STREAM
<<
"AGIPDMC::StartVaccumAndAnalogCards() - "
<<
device_name
<<
endl
;
/*----- PROTECTED REGION ID(AGIPDMC::start_vaccum_and_analog_cards) ENABLED START -----*/
// if(m_nOpMode != 3)
// {
// Tango::Except::throw_exception((const char *)""
// ,"Please call power up cycle in sequence."
// ,(const char *)"");
// }
// else
// {
// Add your own code
SetState
(
Tango
::
MOVING
);
{
omni_mutex_lock
l
(
m_mtxData
);
m_nOpMode
=
4
;
}
//}
SetStatus
(
"Starting AUX and analog cards..."
);
RunCycle
(
4
);
/*----- PROTECTED REGION END -----*/
// AGIPDMC::start_vaccum_and_analog_cards
...
...
@@ -813,22 +786,12 @@ void AGIPDMC::start_module_fpga()
{
DEBUG_STREAM
<<
"AGIPDMC::StartModuleFPGA() - "
<<
device_name
<<
endl
;
/*----- PROTECTED REGION ID(AGIPDMC::start_module_fpga) ENABLED START -----*/
// if(m_nOpMode != 4)
// {
// Tango::Except::throw_exception((const char *)""
// ,"Please call power up cycle in sequence."
// ,(const char *)"");
// }
// else
// {
// Add your own code
SetState
(
Tango
::
MOVING
);
{
omni_mutex_lock
l
(
m_mtxData
);
m_nOpMode
=
5
;
}
// }
SetStatus
(
"Starting module FPGAs..."
);
RunCycle
(
5
);
/*----- PROTECTED REGION END -----*/
// AGIPDMC::start_module_fpga
}
//--------------------------------------------------------
...
...
@@ -844,18 +807,99 @@ void AGIPDMC::start_asics()
/*----- PROTECTED REGION ID(AGIPDMC::start_asics) ENABLED START -----*/
// Add your own code
SetState
(
Tango
::
MOVING
);
{
omni_mutex_lock
l
(
m_mtxData
);
m_nOpMode
=
6
;
}
SetStatus
(
"Starting ASICs..."
);
RunCycle
(
6
);
/*----- PROTECTED REGION END -----*/
// AGIPDMC::start_asics
}
void
AGIPDMC
::
SetState
(
Tango
::
DevState
dState
)
{
set_state
(
dState
);
}
void
AGIPDMC
::
SetStatus
(
string
strMsg
)
{
set_status
(
strMsg
);
}
template
<
typename
T
>
bool
AGIPDMC
::
WriteAttr
(
string
strAttr
,
T
tVal
)
{
try
{
Tango
::
DeviceAttribute
objAttr
(
strAttr
,
tVal
);
m_sptrDP
->
write_attribute
(
objAttr
);
return
true
;
}
catch
(
Tango
::
DevFailed
&
df
)
{
cout
<<
"Tango::DevFailed exception during standard AGIPDMC::WriteAttr"
<<
endl
;
for
(
int
err
=
0
;
err
<
df
.
errors
.
length
();
err
++
)
{
cout
<<
"Error: "
<<
df
.
errors
[
err
].
desc
.
in
()
<<
endl
;
}
return
false
;
}
catch
(
exception
&
e
)
{
cout
<<
"write:"
<<
strAttr
<<
" error!!!"
<<
e
.
what
()
<<
endl
;
return
false
;
}
}
bool
AGIPDMC
::
RunCommand
(
string
strCmd
)
{
try
{
m_sptrDP
->
command_inout
(
strCmd
);
return
true
;
}
catch
(
Tango
::
DevFailed
&
df
)
{
cout
<<
"Tango::DevFailed exception during standard AGIPDMC::RunCommand"
<<
endl
;
for
(
int
err
=
0
;
err
<
df
.
errors
.
length
();
err
++
)
{
cout
<<
"Error: "
<<
df
.
errors
[
err
].
desc
.
in
()
<<
endl
;
}
return
false
;
}
catch
(
exception
&
e
)
{
cout
<<
"run command: error!!!"
<<
e
.
what
()
<<
endl
;
return
false
;
}
}
void
AGIPDMC
::
RunCycle
(
int
nMode
)
{
SetState
(
Tango
::
MOVING
);
bool
bTrue
=
WriteAttr
<
Tango
::
DevShort
>
(
"OpMode"
,
nMode
);
//aux and analog voltage
if
(
nMode
==
3
)
bTrue
=
bTrue
&&
WriteAttr
<
Tango
::
DevShort
>
(
"AUX"
,
1
);
//if device is in automatic mode
// check if automatic == 0
// automatic is not 0, then Execute command is necessary to update the matrix.
// otherwise, matrix will not be updated.
// automatic is 1 then it is not.
// bTrue = bTrue && RunCommand("Execute");
if
(
bTrue
)
{
omni_mutex_lock
l
(
m_mtxData
);
m_nOpMode
=
nMode
;
}
else
{
SetStatus
(
"This step is failed. Please retry it."
);
SetState
(
Tango
::
ON
);
}
}
/*----- PROTECTED REGION ID(AGIPDMC::namespace_ending) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/
// AGIPDMC::namespace_ending
...
...
agipdmc/AGIPDMC.h
View file @
b5e97a0e
...
...
@@ -384,6 +384,13 @@ public:
// Additional Method prototypes
void
CreateDynamicAttributes
();
void
SetState
(
Tango
::
DevState
dState
);
void
SetStatus
(
string
strMsg
);
template
<
typename
T
>
bool
WriteAttr
(
string
strAttr
,
T
tVal
);
bool
RunCommand
(
string
strCmd
);
void
RunCycle
(
int
nMode
);
...
...
agipdmc/MicroController.cpp
View file @
b5e97a0e
...
...
@@ -184,53 +184,64 @@ namespace AGIPDMC_ns
int
MicroController
::
PowerUpStep1
()
{
return
((
m_vshMatrix
[
POWER_UP_STATUS_1_INDEX
]
&
0xff00
)
>>
8
);
//return ((m_vshMatrix[POWER_UP_STATUS_1_INDEX] & 0xff00) >> 8);
sleep
(
5
);
return
0
;
}
int
MicroController
::
PowerUpStep2
()
{
short
shVal
=
(
m_vshMatrix
[
POWER_UP_STATUS_2_INDEX
]
&
0xff00
)
>>
8
;
switch
(
shVal
)
{
case
0
:
//not read yet
return
1
;
case
1
:
// no error
return
0
;
case
2
:
//wait
return
1
;
case
3
:
//error
return
2
;
default:
return
2
;
}
//
short shVal = (m_vshMatrix[POWER_UP_STATUS_2_INDEX] & 0xff00) >> 8;
//
switch(shVal)
//
{
//
case 0: //not read yet
//
return 1;
//
case 1: // no error
//
return 0;
//
case 2: //wait
//
return 1;
//
case 3: //error
//
return 2;
// }
sleep
(
5
)
;
return
0
;
}
int
MicroController
::
PowerUpStep3
()
{
short
shVal
=
(
m_vshMatrix
[
POWER_UP_STATUS_3_INDEX
]
&
0xff00
)
>>
8
;
//
short shVal = (m_vshMatrix[POWER_UP_STATUS_3_INDEX] & 0xff00) >> 8;
//all modules are powered up
if
(
shVal
==
0xff
)
return
0
;
else
//should call again
return
1
;
// //all modules are powered up
// if(shVal == 0xff)
// return 0;
// else //should call again
// return 1;
sleep
(
5
);
return
0
;
}
int
MicroController
::
PowerUpStep4
()
{
sleep
(
5
);
return
0
;
}
int
MicroController
::
PowerUpStep5
()
{
//this step should be checked manually.
//there is no feed back from sub modules
return
1
;
//return 1;
sleep
(
5
);
return
0
;
}
int
MicroController
::
PowerUpStep6
()
{
//TODO : Check digital IO
sleep
(
5
);
return
0
;
}
}
agipdmc/MicroController.h
View file @
b5e97a0e
...
...
@@ -4,7 +4,7 @@
#include
<iostream>
#include
<vector>
#include
<math.h>
#include
<unistd.h>
namespace
AGIPDMC_ns
{
...
...
agipdmc/UpdateDataThread.cpp
View file @
b5e97a0e
...
...
@@ -47,7 +47,16 @@ namespace AGIPDMC_ns
int
UpdateDataThread
::
GetMatrixCounter
(
vector
<
short
>&
vshData
)
{
///TODO::read matrix counter
if
(
vshData
.
empty
()
&&
vshData
.
size
()
<
5000
)
return
-
1
;
short
shHigh
=
vshData
[
0
];
short
shLow
=
vshData
[
1
];
return
(((
int
)(
shLow
&
0xff
))
<<
24
+
(((
int
)(
shLow
&
0xff00
))
>>
8
)
<<
16
+
((
int
)(
shHigh
&
0xff
))
<<
8
+
((
int
)(
shHigh
&
0xff00
))
>>
8
);
}
void
UpdateDataThread
::
ReadOutSpectrum
(
string
strAttrName
)
...
...
@@ -225,14 +234,33 @@ namespace AGIPDMC_ns
m_nAccumulated
=
0
;
}
}
if
(
nRetVal
==
0
)
{
//last step
if
(
nMode
==
6
)
m_nRunningMode
=
1
;
switch
(
nMode
)
{
case
1
:
m_objAGIPDMC
->
SetStatus
(
"microcontroller is ready."
);
break
;
case
2
:
m_objAGIPDMC
->
SetStatus
(
"Master FPGA is ready."
);
break
;
case
3
:
m_objAGIPDMC
->
SetStatus
(
"AUX and analog voltage are ready."
);
break
;
case
4
:
m_objAGIPDMC
->
SetStatus
(
"AUX and analog cards are ready."
);
break
;
case
5
:
m_objAGIPDMC
->
SetStatus
(
"Module FPGAs are ready."
);
break
;
case
6
:
m_objAGIPDMC
->
WriteAttr
<
Tango
::
DevShort
>
(
"OpMode"
,
7
);
m_objAGIPDMC
->
SetStatus
(
"ASISs are ready. System is in normal operation."
);
m_nRunningMode
=
1
;
break
;
}
m_objAGIPDMC
->
SetState
(
Tango
::
ON
);
}
else
if
(
nRetVal
==
2
)
//failed
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment