Home › Forums › Software Development › [Solved] fixationDataStream.Next without Console.ReadKey ?
- This topic has 6 replies, 3 voices, and was last updated 7 years, 5 months ago by Dominic Potts.
- AuthorPosts
- 03/07/2017 at 18:29 #7117Dominic PottsParticipant
Hi, I’m just inquiring about the functionality of some of the sample code on the Tobii github.
Is it possible to run: fixationDataStream.Next += (o, fixation) =>
and print out fixation begin, end and duration coordinates until a certain condition is met, rather than using Console.ReadKey() to disconnect from the host?link: https://github.com/Tobii/CoreSDK/blob/master/samples/Streams/Interaction_Streams_102/Program.cs
Thanks,
Dom03/07/2017 at 21:52 #7121Grant [Tobii]KeymasterHi @dom202, as you can see in the sample code, the fixation information such as begin, end and duration is already included in the output text. Naturally, you can comment out the readkey function as use a different means to break. Perhaps the documentation describing the use of Activatable interactor @ https://tobii.github.io/CoreSDK/articles/interactors.html whereby a function is called when the user gazes at the area associated with the interactor and simultaneously presses a key on the keyboard would be useful for your needs?
If you could kindly be more specific in your needs regarding the ‘certain condition’, we will try to find you the appropriate solution.
04/07/2017 at 10:23 #7123Dominic PottsParticipantHi Grant, Thank you for the prompt response and apologies for not being specific.
The project I am working on is to do with so called ‘Information Foraging’ Theory, and involves dividing up a display’s content into ‘patches’ or blocks of a specified size that are then plotted onto the screen using the Tobii’s coordinates system. For example a 1080px display can be evenly divided up into 4 patches of size 960px X 540px (There are however multiple layouts)
I have a function that signals when every patch has been ‘foraged’ (when a patch has been fixated on at least once) and this is the condition I am testing. While all patches have not been foraged I want to run code that is very similar to the fixationDataStream.Next += (o, fixation) => {…} function in the aforementioned sample. It simply prints to console the begin and end fixation coordinates as well as the fixation duration timestamp.
I have all of this working perfectly, but I want to stop recording fixation once all patches have been ‘foraged’ automatically without the console.ReadKey().
I have tried implementing the conditional without using the console.readkey(), but the code doesn’t run at all. I’ve also tried wrapping fixationDataStream.Next in a while loop, but this did not solve the issue.
I will take a look at the documentation again, but if you have any advice it would be greatly appreciated!
–Dom
04/07/2017 at 12:10 #7124Alex [Tobii]ParticipantHi!
You can use a while loop with Thread.Sleep(10) instead of Console.ReadKey(). Please make sure to set _stop to true when all of your zones are visited.
private static bool _stop = true; public static void Main() { while (!_stop) { Thread.Sleep(10); } }
04/07/2017 at 14:07 #7126Dominic PottsParticipantHi Alex, Thank you for the response.
I forgot to mention that within the fixationDataStream.Next += (o, fixation) => {…}
section of my code I have some timers running to measure the time between user fixations. Simply sleeping the thread creates a race condition where all the threads are updating the timer simultaneously.I’ve read the documentation on the tobii github, but I was hoping that you could give me some insight into how this fixationDataStream.Next function works? Or perhaps an alternative to Thread.Sleep?
I really appreciate your help with this.
–Dom
04/07/2017 at 14:35 #7127Alex [Tobii]ParticipantfixationDataStream.Next is just a callback with lambda expression. You can transform it to process your callback in a function.
04/07/2017 at 15:19 #7128Dominic PottsParticipantHi Alex, your solution works fine. I was completely overthinking it!
Thank you for all your help!
–Dom
- AuthorPosts
- You must be logged in to reply to this topic.