1
yanjinhui
2025-03-03 07223f68b4cf74786269115b290f073e0fc97354
1
已修改11个文件
已添加1个文件
111 ■■■■ 文件已修改
项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_BasicInfoRepository/ProcessRepository .cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_BasicInfoService/ProcessServer.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_IBasicInfoRepository/IProcessRepository.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_IBasicInfoService/IProcessServer.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_ITaskInfoService/INjTaskServer.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Model/Models/SerialPort/Dt_Process.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Model/Models/SerialPort/Dt_TorqueOp.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Server/Controllers/SerialPort/SerialPortController.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Server/Controllers/Task/NjTaskController.cs 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_TaskInfoService/NjTaskServer.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Tasks/SerialPort/SerialPortJob.cs 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_Tasks/SerialPort/SerialPortTestJob.cs 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_BasicInfoRepository/ProcessRepository .cs
@@ -1,5 +1,6 @@
using WIDESEA_ISerialPortRepository;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_Model.Models.SerialPort;
namespace WIDESEA_SerialPortRepository
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_BasicInfoService/ProcessServer.cs
@@ -6,6 +6,7 @@
using WIDESEA_ISerialPortRepository;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_Model.Models.SerialPort;
namespace WIDESEAWCS_TaskInfoService
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_IBasicInfoRepository/IProcessRepository.cs
@@ -1,4 +1,5 @@
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_Model.Models.SerialPort;
namespace WIDESEA_ISerialPortRepository
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_IBasicInfoService/IProcessServer.cs
@@ -6,6 +6,7 @@
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_Model.Models.SerialPort;
namespace WIDESEAWCS_ITaskInfoService
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_ITaskInfoService/INjTaskServer.cs
@@ -17,6 +17,6 @@
        //添加
        //更新
        //删除
        WebResponseContent ReceiveWMSTask(List<WMSTaskDTO> taskDTOs);
        //WebResponseContent ReceiveWMSTask(List<WMSTaskDTO> taskDTOs);
    }
}
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Model/Models/SerialPort/Dt_Process.cs
@@ -6,7 +6,7 @@
using SqlSugar;
using WIDESEAWCS_Core.Tenants;
namespace WIDESEAWCS_Model.Models.SerialPort
namespace WIDESEAWCS_Model.Models
{
    [SugarTable("Dt_Process","工艺步骤表"),MultiTenant]
    public class Dt_Process
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Model/Models/SerialPort/Dt_TorqueOp.cs
@@ -6,9 +6,9 @@
using SqlSugar;
using WIDESEAWCS_Core.Tenants;
namespace WIDESEAWCS_Model.Models.SerialPort
namespace WIDESEAWCS_Model.Models
{
    //[SugarTable("Dt_Process", "每次执行成功存储的值"), MultiTenant]
    [SugarTable("Dt_TorqueOp", "每次执行成功存储的值"), MultiTenant]
    public class Dt_TorqueOp
    {
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主键")]
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/Controllers/SerialPort/SerialPortController.cs
@@ -6,7 +6,7 @@
using WIDESEA_SerialPortService;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseController;
using WIDESEAWCS_Model.Models.SerialPort;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob.Service;
//using WIDESEA_ISerialPortService.ISerialPortService;
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/Controllers/Task/NjTaskController.cs
@@ -18,10 +18,10 @@
        {
        }
        [HttpPost, Route("ReceiveTask"), AllowAnonymous]
        public WebResponseContent ReceiveWMSTask([FromBody] List<WMSTaskDTO> taskDTOs)
        {
            return Service.ReceiveWMSTask(taskDTOs);
        }
        //[HttpPost, Route("ReceiveTask"), AllowAnonymous]
        //public WebResponseContent ReceiveWMSTask([FromBody] List<WMSTaskDTO> taskDTOs)
        //{
        //    return Service.ReceiveWMSTask(taskDTOs);
        //}
    }
}
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_TaskInfoService/NjTaskServer.cs
@@ -18,9 +18,9 @@
        {
        }
        public WebResponseContent ReceiveWMSTask(List<WMSTaskDTO> taskDTOs)
        {
            throw new NotImplementedException();
        }
        //public WebResponseContent ReceiveWMSTask(List<WMSTaskDTO> taskDTOs)
        //{
        //    throw new NotImplementedException();
        //}
    }
}
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Tasks/SerialPort/SerialPortJob.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Quartz;
using WIDESEAWCS_QuartzJob;
namespace WIDESEAWCS_Tasks
{
    public class SerialPortJob : JobBase, IJob
    {
        public enum CommandType
        {
            None = 0,
            Get = 1,
            Set = 2,
        }
        private SerialPort serialPort;
        private CommandType commandType = CommandType.None;
        private string commandGet = "";//读值
        private string commandSet = "";//设值
        private string setOK = "";
        private string getOK = "";
        public Task Execute(IJobExecutionContext context)
        {
            try
            {
                if (serialPort == null) { serialPort = new SerialPort("COM1"); serialPort.DataReceived += SerialPort_DataReceived;}
                if (!serialPort.IsOpen)
                {
                    serialPort.Open();
                    serialPort.Write(commandSet);//打开串口时先设值
                    commandType = CommandType.Set;
                }
                switch (commandType)
                {
                    case CommandType.Get:
                        serialPort.Write(commandGet);
                        break;
                    case CommandType.Set:
                        serialPort.Write(commandSet);
                        break;
                }
            }
            catch (Exception ex) { }            return Task.CompletedTask;
        }
        private void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            byte[] buffers = new byte[1024];
            while (serialPort.BytesToRead > 0)
            {
                serialPort.Read(buffers, 0, serialPort.BytesToRead > buffers.Length ? buffers.Length : serialPort.BytesToRead);
                string data = Encoding.Default.GetString(buffers);
                if (data.Contains(setOK) && commandType == CommandType.Set)
                {
                    commandType = CommandType.Get;
                }
                else if (data.Contains(getOK) && commandType == CommandType.Get)
                {
                    commandType = CommandType.Set;
                }
            }
        }
    }
}
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Tasks/SerialPort/SerialPortTestJob.cs
@@ -2,14 +2,13 @@
using System.Text;
using Quartz;
using WIDESEA_ISerialPortService;
using WIDESEAWCS_Model.Models.SerialPort;
using WIDESEAWCS_Model.Models;
namespace WIDESEAWCS_Tasks
{
    public class SerialPortTestJob:IJob
    {
        // åœ¨ SerialPortTestService ç±»ä¸­æ·»åР坹 ISerialPortService çš„引用
        private readonly ISerialPortService _serialPortService;
        public readonly string _port;
@@ -23,17 +22,13 @@
            SerialPort = new SerialPort(_port);
            //串口接收到数据时,SerialPort ä¼šè‡ªåŠ¨è§¦å‘ DataReceived äº‹ä»¶
            //SerialPort.DataReceived += OnDataReceived; //接收串口发出的数据
        }
        private CancellationTokenSource _cancellationTokenSource;
        private Task _sendTask;
        private int commandType = 2;
        private int commandType = 2;
        // å‘½ä»¤å­—符串
        private string command0 = "";  // ä¸å‘送命令
@@ -43,7 +38,7 @@
        public Task Execute(IJobExecutionContext context)
        {
            OpenSerialPort();
            //OpenSerialPort();
            SerialPort.DataReceived += OnDataReceived;
            return Task.CompletedTask;