ACS系列(6) ACS QT版SPiiPlusClibraryDemo
  k4eu5fcIGZiP 2023年11月02日 67 0
Qt
  1. 工程文件
QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++17

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    main.cpp \
    widget.cpp

HEADERS += \
    widget.h

FORMS += \
    widget.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

RESOURCES += \
    spiipldemo.qrc

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/SDK/ -lACSCL_x64

INCLUDEPATH += $$PWD/SDK
DEPENDPATH += $$PWD/SDK

LIBS +=-L$$PWD/SDK -lACSCL_x64

win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/SDK/ACSCL_x64.lib
  1. 主程序
#include "widget.h"

#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;
    w.show();
    return a.exec();
}
  1. 窗体程序
#ifndef WIDGET_H
#define WIDGET_H

#include "SDK/ACSC.h"
#include <QWidget>
#include <QTimer>

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

const int MAX_AXIS_COUNT = 128;
const int MAX_BUFF_COUNT = 64;
const int UPDATE_TIMER_INTERVAL = 500;
const int GPIO_PORT_NO = 0;
const int MAX_GPIO_COUNT = 8;
const int TIMEOUT_MOTOR_ENABLED = 3000;
const int TIMEOUT_MOTOR_DISABLE	= 3000;

static int g_nTotalAxes, g_nTotalBuffer;

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

private slots:
    void on_pushButtonConnect_clicked();

    void on_pushButtonDisconnect_clicked();

    void on_pushButtonEnable_clicked();

    void on_pushButtonDisable_clicked();

    void on_pushButtonDisableAll_clicked();

    void on_pushButtonBuffStart_clicked();

    void on_pushButtonBuffStop_clicked();

    void on_pushButtonSetZeroAPOS_clicked();

    void on_pushButtonStop_clicked();

    void on_pushButtonStopAll_clicked();

    void on_pushButtonMoveToPosition_clicked();

    void on_pushButtonMoveDec_clicked();

    void on_pushButtonMoveInc_clicked();

    void on_pushButtonNegtive_clicked();

    void on_pushButtonPositive_clicked();

    void on_pushButtonMotinEnd_clicked();

    void on_pushButtonProgramEnd_clicked();

    void on_pushButtonInput_clicked();

    void on_pushButtonSend_clicked();

    void slotClickedBtnGroup();

public slots:
    void timerOut();

