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.

56 lines
2.8 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.Runtime.InteropServices;
namespace GTN
{
public class glink
{
public const short GLINK_MODE_DLL=0;
public const short GLINK_MODE_DSP=1;
[DllImport("gts.dll")]
public static extern short GT_SetGLinkDo(short slaveno, ushort offset, ref byte pData, ushort bytelength);
[DllImport("gts.dll")]
public static extern short GT_GetGLinkDo(short slaveno, ushort offset, ref byte pData, ushort bytelength);
[DllImport("gts.dll")]
public static extern short GT_GetGLinkDi(short slaveno, ushort offset, out byte pData, ushort bytelength);
[DllImport("gts.dll")]
public static extern short GT_SetGLinkDoBit(short slaveno, short doIndex, byte value);
[DllImport("gts.dll")]
public static extern short GT_GetGLinkDiBit(short slaveno, short diIndex, out byte pValue);
[DllImport("gts.dll")]
public static extern short GT_SetGLinkAo(short slaveno, ushort channel, ref short data, ushort count);
[DllImport("gts.dll")]
public static extern short GT_GetGLinkAo(short slaveno, ushort channel, out short data, ushort count);
[DllImport("gts.dll")]
public static extern short GT_GetGLinkAi(short slaveno, ushort channel, out short data, ushort count);
[DllImport("gts.dll")]
public static extern short GT_GetGLinkOnlineSlaveNum(out byte pSlavenum);
[DllImport("gts.dll")]
public static extern short GT_SetGLinkModuleConfig(ref string pFile);
[DllImport("gts.dll")]
public static extern short GT_GLinkInit(short cardNum);
[DllImport("gts.dll")]
public static extern short GT_GLinkInitEx(short cardNum, short opMode);
[DllImport("gts.dll")]
public static extern short GT_GetGLinkDiEx(short slaveno, out byte pData, ushort count);
[DllImport("gts.dll")]
//获取所有Glink从站信息slavenum在线从站数量slavetype 1DIO16 2AIO0606 4DI32 dilength dolength 长度 字节
public static extern short GT_GetGLinkModulesInfo(out char pslavenum,out char pslavetype,out char psubslavetype,out char pdilength,out char pdolength);
public struct GLINK_COMM_STS
{
public byte onlineSlaveNum;
public byte initSlaveNum;
public byte commStatus;
//public byte dump[13];
}
[DllImport("gts.dll")]
public static extern short GT_GetGLinkCommStatus(out GLINK_COMM_STS commSts);
[DllImport("gts.dll")]
public static extern short GT_RelateGlinkToMcGpiBit(short gpi,short slaveno,short bitoffset,short byteOffset);
[DllImport("gts.dll")]
public static extern short GT_RelateGlinkToMcGpoBit(short gpo,short slaveno,short bitoffset,short byteOffset);
[DllImport("gts.dll")]
public static extern short GT_GLinkDeInit(UInt32 Param);
}
}