Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Connection handling & Logging, Power State handling #11

Merged
merged 9 commits into from Aug 6, 2022

Conversation

gbakeman
Copy link
Contributor

@gbakeman gbakeman commented Aug 2, 2022

Focus on improving the handling of NUT connections, entering and exiting OS power states, and logging throughout. Targeting issue #4 .

- WinNUT.vb: Added common logic for handling a disconnection from the UPS, as far as the application as a whole is concerned. This should hopefully fix a few bugs or at least add some stability.
- I shouldn't have put the Logger in the Globals module, IMO it belongs in the main client and passed as necessary to other objects.
- Remove user data from client library project.
- Modified Socket parameters, hoping this will help with IPv6 support
- Socket ConnectionStatus is derived from Socket directly
- Bring Logger object into Socket
- Create_Socket is turned into a subroutine; utilizing Events and Exceptions for communication
- Attempted to make AuthLogin failures non-critical
- Removed ReConnect subroutine from UPS_Device
- Additional bits of logging sprinkled everywhere
- Tried implementing Connection event for WinNUT to prevent hanging main thread, needs work
- No longer attempt to connect immediatly at start up
- Breakout UPS connection login into a seperate subroutine
- Tweak disconnection subroutine
- Reconnect menu now disconnects and connects again
- Uncomment part of prefs_changed, now disconnect and connect UPS again.
@gbakeman gbakeman added bug Something isn't working enhancement New feature or request labels Aug 2, 2022
@gbakeman gbakeman self-assigned this Aug 2, 2022
…or proper OOP

- Disabled auto-connecting to UPS on first start since it locks the GUI thread on a slow connection
- Cleaned up UPS_Connect subroutine for readability, improved log messages, and add a handler for lost_connection events
- Cleaned up UPSDisconnect function: Handlers removed, modified to be reactive in the UI rather than controlling the backend
- Disallowed changing config on the fly from external sources (a Nut_Socket object instead could be considered immutable, and must be destroyed if needing to change settings. Hopefully prevents unexpected bugs)
- Add a dedicated disconnect subroutine to the Socket class.
- Fixed underlying socket not being connected
- Removed dedicated ConnectionStatus variable; not quite sure what its purpose was (might regret this...)
- Made UPS_Device the dedicated object for handling connection monitoring logic (was competing with _Socket before)
- Disabled building installer in Debug mode
- Disabled WatchDog functionality throughout program, since regular data updating acts as a watchdog in and of its self.
- Modified Nut_Exception to carry the Nut_Exception_Value as a property
- Slightly reduced some Logging spam, and added a whole lot more.

Socket:
- Reorganized some functions/subroutines
- Removed some fatal exceptions when a bad authentication occurs, since basic operations can still occur.
- Removed exception handling from Query_Data so that exceptions are handled further up the stack.

UPS_Device:
- Connection events provide the UPS_Device as sender
- Data polling is now handled inside the class rather than in the Form, and the Form must access the data from the UPS_Device object rather than getting its own copy.
- Added Disconnect subroutine to handle shutting down a connection, from the UPS_Device.
- Added subroutine to handle NUT exceptions thrown from the socket. Not sure what to do with these yet.

WinNUT:
- Relocated data updating responsibility to UPS_Device
- Any attempts to disconnect now go through the UPS_Device
- Created a new subroutine UPSReady that fires when the UPS indicated it's ready to start receiving data.
Updating changelog and preparing pre-release upload
@gbakeman gbakeman marked this pull request as ready for review August 6, 2022 23:25
@gbakeman gbakeman merged commit 3041e93 into Dev-2.1 Aug 6, 2022
@gbakeman gbakeman deleted the #4-suspend-resume-dbg branch August 6, 2022 23:25
@gbakeman gbakeman linked an issue Aug 7, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Connection settings are not applied until application restart
1 participant