123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using MECF.Framework.Simulator.Core.Driver;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MECF.Framework.Simulator.Core.Commons
- {
- public class BarcodeReaderSerialPortDevice : BaseSerialSimulator
- {
- #region 常量
- private const string PORT_NAME = "com42";
- #endregion
- /// <summary>
- /// 条码信息
- /// </summary>
- private string _barcode;
- /// <summary>
- /// 给条码赋值
- /// </summary>
- /// <param name="barcode"></param>
- public void SetBarcode(string barcode)
- {
- _barcode = barcode;
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- public BarcodeReaderSerialPortDevice() : base(PORT_NAME, SerialType.ASCII)
- {
-
- }
- /// <summary>
- /// 处理接收到数据
- /// </summary>
- /// <param name="msg"></param>
- protected override void ProcessMessageIn(string msg)
- {
- //接收到获取条码指令
- if (msg.ToLower().Trim() == "lon")
- {
- string data = $"{_barcode}";
- //将当前条码信息返回
- WriteMessage(data);
- }
- }
-
- }
- }
|