dy-sh / MyNodes.NET

Home automation controller (new version available at https://github.com/dy-sh/singlehub)
GNU General Public License v3.0
73 stars 23 forks source link

Fix the mismatch of the input/output of mysensor nodes between what's… #24

Closed gildorwang closed 7 years ago

gildorwang commented 7 years ago

… linked on the editor and what is really linked, when the sensors are not registered in order of sensor id.

Issue:

When a mysensors node has multiple sensors, the order in which those sensors are registered is unpredictable, while AddInput/AddOutput always adds to the end, so we can have a list of inputs/outputs with different order from their sensor ID - this is not an issue.

However, when the node editor presents nodes with inputs and outputs, ConvertNodeToLiteGraphNode(Node) sorts the inputs and outputs with SlotIndex, which is essentially the sensor ID. And later when links are created from the editor, the slot_index from editor is directly used as index of inputs/outputs list on the server (NodeEditorAPIController) which is not sorted. As a result, wrong links are created.

Fix:

So essentially the fix is to try making sure the inputs and outputs lists are always sorted by the SlotIndex, and also in sync with the one in the editor. The fix is working in my scenarios. Please let me know if I missed anything. 😀

image

dy-sh commented 7 years ago

Thank you.