|
| 1 | +The {$product.name$} [Git repository](https://github.com/secure-dev-ops/code-realtime/tree/main/art-samples) contains several sample applications. You can use them for learning about various features of the [Art language](art-lang/index.md) and the APIs provided by the [TargetRTS](target-rts/index.md). You can also use them as a starting point for creating your own applications with {$product.name$}. |
| 2 | + |
| 3 | +The samples are listed here in an order that may be appropriate when learning to use {$product.name$}, starting with the simplest examples and proceeding with more advanced ones. For each sample, Art language constructs and TargetRTS APIs that it uses, are listed, so you can find the sample that shows what you currently want to learn more about. To keep these lists short, we only list what is new in the sample compared to previously mentioned samples. |
| 4 | + |
| 5 | +## [HelloWorld](https://github.com/secure-dev-ops/code-realtime/tree/main/art-samples/HelloWorld) |
| 6 | +The most classical of samples for learning a new programming language. This version prints "Hello World!" on the console after a short delay, implemented by means of a timer. Watch [this video](https://youtu.be/TGpCqA63MxQ) to see how the sample was created. |
| 7 | + |
| 8 | +**Art:** [capsule](art-lang/index.md#capsule), [state machine](art-lang/index.md#state-machine), [initial transition](art-lang/index.md#initial-transition), [state](art-lang/index.md#state), timer [port](art-lang/index.md#port), triggered [transition](art-lang/index.md#transition), [embedded C++ code](art-lang/index.md#embedded-c-code) |
| 9 | + |
| 10 | +**TargetRTS:** [RTTiming](targetrts-api/class_timing_1_1_base.html)::informIn(), [RTController](targetrts-api/class_r_t_controller.html)::abort() |
| 11 | + |
| 12 | +## [PingPong](https://github.com/secure-dev-ops/code-realtime/tree/main/art-samples/PingPong) |
| 13 | +Two capsules, `Pinger` and `Ponger`, send the events `ping` and `pong` back and forth. The `ping` event has an integer parameter which gets incremented by one for each ping-pong round. The sample prints messages to stdout both using standard C++ code and with the Log service of the TargetRTS. |
| 14 | + |
| 15 | +**Art:** fixed [part](art-lang/index.md#part), [connector](art-lang/index.md#connector), service and behavior [port](art-lang/index.md#port), [protocol and event](art-lang/index.md#protocol-and-event), log [port](art-lang/index.md#port) |
| 16 | + |
| 17 | +**TargetRTS:** [RTOutSignal](targetrts-api/struct_r_t_out_signal.html)::send(), [Log](targetrts-api/struct_log.html)::log(), [Log](targetrts-api/struct_log.html)::show(), [Log](targetrts-api/struct_log.html)::commit() |
| 18 | + |
| 19 | +## [PingPongTimeDeltaTracker](https://github.com/secure-dev-ops/code-realtime/tree/main/art-samples/PingPongTimeDeltaTracker) |
| 20 | +While the standard [PingPong sample](#pingpong) runs forever, this version lets the user enter the number of ping-pong rounds at start-up. When the rounds are completed, information about how long it took is printed. |
| 21 | + |
| 22 | +**Art:** [choice](art-lang/index.md#choice-and-junction), [entry action](art-lang/index.md#entry-and-exit-action), [transition guard](art-lang/index.md#transition) |
| 23 | + |
| 24 | +**TargetRTS:** [RTTimespec](targetrts-api/struct_r_t_timespec.html)::getclock() |
| 25 | + |
| 26 | +## [PiComputer](https://github.com/secure-dev-ops/code-realtime/tree/main/art-samples/PiComputer) |
| 27 | +This application computes a value of Pi using [Madhava](https://en.wikipedia.org/wiki/Madhava_of_Sangamagrama)'s formula, which consists of a series of additions and multiplications. The result is obtained as a collaboration of three capsules, each with a simple state machine, which coordinate their work by sending events with parameters. |
| 28 | + |
| 29 | +**Art:** [composite state](art-lang/index.md#hierarchical-state-machine) (hierarchical state machine) |
| 30 | + |
| 31 | +## [TrafficLight](https://github.com/secure-dev-ops/code-realtime/tree/main/art-samples/TrafficLight) |
| 32 | +This sample implements a classical traffic light that switches between red, yellow and green based on a periodic timer. The actual traffic light is implemented by means of a class `Light` with a state machine. An instance of that class is managed by the `TrafficLight` capsule. The `Light` class uses an interface class `ILogger`, which the `TrafficLight` capsules implements, for logging messages when the traffic light switches state. It delegates the work of logging to a separate Logger capsule. Note that only the `ILogger` interface is provided to the `Light` object, instead of the whole `TrafficLight` capsule which has an unnecessary big API for the needs of the `Light`. |
| 33 | + |
| 34 | +**Art:** [class with state machine](art-lang/index.md#class-with-state-machine) |
| 35 | + |
| 36 | +**TargetRTS:** [RTTiming](targetrts-api/class_timing_1_1_base.html)::informEvery() |
| 37 | + |
| 38 | +## [DiningPhilosophers](https://github.com/secure-dev-ops/code-realtime/tree/main/art-samples/DiningPhilosophers) |
| 39 | +Two different implementations of the classical [Dining Philosophers problem](https://en.wikipedia.org/wiki/Dining_philosophers_problem). The applications implement 3 different strategies (represented by an enum) for how to let all philosophers eat and think without causing a deadlock. |
| 40 | + |
| 41 | +Version 1 of the sample uses fixed parts which are incarnated statically. The strategy to use is hard-coded into the application. |
| 42 | + |
| 43 | +Version 2 of the sample uses optional parts which are incarnated dynamically, and with initialization data passed to the initial transition of the capsule state machine. The strategy to use is read as input from the command-line. |
| 44 | + |
| 45 | +**Art:** initialization data passed to the [initial transition](art-lang/index.md#initial-transition), [automatically generated type descriptor](art-lang/cpp-extensions.md#automatically-generated) |
| 46 | + |
| 47 | +**TargetRTS:** [RTActor](targetrts-api/class_r_t_actor.html)::getName(), [RTMessage](targetrts-api/class_r_t_message.html)::sap(), [Frame](targetrts-api/class_frame_1_1_base.html)::incarnate() |
| 48 | + |
| 49 | +## [DependencyInjection](https://github.com/secure-dev-ops/code-realtime/tree/main/art-samples/DependencyInjection) |
| 50 | +This sample shows how to use [dependency injection](https://en.wikipedia.org/wiki/Dependency_injection) to customize capsule incarnation. Build variants are used for configuring how to customize the dependency injection, which will influence on how the application behaves. |
| 51 | + |
| 52 | +**Art:** [capsule inheritance](art-lang/index.md#capsule-inheritance), [capsule factory](target-rts/capsule-factory.md), [dependency injection](target-rts/dependency-injection.md), [build variants](building/build-variants.md) |
| 53 | + |
| 54 | +**TargetRTS:** [RTInjector](targetrts-api/class_r_t_injector.html), [RTActorFactoryInterface](targetrts-api/class_r_t_actor_factory_interface.html) |
| 55 | + |
| 56 | +## [QtTrafficLight](https://github.com/secure-dev-ops/code-realtime/tree/main/art-samples/QtTrafficLight) |
| 57 | +This application has a user interface developed with [Qt](https://www.qt.io/) which controls a realtime application that implements the logic of a traffic light that works together with a pedestrian light. |
| 58 | + |
| 59 | +**Art:** [composite state with entry- and exitpoint](art-lang/index.md#hierarchical-state-machine), [external port](target-rts/integrate-with-external-code.md#external-port), [notification port](art-lang/index.md#notification-port), [internal transition](art-lang/index.md#internal-transition) |
| 60 | + |
| 61 | +**TargetRTS:** [RTTiming](targetrts-api/class_timing_1_1_base.html)::cancelTimer() |
| 62 | + |
| 63 | +## [TcpRangeCounter](https://github.com/secure-dev-ops/code-realtime/tree/main/art-samples/TcpRangeCounter) |
| 64 | +This sample uses the [TCPServer library](https://github.com/secure-dev-ops/code-realtime/tree/main/art-samples/TcpServer) which makes it possible to communicate with the application from the "outside" by means of making TCP requests. A sample [Node.js client](https://github.com/secure-dev-ops/code-realtime/tree/main/art-samples/TcpRangeCounter/client) for making such requests is included. |
| 65 | + |
| 66 | +The sample also shows how to run a capsule instance in its own [thread](target-rts/threads.md). |
| 67 | + |
| 68 | +**Art:** [capsule constructor](art-lang/index.md#capsule-constructor) |
| 69 | + |
| 70 | +**TargetRTS:** [Frame](targetrts-api/class_frame_1_1_base.html)::incarnateCustom() |
| 71 | + |
| 72 | +## DistributedPingPong |
| 73 | +This sample uses the [TCPServer library](https://github.com/secure-dev-ops/code-realtime/tree/main/art-samples/TcpServer) for implementing a distributed application. Two instances of the PingPong application are launched and the TCPServer library ensures that the events that are sent out by one application, are serialized to JSON, sent over TCP and received by the other application. The applications are connected by means of command-line arguments that specify the application's own port, and the port of the other application. |
| 74 | + |
| 75 | +To start the communication, a special command-line argument `-injectFirstPing` is supported. The implementation of this argument uses APIs of [RTMessage](targetrts-api/class_r_t_message.html) for programmatically injecting an event on a port. |
| 76 | + |
| 77 | +**Art:** [timer data](target-rts/timers.md#timer-data), [symmetric events](art-lang/index.md#protocol-and-event), [calling code from an inherited transition](art-lang/index.md#calling-code-from-an-inherited-transition) |
| 78 | + |
| 79 | +**TargetRTS:** [RTMain](targetrts-api/class_r_t_main.html)::argCount(), [RTMain](targetrts-api/class_r_t_main.html)::argStrings(), [RTMemoryUtil](targetrts-api/class_r_t_memory_util.html), [RTMessage](targetrts-api/class_r_t_message.html), [RTController](targetrts-api/class_r_t_controller.html)::receive() |
| 80 | + |
| 81 | +## TokenRing |
| 82 | +This sample is similar to [DistributedPingPong](#distributedpingpong), and also uses the [TCPServer library](https://github.com/secure-dev-ops/code-realtime/tree/main/art-samples/TcpServer). But instead of just connecting two applications, here multiple applications can be connected in a ring structure. The applications exchange a `token` event which has a string (`RTString`) data parameter. |
| 83 | + |
| 84 | +**TargetRTS:** [RTString](targetrts-api/class_r_t_string.html) |
| 85 | + |
| 86 | +## gRPC_MazeRunner |
| 87 | +This sample uses the [gRPCServer library](https://github.com/secure-dev-ops/code-realtime/tree/main/art-samples/gRPCServer) which allows a realtime application to communicate using [gRPC](https://grpc.io/) with other applications. The sample also shows how to mix Art files with [hand-written C++ source files](building/build-cpp-files.md) and build them into a single application. |
| 88 | + |
| 89 | +**TargetRTS:** [RTOutSignal](targetrts-api/struct_r_t_out_signal.html)::invoke() |
0 commit comments