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

Add the Moskus sample #103

Open
alexdresko opened this issue Nov 8, 2018 · 23 comments
Open

Add the Moskus sample #103

alexdresko opened this issue Nov 8, 2018 · 23 comments

Comments

@alexdresko
Copy link
Owner

Summary

@oesolberg helped me to realize that we could add the Moskus sample to HSPI. It's a good idea. Even better if we also make a C# version. See #99 (comment)

Expected Behavior

Developers should be able to create a "Moskus" project from File > New Project. It should use the HSPI and HomeSeer nuget packages where appropriate, as well as any other HSPI specific template features.

Current Behavior

We ain't got no Moskus template...

Possible Solution

Copy one of the existing HSPI templates. The reason for starting with a copy of an existing template is because there are several "features" built into the existing templates that make them work well as a starting point for new project. It would be harder to go the other direction by adding the Moskus project to HSPI first, and then retrofit the HSPI template features.

@dpmurphy
Copy link
Contributor

dpmurphy commented Nov 8, 2018 via email

@oesolberg
Copy link
Contributor

@dpmurphy Link?

@dpmurphy
Copy link
Contributor

dpmurphy commented Nov 8, 2018 via email

@oesolberg
Copy link
Contributor

That is not the Moskus sample is it? It is just the Hspi_sample converted to C#. The Moskus sample plugin is a vb.net project that covers devices, triggers and possibly actions. This has some of the stuff, but not all.

I will look into creating the Moskus sample (if I get his permission). And I might try to create more documentation. The problem now is that I don't remember how to create documentation. I remember it beeing a lot of stuff to set up before you could start the actual writing process.

@alexbk66
Copy link

alexbk66 commented Nov 9, 2018

I think a better example is HSPI_HikAlarmCheck because it's C# and it's very similar to HSPI.
BTW HSPI_HikAlarmCheck has comments for each function - which HSPI is lacking.

@oesolberg
Copy link
Contributor

If we are including a project it should be in C#. But I personally feel that the Moskus plugin shows so much stuff that it is a better fit than HikAlarmCheck. We only need to get it translated into HSPI ;-)

@alexbk66
Copy link

alexbk66 commented Nov 9, 2018

I think HomeSeer should take a lead and create VS templates for delelopers, they will be able to use them internally too
But I suspect it's not gonna happen

@oesolberg
Copy link
Contributor

They have had so many years to do that but since people can create plugins that shows that they don't have to.

@alexdresko
Copy link
Owner Author

HSPI aims to pick up where the HS dev team left off. One of the first things I did was to create the HomeSeer nuget package because the samples provided by HS didn't include the requisite assemblies. Further, the samples provided by HS were in VB.NET and were not complete. AND I pretty much hate the architecture they force you to use. So I created HSPI first of all to get started faster. Next, I collected a few of the samples that others had posted on the forums and turned those into templates. Then, I incorporated some best practices I felt were lacking. And now, my next main goal is to create a template that completely changes how HS plugins are created.

