From b0988ade107916317ed952ac000548655bfb6796 Mon Sep 17 00:00:00 2001 From: marktilles <82381104+marktilles@users.noreply.github.com> Date: Mon, 5 Jul 2021 22:13:41 +0200 Subject: [PATCH] Marks Patches --- .DS_Store | Bin 0 -> 6148 bytes config.py | 38 +- docs/logs 2.md | 25 + kiln-controller.py | 27 +- lib/.DS_Store | Bin 0 -> 6148 bytes lib/max31855.py | 24 +- lib/max31856.py | 45 +- lib/oven.py | 157 ++--- public/.DS_Store | Bin 0 -> 6148 bytes public/assets/.DS_Store | Bin 0 -> 6148 bytes public/assets/js/picoreflow 2.js | 740 ++++++++++++++++++++++ public/assets/js/picoreflow.js | 32 +- public/control.html | 161 +++++ public/index.html | 27 +- storage/profiles/Unni Stengodsglasyr.json | 1 + storage/profiles/cone-05-long-bisque.json | 1 - storage/profiles/cone-6-long-glaze.json | 1 - storage/profiles/test-200-250.json | 1 - 18 files changed, 1070 insertions(+), 210 deletions(-) create mode 100644 .DS_Store create mode 100644 docs/logs 2.md create mode 100644 lib/.DS_Store create mode 100644 public/.DS_Store create mode 100644 public/assets/.DS_Store create mode 100644 public/assets/js/picoreflow 2.js create mode 100644 public/control.html create mode 100644 storage/profiles/Unni Stengodsglasyr.json delete mode 100644 storage/profiles/cone-05-long-bisque.json delete mode 100644 storage/profiles/cone-6-long-glaze.json delete mode 100644 storage/profiles/test-200-250.json diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a9211d2295a9c7dd5bf246bdd3793fb5f1c56103 GIT binary patch literal 6148 zcmeHK%}&EG40g5woe*LN1RQhWw!`=pJ0Mj94&0E6-~b33Izgq
| # | Target Time in ' + time_scale_long+ ' | Target Temperature in °'+temp_scale_display+' | Slope in °'+temp_scale_display+'/'+time_scale_slope+' | |
|---|---|---|---|---|
' + (i+1) + ' | ';
+ html += ''; + html += ' | '; + html += ' |
Oh no, you need a browser that supports WebSockets. How about Google Chrome?
').appendTo('#container'); + } + else + { + + // Status Socket //////////////////////////////// + + ws_status.onopen = function() + { + console.log("Status Socket has been opened"); + + $.bootstrapGrowl("Getting data from server", + { + ele: 'body', // which element to append to + type: 'success', // (null, 'info', 'error', 'success') + offset: {from: 'top', amount: 250}, // 'top', or 'bottom' + align: 'center', // ('left', 'right', or 'center') + width: 385, // (integer, or 'auto') + delay: 2500, + allow_dismiss: true, + stackup_spacing: 10 // spacing between consecutively stacked growls. + }); + }; + + ws_status.onclose = function() + { + $.bootstrapGrowl(" ERROR 1:'+state+'
'); + } + + $('#act_temp').html(parseInt(x.temperature)); + + if (x.heat > 0.0) { + setTimeout(function() { $('#heat').addClass("ds-led-heat-active") }, 0 ) + setTimeout(function() { $('#heat').removeClass("ds-led-heat-active") }, (x.heat*1000.0)-5) + } + if (x.cool > 0.5) { $('#cool').addClass("ds-led-cool-active"); } else { $('#cool').removeClass("ds-led-cool-active"); } + if (x.air > 0.5) { $('#air').addClass("ds-led-air-active"); } else { $('#air').removeClass("ds-led-air-active"); } + if (x.temperature > hazardTemp()) { $('#hazard').addClass("ds-led-hazard-active"); } else { $('#hazard').removeClass("ds-led-hazard-active"); } + if ((x.door == "OPEN") || (x.door == "UNKNOWN")) { $('#door').addClass("ds-led-door-open"); } else { $('#door').removeClass("ds-led-door-open"); } + + state_last = state; + + } + }; + + // Config Socket ///////////////////////////////// + + ws_config.onopen = function() + { + ws_config.send('GET'); + }; + + ws_config.onmessage = function(e) + { + console.log (e.data); + x = JSON.parse(e.data); + temp_scale = x.temp_scale; + time_scale_slope = x.time_scale_slope; + time_scale_profile = x.time_scale_profile; + kwh_rate = x.kwh_rate; + oven_kw = x.oven_kw; + currency_type = x.currency_type; + + if (temp_scale == "c") {temp_scale_display = "C";} else {temp_scale_display = "F";} + + + $('#act_temp_scale').html('º'+temp_scale_display); + $('#target_temp_scale').html('º'+temp_scale_display); + + switch(time_scale_profile){ + case "s": + time_scale_long = "Seconds"; + break; + case "m": + time_scale_long = "Minutes"; + break; + case "h": + time_scale_long = "Hours"; + break; + } + + } + + // Control Socket //////////////////////////////// + + ws_control.onopen = function() + { + + }; + + ws_control.onmessage = function(e) + { + //Data from Simulation + console.log ("control socket has been opened") + console.log (e.data); + x = JSON.parse(e.data); + graph.live.data.push([x.runtime, x.temperature]); + graph.plot = $.plot("#graph_container", [ graph.profile, graph.live ] , getOptions()); + + } + + // Storage Socket /////////////////////////////// + + ws_storage.onopen = function() + { + ws_storage.send('GET'); + }; + + + ws_storage.onmessage = function(e) + { + message = JSON.parse(e.data); + + if(message.resp) + { + if(message.resp == "FAIL") + { + if (confirm('Overwrite?')) + { + message.force=true; + console.log("Sending: " + JSON.stringify(message)); + ws_storage.send(JSON.stringify(message)); + } + else + { + //do nothing + } + } + + return; + } + + //the message is an array of profiles + //FIXME: this should be better, maybe a {"profiles": ...} container? + profiles = message; + //delete old options in select + $('#e2').find('option').remove().end(); + // check if current selected value is a valid profile name + // if not, update with first available profile name + var valid_profile_names = profiles.map(function(a) {return a.name;}); + if ( + valid_profile_names.length > 0 && + $.inArray(selected_profile_name, valid_profile_names) === -1 + ) { + selected_profile = 0; + selected_profile_name = valid_profile_names[0]; + } + + // fill select with new options from websocket + for (var i=0; i