10-26-2010 03:35 PM
Hello,
It seems that using this function doesn't work, making the EMI loaded .dll unusable. There are no apparent errors, the simulation loop runs smoothly, only the dll execution appears to freeze after the EMI_CB_ModelInterface() is called.
When selecting the .dll file at the beginning, a message box requiring to authenticate in order to open SIMX EMI Array Subset Wrapper pops out. This results naturally in an error since this is a core Labview VI, but if Relink to model... is chosen for the second time, the error is cleared. The correct number of outputs is placed in the vector but this is all that is done.
I have tried many combinations, but none of them made a difference. Removing the AddVectorOutput() function from the initialization routine is the only thing that gets everything working again. I really need the functionality associated with this function because I have a model with more than 25 outputs, which is the limit for block diagram scalar outputs.
Attached you will find the test .dll file with the AddVectorOutput called, together with the source file. The error function in CalculateDirectOutputs should signal when called, but it doesn't, hence that code isn't executed.
Tested on LV2010 + GCC compiler (from Codeblocks v.10)
Thank you for your help.
10-26-2010 04:39 PM - edited 10-26-2010 04:46 PM
Hello,
Using LabVIEW 2010 on Windows XP, I tried running the DLL you attached and I received an error message saying "EROARE !!!!!!!".
I then removed the call to EMI_SetError in EMI_CB_CalculateDirectOutputs and rebuilt the DLL using MSVC 7. The simulation then runs as expected and the "TEST" output produces an array of four zeros. I've attached this DLL. Let me know if it runs ok for you.
We need to figure out what is different about our setups. I guess from the include path you are using Vista or Windows 7? Are you on a 64-bit machine?
Cheers,
Damon
10-27-2010 12:37 AM
Thank you for testing the file!
I am indeed using Windows 7 x64, but generally I didn't have any problems other than faulty drivers for exotic hardware or paths not being set correctly by installers.
The error message was introduced to see if the function is being executed, so I guess that for you the program works. Your VI has the same effect as mine on my machine, that is just showing the correct number of outputs and that's it. I also tried to recompile the file using MS Visual C++ Express 2010 and received the same results.
I think the problem may be in the way the VI that pops up during the model loading (Array Wrapper...) handles memory, which fails to return a correct address. The number of outputs being set with their default values indicates that a part of the function is doing what it's supposed to, but the memory allocation routine is broken somehow. I cannot modify the core VI, so the only option left is to test it on a XP machine. The old interface relied on memory operations coded by the user (or so it seems from a model that I studied), the new one does this "under the hood" so it cannot be debugged properly.
Encapsulating the interface is a good thing for the end-user, but for development purposes, it just makes things much harder without proper debugging tools. I just wish that it would be better documented in the following versions, it's a powerful feature that isn't taken advantage of at full extent.
Regards,
Catalin
10-27-2010 11:05 AM
Hi Catalin,
I figured out what the problem was and it has nothing to do memory handling or incorrect addresses. The problem is that the "SIMX EMI Array Subset Wrapper.vi" should not be password protected. I've attached an copy with the password removed. If you replace the existing file on your machine (make sure to back up first!) then you should have no more problems. I've also attached an updated C file that puts {0,1,2,3} into the array for you.
"I just wish that it would be better documented in the following versions, it's a powerful feature that isn't taken advantage of at full extent."
This statement gives me the impression that you may be unaware that there is extensive documentation for the External Model Interface in the LabVIEW help file and online. Start here:
http://zone.ni.com/reference/en-XX/help/371894D-01/lvsimconcepts/sim_using_emi/
There is documentation on everything, from the call order for callbacks:
http://zone.ni.com/reference/en-XX/help/371894D-01/lvsimconcepts/sim_emi_order/
And complete documentation on all the callbacks and functions themselves:
http://zone.ni.com/reference/en-XX/help/371894D-01/lvsimemi/emi_callbacks/
I hope this helps you, and thanks for bringing the issue to our attention!
Damon
10-28-2010 12:43 AM
Thank you for your help, now it works on my machine too! ![]()
I searched for more information about the interface but only found one of the documents you linked to. I guess I didn't see the forest for the trees this time.
All the best,
Catalin