fyziktom / VirtualEconomyFramework

Framework for economy applications
https://veframework.com/
MIT License
24 stars 7 forks source link

WIP: 151 entities blocks driver #152

Closed fyziktom closed 1 year ago

fyziktom commented 1 year ago

First version of the EntitiesBlocks driver matches first expectations. It consists of two basic libraries: driver and UI components. There is the simple WASM demo.

The driver basic imporant interfaces are:

The IEntity has extension in form of interface ISource and IConsumer. These interfaces contains just type now to allow way how to create some additional properties/functions for specific cases of Entities. Example is class BatteryStorage which stores the properties such as Capacity or Maximum Charge and Discharge current.

Handler keeps the dictionary of all IEntities. Their relations are implemented by list of Ids of children entities in each Entity.

Each entity has dicitonary of IBlocks.

The block has StartTime and Timeframe which defines time when block is active. The EndTime is calculated automatically. The block can be repetitive. It means like "each day from 8-18 and run from some date until another date" or "run from some date until another date for X hours with Y off time period". Blocks can carry this informations. In the case of the repetitive blocks the first block does not contains RepetitiveSourceBlockId, but is set as repetitive source it means there is line of blocks which refers to this block through RepetitiveSourceBlockId property. This allow to sort them in one line in graph, or edit/remove whole line. This is also used for optimization of calculation of the Summed Value data of the repetitive blocks (more about Summed Value below). There is known issue with the repetitive block where you need some different values during months/days, etc. example is PVE profile per year, where you have average value per month. This must be added like separated blocks for now. I will solve this in commings refactoring/updates.

The basic functions are used in the unit tests.

The important function of this library is possibility to select some StartTime and EndTime and recalculate amounts in this time area. It means it will identify all blocks which play role in this time area and add them to the result list which is split based on settings of BlockTimeframe. If you set for example BlockTimeframe.Day and StartTime 1.1.2022 and EndTime 1.1.2023, the result list will have 365 blocks, one per each day. If some original block overlay more days it is split and based on average amount it is added to specific days. The extended version of this function can take some window in the day (for example 8-18) and cut just amount which fits to this time window in the day. Example is here.

The IEntitiesHandler has functions for export state to JSON and load it back.

It is still raw and in WIP.

sonarcloud[bot] commented 1 year ago

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 236 Code Smells

58.6% 58.6% Coverage
5.9% 5.9% Duplication

sonarcloud[bot] commented 1 year ago

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 257 Code Smells

54.3% 54.3% Coverage
4.6% 4.6% Duplication

sonarcloud[bot] commented 1 year ago

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 311 Code Smells

52.7% 52.7% Coverage
4.9% 4.9% Duplication