Skip to content

Commit

Permalink
Merge pull request #179 from Eliott-Guevel/newInterfacesDetail
Browse files Browse the repository at this point in the history
New component visualization options details
  • Loading branch information
labordep committed Jun 27, 2024
2 parents f48815a + 8f95c97 commit d0953d1
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 22 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,26 @@ This menu provides `metrics` to have statistics on the Molecule code in selected
This menu provides actions and tools depending on the selected classes.
With this menu you can force to `define` a Component, specially if you have deactivated the Molecule dynamic update or if you have a bug when a Component contract changed.

### See Component implementations
![contextual menu see component implementations](https://github.com/Eliott-Guevel/Molecule-various-fixes/assets/76944457/a4221985-0578-4e95-a133-831548e0f5ef) \
When right-clicking a Trait that uses the `MolComponentType` Trait, a new option appears in the `Molecule` sub-menu (as shown above):

![see component implementations github](https://github.com/Eliott-Guevel/Molecule-various-fixes/assets/76944457/68a94948-d6a0-4dce-9c67-2d1974b78fdf) \
Clicking this option opens this window, showing all the Component implementations of a Type Trait. \
The title of the window indicates the name of the Type Trait. \
Clicking an implementation activates the Browse button, which is used to open it in the **System Browser** of Pharo (double-clicking also works). \
Typing in the filtering list (above the two window buttons) filters the implementations' list.

### See Component users
![contextual menu see component users](https://github.com/Eliott-Guevel/Molecule-various-fixes/assets/76944457/8a9aaa63-33f8-46ea-a638-fc896fc2a60c) \
When right-clicking a interface (that is, a Trait that uses the `MolComponentEvents`, `MolComponentParameters` or `MolComponentServices` Traits), a new option appears in the `Molecule` sub-menu (as shown above):

![See component users github](https://github.com/Eliott-Guevel/Molecule-various-fixes/assets/76944457/682f388b-78a6-41d4-a3c4-2377fb7e9cf5) \
The title of the window indicates the name of the Type Trait as well as the type of interfaces it is about (events, parameters or services). \
In columns are shown the Type Trait requiring and offering this interface. \
Clicking a Type Trait activates the Browse button, which is used to open it in the **System Browser** of Pharo (double-clicking also works). \
Typing in a filtering list (below the columns) filters the relevant Type Traits' list.

## <img src="/resources/puce.svg" width="32" height="32" align="bottom"> Using Components

### Start and stop method
Expand Down
22 changes: 11 additions & 11 deletions documentation/Create and connect Components.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ They're directly linked, in the sense that a change detected in the first Compon
![gps molecule without figure](https://github.com/Eliott-Guevel/Molecule-various-fixes/assets/76944457/a949d2f8-c460-40be-985d-273881e5b3da) \
GPS (Global Positioning System) is the american subsystem of GNSS (Global Navigation Satellite Systems).

The complete GNSS example is present in the **Molecule-Examples** package, but if it's your first time using Molecule, you should follow this tutorial step-by-step in order to understand how Molecule works. \
The complete GNSS example is present in the [Molecule-Examples](https://github.com/OpenSmock/Molecule/tree/main/src/Molecule-Examples) package, but if it's your first time using Molecule, you should follow this tutorial step-by-step in order to understand how Molecule works. \
A graphical form of the example is available in the [Molecule-Geographical-Position-Example](https://github.com/OpenSmock/Molecule-Geographical-Position-Example) repository.

# Contents
[STATIC PART: declaration](https://github.com/OpenSmock/Molecule/blob/documentation/documentation/Create%20and%20connect%20Components.md#static-part-declaration)
* [Define Component Types](https://github.com/OpenSmock/Molecule/blob/documentation/documentation/Create%20and%20connect%20Components.md#define-component-types)
- [Adding Component contract with a Component Type](https://github.com/OpenSmock/Molecule/blob/documentation/documentation/Create%20and%20connect%20Components.md#adding-component-contract-with-a-component-type)
+ [Define first Component Type MolGNSSData](https://github.com/OpenSmock/Molecule/blob/documentation/documentation/Create%20and%20connect%20Components.md#define-the-first-component-type-molgnssdata)
+ [Define the first Component Type MolGNSSData](https://github.com/OpenSmock/Molecule/blob/documentation/documentation/Create%20and%20connect%20Components.md#define-the-first-component-type-molgnssdata)
+ [Define the second Component Type MolGNSSMap](https://github.com/OpenSmock/Molecule/blob/documentation/documentation/Create%20and%20connect%20Components.md#define-the-second-component-type-molgnssmap)
* [Define Services and Events](https://github.com/OpenSmock/Molecule/blob/documentation/documentation/Create%20and%20connect%20Components.md#define-services-and-events)
* [Create a Component implementation of a Type](https://github.com/OpenSmock/Molecule/blob/documentation/documentation/Create%20and%20connect%20Components.md#create-a-component-implementation-of-a-type)
Expand Down Expand Up @@ -100,8 +100,8 @@ This Event trait produces the `currentPositionChanged: aGeoPosition` Event

## Create a Component implementation of a Type
There are two ways to create a new Molecule Component :
- Create a new Component from scratch : write a new Class inheriting from the Component hierarchy
- Re-using an existing Class : augmenting that class with Component behavior
- Create a new Component from scratch: write a new Class inheriting from the Component hierarchy
- Re-using an existing Class: augmenting that class with Component behavior

### Create a new Component from scratch
To develop a new Component from scratch, a class needs to be created that must subclass the `MolAbstractComponentImpl` abstract Class.
Expand All @@ -118,7 +118,7 @@ We must use the Molecule Component interface `MolComponentImpl`, which is a Trai
For this tutorial, the GNSS needs to send its geographical data to the Map. \
In order to do that, its contract needs to be redefined to indicate which Services and Events are produced and provided by it.
![implementation contrat molecule](https://github.com/Eliott-Guevel/Molecule-various-fixes/assets/76944457/a9c14388-0abe-4f09-8ac5-578054f98ad1) \
Redefining a Component's contract is done on the **Class side** of Pharo (in the **System Browser**, accessible through the **Browse** tab of Pharo, click on the radio button located left to the Class side text, which is located in the middle of the **System Browser** window). \
Redefining a Component's contract is done on the **Class side** of Pharo (in the **System Browser** which is accessible through the **Browse** tab of Pharo, click on the radio button located left to the Class side text which is located in the middle of the **System Browser** window). \
![system browser red](https://github.com/Eliott-Guevel/Molecule-various-fixes/assets/76944457/7fa84d1d-45b4-4fe1-b524-6193fc7d6fec)
![class side red](https://github.com/Eliott-Guevel/Molecule-various-fixes/assets/76944457/7b189b8a-1552-46df-a69d-44f78bb73848)

Expand Down Expand Up @@ -181,7 +181,7 @@ MolGNSSDataImpl>>increaseAccuracy
self accuracy: nextAccuracy ]
```

Then, override the `getAccuracyRadiusInMeters` Service (which will simply return `accuracy`). The override is done since the `getAccuracyRadiusInMeters` Service is declared in the `providedComponentServices` part of `MolGNSSData`'s contract. And since `MolGNSSDataImpl` is an implemmentation of `MolGNSSData`, the `getAccuracyRadiusInMeters` is implemented here.
Then, override the `getAccuracyRadiusInMeters` Service (which will simply return `accuracy`). The override is done since the `getAccuracyRadiusInMeters` Service is declared in the `providedComponentServices` part of `MolGNSSData`'s contract. And since `MolGNSSDataImpl` is an implementation of `MolGNSSData`, the `getAccuracyRadiusInMeters` is implemented here.
```smalltalk
MolGNSSDataImpl>>getAccuracyRadiusInMeters
"Get and return the accuracy of the GNSS depending quality of signal and quantity of connected satellites"
Expand Down Expand Up @@ -229,9 +229,9 @@ To quickly detail this method, we first need to examine `getMolGNSSDataEventsNot
To return to `componentActivate`, after every 50 milliseconds, a random geographical position is generated which is sent through the `currentPositionChanged: aGeoPosition` Event.

Generated methods take the following forms:
- get[componentName]EventsNotifier
- get[componentName]EventsSubscriber
- get[componentName]ServicesProvider
- `get[componentName]EventsNotifier`
- `get[componentName]EventsSubscriber`
- `get[componentName]ServicesProvider`

There is no need to manually type them.

Expand All @@ -247,7 +247,7 @@ MolGNSSDataImpl>>componentPassivate
```

## Create the Component implementation for MolGNSSMap
Same way as `MolGNSSDataImpl`, we can move on to create the Map Component, being `MolGNSSMapImpl`. This component uses the `MolGNSSMap` Trait, used to define the Component's contract, as well as the `MolGNSSDataEvents` interface, which needs to be specified in order for the Component to consume its Service.
Same way as `MolGNSSDataImpl`, we can move on to create the Map Component, being `MolGNSSMapImpl`. This component uses the `MolGNSSMap` Trait, used to define the Component's contract, as well as the `MolGNSSDataEvents` interface which needs to be specified in order for the Component to consume its Service.
```smalltalk
MolAbstractComponentImpl subclass: #MolGNSSMapImpl
uses: MolGNSSMap + MolGNSSDataEvents
Expand Down Expand Up @@ -338,7 +338,7 @@ The Pharo **Transcript** (also located in the **Browse** tab of Pharo) will star

### Starting a Component with a name
It's also possible to create a component with a name by using the `MolComponentImpl class>>start: #[name]` method.
This will be useful for [Producers](https://github.com/OpenSmock/Molecule/blob/main/documentation/Creating%20Producers.md), which determine which component of a given Type A receives events from which component of a given Type B, if multiple components of the same Type exist.
This will be useful for [Producers](https://github.com/OpenSmock/Molecule/blob/main/documentation/Creating%20Producers.md), which determine which component of a given Type A receives events from which component of a given Type B if multiple components of the same Type exist.

## Stopping a Component
Components are stopped using the `MolComponentImpl class>>stop` instruction. \
Expand Down
8 changes: 4 additions & 4 deletions documentation/Producers.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Producers
Producers are used to specify the sender of the Events created by components.
Producers are created using the following syntax:
`self forEvents: [componentName]Events useProducer: #[instanceName]`
with [instanceName] being the name you chose for starting a component (see [Create and connect Components](https://github.com/OpenSmock/Molecule/blob/main/documentation/Create%20and%20connect%20Components)), `default` if no name was used.
Producers are used to specify the sender of the Events created by components. \
Producers are created using the following syntax: \
`self forEvents: [componentName]Events useProducer: #[instanceName]` \
with [instanceName] being the name you chose for starting a component (see [Create and connect Components](https://github.com/OpenSmock/Molecule/blob/main/documentation/Create%20and%20connect%20Components)), `default` if no name was used. \
Producers are created in the `componentInitialize` method.

For multiple Producers (multiple named launched components of the same Type), the syntax is
Expand Down
5 changes: 2 additions & 3 deletions documentation/Table of contents.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ Welcome to the Molecule wiki!
[Principles](https://github.com/OpenSmock/Molecule/blob/main/documentation/Principles.md)

# Tutorials
Step-by-step example describing an example between two Components interacting:

## Step-by-step example describing two Components interacting between one another
[Create and connect Components](https://github.com/OpenSmock/Molecule/blob/main/documentation/Create%20and%20connect%20Components.md)

Other tutorials focused on one specific part of Molecule:
## Other tutorials focused on one specific part of Molecule

[Connecting two Components](https://github.com/OpenSmock/Molecule/blob/main/documentation/Connecting%20two%20Components.md)

Expand Down
8 changes: 4 additions & 4 deletions documentation/Tests.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Tests
To create quick tests for your Components, you can create a package named [yourPackageName]-Examples or [yourPackageName]-Tests, then create an Object subclass named [yourPackageName]Examples,
To create quick tests for your Components, you can create a package named `[yourPackageName]-Examples` or `[yourPackageName]-Tests`, then create an Object subclass named `[yourPackageName]Examples`,
```smalltalk
Object subclass: #MolGPS-Examples
instanceVariableNames: ''
classVariableNames: ''
package: 'Molecule-Tutorial'
```
then display the **Class side** of this class.
This then allows the creation of methods for different test cases.
This allows the creation of methods for different test cases.

One practical thing is putting a `<script>` tag at the start of your methods. This will create a small icon next to your method in order to launch it without the use of a Playground.
```smalltalk
Expand Down Expand Up @@ -37,8 +37,8 @@ MolGPS-Examples>>stop

## Switching Components on the fly
This test space can be useful for switching Components on the fly, stopping a component to start another having the same Type.
Make sure that they have a different name or that the current launched Component is stopped before the other of the same Type is launched.
See the Molecule-Examples package for more examples on this.
Make sure that they have a different name or that the current launched Component is stopped before the other of the same Type is launched. \
See the [Molecule-Examples](https://github.com/OpenSmock/Molecule/tree/main/src/Molecule-Examples) package for more examples on this.

## Calling another script
To call another script, you simply have to call it like a regular function with `self [script]` since the `self` here represents the current class (for methods located in the class side).
Expand Down

0 comments on commit d0953d1

Please sign in to comment.