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