Over the past week, I worked on getting RoCo's composite code interface working. To do this, I graphically constructed a component that would take input through a Serial port, convert that to a string, and output a signal to a motor based on the contents of that string. I would then try to export it and when it crashed, I would isolate the cause of this behavior and fix it.
As I was doing this, I noticed that many of the errors I faced were caused by the code that encoded the graphical interface into a text format in the front end then decodes it to create a builder file in the back end. Since the interface is built off of Blockly, I use some of the built in Blockly functionality to serialize the blocks. Blockly was initially built as a way of expressing code in Javascript, Python and other mainstream languages in a graphical format. To accomplish this, each block had a list of code snippets associated with it that would describe the block's functionality in all the languages it supported. Blockly has a function that converts the workspace to code, which essentially concatenates all the code snippets associated with each block taking into account the way that each of the blocks are connected to one another and returns a string of the source code.
In the composite component interface, each of the blocks are custom made and correspond to a component in the library. Since the code snippets for each block that Blockly comes packaged with are no longer relevant, I associated each component block with a list of the used inputs and used outputs. Then, when the workspace is converted to code using blockly, I get a string of the inputs and outputs for each component delimited by characters like underscore or backslash. This limits the names that each component can have. By placing this information in a JSON file instead, delimiters are no longer an issue and parsing will become much easier. I will be focusing on implementing this over the upcoming week.