You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sean Nagle <se...@planet12.net> on 2007/11/22 00:18:40 UTC

Using Tomcat for something other than HTTP servlets

I am working on a research project in which I would like to use servlet
technology for something other than http servlets. In a nutshell I am trying
to extend G code ( the language of CNC routers ) using servlet technology.
What I want to do is create something similar to JSP called GSP
(GcodeServerPages).

A GSP would contain a program to run a CNC machine. The "fixed template
text" would be G code instructions (instead of HTML) and the the page would
be able to dynamically generate content that is written in Java.

In order to do this I would like to have Tomcat (or other Container) be able
to communicate with an application that I am calling an 'Interactive
Environment' (later referrred to as IE, not to be confused with Internet
Explorer) as well as a CNC router machine.

Tomcat and the IE would be running on one computer and the CNC router would
be connected to this computer via a serial cable (RS232). I found this
article regarding COM ports that was encouraging:
http://www.jguru.com/faq/view.jsp?EID=1048895
The IE would have at least a text editor and a way to 'browse' the local
filesystem. From within the IE a programmer could write GSP's and be able to
instruct the Container to evaluate and execute the GSP. The Container would
be able to then send its instructions to the CNC.

Here we come to one of the interesting sticky bits. During execution of a
CNC program (written in traditional G code) it is possible to allow
interactivity with the machinist. For example a program to cut triangles out
of a piece of aluminum might ask the operator "How many triangles would you
like?", "What is the length of the base?" etc... and then once this data has
been collected the program could determine how to cut out the triangles.
With this in mind, for my project I would like the CNC to be able to talk
back to the Container over the serial connector.

So there are two kinds of communication that the Container needs to be able
to perform: 1. Communication between the IE and the container and 2.
Communication between the CNC router and the container.

What I would like to know is does any of this sound feasible using Tomcat as
my Container? If not, I would certainly be willing to write my own simpler
Container to do the job but obviously it would be better to use the existing
software if it can be configured to suit my needs. What I worry about is
that Tomcat may be so intertwined with handling HTTP that it will not be
flexible enough to do something completely different.

Thanks,

Sean Nagle


Re: Using Tomcat for something other than HTTP servlets

Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
---------------------------------------------------------------------------
HARBOR: http://coolharbor.100free.com/index.htm
Now Tomcat is also a cool pojo application server
---------------------------------------------------------------------------
From: "Sean Nagle" <se...@planet12.net>

Sean I think so, but the part that you really need to get is that "Tomcat is 
a server", it doesnt INITIATE, it can only "answer questions".
I think do some reading on how HTTP servers work.

Also I think you completely underestimating how hard it is to make 
containers and good protocols... starting from scratch could be a life time 
of work.

You need to make bridges.

CNC MACHINE ---- |RS232 <-> TCP| ---- TOMCAT
IE DESIGN STATION ----|CAD <-> TCP| ---- TOMCAT

IE DESIGN guys "asks" Tomcat to store stuff.... it catalogs (Q's) the JOBS.
CNC operator PICKS the JOB... "asks tomcat" ... gets the job details.
CNC operator says do JOB (3 triangles) "ask tomcat" .... tomcat returns G 
Files

HTTP wont "block" you, it will help you... because a design like the above 
could be stretched over a network.
ie CNC machine in tokyo, IE Design station in new york, and Tomcat in China.

So... you have to study that CNC machines protocol... can it ask a question, 
what does the file format look like that it sends, what does it expect back?
Then you have to go learn about sockets and TCP/IP/HTTP and figure out how 
to bridge them.
Same with the CAD work stations... how to they export stuff, what formats 
available?
Tomcat will not do the bridging for you... it cant talk RS232

Another concept that doesnt sound right... you are not going to reinvent 
JSP... in fact for this you going to use servlets (not JSP)... and they not 
really protocols, they just programs that do stuff... so tell a servlet that 
when it gets (request?CNC_GiveMeFirstJob = true)... it must look at the job 
Q and sent it back, in HTTP, or in TEXT, or as an image, or GCode.... 
whatever you tell it to do.

So yes, I think you on the right track, but you have to study the protocols 
available. If the CNC machine cant "ask" a question, you screwed... if it 
asks something like this...
1,0050,3  where 1 means "give me", 0050 means, GFile 50, and 3 means, JOB 
3.... then you maybe in business.

You have to study the protocols an all the devices....

Those bridges (language translators) will be more than enough low level 
coding.... you may even find with things like CAD stations that the only way 
to make the bridge is with a printer driver... that will be fun.

Tomcat is a server... it answers HTTP/TCP/IP questions... thats it.

You have to tell it how to answer them... and figure out if the CNC machines 
are even intelligent enough to "ask" a question.
We cant help you with protocols... need to speak to the CNC supplier.

Once you have built your bridges... you can also embed them in Tomcat.

So now a "remote control browser" "asks" via a Tomcat servlet to ask a 
bridge.... Send JOB 1 to CNC machine 3... it then sends a messaage to the 
operator, saying, "can I run this JOB", or it switched on a red flashing 
light, because a machine is about to start, that bridge then "asks" tomcat 
for the GFiles... it sends them back via the right RS232 port.

See how you can start convoluting the thing... and because its HTTP, making 
a nice control station in a browser will be easy, so now HTTP is helping 
you.
You have a hell of a lot to learn... Good luck ;)

