I am attempting to write a Windows Form Application that would provide a PTZ interface for various Analog CCTVs using Pelco D protocol.
I have been able to successfully connect and send serial data (using byte arrays containing Hex values) to a serial server which communicates using a TCP/IP port connection. This connection passes the data to a daisy chain of Pelco CDUs (Matrix Code Distribution Units).
Here is my current dillema: I am in need to ensure the following:
The application should only maintain an active connection to the serial server's port when data needs to be passed. This is to allow for external systems to connect to the port when it is not in use from the current application.
Control of multiple cameras listening from the same port concurrently. At some point, I think a server-client type of configuration will be required so that a single port connection would listen and queue any incoming data from other potential client connections. However, this is a long term goal and not immediate to my current needs.
Button controls are used to send PTZ commands. These buttons have MouseDown and MouseUp event handlers which need to pass data and manage port connections as efficiently as possible.
As a proof of concept, sending non continuous commands such as presets and wiper control execute flawlessly using the following methodology:
on a button's on-click event, perform the following:
• establish connection to TCP/IP port.
• sends corrsponding serial commands based on the current button pressed.
• close connection to TCP/IP port.
I am primarily interested in pseudo code solutions or general advice regarding best practices or reference materials to help steer me in the right direction.
Thanks in advance!