Click here to Skip to main content
15,904,024 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all, I am new to ASP.Net, please forgive me if I use incorrect terminology, I just do not know where to begin.

I have a server located in my equipment closet. In the equipment closet there are several pieces of audio video equipment. Some of the equipment can be controlled via asynchronous tcp/ip control and some can be controlled via RS232. The equipment that is controlled via tcp/ip control is directly connected to the router which is also in the equipment closet. The equipment that is controlled via RS232 to directly connected to the server. All the different equipment both receive and send data. Originally I created a windows application using vb.net to control the equipment, this worked great and I had it working perfectly. The application would run, and I would be able to send and receive data. This included turning on the equipment, raising the volume, changing channels,... I would also receive feedback telling me the status of the equipment. The communication was either in ASCII or hex, depending on the equipment.

After a while, I got to thinking of using the windows server to host an ASP.net website to host this application for equipment control. With this design, any computer or phone on the LAN can control the equipment and check status. Thinking that this was an easy transition, I copied the code and created a form and ran the website on the server. Needless to say, it didn't work as I had hoped. Due to postbacks and the state of websites, it sends the data once and closes the connection. As such, I do not receive data back, I cannot resend data, unless I open the connection again and a number of other issues. What began as a fun project and a cool thing to do turned into an obsession to get it working. I have spent nearly a month trying to figure out how to make this work. I looked into WCF, web services and activeX controls. I cannot seem to figure out if this can be done and what is the best method. I have tried to learn all these new methods, to no avail.

I am by no means an expert, i enjoy programming as a fun hobby as i like challenges So here are my questions:

1). Can I control the equipment in my closet via tcp/ip using an ASP website?

2). Can I control the equipment in my closet via RS232 that is directly connected to the server using an ASP website?

3). If it is feasible, then what is the best way to make this work?

In this situation, I am so lost I do not even know if it can be done and if it can, I do not know how to go about doing it. Thank you in advance for looking at the post an I appreciate any guidance.
Posted

1 solution

The question isn't "Can it be done?", because the answer is just about always yes. The correct question is "HOW can it be done?".

Windows Forms apps are stateful. They maintain the state of an object graph through throughout the lifetime of the application.

Web sites (ASP.NET) are stateLESS. Your client connects to the server, gets a web page sent to it, and disconnects, on EVERY page sent. There is a much more limited ability to maintain the state of an object graph over the lifetime of a web session.

You're probably trying to do the controlling of everything in the closet in the ASP.NET site code. Don't.

I would create a Windows Service that runs on the server to handle controlling the devices and maintaining state information for clients. This service, on startup, would setup communication with the devices in the closet, determine the state of the devices being controlled and setup its internal data structures to hold the status information as well as expose interfaces to accept commands from a client application to control the devices.

The client application I'm talking about is your ASP.NET site. All it would do is communicate with the windows service, probably through a named pipe the service sets up, and get the device status to show the user and send commands to the service. The ASP.NET site then doesn't have to maintain any state information at all.

This kind of setup also solves a problem you probably didn't think of. What would happen if two people tried controlling the same device at the same time?? An ASP.NET site would have a very difficult time controlling concurrent connections to the devices whereas a service can very easily do it and only allow one user to control a device at a time.
 
Share this answer
 
v2
Comments
David Kal 13-Jan-12 12:09pm    
I see what you are saying. How hard is it to setup. I thought about web services, and then I realized I do not need to communicate between two computers and transfer the data, since the server resides in the equipment closet. Can you point me on how I can do this. I have limited knowledge in ASP, but I ok using VB.net. Thank you again for pointing me in that direction. I will look into it in the mean time.
Dave Kreskowiak 13-Jan-12 12:42pm    
I already gave you the things you need to do research on. Windows Services and Named Pipes. I little Google goes a long way.
David Kal 13-Jan-12 13:28pm    
Thank you for the pointer. I will do some research and try to make it work.
Sergey Alexandrovich Kryukov 13-Jan-12 17:55pm    
Quite reasonable arguments, my 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900