using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace StageController.HDS { public class zmotion { //PC库错误码 public enum ZMC_CONNECTION_TYPE { ZMC_CONNECTION_COM = 1, ZMC_CONNECTION_ETH = 2, ZMC_CONNECTION_USB = 3, ZMC_CONNECTION_PCI = 4, }; public struct struct_AxisStates { public byte m_HomeState; // public byte m_AlarmState; public byte m_SDState; public byte m_INPState; public byte m_ElDecState; public byte m_ElPlusState; public byte m_HandWheelAState; public byte m_HandWheelBState; public byte m_EncodeAState; // public byte m_EncodeBState; // public byte m_EMGState; //每个轴都一样 public byte m_ClearState; // public byte m_EnableOut; //增加软限位信号 public byte m_SoftElDecState; //0- 有效 public byte m_SoftElPlusState; public byte m_LatchAState; //锁存信号 public byte m_LatchBState; //锁存信号 }; /********************************************************* 系统状态定义 **********************************************************/ public enum ZBASIC_TASKSTATE { TASK_STATE_RUNING = 1, TASK_STATE_PAUSE = 3, TASK_STATE_STOP = 0, /************ 下面是trio特殊状态, 暂时不支持 ************/ //步进 TASK_STATE_STEP = 2, TASK_STATE_PAUSING = 4, TASK_STATE_STOPING = 5, TASK_STATE_ERROR = 100,//查询的时候如果ID错返回这个值, 脚本初始化发现语法错误也返回这个错误 }; //缺省的等待时间 public const int ZMC_DEFAULT_TIMEOUT = 5000; //串口延时需要更加长一些 public const int ZMC_DEFAULT_TIMEOUT_COM = 5000; //新增加 public const int SYS_STATE_CANNOT_CONNECT = 50;//链接不上 /************************************************************* Description: //与控制器建立链接 Input: //无 Output: //卡链接handle Return: //错误码 *************************************************************/ [DllImport("zmotion.dll", EntryPoint = "ZMC_Open", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] //int32 __stdcall ZMC_Open(ZMC_CONNECTION_TYPE type, char *pconnectstring ,ZMC_HANDLE * phandle); public static extern Int32 ZMC_Open(ZMC_CONNECTION_TYPE type, string pconnectstring, out IntPtr phandle); /************************************************************* Description: //与控制器建立链接, 可以指定连接的等待时间 Input: //无 Output: //卡链接handle Return: //错误码 *************************************************************/ [DllImport("zmotion.dll", EntryPoint = "ZMC_FastOpen", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] //int32 __stdcall ZMC_FastOpen(ZMC_CONNECTION_TYPE type, char *pconnectstring, uint32 uims ,ZMC_HANDLE * phandle); public static extern Int32 ZMC_FastOpen(ZMC_CONNECTION_TYPE type, string pconnectstring, UInt32 uims,out IntPtr phandle); /************************************************************* Description: //与控制器建立链接, 串口方式. Input: //无 Output: //卡链接handle Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_OpenCom(uint32 comid, ZMC_HANDLE * phandle); [DllImport("zmotion.dll", EntryPoint = "ZMC_OpenCom", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_OpenCom(UInt32 comid,out IntPtr phandle); /************************************************************* Description: //可以修改缺省的波特率等设置 uint32 dwByteSize = 8, uint32 dwParity = NOPARITY, uint32 dwStopBits = ONESTOPBIT Input: // Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_SetComDefaultBaud(uint32 dwBaudRate, uint32 dwByteSize, uint32 dwParity, uint32 dwStopBits); [DllImport("zmotion.dll", EntryPoint = "ZMC_SetComDefaultBaud", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_SetComDefaultBaud(UInt32 dwbaudRate, UInt32 dwByteSize, UInt32 dwParity, UInt32 dwStopBits); /************************************************************* Description: //快速控制器建立链接 Input: //无 Output: //卡链接handle Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_PeakCom(uint32 comid, uint32 uims,ZMC_HANDLE * phandle); [DllImport("zmotion.dll", EntryPoint = "ZMC_PeakCom", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_PeakCom(UInt32 comid, UInt32 uims, out IntPtr phandle); /************************************************************* Description: //与控制器建立链接 Input: //IP地址,字符串的方式输入 Output: //卡链接handle Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_OpenEth(char *ipaddr, ZMC_HANDLE * phandle); [DllImport("zmotion.dll", EntryPoint = "ZMC_OpenEth", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_OpenEth(string ipaddr, out IntPtr phandle); /************************************************************* Description: //与控制器建立链接 Input: //IP地址,32位数的IP地址输入, 注意字节顺序 Output: //卡链接handle Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_OpenEth2(struct in_addr straddr, ZMC_HANDLE * phandle); [DllImport("zmotion.dll", EntryPoint = "ZMC_OpenEth2", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_OpenEth2(UInt32 straddr, out IntPtr phandle); /************************************************************* Description: //与控制器建立链接 Input: //PCI卡编号 Output: //卡链接handle Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_OpenPci(uint32 cardnum, ZMC_HANDLE * phandle); [DllImport("zmotion.dll", EntryPoint = "ZMC_OpenPci", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_OpenPci(UInt32 cardnum,out IntPtr Phandle); /************************************************************* Description: //读取PCI的控制卡个数 Input: // Output: // Return: //卡数 *************************************************************/ //uint32 __stdcall ZMC_GetMaxPciCards(); [DllImport("zmotion.dll", EntryPoint = "ZMC_GetMaxPciCards", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern UInt32 ZMC_GetMaxPciCards(); /************************************************************* Description: //与控制器建立链接, 自动查找COM号 Input: //COM号范围 Output: //卡链接handle Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_SearchAndOpenCom(uint32 uimincomidfind, uint32 uimaxcomidfind,uint* pcomid, uint32 uims, ZMC_HANDLE * phandle); [DllImport("zmotion.dll", EntryPoint = "ZMC_SearchAndOpenCom", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_SearchAndOpenCom(UInt32 uimincomidfind, UInt32 uimaxcomidfind, ref UInt32 uims,out IntPtr phandle); /************************************************************* Description: //与控制器建立链接, 自动搜索网络. 暂时不支持 Input: //最长等待时间 Output: //卡链接handle 连接的IP地址 Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_SearchAndOpenEth(char *ipaddr, uint32 uims, ZMC_HANDLE * phandle); [DllImport("zmotion.dll", EntryPoint = "ZMC_SearchAndOpenEth", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_SearchAndOpenEth( string ipaddr, UInt32 uims,out IntPtr phandle); /************************************************************* Description: //与控制器建立链接, 自动搜索网络. Input: //最长等待时间 Output: //控制器IP地址, 地址间用空格区分。 Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_SearchEth(char *ipaddrlist, uint32 addrbufflength, uint32 uims); [DllImport("zmotion.dll", EntryPoint = "ZMC_SearchEth", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_SearchEth(string ipaddrlist, UInt32 addrbufflength, UInt32 uims); /************************************************************* Description: //关闭控制器链接 Input: //卡链接handle Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_Close(ZMC_HANDLE handle); [DllImport("zmotion.dll", EntryPoint = "ZMC_Close", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_Close(IntPtr handle); /************************************************************* Description: //命令的延时等待时间 Input: //卡链接handle 毫秒时间 Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_SetTimeOut(ZMC_HANDLE handle, uint32 timems); [DllImport("zmotion.dll", EntryPoint = "ZMC_SetTimeOut", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_SetTimeOut(IntPtr handle, UInt32 timems); /************************************************************* Description: //命令的延时等待时间 Input: //卡链接handle Output: //毫秒时间 Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_GetTimeOut(ZMC_HANDLE handle, uint32* ptimems); [DllImport("zmotion.dll", EntryPoint = "ZMC_GetTimeOut", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_GetTimeOut(IntPtr handle, ref UInt32 ptimems); /************************************************************* Description: //读取长时间命令的进度 Input: //卡链接handle Output: // Return: //进度, 浮点, *************************************************************/ //float __stdcall ZMC_GetProgress(ZMC_HANDLE handle); [DllImport("zmotion.dll", EntryPoint = "ZMC_Getprogress", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern float ZMC_GetProgress(IntPtr handle); /************************************************************* Description: //读取连接的类型 Input: //卡链接handle Output: // Return: //ZMC_CONNECTION_TYPE *************************************************************/ //uint8 __stdcall ZMC_GetConnectType(ZMC_HANDLE handle); [DllImport("zmotion.dll", EntryPoint = "ZMC_GetConnectType", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern byte ZMC_GetConnectType(IntPtr handle); /************************************************************* Description: //读取连接的名称 Input: //卡链接handle Output: // Return: //string *************************************************************/ //const char* __stdcall ZMC_GetConnectString(ZMC_HANDLE handle); [DllImport("zmotion.dll", EntryPoint = "ZMC_GetConnectString", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern byte[] ZMC_GetConnectString(IntPtr handle); //#if 0 //#endif /*************************************************** ZBASIC命令,文件相关函数列表 ***************************************************/ /************************************************************* Description: ////读取系统状态 Input: //卡链接handle Output: //状态 ZBASIC_TASKSTATE Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_GetState(ZMC_HANDLE handle,uint8 *pstate); [DllImport("zmotion.dll", EntryPoint = "ZMC_GetState", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_GetState(IntPtr handle, ref byte pstate); /************************************************************* Description: //读取暂停导致的任务号 Input: //卡链接handle Output: //任务号 Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_GetStopPauseTaskid(ZMC_HANDLE handle,uint8 *ptaskid); [DllImport("zmotion.dll", EntryPoint = "ZMC_GetStopPauseTaskid", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_GetStopPauseTaskid(IntPtr handle, ref byte ptaskid); /************************************************************* Description: ////读取链接控制器的总虚拟轴数 Input: //卡链接handle Output: // Return: //轴数,出错0 *************************************************************/ //uint8 __stdcall ZMC_GetAxises(ZMC_HANDLE handle); [DllImport("zmotion.dll", EntryPoint = "ZMC_GetAxises", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern byte ZMC_GetAxises(IntPtr handle); /************************************************************* Description: //通用的命令执行接口,此命令不读取控制器的应答. 当控制器没有缓冲时自动阻赛 Input: //卡链接handle pszCommand命令串, uimswait 最长等待ms时间 Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_ExecuteNoAck(ZMC_HANDLE handle, const char* pszCommand, uint32 uimswait); [DllImport("zmotion.dll", EntryPoint = "ZMC_ExecuteNoAck", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_ExecuteNoAck(IntPtr handle, string pszCommand, UInt32 uimswait); /************************************************************* Description: //通用的命令执行接口 当控制器没有缓冲时自动阻赛 Input: //卡链接handle pszCommand命令串, uimswait 最长等待ms时间 Output: //psResponse 接收控制器的执行结果输出 Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_Execute(ZMC_HANDLE handle, const char* pszCommand, uint32 uimswait, char* psResponse, uint32 uiResponseLength); [DllImport("zmotion.dll", EntryPoint = "ZMC_Execute", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_Execute(IntPtr handle, string pszCommand, UInt32 uimswait, byte[] psResponse, UInt32 uiResponseLength); /************************************************************* Description: //等待前面的命令执行结束,控制器执行的应答被丢掉. 当没有缓冲时自动阻赛 Input: //卡链接handle uimswait 最长等待ms时间 Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_ExecuteWaitDown(ZMC_HANDLE handle, uint32 uimaxms); [DllImport("zmotion.dll", EntryPoint = "ZMC_ExecuteWaitDown", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_ExecuteWaitDown(IntPtr handle, UInt32 uimaxms); /************************************************************* Description: //读取在线命令的应答, 对没有接收应答的命令有用. 此函数不阻赛 Input: //卡链接handle uimax 缓冲长度 Output: //pbuff 返回读取结果, puiread 读取的长度, pbifExcuteDown 是否已经执行结束 Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_ExecuteGetReceive(ZMC_HANDLE handle, char * pbuff, uint32 uimax, uint32 *puiread, uint8 *pbifExcuteDown); [DllImport("zmotion.dll", EntryPoint = "ZMC_ExecuteGetReceive", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_ExecuteGetReceive(IntPtr handle, string pbuff, UInt32 uimax, ref UInt32 puiread, ref byte pbifExcuteDown); /************************************************************* Description: //读取在线命令的当前剩余缓冲 Input: //卡链接handle Output: // Return: //剩余空间 出错 - 0 *************************************************************/ //uint32 __stdcall ZMC_ExecuteGetRemainBuffSpace(ZMC_HANDLE handle); [DllImport("zmotion.dll", EntryPoint = "ZMC_ExecuteGetRemainBuffSpace", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern UInt32 ZMC_ExecuteGetRemainBuffSpace(IntPtr handle); /************************************************************* Description: //直接命令接口,用于调试, 只支持少数命令 暂时不支持 Input: //卡链接handle Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_DirectCommand(ZMC_HANDLE handle, const char* pszCommand, char* psResponse, uint32 uiResponseLength); [DllImport("zmotion.dll", EntryPoint = "ZMC_DirectCommand", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_DirectCommand(IntPtr handle, string pszCommand, byte[] psResponse, UInt32 uiResponseLength); /************************************************************* Description: //打下载包ZAR, Input: //卡链接handle pZpjfilename 项目文件名 带路径 pZarfilename ZAR文件名 pPass 软件密码, 绑定APP_PASS 没有密码时pPass = NULL uid 绑定控制器唯一ID, 0-不绑定 Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_MakeZar(const char* pZpjfilename, const char* pZarfilename, const char *pPass, uint32 uid); [DllImport("zmotion.dll", EntryPoint = "ZMC_MakeZar", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_MakeZar(string pZpjfilename, string pZarfilename, string pPass, UInt32 uid); /************************************************************* Description: //打下载包ZAR, 输入二进制的zpj文件 Input: //卡链接handle pzpj 文件缓冲 pBasDir bas程序文件路径 pZarfilename ZAR文件名 pPass 软件密码, 绑定APP_PASS 没有密码时pPass = NULL uid 绑定控制器唯一ID, 0-不绑定 Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_MakeZar2(void *pzpj,const char *pBasDir, const char* pZarfilename, const char *pPass, uint32 uid); [DllImport("zmotion.dll", EntryPoint = "ZMC_MakeZar2", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_MakeZar2(IntPtr pzpj, string pBasDir, string pZarfilename, string pPass, UInt32 uid); /************************************************************* Description: //下载包文件 Input: //卡链接handle pfilename zar文件名 pfilenameinControl BASIC系统只有一个包文件,可以不指定. Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_DownZar(ZMC_HANDLE handle, const char* pfilename, const char* pfilenameinControl); [DllImport("zmotion.dll", EntryPoint = "ZMC_DownZar", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_DownZar(IntPtr handle , string pfilename, string pfilenameinControl); /************************************************************* Description: //下载包文件 Input: //卡链接handle pbuffer zar文件在内存中的地址 buffsize zar文件长度 pfilenameinControl 控制器上文件的名字 , BASIC系统只有一个包文件,可以不指定. Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_DownMemZar(ZMC_HANDLE handle, const char* pbuffer, uint32 buffsize, const char* pfilenameinControl); [DllImport("zmotion.dll", EntryPoint = "ZMC_DownMemZar", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_DownMemZar(IntPtr handle, string pbuffer , UInt32 buffsize, string pfilenameinControl); /************************************************************* Description: //运行包 Input: //卡链接handle pfilenameinControl 文件名, 当为NULL的时候运行缺省文件 , BASIC系统只有一个包文件,可以不指定. Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_RunZarFile(ZMC_HANDLE handle, const char* pfilenameinControl); [DllImport("zmotion.dll", EntryPoint = "ZMC_RunZarFile", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_RunZarFile(IntPtr handle, string pfilenameinControl); /************************************************************* Description: //暂停继续运行 Input: //卡链接handle Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_Resume(ZMC_HANDLE handle); [DllImport("zmotion.dll", EntryPoint = "ZMC_Resume", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_Resume(IntPtr handle); /************************************************************* Description: //下载到ram中运行 Input: //卡链接handle pfilename zar文件名, 带路径 Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_DownZarToRamAndRun(ZMC_HANDLE handle, const char* pfilename); [DllImport("zmotion.dll", EntryPoint = "ZMC_DownZarToRamAndRun", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_DownZarToRamAndRun(IntPtr handle , string pfilename); /************************************************************* Description: //下载包到ram中运行 Input: //卡链接handle pbuffer zar文件在内存中的地址 buffsize zar文件长度 Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_DownMemZarToRamAndRun(ZMC_HANDLE handle, const char* pbuffer, uint32 buffsize); [DllImport("zmotion.dll", EntryPoint = "ZMC_DownMemZarToRamAndRun", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_DownMemZarToRamAndRun(IntPtr handle , string buffer, UInt32 buffsize); /************************************************************* Description: //打下载包ZAR, 并下载到RAM运行 Input: //卡链接handle 文件名 pZpjfilename 项目文件名 带路径 pPass 软件密码, 绑定APP_PASS 没有密码时pPass = NULL uid 绑定控制器唯一ID, 0-不绑定 Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_MakeZarAndRamRun(const char* pZpjfilename,const char *pPass, uint32 uid); [DllImport("zmotion.dll", EntryPoint = "ZMC_MakeZarAndRamRun", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_MakeZarAndRamRun(string pZpjfilename, string pPass, UInt32 uid); /************************************************************* Description: //打下载包ZAR, 并下载到RAM运行 Input: //卡链接handle 文件名 pzpj 文件缓冲 pBasDir bas程序文件路径 pPass 软件密码, 绑定APP_PASS 没有密码时pPass = NULL uid 绑定控制器唯一ID, 0-不绑定 Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_MakeZarAndRamRun2(ZMC_HANDLE handle, void *pzpj,const char *pBasDir,const char *pPass, uint32 uid); [DllImport("zmotion.dll", EntryPoint = "ZMC_MakeZarAndRamRun2", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_MakeZarAndRamRun2(IntPtr handle , IntPtr pzpj , string pBasDir, string pPass, UInt32 uid); /************************************************************* Description: //打下载包ZAR, 并下载到控制器ROM Input: //卡链接handle 文件名 pZpjfilename 项目文件名 带路径 pPass 软件密码, 绑定APP_PASS 没有密码时pPass = NULL uid 绑定控制器唯一ID, 0-不绑定 Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_MakeZarAndDown(const char* pZpjfilename,const char *pPass, uint32 uid); [DllImport("zmotion.dll", EntryPoint = "ZMC_MakeZarAndDown", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_MakeZarAndDown(string pZpjfilename, string pPass, UInt32 uid); /************************************************************* Description: //打下载包ZAR, 并下载到控制器ROM Input: //卡链接handle 文件名 pzpj 文件缓冲 pBasDir bas程序文件路径 pPass 软件密码, 绑定APP_PASS 没有密码时pPass = NULL uid 绑定控制器唯一ID, 0-不绑定 Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_MakeZarAndDown2(ZMC_HANDLE handle, void *pzpj,const char *pBasDir,const char *pPass, uint32 uid); [DllImport("zmotion.dll", EntryPoint = "ZMC_MakeZarAndDown", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_MakeZarAndDown2(IntPtr handle, IntPtr pzpj, string pBasDir , string pPass, UInt32 uid); /************************************************************* Description: //制作单文件的二进制ZPJ文件 Input: //pBasfilename basic文件名,带路径 Output: //pzpj 项目文件缓冲 pBasDir BAS文件路径输出 Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_MakeOneFileZpj(void *pZpjBuff, char *pBasDir, const char* pBasfilename); [DllImport("zmotion.dll", EntryPoint = "ZMC_MakeOneFileZpj", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_MakeOneFileZpj(IntPtr pZpjBuff, string pBaDir, string pBasfilename); /************************************************************* Description: //ZPJ文件重新生成, 用于和上传的ZPJ比较是否修改. Input: //pZpjfilename 二进制zpj文件名,带路径 Output: // pbuffer 缓冲,缓冲长度不能小于文件长度 Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_MakeRealZpj(const char* pZpjfilename, char* pbuffer, uint32 buffsize); [DllImport("zmotion.dll", EntryPoint = "ZMC_MakeRealZpj", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_MakeRealZpj(string pZpjfilename , string pbuffer, UInt32 buffsize); /************************************************************* Description: //ZPJ文件重新生成, 用于和上传的ZPJ比较是否修改. 全部在buff里面 Input: //pBasDir basic文件的路径 pzpj 缓冲,二进制zpj文件, 同时作为输出 Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_MakeRealZpjMem(const char* pBasDir, void *pzpj); [DllImport("zmotion.dll", EntryPoint = "ZMC_MakeRealZpjMem", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_MakeRealZpjMem(string pBasDir, IntPtr pzpj); /************************************************************* Description: //制作ZLIB文件 Input: //pfilenameBas basic 文件 pfilenameZlb zlb 文件 Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_MakeZlib(const char* pfilenameBas, const char* pfilenameZlb); [DllImport("zmotion.dll", EntryPoint = "ZMC_MakeZlib", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_MakeZlib(string pfilenameBas, string pfilenameZlb); /************************************************************* Description: //获取ZLIB文件的全局描述,包括变量,SUB等 Input: //pfilenameZlb lib文件名,带路径 Output: //pbuffer 返回全局描述 Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_GetZlibGlobalDefine(const char* pfilenameZlb, char* pbuffer, uint32 buffsize); [DllImport("zmotion.dll", EntryPoint = "ZMC_GetZlibGlobalDefine", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_GetZlibGlobalDefine(string pfilenameZlb, byte[] pbuffer, UInt32 buffsize); /************************************************************* Description: //上传zpj,用于PC和控制器文件比较 Input: //卡链接handle pbuffer 接收zpj文件的缓冲 buffsize 缓冲最大长度 Output: //puifilesize 读取的zpj文件长度 Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_UpCurZpjToMem(ZMC_HANDLE handle, char* pbuffer, uint32 buffsize, uint32* puifilesize); [DllImport("zmotion.dll", EntryPoint = "ZMC_UpCurZpjToMem", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_UpCurZpjToMem(IntPtr handle, string pbufferm, UInt32 buffsize); /************************************************************* Description: //暂停 Input: //卡链接handle Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_Pause(ZMC_HANDLE handle); [DllImport("zmotion.dll", EntryPoint = "ZMC_Pause", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_Pause(IntPtr handle); /************************************************************* Description: //停止 Input: //卡链接handle Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_Stop(ZMC_HANDLE handle); [DllImport("zmotion.dll", EntryPoint = "ZMC_Stop", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_Stop(IntPtr handle); /********************************************************* 3次文件功能暂时不支持. **********************************************************/ /************************************************************* Description: //检查文件是否存在 Input: //卡链接handle 控制器上文件名,不带扩展 Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_Check3File(ZMC_HANDLE handle, const char* pfilenameinControl, uint8 *pbIfExist, uint32 *pFileSize); [DllImport("zmotion.dll", EntryPoint = "ZMC_Check3File", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_Check3File(IntPtr handle, string pfilenameinControl, ref byte pbIfExist, ref UInt32 pFileSize); /************************************************************* Description: //查找控制器上的文件, 文件名为空表示文件不不存在 Input: //卡链接handle 控制器上文件名,不带扩展 Output: // 是否存在 文件大小 Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_FindFirst3File(ZMC_HANDLE handle, char* pfilenameinControl, uint32 *pFileSize); [DllImport("zmotion.dll", EntryPoint = "ZMC_FindFirst3File", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_FindFirst3File(Int32 handle, string pfilenameinControl, ref UInt32 pFileSize); /************************************************************* Description: //查找控制器上的文件, 文件名为空表示文件不不存在 Input: //卡链接handle 控制器上文件名,不带扩展 Output: // 是否存在 文件大小 Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_FindNext3File(ZMC_HANDLE handle, char* pfilenameinControl, uint32 *pFileSize); [DllImport("zmotion.dll", EntryPoint = "ZMC_FindNext3File", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_FindNext3File(Int32 handle, string pfilenameinControl, ref UInt32 pFileSize); /************************************************************* Description: //查找控制器上的当前文件 Input: //卡链接handle 控制器上文件名,不带扩展 Output: // 是否存在 文件大小(暂时不支持) Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_GetCur3File(ZMC_HANDLE handle, char* pfilenameinControl, uint32 *pFileSize); [DllImport("zmotion.dll", EntryPoint = "ZMC_GetCur3File", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_FindNext3File(IntPtr handle, string pfilenameinControl, ref UInt32 pFileSize); /************************************************************* Description: //删除控制器上的文件 Input: //卡链接handle 控制器上文件名,不带扩展 Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_Delete3File(ZMC_HANDLE handle, const char* pfilenameinControl); [DllImport("zmotion.dll", EntryPoint = "ZMC_Delete3File", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_Delete3File(IntPtr handle, string pfilenameinControl); /************************************************************* Description: //删除控制器上的文件 Input: //卡链接handle Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_RemoveAll3Files(ZMC_HANDLE handle); [DllImport("zmotion.dll", EntryPoint = "ZMC_RemoveAll3File", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_RemoveAll3File(IntPtr handle); /************************************************************* Description: //写用户flash块, float数据 Input: //卡链接handle uiflashid flash块号 uinumes 变量个数 Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_FlashWritef(ZMC_HANDLE handle, uint16 uiflashid, uint32 uinumes, float *pfvlue); [DllImport("zmotion.dll", EntryPoint = "ZMC_FlashWrite", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_FlashWritef(IntPtr handle, UInt16 uiflashid, UInt32 uinumes, float[] pfvlue); /************************************************************* Description: //读取用户flash块, float数据 Input: //卡链接handle uiflashid flash块号 uibuffnum 缓冲变量个数 Output: // puinumesread 读取到的变量个数 Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_FlashReadf(ZMC_HANDLE handle, uint16 uiflashid, uint32 uibuffnum, float *pfvlue, uint32* puinumesread); [DllImport("zmotion.dll", EntryPoint = "ZMC_FlashReadf", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_FlashReadf(IntPtr handle, UInt16 uiflashid, UInt32 uibuffnum, float[] pfvlue, ref UInt32 puinumesread); /************************************************************* Description: //读取当前控制器的IP地址, Input: //卡链接handle Output: //sIpAddr 返回IP地址, 注意:当设置dhcp以后,设置的IP与实际的不一致。 Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_GetCurIpAddr(ZMC_HANDLE handle, char* sIpAddr); [DllImport("zmotion.dll", EntryPoint = "ZMC_GetCurIpAddr", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_GetCurIpAddr(IntPtr handle , byte[] sIpAddr); /************************************************************* Description: //读取字符串在当前控制器上的类型 Input: //卡链接handle Output: //type 类型,string_types TYPE2 当类型为数组时,代表数组的长度 pvalue 变量直接返回值 Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_GetStringType(ZMC_HANDLE handle, const char *sname, uint16 filenum, uint16* type, uint32* type2, double *pvalue); [DllImport("zmotion.dll", EntryPoint = "ZMC_GetStringType", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_GetStringType(IntPtr handle, string sname, UInt16 filenum, UInt16[] type, ref UInt32 type2,ref double pvalue); /************************************************************* Description: //读取脚本输出的信息 Input: //卡链接handle Output: // Return: //错误码 *************************************************************/ //int32 __stdcall ZMC_ReadMessage(ZMC_HANDLE handle, char * pbuff, uint32 uimax, uint32 *puiread); [DllImport("zmotion.dll", EntryPoint = "ZMC_ReadMessage", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_ReadMessage(IntPtr handle, byte[] pbuff, UInt32 uimax, ref UInt32 puiread); //uint32 __stdcall ZMC_Modbus_Set0x(ZMC_HANDLE handle, uint16 start, uint16 inum, uint8* pdata); [DllImport("zmotion.dll", EntryPoint = "ZMC_Modbus_Set0x", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_Modbus_Set0x(IntPtr handle, UInt16 start, UInt16 inum, byte[] pdata); //uint32 __stdcall ZMC_Modbus_Get0x(ZMC_HANDLE handle, uint16 start, uint16 inum, uint8* pdata); [DllImport("zmotion.dll", EntryPoint = "ZMC_Modbus_Get0x", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_Modbus_Get0x(IntPtr handle, UInt16 start, UInt16 inum, byte[] pdata); //uint32 __stdcall ZMC_Modbus_Get4x(ZMC_HANDLE handle, uint16 start, uint16 inum, uint16* pdata); [DllImport("zmotion.dll", EntryPoint = "ZMC_Modbus_Get4x", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_Modbus_Get4x(IntPtr handle, UInt16 start, UInt16 inum, UInt16[] pdata); //uint32 __stdcall ZMC_Modbus_Set4x(ZMC_HANDLE handle, uint16 start, uint16 inum, uint16* pdata); [DllImport("zmotion.dll", EntryPoint = "ZMC_Modbus_Set4x", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern Int32 ZMC_Modbus_Set4x(IntPtr handle, UInt16 start, UInt16 inum, UInt16[] pdata); } }