海康威视道闸进出口LED屏DS-TVL224系列开发C#源码

1 篇文章 0 订阅
1 篇文章 0 订阅

1、类库源码:

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;

namespace LS_HIK_5x
{
    public class Led
    {

        public string ip_add { get; set; }
        public ushort port { get; set; }

        public Led(string _ip_add, ushort _port)
        {
            ip_add = _ip_add;
            port = _port;
        }

        public Led(string _ip_add)
        {
            ip_add = _ip_add;
            port = 10000; //默认端口 TCP:10000
        }               
              

        Encoding GB2312 = Encoding.GetEncoding("GB2312");

        public bool led_show(string text, Color color, out string e)
        {
            try
            {
                //文本内码更新

                byte[] cmd_text_0 = { 0x55, 0xAA, 0x00, 0x00, 0x01, 0x00, 0x00, 0xDA, 0x00, 0x00 };
                byte[] cmd_text_1 = { 0x3D, 0x00, 0x00, 0x00 };//包长度(数据长度+51)
                byte[] cmd_text_2 = { 0x01, 0x01 };
                byte[] cmd_text_3 = { 0x3D, 0x00, 0x00, 0x00 };//帧长度(数据长度+51)
                byte[] cmd_text_4 = { 0x01, 0x01 };
                byte[] cmd_text_5 = { 0x3C, 0x00, 0x00, 0x00 };//节目长度(数据长度+50)
                byte[] cmd_text_6 = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
                byte[] cmd_text_7 = { 0x24, 0x00, 0x00, 0x00 };//区域数据长度 (数据长度+26)
                byte[] cmd_text_8 = { 0x0E, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x3F, 0x00 };
                byte[] cmd_text_9 = { 0x02 };//颜色 01 红 02 绿
                byte[] cmd_text_10 = { 0x00, 0x00, 0x01, 0xFF, 0x01, 0x01, 0x10 };
                byte[] cmd_text_11 = { 0x0A, 0x00, 0x00, 0x00 };//数据长度 低位在前
                byte[] cmd_text_12 = { 0xD2, 0xBB, 0xC2, 0xB7, 0xC6, 0xBD, 0xB0, 0xB2, 0x38, 0x36 };//数据内容
                byte[] cmd_text_13 = { 0x00, 0x00, 0x0D, 0x0A };//帧尾


                //打开连接
                TcpClient led = new TcpClient();
                led.Connect(IPAddress.Parse(ip_add), port);
                NetworkStream ns = led.GetStream();

                if (color == Color.Red)
                {
                    cmd_text_9 = new byte[] { 0x01 };
                }
                else if (color == Color.Green)
                {
                    cmd_text_9 = new byte[] { 0x02 };
                }
                else if (color == Color.Yellow)
                {
                    cmd_text_9 = new byte[] { 0x03 };
                }

                cmd_text_12 = GB2312.GetBytes(text);

                cmd_text_11 = BitConverter.GetBytes(cmd_text_12.Length);
                cmd_text_7 = BitConverter.GetBytes(cmd_text_12.Length + 26);
                cmd_text_5 = BitConverter.GetBytes(cmd_text_12.Length + 50);
                cmd_text_3 = BitConverter.GetBytes(cmd_text_12.Length + 51);
                cmd_text_1 = BitConverter.GetBytes(cmd_text_12.Length + 51);

                byte[] cmd_text = new byte[cmd_text_0.Length + cmd_text_1.Length + cmd_text_2.Length + cmd_text_3.Length + cmd_text_4.Length + cmd_text_5.Length + cmd_text_6.Length + cmd_text_7.Length + cmd_text_8.Length + cmd_text_9.Length + +cmd_text_10.Length + cmd_text_11.Length + cmd_text_12.Length + cmd_text_13.Length];

                cmd_text = cmd_text_0.Concat(cmd_text_1).ToArray();
                cmd_text = cmd_text.Concat(cmd_text_2).ToArray();
                cmd_text = cmd_text.Concat(cmd_text_3).ToArray();
                cmd_text = cmd_text.Concat(cmd_text_4).ToArray();
                cmd_text = cmd_text.Concat(cmd_text_5).ToArray();
                cmd_text = cmd_text.Concat(cmd_text_6).ToArray();
                cmd_text = cmd_text.Concat(cmd_text_7).ToArray();
                cmd_text = cmd_text.Concat(cmd_text_8).ToArray();
                cmd_text = cmd_text.Concat(cmd_text_9).ToArray();
                cmd_text = cmd_text.Concat(cmd_text_10).ToArray();
                cmd_text = cmd_text.Concat(cmd_text_11).ToArray();
                cmd_text = cmd_text.Concat(cmd_text_12).ToArray();
                cmd_text = cmd_text.Concat(cmd_text_13).ToArray();

                ns.Write(cmd_text, 0, cmd_text.Length);

                //关闭连接
                Thread.Sleep(1000);//稍作等待
                ns.Close();
                led.Close();


                e = "发送成功";

                return true;
            }
            catch (Exception ex)
            {
                e = "发送失败,原因:" + ex.Message;
                return false;
                //throw;
            }
        }


        public void led_show_asyn(string text, Color color)
        {
            string info = "";
            Thread th = new Thread(() =>
            {
                led_show(text, color, out info);
            });
        }

