Finishing FMS dash board

This commit is contained in:
stephb9959
2021-07-20 16:10:13 -07:00
parent b6cd35d961
commit 798c2751de
6 changed files with 30 additions and 0 deletions

View File

@@ -219,6 +219,10 @@ components:
$ref: '#/components/schemas/TagIntPairList'
endPoints:
$ref: '#/components/schemas/TagIntPairList'
unknownFirmwares:
$ref: '#/components/schemas/TagIntPairList'
usingLatest:
$ref: '#/components/schemas/TagIntPairList'
#########################################################################################
##

View File

@@ -48,6 +48,18 @@ namespace uCentral {
return false;
}
bool LatestFirmwareCache::IsLatest(const std::string &DeviceType, const std::string &Revision) {
SubMutexGuard G(Mutex_);
std::string Result;
auto E=FirmwareCache_.find(DeviceType);
if(E!=FirmwareCache_.end()) {
return E->second.Revision == Revision;
}
return false;
}
void LatestFirmwareCache::DumpCache() {
SubMutexGuard G(Mutex_);

View File

@@ -39,6 +39,7 @@ namespace uCentral {
void DumpCache();
inline Types::StringSet GetRevisions() { SubMutexGuard G(Mutex_); return RevisionSet_; };
inline Types::StringSet GetDevices() { SubMutexGuard G(Mutex_); return DeviceSet_; };
bool IsLatest(const std::string &DeviceType, const std::string &Revision);
private:
static LatestFirmwareCache *instance_;

View File

@@ -214,6 +214,8 @@ namespace uCentral::FMSObjects {
field_to_json(Obj, "deviceTypes", DeviceTypes_);
field_to_json(Obj, "status", Status_);
field_to_json(Obj,"endPoints", EndPoints_);
field_to_json(Obj, "usingLatest", UsingLatest_);
field_to_json(Obj, "unknownFirmwares", UnknownFirmwares_);
}
bool DeviceReport::from_json(const Poco::JSON::Object::Ptr &Obj) {

View File

@@ -117,6 +117,8 @@ namespace uCentral::FMSObjects {
Types::CountedMap DeviceTypes_;
Types::CountedMap Status_;
Types::CountedMap EndPoints_;
Types::CountedMap UsingLatest_;
Types::CountedMap UnknownFirmwares_;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);

View File

@@ -6,6 +6,7 @@
#include "StorageService.h"
#include "Utils.h"
#include "Poco/Data/RecordSet.h"
#include "LatestFirmwareCache.h"
/*
"serialNumber=?, "
@@ -213,6 +214,14 @@ namespace uCentral {
Types::UpdateCountedMap(Report.Status_, Status);
Types::UpdateCountedMap(Report.EndPoints_, EndPoint);
Types::UpdateCountedMap(Report.OUI_, SerialNumber.substr(0,6));
FMSObjects::FirmwareAgeDetails Age;
if(ComputeFirmwareAge(DeviceType, Revision, Age)) {
if(Age.age==0) {
Types::UpdateCountedMap(Report.UnknownFirmwares_, Revision);
}
}
if(LatestFirmwareCache()->IsLatest(DeviceType, Revision))
Types::UpdateCountedMap(Report.UsingLatest_,Revision);
More = RSet.moveNext();
}
return true;