Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 67 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![MPL-2.0 License](https://img.shields.io/badge/license-MPL_2.0-blue.svg)](https://www.mozilla.org/en-US/MPL/2.0/)

# dynamic-mapping-server

To automatically generate the sql schema file you can use the following command:
Expand All @@ -7,4 +8,69 @@ To automatically generate the sql schema file you can use the following command:

Parameters are not yet generated by the app. For now the app will not work as intended without any data.

After creating the database and its tables, load **src/main/resources/IEEE14Models.sql** to instantiate some.
After creating the database and its tables, load **src/main/resources/IEEE14Models.sql** to instantiate some.

---

# How to add a new model

- Call the POST /models/ endpoint with a Model JSON Object
- (Example: _test/resources/LoadAlphaBeta.json_)

---

# How to add a new equipment type

## Griddyna-app

### For rules:

1) Add [Type] to EquipmentType enum
2) Add properties in EquipmentProperties.[Type]

### For automata:

1) Add [Family] to AutomatonFamily
2) Add properties in AutomatonProperties.[Family]

## Dynamic-mapping-server

1) Add [Type/Family] to utils/EquipmentType

### For rules:

2) Add [Type] to `equipmentTypeToCollectionName` method in Templater
3) Add [Type] to `equipmentTypeToClass` method in Templater
4) Add `get[Type]EquipmentValueMethod` in NetworkServiceImpl
5) Add previous method to `getNetworkValuesFromExistingNetwork` in NetworkServiceImpl
6) Add `getPropertyValuesBy[Type]` in NetworkServiceImpl
7) Add previous method to `matchNetworkToRule` in NetworkServiceImpl

### For automata:

2) Add [Family] to `familyModel` switch in Templater
3) Update `AUTOMATON_IMPORT` if new imports are needed (or create an import constant for each family)

---

# Roadmap

- Create an interface to Delete sets
- Front-End only, probably via `SetEditor`
- Prefill Sets in `SetEditor`
- Either put a default set in `parameterDefinitions` (FE & BE) or use first set to prefill all the others (FE only)
- Fetch EquipmentTypes from BE instead of defining them in the Front End
- Update Data Model and add an `EquipmentController`
- Manage Equipment properties and creates an interface to update/add a type.
- New endpoints to `EquipmentController`
- Create an interface to import models
- FE only, add a page with a form to create new model and its parameters
- Directly create the .dyd without using the script.
- It will need to use `matchNetworkToRule` results and **remove duplicates** from the results.
- Replicate PowSyBl calls to relevant classes to simulate what does the script processing do and fetch missing
values
- Optimise Redux store to speed up FE when the attached network become massive
- Reduce data stored and optimise selectors (memoization)
- Polish Parameters Management appearance (FE)
- Sends only relevant sets to the FE (pertaining to the attached network only), avoid unnecessary forms.
- Rename Script class as Results since the script is no longer the only result
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ResponseEntity<List<ParametersSet>> getSetsGroupsFromModelName(@PathVaria
}

@PostMapping(value = "/{modelName}/parameters/sets/strict")
@Operation(summary = "Save a new parameter sets group without checking sets")
@Operation(summary = "Save a new parameter sets group with checking sets")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Parameter Set Group Saved")})
public ResponseEntity<ParametersSetsGroup> saveParametersSet(@PathVariable("modelName") String modelName, @RequestBody ParametersSetsGroup setsGroup) {
Expand All @@ -72,9 +72,9 @@ public ResponseEntity<List<ModelParameterDefinition>> getParametersDefinitionsFr
}

@GetMapping(value = "/")
@Operation(summary = "get models names")
@Operation(summary = "get models")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "names of all models")})
@ApiResponse(responseCode = "200", description = "simplified versions of all models")})
public ResponseEntity<List<SimpleModel>> getModels() {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(modelService.getModels());
}
Expand Down
Binary file added src/main/resources/Diagrams/DynamicMapping.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
199 changes: 199 additions & 0 deletions src/main/resources/Diagrams/DynamicMapping.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
@startuml

'EQUIPMENT'
enum ET as "EquipmentType" {
GENERATOR
LINE
LOAD
}

enum PT as "ParameterType" {
STRING
INT
DOUBLE
BOOLEAN
}

class EP as "EquipmentProperty" {
String name
String value
ParameterType type
}

class E as "Equipment" {
EquipmentType type
EquipmentProperty[] properties
}

E "1" *-right- "1" ET
E "1" *-left- "*" EP
EP "1" *-left- "1" PT

'MODEL'

enum ST as "SetGroupType" {
FIXED
PREFIX
SUFFIX
}

enum PO as "ParameterOrigin" {
NETWORK
FIXED
USER
}

class MPD as "ModelParameterDefinition" {
String name
ParameterType type
ParameterOrigin origin
String originName
String fixedValue
}

MPD "1" *-up- "1" PT
MPD "1" *-down- "1" PO

class MP as "ModelParameter" {
String name
String value
}


class PS as "ParametersSet" {
String name
ModelParameter[] parameters
Date lastModifiedDate
}

PS "1" *-left- "*" MP



class PSG as "ParametersSetsGroup" {
# String modelName
# String name
# SetGroupType type
ParametersSet[] sets
}

PSG "1" *-down- "1" ST
PSG "1" *-down- "*" PS

'housekeeping'
PS -right[hidden]- ST

class M as "Model" {
String modelName
EquipmentType equipmentType
ModelParameterDefinition[] parameterDefinitions
ParametersSetsGroup[] setsGroups
Boolean isParameterSetGroupValid()
}

M "1" *-left- "*" MPD
M "1" *-up- "*" PSG


'FILTER'
enum O as "Operand" {
EQUALS
NOT_EQUALS
LOWER
LOWER_OR_EQUALS
HIGHER_OR_EQUALS
HIGHER
INCLUDES
STARTS_WITH
ENDS_WITH
IN
NOT_IN
}

abstract F as "AbstractFilter" {
EquipmentProperty property
String filterId
Operand operand
String convertFilterToString()
boolean matchValueToFilter(String valueToTest)
}
F "1" *-up- "1" EP
F "1" *-left- "1" O

class NF as "NumberFilter" extends F {
Float[] value
}

class SF as "StringFilter" extends F {
String[] value
}

class BF as "BooleanFilter" extends F {
Boolean value
}

'housekeeping:'
NF-up[hidden]-F
SF-up[hidden]-F
BF-up[hidden]-F


'RULE'
class R as "Rule" {
EquipmentType type
String mappedModel
String setGroup
SetGroupType groupType
AbstractFilter[] filters
String composition
}

R "1" *-left- "*" F
R "1" *-up- "1" ET
R "1" *-down- "1" PSG

note right of R
composition is the expression
organizing the different filters
<b>Example:</b> <i>(Filter1 && Filter3) || Filter2</i>
end note

'AUTOMATON'
enum AF as "AutomatonFamily" {
CURRENT_LIMIT_AUTOMATON
}

abstract AA as "AbstractAutomaton" {
AutomatonFamily family
String model
String setGroup
String watchedElement
}

AA "1" *- "1" AF
AA "1" *-down- "1" PSG


class CLA as "CurrentLimitAutomaton" extends AA {
String side
}

'housekeeping:'
'CLA-left[hidden]-AA

'MAPPING'

class DynamicMapping {
# String name
Rule[] rules
Automaton[] automata
Boolean controlledParameters
Script convertToScript()
}

DynamicMapping "1" o-down- "*" R
DynamicMapping "1" o-down- "*" AA

'housekeeping'
R -right[hidden]- AA
@enduml