private:
    Ui::Widget *ui;

    int		m_nConnectType;
    HANDLE m_hAcsComm;				// ACS Communication handle
    BOOL m_bConnected;

    int m_nSelectedAxisNo;

    double m_RPosition[MAX_AXIS_COUNT];		// Reference Position
    double m_FPosition[MAX_AXIS_COUNT];		// Feedback Position
    double m_FVelocity[MAX_AXIS_COUNT];		// Feedback Velocity
    double m_PositionErr[MAX_AXIS_COUNT];	// Position Error
    int    m_MotorStatus[MAX_AXIS_COUNT];	// Motor Status
    int    m_MotorError[MAX_AXIS_COUNT];	// Motor Error

    int m_nTimerID;
    QTimer* m_Timer;

    void initImageLabel();
    void initRadioButton();

    void terminatePrevConnect();
    void updateParameters(int nAxisIndex);
};
#endif // WIDGET_H
#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
    ,m_nSelectedAxisNo(0)
{
    ui->setupUi(this);

    initImageLabel();
    initRadioButton();

    m_Timer = new QTimer(this);
    m_Timer->start(UPDATE_TIMER_INTERVAL);
    connect(m_Timer,&QTimer::timeout, this, &Widget::timerOut);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::initRadioButton()
{
    ui->buttonGroup->addButton(ui->radioButtonSimulator,0);
    ui->buttonGroup->addButton(ui->radioButtonTcpIp ,1);
    connect(ui->radioButtonSimulator, SIGNAL(clicked()), this,SLOT(slotClickedBtnGroup()));
    connect(ui->radioButtonTcpIp, SIGNAL(clicked()), this,SLOT(slotClickedBtnGroup()));
}

void Widget::initImageLabel()
{
    QString filename(":/images/Images/Off.bmp");
    QImage* img=new QImage;
    img->load(filename);

    ui->lbl_sys_left0->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_sys_left1->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_sys_left2->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_sys_left3->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_sys_left4->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_sys_left5->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_sys_left6->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_sys_left7->setPixmap(QPixmap::fromImage(*img));

    ui->lbl_sys_right0->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_sys_right1->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_sys_right2->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_sys_right3->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_sys_right4->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_sys_right5->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_sys_right6->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_sys_right7->setPixmap(QPixmap::fromImage(*img));

    ui->lbl_sys_emergency->setPixmap(QPixmap::fromImage(*img));

    ui->lbl_gen_input0->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_gen_input1->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_gen_input2->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_gen_input3->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_gen_input4->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_gen_input5->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_gen_input6->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_gen_input7->setPixmap(QPixmap::fromImage(*img));

    ui->lbl_gen_output0->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_gen_output1->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_gen_output2->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_gen_output3->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_gen_output4->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_gen_output5->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_gen_output6->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_gen_output7->setPixmap(QPixmap::fromImage(*img));

    ui->lbl_motorStatus_moving->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_motorStatus_acceleration->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_motorStatus_inPosition->setPixmap(QPixmap::fromImage(*img));
    ui->lbl_motorStatus_enabled->setPixmap(QPixmap::fromImage(*img));

    delete img;
}

void Widget::on_pushButtonConnect_clicked()
{
    double SysInfo = 0.0;

    terminatePrevConnect();
    switch(m_nConnectType)
    {
    // Simulation Mode
    case 0:
        m_hAcsComm = acsc_OpenCommSimulator();
        break;

        // Ethernet
    case 1:
        // Connect to the controller via TCP socket
        int port = ui->lineEditPort->text().toInt() == 0 ? ACSC_SOCKET_STREAM_PORT:ui->lineEditPort->text().toInt();
        m_hAcsComm = acsc_OpenCommEthernetTCP((char*)ui->lineEditIpAddr->text().toLatin1().data(), port);

        // UDP Socket (ACS is supporting only 1 UDP channel)
        //m_hAcsComm = acsc_OpenCommEthernetUDP((char*)LPCTSTR(m_strIPAddress), ACSC_SOCKET_DGRAM_PORT);
        break;
    }

    // After connecting, if you got an invalid handle
    if(m_hAcsComm == ACSC_INVALID)
    {
        qDebug() << "Connection Error";
        return;
    }

    qDebug() << "Open Connection Successfully";

    // Get maximum number of axes
    SysInfo = 0.0;
    acsc_SysInfo(m_hAcsComm, 13, &SysInfo, NULL);
    g_nTotalAxes = (int)SysInfo;

    for(int i=0; i< g_nTotalAxes; i++)
    {
        ui->comboBoxAxis->addItem(QString::number(i));
    }
    ui->comboBoxAxis->setCurrentIndex(0);

    m_nSelectedAxisNo = 0;

    // Get total number of buffers
    SysInfo = 0.0;
    acsc_SysInfo(m_hAcsComm, 10, &SysInfo, NULL);
    g_nTotalBuffer = (int)SysInfo;

    for(int i=0; i< g_nTotalBuffer; i++)
    {
        ui->comboBoxBuffer->addItem(QString::number(i));
    }
    ui->comboBoxBuffer->setCurrentIndex(0);

    updateParameters(0);

    m_Timer->start(UPDATE_TIMER_INTERVAL);
}

void Widget::updateParameters(int nAxisIndex)
{
    double Vel, Acc, Dec, Jerk, KDec; // , FPos, RPos, FVel, PE;

    //==================================================================================
    // Velocity
    //==================================================================================
    if(acsc_GetVelocity(m_hAcsComm, nAxisIndex, &Vel, NULL))
    {
        QString strVelocity = QString::number(Vel,'f',4);
        ui->lineEditVeloccity->setText(strVelocity);
    }
    else
    {
        qDebug() << "Get Velocity Error";
    }

    //==================================================================================
    // Acceleration
    //==================================================================================
    if(acsc_GetAcceleration(m_hAcsComm, nAxisIndex, &Acc, NULL))
    {
        QString strAcc = QString::number(Acc,'f',4);
        ui->lineEditAcceleration->setText(strAcc);
    }
    else
    {
        qDebug() << "Get Acceleration Error";
    }


    //==================================================================================
    // Deceleration
    //==================================================================================
    if(acsc_GetDeceleration(m_hAcsComm, nAxisIndex, &Dec, NULL))
    {
        QString strDec = QString::number(Dec,'f',4);
        ui->lineEditDeceleration->setText(strDec);
    }
    else
    {
        qDebug() << "Get Deceleration Error";
    }

    //==================================================================================
    // Kill Deceleration
    //==================================================================================
    if(acsc_GetKillDeceleration(m_hAcsComm, nAxisIndex, &KDec, NULL))
    {
        QString strKillDec = QString::number(KDec,'f',4);
        ui->lineEditKillDeceleration->setText(strKillDec);
    }
    else
    {
        qDebug() << "Get Kill Deceleration Error";
    }

    //==================================================================================
    // Jerk
    //==================================================================================
    if(acsc_GetJerk(m_hAcsComm, nAxisIndex, &Jerk, NULL))
    {
        QString strJerk = QString::number(Jerk,'f',4);
        ui->lineEditJerk->setText(strJerk);
    }
    else
    {
        qDebug() << "Get Jerk Erorr";
    }
}

void Widget::slotClickedBtnGroup()
{
    switch(ui->buttonGroup->checkedId())
    {
    case 0:
        m_nConnectType = 0;
        qDebug() << QString::fromLocal8Bit("Simulator");
        break;
    case 1:
        m_nConnectType = 1;
        qDebug() << QString::fromLocal8Bit("Tcp/IP");
        break;
    }
}

void Widget::terminatePrevConnect()
{
    char tmpSeperator[2] = "\\";
    char *pSeperator = &tmpSeperator[0];
    char *pToken = NULL;
    char pApplicationName[256] = { 0x00, };

    int nConnections;
    ACSC_CONNECTION_DESC ConnectionList[10];

    if(!acsc_GetConnectionsList(ConnectionList, 10, &nConnections)) printf("Error %d\n", acsc_GetLastError());

    for (int i = 0; i < nConnections; i++)
    {
        // Sperate names (if the application name is "USERNAME\ACS.Fremwork.exe" in UMD list, you need to seprate it.)
        pToken = strtok(ConnectionList[i].Application, pSeperator);
        sprintf(pApplicationName, pToken);
        while (pToken)
        {
            pToken = strtok(NULL, pSeperator);	// Find next
            if(pToken != NULL)
            {
                sprintf(pApplicationName, pToken);
            }
        }

        // Clear connection without MMI application studio
        if((strcmp(pApplicationName, "ACS.Framework.exe")) != 0)
        {
            // Terminate connection from UDM
            if(!acsc_TerminateConnection(&(ConnectionList[i])))
            {
                printf("Error closing communication of %s application: %d\n", ConnectionList[i].Application, acsc_GetLastError());
            }
            else
            {
                printf("Communication of %s application is successfully closed!\n", ConnectionList[i].Application);
            }
        }
    }
}

void Widget::timerOut()
{
    QString strTemp;
    std::string strCmd;

    if(m_bConnected == FALSE) return;

    //==================================================================================
    // Read Feedback(FPOS), Reference position(RPOS), Feedback velocity(FVEL), Motor status(MST)
    //==================================================================================
    // Instruction 1. User libarary functions - acsc_GetFPosition, acsc_GetRPosition, ....
    // Instruction 2. Read ACS variable - Already defined almost things (FPOS, RPOS, ...)
    //                Motion parameters and state is array (Max length is total number of axes)
    //
    // * Library function can read only 1 axis information, so if you want to read several axes, you have to call the function many times.
    //   (This may cause communication dealy.)
    //   Recommand (if you want to read many axes) : read/write variable using acsc_ReadInteger, acsc_ReadReal, acsc_WriteInteger, acsc_WriteReal...

    // Feedback Position
    // ACSPL+ Variable : FPOS, C-Lib : acsc_GetFPosition()
    // - Read feedback position of total axes at once
    strCmd = "FPOS";
    acsc_ReadReal(m_hAcsComm, -1, &strCmd[0], 0, g_nTotalAxes - 1, -1, -1, m_FPosition, NULL);
    // If you are using the get function,
    // acsc_GetFPosition(m_hAcsComm, 0, &m_FPosition[0], NULL);
    // acsc_GetFPosition(m_hAcsComm, 1, &m_FPosition[1], NULL);
    // acsc_GetFPosition(m_hAcsComm, 2, &m_FPosition[2], NULL);
    // acsc_GetFPosition(m_hAcsComm, 3, &m_FPosition[3], NULL);
    // ...

    // Reference Position
    // ACSPL+ Variable : RPOS, C-Lib : acsc_GetRPosition()
    strCmd = "RPOS";
    acsc_ReadReal(m_hAcsComm, -1, &strCmd[0], 0, g_nTotalAxes - 1, -1, -1, m_RPosition, NULL);

    // Feedback Velocity
    // ACSPL+ Variable : FVEL, C-Lib : acsc_GetFVelocity()
    strCmd = "FVEL";
    acsc_ReadReal(m_hAcsComm, -1, &strCmd[0], 0, g_nTotalAxes - 1, -1, -1, m_FVelocity, NULL);

    // Position Error
    // ACSPL+ Variable : PE, C-Lib : there is no function
    strCmd = "PE";
    acsc_ReadReal(m_hAcsComm, -1, &strCmd[0],   0, g_nTotalAxes - 1, -1, -1, m_PositionErr, NULL);

    // Motor State
    // ACSPL+ : MST, C-Lib : acsc_GetMotorState()
    // Return value is integer, you have to use bitmask
    //
    // if (m_MotorStatus[0] & ACSC_MST_MOVE )
    // {
    //     Moving state
    // }
    // else
    // {
    //     Stand.. (in position)
    // }
    strCmd = "MST";
    acsc_ReadInteger(m_hAcsComm, -1, &strCmd[0],  0, g_nTotalAxes -1, -1, -1, m_MotorStatus, NULL);

    // Motor Error Code
    // ACSPL+ : MERR, C-Lib : acsc_GetMotorError()
    strCmd = "MERR";
    acsc_ReadInteger(m_hAcsComm, -1, &strCmd[0], 0, g_nTotalAxes -1, -1, -1, m_MotorError, NULL);

    //==================================================================================
    // Update dialog : Reference, Feedback position, Feedback velocity, Position Error
    //==================================================================================
    strTemp = QString::number(m_RPosition[m_nSelectedAxisNo] , 'f' ,4);
    ui->lineEditRPOS->setText(strTemp);

    strTemp = QString::number(m_FPosition[m_nSelectedAxisNo] , 'f' ,4);
    ui->lineEditApos->setText(strTemp);

    strTemp = QString::number(m_FVelocity[m_nSelectedAxisNo] , 'f' ,4);
    ui->lineEditAVelocity->setText(strTemp);

    strTemp = QString::number(m_PositionErr[m_nSelectedAxisNo] , 'f' ,4);
    ui->lineEditPositionError->setText(strTemp);

//    //==================================================================================
//    // Update dialog : Motor Status
//    //==================================================================================
//    if(m_MotorStatus[m_nSelectedAxisNo] & ACSC_MST_ENABLE) m_picEnable.SetBitmap(BITMAP_ON);
//    else m_picEnable.SetBitmap(BITMAP_OFF);

//    if(m_MotorStatus[m_nSelectedAxisNo] & ACSC_MST_MOVE) m_picMove.SetBitmap(BITMAP_ON);
//    else m_picMove.SetBitmap(BITMAP_OFF);

//    if(m_MotorStatus[m_nSelectedAxisNo] & ACSC_MST_ACC) m_picAcc.SetBitmap(BITMAP_ON);
//    else m_picAcc.SetBitmap(BITMAP_OFF);

//    if(m_MotorStatus[m_nSelectedAxisNo] & ACSC_MST_INPOS) m_picInpos.SetBitmap(BITMAP_ON);
//    else m_picInpos.SetBitmap(BITMAP_OFF);
//    //==================================================================================
//    // Read General Input 8 bits, Output 8 bits at once (ACSPL Variable : IN(0), OUT(0))
//    //==================================================================================
//    acsc_GetInputPort(m_hAcsComm,  GPIO_PORT_NO, &m_GeneralInput,  NULL);
//    acsc_GetOutputPort(m_hAcsComm, GPIO_PORT_NO, &m_GeneralOutput, NULL);
//    UpdateGeneralIO();

//    //==================================================================================
//    // Left, Right Limit state
//    //  - ACSPL Variable : FAULT(MAX_AXIS_COUNT)
//    //  - acsc_GetFault : this function is reading fault informaton one by one
//    //  - if you are using acsc_ReadInteger function, you can read all informations at once
//    //==================================================================================
//    for(int iAxis = 0; iAxis < g_nTotalAxes; iAxis++)
//    {
//        acsc_GetFaultMask(m_hAcsComm, iAxis, &m_FaultMask, NULL);
//        acsc_GetFault(m_hAcsComm, iAxis, &m_MotorFault, NULL);

//        UpdateRightLimit(iAxis);
//        UpdateLeftLimit(iAxis);
//    }
//    // acsc_ReadInteger(m_hAcsComm, "FAULT", 0, g_nTotalAxes - 1, -1, -1, FaultArray, NULL);

//    //==================================================================================
//    // For updating Emergency Stop state (from System fault)
//    //  - ACSPL variable : S_FAULT
//    //   1. acsc_GetFault : Axis number is -1 (ACSC_NONE)
//    //   2. acsc_ReadInteger : ACS Variable  'S_FAULT', range 0 to 0
//    //==================================================================================
//    acsc_GetFaultMask(m_hAcsComm, ACSC_NONE, &m_EmergencyMask, NULL);
//    acsc_GetFault(m_hAcsComm, ACSC_NONE, &m_EmergencyFault, NULL);
//    UpdateEmergency();
}

void Widget::on_pushButtonDisconnect_clicked()
{
    m_Timer->stop();

    if(m_hAcsComm != ACSC_INVALID)
    {
        if(acsc_CloseComm(m_hAcsComm))
        {
            m_hAcsComm = ACSC_INVALID;
            m_bConnected = FALSE;

            qDebug() << "Close connection!!";
        }
    }
}

void Widget::on_pushButtonEnable_clicked()
{
    int Error;
    char ErrorStr[256];
    char MsgsStr[256];
    int Received;
    // Axis Enable command
    if (!acsc_Enable(m_hAcsComm, m_nSelectedAxisNo, NULL))
    {
        qDebug() << "Axis enable error";
    }
    // Waiting until enabled
    if (!acsc_WaitMotorEnabled(m_hAcsComm, m_nSelectedAxisNo, 1, TIMEOUT_MOTOR_ENABLED))

    if (acsc_GetMotorError(m_hAcsComm, m_nSelectedAxisNo, &Error, NULL))
    {
        if (Error > 0)
        {
            if (acsc_GetErrorString(m_hAcsComm, Error, ErrorStr, 255, &Received))
            {
                ErrorStr[Received] = '\0';
                sprintf_s(MsgsStr, "Error = % d ,%s", Error, ErrorStr);
                qDebug() << MsgsStr;
                return;
            }
        }

    }
    else
    {
        qDebug() << "Axis enable error";
    }

    // If you want to enable several axes..
    // Ex) eanble (0, 1, 5, 7)
    // int AxisList[] = { 0, 1, 5, 7, -1 };		!! You must set '-1' at the last of array.
    // acsc_EnableM(m_hAcsComm, AxisList, NULL);
}


void Widget::on_pushButtonDisable_clicked()
{
    // Axis disable command
    if(!acsc_Disable(m_hAcsComm, m_nSelectedAxisNo, NULL))
    {
        qDebug() << "Axis disable error";
    }
    // Waiting until disabled
    if(!acsc_WaitMotorEnabled(m_hAcsComm, m_nSelectedAxisNo, 0, TIMEOUT_MOTOR_ENABLED))
    {
        qDebug() << "Axis enable error";
    }

    // If you want to disable several axes..
    // Ex) disable (0, 1, 5, 7)
    // int AxisList[] = { 0, 1, 5, 7, -1 };		!! You must set '-1' at the last of array.
    // acsc_DisableM(m_hAcsComm, AxisList, NULL);
}


void Widget::on_pushButtonDisableAll_clicked()
{
    if(!acsc_DisableAll(m_hAcsComm, NULL))
    {
        qDebug() << "All axes disable error";
    }
}


void Widget::on_pushButtonBuffStart_clicked()
{

}


void Widget::on_pushButtonBuffStop_clicked()
{

}


void Widget::on_pushButtonSetZeroAPOS_clicked()
{
    if(!acsc_SetFPosition(m_hAcsComm, m_nSelectedAxisNo, 0, NULL))
    {
        qDebug() << "Set Feedback Position error";
    }
}


void Widget::on_pushButtonStop_clicked()
{
    if(!acsc_Halt(m_hAcsComm, m_nSelectedAxisNo, NULL))
    {
        qDebug() << "Halt command error";
    }
}


void Widget::on_pushButtonStopAll_clicked()
{
    int Axes[MAX_AXIS_COUNT + 1];
    for (int i = 0; i < g_nTotalAxes; i++)
    {
        // Set all axes
        Axes[i] = i;
    }
    // Add '-1' at the last of array
    Axes[g_nTotalAxes] = -1;

    if(!acsc_HaltM(m_hAcsComm, Axes, NULL))
    {
        qDebug() << "HaltM command error";
    }
}


void Widget::on_pushButtonMoveToPosition_clicked()
{
    // If motor is moving state,
    if(m_MotorStatus[m_nSelectedAxisNo] & ACSC_MST_MOVE) return;

    // Seconds arguement '0', it means absolute position (no option)
    double distance = ui->lineEditPosOrDistance->text().toDouble();
    if(!acsc_ToPoint(m_hAcsComm, 0, m_nSelectedAxisNo, distance, NULL))
    {
        qDebug() << "Move to Position (Absolute position) command error";
    }
}


void Widget::on_pushButtonMoveDec_clicked()
{
    // If motor is moving state,
    if(m_MotorStatus[m_nSelectedAxisNo] & ACSC_MST_MOVE) return;

    double distance = ui->lineEditPosOrDistance->text().toDouble();
    // Move relative position (from current position)
    if(!acsc_ToPoint(m_hAcsComm, ACSC_AMF_RELATIVE, m_nSelectedAxisNo, distance * (-1), NULL))
    {
        qDebug() << "Move Decrement command error";
    }
}


void Widget::on_pushButtonMoveInc_clicked()
{
    // If motor is moving state,
    if(m_MotorStatus[m_nSelectedAxisNo] & ACSC_MST_MOVE) return;

    double distance = ui->lineEditPosOrDistance->text().toDouble();
    // Move relative position (from current position)
    if(!acsc_ToPoint(m_hAcsComm, ACSC_AMF_RELATIVE, m_nSelectedAxisNo, distance, NULL))
    {
        qDebug() << "Move Decrement command error";
    }
}


void Widget::on_pushButtonNegtive_clicked()
{

}


void Widget::on_pushButtonPositive_clicked()
{

}


void Widget::on_pushButtonMotinEnd_clicked()
{

}


void Widget::on_pushButtonProgramEnd_clicked()
{

}


void Widget::on_pushButtonInput_clicked()
{

}


void Widget::on_pushButtonSend_clicked()
{

}

  1. 运行结果

ACS系列(6) ACS QT版SPiiPlusClibraryDemo_QT



【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  lA9hNJ8xYnRP   2023年12月12日   30   0   0 Qt
  lA9hNJ8xYnRP   2023年12月06日   32   0   0 Qt
  nIBmcPWZzwbL   2023年11月13日   32   0   0 Qt
  nIBmcPWZzwbL   2023年11月13日   44   0   0 Qt
  lA9hNJ8xYnRP   2023年12月06日   35   0   0 构造函数Qt
  lA9hNJ8xYnRP   2023年12月07日   32   0   0 Qt
  lA9hNJ8xYnRP   2023年12月11日   28   0   0 Qt
  lA9hNJ8xYnRP   2023年11月25日   38   0   0 Qt数据
  lA9hNJ8xYnRP   2023年11月30日   32   0   0 Qt表视图
  nIBmcPWZzwbL   2023年11月13日   31   0   0 Qt
  nIBmcPWZzwbL   2023年11月13日   35   0   0 Qt
  nIBmcPWZzwbL   2023年11月13日   47   0   0 Qt
k4eu5fcIGZiP