Compare commits

..

No commits in common. '0fefb4b423c4728e8cf9007cc342902288fea0ba' and '54503e69f5f69f5a1bdafbec8b6a4b6e1f4ccbf9' have entirely different histories.

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

@ -1,12 +1,9 @@
var active_timer = 100;
var calculation = [];
var calculation = 0;
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function truncator(numToTruncate, intDecimalPlaces) {
var numPower = Math.pow(10, intDecimalPlaces); // "numPowerConverter" might be better
return ~~(numToTruncate * numPower)/numPower;
}
function init_edit(partID) {
$('table#details tr#type td p').hide();
$('#type-dropdown').show();
@ -60,30 +57,7 @@ function new_entry() {
}
function calculate() {
let total = 0;
count = Object.keys(calculation).length;
for(let m = 0; m < count; m++) {
let jsonParameters = calculation[m];
let obj = Object.keys(jsonParameters);
let values = Object.values(jsonParameters);
$.getJSON(rootURL + 'getpartinfo/' + jsonParameters["partid"], function(data) {
// $('table#calculations tr#results td p').text(data.partno+" "+jsonParameters["energy"]+" J over "+jsonParameters["period"]+" seconds");
// $('table#calculations tr#results td p').show();
total+= truncator(jsonParameters["energy"],5);
if($('table#calculations tr#'+jsonParameters["partid"]).length == 0) {
$('table#calculations').append('<tr id='+jsonParameters["partid"]+'><td><p>'+data.partno+" "+truncator(jsonParameters["energy"],5)+" J over "+jsonParameters["period"]+' seconds</p></td></tr>');
$('table#calculations tr#'+jsonParameters["partid"]+' td p').show();
}
$('#results td p').text("Total: "+truncator(total,5)+" J");
});
}
calculateoverlay_in();
}
function end_edit() {
@ -121,7 +95,7 @@ function save(partID) {
alert('Please select a component type.');
return;
}
var type_id_v = $('#type-dropdown').val();
var type_id_v = $('type-dropdown').val();
var partno_v = $('input[name=partno-input]').val();
var description_v = $('input[name=description-input]').val();
var datasheet = $('table#details tr#datasheet td input')[0].files;
@ -134,7 +108,7 @@ function save(partID) {
total.push(elem.value);
mapped[elem.name] = elem.value;
});
//console.log(mapped);
console.log(mapped);
if(partno_v.length == 0){
alert('Please enter a part number.');
return;
@ -166,7 +140,7 @@ function save(partID) {
data.append('type_id', type_id_v);
data.append('description', description_v);
data.append('notes', notes_v);
data.append('parameters', JSON.stringify(mapped));
data.append('parameters', mapped);
$.ajax({
@ -225,55 +199,34 @@ function delete_entry(partID) {
},
});
}
function calculate_entry(partID,jsonParameters) {
function calculate_entry(partID,parameters) {
if (partID < 0)
return;
if (!confirm('Add selected entry to calculation?'))
return;
if(jsonParameters != null) {
console.log(parameters);
if(parameters != null) {
var jsonParameters = JSON.parse(data.parameters);
console.log(jsonParameters);
var count = Object.keys(jsonParameters).length;
console.log(count);
// for(var k = 0; k < count; k++) {
var obj = Object.keys(jsonParameters);
var values = Object.values(jsonParameters);
var voltage = 0;
var activepower = 0;
var sleeppower = 0;
var single_period = 0;
//console.log(obj);
var currents = [];
console.log(obj);
for (var key in obj) {
var value = obj[key];
var numbers = values[key]
//console.log(key+":"+value+":"+numbers);
console.log(key+":"+value);
if(value.includes('voltage')) {
voltage = values[key];
}
else if(value.includes('current')) {
if(value.includes('sleep')) {
sleeppower = Number(values[key]);
}
else {
activepower+=Number(values[key]);
}
}
else if(value.includes('mode')) {
single_period=Number(values[key])+Number(single_period);
if(value.includes('sleep')) {
sleeppower=sleeppower*Number(values[key]);
}
else {
activepower=activepower*Number(values[key]);
}
}
else {
console.log("Unconfigured: "+value+":"+values[key]);
}
}
jsonParameters["energy"]=voltage*(sleeppower+activepower);
jsonParameters["period"]=single_period;
jsonParameters["partid"]=partID;
calculation.push(jsonParameters);
}
overlay_out();
}
}
function show_part_info(partID) {
@ -295,15 +248,21 @@ function show_part_info(partID) {
$('table#details tr#description td input').val(text_filter(data.description));
$('table#details tr#notes td p').text(text_filter(data.notes));
$('input[name=notes-input]').val(text_filter(data.notes));
console.log(data.parameters);
if(data.parameters != null) {
var jsonParameters = JSON.parse(data.parameters);
console.log(jsonParameters);
var count = Object.keys(jsonParameters).length;
console.log(count);
// for(var k = 0; k < count; k++) {
var obj = Object.keys(jsonParameters);
var values = Object.values(jsonParameters);
console.log(obj);
for (var key in obj) {
var value = obj[key];
console.log(key+":"+value);
console.log($('table#details tr#'+value.substring(0,value.indexOf("-"))).children().length );
if(value.includes("input") && $('table#details tr#'+value.substring(0,value.indexOf("-"))).children().length == 0 ) {
$('table#details').append('<tr id='+value.substring(0,value.indexOf("-"))+'><td><p></p><input type="text" name='+value+' class="pinfo-input"></td></tr>')
$('table#details tr#'+value.substring(0,value.indexOf("-"))+' td p').text(capitalizeFirstLetter(value.substring(0,value.indexOf("-"))));
@ -342,7 +301,8 @@ function show_part_info(partID) {
$('#calculate-add-button').off('click').on('click', function() {
for (var key in obj) {
var value = obj[key];
jsonParameters[value]=$('table#details tr#'+value.substring(0,value.indexOf("-"))+' td input').val();
console.log(key+":"+value);
jsonParameters[obj[key]]=$('table#details tr#'+value.substring(0,value.indexOf("-"))+' td input').val();
}
calculate_entry(partID,jsonParameters);
@ -369,6 +329,7 @@ function perform_query() {
var queryPromise = $.getJSON(rootURL + 'query/' + filter + '/' + query, data, function(data) {
for(var i = 0; i < data.length; i++) {
console.log(data[i]);
var newRow = $('<tr onclick="show_part_info(' + data[i].id + ')"></tr>');
newRow.append($('<td id="type"></td>').text(text_filter(data[i].type_descriptor)));
newRow.append($('<td id="partno"></td>').text(text_filter(data[i].partno)));

@ -98,10 +98,7 @@ input[type=checkbox]:checked + label.toggle-btn {
.round-floating-button a{
color: #D7E2E2;
}
#calculate-button {
right: 76px;
margin-right: 8px
}
#results {
width:100%;
margin-top: 1em;
@ -159,22 +156,7 @@ input[type=checkbox]:checked + label.toggle-btn {
top:0;
z-index: 201;
}
.calculateoverlay {
background-color: #226666;
color: #D7E2E2;
display: none;
height: 90%;
padding: 0;
position: fixed;
margin:auto;
left:0;
right:0;
top:0;
width:90%;
z-index: 201;
text-align: center;
opacity: 0.0;
}
h2 {
background-color: #013A3A;
padding: 8px 0 8px 0;

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Power Budget Estimator</title>
<title>IL2232 Estimator</title>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
@ -14,12 +14,11 @@
<link rel="apple-touch-icon-precomposed" href="static/apple-touch-icon.png">
<script src="https://use.fontawesome.com/2fef7be393.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/11.5.0/math.js" type="text/javascript"></script>
<script type="text/javascript" src="static/common.js"></script>
<script type="text/javascript" src="static/script.js"></script>
</head>
<body>
<h1>Smart cities power budget estimator </h1>
<h1>IL2232 Smart cities power budget estimator </h1>
<p>Designing an energy harvesting solution? Search for your components, add them and get a power requirement estimate</p>
<input type="text" name="search-bar" class="search-bar" placeholder="Search parts">
<div class="filter-container">
@ -42,6 +41,7 @@
<div class="overlay">
<h2>Part Details</h2>
<div id="info-container">
<img src="" id="map" class="map"/>
<table id="details">
<tr id="type-head" class="details-header"><td>TYPE</td></tr>
<tr id="type" class="details-content"><td><p></p>
@ -80,11 +80,14 @@
<h2>Calculation results</h2>
<div id="calculation-container">
<table id="calculations">
<tr id="calculation-head" class="calculations-header"><td>Results</td></tr>
<tr id="results" class="calculations-content"><td><p>0</p>
<tr id="type-head" class="calculations-header"><td>TYPE</td></tr>
<tr id="type" class="calculations-content"><td><p></p>
</td></tr>
</table>
<div class="button-container">
<div class="round-button"><a href="#" id="delete-button"><i class="fa fa-trash" aria-hidden="true"></i></a></div>
<div class="round-button"><a href="#" id="edit-button"><i class="fa fa-pencil" aria-hidden="true"></i></a></div>
<div class="round-button"><a href="#" id="duplicate-button" onclick="init_edit(-1)"><i class="fa fa-copy" aria-hidden="true"></i></a></div>
<div class="round-button text-center"><a href="#" id="calculate-add-button"><i class="fa fa-calculator" aria-hidden="true"></i></a></div>
</div>
</div>

Loading…
Cancel
Save