通过ASP.Net进行设备控制 [英] Equipment Control Via ASP.Net

查看:71
本文介绍了通过ASP.Net进行设备控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我是ASP.Net的新手,如果使用不正确的术语,请原谅我,我只是不知道从哪里开始.

我的设备壁橱中有一台服务器.在设备壁橱中,有几件音频视频设备.某些设备可以通过异步tcp/ip控制进行控制,而某些设备可以通过RS232进行控制.通过tcp/ip控制控制的设备直接连接到路由器,该路由器也在设备壁橱中.通过RS232控制的设备直接连接到服务器.所有不同的设备都可以接收和发送数据.最初,我使用vb.net创建了一个Windows应用程序来控制设备,这很好用,并且可以完美运行.该应用程序将运行,并且我将能够发送和接收数据.这包括打开设备,提高音量,更改频道等...我也会收到反馈,告诉我设备的状态.根据设备的不同,通信方式可以是ASCII或十六进制.

一段时间后,我开始考虑使用Windows服务器托管一个ASP.net网站来托管此应用程序以进行设备控制.通过这种设计,LAN上的任何计算机或电话都可以控制设备并检查状态.认为这是一个简单的过渡,所以我复制了代码并创建了一个表单,然后在服务器上运行了网站.不用说,它没有按我希望的那样工作.由于回发和网站的状态,它发送一次数据并关闭连接.这样,除非重新打开连接和其他许多问题,否则我不会收到数据,也无法重新发送数据.最初是一个有趣的项目,一个很酷的事情变成了让它工作的一种迷恋.我花了近一个月的时间试图弄清楚如何进行这项工作.我研究了WCF,Web服务和activeX控件.我似乎无法弄清楚是否可以做到这一点,什么是最好的方法.我试图学习所有这些新方法,但无济于事.

我绝不是专家,我喜欢喜欢挑战就喜欢将编程作为一种有趣的爱好,所以这是我的问题:

1).我可以使用ASP网站通过tcp/ip控制壁橱中的设备吗?

2).我可以通过使用ASP网站直接连接到服务器的RS232来控制壁橱中的设备吗?

3).如果可行,那么使这项工作最好的方法是什么?

在这种情况下,我很失落,我什至不知道是否可以做到,如果可以,我也不知道该怎么做.预先感谢您查看该帖子,我非常感谢任何指导.

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.

推荐答案

问题不是可以做到吗?",因为答案是几乎总是会的.正确的问题是如何完成?".

Windows窗体应用程序是有状态的.它们在应用程序的整个生命周期中都保持对象图的状态.

网站(ASP.NET)是无状态的.您的客户端连接到服务器,获取发送给它的网页,并在发送的每个页面上断开连接.在Web会话的整个生命周期内维护对象图状态的能力要有限得多.

您可能正在尝试对ASP.NET站点代码中壁橱中的所有内容进行控制.不要.

我将创建一个在服务器上运行的Windows服务,以处理控制设备和维护客户端状态信息的过程.此服务在启动时将与壁橱中的设备建立通信,确定受控制设备的状态,并设置其内部数据结构以保存状态信息,并公开接口以接受来自客户端应用程序的命令以控制设备.设备.

我正在谈论的客户端应用程序是您的ASP.NET网站.它所要做的就是与Windows服务通信,可能通过服务设置的命名管道进行,并获取设备状态以向用户显示并向该服务发送命令.这样,ASP.NET站点完全不必维护任何状态信息.

这种设置还解决了您可能没有想到的问题.如果两个人同时尝试控制同一台设备会发生什么?一个ASP.NET站点将很难控制设备的并发连接,而​​服务可以很容易地做到这一点,并且一次只能允许一个用户控制设备.
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.


这篇关于通过ASP.Net进行设备控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