Hi there,
I have developed a filamentscale inside a dry box. Unfortunately I am not good at programming. So I am stuck with a problem that exceeds my skills. Perhaps someone else is interested in my project and is willing to help.
The plugin stores some values about filament spools in a text file. These values are stored in a list of dicts server side and in an ObservableArray client side. When transferring the values from one side to the other I use api_command/json.loads and json.dumps/send_plugin_message. (I know that a socket solution would be better but I couldn't get it to work.)
I get an error when loading data from the text file or adding data though the plugin.
My workaround is transmitting the data back and forth. But I'd like to get rid of that.
You can find my code here:
How to reproduce:
Comment out line 236 in __ini__.py
file_obj.close()
# self._plugin_manager.send_plugin_message(self._identifier, dict(filaments=self.filaments, active_filament=self.active_filament)) # my workaround
except IOError:
Start Octoprint and add some filaments to the list on the SmartScaletab.
Reload the browser and add some more filaments.
When trying to activate the filaments with a click on their name I get an error in/static/js/SmartScale.js
around line 100 - 1004.
This code works for the loaded data but the newly added data throws a "Mandatory parameter spoolweight missing for command load"
self.newFilament(self.filaments()[self.active_filament()].fila)
self.spool_weight(self.filaments()[self.active_filament()].spool);
self.material_density(self.filaments()[self.active_filament()].density);
This code works for the newly added data but the loaded data throws a "self.filaments()[...].fila is not a function"
self.newFilament(self.filaments()[self.active_filament()].fila())
self.spool_weight(self.filaments()[self.active_filament()].spool());
self.material_density(self.filaments()[self.active_filament()].density());
I must be doing something wrong when transferring/adding the data. I've read through the Knockout, Octoprint and lots of Java/JSON docs.
I know my code is a mess. Thanks for your effort.
Jebril.