完善了像马达发送命令的函数 修改了控制函数为带有默认参数的函数 区分单个马达和多个马达 等等
This commit is contained in:
@ -35,13 +35,28 @@
|
||||
#ifndef VINCECONTROL_H
|
||||
#define VINCECONTROL_H
|
||||
|
||||
#ifdef VINCECONTROL_LIB
|
||||
# define VINCECONTROL_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define VINCECONTROL_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
#define LOGOUT
|
||||
|
||||
#include "vincecontrol_global.h"
|
||||
#include "QString"
|
||||
#include "QStringList"
|
||||
#include "QList"
|
||||
#include <QObject>
|
||||
#include <QSerialPort>
|
||||
#include <QTcpServer> //监听套接字
|
||||
#include <QTcpSocket> //通信套接字
|
||||
#include "QByteArray"
|
||||
|
||||
enum ProTools
|
||||
{
|
||||
RS232 = 0,
|
||||
RS485 = 1
|
||||
RS485 = 1,
|
||||
NETTCP=2
|
||||
};
|
||||
/********************************************************************
|
||||
* 描述:马达控制程序
|
||||
@ -52,8 +67,10 @@ RS485 = 1
|
||||
* 4)使用
|
||||
* 2020-8-5:立新
|
||||
*******************************************************************/
|
||||
class VINCECONTROL_EXPORT VinceControl
|
||||
class VINCECONTROL_EXPORT VinceControl:public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//************************************
|
||||
// Method: VinceControl
|
||||
@ -64,6 +81,16 @@ public:
|
||||
// Parameter: ProTools 通讯协议 RS485 或者 RS232
|
||||
//************************************
|
||||
VinceControl(ProTools proto);
|
||||
//************************************
|
||||
// Method: VinceControl //走网络协议 需要两个参数 第一个为NETTCP 第二个为端口 6000或者6001
|
||||
// FullName: VinceControl::VinceControl
|
||||
// Access: public
|
||||
// Returns:
|
||||
// Qualifier:
|
||||
// Parameter: ProTools proto
|
||||
// Parameter: int port
|
||||
//************************************
|
||||
VinceControl(ProTools proto,int port);
|
||||
~VinceControl();
|
||||
//************************************
|
||||
// Method: serialconnect
|
||||
@ -74,8 +101,19 @@ public:
|
||||
// Parameter: QString comname 串口名称
|
||||
// Parameter: QString bandrate 串口波特率
|
||||
//************************************
|
||||
|
||||
bool serialconnect(QString comname,QString bandrate);
|
||||
//************************************
|
||||
// Method: Handshacke
|
||||
// FullName: VinceControl::Handshacke
|
||||
// Access: public
|
||||
// Returns: void
|
||||
// Qualifier:
|
||||
//************************************
|
||||
|
||||
|
||||
void Handshacke(QString motorid = "non");
|
||||
//************************************
|
||||
// Method: SetRS485ID
|
||||
// FullName: VinceControl::SetRS485ID
|
||||
// Access: public
|
||||
@ -91,7 +129,7 @@ public:
|
||||
// Returns: void
|
||||
// Qualifier:
|
||||
//************************************
|
||||
void EnableMotro();
|
||||
void EnableMotro(QString motornetid="non");
|
||||
//************************************
|
||||
// Method: 取消使能
|
||||
// FullName: VinceControl::DisableMotro
|
||||
@ -99,16 +137,27 @@ public:
|
||||
// Returns: void
|
||||
// Qualifier:
|
||||
//************************************
|
||||
void DisableMotro();
|
||||
void DisableMotro(QString motornetid = "non");
|
||||
//************************************
|
||||
// Method: SendCommandtoSerial
|
||||
// FullName: VinceControl::SendCommandtoSerial
|
||||
// Access: public
|
||||
// Returns: void
|
||||
// Qualifier:
|
||||
// Parameter: QString str 命令 不包含id
|
||||
// Parameter: QString str 命令 不包含id 如果是nettcp 默认想第一个发送
|
||||
//************************************
|
||||
void SendCommandtoSerial(QString str);
|
||||
void SendCommandtoMotor(QString str);
|
||||
|
||||
//************************************
|
||||
// Method: SendCommandtoMotor //两个参数 仅网络协议 第一个为命令 第二个为马达
|
||||
// FullName: VinceControl::SendCommandtoMotor
|
||||
// Access: public
|
||||
// Returns: void
|
||||
// Qualifier:
|
||||
// Parameter: QString str
|
||||
// Parameter: int motorid
|
||||
//************************************
|
||||
void SendCommandtoMotor(QString str,QString modor);
|
||||
//************************************
|
||||
// Method: MoveSetDistance 电机左移/右移 一定数量(不是距离)
|
||||
// FullName: VinceControl::MoveSetDistance
|
||||
@ -117,7 +166,8 @@ public:
|
||||
// Qualifier:
|
||||
// Parameter: long distance
|
||||
//************************************
|
||||
void MoveSetDistance(long distance);
|
||||
|
||||
void MoveSetDistance(long distance, QString motornetid = "non");
|
||||
//************************************
|
||||
// Method: MoveModar 电机左移/右移 direction是方向
|
||||
// FullName: VinceControl::MoveModar
|
||||
@ -126,16 +176,17 @@ public:
|
||||
// Qualifier:
|
||||
// Parameter: bool direction 方向
|
||||
//************************************
|
||||
void MoveMotar(bool direction);
|
||||
void MoveMotar(bool direction, QString motornetid = "non");
|
||||
//************************************
|
||||
// Method: SettingSpeed 设置速度
|
||||
// FullName: VinceControl::SettingSpeed
|
||||
// Access: public
|
||||
// Returns: void
|
||||
// Qualifier:
|
||||
// Parameter: unsigned long Speed 速度 无方向
|
||||
// Parameter: unsigned long Speed 速度 正值 无方向
|
||||
//************************************
|
||||
void SettingSpeed(unsigned long Speed);
|
||||
void SettingSpeed(unsigned long Speed, QString motornetid = "non");
|
||||
|
||||
//************************************
|
||||
// Method: MovetoZero 归零
|
||||
// FullName: VinceControl::MovetoZero
|
||||
@ -143,7 +194,7 @@ public:
|
||||
// Returns: void
|
||||
// Qualifier:
|
||||
//************************************
|
||||
void MovetoZero();
|
||||
void MovetoZero(QString motornetid = "non");
|
||||
//************************************
|
||||
// Method: GetLocationNow 获取当前至0点位置
|
||||
// FullName: VinceControl::GetLocationNow
|
||||
@ -171,6 +222,17 @@ public:
|
||||
// Parameter: int downspeed 减速度
|
||||
//************************************
|
||||
void SettingUpandDownSpeed(int addspeed, int downspeed);
|
||||
|
||||
void StopMotormove(QString motornetid = "non");
|
||||
|
||||
|
||||
QStringList Motorlist;
|
||||
signals:
|
||||
void SendLogToCallClass(QString str);
|
||||
public slots :
|
||||
void onNewTcpClinetConnet();
|
||||
void onReciveFromClinet();
|
||||
void onClinetDisConnet();
|
||||
private:
|
||||
QSerialPort *serial;
|
||||
|
||||
@ -178,6 +240,15 @@ private:
|
||||
ProTools protools;
|
||||
QString RS485ID;
|
||||
unsigned long speed;
|
||||
QTcpServer *tcpServer; //定义监听套接字tcpServer
|
||||
QList<QTcpSocket *>tcpSocket; //定义通信套接字tcpSocke
|
||||
void SendLog(QString str);
|
||||
QList<bool> isSettingSpeedlist;
|
||||
QList<int> Speedlist;
|
||||
bool SpeedisSet;
|
||||
int Speednow;
|
||||
//
|
||||
void SettingSpeedByThis(long Speed, QString motornetid = "non");
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user