In the meantime, I think it's a great idea to bring in as much helpful code from the forums that we can. That includes the alarm clock, Moskus's sample, etc... Maybe we can start by collecting as many of those resources from the forums as possible and posting them here. Once we get them organized, we can figure out which ones make sense to incorporate into HSPI. It's really pretty easy. Converting things from VB.NET to C# isn't even that bad (I converted the original VB.NET samples to C# once).

Someone mentioned a day or two ago (I can't find the comment right now) that they felt we shouldn't incorporate samples as templates in HSPI, but that's exactly what the current templates are. If someone posts a sample on the forums, we can turn that into a template like the existing templates.

The super powerful thing behind HSPI is that it's hosted on Github, and therefore anyone can contribute. When the samples are left on the forums, the code gets forked in all kinds of ways and the collective whole doesn't benefit from any particular developer's enhancements. With HSPI, everyone benefits.

Sorry for rambling.

@oesolberg
Copy link
Contributor

I voiced my opinion that project samples should not be templates since they are just samples. But if it is some easy way to use them as templates and not examples then it is another story.

I have now contacted Moskus and we will port his plugin to C#. The first project will target .net 4.0. This is done due to rumors that mono (linux) does not behave nice when we are at higher versions. Not sure if that is the fact, but since Moskus has agreed to join forces in porting from vb.net to C# I don't care much. After the plugin is ported we can more easily add it to HSPI.

"Completely changes how HS plugins are created" - It is good to have higher goals :-)

@alexbk66
Copy link

alexbk66 commented Nov 10, 2018

Create the HomeSeer nuget package because the samples provided by HS didn't include the requisite assemblies

I actually don't agree it's a good idea - because it changes every version, so it's better to copy three HS dlls from the actual HS installation.

@alexdresko
Copy link
Owner Author

Thanks for the feedback, @alexbk66. I feel like I'm missing some context, though.

Can you explain what you mean by this statement?

it changes every version, so it's better to copy three HS dlls from the actual HS installation.

Theoretically, the HomeSeer nuget package will be updated anytime there's a new version of those assemblies from HS. Thus, updating to the latest version of the HS assemblies is as simple as updating the nuget package. It seems easier to me than copying the assemblies manually.

Admittedly, the nuget package assumes you're running the latest HS release, as the assemblies included in the nuget package should be the same.

Also, with the latest version of the package, I automated the release notes to show the versions of the HS assemblies contained within:

image

If you don't want to update to those assemblies, you don't have to, and if you don't want the nuget package at all, you can just uninstall it.

The point of the nuget package was to make it so projects created with the template "just worked".

I'm confused and concerned about this for sure. I definitely want to make sure I make the best decisions for this project, so let's make sure we're on the same page and go from there.

@alexdresko
Copy link
Owner Author

@oesolberg Just to make sure you and I are on the same page as well (we're juggling a lot of mini conversations in this issue), what do you consider to be the difference between a sample and a template? To me, they're kind of the same thing. A "sample" might just have more code that most people would delete immediately after creating the project.

@oesolberg
Copy link
Contributor

Normally I think of a template as a starting point where you still are missing code to actually get it up and running. But thinking about it I guess I am wrong since a lot of the VS templates are actual small applications (Webapps and services, console app, MVC etc).

I am currently busy converting the Moskus plugin from vb.net to C#. Now it is just a raw conversion. The repo can be found at https://github.com/Moskus/hspi_CsharpSample

@alexbk66
Copy link

Hi @alexdresko

Admittedly, the nuget package assumes you're running the latest HS release, as the assemblies included in the nuget package should be the same

I don't think it's really a big deal, but for me it's better to use the local HS DLLs to make sure they are in sync with the HS installation. And instead of copying the DLLs - the easier option is to set VS reference assembly path to HS folder.
But again, it's pretty minor issue.

@jeangv
Copy link

jeangv commented Nov 14, 2018

@alexdresko and @oesolberg with respect to the HSPI templates, they are fantastic in that once you have the environment setup, it gets you a template HS3 plugin very quickly. What is missing is a very basic "Hello World" plugin written using both TemplateA and TemplateB. For someone completely new, I can look at both the Moskus and HSPI_HikAlarmCheck plugins for some examples, but neither of these use the HSPI template. Here is a very basic issue that I am not struggling with the HSPI template that an example plugin based on HSPI would immediately answer:

Problem: Even if my code did nothing at all related to HomeSeer and just did it's own thing, where would I place that code? There are two .cs files in the template (Program.cs and HSPI.cs). InitIO and ShutdownIO in the HSPI.cs make sense for start-up and shutdown, but there is no obvious execution point for a "main program itself"

@alexbk66
Copy link

In .NET the entry point is private static void Main

@jeangv
Copy link

jeangv commented Nov 16, 2018

Yes @alexbk66 I realize that for C# the entry point is the Main, but that is not really where the code logic should start after the plugin connects. After some more digging I learned that I needed to do a:

public override string InitIO(string port) in my HSPI class and place the code I wanted to kick off the there. I learned that since InitIO needs to return an empty string quickly, I just start a new thread that runs the main code logic from InitIO.

So I answered my own question with that I needed to do a public overide of InitIO in HSPI.cs and have it call code in a new thread that is in Program.cs.

This is where a basic example of HSPI would be helpful. Once I get more of this complete, I will put together a video walk though of my crappy coding but at least it will work and may get others started.

@alexbk66
Copy link

@jeangv What I did to learn the sequence of events - I override in my class every function called by HS and put a break point in every function. Stupid, but very informative

@jeangv
Copy link

jeangv commented Nov 16, 2018

@alexbk66 that is genius!! I would never have thought of that!!! Thank you!

@oesolberg
Copy link
Contributor

@jeangv There are a lot of moving parts to get this running. And for easy things you still need a lot of them functioning.
As @alexbk66 says: Put breakpoints into the HSPI.cs functions to learn the sequence order.

I hope that in the beginning of 2019 we will have at least one example app running using HSPI template.

@oesolberg
Copy link
Contributor

Moskus sample is now translated and seems to be working.
How should I add this to the solution?

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

No branches or pull requests

5 participants