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
{
///
/// 控制命令发送接口,引用C++服务
///
public static class CmdSendService
{
///
/// 遥信
///
public static byte GYCP_TYPE_YX = 0;
///
/// 遥测
///
public static byte GYCP_TYPE_YC = 1;
///
/// 遥控
///
public static byte GYCP_TYPE_YK = 2;
///
/// 遥调
///
public static byte GYCP_TYPE_YT = 3;
///
/// 遥视
///
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);
///
/// 创建句柄
///
/// 服务地址
/// 端口
/// 重连时间
/// keepalive时间
/// keepalive返回时间
/// 回调函数
/// 回调函数参数
///
[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);
///
/// 发送命令
///
/// 句柄
/// 控制类型
/// 控制地址(控制点)
/// 控制值
/// 数组长度
///
[DllImport("gycp.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int gycp_control(IntPtr gycp, byte[] types, uint[] addrs, float[] values, uint length);
}
}