JKISoftware / JKI-State-Machine-Objects

Object-oriented framework for LabVIEW based on the JKI State Machine
BSD 3-Clause "New" or "Revised" License
95 stars 54 forks source link

SMOFacade:Call does not correctly handle clusters #71

Closed Monkeymerlot closed 2 years ago

Monkeymerlot commented 4 years ago

Describe the bug I was playing around with the Facade methods, and tried to create a simple test where I would add two numbers in a cluster together and return their result. However, when called by the facade, we get an error. image

This is how I was calling the method: image (where I cleared the errors to prevent them from influencing downstream behavior/popups.) Inside the Call.vi, the error originates in the Prep Inputs: image

Taking a look at the functionality inside the Prep Inputs, we can see that the input data type is an array of size two, with each element being a doubles, while the data is supposed to be a variant containing two doubles: image

This actually leads me to believe that cause of the error originates in MatchInputs.vi: (screenshot is taken in Call.vi) image image

And just incase you were curious, this is what Add.vi looks like: image image where the SMO will add the results and return them using a notifier created in the Add.vi method.

To Reproduce Steps to reproduce the behavior: I attached a sample project with all of the VIs. Facade.zip Open the project and in the FacadeTest.lvclass you can run ExampleError.vi to see the error using the facade, or to verify that the method works itself you can use the TestLauncher.vi, which should not produce an error.

Expected behavior I expect to get a variant containing a single double of the value 3. I did a sample setup in the test launcher to verify that this method works, so the facade should provide the same outputs as the method in the class.

Desktop (please complete the following information):

Let me know if you need any more details!

Best, Joe

francois-normandin commented 4 years ago

I don't have the code in front of me, but I think the "Matched Input" node could be a little smarter indeed. It seems to consider the cluster as a way to wrap up multiple terminal types into a single cluster...

To test this hypothesis, can you simply add a "build array" node before you wire the value in? If I'm correct, the inputs might match. This could provide a workaround until the node is fixed.

image

Monkeymerlot commented 4 years ago

Thanks for your quick reply! Unfortunately, that doesn't seem to fix the issue... image image image

This is what the values in and out of Matchinputs.vi look like now: image

However, bundle instead of build array did the trick: image image and result: image

francois-normandin commented 4 years ago

ok, I've taken a look inside the MatchInputs and there are some use cases that are not correct. I've made it work by inserting a "Array elements to Cluster" in the path:

image

Use this node and insert it in your MatchInputs method as a workaround:

Variant_BuildClusterFromElementArray_LabVIEWOpenSource.zip

Monkeymerlot commented 4 years ago

That made it work! Thanks so much!