从实践中学习C++

zyx040404 2018-01-19 11:06:04
加精
我做了二十多年的软件开发,目前主要做自动化设备。我主要是介绍一下我学习使用C++的一些经验和自动化设备研发的一些经验,希望他人学习C++或者做自动化设备有个参考。当然,我的经验也不一定都正确,可能也没多高水平,仅供参考吧。
详细内容可以在我的资源里查看,我在帖子里慢慢发,如果哪里违反了csdn规则,请告知
...全文
144821 257 打赏 收藏 转发到动态 举报
写回复
用AI写文章
257 条回复
切换为时间正序
请发表友善的回复…
发表回复
sichuanwww 2018-10-06
  • 打赏
  • 举报
回复
zyx040404 2018-09-29
  • 打赏
  • 举报
回复
有人告訴我,现在大家都在用GitHub,csdn等网站人越来越少了
啊大1号 2018-09-15
  • 打赏
  • 举报
回复
qq_42746967 2018-09-14
  • 打赏
  • 举报
回复
Thanks~
zyx040404 2018-09-14
  • 打赏
  • 举报
回复
希望大家多提意见,有人告诉我解释太少了,我一直在更改代码,也在更新书,加了更多的注释
绝影1 2018-09-10
  • 打赏
  • 举报
回复
感谢分享!!!
liquanhai 2018-09-09
  • 打赏
  • 举报
回复
引用 250 楼 zyx040404 的回复:
[quote=引用 247 楼 liquanhai 的回复:]
[quote=引用 244 楼 zyx040404 的回复:]
[quote=引用 242 楼 liquanhai 的回复:]
[quote=引用 240 楼 zyx040404 的回复:]
[quote=引用 239 楼 liquanhai 的回复:]
大哥写的书准备出版么?还是在网上电子版传阅,能坚持这么久的帖子,很有价值!

书在我的资源里有下载,如果有出版社想出板也可以[/quote]
谢谢大哥的无私奉献,你是技术界的一股清流,我们向你看齐建议把相关代码整理,放到github。
我的是https://github.com/liquanhai,欢迎相互关注![/quote]
大概是自己老了,没看懂GitHub是做什么的,也不知道怎么用,我都不知道如何创建一个目录,也不知道如何把代码上传[/quote]

下载个github的desktop软件直接管理就好了,没有那么难得 https://blog.csdn.net/qq_25327609/article/details/72455899[/quote]

第7步,然后commit一下就保存到了本地
没看到如何commint,有个commit to master,是灰色的,不能操作

第8步,提交到远程仓库
提示失败,名字已经存在了,提交的是目录,如何提交一个文档?
[/quote]

已经给你发了私信,录了一个视频。
zyx040404 2018-09-09
  • 打赏
  • 举报
回复
liquanhai, 謝謝你
zyx040404 2018-09-07
  • 打赏
  • 举报
回复
引用 247 楼 liquanhai 的回复:
[quote=引用 244 楼 zyx040404 的回复:]
[quote=引用 242 楼 liquanhai 的回复:]
[quote=引用 240 楼 zyx040404 的回复:]
[quote=引用 239 楼 liquanhai 的回复:]
大哥写的书准备出版么?还是在网上电子版传阅,能坚持这么久的帖子,很有价值!

书在我的资源里有下载,如果有出版社想出板也可以[/quote]
谢谢大哥的无私奉献,你是技术界的一股清流,我们向你看齐建议把相关代码整理,放到github。
我的是https://github.com/liquanhai,欢迎相互关注![/quote]
大概是自己老了,没看懂GitHub是做什么的,也不知道怎么用,我都不知道如何创建一个目录,也不知道如何把代码上传[/quote]

下载个github的desktop软件直接管理就好了,没有那么难得 https://blog.csdn.net/qq_25327609/article/details/72455899[/quote]

第7步,然后commit一下就保存到了本地
没看到如何commint,有个commit to master,是灰色的,不能操作

第8步,提交到远程仓库
提示失败,名字已经存在了,提交的是目录,如何提交一个文档?
yunsongblue 2018-08-14
  • 打赏
  • 举报
回复
顶,努力学习中,谢谢各位大神分享经验
liquanhai 2018-08-13
  • 打赏
  • 举报
回复
引用 244 楼 zyx040404 的回复:
[quote=引用 242 楼 liquanhai 的回复:]
[quote=引用 240 楼 zyx040404 的回复:]
[quote=引用 239 楼 liquanhai 的回复:]
大哥写的书准备出版么?还是在网上电子版传阅,能坚持这么久的帖子,很有价值!

书在我的资源里有下载,如果有出版社想出板也可以[/quote]
谢谢大哥的无私奉献,你是技术界的一股清流,我们向你看齐建议把相关代码整理,放到github。
我的是https://github.com/liquanhai,欢迎相互关注![/quote]
大概是自己老了,没看懂GitHub是做什么的,也不知道怎么用,我都不知道如何创建一个目录,也不知道如何把代码上传[/quote]

