ASP.NET Core Communication

Situation:

I need to create some kind of control piece of communication over Modbus TCP / IP in my ASP.NET Core project.

Communication is working properly with Modbus, but I need to read some Modbus addresses and I need to set the interval. I have a structure like this for this in db.

I now have a singleton called CommunicationRepository, which is such a controller for this protocol and has methods for reading from a module, writing to a module, structures for data from modules, etc. and creating CommunicationRunners.

Communication link diagram

CommunicationRunner is something that can wait to pass the interval and pass a delegate from CommunicationRepository, which then reads a specific Modbus address.

CommunicationRunner diagram

Problem: This is now done with async which slows down everything else - page navigation, responses from the web api, etc. Offcourse this problem is recognized at small intervals (eg 10ms).

How can I make it more stable without distortion? Do I need to use streams? If, how exactly?

I would appreciate some code examples.

Thanks and look at the images.

0


source to share





All Articles