qiuyao
2025-02-28 d7ad50a2e9fb4713fd9350ab6475cb1c89060370
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/SerialPortService/SerialPortService.cs
@@ -10,36 +10,33 @@
using WIDESEA_ISerialPortService;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Model.Models.SerialPort;
using WIDESEAWCS_Model.Models;
namespace WIDESEA_SerialPortService
{
    public class SerialPortService : ServiceBase<Dt_TorqueOp, ISerialPortRepository>, ISerialPortService
    {
        private SerialPortTestService _serialPortTestService;  // ä¸²å£æœåŠ¡
        //private SerialPortTestJob _SerialPortTestJob;  // ä¸²å£æœåŠ¡
        public SerialPortService(ISerialPortRepository BaseDal) : base(BaseDal)
        {
            //_SerialPortTestJob = new SerialPortTestJob("COM3", this);
            _serialPortTestService = new SerialPortTestService("COM3");
        }
        public WebResponseContent AddSerialPort(Dt_TorqueOp TorqueOp)
        {
            WebResponseContent content = new WebResponseContent();
            BaseDal.Db.Insertable(TorqueOp).ExecuteCommand();
            //BaseDal.Db.Insertable(TorqueOp).ExecuteCommand();
            BaseDal.AddData(TorqueOp);
            content = WebResponseContent.Instance.OK("成功");
            return content;
        }
        //// å¯åŠ¨ä¸²å£é€šä¿¡
        //public WebResponseContent StartSerialPortCom()
        //{
        //    WebResponseContent content = new WebResponseContent();
        //    // æ‰“开串口并开始发送数据
        //    _serialPortTestService.OpenSerialPort();
        //    return content;
        //}
        // å¯åŠ¨ä¸²å£é€šä¿¡
        public void StartSerialPortCom()
@@ -47,7 +44,7 @@
            //WebResponseContent content = new WebResponseContent();
            // æ‰“开串口并开始发送数据
            _serialPortTestService.OpenSerialPort();
            //_SerialPortTestJob.OpenSerialPort();
            //return content;
        }
@@ -58,15 +55,16 @@
        public void StopSerialPortCom()
        {
            //WebResponseContent content = new WebResponseContent();
            _serialPortTestService.CloseSerialPort();  // å…³é—­ä¸²å£
            //return content;
            //_SerialPortTestJob.CloseSerialPort();  // å…³é—­ä¸²å£
           // return content;
        }
        public List<string> GetSerialPortCom()
        {
          return  _serialPortTestService.GetReceivedData();
            //return  _serialPortTestService.GetReceivedData();
            return null;
         
        }