下载个github的desktop软件直接管理就好了,没有那么难得 https://blog.csdn.net/qq_25327609/article/details/72455899
赵4老师 2018-08-01
  • 打赏
  • 举报
回复
老树要发新芽还是不容易的。
Chuckyuan9527 2018-08-01
  • 打赏
  • 举报
回复
我也是做自动化的,不过我主要是使用PLC等,
zyx040404 2018-07-31
  • 打赏
  • 举报
回复
引用 242 楼 liquanhai 的回复:
[quote=引用 240 楼 zyx040404 的回复:]
[quote=引用 239 楼 liquanhai 的回复:]
大哥写的书准备出版么?还是在网上电子版传阅,能坚持这么久的帖子,很有价值!

书在我的资源里有下载,如果有出版社想出板也可以[/quote]
谢谢大哥的无私奉献,你是技术界的一股清流,我们向你看齐建议把相关代码整理,放到github。
我的是https://github.com/liquanhai,欢迎相互关注![/quote]
大概是自己老了,没看懂GitHub是做什么的,也不知道怎么用,我都不知道如何创建一个目录,也不知道如何把代码上传
zyx040404 2018-07-28
  • 打赏
  • 举报
回复
最近一边做设备,一边改底层代码,书的内容也更新了不少,等改完再发布
liquanhai 2018-06-23
  • 打赏
  • 举报
回复
引用 240 楼 zyx040404 的回复:
[quote=引用 239 楼 liquanhai 的回复:]
大哥写的书准备出版么?还是在网上电子版传阅,能坚持这么久的帖子,很有价值!

书在我的资源里有下载,如果有出版社想出板也可以[/quote]
谢谢大哥的无私奉献,你是技术界的一股清流,我们向你看齐建议把相关代码整理,放到github。
我的是https://github.com/liquanhai,欢迎相互关注!
丁劲犇 2018-06-23
  • 打赏
  • 举报
回复
厉害!!学习了!
----
还是有坚持这么多年在技术开发一线的人啊!
zyx040404 2018-06-22
  • 打赏
  • 举报
回复
引用 239 楼 liquanhai 的回复:
大哥写的书准备出版么?还是在网上电子版传阅,能坚持这么久的帖子,很有价值!

书在我的资源里有下载,如果有出版社想出板也可以
liquanhai 2018-06-19
  • 打赏
  • 举报
回复
大哥写的书准备出版么?还是在网上电子版传阅,能坚持这么久的帖子,很有价值!
zyx040404 2018-05-20
  • 打赏
  • 举报
回复



void CPath::__CreatePath_LineX()
{
	BOOL bIsPoint2X = FALSE;
	for (VEC_CUT_DATA_IT it = m_vecCutDataSequence.begin(); it != m_vecCutDataSequence.end(); ++it)
	{
		tagCutData & stuCutData = *it;

		switch (stuCutData.nCutDataType)
		{
		case CutDataType::PerimeterX1:
		case CutDataType::PerimeterX2:
		case CutDataType::LineX:
			if (vecCutPath.empty())
			{
				for (int i = 0; i < stuCutData.nCutTimes; ++i)
				{
					if (i % 2 == 0)
					{
						vecCutPath.push_back(stuCutData);
					}
					else
					{
						tagCutData stuReverse;
						__ReverseCutData(stuCutData, stuReverse);
						vecCutPath.push_back(stuReverse);
					}

					bIsPoint2X = !bIsPoint2X;
				}
			}
			else
			{
				tagCutData & stuLastCutPath = vecCutPath[vecCutPath.size() - 1];

				if (bIsPoint2X)
				{
					//connect line
					tagCutData stuConnect;
					memset(&stuConnect, NULL, sizeof(stuConnect));
					stuConnect.point1.x = stuLastCutPath.point2.x;
					stuConnect.point1.y = stuLastCutPath.point2.y;
					stuConnect.point2.x = stuCutData.point2.x;
					stuConnect.point2.y = stuCutData.point2.y;
					stuConnect.nCutDataType = CutDataType::None;
					stuConnect.nCutTimes = 0;
					vecCutPath.push_back(stuConnect);

					//cut line
					for (int i = 0; i < stuCutData.nCutTimes; ++i)
					{
						if (i % 2 == 0)
						{
							tagCutData stuReverse;
							__ReverseCutData(stuCutData, stuReverse);
							vecCutPath.push_back(stuReverse);
						}
						else
						{
							vecCutPath.push_back(stuCutData);
						}

						bIsPoint2X = !bIsPoint2X;
					}
				}
				else
				{
					//connect line
					tagCutData stuConnect;
					memset(&stuConnect, NULL, sizeof(stuConnect));
					stuConnect.point1.x = stuLastCutPath.point2.x;
					stuConnect.point1.y = stuLastCutPath.point2.y;
					stuConnect.point2.x = stuCutData.point1.x;
					stuConnect.point2.y = stuCutData.point1.y;
					stuConnect.nCutDataType = CutDataType::None;
					stuConnect.nCutTimes = 0;
					vecCutPath.push_back(stuConnect);

					//cut line
					for (int i = 0; i < stuCutData.nCutTimes; ++i)
					{
						if (i % 2 == 0)
						{
							vecCutPath.push_back(stuCutData);
						}
						else
						{
							tagCutData stuReverse;
							__ReverseCutData(stuCutData, stuReverse);
							vecCutPath.push_back(stuReverse);
						}

						bIsPoint2X = !bIsPoint2X;
					}
				}
			}

			break;
		default:
			break;
		}
	}
}


