How do I add custom block menus to the VisSim drop down bar?
Submitted by Joe on Sat, 09/29/2012 - 10:24
Thank you very much for the advice. I was able to start with your example and get everything working.
Just a few more questions:
-
Is there any way to left justify the block title for a userFunction? I list a bunch of parameters in the title of my block and it is very hard to read. If I left justify it, it would be easier.
If this is not possible, is there a way to make it so that right clicking brings up the file chooser dialog (which I've already programmed) but then double left-clicking brings up a different dialog that would display the static parameter values? -
How do I add custom block menus to the VisSim drop down bar? I'd love to have custom submenus where I can select my custom .dll blocks. It would be great if they were accessible from the main Blocks drop down window.
-
Every time I insert a userFunction block, I have to add in all of my connectors before linking it to the .dll because the connectors aren't automatically added when I load the .dll to accommodate the correct number of inputs and outputs. Is there a way to have this done automatically when the .dll is linked to the userFunction block?
Answers
-
Submitted by Anders89 on Sat, 09/29/2012 - 10:48.
1) No, you can't left justify, but you can insert new lines using '\n'.
2) If you used the VisSim DLL wizard to create your DLL project, you already have the code to insert your block in the VisSim menu as below:
/* User menu Table * These menus will be setup by VisSim if the DLL registered in the Edit > Preferences... > Addons list */ static USER_MENU_ITEM um0[] = { /* Top level menu name, DLL name, -2 */ {'&My Blocks', 'My.DLL', -2} /* level 1 (top level) block menu item */ /* Category menu name, DLL name, -1 */ ,{'Block Class1', DLL_NAME, -1} /* level 2 (category) block menu item */ /* menu name, function name, input count, output count, size of local data struct, quick help string */ ,{'PI Regulator', 'piRegulatorFun', 2, 1, sizeof(PID_BLOCK_INFO),'PID'} /* level 2 menu item #1 */ ,{'&My Funky Block', 'MyBlockFun',1,3,sizeof(MY_FUNKY_BLOCK_INFO),'Configure Fixed Point Block Set'} /* level 2 (category) block menu item */ ,{'About My Funky Block Set...', 'aboutFun', 0,0, 0,'About my Block Set'} /* level 2 menu item #1 */ ,{0}}; EXPORT32 int EXPORT PASCAL vsmInit() { setUserBlockMenu(um1); return 0; }
3) If your DLL is registered in the Edit > Preferences... > Addons list, then the blocks will show up in the VisSim menu, and have the proper number of inputs and outputs when inserted to the diagram.
0