generated from jobindjohn/obsidian-publish-mkdocs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved reference. Now adding code automatically also
- Loading branch information
Showing
34 changed files
with
197 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Activation | ||
|
||
::: cockpitdecks.buttons.activation.activation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Deck | ||
|
||
::: cockpitdecks.deck | ||
options: | ||
show_inheritance_diagram: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Cockpitdecks API | ||
|
||
Here are the main Cockpitdecks entities meant to be extended by developers | ||
|
||
- [`Representation`][representation] | ||
- [`Deck`][deck] | ||
- [`Deck Type`][resrouces.decktype] (Resource) | ||
- [`Instruction`][instruction] | ||
- [`Simulator`][simulator] | ||
|
||
- [`Activation`][activation] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Instruction | ||
|
||
::: cockpitdecks.instruction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Representation | ||
|
||
::: cockpitdecks.buttons.representation.representation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Deck Type | ||
|
||
::: cockpitdecks.decks.resources.decktype |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Simulator | ||
|
||
::: cockpitdecks.simulator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,3 +49,5 @@ type: push | |
specialty-icon: | ||
param1: value | ||
``` | ||
|
||
# Representation API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
To add a new simulator to Cockpitdecks, the developer has to create a new Simulator sub-class derived from `cockpitdecks.Simulator` (or one of its subclass). | ||
|
||
```python hl_lines="3-4" | ||
class SubLogicFlightSimulator(Simulator): | ||
|
||
name = "A2FS1" | ||
|
||
def __init__(self, cockpit, environ): | ||
|
||
``` | ||
|
||
# Simulator API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Activation occurs when a Button is requested to handle an Event. | ||
|
||
A first step consists of the Activation preparation and initialization. This occurs when the deck is installed and each page created. | ||
|
||
Initialization of the Activation will result in the creation of one or more Instructions. In the process, the Performer entity responsible for executing the Instruction is clearly identified. For example, CockpitInstruction are performed by the Cockpit entity, while SimulatorInstructions are executed by the simulator software. | ||
|
||
The initialization of the Activation result in a global status is_valid() that returns True if the Activation contains all information necessary for handling events. | ||
|
||
When the Button receives the event, it calls the activate() function on its activation, supplying the event. | ||
|
||
```py | ||
# In the Button class | ||
def activate(self, event) -> bool: | ||
result = self._activation.activate(event) | ||
if result: | ||
self.render() | ||
else: | ||
logger.warning("there was an issue handling the event") | ||
``` | ||
|
||
Activate() functions return the status of the execution, True if all instructions were carried out without error. | ||
|
||
The Activation activate() function always proceeds in similar patterns: | ||
|
||
1. It first checks whether the Activation is capable of handling the event. | ||
2. Depending on the event type, it executes one or more Instructions, collecting the result of the execution. | ||
3. When all Instructions have completed, it returns a global status for the entire Activation. | ||
|
||
Here is a pseudo-code that handles button press events: | ||
|
||
```py | ||
# In the Activation class | ||
def activate(self, event: PushEvent) -> bool: | ||
status = False | ||
if not self.can_handle(event): | ||
return False | ||
if not super().activate(event): | ||
return False | ||
if event.pressed: | ||
status = self.instruction.execute() | ||
return status # Normal termination | ||
``` | ||
|
||
From then on, the Button must decide what to do next, including if necessary regenerating its appearance. |
10 changes: 10 additions & 0 deletions
10
docs/Extending/Development/Internals/Data and Value Changes.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Cockpitdecks uses two types of value that can come from different sources: | ||
|
||
1. **Data** are simple *scalar* typed values (mainly string, float or integer). They can either come from the simulator software or Cockpitdecks internal values. | ||
2. **Value** are complex scalar typed values that depends on one or more **Data**. If the Value depends on more than one Data, a **Formula** is used to combined all Data together and ultimately provide a single final value. | ||
|
||
Values are used by buttons and observables. Values are used when there is a need to combine and modify raw values as provided by the simulator or by Cockpitdecks. | ||
|
||
Values are notified when one of its underlying Data has changed. This allows the Value to compute its new value. the Value in turn notifies the Button or the Observable that created it of its change. The Button or Observable can adjust as needed. | ||
|
||
Changes of Data value enter Cockpitdecks through Events. The SimulatorEvent (or one of its sub-class) is used to report the change of a value in the simulator software. The CockpitEvent (or one of its sub-class) to report change of value in the Cockpit. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Rendering occurs as follow. | ||
|
||
Request to render always starts from the Button. The Button solely calls the procedure render() on itself. | ||
|
||
To render a Page for example, the Page will call render() on each button in turn. It may then call a supplemental procedure to fill unused icons with images. | ||
|
||
The Button render() call is quickly transferred to the Deck for specific rendering handling. So the Button asks the Deck to render itself: | ||
|
||
```py | ||
# In the Button class | ||
def render(self) -> None: | ||
self.deck.render(self) | ||
``` | ||
|
||
From the button index, the Deck will deduce rendering possibilities. It will then ask the button to supply the data for the rendering. | ||
|
||
```py | ||
# In the Deck class | ||
def render(self, button: Button) -> None: | ||
button_representation = button.get_representation() | ||
render_data = button_representation.render() | ||
# transform render_data if necessary | ||
# send it to device driver for handling (display, sound, coloring...) | ||
self.device.handle_data(render_data) | ||
``` | ||
|
||
In other words, the representation of the button is responsible to generate and provide whatever is necessary for the deck device driver. | ||
|
||
Let us take a very practical example. | ||
|
||
The deck device driver has a function to display an iconic image on a key. That function expects the index of the key to designate it unambiguously, and an image in JPG format with the proper size 90 × 90 pixels. | ||
|
||
If we use a generic representation that produces an image, the resulting image will be a 256 × 256 pixel transparent PNG image. We need to convert and resize that image before we can send it to the device driver. | ||
|
||
``` | ||
def render(self, button: Button) -> None: | ||
brep = button.get_representation() | ||
render_image = brep.render() | ||
# transform render_data if necessary | ||
keyicon = render_image.resize([90, 90]).convert("RGB") | ||
# send it to device driver for handling (display, sound, coloring...) | ||
self.device.set_key_image(key=button.inedx, image=keyicon) | ||
``` | ||
|
||
This is a very simple example, but it shows the flow of information and the sequence of calls to get the work done. | ||
|
||
To emit a sound, the representation render() function would be responsible for generating, for example, a sound file in WAV format. The deck render function would then pass that sound to the device driver play_sound() function that expects a sound file to play. | ||
|
||
To color a LED, the representation render() function would be responsible for generating a color and a light intensity (in 0..1 value range). THe deck render function would then pass those data to the device driver turn_led_on(color, intensity) function to submit appropriate instruction to the device to turn the light on with the desired color and intensity. | ||
|
||
People familiar with internet web development knowledge can follow the process for (Virtual) Web Decks. The device driver of Web Deck (called VirtualDeck) is a relatively straightforward JSON message generator and ultimately sends the message to the browser for display. In the browser, JavaScript process decodes the message and interpret it to display an image, play a sound, or refresh an entire page. (Communication occurs in a WebSocket channel.) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.