更新项目文件和数据发送逻辑

- 将多个项目文件中的
- 在 `DriverMainDlg.cpp` 中注释掉与 `m_bAutoSend2` 相关的代码,新增 `SendCanAGVMoveData` 和 `SendCanAGVTurnData` 函数以发送运动和转向数据。
- 更新 `SendCanThreadForFast` 函数,使用新的数据发送函数替代旧实现。
- 在 `OnBnClickedAutoSend3` 函数中添加停止发送 CAN 报文的逻辑,并将速度置为 0。
- 在 `DriverMainDlg.h` 中新增相关函数声明。
- 其他项目文件(如 `Fast.vcxproj`、`KcCtrl.vcxproj`、`Plc.vcxproj` 和 `QrGuide.vcxproj`)也进行了类似的工具集更新。
This commit is contained in:
美食博主 2025-06-19 15:04:23 +08:00
parent c0a5ddfeb7
commit 62924be8d7
9 changed files with 78 additions and 18 deletions

View File

@ -22,7 +22,7 @@
<ProjectGuid>{548705F2-AF3E-45B7-A716-578791B1ECBE}</ProjectGuid> <ProjectGuid>{548705F2-AF3E-45B7-A716-578791B1ECBE}</ProjectGuid>
<RootNamespace>CCEXPipe</RootNamespace> <RootNamespace>CCEXPipe</RootNamespace>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
@ -45,7 +45,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">

View File

@ -21,7 +21,7 @@
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{4DA0C82B-2496-4A33-BDCE-E89D85A60BF8}</ProjectGuid> <ProjectGuid>{4DA0C82B-2496-4A33-BDCE-E89D85A60BF8}</ProjectGuid>
<RootNamespace>VcsClient</RootNamespace> <RootNamespace>VcsClient</RootNamespace>
<WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<Keyword>MFCProj</Keyword> <Keyword>MFCProj</Keyword>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@ -43,7 +43,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc> <UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup> </PropertyGroup>

View File

@ -21,7 +21,7 @@
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{8BBB60C1-510D-47BC-8FD2-E14E9EA3A156}</ProjectGuid> <ProjectGuid>{8BBB60C1-510D-47BC-8FD2-E14E9EA3A156}</ProjectGuid>
<RootNamespace>VcsClient</RootNamespace> <RootNamespace>VcsClient</RootNamespace>
<WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<Keyword>MFCProj</Keyword> <Keyword>MFCProj</Keyword>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@ -43,7 +43,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc> <UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup> </PropertyGroup>

View File

