Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SHS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
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
Marco Kurzynski
SHS
Commits
b1f3cf64
Commit
b1f3cf64
authored
2 years ago
by
Marco Kurzynski
Browse files
Options
Downloads
Patches
Plain Diff
checkpoint
parent
8424a252
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/client.cc
+32
-6
32 additions, 6 deletions
src/client.cc
src/server.cc
+6
-7
6 additions, 7 deletions
src/server.cc
src/shs.proto
+7
-3
7 additions, 3 deletions
src/shs.proto
with
45 additions
and
16 deletions
src/client.cc
+
32
−
6
View file @
b1f3cf64
...
@@ -39,7 +39,8 @@ using grpc::CompletionQueue;
...
@@ -39,7 +39,8 @@ using grpc::CompletionQueue;
using
grpc
::
Status
;
using
grpc
::
Status
;
using
shs
::
Image
;
using
shs
::
Image
;
using
shs
::
Node
;
using
shs
::
Node
;
using
shs
::
Request
;
using
shs
::
ImageRequest
;
using
shs
::
Telemetry
;
template
<
size_t
NUM_CHANNELS
>
class
NodeClient
{
template
<
size_t
NUM_CHANNELS
>
class
NodeClient
{
public:
public:
...
@@ -50,8 +51,8 @@ public:
...
@@ -50,8 +51,8 @@ public:
}
}
}
}
void
Exposur
e
()
{
void
FetchImag
e
()
{
Request
request
;
Image
Request
request
;
request
.
set_milliseconds
(
2
);
request
.
set_milliseconds
(
2
);
for
(
int
i
=
0
;
i
<
NUM_CHANNELS
;
i
++
)
{
for
(
int
i
=
0
;
i
<
NUM_CHANNELS
;
i
++
)
{
readers_
[
i
]
=
readers_
[
i
]
=
...
@@ -71,8 +72,8 @@ public:
...
@@ -71,8 +72,8 @@ public:
private
:
private
:
class
Reader
:
public
grpc
::
ClientReadReactor
<
Image
>
{
class
Reader
:
public
grpc
::
ClientReadReactor
<
Image
>
{
public:
public:
Reader
(
Node
::
Stub
*
stub
,
const
Request
&
request
,
int
i
)
:
i_
(
i
)
{
Reader
(
Node
::
Stub
*
stub
,
const
Image
Request
&
request
,
int
i
)
:
i_
(
i
)
{
stub
->
async
()
->
Exposur
e
(
&
context_
,
&
request
,
this
);
stub
->
async
()
->
FetchImag
e
(
&
context_
,
&
request
,
this
);
StartCall
();
StartCall
();
StartRead
(
&
reply_
);
StartRead
(
&
reply_
);
}
}
...
@@ -84,6 +85,31 @@ private:
...
@@ -84,6 +85,31 @@ private:
}
}
}
}
void
OnDone
(
const
Status
&
s
)
override
{
void
OnDone
(
const
Status
&
s
)
override
{
Telemetry
reply
;
ClientContext
context
;
std
::
mutex
mu
;
std
::
condition_variable
cv
;
bool
done
=
false
;
Status
status
;
stub_
->
async
()
->
FetchTelemetry
(
&
context
,
&
request
,
&
reply
,
[
&
mu
,
&
cv
,
&
done
,
&
status
](
Status
s
)
{
status
=
std
::
move
(
s
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mu
);
done
=
true
;
cv
.
notify_one
();
});
std
::
unique_lock
<
std
::
mutex
>
lock
(
mu
);
cv
.
wait
(
lock
,
[]{
return
done
;
});
if
(
!
status
.
ok
())
{
std
::
cout
<<
status
.
error_code
()
<<
": "
<<
status
.
error_message
()
<<
std
::
endl
;
return
;
}
uint64_t
unixseconds
=
reply
.
unixseconds
();
// save picture
// save picture
int
status
=
0
;
int
status
=
0
;
long
naxes
[]
=
{
1920
,
1200
};
long
naxes
[]
=
{
1920
,
1200
};
...
@@ -129,7 +155,7 @@ int main(int argc, char **argv) {
...
@@ -129,7 +155,7 @@ int main(int argc, char **argv) {
grpc
::
InsecureChannelCredentials
()),
grpc
::
InsecureChannelCredentials
()),
};
};
NodeClient
<
1
>
Node
(
channels
);
NodeClient
<
1
>
Node
(
channels
);
Node
.
Exposur
e
();
Node
.
FetchImag
e
();
return
0
;
return
0
;
}
}
This diff is collapsed.
Click to expand it.
src/server.cc
+
6
−
7
View file @
b1f3cf64
...
@@ -22,7 +22,7 @@ using grpc::ServerWriteReactor;
...
@@ -22,7 +22,7 @@ using grpc::ServerWriteReactor;
using
grpc
::
Status
;
using
grpc
::
Status
;
using
shs
::
Image
;
using
shs
::
Image
;
using
shs
::
Node
;
using
shs
::
Node
;
using
shs
::
Request
;
using
shs
::
Image
Request
;
using
shs
::
Image
;
using
shs
::
Image
;
...
@@ -30,14 +30,13 @@ static AtikCamerasSDKApp app;
...
@@ -30,14 +30,13 @@ static AtikCamerasSDKApp app;
class
NodeServiceImpl
final
:
public
Node
::
CallbackService
{
class
NodeServiceImpl
final
:
public
Node
::
CallbackService
{
public:
public:
ServerWriteReactor
<
Image
>
*
Exposur
e
(
CallbackServerContext
*
context
,
ServerWriteReactor
<
Image
>
*
FetchImag
e
(
CallbackServerContext
*
context
,
const
Request
*
request
)
override
{
const
Image
Request
*
request
)
override
{
class
Streamer
:
public
ServerWriteReactor
<
Image
>
{
class
Streamer
:
public
ServerWriteReactor
<
Image
>
{
public:
public:
Streamer
(
const
Request
*
request
)
{
Streamer
(
const
Image
Request
*
request
)
{
app
.
Start
();
app
.
Start
();
memcpy
(
buff
,
app
.
StartExposure
(
request
->
milliseconds
()),
buff
=
(
uint16_t
*
)
app
.
StartExposure
(
request
->
milliseconds
());
1920
*
1200
*
sizeof
(
uint16_t
));
NextWrite
();
NextWrite
();
}
}
void
OnDone
()
override
{
void
OnDone
()
override
{
...
@@ -47,7 +46,7 @@ public:
...
@@ -47,7 +46,7 @@ public:
void
OnWriteDone
(
bool
)
override
{
NextWrite
();
}
void
OnWriteDone
(
bool
)
override
{
NextWrite
();
}
private
:
private
:
uint16_t
buff
[
1920
*
1200
]
;
uint16_t
*
buff
;
AtikCamerasSDKApp
app
;
AtikCamerasSDKApp
app
;
Image
image_
;
Image
image_
;
int
i_
=
0
;
int
i_
=
0
;
...
...
This diff is collapsed.
Click to expand it.
src/shs.proto
+
7
−
3
View file @
b1f3cf64
...
@@ -17,13 +17,17 @@ syntax = "proto3";
...
@@ -17,13 +17,17 @@ syntax = "proto3";
package
shs
;
package
shs
;
service
Node
{
service
Node
{
rpc
Exposure
(
Request
)
returns
(
stream
Image
)
{}
rpc
FetchImage
(
ImageRequest
)
returns
(
Image
)
{}
rpc
FetchTelemetry
(
google.protobuf.Empty
)
returns
(
Telemetry
)
{}
}
}
message
Request
{
message
Image
Request
{
uint32
milliseconds
=
1
;
uint32
milliseconds
=
1
;
}
}
message
Image
{
message
Image
{
bytes
imagedata
=
1
;
bytes
imagedata
=
1
;
}
}
message
Telemetry
{
uint64
unixseconds
=
1
;
}
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