Skip to content

Commit

Permalink
Increment: Add Balancing Helper UI Component to EAF
Browse files Browse the repository at this point in the history
The Balancing Helper UI component has been integrated into the Energy Application Framework (EAF). The component allows users to configure energy balancing for a specific balancing point through the 'uc_balancing.html' page in the admin interface. This update facilitates defining which metering points feed into a balancing point and which of them draw energy from it, enabling applications such as community energy collectives, tenant power models, and cloud storage solutions to operate effectively.

- Implemented Balancing Helper on `uc_balancing.html`
- Added configuration options for injection and withdrawal metering points
- Enabled configuration of energy balancing for different use cases
- Included documentation and help tooltips for user guidance
- Improved admin interface for seamless navigation to Balancing Helper settings
  • Loading branch information
zoernert committed Jan 28, 2024
1 parent eeb1eb7 commit b0cfb29
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 5 deletions.
2 changes: 1 addition & 1 deletion framework/docs
Submodule docs updated from 49a775 to 436579
84 changes: 82 additions & 2 deletions framework/public/devUI/assets/js/uc_balancehelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,102 @@ $(document).ready(function() {
}
});
$.getJSON("/api/balancing/peers?assetId="+assetId,function(data) {
window.peersFrom = {};
window.peersTo = {};

let einspeiser_html = '<ul>';
let bezieher_html = '<ul>';
for(let i=0;i<data.length;i++) {
if(data[i].balancerule.to == assetId) {
einspeiser_html += '<li>'+data[i].assetId+'</li>';
einspeiser_html += '<li><btn class="btn btn-light removeAsset" date-assetId="'+data[i].assetId+'">'+data[i].assetId+'</button></li>';
window.peersFrom[data[i].assetId] = true;
} else if(data[i].balancerule.from == assetId) {
bezieher_html += '<li>'+data[i].assetId+'</li>';
bezieher_html += '<li><btn class="btn btn-light removeAsset" date-assetId="'+data[i].assetId+'">'+data[i].assetId+'</button></li>';
window.peersTo[data[i].assetId] = true;
}
}
einspeiser_html += '</ul>';
bezieher_html += '</ul>';
$('#einspeiser').html(einspeiser_html);
$('#bezieher').html(bezieher_html);
$('.removeAsset').off();
$('.removeAsset').click(function() {
let balancerule = {};

balancerule["from"] = "eaf_generic_balancegroup";

$.ajax({
type: 'POST',
url: '/api/asset/upsert',
data: JSON.stringify({
assetId: $(this).attr('date-assetId'),
type: 'balance', //realy? maybe we could split here
balancerule: balancerule
}),
contentType: 'application/json',
success: function(response) {
renderPeers(window.assetId);
}
});
});
});
}

const addBalanceRule = function (assetId,rule) {
let balancerule = {};

balancerule[rule] = window.assetId;
console.log(balancerule);
$.ajax({
type: 'POST',
url: '/api/asset/upsert',
data: JSON.stringify({
assetId: assetId,
type: 'balance', //realy? maybe we could split here
balancerule: balancerule
}),
contentType: 'application/json',
success: function(response) {
renderPeers(window.assetId);
}
});
}

