Client/Server Starting Help
Concept:
The server side polls an industrial WinCE controller via ModbusTCP on a timer. The data is collected and eventually averaged and sent to a SQL database. This portion of the program is almost complete. This program needs to reside on one of our file servers.
Here is the issue:
I need a client side that is accessible from any computer in the plant. This leads me down the Web Based road as it seems like the best approach.
I am using a series of gauges that I purchased from Dundas Software that I need to dynamically update. I am not a strong web programmer at all but I think this is the way to go.
Here is where I am missing the boat a bit. Is there a way to expose the variables in the server side to a client side without writing them to a file? I don't want to have to do a file swap if I can avoid it. I am also concerned about the server side trying to write to a file while the client side is reading it. I have used methods in the past to write to a .ini file using VB6 but I have not looked into this method in .net so I don't know if that is a better option either.
Also, I assume that I need to use AJAX to dynamically update the individual gauges. The way I understand it is that AJAX prevents the entire page from reloading at each call. It only reloads the objects that you want. Luckily the guys at Dundas have anticiapated this and I have both the VB.net and ASP.net versions of the gauges.
Like I said. The server side is not a real issue for me. Not knowing a whole lot about sockets yet (I am learning) is it possible that the client notifies the server when it is online and the server then sends the data to each online client after its MODBUS Poll?
Wow I think I might have answered my own question to some degree.
Someone give me a nod if I am on the right track please. I will probably be back with a few more questions before this is over.
Thanks in advance,
Wade
Re: Client/Server Starting Help
If you take this to a web server you don't need to know anything about sockets. You need to create an ASP.NET application that runs on the IIS (preferably) web server and it knows that a client is online by simply getting a web request from it.
1) Install the IIS on the server.
2) Create an ASP.NET app on the server (implement AJAX if you want). To put it simply you need to 'create a website' and add 1 (or more) web form page in it. Then edit the page to your liking and put the AJAX updating code to your proprietary controls (you only need to add them to a webform and configure them).
3) Clients will connect to the server page with a web-browser and get the data.
The whole client-server part of the solution comes down to developing of an ASP.NET page.
Re: Client/Server Starting Help
Okay,
I have now read up a bit more on how VS Web Sites work but I am still having a bit of a disconnect.
I create a website. It will eventually be moved to the Server using IIS as I understand this to be the best method. The webpages I create for the client side will have the various gauges and other info on them that will be updated on postback. This I get and I see where it works.
My hangup is still on the server side. The server needs to poll the industrial PC on a timer. It uses a very specific Modbus TCP protocol to retrieve the data. I would like the server side to run as a Windows app or at least be able to display a Windows Form that shows logging info, connection status etc. Is this possible? From the limited data I have gathered so far, there is some inherent ability of the server side to do things with data but I don't really get it.
Another issue is that I need the application to always be runnning. In other words, when the server is on-line (which is essentially always) the app runs. I know how to add this to the .bat file so that is not an issue for a win app but I am not so sure for a web server. It will poll the industrial PC until it gets an answer that it is online at which point it will start recording data. In other words, I don't care if no clients are actively watching the data but I still need the data to be recorded so that it can be manipulated and sent to the SQL database.
I can see where I could add the polling functions to the client webpages but this does not solve my primary function of recording and storing the data.
Sorry for my basic questions. Once I get a handle on the concept I can work the code, I am just missing the forest for the trees here.
Thanks again,
Wade
Re: Client/Server Starting Help
Could I do it this way?
Build my Server Side as a stand alone windows app as described above. It is loaded at Server Start and polls the Industrial PC until it gets a connect signal. It then starts recording and storing data as required. It also displays the log info that I need in a standard Windows form.
Now if I understand VS.Net WebSites, they are not compiled like a standard application. So the data is merely stored in a file on the server side. So if I pulled the data for my gauges on on the webpages from an xml file and then updated the xml file from my server side stand alone. Would that work?
Would I run into problems trying to read and write from the xml file at the same time?
Would there be a better file format or method to swap the data from. The issue at hand is that the server side will be polling the controller about every 30ms so it is retrieving data very rapidly. I could put a short pause in after it gets all the data it needs so that it can write it all out if need be so that I end up with about a 2 second cycle for new data.
I sincerely hope I am making some sense.
Wade
Re: Client/Server Starting Help
First you should understand that a Web server WON'T poll a client. They only get connected when a client initiates a web request to the server.
Generally, in order for a client to receive a poll call its machine has to have a listener running (something simply has to answer an incoming connection, i.e. TCPListener).
You could walk down this path but it wouldn't be very effective since you will have to maintain additional park of mahcines and ensure they will always wait for incoming poll from the server. In this case we can rule out web application as a class.
You need to design a client part that is able to initiate or receive some communication from the server and transmit some data to it.
If you want to stick to the web server (or a service) you would have to configure clients to initiate requests to it in a given freqiency (basically, a user, or an app should reload the page on a server once an hour, for example).
You can transmit data to the server using web requests. If the data is relatively small, it can be transferred in the request string (i.e. www.myhost.com?mydata=1234) using GET method. (The server will receive 1234)
If you need to transfer an amount of data bigger than can be conveniently packed in a request string you should use POST method.
Pros: the client side doesn't really need anything except a web browser (and probably an app that constructs the web requests) and a windows scheduler to do it periodically.
Cons: The server can only receive data from the client when the client sends a request.
If you need realtime communications you should either develop your own client part and a server part and also the data transmission protocol or use an existing one - I'd looked into something like Jabber: http://en.wikipedia.org/wiki/Extensi...sence_Protocol. There are bound to be SDKs for it (if you use some instant messenger like ICQ or AIM, etc you'll get the basic knowledge of how it works).
Pros: realtime communications at any time
Cons: you will have to maintain a client base on the server and also maintain the software and connectivity of numerous clients.