Skip to content

Restructured code & Nuget support#7

Open
KeesCBakker wants to merge 74 commits intoarvydas:masterfrom
KeesCBakker:base-project
Open

Restructured code & Nuget support#7
KeesCBakker wants to merge 74 commits intoarvydas:masterfrom
KeesCBakker:base-project

Conversation

@KeesCBakker
Copy link
Copy Markdown

Hi!

When I saw the BlinkStick code I saw it was very hard to maintain, that’s why I ended up restructuring its code. One thing led to another and I ended up with doing a lot of structural changes. I’ve tried to keep the methods as backwards compatible as possible.

Are you interested in merging the project?

I've removed my animations project. It can be a separate project (unless you're interested in async animations for the BlinkStick as well, happy to work together).

USB Monitoring
The project uses two dependencies, implemented by forked projects. I removed them for their NuGet packages. The code of these packages (the device and the stream) was highly coupled with BlinkStick. I ended up writing a IUsbDevice and IUsbStream abstractions so that packages can be easier swapped out in the future. I also split the monitor in a central monitor and a monitor for devices based on VendorId and ProductId. Note: I don’t have Linux/Mono so I cannot test it.
(Had to disable the signing otherwise it wouldn't work. You might want to look into that...)

Meta information
Created a wrapper for the meta information so it doesn’t clutter up the BlinkStick class. BlinkStick class still has the properties but reroutes it through the Meta property (decorated with obsoletes).

Animations
I’ve separated the animation logic by using an extension class. The user can still use the methods through the BlinkStick class, but the implementation now has its own class (Animations\AnimationExtensions.cs).

Colors
I did the same for the colors (Colors\ColorExtensions.cs). All SetColor methods are variations on the SetColor(channel, index, r, g, b).

Integration Testing
I had the need to for some integration tests (to test the USB monitor, test if the moved code still worked). That’s why I created a special project that helps debugging scenarios. Project is based on Visual Studio testing. Don’t know if Linux/Mono has something for it.

GetLedCount()
Now returns the right number of leds when a Square or other non-pro device is connected.

NuGet
For my own project I needed Nuget packages, so I implemented Continuous Integration with MyGet that helps in the creation of Nuget packages. Works like a charm… got the packages up. Love to transfer them to you.

…program will not stop when interacting with the stick.
…es. This makes the software pluggable and gives us a better seperation of concern.
…interact using IUseDevice (not with a full BlinkStick). Renamed BlinkStickConnected and BlinkStickDisconnected because is should not reflect anything to do with BlinkStick.
… to do some syncing. Hopefully it won't be needed in the future.
@KeesCBakker
Copy link
Copy Markdown
Author

Packages can be found here if you want to try them out: https://www.nuget.org/packages?q=blinkstick

@KeesCBakker
Copy link
Copy Markdown
Author

Any news on the matter?

@drewnoakes
Copy link
Copy Markdown

drewnoakes commented Mar 15, 2017

@KeesCBakker I'm hoping this project isn't dead. It'd be good to at least hear a response from the maintainer about your PR.

Thanks for making the project available on NuGet. Are you using UsbMonitor? I'm not seeing events being raised and am wondering if it's related to your changes. My code resembles:

var monitor = new UsbMonitor();
monitor.Connected += (s, e) => Console.WriteLine("Connected");
monitor.Disconnected += (s, e) => Console.WriteLine("Disconnected");
monitor.Start();

[assembly: AssemblyDescription("BlinkStick Generic Hid Library with KeesTalksTech modifications")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Agile Innovative Ltd")]
[assembly: AssemblyCompany("KeesTalksTech")]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a bit presumptuous to change the company name on the assembly.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahaha... I think it was an automatic rename. I'm moving the animations to another project.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has been a while. I did it to see the difference between the projects (the DLL from the Nuget package is not an official DLL).

{
private double _hue;
private double _saturation;
private double _lightness;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is to be mutable, it should be a class not a struct.

https://blogs.msdn.microsoft.com/ericlippert/2008/05/14/mutating-readonly-structs/

My sense (which follows the BCL colour types) is to make HslColor and RbgColor immutable structs.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

/// Defines an HSL color.
/// </summary>
/// <remarks>Check http://en.wikipedia.org/wiki/HSL_color_space for more info.</remarks>
public struct HSLColor
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.NET style guidelines would have this called HslColor.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok -- I see that this type was moved, not added. Comment applies to upstream code, in that case.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it has been restructured. A rename will break the implementation.

// You should have received a copy of the GNU General Public License along with
// BlinkStick application. If not, see http://www.gnu.org/licenses/.
#endregion

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't just remove the license header from files...

@drewnoakes
Copy link
Copy Markdown

Took a few minutes to look through this PR. My $0.02 is that too much has changed for this to reasonably be merged. I get wide-reaching PRs from time to time against my own projects and generally they don't get merged. Even if there's some good stuff in there, it's too hard to see what's changed and whether it's correct.

I think you'd have more luck with smaller PRs. A minimal PR that added NuGet support would be great.

@drewnoakes
Copy link
Copy Markdown

Perhaps you could also grant @arvydas access to the NuGet package.

@KeesCBakker
Copy link
Copy Markdown
Author

Thanks for the review. @arvydas can have all the rights to the project and the way packages are deployed. I'm also happy to work on a better way of merging the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants