Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F386601
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Size
3 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/apps/ccam/cheatsheet.c b/apps/ccam/cheatsheet.c
new file mode 100644
index 0000000..749478d
--- /dev/null
+++ b/apps/ccam/cheatsheet.c
@@ -0,0 +1,92 @@
+#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}};
+ }));
\ No newline at end of file
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Jul 3, 10:35 PM (17 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
157391
Default Alt Text
(3 KB)
Attached To
Mode
R20 SoC_Rosa_repo
Attached
Detach File
Event Timeline
Log In to Comment