init
This commit is contained in:
173
device/control/acs/acscontroller.h
Normal file
173
device/control/acs/acscontroller.h
Normal file
@@ -0,0 +1,173 @@
|
||||
#ifndef ACSCONTROLLER_H
|
||||
#define ACSCONTROLLER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "ACSC.h"
|
||||
|
||||
#include <QVector>
|
||||
#include "myexception.h"
|
||||
#include <QMap>
|
||||
#include "base.h"
|
||||
|
||||
#define TIMEOUT_MOTOR_ENABLED 3000 // 使能电机超时
|
||||
#define TIMEOUT_MOTOR_DISABLE 3000 // 关闭电机使能超时
|
||||
#define MAX_CONNECT_NUM 10
|
||||
|
||||
|
||||
class ACSController:public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
~ACSController();
|
||||
ACSController();
|
||||
|
||||
void connect(char* Address, int Port);
|
||||
void disconnect();
|
||||
|
||||
// 获取连接状态
|
||||
bool getConnectState();
|
||||
|
||||
// 获取速度参数
|
||||
QVector<double> getVELParams(int axisNum);
|
||||
|
||||
double getVEL(int axisNum);
|
||||
double getACC(int axisNum);
|
||||
double getDEC(int axisNum);
|
||||
double getJERK(int axisNum);
|
||||
double getKDEC(int axisNum);
|
||||
|
||||
// 设置速度参数
|
||||
void setVEL(int axisNum,double Vel);
|
||||
void setACC(int axisNum,double Acc);
|
||||
void setDEC(int axisNum,double Dec);
|
||||
void setJERK(int axisNum,double Jerk);
|
||||
void setKDEC(int axisNum,double KDec);
|
||||
|
||||
// 设置指定轴的速度参数的便捷方法
|
||||
void setVELParams(int axisNum,double Vel);
|
||||
|
||||
void enable(int axisNum);
|
||||
void disable(int axisNum);
|
||||
void halt(int axisNum);
|
||||
|
||||
//JOG
|
||||
// 负方向
|
||||
void jogNeg(int axisNum);
|
||||
void jogNeg(int axisNum, double vel);
|
||||
// 正方向
|
||||
void jogPos(int axisNum);
|
||||
void jogPos(int axisNum,double vel);
|
||||
|
||||
//PTP
|
||||
// 绝对
|
||||
void ABSToPoint(int axisNum,double point);
|
||||
// 两个轴绝对
|
||||
void ABSToPoint(int axisNum1,double point1,int axisNum2,double point2);
|
||||
// 相对 负方向
|
||||
void RToPointNeg(int axisNum,double point);
|
||||
// 相对 正方向
|
||||
void RToPointPos(int axisNum,double point);
|
||||
|
||||
// 两个轴相对
|
||||
void RToPoint(int axisNum1,double point1,int axisNum2,double point2);
|
||||
|
||||
// 获取当前反馈位置
|
||||
double getFPOS(int AxisNum);
|
||||
void SetFPOS(int AxisNum,double fPos);
|
||||
|
||||
// 获取使能状态
|
||||
bool getEnable(int AxisNum);
|
||||
|
||||
LIMIT_STATE getAxesLimitState(int AxisNum);
|
||||
|
||||
// 获取急停状态
|
||||
bool getEmergencyStopState();
|
||||
|
||||
// 运行指定buffer
|
||||
void runBuffer(int bufferNum);
|
||||
// 暂停指定buffer代码运行
|
||||
void SuspendBuffer(int bufferNum);
|
||||
// 停止指定buffer代码运行
|
||||
void stopBuffer(int bufferNum);
|
||||
// 添加代码到指定buffer
|
||||
void appendBuffer(char* codeText,int bufferNum);
|
||||
// 清除指定buffer代码
|
||||
void clearBuffer(int bufferNum);
|
||||
// 编译指定buffer代码
|
||||
void compileBuffer(int bufferNum);
|
||||
// 清空并下载代码到指定buffer
|
||||
void loadBuffer(int bufferNum,char* program);
|
||||
// 把文件中代码加载到指定buffer
|
||||
void loadBuffersFromFile(char* fileName);
|
||||
// 暂停buffer代码运行
|
||||
void suspendBuffer(int bufferNum);
|
||||
// 上传指定buffer程序
|
||||
QByteArray uploadBuffer(int bufferNum);
|
||||
|
||||
bool getBufferRunState(int AxisNum);
|
||||
|
||||
bool getMotorState(int AxisNum);
|
||||
|
||||
|
||||
// 设置DO
|
||||
void setDO(int port,int bit,bool value);
|
||||
// 读取DO
|
||||
bool getDO(int port,int bit);
|
||||
// 读取DI
|
||||
bool getDI(int port,int bit);
|
||||
|
||||
|
||||
// 读取单个全局实数变量
|
||||
double getGlobalReal(char* realName);
|
||||
// 读取实数全局变量
|
||||
QVector<double> getGlobalReal(char* realName,int bufNum,int from1,int end1);
|
||||
// 写单个全局实数变量
|
||||
void setGlobalReal(char* realName,double value);
|
||||
// 写实数全局变量
|
||||
void setGlobalReal(char* realName,int from1,int end1,QVector<double> value);
|
||||
|
||||
void setGlobalReal(char* realName,int from1,int end1,int from2,int end2,double* value);
|
||||
|
||||
|
||||
|
||||
|
||||
// 读取单个全局整型
|
||||
int getGlobalInt(char* name);
|
||||
// 读取多个全局整型
|
||||
QVector<int> getGlobalInt(char* name,int from1,int end1);
|
||||
// 写单个全局整型
|
||||
void setGlobalInt(char* name,int value);
|
||||
// 写多个全局整型
|
||||
void setGlobalInt(char* name,int from1,int end1,QVector<int> value);
|
||||
|
||||
|
||||
// 读取指定buffer代码总行数
|
||||
int getBufferLines(int bufferNum);
|
||||
// EtherCAT 输入变量和变量映射
|
||||
void mapEtherCatInput(int offset,QString vbName);
|
||||
// EtherCAT 输出变量和变量映射
|
||||
void mapEtherCatOutput(int offset,QString vbName);
|
||||
// 重置EthCat映射
|
||||
void resetMapEtherCatInputOutput();
|
||||
// 禁用补偿
|
||||
void disableComp(int axisNum);
|
||||
|
||||
int getProgramError(int bufferNum);
|
||||
|
||||
int getMotorError(int AxisNum);
|
||||
|
||||
bool getMoveState(int AxisNum);
|
||||
|
||||
private:
|
||||
void terminatePrevConnect();
|
||||
double getAxesMST(int AxisNum);
|
||||
|
||||
private:
|
||||
/* void* m_hComm = (void*) -1;
|
||||
* m_hComm 中用于存放地址的空间存放了-1
|
||||
*/
|
||||
HANDLE m_hComm= HANDLE(-1);
|
||||
};
|
||||
|
||||
#endif // ACSCONTROLLER_H
|
||||
Reference in New Issue
Block a user