Looking to get my hands dirty #29
Replies: 1 comment
-
@scottmwyant Thanks for looking into this and yes the ShdrAdapter is something I'm working on updating. The UpdateDataItem method uses a Dictionary<string, IEnumerable> to keep a list of dataitems for that DataItemKey so since IEnumerable doesn't have an Add method (the variable is a List but accessed as an IEnumerable) then that is why I was creating a new List and adding existing items as well as the new item to it. Items are removed from the list/queue when they are sent although I do need to look at how to manage client disconnections with this by either clearing the list or limiting the list to a certain size. I'm sure this could be optimized and honestly this was something I did as a quick fix as I was previously only storing the latest ShdrDataItem for the corresponding DataItemKey and the adapter would send that value at the specified Interval. But I wanted to have the ability to send everything added to the Adapter so I updated it to keep a list. Now that I seem to have things more settled on the Agent side of things I plan to focus on the Adapter side. Some of the things I would like to do is:
I have a number of updates to include in the next 0.6.0 Release (which I should have ready next week) so I will plan to include any updates for the Adapters to 0.7.0. Thanks for looking into this and for the feedback. Feel free to submit Pull Requests or Issues for anything you find or want to improve. -Patrick |
Beta Was this translation helpful? Give feedback.
-
Hi @PatrickRitchie,
I'm seeing some things in the MTConnect.Adapters.Shdr.ShdrAdapter class that aren't making a lot of sense to me. Happy to submit a PR but wanted to reach out first. Looking at the
UpdateDataItem
method specifically; you check if the incomingdataItem.DataItemKey
exists in the Dictionary and if it does, copy all the DataItems for that key to a new list, check if the incoming one exists in the List, and if not, add it.I'm not understanding why you need to swap out the entire List vs just add the incoming DataItem. Secondly, if I'm reading it right, DataItems are only ever being added to the List for their respective keys, but it seems like they should be removed at some point.
Again, I am willing to dig into this but want to make sure I'm not missing something with the design before doing so.
Beta Was this translation helpful? Give feedback.
All reactions