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.

82 lines
2.9 KiB
C++

#pragma once
#ifndef _INCLUDE_CARDSRV_GUGAO_H
#define _INCLUDE_CARDSRV_GUGAO_H
#include "sysapi.h"
#include "dtype.h"
#define MAXCARD 8 //最多8张卡
#define MAXCRD 2 //每张卡最多2个坐标系
#define MAXAXIS 8
#define MAXIO 16
#define MAXAD 8
#define ins CardService::GetInstance()
class CCard;
class CardService
{
public:
CardService(void);
~CardService(void);
static CardService* GetInstance();
static void ReleaseInstance();
int Init() { return 0; }
int OpenCard(ushort cardIndex);
int CloseCard(ushort cardIndex);
int GetStatus(ushort cardIndex);
//单轴点位运动
int AxisReset(ushort cardIndex, ushort axisIndex);
int AxisZeroPos(ushort cardIndex, ushort axisIndex); //单轴清零位置
int AxisIsMoving(ushort cardIndex, ushort axisIndex); //1运动中 0就绪
int AxisStop(ushort cardIndex, ushort axisIndex, int stopType);
int AxisSetSpeed(ushort cardIndex, ushort axisIndex, double vel);
//获取当前位置
int AxisGetPos(ushort cardIndex, ushort axisIndex, EMPosType postype, double* pval);
//设置目标位置并运动
int AxisSetPos(ushort cardIndex, ushort axisIndex, long pos);
//dir 0 负方向 1 正方向
int AxisMoveJog(ushort cardIndex, ushort axisIndex, int dir, double vel, double acc, double dec);
int AxisMovePos(ushort cardIndex, ushort axisIndex, long pos, double vel, double acc, double dec);
int AxisHome(ushort cardIndex, ushort axisIndex, ushort homeType, long pos, long offset, double vel);
int AxisMoveOffset(ushort cardIndex, ushort axisIndex, long offset, double vel, double acc, double dec);
//IO操作
int ReadBit(ushort cardIndex, ushort in_index, short di_type);
int ReadOutBit(ushort cardIndex, ushort out_index, short do_type);
int WriteOutBit(ushort cardIndex, ushort out_index, ushort val, short do_type);
//AD接口
int ReadAdc(ushort cardIndex, ushort index, double* pVal);
int WriteAdc(ushort cardIndex, ushort index, double Val);
//插补运动
int CreateCrd(ushort cardIndex, ushort *pAxisIndex, ushort axisCnt);
int CloseCrd(int crdID);
int AddLinePos(int crdID, double *ppos, ushort nsize, double vel, double acc, double endvel);
int AddArcPos(int crdID, double *ppos1, double *ppos2, double *ppos3, ushort nsize, double vel, double acc, double endvel);
int CrdStartMove(int crdID);
int CrdStatus(int crdID, int *progress);
//命令行 接口
int SendCustomCommand(ushort cardIndex, const char* cmd, char* lpMsg);
int RecvCustomCommand(ushort cardIndex, const char* msg, char* res, int timeout);
int GetCommandDesc(char* pszcmddesc);
protected:
//从crdID转化成index
int ConvertcrdIndex(ushort& cardIndex, int crd) { cardIndex = (ushort)crd / MAXCRD; return crd % MAXCRD; }
private:
static CardService *m_pInstance;
CCard* m_pCard[MAXCARD]; //控制卡
};
#endif //防止重复包含