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

LW4 Integration #2

Closed
cprezzi opened this issue Jan 10, 2017 · 144 comments
Closed

LW4 Integration #2

cprezzi opened this issue Jan 10, 2017 · 144 comments

Comments

@cprezzi
Copy link
Member

cprezzi commented Jan 10, 2017

I'm comming to the point where I need to integrate lw.comm-server into LW4 and need some help how to start. I still have no clue how the react/Redux stuff works. Especially where I have to place my Code and how to access the gcode or save/lose Settings.

@openhardwarecoza, @tbfleming : can one of you give me a Quickstart?

@tbfleming
Copy link
Member

@cprezzi I just committed some example code to components/com.js to get you started on the UI part.

Note that to add new fields to settings, you need to add them to the bottom of reducers/settings.js or they'll get discarded on reload.

@tbfleming
Copy link
Member

@jorgerobles may also help answer questions.

@cprezzi
Copy link
Member Author

cprezzi commented Jan 10, 2017

Thanks @tbfleming. That's a start.
Now, as I understand the structure, the code to config the connection and initiate the connection has to go into com.js.

Is it correct to place the code that handles the user interactions (like jog, play, pause...) in jog.js?

Is it ok to include a comm-server client library into the lib folder and use that lib from com.js and jog.js?

How do I access the gcode that has to be run? Via state.gcode?

@tbfleming
Copy link
Member

Now, as I understand the structure, the code to config the connection and initiate the connection has to go into com.js.

yes

Is it correct to place the code that handles the user interactions (like jog, play, pause...) in jog.js?

yes

Is it ok to include a comm-server client library into the lib folder and use that lib from com.js and jog.js?

yes. lib/ is for anything that doesn't fit into the other folders. Other options include git submodules and npm packages.

How do I access the gcode that has to be run?

I just pushed an example.

@cprezzi
Copy link
Member Author

cprezzi commented Jan 10, 2017

Ok. Let's see how far I get ;)

@jorgerobles
Copy link
Contributor

One piece a time, The Ripper said

@cprezzi think of jog.js as a widget. An autocontained piece of code that holds all the rendering and interaction. Interaction is on two folds, UI, and (application) State.
The component reads UI interactions (and optionally keeps his own state) and dispatches commands (Actions) to the Application state if needed.

So, to bind a library (as lw-comms) to a component is pretty straightforward.
If the client library is ready to be used, just jump into UI. Make it static first, and then add interaction.

If any setting should be remembered by the application, you have to bind it to the Application State thru connect method wrapper. Many aspects of the state (in this case Settings) are developed already, so you only have to dispatch the correct action.

Anyway, ask any questions you have (on G+if needed), I'm here to help.

@jorgerobles
Copy link
Contributor

@cprezzi have you opened a branch on lw4 for the integration? Do you need help (react or other?)

@ghost
Copy link

ghost commented Jan 21, 2017

I dont know if its any help, but I'll post it nonetheless

From the days before @tbfleming joined the project, there was a 'dev' branch by @lautr3k which actually had a really nice comms module - maybe some work from there can make your tasks easier (probably not since its not react - well maybe some of the UI inspiration if nothing else)

serial:
comms

http:
http

Locked up in
https://github.com/LaserWeb/LaserWeb4/tree/dev

@ghost
Copy link

ghost commented Jan 21, 2017

