Events in classes LabVIEW 8.6
i have class with some member (counter of something)
and i want to generate a user event when this member has specific values.
currently i manage to generate the event only if i register the event of the class
in the Top Vi that use this class
can i register the event inside the class itself, let say inside the initilize vi that i ave for the this class ?
thanks
Solved!
Go to Solution.
The question is a little confusing. You can register for the event anywhere you like, but somewhere you pretty much need to have an Event Structure in a running VI waiting for that event to occur.
What should be aware of these events? Class members
P.S. On second reading, it seems you might just be asking if you can register the event in a class VI, instead of having to register it in the top-level VI. If that's the case, then yes you can. Just have the Register for Events function inside the Initialize VI of your class and have it output the Event Registration Refnum corresponding to your event.
Message Edited by Jarrod S. on 11-02-2008 08:48 PM
Jarrod S.
National Instruments
Similar Messages
-
Event Handling in labview with arrays as event data
Hey folks,
I have a Labview Application which uses a dll to read Ethernet data. The setup is such that, when the dll has fresh data it sends out an event to the Labview Application so that the fresh data can be displayed.
However i have only managed to get this event based mechanism to send out a single structure at a time. Hence if there are 10 fresh data values, i need to send out 10 events (each event structure contains the parameter name, parameter value, unit and time stamp). It would be more efficient to send out an array of structures in a sigle shot.
I have tried this but Labview keeps crashing saying that an error was encountered and Labview needs to close along with an access violation message. I did a lot of online searching and found some LV code for event handling but not come accross any implementation which uses arrays as evend data. Is this supoorted? And if so is there any example vi that can be shared so that i get some knowledge about this.
Many Thanks in adavance,
Abel.I also gave a try by using a variant as the event data type instead of the cluster which contains the array of floats. I converted the cluster into a variant and used that to create the user event reference. Followed the same logic while decoding the dats.
But still the crash.... Here is the windbg output...
ModLoad: 07580000 075b7000 C:\Program Files\National Instruments\LabVIEW 2012\resource\lvalarms.dll
ModLoad: 0ca90000 0cb72000 C:\Program Files\National Instruments\LabVIEW 2012\resource\mesa.dll
ModLoad: 0c7f0000 0c7f9000 C:\Program Files\National Instruments\LabVIEW 2012\resource\lvuste.dll
ModLoad: 35000000 3509b000 C:\Program Files\National Instruments\Shared\TDMS\tdms.dll
ModLoad: 0c860000 0c87c000 D:\SapphireViewer\dll\SapphireClientDll.dll
ModLoad: 0e240000 0e2c7000 C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.6195_x-ww_44262b86\MSVCP80.dll
ModLoad: 0e2d0000 0e36b000 C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.6195_x-ww_44262b86\MSVCR80.dll
(1cb0.1a34): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=0e47f8b4 ebx=051f0040 ecx=051f0040 edx=061e5764 esi=22820840 edi=07b10040
eip=03c2050c esp=0e47f5cc ebp=0e47f810 iopl=0 nv up ei pl nz na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010202
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Program Files\National Instruments\LabVIEW 2012\resource\tdcore_12_0.dll -
tdcore_12_0!LvVariant:etContents+0xac:
03c2050c 837e3100 cmp dword ptr [esi+31h],0 ds:0023:22820871=????????
I cannot really tell whats going on. Looking for some pointers.
Regards,
Abel. -
Creating a singleton Event Listener class
A typical singleton OO design pattern involved a protected (or private)
no-arg
constructor and a public instance() method that manages a private static
variable
referencing the single instance, internally invoking the no-arg constructor.
A class designated in web.xml as a <listener> must have a public no-arg
constructor.
(from http://e-docs.bea.com/wls/docs61/webapp/app_events.html#178593)
Anyone thoughts on how to accomplish both goals?
What I want to do: I'd like to set up a singleton to listen for session
events.
Other code will query this one-and-only-one session event listener for
various
information. Some of this info I can currently get from the runtime via
MBeans but
some I can't, hence my investigation into session event listeners.
TIA, matt.Hi Matt,
This sounds like a case where you will need to have two classes -- your
singleton class, and then your session event listener class, which would use
the singleton class.
Dennis Munsie
Developer Relations Engineer
BEA Support
"Matt Hembree" <[email protected]> wrote in message
news:[email protected]..
A typical singleton OO design pattern involved a protected (or private)
no-arg
constructor and a public instance() method that manages a private static
variable
referencing the single instance, internally invoking the no-argconstructor.
>
A class designated in web.xml as a <listener> must have a public no-arg
constructor.
(from http://e-docs.bea.com/wls/docs61/webapp/app_events.html#178593)
Anyone thoughts on how to accomplish both goals? -
JTabbedPane single event handling class.
I have a list of proxyNames which are stored in a Vector.
These proxy names are then displayed as Tabs accordingly.
For every tab there is a specific action to be performed.
I want to write a single event handling class for handling all events.
What I have is this:
while(eNum.hasMoreElements()){
Object proxyName = eNum.nextElement();
tabbedPane.addTab(proxyName.toString(), null, null, "Proxy");
tabbedPane.addChangeListener(itemHandler);
panel4.add(tabbedPane2);
class ItemHandler implements ChangeListener{
public void stateChanged(ChangeEvent e){
for(int i=0; i < v.size(); i++){
// Perform action on choosing the concerned tab...
How do I have a single event listener?Yikes! Is that a minimal program? When I am trying to do something new, or facing a problem that causes me to get stuck for more than an hour, I create a short program to solve just that problem. In time, you create a directory of test programs that's useful, and with practice, solving a problem in isolation is a faster (and generally better) way to go about things that doing it all in a larger application.
Any way, here is your code, with a change listener added in method makeSubpanel. If you don't want the listener called the very first time, add it at the end of this method. I also fixed some bugs in createProxyList.
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
public class TrialTabbed extends JPanel {
// Will hold all file names read from the /config directory.
private Vector v,v1;
JTabbedPane tabbedPane,tabbedPane2;
Object proxyName;
public TrialTabbed(){
tabbedPane = new JTabbedPane();
// Instantiate the Vector.
v1 = new Vector();
Component panel1 = makeTextPanel("Blah");
tabbedPane.addTab("Debug Mode", null, panel1, "Debug");
Component panel2 = makeSubPanel();
tabbedPane.addTab("Normal Mode", null, panel2, "Normal");
// Add the tabbed pane to this panel.
setLayout(new GridLayout(1, 1));
add(tabbedPane);
protected Component makeTextPanel(String text) {
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
private Component makeSubPanel(){
JPanel panel4 = new JPanel(false);
panel4.setLayout(new GridLayout(1, 1));
tabbedPane2 = new JTabbedPane();
//new code - a change listener for pane2
tabbedPane2.addChangeListener(new ChangeListener(){
public void stateChanged(ChangeEvent e){
int tab = tabbedPane2.getSelectedIndex();
if (tab == -1)
System.out.println("no tab selected");
else {
String filename = tabbedPane2.getTitleAt(tab);
File file = new File("..", filename); //brittle!
if (file.isDirectory()) {
String[] contents = file.list();
int size = contents == null ? 0 : contents.length;
System.out.println(filename + " contains " + size + " files");
} else
System.out.println(filename + " has length " + file.length());
//end of new code
ItemHandler itemHandler = new ItemHandler();
v = createProxyList();
// Enumerate thru the Vector and put them as tab names.
Enumeration eNum = v.elements();
while(eNum.hasMoreElements()){
proxyName = eNum.nextElement();
tabbedPane2.addTab(proxyName.toString(), null, null, "Proxy");
panel4.add(tabbedPane2);
return panel4;
// Display the file names in this directory as tab Names.
//new code: changed dirName to "..", fixed some obvious bugd
private Vector createProxyList(){
String dirName = "..";
File file = new File(dirName);
if(file.isDirectory()){
String[] s = file.list();
for(int i=0; i< s.length; i++){
v1.addElement(s);
} // End for.
} // End of if.
return v1;
} // End createProxyList().
class ItemHandler implements ChangeListener{
public void stateChanged(ChangeEvent e){
System.out.println(v.size());
System.out.println("IN CHANGE LISETENER" + proxyName.toString());
} // End actionPerformed.
} // End Inner class ItemHandler.
public static void main(String[] args) {
JFrame frame = new JFrame("TabbedPaneDemo");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
frame.getContentPane().add(new TrialTabbed(),BorderLayout.CENTER);
frame.setSize(500, 425);
frame.setVisible(true); -
Broadcast events between classes (objects)
Hello,
I'm can't figure out how to broadcast an event to another
class.
In actionscript 2 I created 2 classes. The first class called
the second class to load a file from an url. When the file was
loaded I used dispatchEvent({type: "fileLoaded", target: this,
filename: sFilename})
In the first I simply wrote addEventListener("fileLoaded",
handleFile)
But with AS3 this no longer works.
Can anyone tell me how to accomplish this? Because I can't
find a clear example and I don't know how to do this.In the defintion of your custom event I miss the isEnabled
part (don't know if that has anything to do with the issue though).
Below a custom event that works for me
package Components {
import flash.events.Event;
public class ZoomEvent extends Event
public var isEnabled:Boolean;
public static const ZOOM:String = 'zoom';
public var vertical:Boolean = true;
public var minvalue:Number = 0;
public var maxvalue:Number = 0;
public var zoomfactor:Number = 0;
public function ZoomEvent(type:String,
isEnabled:Boolean=false) {
super(type);
this.isEnabled = isEnabled;
public override function clone():Event {
return new ZoomEvent(type, isEnabled);
Furthermore I have somewhere read in the documentation that
using custom event should go together with adding an embedded
statement like: [Event(name="update",
type="Components.UpdateEvent")] in the class where you use the
event, but for me it also works without this embedding code (???)
And is your class XMLData a subclass from a class that
supports dispatchEvent. I do not know what classes support
dispatchEvent, maybe all. Then this remark makes no sense.
Good Lcuk -
What is the problem with this event handler in LabView 8.0?
Please find attached a copy of a simple Event Structure VI. Can anyone please tell me why the Pos 0, Pos 1, Pos 2 work fine, but Pos 3 does Not????? It works in Version 7.1 of Labview, but Not in version 8.0. Any help here would be appreciate
Everything is Free! Until you have to pay for it.
Attachments:
ValChgEventBug.vi 29 KBHi,
It doesn't work because the logic is flawed. If you run the VI in Execution-Highlight mode you will see that for a value-change of, say, 7.0, all the cases (except the first one) are True! And since there is no data dependency, whatever case executes last will set the final position.
You will want to change the logic to check if the value falls in a range, rather than just being greater than something. For isntance, the psuedo-code would be:
"go to position 2 IF value >= 4 AND < 6"
You are missing the "AND" part. Hope this helps.
-Khalid -
Dear Fellow LabVIEW programmers:
Most of the systems you deal with are reactive. It means that their
primary function is constant interaction with their environment by
sending and receiving events. But most likely, they can have something
happening inside them too, even when they are not processing messages
received from outside. So, such systems have to continuosly react to
external and internal stimuli. Right? Moreover, most likely, they
consist of subsystems that are reactive too and, in turn, can have
their own "life", to an extent independent from other parts (with
which they still communicate, of course). Reactive (event-driven)
systems are more naturally modeled with active objects. So, why then
should we try to model and code them with GOOP and its passive
("dead"!) objects?
"Flat" State Machines have been known for decades to have severe
limitations. It's been more than 20 years since Dr. Harel invented
Hierarchical State Machines (statecharts) to fight those limitations.
Then why does NI still tout the same old good Moore FSM as the
ultimate tool for event-driven programming in LabVIEW in its $995
State Diagram KIt?
The LabHSM toolkit we are happy to present, makes it possible to
easily create and then maintain complex event-driven applications in
LabVIEW as a collection of HSM-driven active object VIs using a higher
level of abstraction and agile software development methodologies.
These active object VIs are created based on a universal Hierarchical
State Machine ( HSM or statechart ) template. So. all your code looks
similar regardless of its functionality!
We all love just jump to code, right? However, to be good boys, we
need to do design first. Then implement it in code. If the logic is
modified we need to redo the design first and then redo the code. When
using LabHSM where behavior information is abstracted into a separate
HSM data file editable with a supplied editor, there is no need for
coding separate from design any more. The modified behavior becomes
code automatically as soon as the HSM file is saved. Design is code!
The implementation basically follows Dr. Samek's Quantum Programming
paradigm. (see http://www.quantum-leaps.com). However, as already
mentioned, LabHSM stores the behavior information in a file separate
from the code itself. It also adds state dependent priorities to
events, a separate queue for public events/messages, and, of course,
some LabVIEW specific code like capturing front panel user events and
putting them into the private Events queue. Communication and
instantiation functions are also rather specific for LabVIEW.
It is available for UNLIMITED PERIOD trial. Please visit
http://www.labhsm.com for details and download. The site also contains
references which you may want to check to learn more about
hierarchical state machines and active object computing.
Since this is our debut we will appreciate any comments and
suggestions. Our contact information is available on our site, of
course.
Have a G'day!Symtx is currently hiring the following position. Please contact me if interested.
Amy Cable
Symtx, HR
[email protected]
Symtx, the leading supplier of functional test equipment, hires the brightest & most talented engineering professionals to design & manufacture complex custom electronic systems for advanced technology leaders in the defense, aerospace, communications, medical, transportation & semiconductor industries. Symtx’ challenging & dynamic work environment seeks to fill openings with highly qualified electronic engineering design professionals.The ideal candidate will be responsible for defining the requirements, software design and code development, and integration of test control software for custom functional test systems. Candidate should be familiar with data acquisition concepts, instrument control, complex test, measurement and calibration algorithm development and definition and implementation of control interfaces to hardware. Prefer familiarity with instrument control via GPIB, VXI, MXI, RS-232 desirable. Requires BS/MSEE and 3 -7+ yrs of experience in one or several of the following test applications in a Windows NT/2000/XP environment using Labwindows CVI, TestStand, Labview, Visual Basic, C++ and knowledge of RF systems is a plus. Job responsibilities will include software design, development, integration, team leadership, and interfacing with customers( includes PDR’s & CDR’s). -
Canoe Event Handling in Labview
Anybody worked on handling the events of CANoe in Labview?
I am trying to handle the event when there is a value change in the environment variable of CANoe. CANoe provides a COM method "OnChange" but i do not know how to implement this method in Labview. This method is available in CANoe -> Application-> Environment->EnvironmentVariable-> then event OnChange.
Any ideas??
Thanks,
SuhasHello,
I'm willing to handle the same process as you, but I did not yet success. I attached my project, and I think my problem is more Labview than CANoe. If you successed or if anyone already have done such diagram with VICallback and Event Data, please have a look, I'm really fighting without success now.....
Attachments:
CANoe_Graphic.vi 22 KB
sub2.vi 12 KB -
Event Acquisition in LabView Signal Express
I have the USB-6009 data logger and LabView Express. I am trying to record certain events as they happen in the process. The signal I am recording is a 0 or 10 V DC signal and each time that signal goes to 10V DC I want to record that as a event. I am not worried about the actual voltage just the event. I am not sure what the best way would be to set this up in LabView signal express. Any advice on how to achieve this.
Hi CoryB,
In SignalExpress you can create events by in the Recording Options tab clicking Events. Then, in the Category list select Add. From here, you can change the options for the event. Here is a link to the help on the events page.
Also, Dennis is absolutely correct. You will get better assistance with your questions if you post in the correct board.
Bill E. | Applications Engineer | National Instruments -
Hi all
Can any one explain me the functionality about events and event handlers in ABAP OO??
Thanks and Regards,
Arun JosephHi there
Whilst the SENDER doesn't know about the RECEIVER the reverse is not true. Some people might (wrongly) infer from the comment about the sender that the receiver doesn't know either. I'm only adding the comment below hopefully to clear this up for some people who perhaps a new to OO programming and OO ABAP in particular.
By using the parameter SENDER the receiver can know what object triggered the event. This is of course useful where you have say multiple grid displays on the screen and an action needs to be performed depending on what object triggered it.
class lcl_event_handler definition.
* CLASS cl_event_receiver
* DEFINITION
public section.
methods:
*--To add new functional buttons to the ALV toolbar
handle_toolbar for event toolbar of cl_gui_alv_grid
importing e_object e_interactive
sender,
*--To implement user commands
handle_user_command
for event user_command of cl_gui_alv_grid
importing e_ucomm
sender,
class lcl_event_handler implementation.
*--Handle Toolbar
method handle_toolbar.
* PERFORM handle_toolbar USING e_object e_interactive .
endmethod .
*--Handle Hotspot Click
method handle_hotspot_click .
* PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no .
create object go_handler.
set handler go_handler->handle_user_command
for go_grid1.
set handler go_handler->handle_user_command
for go_grid2.
form handle_toolbar
case g_sender
when go_grid1
etc
sorry if this info is a case of "stating the obvious" but reading the forums there's quite a bit of confustion surronding event generation and handling in OO ABAP.
Cheers
jimbo -
Active x and event callback in Labview
I have an active x written by Aanderaa Instruments (makes
weather and hydrology sensors), it contain various methods and events to get
the next line of records from a sensory scanning unit. The connection is
through the COM1, so far i have wired it up only using the methods to get next
record level, but then I have found that sometimes it does not get the complete
record from the COM port. So to solve that I have to use an event in the active
x to check for new record available. So what I want to do is send the event
(when complete record available) to VI that uses the get next record method to
pick up the data from the COM1 port and then send the data back to the main VI
for processing, plotting and writing.
My problem is that when I connect the output from the GetNextRecord method to a
indicator that I then wire on the connector pane to be an output from this
VI get an error that there is a wire function conflict. I have tried to
explain a bit better in the attached pdf file with diagrams.
The reason why I want to export the data back in the main VI is because it runs
continuously collecting data every 2 min and I plot them on a graph and write
them to a file so it will no work to have all that done in the event callback
VI that will only run ever 2 min, then it will reset the graph the whole time
and I want continuous data plotting for 10 days of historic data records. I
also have a few other sensors that come in through a connector board that are
written o the same file.
hope somebody can give me some hints
Attachments:
labview question.pdf 721 KBDuplicate post, click here for the original: http://forums.ni.com/ni/board/message?board.id=170&message.id=135639#M135639
LabVIEW Champion . Do more with less code and in less time . -
Could i use page unload event in Class Library (Web part)?
Hi,
I am creating Web Part using visual studio class library. I am going to deploy it in SharePoint environment.
I want to do some functionality while page unload. Is there anything like that?
Could anyone tell about it?
Thanks & Regards
Poomani SankaranHi,
According to your description, my understanding is that you want to create a web part programmatically and then do some functionality in the page unload event.
There is a web part method called WebPart.OnUnload method, you can override this method and add the custom code to the override method.
Here are some detailed articles for your reference:
https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.webpart.onunload(v=office.14).aspx
http://www.codeproject.com/Articles/25019/Developing-SharePoint-WebParts
Thanks
Best Regards
Jerry Guo
TechNet Community Support -
Configure event of class to trigger workflow...
Hi,
When a material is created, the standard event CREATED gets triggered of BO 'BUS1001006'.
But my client wants everything to be handled based on classes.
So i have created a custom class and its custom event 'CREATED' which needs to be triggered once a material is created.
So my question is how will i trigger this custom event of custom class. Is there any configuration that needs to be done for the same?
For now, i am planning to trigger the custom event in a BADI or user exit using standard FM 'SAP_WAPI_CREATE_EVENT'.
Kindly suggest your ideas.
Regards,
GuddanHi- My suggestion is, let the WF be triggered using std BO and event. For additional custom methods, you create a new WF based class
Also you need to decide, is it required to create an instance for the class (for instance method)
Vinoth -
Hi All,
I would like to know if events (instance/static) can be raised within class constructors. My understanding is that events can be raised but not of the same class as the class constructor belongs to.
Please clarify.
Thanks and Regards,
Vidya.Hi Vidya,
Welcome to SDN.
see this link
http://help.sap.com/saphelp_nw04/helpdata/en/41/7af4eca79e11d1950f0000e82de14a/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/0a/b552f7d30911d2b467006094192fe3/frameset.htm
http://help.sap.com/saphelp_nw04s/helpdata/en/41/7af4eca79e11d1950f0000e82de14a/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
for Implementing constructor outside class implementation..
use this code
codeREPORT zkarthik.
CLASS counter DEFINITION
CLASS counter DEFINITION.
PUBLIC SECTION.
*METHODS CONSTRUCTOR.
CLASS-METHODS: set IMPORTING value(set_value) TYPE i,
increment,
get EXPORTING value(get_value) TYPE i.
PRIVATE SECTION.
CLASS-DATA count TYPE i.
NO explicit constructor
*METHOD CONSTRUCTOR.
*WRITE:/ 'I AM CONSTRUCTOR DUDE'.
*ENDMETHOD.
ENDCLASS. "counter DEFINITION
CLASS counter IMPLEMENTATION
CLASS counter IMPLEMENTATION.
METHOD set.
count = set_value.
ENDMETHOD. "set
METHOD get.
ENDMETHOD. "get
METHOD increment.
ENDMETHOD. "increment
ENDCLASS. "counter IMPLEMENTATION
DATA cnt TYPE REF TO counter.
START-OF-SELECTION.
Implicit constructor is called
CREATE OBJECT cnt.
CALL METHOD counter=>set
EXPORTING
set_value = 5.
END-OF-SELECTION.[/code]
happy learning.
thanks
karthik -
ActiveX event queue in Labview 7.0
I've acquired an Ortec toolkit with ActiveX controls and am trying to
follow the procedures shown in the manual for handling ActiveX
events. The manual tells me to add 'Create ActiveX Event Queue
node', "Wait on ActiveX Event Node' and 'Destroy ActiveX Event Queue
node' to my vi. The problem is, the manual was written for
Labview 5.1, and I have Labview 7.0, which no longer uses these
nodes. Instead, LV 7 uses the 'Register Event Callback Node'. Can anyone tell me how to alter the attached vi to use the Register Event Callback Node instead of event queueing?
Attachments:
EventsExample.vi 80 KBhi there
see attachment for an example (because i don't had your control i used one of MSCOMCTL)
best regards
chris
Best regards
chris
CL(A)Dly bending G-Force with LabVIEW
famous last words: "oh my god, it is full of stars!"
Attachments:
AX Events 7.0.zip 13 KB
Maybe you are looking for
-
Problem with Facetime and my MacBookPro camera
Hello, I've got a MacBookPro and I have a problem with Facetime and my front camera. When I have a discussion with an iMac or an other MacBook the image received by the other person becomes fix. To unfix it I have to put my finger on my camera and th
-
My powerbook can't recognize a font!
Hi, experts! I have a FFIL font(New Baskerville) for my web design job. I've copied it to Fonts folder a few times but either Font Book nor other applications such as Photoshop. Could anyone help me? Thanks in advance.
-
if you go to the creative explorer, and click on the settings, button, then the settings tab, there is an option to change the start-up screen, but the "change" button is always unavailable. is it possible to change the splash screen on the zen micro
-
Is there a way to get rid of those "red lines and boxes" that surround email text?
The red lines and boxes I refer to in the question do not cause any real problems, but editing email, cut and pasting, etc., can get a little complicated with them appearing in the text of an email. I couldn't see any setup or option that referred to
-
Getting "Document Dimensions" Readout to Stick
I like to set the little status area at the bottom left of my image window to "Document Dimensions", because I like to watch the pixel count. It will stay like this during my editing session once I set it. Unfortunately whenever I go to look at the t