You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.6 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NewLife;
using NewLife.Log;
namespace NDSD_TouchSocket
{
public class DOperate
{
SendAnalysis sendAnalysis;
TcpServer Server = TcpServer.Instance;
public DOperate()
{
sendAnalysis = new SendAnalysis();
}
/// <summary>
/// 枚举类控制接口开一段时间
/// </summary>
/// <param name="port">Port枚举类D1-D16</param>
/// <param name="delay">延迟1代表0.1s/100ms</param>
public void DTimeOpen(Port port, int delay)
{
// string str = sendAnalysis.DTimeOpenDataAnalysis((byte)port, delay).ToHex(" ");
Server.SendMessage(sendAnalysis.DTimeOpenDataAnalysis((byte)port, delay));
}
/// <summary>
/// int控制接口开一段时间
/// </summary>
/// <param name="port">int1-16</param>
/// <param name="delay">延迟1代表0.1s/100ms</param>
public void DTimeOpen(int port, int delay)
{
XTrace.WriteLine("发送延迟开灯指令:"+(int)port);
DTimeOpen((Port)(port + 4), delay);
}
/// <summary>
/// 枚举类控制接口开
/// </summary>
/// <param name="port">Port枚举类D1-D16</param>
public void DOpen(Port port)
{
Server.SendMessage(sendAnalysis.DOpenDataAnalysis((byte)port));
}
/// <summary>
/// int控制接口开
/// </summary>
/// <param name="port">int1-16</param>
public void DOpen(int port)
{
XTrace.WriteLine("发送开灯指令:"+(int)port);
DOpen((Port)(port + 4));
}
/// <summary>
/// 枚举类控制接口关
/// </summary>
/// <param name="port">Port枚举类D1-D16</param>
public void DClose(Port port)
{
Server.SendMessage(sendAnalysis.DCloseDataAnlysis((byte)port));
}
/// <summary>
/// int控制接口关
/// </summary>
/// <param name="port">int1-16</param>
public void DClose(int port)
{
XTrace.WriteLine("发送关灯指令:"+(int)port);
DClose((Port)(port + 4));
}
}
public enum Port
{
D1 = 0x05,
D2,
D3,
D4,
D5,
D6,
D7,
D8,
D9,
D10,
D11,
D12,
D13,
D14,
D15,
D16,
}
}