(; i quite liked the icons in the console. He also had some websocket status info in the console, and automatic reconnect (see sept 8th)

https://github.com/LaserWeb/LaserWeb4/commits/dev

@cprezzi
Copy link
Member Author

cprezzi commented Jan 21, 2017

I did not open a new branch in LW4 yet. I am working locally on a cloned dev-es6 and planned to push directly to dev-es6, as this is a development version and nobody else is working on the same components (com and jog). Is that ok, or should I move my work to a new branch?

@openhardwarecoza: Thanks for the hint. I didn't know sebastien already worked on the frontend for comms. I will check it to see if it helps me. At least his styling is nice.

The basic communication (USB connect, send command to server, jog) is already working. I am working on the details and stability now.

During development I realised that it is not very convenient to have comms in a separate tab of the sidebar. It was better in LW3, when it was always visible in the toolbar. Is it conceivable to have the toolbar also in LW4?
An alternative would be to have the comms part in the jog tab, as this is the open tab during preparation and execution of a job (machining). What do you think?

@ghost
Copy link

ghost commented Jan 21, 2017 via email

@tbfleming
Copy link
Member

The CAM tab is already crammed for space; a toolbar will make this worse. Combining comms and jog sounds good to me.

@cprezzi
Copy link
Member Author

cprezzi commented Jan 21, 2017

We could also move the config of the machine interface to the settings tab and only have the connect button and state in jog module. It's unlikely that users will change the machine connection very often.

@jorgerobles
Copy link
Contributor

@cprezzi Indeed, a tiny icon aside the connect with gears, by example could trigger the change to settings pane.

About the branching or not from dev-es6 was just to know your preference. Either if a branch is opened, or if you push to dev-es6, We could check / help with the integration if you need it. You are not alone...

@jorgerobles
Copy link
Contributor

@cprezzi, @tbfleming I'm curious, what's is the way to bootstrap the server(ws)/client(app) with webpack?
Is it possible to serve WS and http on the same port?, If not, the WS server should be run on another port?
Will the server be launched (via npm script) and serve static /dist, or would it conflict with the hot-dev-server?

@cprezzi, I'm looking to the comm-server and maybe will be good to create an index with the verbs (i.e. describing the ws api) so we can collaborate implementing frontend/backend. What do you think? (grep emit will suffice as an alternative)

@ghost
Copy link

ghost commented Jan 25, 2017

@jorgerobles @tbfleming
You might be interested in the method and results we obtained with raster engraving in this thread:
LaserWeb/deprecated-LaserWeb3#219 (comment)
Smoothieware/Smoothieware#1096 (comment)

@tbfleming
Copy link
Member

@jorgerobles we'll probably keep the webpack dev server separate from the WS server since only devs need the dev server. They'll have to run on different ports if we do it this way.

@cprezzi
Copy link
Member Author

cprezzi commented Jan 26, 2017

@jorgerobles I have made a wiki page on gh to document the server api (work in progress). Is that ok, or do you prefer another way.

I don't know much about webpack, so I leave that to the experienced people ;)
I have made the server IP:port configurable on client side, so it is possible to connect the same host:port as the webserver, or something different.

@cprezzi
Copy link
Member Author

cprezzi commented Jan 26, 2017

@DarklyLabs For me the proirity is to bring the lw.comm-server to LW4 first, and then care about performance.

@jorgerobles
Copy link
Contributor

this one? https://github.com/LaserWeb/lw.comm-server/wiki/Client-communication
Fits perfect there :)

@cprezzi
Copy link
Member Author

cprezzi commented Jan 26, 2017

Ok. I will extend it, once the api has sellted a bit ;)

@cprezzi
Copy link
Member Author

cprezzi commented Jan 31, 2017

I could use some help.

I need to fill the availabe serial ports to a dropdown by code. The actual form field looks like this:
<SelectField {...{ object: settings, field: 'connectPort', setAttrs: setSettingsAttrs, data: ['COM3',' COM4'], defaultValue: '', description: 'USB / Serial Port', selectProps: { clearable: false } }} />
How can I fill the ports by code instead of static data attribute?

@jorgerobles
Copy link
Contributor

Hi @cprezzi take a look to https://github.com/LaserWeb/LaserWeb4/blob/dev-es6/src/components/webcam.js#L246

This is the most basic example of how a select is populated with programatic data.
Note that is not advisable to get data on render(). Render should use "static" data, through props or internal component state, else it could enter a loop because every change of data re-renders the component.
So basically you have to alter the internal state first (with setState()) and then the render makes its magic.
I found this package https://www.npmjs.com/package/react-websocket that encapsulate all the websocket boilerplate to a component. I think is a good idea-

@cprezzi
Copy link
Member Author

cprezzi commented Jan 31, 2017

@jorgerobles The websocket communication is not the problem. That's already working ;)

@cprezzi
Copy link
Member Author

cprezzi commented Jan 31, 2017

I'm just fighting with some react/redux specific details.
I see that your sample is using pure select field instead of the SelectField of forms component. It seems that handling is different, right?

@jorgerobles
Copy link
Contributor

Yes, I had to use it because a weird glitch with other components in the pane. But anyways, the relevant code you should modify is the data attribute