void CPath::__CreatePath_LineY()
{
	BOOL bIsPoint2Y = !vecCutPath.empty();
	for (VEC_CUT_DATA_IT it = m_vecCutDataSequence.begin(); it != m_vecCutDataSequence.end(); ++it)
	{
		tagCutData & stuCutData = *it;

		switch (stuCutData.nCutDataType)
		{
		case CutDataType::PerimeterY1:
		case CutDataType::PerimeterY2:
		case CutDataType::LineY:
			if (vecCutPath.empty())
			{
				for (int i = 0; i < stuCutData.nCutTimes; ++i)
				{
					if (i % 2 == 0)
					{
						vecCutPath.push_back(stuCutData);
					}
					else
					{
						tagCutData stuReverse;
						__ReverseCutData(stuCutData, stuReverse);
						vecCutPath.push_back(stuReverse);
					}

					bIsPoint2Y = !bIsPoint2Y;
				}
			}
			else
			{
				tagCutData & stuLastCutPath = vecCutPath[vecCutPath.size() - 1];
//				BOOL bIsSmaePoint = (stuLastCutPath.point2.x == stuCutData.point2.x && stuLastCutPath.point2.y == stuCutData.point2.y);

				if (bIsPoint2Y)
				{
					//connect line
//					if (!bIsSmaePoint)
					{
						tagCutData stuConnect;
						memset(&stuConnect, NULL, sizeof(stuConnect));
						stuConnect.point1.x = stuLastCutPath.point2.x;
						stuConnect.point1.y = stuLastCutPath.point2.y;
						stuConnect.point2.x = stuCutData.point2.x;
						stuConnect.point2.y = stuCutData.point2.y;
						stuConnect.nCutDataType = CutDataType::None;
						stuConnect.nCutTimes = 0;
						vecCutPath.push_back(stuConnect);
					}

					//cut line
					for (int i = 0; i < stuCutData.nCutTimes; ++i)
					{
						if (i % 2 == 0)
						{
							tagCutData stuReverse;
							__ReverseCutData(stuCutData, stuReverse);
							vecCutPath.push_back(stuReverse);
						}
						else
						{
							vecCutPath.push_back(stuCutData);
						}

						bIsPoint2Y = !bIsPoint2Y;
					}
				}
				else
				{
					//connect line
//					if (!bIsSmaePoint)
					{
						tagCutData stuConnect;
						memset(&stuConnect, NULL, sizeof(stuConnect));
						stuConnect.point1.x = stuLastCutPath.point2.x;
						stuConnect.point1.y = stuLastCutPath.point2.y;
						stuConnect.point2.x = stuCutData.point1.x;
						stuConnect.point2.y = stuCutData.point1.y;
						stuConnect.nCutDataType = CutDataType::None;
						stuConnect.nCutTimes = 0;
						vecCutPath.push_back(stuConnect);
					}

					//cut line
					for (int i = 0; i < stuCutData.nCutTimes; ++i)
					{
						if (i % 2 == 0)
						{
							vecCutPath.push_back(stuCutData);
						}
						else
						{
							tagCutData stuReverse;
							__ReverseCutData(stuCutData, stuReverse);
							vecCutPath.push_back(stuReverse);
						}

						bIsPoint2Y = !bIsPoint2Y;
					}
				}
			}

			break;
		default:
			break;
		}
	}
}


