网络类智能开关控制板采用 TCP/IP 协议与控制主机(PC 机)进行通讯,运
行稳定可靠,传输距离远,尤其适合不方便布线的场所。每块开关板分配一个唯
一的 IP 地址,通过 IP 地址进行控制数据的传输区分;每个开关触点容量为
220V/10A,一般情况下推荐使用到 6A 左右,太大的电流请使用我公司的 30A 控
制卡。
网络类普通型号(有线、无线和混合网络)可以直接连路由器,手机和电脑
连接路由器后均可以控制,但是异地远程需要路由器所在网络有外网 IP,通过
花生壳+端口映射即可实现异地远程。云转发型号直接支持异地远程,插上网线
手机和电脑软件中输入设备序列号即可异地远程进行开关控制
下面以两路的控制板举例:硬件图片
设置界面:
demo代码:
using System;
using System.Net;
using System.Net.Sockets;using System.Windows.Forms;namespace 远程智能开关控制板
{public partial class Form1 : Form{public Form1()
{InitializeComponent();}private void Form1_Load(object sender, EventArgs e)
{radioButton1.Checked = true;textBox1.Text = "192.168.1.80";textBox2.Text = "3000";}private void SendData(IPAddress remoteIP, int Port,byte[] bits)
{//实例化socket Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);IPEndPoint ipep = new IPEndPoint(remoteIP, Port);socket.Connect(ipep);//socket.Send(bits, 8, SocketFlags.None);socket.Send(bits);socket.Close();}private void button1_Click(object sender, EventArgs e)
{byte[] order = new byte[8];foreach (RadioButton c in groupBox1.Controls){if (c.Checked){switch (c.Name){case "radioButton1": order = new byte[] { 0x55, 0x01, 0x12, 0x00, 0x00, 0x00, 0x01, 0x69 }; break;//闭合第一路case "radioButton2": order = new byte[] { 0x55, 0x01, 0x12, 0x00, 0x00, 0x00, 0x02, 0x6a }; break;//闭合第二路case "radioButton3": order = new byte[] { 0x55, 0x01, 0x12, 0x00, 0x00, 0x00, 0x03, 0x6b }; break;//闭合第三路case "radioButton4": order = new byte[] { 0x55, 0x01, 0x12, 0x00, 0x00, 0x00, 0x04, 0x6c }; break;//闭合第四路default: break;}}}SendData(IPAddress.Parse(textBox1.Text), int.Parse(textBox2.Text), order);MessageBox.Show("闭合指令发送成功");}private void button2_Click(object sender, EventArgs e)
{byte[] order = new byte[8];foreach (RadioButton c in groupBox1.Controls){if (c.Checked){switch (c.Name){case "radioButton1": order = new byte[] { 0x55, 0x01, 0x11, 0x00, 0x00, 0x00, 0x01, 0x68 }; break;//断开第一路case "radioButton2": order = new byte[] { 0x55, 0x01, 0x11, 0x00, 0x00, 0x00, 0x02, 0x69 }; break;//断开第二路case "radioButton3": order = new byte[] { 0x55, 0x01, 0x11, 0x00, 0x00, 0x00, 0x03, 0x6a }; break;//断开第三路case "radioButton4": order = new byte[] { 0x55, 0x01, 0x11, 0x00, 0x00, 0x00, 0x04, 0x6b }; break;//断开第四路default: break;}}}SendData(IPAddress.Parse(textBox1.Text), int.Parse(textBox2.Text), order);MessageBox.Show("断开指令发送成功");}}
}
运行界面: