|
-
Oct 2nd, 2016, 12:39 PM
#1
Thread Starter
Frenzied Member
Threads + Synlock + Buffers
Hello
Need some advice, for this application that i'm building.
I have a machine that sends messages (ant+ messages with 5 different types and each one has 8 bytes), the timing isn't defined, but i get several messages in one second, and doesn't have any specific order. The data that i save for each message will vary with the message type, but will be short or integer.
I have 3 requirements, from order of importance to the system:
1 - Save all the data in buffers, while testing, i'm using 5 sorted lists, the keys are the ticks, and the value it's the value in the message.
Question: Is this the best way to store the data? And about the event handler, the sdk does all the job to receive the data (event onDataReceived), but then defining the procedure to handle this data to save, how to make it run in a different thread?
2 - One of the buffers need to be re sent in another channel but with a predefined timing 250ms/500ms/1s (not defined by now), to do this, i was thinking in creating a timer and in the elapsed event, i'll get all values received, within the the predefined timer, if it's one second, i'll get all itens in the list that the keys are greater than the tick value of the previous second, and get the average of the values and sent.
Question: The buffers will be "shared", so i need to control the access, synlock? Other way? Or just use a double buffer approach? What's the best way to receive all data, and to do this? If the sortedlist it's the ay to go, binarysearch and extension method select?
3 - Interface, that shows the data received, some thread, that get the last value of each buffer at intervals of one second.
Question: The same problem, getting data from the buffers and the shared memory.
The general workflow of the app, start the GUI, user click in start, the system resets and start listen and start sending. Main problem, shared access without losing anything. 
So this is programming and approach to the problem question, doesn't know in what section to post so i posted it here.
Thanks
Rate People That Helped You
Mark Thread Resolved When Resolved
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|