Jump to content

Francois Normandin

Members
  • Posts

    1,209
  • Joined

  • Last visited

  • Days Won

    47

Posts posted by Francois Normandin

  1. index.php?app=downloads&module=display&section=screenshot&id=152

    Name: LVOOP Event Handler

    Submitter: François Normandin

    Submitted: 07 Oct 2010

    File Updated: 03 Jan 2011

    Category: LabVIEW OOP

    LabVIEW Version: 2009

    License Type: BSD (Most common)

    LVOOP Event Handler v1.0.1

    Copyright © 2010, François Normandin.

    All rights reserved.

    Author:François Normandin

    Contact Info: Contact via PM on www.lavag.org

    LabVIEW Versions:

    Created and tested with LabVIEW 2009

    Dependencies:

    openg_appcontrol 2.10

    openg_error 2.3

    Description:

    This is a package that provides the framework for a LVOOP Subscribable Event Handler.

    Processes can dynamically register new events and list the classes that are allowed to subscribe to it.

    Once a TopProcess takes ownership of the Handler, it manages a Global Stop event and a Handler Activity event to inform subscribers that a new event has been registered with the handler. All subscribers can then get a list of all the events they are allowed to subscribe to.

    Everything is done through events with LVOOP LVObject as a backbone. The subscriber will then be free to implement its interpretation of the subscribe event content when received, by casting to the known object types.

    Instructions:

    After installing package with VIPM, refresh palettes if VIPM is not set to refresh automatically.

    Use palette to find the LVOOP Event Handler. Select the Event Handler VI and drop it in your application.

    There is a test program that shows how data is exchanged between three dummy classes. You can open the front panel

    of the Event Handler to see what are the actual allowed subscribers for which event owner.

    Known Issues:

    Acknowledgements:

    History:

    v1.0.0: Initial release of the code. (2009)

    v1.0.1: Fixed a wrong connection with the "Preserve RunTime Class" primitive where children classes were not considered as such when a parent class was passed.

    Better error handling on Destroy Handler command. (Caused a code 1 error when event destroyed by owner prior handler command.

    Added the Event Description string to the connector pane.

    License:

    Distributed under the BSD license.

    Support:

    If you have any problems with this code or want to suggest features:

    please go to www.lavag.org and Navigate to the discussion page.

    Distribution:

    This code was downloaded from the LAVA Code Repository found at www.lavag.org

    ============================

    How it works:

    This framework consists of a FGV Event Handler that manages the interactions between publishers and subscribers to events. It consists of some commands that allow the use of generic LVOOP events.

    It allows the owner to control a Global Stop command, which can be listened by any VI. Once initialized, any process can register its own events and choose which classes are able to subscribe dynamically to it.

    A generic event notifies all subscribers to a change in the list of the events available, so that no VI needs to poll constantly to detect the new events or unsubscribe from events that are unregistered by its owner.

    Commands:

    1- Initialize Handler: The first VI to call the initialization takes ownership of the handler. All other calls before the handler is destroyed will return an error.

    2- Subscribe: Default case. When a VI subscribes to event, it will receive a list of all events for which it is allowed to register. Then the VI can decide what it does with the incoming data on that event channel.

    3- Register: Any VI can register an event refnum (LVOOP type) and decide which object types can subscribe to it. If no input is provided, or if LVObject is in the list, then all are allowed to subscribe. A notification is sent via the Handler Activity event.

    4- Unregister: Any VI that owns an event can remove it from the list. A notification is sent to everyone that listens to the Handler Activity event to prevent the need for poling.

    5- Global Stop: Only the owner of the handler can call a global stop. It is meant to protect the integrity of the program should a subscriber decide to play god.

    6- Destroy Handler: Releases the command to any process that wants to initialize it. It also erases all events still registered. It can only be called by the Handler's owner.

    ***************

    There is an example VI in the LVOOP Event Handler palette.

    Click here to download this file

  2. Froncois,thank you so much. it just worked!! i think there were 2 corrupted images among that directory files which made it not functioning. thanks. I have 3 questions :

    1- now when i click and hold the mouse left button, it shows the pictures and select the picture when i hold the mouse on the picture and then release the left button. Is it possible to make it like normal drop down which by first click it pulls down and shows the pictures and then selecting the picture just by clicking on that?

    2- is it possible to make the combination drop down menu ( see the image) by using picture array?

    3-Is there any way to scrolling pictures by scrolling the middle button of mouse?(i need this function for another user interface)

    Again, Thank you a lot and appreciate your patience and kind effort.

    I was thinking of corrupted files when I sent you the test VI. But it's so rare...

    Concerning your questions, it surely is possible to use the events to do what you want. You need to activate/deactivate the events based on the last action performed. Wiring a constant to the references deactivates them, and wiring the correct reference activates them. Establish a list of the sequences you need to achieve what you want and code them accordingly as shown in the VI I posted.

    (1) What's the detailed list of user interactions for this? That's what you need to code. Ex: When left-click is detected, show the scroll down pictures and activate two choices: a) if mouse leaves, close the drop down menu or b) if user left clicks again, select it. In the example I showed, I used the Mouse Up event, but if you replace those by Mouse Down, it might work without further modifications. Try it, and if you don't succeed, upload your modified code to show what you tried.

    (2) You could add to the code to check for a condition when the user selects a picture that should have a second drop down menu to show this second picture array (make it visible) and position it where the user had clicked. Configure the events to react exactly the same way has for the first array of pictures (select or hide) depending on the mouse down/leave events.

    (3) You'll notice, in the Event cases, that there is an inside terminal with a list of things like buttons, coords, ctl ref, etc. The button terminal lists which button is activated. I'm not sure how you can scroll your list with the scroll button of the mouse, but it might be doable. Never tried that.(I don't think there is a "Mouse Scroll?" event)

  3. it does'nt show any error!! but still no picture is shown. here is the image with highlighting execution.

    I think the pictures are there...

    What is the size of your images???

    Resize the picture frame in the array to show more if needed, but if they're huge, use an image editor to reduce the pixels to what you need to display in the array. I used a 32x32 picture, but enlarge it to what you want. It doesn't have to be square. However, the array elements are not resizing automatically to your picture size.

  4. Array indexing inside a for loop is a killer. Actually concatenating isn't too bad due to optimisations (LV is very efficient with For-loops). I vaguely remember a challenge from Jim Kring to find a better method than concatenating for selecting arbitrary values from an array. I don't think there were any takers.

    So assuming that we have to concatenate in some form or another the best we can hope for is pre-processing. Along this line what about finding turning points? Maybe faster, maybe not but it would uses in-build functions (generally faster than native LV) and eliminate the array indexing.

    Isn't the array intersection the result of the terms present in both arrays? You show the list of terms that are present at least in one, not both.

  5. Yes I have png files. I tried the new file you just sent. again the same problem. As you see in the image, when i select the folder which contains png files nothing is selected in "file name" section. it doesn't select neither by selecting and hiting open button nor by double click or etc.!!!

    Browse to the folder that contains a list of your images (the usual double-clicks to open the folder). When you see the png files listed, select "Current Folder" at the bottom right.

    <object id="scPlayer" class="embeddedObject" width="634" height="478" type="application/x-shockwave-flash" data="http://content.screencast.com/users/normandinf/folders/Jing/media/41ae1109-54db-438b-b200-e462ec7e9383/jingh264player.swf" >

    <param name="movie" value="http://content.screencast.com/users/normandinf/folders/Jing/media/41ae1109-54db-438b-b200-e462ec7e9383/jingh264player.swf" />

    <param name="quality" value="high" />

    <param name="bgcolor" value="#FFFFFF" />

    <param name="flashVars" value="thumb=http://content.screencast.com/users/normandinf/folders/Jing/media/41ae1109-54db-438b-b200-e462ec7e9383/FirstFrame.jpg&containerwidth=634&containerheight=478&content=http://content.screencast.com/users/normandinf/folders/Jing/media/41ae1109-54db-438b-b200-e462ec7e9383/2010-10-01_0941.mp4&blurover=false" />

    <param name="allowFullScreen" value="true" />

    <param name="scale" value="showall" />

    <param name="allowScriptAccess" value="always" />

    <param name="base" value="http://content.screencast.com/users/normandinf/folders/Jing/media/41ae1109-54db-438b-b200-e462ec7e9383/" />

    <video width="634" height="478" controls="controls"><br />

    <source src="http://content.screencast.com/users/normandinf/folders/Jing/media/41ae1109-54db-438b-b200-e462ec7e9383/2010-10-01_0941.mp4" type="video/mp4;" /><br />

    <b>Your browser cannot play this video. <a href="http://www.screencast.com/handlers/redirect.ashx?target=viewingembededhelp">Learn how to fix this</a>.</b>

    </video>

    </object>

  6. I tried again but still when i browse to select a directory which contains my pictures,either in non-executing mode and executing mode! it does not select the directory. could u double check the file yo sent me? Thanks

    Did you have any PNG files in the directory? You can change it in the code if you use other formats. Also, I've limited it to the four first file in the folder for the demo, but you can change that in the code.

    I've changed the code to ask for the folder on startup.

    <a href="http://content.screencast.com/users/normandinf/folders/Jing/media/6fa447b3-276b-484f-a496-3d3f10261a04/2010-10-01_0905.png"><img'>http://content.screencast.com/users/normandinf/folders/Jing/media/6fa447b3-276b-484f-a496-3d3f10261a04/2010-10-01_0905.png"><img class="embeddedObject" src="http://content.screencast.com/users/normandinf/folders/Jing/media/6fa447b3-276b-484f-a496-3d3f10261a04/2010-10-01_0905.png" width="306" height="284" border="0" /></a>

    PictRing.vi

  7. Thank you guys. as michael said i have not that much experience but i m trying to either make my project and also learn labview. it's hard but i ma really interested . I have to read more about xcontol and picture controls.

    This won't do the cascading effect, but you can have a quick look at how you could use a simple array of pictures with events to act as a drop-down picture ring.

    PictRing.vi

    • Like 1
  8. EDIT: Yeah, I thought I remembered this example from John.

    Jon, sorry to quote myself, but I had edited an earlier post and since it was past midnight in Montreal, I didn't think you'd miss it... but then it was afternoon in your part of the world.

    This example by John Lokanis is reusable code directly. Unzip and check the first example.

    All I did yesterday was to copy John's GIF on the Front Panel of the calling VI that would be deferred, and insert John's code while it was being deferred, thus producing the effect of seeing one GIF stop (deferred panel) and the other being superimposed in a new window.

  9. <edit>

    Ok maybe a stupid question?

    How do I get a gif on the FP.

    Drag and Drop not supported.

    Subpanel does not update if calling VI panel is deferred :(

    Well, thats good to know that.

    </edit>

    I had the same problem with dropped GIF... but check the edit I made concerning John Lokanis' example...

    <object id="scPlayer" class="embeddedObject" width="272" height="370" type="application/x-shockwave-flash" data="http://content.screencast.com/users/normandinf/folders/Jing/media/3c02b570-2242-47fd-b675-9a5e8884cc3c/jingh264player.swf" >

    <param name="movie" value="http://content.screencast.com/users/normandinf/folders/Jing/media/3c02b570-2242-47fd-b675-9a5e8884cc3c/jingh264player.swf" />

    <param name="quality" value="high" />

    <param name="bgcolor" value="#FFFFFF" />

    <param name="flashVars" value="thumb=http://content.screencast.com/users/normandinf/folders/Jing/media/3c02b570-2242-47fd-b675-9a5e8884cc3c/FirstFrame.jpg&containerwidth=272&containerheight=370&content=http://content.screencast.com/users/normandinf/folders/Jing/media/3c02b570-2242-47fd-b675-9a5e8884cc3c/2010-09-30_0038.mp4&blurover=false" />

    <param name="allowFullScreen" value="true" />

    <param name="scale" value="showall" />

    <param name="allowScriptAccess" value="always" />

    <param name="base" value="http://content.screencast.com/users/normandinf/folders/Jing/media/3c02b570-2242-47fd-b675-9a5e8884cc3c/" />

    <video width="272" height="370" controls="controls"><br />

    <source src="http://content.screencast.com/users/normandinf/folders/Jing/media/3c02b570-2242-47fd-b675-9a5e8884cc3c/2010-09-30_0038.mp4" type="video/mp4;" /><br />

    <b>Your browser cannot play this video. <a href="http://www.screencast.com/handlers/redirect.ashx?target=viewingembededhelp">Learn how to fix this</a>.</b>

    </video>

    </object>

  10. I want to defer panel updates as specific FP Objects are UI intensive, but at the same time I want to show the user that something is happening (with another object on that panel, e.g. Status or Throbber) but it is not possible when I have deferred panel updates set!

    You could try with a simple animated gif.

    wait2.gif

    Would it stop too with deferred panel updates?

    EDIT: Yeah, I thought I remembered this example from John.

    RE-EDIT: Well, deferring panel updates does stop the animation. But John's example is a superposition of a transparent VI which won't be affected...

  11. This is a dataflow problem.

    When you split a wire, you split data. You've created a race condition where you carry the information on two wires, modify the data differently on both and then each one races to update the Array.

    Remember that LabVIEW is not using pointers to controls or indicators. Follow one wire and make each function work on the data previously modified by the node before.

    <object id="scPlayer" class="embeddedObject" width="630" height="378" type="application/x-shockwave-flash" data="http://content.screencast.com/users/normandinf/folders/Jing/media/40e1f056-bf17-46df-bd03-df951dffa53d/jingh264player.swf" >

    <param name="movie" value="http://content.screencast.com/users/normandinf/folders/Jing/media/40e1f056-bf17-46df-bd03-df951dffa53d/jingh264player.swf" />

    <param name="quality" value="high" />

    <param name="bgcolor" value="#FFFFFF" />

    <param name="flashVars" value="thumb=http://content.screencast.com/users/normandinf/folders/Jing/media/40e1f056-bf17-46df-bd03-df951dffa53d/FirstFrame.jpg&containerwidth=630&containerheight=378&content=http://content.screencast.com/users/normandinf/folders/Jing/media/40e1f056-bf17-46df-bd03-df951dffa53d/dataflow.mp4&blurover=false" />

    <param name="allowFullScreen" value="true" />

    <param name="scale" value="showall" />

    <param name="allowScriptAccess" value="always" />

    <param name="base" value="http://content.screencast.com/users/normandinf/folders/Jing/media/40e1f056-bf17-46df-bd03-df951dffa53d/" />

    <video width="630" height="378" controls="controls"><br />

    <source src="http://content.screencast.com/users/normandinf/folders/Jing/media/40e1f056-bf17-46df-bd03-df951dffa53d/dataflow.mp4" type="video/mp4;" /><br />

    <b>Your browser cannot play this video. <a href="http://www.screencast.com/handlers/redirect.ashx?target=viewingembededhelp">Learn how to fix this</a>.</b>

    </video>

    </object>

    • Like 1
  12. I just started to make a Vi project today. All of the sudden when i tried to re-open it , it showed me an error message which I attached here. I also attach my file. I don't know hoe it happened and i would appreciate if you could help me to open it up!

    Thanks

    Farid,

    when you upload code that is not in the same version as the one you show in your profile, please add a note for the version the VI is saved in.

    I don't have LV2010 installed, so I can't help you. But I wouldn't have tried if there was a note next to your uploaded file. ;)

    Worst case, if the file is corrupted and the code inside is very complex and hard to duplicate, perhaps NI can help?

  13. Even though I have a plan for the content. It will be evolving over time based on your feedback. I would love to hear from all of you.

    What would you love to see as some of the content on the site?

    What LabVIEW related topics would you like to see covered?

    Have you considered a Collaborative Videos Repository?

    I mean there would be a process for people to submit how-to videos about any LabVIEW topic and have a review team certify the videos content before it would be put online?

    This way, you could have as broad a list of topics as you can dream and in a few years, that would be quite an interesting resource... for beginners and advanced LabVIEW user alike.

  14. Glad to hear it's not a homework.

    To add or delete users from the database, you will have to have a file which contains you credentials.

    Steps to implement:

    1- Create a file that will contain the usernames, passwords (encrypted would be best...) and privileges. (You can "salt" your encryption

    If your file will be small, load its content on initialization and store it in the Cluster from easy access.

    If your file is to be deployed, create VIs to access the file throughout your program (call when needed).

    2- Create a VI that will read the data from file and a VI that writes (or modifies) the data in file.

    3- Add two states in the case structure for saving to file and reading from it. These states will be called when you have a logon (read) or add/delete user credentials (write).

    4- Create two more states (add user / delete user) and associate the buttons for adding and deleting users in the Event structure to call these states when required. You will handle all the hiding/showing of controls in these states. These options will be revealed in the Login state if the user has logged in as an admin. If so, enqueue a new state to reveal the "Add user" and "Delete user" on the front panel.

    5- In the Event structure (Idle state), associate the OK button from the delete or add users and call a sequence of states (using Queue VIs) to perform the necessary actions (Show/Hide stuff, read database, write to database, verification, etc.)

    Try this and upload your modified code if you need more help.

    • Like 1
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.