本文整理汇总了C++中CONTROL::findZeroPos方法的典型用法代码示例。如果您正苦于以下问题:C++ CONTROL::findZeroPos方法的具体用法?C++ CONTROL::findZeroPos怎么用?C++ CONTROL::findZeroPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CONTROL
的用法示例。
在下文中一共展示了CONTROL::findZeroPos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runPreset
STATUS runPreset()
{
UINT64 endTick = 0;
UINT64 eStartTick = 0;
if(GV::isStopAll)
{
DISPLAY_FAULT("系统已清除状态,停止接收启动指令,启动失败!");
file.writeLogFile("系统已清除状态,停止接收启动指令!");
return ERROR;
}
for(UINT nodeNum = 0;nodeNum < AXIS_NUM;nodeNum++){
if(!GV::isPowerOutput[nodeNum] || !GV::isZeroPosSet[nodeNum] || (GV::opMode[nodeNum] != 0x1) || GV::isBoltOn[nodeNum] || GV::isLimit[nodeNum]){
printf("%d %d %d %x\n",GV::isPowerOutput[nodeNum],GV::isZeroPosSet[nodeNum],GV::isBoltOn[nodeNum],GV::opMode[nodeNum]);
DISPLAY_FAULT("启动失败,请检查驱动器是否上电,转台是否处在插销和限位状态!");
return ERROR;}}
CAN_PACKET sendPack,recvPack;
stringstream ss;
memset(&sendPack,0,CP_SIZE);
memset(&recvPack,0,CP_SIZE);
UCHAR buf[WCTLMSG_SIZE];
memset(buf, 0, WCTLMSG_SIZE);
memcpy(buf, &GV::ctrlParamMsg, WCTLMSG_SIZE);
int validBit = 0;
for(validBit = 0;validBit < 5;validBit++){
if(buf[2 + validBit] ^ 0xff){
break;}}
if(buf[2 + validBit] == 0xa0){
control.findZeroPos();
return OK;}
else{
ss << buf[2 + validBit] - 0xa0;
for(int seg = 0; seg < file.jsonDoc[ss.str().c_str()]["seg"].GetInt(); seg++)
{
if(OK != semTake(GV::isCANOccupy,SEM_TIME_OUT*SYS_FREQ))
{
DISPLAY_FAULT("启动操作:获取CAN总线资源失败!");
file.writeLogFile("启动操作:获取CAN锁信号量超时!");
return ERROR;
}
can.writeCopleyCMD(sendPack,
DRIVER_CMD_POS_SET,
file.jsonDoc[ss.str().c_str()]["angle"][seg].GetDouble(),
validBit + 1);
if(ERROR == can.uCMDSend(sendPack,recvPack,USING_CAN_CHANNEL)){
semGive(GV::isCANOccupy);
return ERROR;}
can.writeCopleyCMD(sendPack,
DRIVER_CMD_VEL_SET,
fabs(file.jsonDoc[ss.str().c_str()]["angle"][seg].GetDouble() / file.jsonDoc[ss.str().c_str()]["time"][seg].GetDouble()) * 1.2,
validBit + 1);
if(ERROR == can.uCMDSend(sendPack,recvPack,USING_CAN_CHANNEL)){
semGive(GV::isCANOccupy);
return ERROR;}
can.writeCopleyCMD(sendPack,
DRIVER_CMD_ACC_SET,
MAX_ACC[validBit],
validBit + 1);
if(ERROR == can.uCMDSend(sendPack,recvPack,USING_CAN_CHANNEL)){
semGive(GV::isCANOccupy);
return ERROR;}
can.writeCopleyCMD(sendPack,
DRIVER_CMD_DEACC_SET,
MAX_ACC[validBit],
validBit + 1);
if(ERROR == can.uCMDSend(sendPack,recvPack,USING_CAN_CHANNEL)){
semGive(GV::isCANOccupy);
return ERROR;}
can.writeCopleyCMD(sendPack,
DRIVER_CLEAR_MOVE,
0,
validBit + 1);
if(ERROR == can.uCMDSend(sendPack,recvPack,USING_CAN_CHANNEL)){
semGive(GV::isCANOccupy);
return ERROR;}
can.writeCopleyCMD(sendPack,
DRIVER_REL_START,
0,
validBit + 1);
if(ERROR == can.uCMDSend(sendPack,recvPack,USING_CAN_CHANNEL)){
semGive(GV::isCANOccupy);
return ERROR;}
semGive(GV::isCANOccupy);
endTick = tick64Get();
taskDelay(static_cast<int>((file.jsonDoc[ss.str().c_str()]["time"][seg].GetDouble()
* SYS_FREQ)) - (seg == 0 ? 0 : (endTick - eStartTick)));
eStartTick = tick64Get();
}}
return OK;
}