<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><title>dp 博客</title><link>https://blog.diphub.top</link><description>上位机、机器视觉、工业通讯和考研笔记</description><language>zh-CN</language><item><title>2 核 2G 的服务器上怎么放下三个站</title><link>https://blog.diphub.top/posts/dp-site-matrix/</link><guid>https://blog.diphub.top/posts/dp-site-matrix/</guid><pubDate>Sat, 24 Oct 2026 00:00:00 GMT</pubDate><category>建站</category><description>主站、博客全静态，英语站一个 Node 进程，前面一个 Caddy。带宽只有 3 Mbps，所以字体和图片都要省。</description></item><item><title>RS-232、RS-422、RS-485 详解</title><link>https://blog.diphub.top/posts/rs232-422-485/</link><guid>https://blog.diphub.top/posts/rs232-422-485/</guid><pubDate>Mon, 23 Sep 2024 00:00:00 GMT</pubDate><category>工业通讯</category><description>三种串口标准各自解决了什么问题、电平和距离速率怎么比、DB9 引脚和接线怎么接。补充现场最常见的问题：A/B 线反了、终端电阻乱加、星形接线，以及 485 半双工的收发切换。</description></item><item><title>C# 结构和类的区别</title><link>https://blog.diphub.top/posts/csharp-struct-vs-class/</link><guid>https://blog.diphub.top/posts/csharp-struct-vs-class/</guid><pubDate>Sun, 16 Jun 2024 00:00:00 GMT</pubDate><category>C# 语言</category><description>struct 是值类型、class 是引用类型，由此带来的复制语义、继承、构造和回收上的差异，以及项目里什么时候该用 struct。补充了「值类型一定在栈上」这个常见误解。</description></item><item><title>WinForm 里的简单 HTTP 服务器与客户端</title><link>https://blog.diphub.top/posts/csharp-http-server-client/</link><guid>https://blog.diphub.top/posts/csharp-http-server-client/</guid><pubDate>Mon, 25 Dec 2023 00:00:00 GMT</pubDate><category>工业通讯</category><description>同事说「用 WebApi、Get、Post 传数据」，其实就是 HTTP。用 HttpListener 写一个带路由的小服务器、用 HttpClient 写客户端，和 AGV 调度系统交换 JSON。顺带纠正几个关于 HTTP 的常见误解：连接、超时、权限。</description></item><item><title>C# 委托与事件</title><link>https://blog.diphub.top/posts/csharp-delegate-event/</link><guid>https://blog.diphub.top/posts/csharp-delegate-event/</guid><pubDate>Wed, 29 Nov 2023 00:00:00 GMT</pubDate><category>C# 语言</category><description>委托是可以存方法的类型，事件是只允许外部订阅、只允许自己触发的委托。多播委托的返回值、GetInvocationList、防止重复订阅，以及 Action/Func 和 EventHandler 的标准写法。</description></item><item><title>C# 多线程（四）：异步调用容易踩的坑</title><link>https://blog.diphub.top/posts/csharp-async-pitfalls/</link><guid>https://blog.diphub.top/posts/csharp-async-pitfalls/</guid><pubDate>Mon, 27 Nov 2023 00:00:00 GMT</pubDate><category>C# 语言</category><description>for 循环里 Task.Run 捕获循环变量，打印出来的全是错的；原因是闭包捕获的是变量本身而不是值。顺带补上另外几个常见的坑：界面线程上 .Result 死锁、async void 吞异常、忘记 await。</description></item><item><title>相机取图后转成视觉库的图像</title><link>https://blog.diphub.top/posts/camera-buffer-to-image/</link><guid>https://blog.diphub.top/posts/camera-buffer-to-image/</guid><pubDate>Wed, 02 Aug 2023 00:00:00 GMT</pubDate><category>机器视觉</category><description>用相机厂家的 SDK 取图，拿到的是一块像素缓冲区，要转成 Halcon、VisionPro 能用的图像。以大华相机为例转 HImage，修正原代码里 fixed 用错的隐患，补充行填充、彩色和 Bayer 格式的处理。</description></item><item><title>Halcon 在 C# 里的数据类型转换</title><link>https://blog.diphub.top/posts/halcon-csharp-types/</link><guid>https://blog.diphub.top/posts/halcon-csharp-types/</guid><pubDate>Tue, 01 Aug 2023 00:00:00 GMT</pubDate><category>机器视觉</category><description>封装 Halcon 代码时常用的转换：HObject 转 HImage、HRegion，HTuple 和 int、double、string、数组互转，HImage 和 Bitmap 互转。重点是 Bitmap 的行对齐（Stride）和对象的释放。</description></item><item><title>C# 多线程（二）：Thread</title><link>https://blog.diphub.top/posts/csharp-thread/</link><guid>https://blog.diphub.top/posts/csharp-thread/</guid><pubDate>Mon, 31 Jul 2023 00:00:00 GMT</pubDate><category>C# 语言</category><description>Thread 的前台与后台、启动、线程状态、Join 等待，以及为什么不该再用 Abort：.NET 5 以后它直接抛异常。改用 CancellationToken 或标志位让线程自己退出。</description></item><item><title>C# 多线程（三）：Thread 和 Task 怎么选</title><link>https://blog.diphub.top/posts/csharp-thread-vs-task/</link><guid>https://blog.diphub.top/posts/csharp-thread-vs-task/</guid><pubDate>Mon, 31 Jul 2023 00:00:00 GMT</pubDate><category>C# 语言</category><description>从创建管理、异步编程、返回值、异常、线程复用五个方面比较 Thread 和 Task，最后给一张上位机开发里的选型表。</description></item><item><title>C# 多线程（一）：Task</title><link>https://blog.diphub.top/posts/csharp-task/</link><guid>https://blog.diphub.top/posts/csharp-task/</guid><pubDate>Wed, 26 Jul 2023 00:00:00 GMT</pubDate><category>C# 语言</category><description>Task 的五种用法：后台执行、await 等待、WhenAll 并行、异常处理、CancellationToken 取消。顺带纠正原文里 new Task 包 async 方法导致 WhenAll 等不到的真正原因。</description></item><item><title>用 LiveCharts 画实时时序图</title><link>https://blog.diphub.top/posts/livecharts-step-line/</link><guid>https://blog.diphub.top/posts/livecharts-step-line/</guid><pubDate>Tue, 18 Jul 2023 00:00:00 GMT</pubDate><category>WinForm</category><description>用 LiveCharts 的 StepLineSeries 画 E84 信号的实时步进图：时间轴、枚举标签、实时追加数据，以及悬停时线越来越粗的问题和改源码的办法。补充数据量控制和更适合高频数据的图表库。</description></item><item><title>Halcon：在 HWindow 上显示文字</title><link>https://blog.diphub.top/posts/halcon-hwindow-text/</link><guid>https://blog.diphub.top/posts/halcon-hwindow-text/</guid><pubDate>Wed, 12 Jul 2023 00:00:00 GMT</pubDate><category>机器视觉</category><description>视觉项目里要在图像窗口上叠加检测结果：DispText 和 WriteString 两种方式的用法和区别；部署到别的电脑报 #5123、#5137 的原因是缺了 hcanvas.dll，以及它对字体格式的影响；字被盖掉和刷新闪烁的处理。</description></item><item><title>浏览器提示「你的连接不是专用连接」</title><link>https://blog.diphub.top/posts/https-not-private/</link><guid>https://blog.diphub.top/posts/https-not-private/</guid><pubDate>Tue, 04 Jul 2023 00:00:00 GMT</pubDate><category>运维踩坑</category><description>Edge、Chrome 打开内网设备的 HTTPS 页面被拦住，而且没有「继续访问」按钮。临时办法是在页面上直接敲 thisisunsafe；根本的办法是弄明白证书为什么不被信任：时间不对、自签名、域名不匹配，各有各的修法。</description></item><item><title>VS2019 发布和调用 WebService，以及 IIS 的坑</title><link>https://blog.diphub.top/posts/webservice/</link><guid>https://blog.diphub.top/posts/webservice/</guid><pubDate>Tue, 04 Jul 2023 00:00:00 GMT</pubDate><category>工业通讯</category><description>对接工厂 MES 时用到的 WebService：新建 ASMX 服务、发布到 IIS、客户端添加服务引用调用。把三篇踩坑记录合在一起：没有 IIS 管理器、HTTP 403.14、测试页只能本机访问等。</description></item><item><title>相机标定（二）：九点标定和旋转中心</title><link>https://blog.diphub.top/posts/camera-calibration/</link><guid>https://blog.diphub.top/posts/camera-calibration/</guid><pubDate>Thu, 23 Mar 2023 00:00:00 GMT</pubDate><category>机器视觉</category><description>相机固定时引导模组或机械手定位的两种情况：只需要 XY 定位时，九点标定加示教基准；需要纠正角度时，再标定旋转中心，用旋转公式算出补偿量。补充眼在手上的做法和精度要点。</description></item><item><title>相机标定（一）：世界、相机、图像、像素四个坐标系</title><link>https://blog.diphub.top/posts/camera-coordinates/</link><guid>https://blog.diphub.top/posts/camera-coordinates/</guid><pubDate>Wed, 08 Mar 2023 00:00:00 GMT</pubDate><category>机器视觉</category><description>标定要解决的是「图像里的一个像素对应现实中的哪个位置」。理清四个坐标系的含义，以及它们之间一步步的转换：旋转平移、透视投影、单位换算，最后合成内参和外参矩阵。</description></item><item><title>HDevelop 的语法：变量、元组、判断和循环</title><link>https://blog.diphub.top/posts/halcon-syntax/</link><guid>https://blog.diphub.top/posts/halcon-syntax/</guid><pubDate>Sat, 04 Mar 2023 00:00:00 GMT</pubDate><category>机器视觉</category><description>HDevelop 脚本和 C# 不太一样的地方：变量不用声明、赋值用 :=、数组是元组、下标从 0 开始、if 和 for 要用 endif、endfor 结尾。附一张和 C# 的对照表。</description></item><item><title>Halcon：HWindow 以鼠标为中心缩放和拖动</title><link>https://blog.diphub.top/posts/halcon-hwindow-zoom/</link><guid>https://blog.diphub.top/posts/halcon-hwindow-zoom/</guid><pubDate>Sun, 26 Feb 2023 00:00:00 GMT</pubDate><category>机器视觉</category><description>HWindowControl 的缩放和平移都靠 SetPart：显示图像的一部分就是放大，移动这部分就是平移。推导以鼠标为中心缩放的公式，实现滚轮缩放、左键拖动和双击还原，并解决拖动时的闪烁。</description></item><item><title>Halcon 入门：XL 版本、算子签名和第一个程序</title><link>https://blog.diphub.top/posts/halcon-basics/</link><guid>https://blog.diphub.top/posts/halcon-basics/</guid><pubDate>Tue, 14 Feb 2023 00:00:00 GMT</pubDate><category>机器视觉</category><description>Halcon 和 Halcon XL 有什么区别；算子签名里那三个冒号是什么意思；dev_open_window、read_image 这几个最先用到的算子。五篇入门短笔记合在一起。</description></item><item><title>Windows 局域网共享文件夹</title><link>https://blog.diphub.top/posts/lan-shared-disk/</link><guid>https://blog.diphub.top/posts/lan-shared-disk/</guid><pubDate>Fri, 30 Dec 2022 00:00:00 GMT</pubDate><category>运维踩坑</category><description>现场 U 盘被禁用、网络受限时，用局域网共享在两台电脑之间传文件：打开网络发现和文件共享、设置共享和 NTFS 权限、用 \\IP 访问。补充访问不了时的排查，以及别把整个盘共享给 Everyone。</description></item><item><title>WinForm 常用控件：TreeView 与 DateTimePicker</title><link>https://blog.diphub.top/posts/winform-controls/</link><guid>https://blog.diphub.top/posts/winform-controls/</guid><pubDate>Fri, 23 Sep 2022 00:00:00 GMT</pubDate><category>WinForm</category><description>TreeView 的节点增删、图标、选中事件和 FullPath；DateTimePicker 的显示格式、自定义格式和取值。补充：大量节点时的 BeginUpdate，以及只选日期、选时间段的写法。</description></item><item><title>VisionPro 脚本：调试与调用自己的 DLL</title><link>https://blog.diphub.top/posts/visionpro-script/</link><guid>https://blog.diphub.top/posts/visionpro-script/</guid><pubDate>Wed, 21 Sep 2022 00:00:00 GMT</pubDate><category>机器视觉</category><description>VisionPro 的 C# 脚本看不到内部运行，用 VS 附加进程断点调试；脚本里引用自己封装的 DLL，要放对目录、带上依赖。补充 GroupRun 返回值的含义和脚本里写文件的注意事项。</description></item><item><title>什么对象会被 .NET 垃圾回收</title><link>https://blog.diphub.top/posts/dotnet-gc/</link><guid>https://blog.diphub.top/posts/dotnet-gc/</guid><pubDate>Tue, 13 Sep 2022 00:00:00 GMT</pubDate><category>C# 语言</category><description>对象不再被任何根引用时就成了垃圾。原文只记了两种情况，这次补上 GC 的根、分代、什么时候回收，以及上位机里最常见的「其实没被回收」的内存泄漏。</description></item><item><title>西门子 PLC 通讯（四）：C# 用 S7.Net 读写 1500</title><link>https://blog.diphub.top/posts/siemens-s7netplus/</link><guid>https://blog.diphub.top/posts/siemens-s7netplus/</guid><pubDate>Fri, 02 Sep 2022 00:00:00 GMT</pubDate><category>工业通讯</category><description>用开源库 S7.Net 读写 S7-1500 的 DB 块：连接、按地址读、按类型读、写入，Bit 到 LReal 的常用类型和 String、WString 的特殊处理。补充：批量读取、断线重连和线程安全。</description></item><item><title>西门子 PLC 通讯（三）：用 NetToPLCsim 连普通 PLCSIM</title><link>https://blog.diphub.top/posts/siemens-nettoplcsim/</link><guid>https://blog.diphub.top/posts/siemens-nettoplcsim/</guid><pubDate>Thu, 01 Sep 2022 00:00:00 GMT</pubDate><category>工业通讯</category><description>博图自带的 PLCSIM 外部程序连不上，NetToPLCsim 把它转发到本机网卡的 102 端口，上位机就能像连真 PLC 一样连它。比 PLCSIM Advanced 轻量，五步配好。</description></item><item><title>倍福 PLC：C# 用 ADS 读写变量和结构体</title><link>https://blog.diphub.top/posts/beckhoff-ads/</link><guid>https://blog.diphub.top/posts/beckhoff-ads/</guid><pubDate>Mon, 29 Aug 2022 00:00:00 GMT</pubDate><category>工业通讯</category><description>TwinCAT 的 ADS 通讯：按变量名拿句柄、读写基本类型和字符串，重点是结构体和结构体数组怎么在 C# 里定义才能和 PLC 的内存对上（pack_mode 与 Pack、MarshalAs）。补充：变量通知代替轮询、端口和路由。</description></item><item><title>C# 实现一个虚拟键盘</title><link>https://blog.diphub.top/posts/winform-virtual-keyboard/</link><guid>https://blog.diphub.top/posts/winform-virtual-keyboard/</guid><pubDate>Thu, 25 Aug 2022 00:00:00 GMT</pubDate><category>WinForm</category><description>触摸屏工控机没有实体键盘，用 keybd_event 模拟按键做一个屏幕键盘：单键、组合键、中文输入。补充：按钮不能抢焦点、更推荐的 SendInput，以及直接调用系统触摸键盘。</description></item><item><title>WinForm 加载界面卡死：UI 线程被堵住了</title><link>https://blog.diphub.top/posts/winform-loading-freeze/</link><guid>https://blog.diphub.top/posts/winform-loading-freeze/</guid><pubDate>Mon, 22 Aug 2022 00:00:00 GMT</pubDate><category>WinForm</category><description>在 Main 里先 Show 一个加载窗体再做初始化，进度条和文字都不动。原因是消息循环还没跑起来。解决办法是让加载窗体在自己的线程里 Application.Run；同类问题「Show 之后窗体显示不全」也一并说清楚。</description></item><item><title>Windows 远程桌面：账户没有密码也能连</title><link>https://blog.diphub.top/posts/remote-desktop-no-password/</link><guid>https://blog.diphub.top/posts/remote-desktop-no-password/</guid><pubDate>Sat, 06 Aug 2022 00:00:00 GMT</pubDate><category>运维踩坑</category><description>工控机的账户通常没设密码，而 Windows 默认不允许空密码账户远程登录。改一条组策略就能连，但这等于给局域网开了一扇不上锁的门。更推荐的做法是设个密码、让工控机自动登录。</description></item></channel></rss>