Commit ae700126 authored by Frantisek Mikulu's avatar Frantisek Mikulu

IqrfInfo DB enum percentage, update doc

parent 34066631
Pipeline #2126 passed with stages
in 151 minutes and 41 seconds
......@@ -55,6 +55,11 @@
"type": "integer",
"description": "number of the enumeration phase steps",
"default": 0
},
"percentage": {
"type": "integer",
"description": "very rough percentage of enum overall procedure usable for gui progress bar",
"default": 0
}
},
"required": [
......
......@@ -94,8 +94,8 @@ This is done by:
- JS driver identification is done by an existing package from IqrfRepo
- if the device is not registered in IqrfRepo the drivers are evaluated according DPA requests *iqrf.embed.exprore.PeripheralInformation* and *iqrf.embed.exprore.MorePeripheralInformationn*
#### Load drivers
This loads JS drivers from IqrfRepo to standalone JS engine per device.
#### Device enum
This selects and loads JS drivers from IqrfRepo to standalone JS engine per device.
#### Std enum
This phase take care only of Iqrf Standards enumeration with usage of matching JS drivers versions loaded in previous versions
......@@ -156,10 +156,43 @@ Component **JsonIqrfInfoApi** provides JSON API. See schemes at https://gitlab.i
- get - returns orphaned mids
- remove - remove orphaned mids
The request **infoDaemon_Enumeration** with command **now** provides more responses with an information about running enumeration phases. These items (see complete schema) provides the information:
```json
{
"enumPhase": {
"type": "integer",
"description": "enumeration phase",
"default": 0
},
"step": {
"type": "integer",
"description": "step order of the enumeration phase steps",
"default": 0
},
"steps": {
"type": "integer",
"description": "number of the enumeration phase steps",
"default": 0
},
"percentage": {
"type": "integer",
"description": "very rough percentage of enum overall procedure usable for gui progress bar",
"default": 0
}
}
```
enumeration phase:
- start = 0 just started
- check = 1 running check enum phase
- fullNode = 2 running full enum phase
- fullDevice = 3 running device enum phase
- standard = 4 running standard enum phase
- finish = 5 all phases finished - this is last response
All pfases provides actual **step** from **steps** number. The percentage is rough guess but good enough for GUI progress bar.
## Next possible development steps
- download only detected drivers from Iqrf Repo (makes sense only if provisory load skipped)
- provide event system of finished enum phases and correct drivers load
- provide user an info what's going on - e.g. percentage
\ No newline at end of file
......@@ -27,6 +27,7 @@
#include <random>
#include <cstddef>
#include <tuple>
#include <cmath>
#include "iqrf__IqrfInfo.hxx"
......@@ -262,6 +263,48 @@ namespace iqrf {
TRC_FUNCTION_LEAVE("");
}
// percentage estimate
void percentageEstimate(IIqrfInfo::EnumerationState & estate)
{
const int estimateCheck = 5;
const int estimatefullNode = 70;
const int estimatefullDevice = 85;
const int estimateStandard = 99;
switch (estate.m_phase) {
case IIqrfInfo::EnumerationState::Phase::start:
estate.m_percentage = 0;
break;
case IIqrfInfo::EnumerationState::Phase::check:
estate.m_percentage = estimateCheck;
break;
case IIqrfInfo::EnumerationState::Phase::fullNode:
{
double span = estimatefullNode - estimateCheck;
estate.m_percentage = floor(estimateCheck + (span / (double)estate.m_steps) * estate.m_step);
break;
}
case IIqrfInfo::EnumerationState::Phase::fullDevice:
{
double span = estimatefullDevice - estimatefullNode;
estate.m_percentage = floor(estimatefullNode + (span / (double)estate.m_steps) * estate.m_step);
break;
}
case IIqrfInfo::EnumerationState::Phase::standard:
{
double span = estimateStandard - estimatefullDevice;
estate.m_percentage = floor(estimatefullDevice + (span / (double)estate.m_steps) * estate.m_step);
break;
}
case IIqrfInfo::EnumerationState::Phase::finish:
estate.m_percentage = 100;
break;
default:
;
}
}
void runEnum()
{
TRC_FUNCTION_ENTER("");
......@@ -320,6 +363,7 @@ namespace iqrf {
void handleEnumEvent(EnumerationState estate)
{
percentageEstimate(estate);
try {
for (auto & hnd : m_enumHandlers) {
hnd.second(estate);
......
......@@ -508,6 +508,7 @@ namespace iqrf {
Pointer("/data/rsp/enumPhase").Set(doc, (int)m_estate.m_phase, a);
Pointer("/data/rsp/step").Set(doc, m_estate.m_step, a);
Pointer("/data/rsp/steps").Set(doc, m_estate.m_steps, a);
Pointer("/data/rsp/percentage").Set(doc, m_estate.m_percentage, a);
}
}
......
......@@ -58,11 +58,13 @@ namespace iqrf
:m_phase(phase)
,m_step(step)
,m_steps(steps)
,m_percentage(0)
{}
Phase m_phase = Phase::start;
int m_step = 1; // step order in steps
int m_steps = 1; // number of steps of the phase
int m_percentage = 0; // rough percetage estimation of overall enumeration procedure
};
typedef std::function<void(EnumerationState es)> EnumerateHandlerFunc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment