Beckhoff-USA-Community / SPT-Libraries

MIT License
70 stars 16 forks source link

Method ModeChanged() is called after the LastState assignment statement. #55

Open ulysses936 opened 1 month ago

ulysses936 commented 1 month ago

The ModeChanged() method is called when the PackML mode is changed, but currently there is no way to determine the LastMode at the time of the method call because the LastMode is assigned to the current Mode before the method is called.

If the mode before the change of mode is available, it is possible to apply different logic for different modes. For example, if I only want to trigger a logic when switching from Auto to Manual, but not when switching from Invalid to Auto mode at machine startup, LastMode is necessary.

I think it would be better to call the ModeChanged() method before LastMode is reassigned, but I'm not sure if that would have any other implications.

image

AB#4761

SimmelFlo commented 1 month ago

I can see your use-case. We will review the request and if there are no negative side-effects we will roll it into the next release.

nshiggins commented 1 month ago

This would be nearly impossible to regression test. I like the idea though. Maybe another library parameter to allow the timing of the call to differ?

On Sun, May 12, 2024 at 11:47 Simmel Florian @.***> wrote:

I can see your use-case. We will review the request and if there are not negative side-effects we will roll it into the next release.

— Reply to this email directly, view it on GitHub https://github.com/Beckhoff-USA-Community/SPT-Libraries/issues/55#issuecomment-2106296301, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEMHY7JJQMINVOJ3N7SPSLTZB6FKLAVCNFSM6AAAAABHS4W7W2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBWGI4TMMZQGE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ulysses936 commented 1 month ago

I moved the ModeChanged method call before LastMode is assigned and generated a new library file, no problems encountered so far, I think it's because the ModeChanged method isn't used anywhere else in the library, only the user of the library overrides the method to add their own logic.