122 lines
3.8 KiB
C++
122 lines
3.8 KiB
C++
/******************************************************
|
||
* 文件名 : vincecontrol.h
|
||
* 类名 :
|
||
* 作用 :马达控制程序
|
||
* 作者 : xin
|
||
* 邮箱 : renlixin@iris-rs.cn
|
||
* 日期 : 2020-8-5
|
||
********************************************************
|
||
* *
|
||
* _ooOoo_ *
|
||
* o8888888o *
|
||
* 88" . "88 *
|
||
* (| -_- |) *
|
||
* O\ = /O *
|
||
* ____/`---'\____ *
|
||
* .' \\| |// `. *
|
||
* / \\||| : |||// \ *
|
||
* / _||||| -:- |||||- \ *
|
||
* | | \\\ - /// | | *
|
||
* | \_| ''\---/'' | | *
|
||
* \ .-\__ `-` ___/-. / *
|
||
* ___`. .' /--.--\ `. . __ *
|
||
* ."" '< `.___\_<|>_/___.' >'"". *
|
||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||
* \ \ `-. \_ __\ /__ _/ .-` / / *
|
||
* ======`-.____`-.___\_____/___.-`____.-'====== *
|
||
* `=---=' *
|
||
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ *
|
||
* 佛祖保佑 长发永存 *
|
||
* *
|
||
********************************************************/
|
||
|
||
|
||
|
||
#ifndef VINCECONTROL_H
|
||
#define VINCECONTROL_H
|
||
|
||
#include "vincecontrol_global.h"
|
||
#include "QString"
|
||
#include <QSerialPort>
|
||
enum ProTools
|
||
{
|
||
RS232 = 0,
|
||
RS485 = 1
|
||
};
|
||
/********************************************************************
|
||
* 描述:马达控制程序
|
||
* 使用步骤
|
||
* 1)初始话 需要告诉通讯协议(Vince规定的):
|
||
* 2)如果是485 请设置id 默认为0
|
||
* 3) serialconnect 建立链接
|
||
* 4)使用
|
||
* 2020-8-5:立新
|
||
*******************************************************************/
|
||
class VINCECONTROL_EXPORT VinceControl
|
||
{
|
||
public:
|
||
//************************************
|
||
// Method: VinceControl
|
||
// FullName: VinceControl::VinceControl
|
||
// Access: public
|
||
// Returns:
|
||
// Qualifier:
|
||
// Parameter: ProTools 通讯协议 RS485 或者 RS232
|
||
//************************************
|
||
VinceControl(ProTools proto);
|
||
~VinceControl();
|
||
//************************************
|
||
// Method: serialconnect
|
||
// FullName: VinceControl::serialconnect
|
||
// Access: public
|
||
// Returns: bool
|
||
// Qualifier:
|
||
// Parameter: QString comname 串口名称
|
||
// Parameter: QString bandrate 串口波特率
|
||
//************************************
|
||
bool serialconnect(QString comname,QString bandrate);
|
||
//************************************
|
||
// Method: SetRS485ID
|
||
// FullName: VinceControl::SetRS485ID
|
||
// Access: public
|
||
// Returns: void
|
||
// Qualifier:
|
||
// Parameter: QString id RS485 id
|
||
//************************************
|
||
void SetRS485ID(QString id);
|
||
//************************************
|
||
// Method: 电机使能
|
||
// FullName: VinceControl::EnableMotro
|
||
// Access: public
|
||
// Returns: void
|
||
// Qualifier:
|
||
//************************************
|
||
void EnableMotro();
|
||
//************************************
|
||
// Method: 取消使能
|
||
// FullName: VinceControl::DisableMotro
|
||
// Access: public
|
||
// Returns: void
|
||
// Qualifier:
|
||
//************************************
|
||
void DisableMotro();
|
||
//************************************
|
||
// Method: SendCommandtoSerial
|
||
// FullName: VinceControl::SendCommandtoSerial
|
||
// Access: public
|
||
// Returns: void
|
||
// Qualifier:
|
||
// Parameter: QString str 命令 不包含id
|
||
//************************************
|
||
void SendCommandtoSerial(QString str);
|
||
private:
|
||
QSerialPort *serial;
|
||
|
||
bool IsMotorInit;
|
||
ProTools protools;
|
||
QString RS485ID;
|
||
|
||
};
|
||
|
||
#endif // VINCECONTROL_H
|