Cosmik42

Control all your Powered Up & Power Function (SBrick) devices with a single software

Recommended Posts

Hi Cosmik42,

just started and wanted to let you know that it is - amazing?

Here's a litlle video (22sec)

 

Share this post


Link to post
Share on other sites
56 minutes ago, Lok24 said:

Hi Cosmik42,

just started and wanted to let you know that it is - amazing?

Here's a litlle video (22sec)

 

Very cool! Actually I am very likely to drop the 'train' word in 'The Lego train Project' for the word 'automation', because this little project is much wider than that at this point.

You have no idea how awesome it is to see this video after so many hours of coding :)

Edited by Cosmik42

Share this post


Link to post
Share on other sites
31 minutes ago, Cosmik42 said:

Very cool! Actually I am very likely to drop the 'train' word because this little project is much wider than that at this point.

@Cosmik42

This is really cool. Yes, I believe that this project is far beyond "Trains". You should go and post in the "LEGO Mindstorms and Robotics" forum. They are going crazy on programming there. You may get even more input for your wonderful work.

What I believe should come eventually for the "Train" theme is an UI that is leaned towards the train theme. This could include "tiling" your actual track layout as for example the very nice 4DBrix nControl Software is doing. E.g. clicking on a tile within the layout representing a switch point, which then actually graphically shows the switch direction is more intuitive than slider controls and/or buttons. However that is a rather extensive programming business as you need to keep track of what element is doing what kind of work (switch drive, street lights, train) etc. Here is my UI you know already - and which shows the ancient VB6 design elements of 2003. Well - has grown over the years as my LEGO brick collection has as well:blush:.   

But as of now I believe you are developing solid communication software first and you may then migrate into making it train layout friendly. If at all. What you have achieved so far for all LEGO fans running the new generation remote control/programming hardware.

All the best,

Thorsten

 

 

Share this post


Link to post
Share on other sites
3 hours ago, Toastie said:

This could include "tiling" your actual track layout as for example the very nice 4DBrix nControl Software is doing. E.g. clicking on a tile within the layout representing a switch point, which then actually graphically shows the switch direction is more intuitive than slider controls and/or buttons.

This is my dream! Especially as I am working on a generic anti-collision system for trains, so having a map editor would put it even more to life.
But being an ex-video-game programmer, I know that this kind of editor can eat a lot of time to make ...

Edited by Cosmik42

Share this post


Link to post
Share on other sites
1 minute ago, Cosmik42 said:

This is my dream!

Well, as far as I believe, there is nothing more powerful than dreams in this world. Dreams can overcome any borders, challenges, and surely any time constraints.

So dream on (I do it myself). It gives life a "meaning".

All the best,

Thorsten

 

Share this post


Link to post
Share on other sites

Hi,

just a little bit testing, but I'm totally lost in C#  :look:

- made some code snippet like "MainBoard.WriteLine(DateTime.Now.ToString("h:mm:ss tt"));"

If I use a sensor-event (color) to execute it is always executed twice?

untitled2d.png.658ff9cb2344c2aa664295cb86bc727e.png


 

And how to choose the other colors?

untitled4wer.png.a1568f2c9ad168e598f80590814e2b01.png

And third problem:

How to call "MyGlobalFunction" in such an event? No Idea for the syntax

Sorry for having so many questions...


 
Edited by Lok24

Share this post


Link to post
Share on other sites
5 hours ago, Lok24 said:

If I use a sensor-event (color) to execute it is always executed twice?

It should not. How do you display the time when it's not through a trigger? It is possible this code triggered at the same time as the event itself?

 

5 hours ago, Lok24 said:

And how to choose the other colors?

After many test putting a color detector under a train, only these 3 colors were reliably discovered. But given the video you show, you would be able to discover all other color when not using it in a train scenario.

5 hours ago, Lok24 said:

How to call "MyGlobalFunction"

Simply write MyGlobalFunction();

Share this post


Link to post
Share on other sites

First of all, amazing work and thank you for sharing!

I was trying it out last night with my powered up equipped horizon express, and it works great!

I have one question, what does "Exception while connecting Object reference not set to an instant of an object." mean?  It keeps popping up, but doesn't seem to affect anything.

Thanks in advance,

Unfinished_Projects

Share this post


Link to post
Share on other sites
29 minutes ago, Cosmik42 said:

It should not. How do you display the time when it's not through a trigger? It is possible this code triggered at the same time as the event itself?

 

I have a red plate of app. 15cm length on the track, here's an example, as you see the message "Action triggered" appers only once, the "Writeline" twice:

t23.png

 

29 minutes ago, Cosmik42 said:

After many test putting a color detector under a train, only these 3 colors were reliably discovered. But given the video you show, you would be able to discover all other color when not using it in a train scenario.

 

I can only select these three colors in the drop-down field?

29 minutes ago, Cosmik42 said:

Simply write MyGlobalFunction(); 

That was my idea! But:

c23.png

 

And here's the translation:

Compiling code ...
Compiling failed.
Error (CS0120): An object reference is required for the non-static field, method, or LegoTrainProject.DynamicCode.MyGlobalFunction () property.
Error (CS1998): This async method lacks the 'await' operators, so it runs synchronously. You should consider using the await operator or await Task.Run (...) to wait for non-blocking API calls or perform CPU-bound tasks on a background thread.

Edited by Lok24

Share this post


Link to post
Share on other sites

From an automation standpoint, could a sensor be placed under the track point up and then each train is color coded underneath? This would allow for say, a station where you could have a main line and then trains are "sorted" into tracks for loading.

Share this post


Link to post
Share on other sites
14 hours ago, Unfinished_Projects said:

I have one question, what does "Exception while connecting Object reference not set to an instant of an object." mean?  It keeps popping up, but doesn't seem to affect anything.

