1
Open Discussion / Re: What would you like to see in the next major release?
« on: November 09, 2018, 01:25:22 PM »Since you already have some "Run as a Service" solution, would you care to share it with members of this forum as well?
To provide a basis to build on, I'll first refer to the following MS tutorial on creating a windows service:
https://docs.microsoft.com/en-us/dotnet/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer
Once you've got a Service created, add an AHMI Com component such as ethernetIPforCLXCom, from the toolbox, to the design sheet. You can now read from or write to the PLC just as you do within a normal Windows Forms App.
I wasn't able to get the DataSubscriber to work within a Service, possibly due to my own incompetence, although it had worked within a Windows Forms App. But it's pretty easy to achieve the same thing. I set up a 500ms timer to read a tag and compare it to the previous value. If it has changed, then I call a function to deal with it. That's essentially what the DataSubscriber does behind the scenes.
In my case, the data I wanted to collect was a 128-byte string that the PLC updates every 15 to 45 seconds. In order to avoid having to read that entire string every 500ms, I setup a Boolean tag that the PLC toggles after every update of the 128-byte string. So I can monitor the Boolean value every 500ms, but I only need to read the long string if the Boolean value has changed. Note: The Boolean value is returned by ethernetIPforCLXCom.Read() as a string, i.e. "True" or "False", even though the PLC sends it as a bit, 1 or 0.
LG