<SelectField {...{ object: settings, field: 'connectPort', setAttrs: setSettingsAttrs, data: this.state.ports, defaultValue: '', description: 'USB / Serial Port', selectProps: { clearable: false } }} />
being this.state populated with the websocket content.

If you are dispatching the action to setSettingsAttrs make sure connectPort is added to the settings reducer. Else won't pass state validation and will be discarded.

@cprezzi
Copy link
Member Author

cprezzi commented Feb 12, 2017

How can I integrate the lw.comm-server (the server part) into the LaserWeb4 distro and also start the server in together with npm start?
At the moment I have to start the server in a separate command window.

@jorgerobles
Copy link
Contributor

@cprezzi
Copy link
Member Author

cprezzi commented Feb 12, 2017

And to integrate lw.comm-server into LaserWeb4 distro? Is it enough to add lw.comm-server to devDependencies in package.json?

@cprezzi
Copy link
Member Author

cprezzi commented Feb 12, 2017

How does npm know where to get it from?

@arthurwolf
Copy link

arthurwolf commented Feb 27, 2017 via email

@chamnit
Copy link

chamnit commented Feb 27, 2017

Personally, I never liked the M115 and its verbose formatting. The output string is already several dozen characters to tell you just a handful of things. That said, it doesn't mean that its not useful.

At this point, Grbl's protocol is done. There is no more room in the 328p to make anymore changes. Nor am I particularly interested in trying to cram more in. All development work is now focused on the ARM project. I can take on new protocol tweaks there, but only if they make sense to.

@arthurwolf
Copy link

arthurwolf commented Feb 27, 2017 via email

@chamnit
Copy link

chamnit commented Feb 27, 2017

The response is an error: since it's not recognized by the parser. I suppose I could have it output the build info string and maybe even the welcome string. That's about all I can do. I can't fit anymore strings into flash without compromising something.

@ghost
Copy link

ghost commented Feb 27, 2017 via email

@arthurwolf
Copy link

arthurwolf commented Feb 27, 2017 via email

@chamnit
Copy link

chamnit commented Feb 27, 2017

Well, it seems that an implementation of M115 will take about 140 bytes of flash. I literally have a few hundred bytes to work with in certain critical configurations. These are generally reserved for bug fixes. I was hoping that it would be a few dozen bytes but it's a no go. So, I'm going to have to pass on this.

On the plus side, I'll add M115 in the ARM project (and likely Mega version) to output the build info strings.

@ghost
Copy link

ghost commented Feb 27, 2017

@cprezzi While the most efficient method is being resolved, is there any temporary code you can apply to help all the smoothie users get past this problem?
As Peter mentioned, the machine profile can contain a setting for the type of firmware and then LW can act accordingly?

@cprezzi
Copy link
Member Author

cprezzi commented Feb 27, 2017

@DarklyLabs I suspect that smoothie users just have to live with it. Remember, it's just when connected via ESP, not USB, and it's only on connect. I think it's not the right solution to complicate the usage for all users, to achieve just a bit more convenience for rare situations.

As you see above, nobody is willing to change anything, so why shoud we make a handstand to hide firmware problems?

If the maker scene wants to make progress, they have to work out common standards, else everything is slowed down.

@arthurwolf
Copy link

arthurwolf commented Feb 27, 2017 via email

@ghost
Copy link

ghost commented Feb 27, 2017

@cprezzi I couldnt disagree more.

This is not a rare situation. There are still problems with USB where we have to restart our machine everytime 'abort' is pressed. These problems were not present in LW3 with its approach to these conditions.

LW is a program using various technologies, Smoothie, GRBL, etc.
It is designed to let users interact with these platforms in an easy way.

We cannot stand here and demand a developer to change their firmware because we are not happy with it. Both Arthur and Sonny have been more than accomodating in this discussion to even consider alternatives.

There are easy ways as discussed to properly support Smoothie that have been made here. Smoothie IS a KEY platform for LW along with GRBL. I find the comment 'users have to deal with it' a very frustrating one and contrary to the underlying philosophy of Laserweb.

Why can't users select their firmware and then the correct behaviour is used?
Why does every firmware need to be consistent? This is not realistic in the real world.

@cprezzi
Copy link
Member Author

cprezzi commented Feb 27, 2017

@chamnit It would be enough to get the string "grbl". After that, we can use $I for the details.

@arthurwolf Would't it make more sense to implement $I in smoothieware instead? You don't have space problems, right?