Thank you for the kind words and happy to read the software works for you!
This error means that at some point the program tried to access an object that wasn't initialized. Can you give me more context as of when this pops up? 

Finally, thank you for the donation!

Share this post


Link to post
Share on other sites
14 hours ago, Lok24 said:

I have a red plate of app. 15cm length on the track, here's an example, as you see the message "Action triggered" appers only once, the "Writeline" twice:

t23.png

Oh my!! Indeed, it was my bad. A piece of code left after a debug!

 

14 hours ago, Lok24 said:

I can only select these three colors in the drop-down field?

For now yes. I will try to extend this during the weekend!

 

14 hours ago, Lok24 said:
14 hours ago, Cosmik42 said:

Simply write MyGlobalFunction(); 

That was my idea! But:

Ok, I have changed the declaration which was wrong.
All functions made this way should be static!
So in the 'Global Code' section make sure to edit it to this:

public static void MyGlobalFunction()
{
   // Execute your code here
}

Thank you so much for the throughful testing!
I will drop a new later today that fixes all these issues!

14 hours ago, Lok24 said:

And here's your project used for a shuttle train, please note the smooth acceleration....

https://youtu.be/RWmmEqOEAD0

This is beautiful! <3

11 hours ago, supertruper1988 said:

From an automation standpoint, could a sensor be placed under the track point up and then each train is color coded underneath? This would allow for say, a station where you could have a main line and then trains are "sorted" into tracks for loading.

@supertruper1988, absolutely!

Share this post


Link to post
Share on other sites

Thanks for the moment, i'll tried that withe the "static" (think i did that already yesterday, and it worked, stay tuned)

The debug-Mode: sounds familiar to me :wink:

Can you imagine what happens if you have different RampMotor commands, which are executed twice parallel? Funny!

Donation is difficult, cause I got no PayPal....

 

Edited by Lok24

Share this post


Link to post
Share on other sites
Just now, Lok24 said:

Donation is difficult, cause I got no PayPal....

Do not worry! Your videos are fullfiling to watch :)

Share this post


Link to post
Share on other sites
11 hours ago, supertruper1988 said:

From an automation standpoint, could a sensor be placed under the track point up and then each train is color coded underneath? This would allow for say, a station where you could have a main line and then trains are "sorted" into tracks for loading.

Hi,

yes, sure, it's another appraoch.

Needs all tracks to be buld in a certain height, of course.

But for a station you could perhaps use only sensor half a meter before the first switch!

 

Share this post


Link to post
Share on other sites
15 hours ago, Lok24 said:

And here's your project used for a shuttle train, please note the smooth acceleration....

https://youtu.be/RWmmEqOEAD0

 

Off-topic, so don't shoot, but I like the rolling stock. Any close-up photos? :)

Share this post


Link to post
Share on other sites
6 hours ago, Cosmik42 said:

This error means that at some point the program tried to access an object that wasn't initialized. Can you give me more context as of when this pops up? 

It pops up continuously starting right after the program is launched.  Powered up hub can still be connected and controlled as normal it seems. 

Thanks again,

Unfinished_Projects

Capture

 

Share this post


Link to post
Share on other sites
1 hour ago, Unfinished_Projects said:

It pops up continuously starting right after the program is launched.  Powered up hub can still be connected and controlled as normal it seems. 

Thanks again,

Unfinished_Projects

Capture

Oh this was extremely useful! 
It looks like you have some weird bluetooth device around you.

I just added an extra test to avoid this log. 
I will share a new version later tonight!

Share this post


Link to post
Share on other sites

Hey folks,

What about the idea to support Cosmik42 by writing a tutorial for the software? Does anybody here has knowledge to set up a Wiki for instance? (or something similar ...)

Share this post


Link to post
Share on other sites
1 hour ago, Cosmik42 said:

It looks like you have some weird bluetooth device around you.

 

Nice topic!

the program gathers all LEGO(?)-BT-devices.

What if the neighbour starts his LEGO-boost? What when used at an exhibition with a dozen of devices around?

Idea: implementing a list of "allowed" adresses
As your program doesn't use any .ini-files for the user you could set up such a list in any form in the "global" routine?

Share this post


Link to post
Share on other sites

couldnt you make it so that you manualy pair with your devices in the program? So that no other devices than yours will pair or did i missunderstand something about how the hubs work?

Hope this helps

XGBC

Share this post


Link to post
Share on other sites

Really excited to share with you V0.5!

  • Full support of SBrick Plus and PF Sensors.
  • Introducting an Anti-Collision system that works with simple distance detectors
  • Bug fix: Code was executed twice on sensor event
  • Bug fix: Better handling of faulty device connection

You can download the build here: https://www.dropbox.com/sh/4r7tbnbbvnevfhm/AADsny98v7uzdr0IU9mvvymqa?dl=1

 

Share this post


Link to post
Share on other sites

This is what I am doing (a very, very nice software company in the US - "/n software" - granted me a personal license of their BLEClient activeX control they have developed for all major program languages - believe it or not, also for VB6 - my lifetime programming environment. VB6 was phased out by Microsoft in 2002 or so, when surpassed by dot net stuff. Well not for me though … have instead migrated my VB6SP6 from Win2000 to XP to Win7 to Win10/64bit).

And believe it or not that BLEClient connects to all LEGO BLE devices like a charm - so I can continue my 14 years development of a TrainControl program … I am so grateful for that!

And this is what I am doing: Instead of scanning for devices I am directly connecting to the unique device address of each BLE server. You can find out that address in multiple ways - in Win10, when you scan for new devices in the corresponding system section, you can fetch that address easily - or you may use the Bluetooth LE Lab or Bluetooth LE explorer.

Best regards,
Thorsten       

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.