Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AmptekHardwareInterface
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Körnig, Christian Gabriel
AmptekHardwareInterface
Commits
2daa2ac0
Commit
2daa2ac0
authored
3 years ago
by
Christian Koernig
Browse files
Options
Downloads
Patches
Plain Diff
Added buffer slots to simulator
parent
66e088c0
Branches
master
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/AmptekSimulatorConnectionHandler.h
+2
-0
2 additions, 0 deletions
include/AmptekSimulatorConnectionHandler.h
src/AmptekSimulatorConnectionHandler.cpp
+31
-5
31 additions, 5 deletions
src/AmptekSimulatorConnectionHandler.cpp
with
33 additions
and
5 deletions
include/AmptekSimulatorConnectionHandler.h
+
2
−
0
View file @
2daa2ac0
...
...
@@ -24,7 +24,9 @@ private:
void
disable
();
void
clear
();
int
speclen
=
1024
;
int
buffer_depth
=
64
;
unsigned
int
*
spectrum
;
byte
*
spectrum_buffer
;
uint32_t
total_counts
;
double
acc_time
=
0
;
...
...
This diff is collapsed.
Click to expand it.
src/AmptekSimulatorConnectionHandler.cpp
+
31
−
5
View file @
2daa2ac0
...
...
@@ -69,13 +69,22 @@ Packet AmptekSimulatorConnectionHandler::sendAndReceive( const Packet& request){
p
.
setPid2
(
DP5_P2_SPECTRUM_RESPONSE_SPECTRUM8192_STATUS
);
break
;
}
word16
len
=
3
*
speclen
+
STATUS_SIZE
;
p
.
resize
(
MIN_PACKET_LEN
+
len
);
if
(
pid2
==
DP5_P2_SPECTRUM_REQUEST_SPECTRUM_STATUS
){
byte
arr
[
len
];
createSpectrumData
(
arr
);
createStatusData
(
arr
+
3
*
speclen
);
p
.
resize
(
MIN_PACKET_LEN
+
len
);
p
.
setData
(
arr
,
len
);
}
else
{
size_t
buffer_idx
=
(
request
.
at
(
DATA
)
<<
8
)
+
request
.
at
(
DATA
);
if
(
buffer_idx
>=
buffer_depth
){
return
Packet
(
DP5_P1_ACK
,
DP5_P2_ACK_BADPARAM_ERR
,
nullptr
,
0
);
}
byte
*
bufferslot
=
spectrum_buffer
+
(
(
3
*
speclen
+
STATUS_SIZE
)
*
buffer_idx
);
p
.
setData
(
bufferslot
,
len
);
}
}
else
if
(
pid1
==
Packet
::
DP5_PKT_REQUEST_STATUS
.
at
(
PID1
)
&&
pid2
==
Packet
::
DP5_PKT_REQUEST_STATUS
.
at
(
PID2
))
...
...
@@ -134,6 +143,22 @@ Packet AmptekSimulatorConnectionHandler::sendAndReceive( const Packet& request){
readConfig
(
configs
);
return
Packet
(
DP5_P1_ACK
,
DP5_P2_ACK_OK
,
nullptr
,
0
);
}
else
if
(
pid1
==
DP5_P1_SPECTRUM_REQUEST
&&
pid2
==
DP5_P2_SPECTRUM_REQUEST_BUFFER_CLEAR
)
{
size_t
buffer_idx
=
(
request
.
at
(
DATA
)
<<
8
)
+
request
.
at
(
DATA
);
if
(
buffer_idx
>=
buffer_depth
){
return
Packet
(
DP5_P1_ACK
,
DP5_P2_ACK_BADPARAM_ERR
,
nullptr
,
0
);
}
byte
*
bufferslot_spectrum
=
spectrum_buffer
+
(
(
3
*
speclen
+
STATUS_SIZE
)
*
buffer_idx
);
byte
*
bufferslot_status
=
bufferslot_spectrum
+
3
*
speclen
;
createSpectrumData
(
bufferslot_spectrum
);
createStatusData
(
bufferslot_status
);
clear
();
}
else
{
return
Packet
(
DP5_P1_ACK
,
DP5_P2_ACK_OK
,
nullptr
,
0
);
}
...
...
@@ -144,6 +169,7 @@ Packet AmptekSimulatorConnectionHandler::sendAndReceive( const Packet& request){
AmptekSimulatorConnectionHandler
::
AmptekSimulatorConnectionHandler
(){
spectrum
=
new
unsigned
int
[
speclen
];
spectrum_buffer
=
new
byte
[(
3
*
speclen
+
STATUS_SIZE
)
*
buffer_depth
];
start_time
=
std
::
chrono
::
system_clock
::
now
();
clear
();
initConfigs
();
...
...
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