        public bool led_speak(string text, out string e)
        {
            try
            {


                //语音播报
                byte[] cmd_speak_0 = { 0x55, 0xAA, 0x00, 0x00, 0x01, 0x00, 0x00, 0xDA, 0x00, 0x00 };
                byte[] cmd_speak_1 = { 0x36, 0x00, 0x00, 0x00 };//包长度(数据长度+51)
                byte[] cmd_speak_2 = { 0x00, 0x00 };
                byte[] cmd_speak_3 = { 0x36, 0x00, 0x00, 0x00 };//帧长度(数据长度+51)
                byte[] cmd_speak_4 = { 0x01, 0x01 };
                byte[] cmd_speak_5 = { 0x35, 0x00, 0x00, 0x00 };//节目长度(数据长度+50)
                byte[] cmd_speak_6 = { 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01 };
                byte[] cmd_speak_7 = { 0x1D, 0x00, 0x00, 0x00 };//区域数据长度 (数据长度+26)
                byte[] cmd_speak_8 = { 0x2D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x01 };
                byte[] cmd_speak_9 = { 0x03, 0x00, 0x00, 0x00 };//数据长度 低位在前
                byte[] cmd_speak_10 = { 0x32, 0x33, 0x35 };//数据内容 (语音:“二百三十五”)
                byte[] cmd_speak_11 = { 0x00, 0x00, 0x0D, 0x0A };//帧尾            

                //打开连接
                TcpClient led = new TcpClient();
                led.Connect(IPAddress.Parse(ip_add), port);
                NetworkStream ns = led.GetStream();

                cmd_speak_10 = GB2312.GetBytes(text);

                cmd_speak_9 = BitConverter.GetBytes(cmd_speak_10.Length);
                cmd_speak_7 = BitConverter.GetBytes(cmd_speak_10.Length + 26);
                cmd_speak_5 = BitConverter.GetBytes(cmd_speak_10.Length + 50);
                cmd_speak_3 = BitConverter.GetBytes(cmd_speak_10.Length + 51);
                cmd_speak_1 = BitConverter.GetBytes(cmd_speak_10.Length + 51);

                byte[] cmd_speak = new byte[cmd_speak_0.Length + cmd_speak_1.Length + cmd_speak_2.Length + cmd_speak_3.Length + cmd_speak_4.Length + cmd_speak_5.Length + cmd_speak_6.Length + cmd_speak_7.Length + cmd_speak_8.Length + cmd_speak_9.Length + +cmd_speak_10.Length + cmd_speak_11.Length];

                cmd_speak = cmd_speak_0.Concat(cmd_speak_1).ToArray();
                cmd_speak = cmd_speak.Concat(cmd_speak_2).ToArray();
                cmd_speak = cmd_speak.Concat(cmd_speak_3).ToArray();
                cmd_speak = cmd_speak.Concat(cmd_speak_4).ToArray();
                cmd_speak = cmd_speak.Concat(cmd_speak_5).ToArray();
                cmd_speak = cmd_speak.Concat(cmd_speak_6).ToArray();
                cmd_speak = cmd_speak.Concat(cmd_speak_7).ToArray();
                cmd_speak = cmd_speak.Concat(cmd_speak_8).ToArray();
                cmd_speak = cmd_speak.Concat(cmd_speak_9).ToArray();
                cmd_speak = cmd_speak.Concat(cmd_speak_10).ToArray();
                cmd_speak = cmd_speak.Concat(cmd_speak_11).ToArray();

                ns.Write(cmd_speak, 0, cmd_speak.Length);

                //关闭连接
                Thread.Sleep(1000);//稍作等待
                ns.Close();
                led.Close();
                e = "发送成功";
                return true;
            }
            catch (Exception ex)
            {
                e = "发送失败,原因:" + ex.Message;
                return false;
                //throw;
            }
        }
    }
}

2、调用示例:

using LS_HIK_5x;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 海康DS_TVL224LED屏文本与语音测试
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void button2_Click(object sender, EventArgs e) //语音播报
        {
            string err;
            Led led = new Led(textBox1.Text,Convert.ToUInt16(textBox2.Text));
            led.led_speak(textBox4.Text,out err);
            Debug.Print(err);
        }

        private void button1_Click(object sender, EventArgs e)  //文本更新
        {
            string err;
            Led led = new Led(textBox1.Text, Convert.ToUInt16(textBox2.Text));
            Color text_color;
            if (radioButton1.Checked)
            {
                text_color = Color.Red;
            }
            else
            {
                text_color = Color.Green;
            }
            led.led_show(textBox4.Text, text_color, out err);
            Debug.Print(err);
        }
    }
}


 

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 8
    评论
海康威视DS-K1T673是一款技术文档C型的产品。DS-K1T673是一种高性能的门禁终端设备,具有多种功能和特点。 首先,DS-K1T673采用了先进的技术和算法,具有快速而准确的人脸识别能力。它能够高效地识别注册人员的脸部特征,并进行比对。在识别过程中,它能够快速判断人员的身份,确保门禁系统的安全性。 其次,DS-K1T673还具有多种身份认证方式。除了人脸识别功能之外,它还支持IC卡和密码输入等多种认证方式,便于用户选择适合自己的认证方式。这样,用户可以根据具体需求和场景,选择最便捷和安全的认证方式。 此外,DS-K1T673还具有一系列智能功能。它支持人脸出入、人员轨迹记录以及报警等功能。在人员轨迹记录方面,它能够记录人员在指定时间段内的出入记录,并提供相应的数据报表。这对于企业管理来说,非常有利于统计和分析人员出入情况。 最后,DS-K1T673还具有良好的扩展性。它支持TCP/IP网络通信,能够与其他设备进行联动,实现更复杂的门禁系统。同时,它还支持集中式或分布式部署,可以根据具体需求进行灵活的布局。 总之,海康威视DS-K1T673技术文档C型是一款功能齐全、性能优越的门禁终端设备,具有快速准确的人脸识别能力、多种身份认证方式、智能功能以及良好的扩展性。它的出现将极大地提升门禁系统的安全性和便捷性,满足不同领域的需求。
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lzl640

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值