void CPath::__CreatePath_Circle()
{
	for (VEC_CUT_DATA_IT it = m_vecCutDataSequence.begin(); it != m_vecCutDataSequence.end(); ++it)
	{
		tagCutData & stuCutData = *it;

		switch (stuCutData.nCutDataType)
		{
		case CutDataType::Circle:
			//connect line
			if (!vecCutPath.empty())
			{
				tagCutData & stuLastCutPath = vecCutPath[vecCutPath.size() - 1];

				tagCutData stuConnect;
				memset(&stuConnect, NULL, sizeof(stuConnect));

				tagCircle circle;
				circle.ptCenter.x = g_pCell->stuSize.x / 2;
				circle.ptCenter.y = g_pCell->stuSize.y / 2;
				circle.radius = padbRadius;

				DPOINT point1, point2;
				point1.x = stuLastCutPath.point2.x;
				point1.y = stuLastCutPath.point2.y;
				SAMA::GetPointOnCircle(circle.ptCenter, circle.radius, point1, point2);

				stuConnect.point1.x = stuLastCutPath.point2.x;
				stuConnect.point1.y = stuLastCutPath.point2.y;
				stuConnect.point2.x = point2.x;
				stuConnect.point2.y = point2.y;
				stuConnect.nCutDataType = CutDataType::None;
				stuConnect.nCutTimes = 0;
				vecCutPath.push_back(stuConnect);

				//circle
				stuCutData.point1.x = stuCutData.point2.x = stuConnect.point2.x;
				stuCutData.point1.y = stuCutData.point2.y = stuConnect.point2.y;
				for (int i = 0; i < stuCutData.nCutTimes; ++i)
					vecCutPath.push_back(stuCutData);
			}
			else
			{
				tagCircle circle;
				circle.ptCenter.x = g_pCell->stuSize.x / 2;
				circle.ptCenter.y = g_pCell->stuSize.y / 2;
				circle.radius = padbRadius;

				DPOINT point, start_point;
				point.x = 0;
				point.y = g_pCell->stuSize.y;
				SAMA::GetPointOnCircle(circle.ptCenter, circle.radius, point, start_point);

				//circle
				stuCutData.point1.x = stuCutData.point2.x = start_point.x;
				stuCutData.point1.y = stuCutData.point2.y = start_point.y;
				for (int i = 0; i < stuCutData.nCutTimes; ++i)
					vecCutPath.push_back(stuCutData);
			}

			break;
		default:
			break;
		}
	}
}


void CPath::ReadSettings()
{
	TSTRING sTagName = _T("");

	//CutOffset
	sTagName = _T("DSM/Path/CutOffset");
	g_pIXMLParserSettings->GetDouble(sTagName, stdbCutOffset);
}


void CPath::UpdateSettings()
{
	TSTRING sTagName = _T("");

	//CutOffset
	sTagName = _T("DSM/Path/CutOffset");
	g_pIXMLParserSettings->PutDouble(sTagName, stdbCutOffset);
}


UINT WINAPI CPath::CutPathInThread(LPVOID lParam)
{
	tagCutData * pstuCutData = (tagCutData *)lParam;

	COMMON_ERR nError = g_pPath->__CutPath(*pstuCutData);
	if COMMON_FAILED(nError)
		g_nCurrentErrorCode = nError;

	_endthreadex(0);

	return 0;
}


COMMON_ERR CPath::__CutPath(const tagCutData & stuCutPath)
{
	COMMON_ERR nError = COMMON_OK;

	try
	{
		tagPosition stuPosition1;
		stuPosition1.x = g_pLaser->stuOrg.x + stuCutPath.point1.x;
		stuPosition1.y = g_pLaser->stuOrg.y + stuCutPath.point1.y - g_pCell->stuSize.y;
		tagPosition stuPosition2;
		stuPosition2.x = g_pLaser->stuOrg.x + stuCutPath.point2.x;
		stuPosition2.y = g_pLaser->stuOrg.y + stuCutPath.point2.y - g_pCell->stuSize.y;

		COMMON_IF_FAILED_THEN_THROW(g_pTable->MoveToPosition(stuPosition1));

		if (CutDataType::None != stuCutPath.nCutDataType && !g_pDeviceDebug->bIsDisableLaser)
		{
			g_pLaser->OpenLaser();
			Sleep(panCutWait);
		}
		else
		{
			g_pLaser->CloseLaser();
		}

		COMMON_IF_FAILED_THEN_THROW(g_pTable->MoveToPosition(stuPosition2));
	}
	catch (COMMON_ERR & err)
	{
		nError = err;
	}

	g_pLaser->CloseLaser();

	return nError;
}
说明: void CPath::CreateCutData() 创建划片数据,包括周边,直线和圆 void CPath::CreateCutPath() 创建划片路径,顺序是周边X1-线X-周边X2-周边Y2-线Y-周边Y1-圆,路径和路径之间由虚路径链接 10.3.6.1【已知问题】圆形划片补偿 当划片数据是圆形的时候,从起点划片到终点后,还应该再多划片一段补偿距离,保证划片成功 10.3.6.2【已知问题】圆形划片虚路径 当划片数据是圆形的时候,因为圆形直径大于电池长宽,当激光划片路径不在电池上时,应该关闭激光
加载更多回复(237)

15,440

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