Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F27035960
cheatsheet.c
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
cheatsheet.c
View Options
#include
"rosa/deluxe/DeluxeContext.hpp"
std
::
unique_ptr
<
DeluxeContext
>
C
=
DeluxeContext
::
create
(
"Deluxe"
);
// sensor
C
->
createSensor
<
Input
,
output
>
(
name
,
// lambda function
[](
std
::
pair
<
input
,
bool
>
I
)
->
void
{
// automatically pushes its value to the
// connected agent
});
// ---------------------------------------------------------------------------
// communication with 1 other agent
// ---------------------------------------------------------------------------
// Handlerfunctions have to be the corresponding std::functions
// singe input singe output
C
->
createAgent
(
Name
,
Handlerfunction
(
// lambda function
[](
std
::
pair
<
InputType
,
bool
>
I
)
->
optional
<
ResultType
>
{
//...
// return {value};
}));
// multi input single output
C
->
createAgent
(
Name
,
Handlerfunction
(
// lambda function
[](
std
::
pair
<
DeluxeTuple
<
InputType1
,
InputType2
>
,
bool
>
I
)
->
optional
<
DeluxeTuple
<
ResultType
>>
{
//...
// DeluxeTuple<ResultType> output(value);
// return {output};
}));
// single input multi output
C
->
createAgent
(
Name
,
Handlerfunction
(
// lambda function
[](
std
::
pair
<
DeluxeTuple
<
InputType
>
,
bool
>
I
)
->
optional
<
DeluxeTuple
<
ResultType1
,
ResultType2
>>
{
//...
// DeluxeTuple<ResultType1, ResultType2>
// output(value1,value2);
// return {output};
}));
// multi in/out and handles results from master
C
->
createAgent
(
Name
,
// Master-input handler.
MasterHandlerfunction
(
// lambda function
[](
std
::
pair
<
DeluxeTuple
<
feedbackType
>
,
bool
>
I
)
->
void
{
// you can again return something to the master but i
// don't know at the moment the changes that would cause
//
//..
}),
// input handler.
Handlerfunction
(
// lambda function
[](
std
::
pair
<
DeluxeTuple
<
InputType1
,
InputType2
>
,
bool
>
I
)
->
optional
<
DeluxeTuple
<
ResultType1
,
ResultType2
>>
{
//...
// DeluxeTuple<ResultType1, ResultType2>
// output(value1,value2);
// return {output};
}));
// ---------------------------------------------------------------------------
// communication with n other agent
// ---------------------------------------------------------------------------
// I don't know how it reacts if input 1 is a DeluxeTuple and input 2 is just a
// value I'm just using all with DeluxeTuples
C
->
createAgent
(
Name
,
Handlerfunction
(
// lambda function
[](
std
::
pair
<
DeluxeTuples
<
SlaveOutputs1
...
>
,
bool
>
I0
,
std
::
pair
<
DeluxeTuples
<
SlaveOutputs2
...
>
,
bool
>
I1
,
std
::
pair
<
DeluxeTuples
<
SlaveOutputs3
...
>
,
bool
>
I2
,
...)
->
std
::
tuple
<
Optional
<
DeluxeTuple
<
give_to_master
>>
,
Optional
<
DeluxeTuple
<
give_to_slave1
>>
,
Optional
<
DeluxeTuple
<
give_to_slave2
>>
,
Optional
<
DeluxeTuple
<
give_to_slave3
>>
,
...
>
;
{
// ...
// return {{for_master}, {for_slave_1}, {for_slave_1},
// {for_slave_1}};
}));
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Tue, Oct 27, 7:20 PM (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
407581
Default Alt Text
cheatsheet.c (3 KB)
Attached To
Mode
R20 SoC_Rosa_repo
Attached
Detach File
Event Timeline