@ -490,12 +490,12 @@ BOOL CDriverMainDlg::OnInitDialog()
else else
StopFlag = 1; StopFlag = 1;
if (m_bAutoSend2) //if (m_bAutoSend2)
{ //{
m_StopSendFlag2 = 0; // m_StopSendFlag2 = 0;
//开启发送线程 // //开启发送线程
AfxBeginThread(SendCanThread2, this); // AfxBeginThread(SendCanThread2, this);
} //}
if (m_bAutoSendForFast) if (m_bAutoSendForFast)
{ {
m_StopSendFlagForFast = 0; m_StopSendFlagForFast = 0;
@ -1018,6 +1018,58 @@ void CDriverMainDlg::SendCanControlDataForKDS(float Vel, float Ang) {
LogOutToFile("(inner)SendCanControlDataForKDS: canData326 = %c,%c,%c,%c,%c,%c,%c,%c", canData326[0], canData326[1], canData326[2], canData326[3], canData326[4], canData326[5], canData326[6]); LogOutToFile("(inner)SendCanControlDataForKDS: canData326 = %c,%c,%c,%c,%c,%c,%c,%c", canData326[0], canData326[1], canData326[2], canData326[3], canData326[4], canData326[5], canData326[6]);
//SendCanData(0, 0, m_nSendFrameTypeIdx0, m_nSendFrameFormatIdx0, 0x326, canData326); //SendCanData(0, 0, m_nSendFrameTypeIdx0, m_nSendFrameFormatIdx0, 0x326, canData326);
} }
//下发自动模式下前进后退参数_CAN_0x226
void CDriverMainDlg::SendCanAGVMoveData(float Vel) {
UINT32 acId = 0x226; //速度参数帧
byte mvDirection = 0;
float C = 3.14 * 0.343; //计算轮子周长
float reSpeed = 0;
if (Vel > 0) {
mvDirection = 5; //前进
}
else if (Vel < 0) {
mvDirection = 3; //后退
Vel = -Vel;
}
reSpeed = Vel * 60 / C * 20.2; //RPM
int16_t bytePair = static_cast<int16_t>(reSpeed);
uint8_t reSpeedHByte = (bytePair >> 8) & 0xFF; // 高字节
uint8_t reSpeedLByte = bytePair & 0xFF; // 低字节
//TRACE("HByte is %x LByte is %x", reSpeedHByte, reSpeedLByte);
char acData[8] = {};
acData[0] = mvDirection;
acData[1] = reSpeedLByte;
acData[2] = reSpeedHByte;
acData[3] = 30;
acData[4] = 30;
acData[5] = 1;
acData[6] = 1;
acData[7] = 0;
SendCanData(0, 0, m_nSendFrameTypeIdx0, m_nSendFrameFormatIdx0, acId, acData);
}
//下发自动模式下转向角度_CAN_0x326
void CDriverMainDlg::SendCanAGVTurnData(float Ang)
{
UINT32 acId = 0x326; //角度帧
Ang = Ang * 100;
int16_t bytePair = static_cast<int16_t>(Ang);
uint8_t turnDegreeHByte = (bytePair >> 8) & 0xFF; // 高字节
uint8_t turnDegreeLByte = bytePair & 0xFF; // 低字节
//TRACE("HByte is %x LByte is %x", turnDegreeHByte, turnDegreeLByte);
char acData[8] = {};
acData[0] = turnDegreeLByte;
acData[1] = turnDegreeHByte;
acData[2] = 0;
acData[3] = 0;
acData[4] = 0;
acData[5] = 0;
acData[6] = 0;
acData[7] = 0;
SendCanData(0, 0, m_nSendFrameTypeIdx0, m_nSendFrameFormatIdx0, acId, acData);
}
@ -1206,8 +1258,11 @@ UINT CDriverMainDlg::SendCanThreadForFast(LPVOID v)
//theApp.m_fAngCalForFast = UserAng; //theApp.m_fAngCalForFast = UserAng;
//下发运动控制参数 //下发运动控制参数
LogOutToFile("(inner)SendCanThreadForFast: Vel = %f, Ang = %f", theApp.m_fVelCalForFast, theApp.m_fAngCalForFast); LogOutToFile("(inner)SendCanThreadForFast: Vel = %f, Ang = %f", theApp.m_fVelCalForFast, theApp.m_fAngCalForFast);
dlg->SendCanControlDataForKDS(theApp.m_fVelCalForFast, theApp.m_fAngCalForFast); //dlg->SendCanControlDataForKDS(theApp.m_fVelCalForFast, theApp.m_fAngCalForFast);
Sleep(20); dlg->SendCanAGVMoveData(theApp.m_fVelCalForFast);
Sleep(10);
dlg->SendCanAGVTurnData(theApp.m_fAngCalForFast);
Sleep(10);
} }
return 0; return 0;
} }
@ -1240,6 +1295,9 @@ void CDriverMainDlg::OnBnClickedAutoSend3()
} }
else else
m_StopSendFlagForFast = 1; m_StopSendFlagForFast = 1;
//停止发送Can报文并将速度置0
SendCanAGVMoveData(0.0f);
theApp.m_fVelCalForFast = 0.0f;
} }
int before_trafficstop_action; int before_trafficstop_action;

View File

@ -118,6 +118,8 @@ public:
BOOL OpenCanDevice(); BOOL OpenCanDevice();
float NormalizeAngle(float angle); float NormalizeAngle(float angle);
float CorrectAngle(float currentAngle, float targetAngle); float CorrectAngle(float currentAngle, float targetAngle);
void SendCanAGVMoveData(float Vel);
void SendCanAGVTurnData(float Ang);
void UpdateCanStatue(BOOL bStatue); void UpdateCanStatue(BOOL bStatue);
void ProcessPipeMsg(int lMsgId, char* pData, int lLen); void ProcessPipeMsg(int lMsgId, char* pData, int lLen);
void SendCanData(int nDevIdx, int nCanIdx, int nFrameType, int nFrameFormat, UINT32 acFrameId, char acFrameData[8]); void SendCanData(int nDevIdx, int nCanIdx, int nFrameType, int nFrameFormat, UINT32 acFrameId, char acFrameData[8]);

View File

@ -47,7 +47,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc> <UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup> </PropertyGroup>

View File

@ -43,7 +43,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc> <UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup> </PropertyGroup>

View File

@ -43,7 +43,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc> <UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup> </PropertyGroup>

View File

@ -47,7 +47,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc> <UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup> </PropertyGroup>