⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 operatemoto.cpp

📁 profibus dp主站于从站通信
💻 CPP
字号:
/////////////////////////////////////////////////
//
//2008-5-8

#include <windows.h>

#include "keywords.h"

#include<memory.h> 
#include<string.h>

#include "pb_type.h"
#include "pb_conf.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "pb_type.h"
#include "PbproComm.h"
#include "PidReg.h"
#include "common.h"
#include "OperateMoto.h"
#include <string.h> //2008-5-7
#include "Err.h"



extern CPbproComm  m_PbproComm;	
/*******************************************************/
//函数名称: InitSystem()
// 说明:初始化Init_profibus,并检测可连接的salve。
//返回码: SUCCESS:初始化成功
//         ERROR_SET_CONFIGURATION_REQ_STOP  :初始化失败
// 输入参数:无
// 输出参数:无
/**********************************************************/
int InitSystem()
{   
	int iRet = SUCCESS;
	//OnInitApply();
	iRet =OnInitApply();
	if(iRet!=SUCCESS)
	{ 
		return iRet;
	}
	if(m_PbproComm.fmb_set_configuration_req()==PB_TRUE) //2008-4-29
	{
    	//ScanSlaves();
		iRet=ScanSlaves();
		return iRet;
	}
	else
	{
		return ERROR_SET_CONFIGURATION_REQ_STOP ;
	}

}
/*******************************************************/
//函数名称: SetMasterPrm(struct MasterPrm *myMasterPrm)
//返回码:  SUCCESS :函数成功
//          ERROR_INIT_MASTER_REQ  :Master初始化失败
// 输入参数:*myMasterPrm,指向MasterPrmdlg的指针
// 输出参数:无
/**********************************************************/

int SetMasterPrm(struct MasterPrm *myMasterPrm)
{    
     
	 return OnSetMasterPrm(myMasterPrm);
	    
}


/*******************************************************/
//函数名称:SetCBusPrm(struct CBusPrm *myBusPrm)
//返回码:  SUCCESS :函数成功
//          ERROR_GET_BUSPRM :Bus初始化失败
// 输入参数:*myBusPrm,指向CBusPrmdlg的指针
// 输出参数:无
/**********************************************************/

int SetCBusPrm(struct CBusPrm  *myBusPrm)
{
     
    return    OnSetBusPrm(myBusPrm);
}


		//step5
/*******************************************************/
//函数名称:SetCSlavePrm(struct CSlavePrmSet  *mySlavePrmSet)
//返回码:  SUCCESS :函数成功
//          ERROR_GET_SLAVEPRM :Slave初始化失败
// 输入参数:*mySlavePrmSet,指向SlavePrmSet的指针
// 输出参数:无
/**********************************************************/

int SetCSlavePrm(struct CSlavePrmSet  *mySlavePrmSet)
{
		     
        return  OnSetSlavePrm(mySlavePrmSet);
		 

}
/*******************************************************/
//函数名称:OperateChange()
//返回码:  SUCCESS :函数成功
//          ERROR_OPERATECHANGE :Slave状态转换失败
// 输入参数:无		
// 输出参数:无
/**********************************************************/


int OperateChange()
{    
	
    int iRet=0;
    iRet=OnGetOffsets();
    if(iRet!=SUCCESS)
    {
       return iRet;
    }
     
    iRet=OnOfflStop();
	 if(iRet!=SUCCESS)
    {
       return iRet;
     }	

    iRet=OnStopClear();
	 if(iRet!=SUCCESS)
    {
       return iRet;
     }			
     
    iRet=OnClearOperate();
    if(iRet!=SUCCESS)
    {
       return iRet;
    }


}	
/////////////////////////////////////////////////
	/////////2008-5-5
	//在此处选择总线模式即 KE_OUT=8598,UINT IND_OUT=0,UINT PWE=36
    //此处需要根据驱动器具体参数设置。 
/*******************************************************/
//函数名称:BusModeSelect(struct CDataSdRcv  *myDataExch,UINT slavenumber)
//返回码:  SUCCESS :函数成功
//          ERROR_BUSMODE_SELECT :总线模式选择失败
// 输入参数:*myDataExch 指向CDataSdRcv的指针,UINT slavenumber
// 输出参数:无
/**********************************************************/
int BusModeSelect(struct CDataSdRcv  *myDataExch,UINT slavenumber)
{    
	
	 OnDataexchang(myDataExch, slavenumber);
	 return SUCCESS ;
			
	        
}

/*******************************************************/
//函数名称:stopwork()
//返回码:  SUCCESS :函数成功
//          ERROR_STOPWORK  :退出通讯失败
// 输入参数:无
// 输出参数:无
/**********************************************************/


int stopwork()
{
	
	return OnStopCommunication();

}


/*******************************************************/
//函数名称:Warnclean(struct CDataSdRcv  *myDataExch, UINT slavenumber)
//返回码:  SUCCESS :函数成功
//          ERROR_WARNCLEAN :清除报警失败
// 输入参数:*myDataExch 指向CDataSdRcv的指针,UINT slavenumber
// 输出参数:无
/**********************************************************/
int Warnclean(struct CDataSdRcv  *myDataExch, UINT slavenumber) //如何将STW1的值通过传进去
{   
	
		
	    myDataExch->m_STW1=0;
	    OnDataexchang(myDataExch, slavenumber);

		Sleep(2000);
		
		myDataExch->m_STW1=128;
	    OnDataexchang(myDataExch, slavenumber);
	    return SUCCESS ;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -