Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
NADS_DDSLIB
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
NADS-Public
NADS_DDSLIB
Commits
31b3817b
Commit
31b3817b
authored
May 01, 2019
by
Heitbrink, David A
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added missing Heartbeat, and state ack to client
parent
2760b4b1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
7 deletions
+65
-7
DDSSimClient.cpp
DDSSimClient.cpp
+62
-4
DDSSimClient.h
include/NadsDDSLib/DDSSimClient.h
+3
-3
No files found.
DDSSimClient.cpp
View file @
31b3817b
...
@@ -29,7 +29,7 @@ namespace NDDSClient {
...
@@ -29,7 +29,7 @@ namespace NDDSClient {
auto
&
cellIn
=
cell
.
second
;
auto
&
cellIn
=
cell
.
second
;
cellIn
->
_sub
->
SwapBuffer
();
cellIn
->
_sub
->
SwapBuffer
();
size_t
size
=
cellIn
->
_sub
->
GetSizeInByes
();
size_t
size
=
cellIn
->
_sub
->
GetSizeInByes
();
if
(
cellIn
->
_size
==
size
)
{
if
(
cellIn
->
_size
>=
size
)
{
//the raw publication can be of variable length, DDS may trim un-needed data;
void
*
ptr
=
cellIn
->
_sub
->
GetRaw
();
void
*
ptr
=
cellIn
->
_sub
->
GetRaw
();
apex
::
memcpy
(
cellIn
->
_target
,
ptr
,
size
);
apex
::
memcpy
(
cellIn
->
_target
,
ptr
,
size
);
}
}
...
@@ -89,14 +89,32 @@ namespace NDDSClient {
...
@@ -89,14 +89,32 @@ namespace NDDSClient {
}
}
}
}
void
DDSSimClient
::
RegisterStartup
(
DDSSimClient
::
TStartCBRef
)
{
void
DDSSimClient
::
RegisterStartup
(
DDSSimClient
::
TStartCBRef
cb
)
{
_StartupCBs
.
push_back
(
cb
);
}
}
void
DDSSimClient
::
RegisterFrameCB
(
DDSSimClient
::
TFrameCBRef
)
{
void
DDSSimClient
::
RegisterFrameCB
(
DDSSimClient
::
TFrameCBRef
ref
)
{
_FrameCBs
.
push_back
(
ref
);
}
}
DDSSimClient
::
DDSSimClient
()
:
NADSDDS
::
CState
::
Callback
(),
_currentFrame
(
-
1
),
_Started
(
false
)
{}
DDSSimClient
::
DDSSimClient
()
:
NADSDDS
::
CState
::
Callback
(),
_currentFrame
(
-
1
),
_Started
(
false
)
{}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// \fn void DDSSimClient::OnFrame(int frame)
///
/// \brief Executes the frame action
/// This function:
/// Read in the Frame data, copies Publication data, out to host apps varaibles
/// Call back to the host App -> have it runs its frame
/// Write The Host Apps registered varaibles out as a publication
///
/// \author Simop
/// \date 5/1/2019
///
/// \param frame The frame.
////////////////////////////////////////////////////////////////////////////////////////////////////
void
DDSSimClient
::
OnFrame
(
int
frame
)
{
void
DDSSimClient
::
OnFrame
(
int
frame
)
{
_currentFrame
=
frame
;
_currentFrame
=
frame
;
NADSDDS
::
CState
cs
;
NADSDDS
::
CState
cs
;
...
@@ -109,10 +127,47 @@ namespace NDDSClient {
...
@@ -109,10 +127,47 @@ namespace NDDSClient {
_HeartBeat
->
asShort
()[
0
]
++
;
_HeartBeat
->
asShort
()[
0
]
++
;
_HeartBeat
->
Publish
();
_HeartBeat
->
Publish
();
}
}
for
(
auto
&
cb
:
_FrameCBs
)
{
bool
stateOK
=
true
;
if
(
auto
frameCB
=
cb
.
lock
())
{
if
(
!
frameCB
->
Frame
(
*
this
,
state
,
frame
))
stateOK
=
false
;
}
if
(
!
stateOK
)
_StateAck
->
asInt
()[
0
]
=
-
1
;
else
_StateAck
->
asInt
()[
0
]
=
state
;
_StateAck
->
Publish
();
}
_omap
.
WriteOutputElements
();
_omap
.
WriteOutputElements
();
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// \fn void DDSSimClient::StartUp()
///
/// \brief Signal to connected clients its time to startup
///
/// This registration of publications and subscriptions should happen based on callbacks here
/// \author Simop
/// \date 5/1/2019
////////////////////////////////////////////////////////////////////////////////////////////////////
void
DDSSimClient
::
StartUp
()
{
void
DDSSimClient
::
StartUp
()
{
string
stateAck
=
"_StateAck_"
+
_name
;
string
heartBeat
=
"_HeartBeat_"
+
_name
;
_HeartBeat
=
NADSDDS
::
CPublication
::
MakePublication
(
stateAck
,
-
1
,
1
,
's'
);
_StateAck
=
NADSDDS
::
CPublication
::
MakePublication
(
heartBeat
,
-
1
,
1
,
'i'
);
for
(
auto
&
cb
:
_StartupCBs
)
{
if
(
auto
startCB
=
cb
.
lock
())
{
startCB
->
Startup
(
*
this
);
}
}
_Started
=
true
;
}
}
void
DDSSimClient
::
RegInputCell
(
const
std
::
string
&
name
,
void
*
pnt
,
size_t
size
,
char
type
)
{
void
DDSSimClient
::
RegInputCell
(
const
std
::
string
&
name
,
void
*
pnt
,
size_t
size
,
char
type
)
{
...
@@ -139,9 +194,12 @@ namespace NDDSClient {
...
@@ -139,9 +194,12 @@ namespace NDDSClient {
/// \returns A DDSSimClient::TRef.
/// \returns A DDSSimClient::TRef.
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
DDSSimClient
::
TRef
DDSSimClient
::
Make
(
TFrameCBRef
frame
,
TStartCBRef
startup
)
{
DDSSimClient
::
TRef
DDSSimClient
::
Make
(
TFrameCBRef
frame
,
TStartCBRef
startup
,
const
std
::
string
&
name
)
{
//this most likely should use a proxy obj so we can use make_shared
//this most likely should use a proxy obj so we can use make_shared
auto
ptr
=
DDSSimClient
::
TRef
(
new
DDSSimClient
());
auto
ptr
=
DDSSimClient
::
TRef
(
new
DDSSimClient
());
ptr
->
_name
=
name
;
ptr
->
RegisterFrameCB
(
frame
);
ptr
->
RegisterFrameCB
(
frame
);
ptr
->
RegisterStartup
(
startup
);
ptr
->
RegisterStartup
(
startup
);
ptr
->
StartUp
();
ptr
->
StartUp
();
...
...
include/NadsDDSLib/DDSSimClient.h
View file @
31b3817b
...
@@ -135,7 +135,7 @@ namespace NDDSClient {
...
@@ -135,7 +135,7 @@ namespace NDDSClient {
void
RegisterFrameCB
(
TFrameCBRef
);
void
RegisterFrameCB
(
TFrameCBRef
);
virtual
void
OnFrame
(
int
frame
);
virtual
void
OnFrame
(
int
frame
);
static
TRef
Make
(
TFrameCBRef
,
TStartCBRef
);
static
TRef
Make
(
TFrameCBRef
,
TStartCBRef
,
const
std
::
string
&
name
);
//char
//char
void
RegInputCell
(
const
std
::
string
&
name
,
char
*
pnt
,
size_t
cnt
)
{
void
RegInputCell
(
const
std
::
string
&
name
,
char
*
pnt
,
size_t
cnt
)
{
...
@@ -222,11 +222,11 @@ namespace NDDSClient {
...
@@ -222,11 +222,11 @@ namespace NDDSClient {
void
StartUp
();
void
StartUp
();
void
RegInputCell
(
const
std
::
string
&
name
,
void
*
pnt
,
size_t
size
,
char
type
);
void
RegInputCell
(
const
std
::
string
&
name
,
void
*
pnt
,
size_t
size
,
char
type
);
void
RegOutputCell
(
const
std
::
string
&
name
,
void
*
pnt
,
size_t
size
,
char
type
);
void
RegOutputCell
(
const
std
::
string
&
name
,
void
*
pnt
,
size_t
size
,
char
type
);
std
::
vector
<
TFrameCBRef
>
_FrameCBs
;
std
::
vector
<
TFrameCB
W
Ref
>
_FrameCBs
;
std
::
vector
<
TStartCBWRef
>
_StartupCBs
;
std
::
vector
<
TStartCBWRef
>
_StartupCBs
;
NADSDDS
::
CPublication
::
TRef
_heartBeat
;
CCellInputMap
_map
;
CCellInputMap
_map
;
CCellOutputMap
_omap
;
CCellOutputMap
_omap
;
std
::
string
_name
;
int
_currentFrame
;
int
_currentFrame
;
bool
_Started
;
bool
_Started
;
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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