$('#searchForm').submit(function(e) {
e.preventDefault();
$.getJSON("/api/metering/assets?q="+$('#addSearch').val(), function(data) {
let html = '';
html += '<div class="row" style="margin-top:25px">';
html += '<div class="col"><h3>Einspeiser</h3></div>';
html += '<div class="col"><h3>Bezieher</h3></div>';
html += '</div>';

for(let i=0;i<data.length;i++) {
html += '<p>'+data[i].meterId+'</p>';
html += '<div class="row" style="margin-bottom:15px">';
let state = "";
if(typeof window.peersFrom[data[i].meterId] !== 'undefined') {
state = " disabled='disabled' ";
}
html += '<div class="col"><button class="btn btn-dark btnAddEinspeiser" '+state+' data-assetId="'+data[i].meterId+'"><i class="fa fa-plus-square"></i></button></div>';
state = "";
if(typeof window.peersTo[data[i].meterId] !== 'undefined') {
state = " disabled='disabled' ";
}
html += '<div class="col"><button class="btn btn-dark btnAddBezieher" '+state+' data-assetId="'+data[i].meterId+'"><i class="fa fa-plus-square"></i></button></div>';
html += '</div>';
}
$('#addSearchResult').html(html);
$('.btnAddEinspeiser').off();
$('.btnAddEinspeiser').click(function() {
addBalanceRule($(this).attr('data-assetId'),'to');
});
$('.btnAddBezieher').off();
$('.btnAddBezieher').click(function() {
addBalanceRule($(this).attr('data-assetId'),'from');
});
});
});
if($.urlParam('assetId')) {
window.assetId = $.urlParam('assetId');
renderPeers(window.assetId);
Expand Down
3 changes: 3 additions & 0 deletions framework/public/devUI/assets/js/uc_balancing.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,7 @@ $(document).ready(function() {

// console.log(balancerule);
});
$('#balancingHelper').click(function(e) {
location.href="./uc_balancehelper.html?assetId="+window.assetId;
})
});
11 changes: 10 additions & 1 deletion framework/public/devUI/uc_balancehelper.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ <h3>Bezieher</h3>
</div>
</div>
</div>
<div class="card" style="margin-bottom: 25px;">
<div class="card-body">
<h3>Hinzufügen</h3>
<form id="searchForm">
<div class="input-group"><span class="input-group-text">Messstelle</span><input class="form-control" type="text" id="addSearch"><button class="btn btn-dark" type="submit"><i class="fa fa-search"></i></button></div>
</form>
<div id="addSearchResult"></div>
</div>
</div>
<form id="balancerule">
<div class="card" style="margin-bottom: 25px;">
<div class="card-body">
Expand Down Expand Up @@ -122,7 +131,7 @@ <h4 class="modal-title">Zertifikat</h4><button class="btn-close" type="button" a
<script src="assets/bootstrap/js/bootstrap.min.js?h=e55bde7d6e36ebf17ba0b8c1e80e4065"></script>
<script src="assets/js/utils.js?h=b6a1e690b2a987d9af7e9692dff15273"></script>
<script src="assets/js/3party/marked.min.js?h=26085551a49dd1635b48b42f08c3d583"></script>
<script src="assets/js/uc_balancehelper.js?h=326e7d21d9fe60fa2e39fe5756da839f"></script>
<script src="assets/js/uc_balancehelper.js?h=8b306daa4acffe1d64622a4522ecadae"></script>
<script src="assets/js/uc_contract.js?h=f3ad95a4c2133df734c874a6d3bbef70"></script>
</body>

Expand Down
3 changes: 2 additions & 1 deletion framework/public/devUI/uc_balancing.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ <h3>
</h3>
<div id="profileDiv"><canvas id="profileChart"></canvas></div>
<div id="balances"></div>
<div class="text-end"><button class="btn btn-dark" id="balancingHelper" type="button"><i class="fa fa-gear"></i></button></div>
</div>
</div>
<form id="balancerule">
Expand Down Expand Up @@ -119,7 +120,7 @@ <h4 class="modal-title">Zertifikat</h4><button class="btn-close" type="button" a
<script src="assets/js/3party/qrcode.js?h=517b55d3688ce9ef1085a3d9632bcb97"></script>
<script src="assets/js/utils.js?h=b6a1e690b2a987d9af7e9692dff15273"></script>
<script src="assets/js/3party/marked.min.js?h=26085551a49dd1635b48b42f08c3d583"></script>
<script src="assets/js/uc_balancing.js?h=d1b72c954202373c52462b7e110568df"></script>
<script src="assets/js/uc_balancing.js?h=e4e74120e2a34b992e8745be07a4cdb4"></script>
<script src="assets/js/uc_contract.js?h=f3ad95a4c2133df734c874a6d3bbef70"></script>
</body>

Expand Down

0 comments on commit b0cfb29

Please sign in to comment.