123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
- namespace IntelligentControlForsx.Service.WindturbineControl.IntPtrSvc
- {
- /// <summary>
- /// 控制命令发送接口,引用C++服务
- /// </summary>
- public static class CmdSendService
- {
- /// <summary>
- /// 遥信
- /// </summary>
- public static byte GYCP_TYPE_YX = 0;
- /// <summary>
- /// 遥测
- /// </summary>
- public static byte GYCP_TYPE_YC = 1;
- /// <summary>
- /// 遥控
- /// </summary>
- public static byte GYCP_TYPE_YK = 2;
- /// <summary>
- /// 遥调
- /// </summary>
- public static byte GYCP_TYPE_YT = 3;
- /// <summary>
- /// 遥视
- /// </summary>
- public static byte GYCP_TYPE_YS = 4;
- [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.Cdecl)]
- public delegate void GycpReceive(IntPtr types, IntPtr addrs, IntPtr errors, uint length, IntPtr arg);
- /// <summary>
- /// 创建句柄
- /// </summary>
- /// <param name="ip">服务地址</param>
- /// <param name="port">端口</param>
- /// <param name="t0">重连时间</param>
- /// <param name="t1">keepalive时间</param>
- /// <param name="t2">keepalive返回时间</param>
- /// <param name="receive">回调函数</param>
- /// <param name="arg">回调函数参数</param>
- /// <returns></returns>
- [DllImport("gycp.dll", CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr gycp_create(string ip, ushort port, byte t0, byte t1, byte t2, GycpReceive receive, IntPtr arg);
- [DllImport("gycp.dll", CallingConvention = CallingConvention.Cdecl)]
- public static extern void gycp_destroy(IntPtr gycp);
- /// <summary>
- /// 发送命令
- /// </summary>
- /// <param name="gycp">句柄</param>
- /// <param name="types">控制类型</param>
- /// <param name="addrs">控制地址(控制点)</param>
- /// <param name="values">控制值</param>
- /// <param name="length">数组长度</param>
- /// <returns></returns>
- [DllImport("gycp.dll", CallingConvention = CallingConvention.Cdecl)]
- public static extern int gycp_control(IntPtr gycp, byte[] types, uint[] addrs, float[] values, uint length);
-
- }
- }
|