@arthurwolf
Copy link

arthurwolf commented Feb 27, 2017 via email

@ghost
Copy link

ghost commented Feb 27, 2017

@cprezzi Please remember that LW is independent of Smoothie or GRBL.
Because it works with one perfectly and not the other means it is not working perfectly.

@cprezzi
Copy link
Member Author

cprezzi commented Feb 27, 2017

@DarklyLabs The problem with the blocked board after abort should have been solved and has nothing to do with this connect issue. I am only talking about the issue that a $X is needed after connecting via ESP! And we will probably add a button to do that. That's realy no big deal.

@arthurwolf I didn't see the newer messages when I wrote about the willingness (while I was writing). But good to see you and Sonny are trying to help!

@cprezzi
Copy link
Member Author

cprezzi commented Feb 28, 2017

@arthurwolf I am just frustrated because I am fighting with all the firmware differences/problems since weeks and every time I was asking for something, that you eventually confimed, Jim came afterwards and refused.
If it would have a chancde to be accepted, I would make a PR to treat $I the same like version, but that seems to be a dead duck.

@ghost
Copy link

ghost commented Feb 28, 2017

@cprezzi There are lots of branches to LW now, dev_comms, es-6, installer versions and it is tricky to keep up to date with them all. For instance, the es-6 version doesn't have your comms in it but does have all the other latest work from Jorge etc.

How can we improve on this and have everything in one place?
What branch should we be checking you your latest work? (dev_comms?)

@cprezzi
Copy link
Member Author

cprezzi commented Feb 28, 2017

@DarklyLabs Until now I was only working in dev_comms and I did regularly merge new stuff from dev-es6 to dev_comms. As quick as we have a "stable" enough version on dev_comms, I want to merge my work to dev-es6. Hopefully this will be in the next few days.

@cprezzi
Copy link
Member Author

cprezzi commented Feb 28, 2017

I had an idea for the clearing of an alarm, because manually sending $X is not convenient:

What if I make the abort button dual state like the pause button? When in alarm state, a click would send $X to clear the alarm, in all other states it would send ctrl-x (and clear the queue).

This way, the user could just click the same button twice to first stop the job and then clear the alarm.

@arthurwolf
Copy link

arthurwolf commented Feb 28, 2017 via email

@jorgerobles
Copy link
Contributor

jorgerobles commented Feb 28, 2017

@cprezzi I understand your frustration. Be clear in your mind that if other people/projects are not eager to modify their projects (They will have their own reasons, of course), then go to the KISS way (like @openhardwarecoza machine profiles suggestion) and open an issue on the other people project suggesting the change. It bites self-steem I know.

Any end user complain about that issue could be forwarded to "Yes, we are aware of, I've done all on my reach, please check LinkToTheOtherPeopleIssueOpenedByYou".

@cprezzi
Copy link
Member Author

cprezzi commented Feb 28, 2017

@arthurwolf I'm not upset, just a bit frustrated because all I try is to improve it for our and your users and sometimes I feel that my inputs are seen as disturbance instead of ideas for improvements, especially from Jim. You seem to be more open for discussion at least.

And just for your info, I do know what low level software development means. I did that job for several years.

I never did a PR, because I also think it's better to discuss an idea first, but probably I have choosed the wrong media (git issue). Never realized there is a dev mailing list.

The thing is: I could easily take a fork and change what ever I want (as suggested by some of your community), but that would not help smoothieware. That's why I prefer to work together.

@arthurwolf
Copy link

arthurwolf commented Feb 28, 2017 via email

@cprezzi
Copy link
Member Author

cprezzi commented Feb 28, 2017

@jorgerobles Thanks for your understanding.

I just try to avoid any more sources for misconfiguration issus if anyhow possible. If all users have to select thier firmware just to resolv an issue we have when connecting through ESP8266, that's not efficient and can cause more configuration issues.
So, if possible in any way, I will try to solve this issue without firmware selection. Especially, because it's not only related to the firmware, but also to the connection type (USB, Serial, Telnet, ESP).

@ghost
Copy link

ghost commented Feb 28, 2017

I split off this issue into the three distinct issues instead ( #10 , #11 , #12 ) - otherwise working the problems just becomes a little harder to follow along on... (:

Hope that helps.

This issue was closed.
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

No branches or pull requests

6 participants