LabVIEW: Count how long a button has been pressed - arrays

I'm trying to create a LabVIEW VI with an "ok button", a numeric indicator "Number of click" and an array of cluster, in which every cluster contain a TimeStamp indicator and a numeric indicator.
When the VI is running I want to keep track of:
When the button is released (timestamp)
How long the button has been pressed (in millisecond or second).
Then, when i click on STOP, i want to visualize these information about ALL the button pression in the array of cluster.
That's what I've done. I've tried to change the manner in which I create the array, and also the "Tunnel mode" in the While loop, but it doesn't work..
Can you help me? Thank you all!

please check my attached code and compare it with yours.
It's the simplest method, but you may also read about Event Structure, which would help to do that in much smarter way. Additionally you may want to change my code a bit to have indicators being updated in real-time instead after the exit. It's worth also reading about "Feedback node" and "Conditional" type of output tunnels. They would help to simplify the code, but I didn't use them to keep it as simple as possible!

Related

Flink drop late records even I specified the side output

I use flink to process dynamoDB stream data.
Watermark strategy: periodic, extract approximate time stamp from stream events and use it under withTimeStampAssigner.
Idleness: 10s(may not be useful at all as we only use parallism of 1.)
The data work flow looks like this:
InputStream.assignTimeStampsAndWatermarks().keyby().window(TumblingEventTimeWindow.of(1min).sideOutputLateData().reduce().map()
Then I getSideOutput(), and process the late events using exactly similar above workflow with small change such as no need to assign time stamp and watermark, no need for late output.
My logs show that all things work perfectly if ddb stream data has right timstamp, the corresponding window can close without issue and I can see the output after window is closed.
However, after I introduced late events, the late records processing logic is never triggered. I am sure that the late record’s timestamp corresponding window has closed. I put a log after I call getSideOutPut(), it never triggered. I used debugger and I am sure the getSideOutput() code is not triggered as well.
Can someone help to check this issue? Thank you.
I tried to use a different watermark strategy for late records logic. This doesn’t work as well. I want to understand why the late records are not collected to the late stream.
Without seeing more details from your implementation is difficult to give an accurate diagnosis, but based on your description, I wouldn't expect this to work:
Then I getSideOutput(), and process the late events using exactly similar above workflow with small change such as no need to assign time stamp and watermark, no need for late output.
If you are trying to apply event time windowing to the stream of late events, that's not going to work unless you adjust the allowed lateness for those windows enough to accommodate them.
As a starting point, have you tried printing the stream of late events?

multiple timer with end result text

I need to show three timers, something like this:
'https://codepen.io/kaicarver/pen/pyaKVR' or 'https://jsfiddle.net/7bk5mw9y' of whatever as long as it shows three timers, (preferably with a start all button)
the three contesters need to stop their time, so far all possible with both scripts.
After the last one presses stop the page should show a message below the scores.
I am searching and coding for days now without luck.
I am way to beginner to achieve this. Is there anyone here who knows an existing script that does this of maybe have a simple solution?

Overlapping Toastbar messages

I'm using the ToastBar messages with timeout 6 seconds. If I click another button within 6 seconds which will display another toastbar message, second one will overlap with first one in some instances. How can a dispose first message and display second message without overlapping if the button is clicked before timeout occurs. Please advise.
ToastBar.showErrorMessage("Test Message", 6000);
Thanks
Make sure you are always invoking this method from the EDT and not from a separate thread e.g. the network thread. Use the edt error detection tool in the simulator to try and track such issues.
I have the same issue. First I tried to make sure that I do not call each message using the same object reference, but also use local variable instances to allow the Garbage Collector (GC) dispose them since the instance is discarded when the task is done.
However, this may take some time and the message still appears overlapping or even worse, it repeats itself with out a trigger, but less likely (infrequent) now because the GC collects the object.
It may be tempting to call the GC manually if possible, but then you need to assess performance impact.
I have not attempted yet the approach I am about to suggest, but let me know what you think.
Making it so, that ToastBar messages appear one on top of the other when triggered. Maybe a List<ToastBar> object or other similar may prove useful. This may be described as a ToastBar "buffer".
The other way around is to clear() the message but then if it is too long it will not allow the user the necessary time to read the feedback.
I have this in my TODO list but will follow up when I make some additional progress.

How to detect when text is replaced in GtkTextBuffer instead of delete followed by insert?

I have worked a great deal with the text system in Objective-C for macOS/iOS (e.g. NSTextView, NSTextStorage, etc.) I am now experimenting with GTK3 to see how well I can translate my project for use on Linux, etc.
I am brand new to using GTK, but after a few days of Google time and experimenting, I have a working text editor prototype with my custom code plugged in.
The problem is this -- I need to be able to detect when a user highlights a section of text, and then replaces it with other text (e.g. a keystroke). This is distinct from highlighting a section of text, hitting the delete key, and then typing the new text. A specific use example would be highlighting a word, then typing a double quote character in order to wrap the word in quotes (e.g. foo becomes "foo").
In Cocoa, one would receive replaceCharactersInRange: that indicates the range originally selected, as well as the new string to replace it with. I can then detect the presumed intent of the user based on the information received.
In GTK, it seems that we receive a delete-range signal, followed by a separate insert-text signal. Because of this separation, the code in the "insert" section has no way of knowing that the user intended to replace text, not insert new text.
I used the following to receive the signals above:
g_signal_connect(buffer, "insert-text", G_CALLBACK(insert_text_cb), NULL);
g_signal_connect(buffer, "delete-range", G_CALLBACK(delete_range_cb), NULL);
Is there something else I can do in order to tell that there is a delete, followed by an insert as part of the same user action?
Thanks for any pointers offered!
Instead of trying to correlate the delete and insert events, I would suggest creating a GAction for your desired action (e.g. toggle quotes around the selected text) and setting its shortcut key to " using gtk_application_set_accels_for_action().
For more information, check out this HowDoI wiki page.
No answers over the last month, so I kept brainstorming and digging around. I finally came up with this, which works, but is not quite as elegant as I had hoped.
Handle delete-range signal as before, but keep track of the the deleted text for later (e.g. in char * deletedText).
Handle the insert-text signal as before, but if we have a string in deletedText then change the behavior to perform a replacement instead of an insertion. In my case, this actually meant inserting the deleted text back in, and then performing the replacement.
Add a callback for the end-user-action signal, which indicates that all delete/inserts associated with a particular action are complete. In this callback, free deletedText from above and set to NULL (to indicate that everything has been handled).
Again -- this works, but feels a bit inelegant. And depending on how complex your delete/insert routines are, it may slow the performance slightly since some steps have to be duplicated. A better solution would be to detect during the delete-range callback that there is a pending insert-text callback and handle both steps at once. I have thus far not been able to do that.

How to read string from a field without pressing enter

I have a barcode scanner that needs to read data into a database whenever a barcode is scanned. All the scanner does is take the barcode and create a string with it. Barcodes, however can be variable lengths.
The idea behind it is to have a java class open, and the user will scan multiple barcodes one after the other (without pressing the enter key). This class must then take each barcode and read it into a database.
I need help to read the strings from the scanner without the user having to press enter each time (as this makes the program pretty useless and not very user friendly)
Thanks. Looking forward to finding a solution!
I've done something similar to this in .NET but the concept should be about the same.
I would set a timer up with a delay long enough to be a sign that input has stopped but not too long to cause delay - so say 500ms.
On text box update event you ensure both that the timer is enabled and that you reset the timer essentially giving you another 500ms to enter more information.
On the timer tick event or equivalent you do your action (in your case save to the DB) and disable the timer, ensuring you don't affect focus during the processing obviously.
Assuming you also clear the text box, you can then after whatever delay you specify scan something else and trigger the exact same functionality.
Note this may fall down if you ever have to fall back to using a keyboard instead of barcode scanning. At the very least if this was the case you would need to research a better delay value that would accommodate both or maybe provide a way to disable the timer and revert back to using the enter key
Hope this helps

Resources