Skip to content

Commit

Permalink
fixed for #94
Browse files Browse the repository at this point in the history
  • Loading branch information
LazeMSS committed Jan 8, 2023
1 parent 684655b commit 4c1b4b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
17 changes: 10 additions & 7 deletions octoprint_toptemp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# coding=utf-8
from __future__ import absolute_import

Expand All @@ -18,6 +17,7 @@
import threading
import queue
import time
import math

class TopTempPlugin(octoprint.plugin.StartupPlugin,
octoprint.plugin.SettingsPlugin,
Expand Down Expand Up @@ -253,7 +253,7 @@ def on_settings_initialized(self):
# make sure changed customMons are returned
def on_settings_load(self):
returnData = self._settings.get([],merged=True, asdict=True)
returnData['customMon'] = self.customMon;
returnData['customMon'] = self.customMon
return returnData

# Save handler - has a bit of hack to cleanup remove custom monitors
Expand Down Expand Up @@ -336,7 +336,7 @@ def on_settings_save(self,data):
data['customMon'] = newCust.copy()

data['firstRun'] = False
self.customMon = newCust.copy();
self.customMon = newCust.copy()

#Needed to write all the data
octoprint.plugin.SettingsPlugin.on_settings_save(self, data)
Expand Down Expand Up @@ -734,8 +734,10 @@ def handleCustomData(self,indx,out,time):
if indx not in self.customHistory:
self.customHistory[indx] = []
self.customHistory[indx].append(resultData)
# slice of 300
self.customHistory[indx] = self.customHistory[indx][-300:]
# we keep the history for double the needed just for fun
sliceMe = math.ceil(0 - ((int(self.customMon[indx]['gHisSecs'])/int(self.customMon[indx]['interval']))))*2
self.debugOut(indx + " only wants " + str(self.customMon[indx]['gHisSecs']) + " seconds of data - we need to slice: " + str(sliceMe))
self.customHistory[indx] = self.customHistory[indx][sliceMe:]

# send to the frontend
self.debugOut("Sending data to UI, " + indx + " : " + str(out))
Expand Down Expand Up @@ -775,7 +777,7 @@ def on_api_command(self, command, data):
self._logger.info("Sending items monitored")
sortOrder = self._settings.get(["sortOrder"],merged=True,asdict=True)
custom = self._settings.get(["customMon"],merged=True,asdict=True)
curTemps = self._printer.get_current_temperatures();
curTemps = self._printer.get_current_temperatures()
returnList = {}
lastValues = {}
for item in sortOrder:
Expand Down Expand Up @@ -878,7 +880,8 @@ def runcommand (self,cmd):
std_out, std_err = proc.communicate(timeout=self.cmdTimeout)
except subprocess.TimeoutExpired:
proc.kill()
return -1, "\""+cmd+"\" timed out", "Maximum execution time, 5 seconds, exceeded!"
self._logger.warning("\""+cmd+"\" timed out")
return -1, "\""+cmd+"\" timed out", "Maximum execution time, "+self.cmdTimeout+" seconds, exceeded!"

return proc.returncode, std_out.strip(), std_err

Expand Down
4 changes: 2 additions & 2 deletions octoprint_toptemp/static/js/TopTemp.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ $(function() {
}
}else{
var reval = 0;
graphData = {'series' : [self.tempModel.temperatures[name].actual.slice(-300).map(function(val,i){return val[1]})]};
graphData = {'series' : [self.tempModel.temperatures[name].actual.slice((0-iSettings.gHisSecs())).map(function(val,i){return val[1]})]};
}

var MinYVal = reval;
Expand Down Expand Up @@ -350,7 +350,7 @@ $(function() {
self.customHistory[data.key] = [];
}
self.customHistory[data.key].push(data.result);
self.customHistory[data.key] = self.customHistory[data.key].slice(-300);
//self.customHistory[data.key] = self.customHistory[data.key].slice(-300);
self.FormatTempHTML(data.key,{'actual' : data.result[1]},true);
}

Expand Down

0 comments on commit 4c1b4b4

Please sign in to comment.