How does it work?

How does it work?

The first thing to be clear about is how the Framework works.

When the program starts, all controls of type ViSnap7 contained in Control_List.PlcControlTypes are searched.

Knowing the type of memory area and the bytes they occupy, each client (depending on the number of PLCs used) is configured in such a way that once the list of controls is complete, it is known which memory areas should be read.

For example, let’s imagine 4 controls (of any type, which is irrelevant) in such a way that they occupy the following areas:

  • DB10, DBW20
  • DB10, DBD34
  • MD500
  • MW510

With this information the following memory areas are read:

  • In DB10, from byte 20 to byte 37, both included
  • From MB500 to MB511

So we have 4 controls but 2 readings will take place.

There will be areas of memory that will be read unnecessarily (eg MB504 to MB509), but it is more efficient to read more while not making more read calls.

Every time the number of open forms changes, this process is repeated as the number of active controls of type ViSnap7 can change.

This background work is done with the BackgroundTasks.AccomodatePlcData method

Once in each cycle, the UpdateControl method of each control is executed.

In this method, the information of the control is read, and if it were the case, the writing tasks are executed in the PLC.