Yes... I think you onto a good thing....

>I am working on a research project in which I would like to use servlet
> technology for something other than http servlets. In a nutshell I am 
> trying
> to extend G code ( the language of CNC routers ) using servlet technology.
> What I want to do is create something similar to JSP called GSP
> (GcodeServerPages).
>
> A GSP would contain a program to run a CNC machine. The "fixed template
> text" would be G code instructions (instead of HTML) and the the page 
> would
> be able to dynamically generate content that is written in Java.
>
> In order to do this I would like to have Tomcat (or other Container) be 
> able
> to communicate with an application that I am calling an 'Interactive
> Environment' (later referrred to as IE, not to be confused with Internet
> Explorer) as well as a CNC router machine.
>
> Tomcat and the IE would be running on one computer and the CNC router 
> would
> be connected to this computer via a serial cable (RS232). I found this
> article regarding COM ports that was encouraging:
> http://www.jguru.com/faq/view.jsp?EID=1048895
> The IE would have at least a text editor and a way to 'browse' the local
> filesystem. From within the IE a programmer could write GSP's and be able 
> to
> instruct the Container to evaluate and execute the GSP. The Container 
> would
> be able to then send its instructions to the CNC.
>
> Here we come to one of the interesting sticky bits. During execution of a
> CNC program (written in traditional G code) it is possible to allow
> interactivity with the machinist. For example a program to cut triangles 
> out
> of a piece of aluminum might ask the operator "How many triangles would 
> you
> like?", "What is the length of the base?" etc... and then once this data 
> has
> been collected the program could determine how to cut out the triangles.
> With this in mind, for my project I would like the CNC to be able to talk
> back to the Container over the serial connector.
>
> So there are two kinds of communication that the Container needs to be 
> able
> to perform: 1. Communication between the IE and the container and 2.
> Communication between the CNC router and the container.
>
> What I would like to know is does any of this sound feasible using Tomcat 
> as
> my Container? If not, I would certainly be willing to write my own simpler
> Container to do the job but obviously it would be better to use the 
> existing
> software if it can be configured to suit my needs. What I worry about is
> that Tomcat may be so intertwined with handling HTTP that it will not be
> flexible enough to do something completely different.
>
> Thanks,
>
> Sean Nagle
>
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Using Tomcat for something other than HTTP servlets

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sean,

Sean Nagle wrote:
> In a nutshell I am trying
> to extend G code ( the language of CNC routers ) using servlet technology.
> What I want to do is create something similar to JSP called GSP
> (GcodeServerPages).

Interesting. Do you want to re-use JSP technology to generate G code
output? I'm not really sure I understand why a servlet server would be
useful, here: the servlet server is mostly concerned with network
operations, the queuing and dispatching of requests, etc. I'm not sure
how much of that is useful for your CNC project.

It looks like what you really need is a console application that is
intended to be used with a single operator standing next to the machine.
In that case, I'd look into using something like Rhino (now the built-in
javascript interpreter in Java) to script some useful tools that you
write in Java yourself. Then, your meta-G (my name for your language
that emits G code) language could be programmed by people who don't have
to know anything about Java per se.

Does this sound like what you're looking for?

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHSw+e9CaO5/Lv0PARApQBAJ4+J8f0HgXS7KKOu1NKGU+98tPE8wCfQovZ
uNaAMIBOLqbxXGiJvKS8Bd0=
=axvV
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org