PLCgen::TNG (The Next Generation)
Last week I heard about the results of a real-world system test that was conducted at RWS.
While everything was working as desired, with respect to PLCgen generated PLC code, two things were noted.
- It's large.
- It's a mess to track down a problem in the PLC (ie a PLC engineer at site trying to figure out what the cause of a problem is by looking at the PLC code in the live system).
I agree with both points.
Wrt to the first item, we flatten all structure of the model and thereby eliminate all re-use of functionality, so obviously it explodes in size.
A (perhaps) naive approach would be to preserve the model structure and translate it to PLC function blocks. The model may not have optimal structure. It would be interesting to try that though.
Wrt to the second item, I think the root cause is that we throw all events onto one heap and try them all (repeatedly) in some fixed arbitrary order. There is no logic structure for a PLC engineer to follow as with (I assume) handwritten code. Instead they have to randomly jump back and forth between event processing for different (possibly unrelated) sub-systems before finding the point they are looking for.
Throwing all events at one heap seems a very blunt approach here. It is never the case that all events happen in the same cycle. Eg a door cannot both open and close in the same cycle. In addition, not all events are connected to each. Opening and closing of one door has nothing to do with opening and closing of a second door. (Maybe at a higher level they come together, but at sensor level they don't interact.) In other words, there has to be structure in the events that we are not using currently.
So I think a relevant question is how to structure the heap of events? Related (but not sure how), there has to be structure in the flattened model. This may give a path to better code structure. It likely also causes shifts in event order and thus touches #911 and perhaps other computations.
Addresses #679