gawindx / WinNUT-Client

This is a NUT windows client for monitoring your ups hooked up to your favorite linux server.
GNU General Public License v3.0
416 stars 70 forks source link

NUT protocol in .Net DLL/Library #54

Open gbakeman opened 3 years ago

gbakeman commented 3 years ago

I tried reaching out to you via email since I wasn't sure if this should be an issue, but I wanted to let you know that I've started working on core NUT functions in a .Net library here. I'd really appreciate your feedback!

gawindx commented 3 years ago

I got your email, but I didn't have time to process the information, a fairly busy week at the pro level.

i'm trying to watch this weekend and i'm getting back to you.

gawindx commented 3 years ago

It may be promising but I cannot judge for the moment, your code is far from being completed and mine is not sufficiently successful either to allow the functioning of the library to be tested.

You can get inspiration from my code to move forward on your project, I don't have any problem (at least for the part concerning the communication with the NUT server). For my part, I have to advance on WinNut and prepare the next version which will be able to use your library (there will surely be adaptations to be made when the time comes).

I think you will have to take into account:

This means a rather difficult task because in your case, your library should be a tool that goes everywhere.

In my case, there is also a lot of work left which means that your project could allow me to progress more quickly on the other parts of the code by not wasting time on the communication part to the NUT server.

What do you think?

gbakeman commented 3 years ago

That is excellent feedback, thank you. I was thinking I could use this issue to track progress and provide occasional updates, and you gave me a good list of features and goals I should aim for.

Thank you!

gbakeman commented 3 years ago

Just want to provide an update here. A lot of the basic functionality is done at this point. The library implements nearly all of the NUT protocol at this point, so variables can be retrieved and set, user logged in and out, etc. I'm finishing implementing one query right now, but unless you have other plans, I think I might make a branch of your code and start trying to add the library to it.

gawindx commented 3 years ago

Please note, I am currently working on the 2.1 branch which contains many modifications in the code. Among other things, I also set up a DLL which contains the functions which will be necessary for the creation of a windows service. So I completely revised the way to communicate between the GUI and the NUT server. 2 new classes have seen their appearance:

Your project would integrate more at the level of these 2 classes (with probably adaptations in the rest of the code).

gbakeman commented 3 years ago

I think you're right, your work sounds close in function to what I was doing. Do you want to keep working on it, or would you like to put it on hold for now and start a new branch?

gawindx commented 3 years ago

You can base yourself on the 2.1 branch, this version is still far from being considered stable and there will still be time to do a pull request.

I will inform you of the progress on this branch so that you can do a rebase if necessary.

The service mode will not arrive before 2.2, there are still quite a few things that I would like to set up before bringing this functionality.

In my opinion, if I have separated the communication between the GUI and the NUT server into 2 classes, it is precisely to specialize one class to communicate with the NUT server and the other to provide information from the UPS either to the GUI, either towards the windows service but in an exploitable format and corresponding to the needs of WinNUT in general.

gbakeman commented 3 years ago

OK, I will take a look at it soon.

gbakeman commented 3 years ago

I've pulled in your changes on the 2.1 Dev branch, and wow, you've done a lot of work. It's going to take me awhile to figure out how I can integrate the library I've been working on with what you have. I might need to make some structural changes to my library, especially after seeing the detail you've put in to your classes.

gawindx commented 3 years ago

Don't fall into the trap of over-specializing your library for WinNUT. In principle, your library should serve as a toolbox for dialoguing with the NUT server, so it must offer generic results so that anyone who needs to communicate with a NUT server can use it and exploit the result as it sees fit. Optionally, you can offer the possibility of obtaining the results in different forms but only via specific arguments. For example, in the case of a LIST VAR command, your function must return a default response in a basic form (a list of string for example) and you can offer the possibility of retrieving the raw result via an optional boolean passed when calling the function.

To be honest, I've been following your development from afar, so maybe this is something you already have in place.

On the other hand, I looked quickly at your repositories and I can see my project well but only its master branch and I would like to be able to take a look at the code once your library is integrated.

gbakeman commented 3 years ago

Sorry for going silent for a long time, I had some other things come up that I needed to prioritize. I also had to take some time to figure out how to update a GitHub repository from upstream, and make NuGet packages. This has been a learning experience! :) You can see the current branch I'm working on here. I've just added the NuGet packages, now I'll work on integrating the library.

gawindx commented 3 years ago

oh don't worry, i'm having the same availability issues right now. I'll try to watch it this weekend. for the nuget package, it's a good idea and I will have recommended it to you, even if I myself have not yet documented myself on this point.

gbakeman commented 3 years ago

A progress report:

I've done some work implementing the NDN library throughout WinNUT's code. It's building successfully and I did some small testing with my own NUT server. I feel terrible commenting out all of the work you did... I'll need to do a lot of testing to make sure I haven't introduced any bugs that you patched out before. I've also identified some small changes or additions I need to make to NUTDotNet so it fully supports WinNUT.

gbakeman commented 3 years ago

Another progress report, now much later:

I've finally gotten the NUT library to a good place, and it's implemented in most of WinNUT. The program seems to be working well for a stable UPS. I need to do some testing of different events and see what happens. I should have a pull request soon!

gbakeman commented 3 years ago

I take that back - there's still more work to be done. I've realized how important it is to have a proper Events system with updated UPS statuses. This will take a little bit longer, but hopefully worth it.

gbakeman commented 3 years ago

As I was testing, I realized I needed to go back to the NUTDotNet library and add in some more features. I'm going to attempt to make it asynchronous to prevent the UI from locking up, and at the same time implement the events that are needed. Again this is going to add more time.