From 3db3b2244255ca7eadc4babe1cc4430bc22cb46b Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期四, 25 十二月 2025 15:49:06 +0800
Subject: [PATCH] 1
---
代码管理/WIDESEAWCS_Server/WIDESEAWCS_Server/WIDESEAWCS_Tasks/PLCJob.cs | 35 +++++++++++++++++++++++++++++++++--
1 files changed, 33 insertions(+), 2 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WIDESEAWCS_Server/WIDESEAWCS_Server/WIDESEAWCS_Tasks/PLCJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WIDESEAWCS_Server/WIDESEAWCS_Server/WIDESEAWCS_Tasks/PLCJob.cs"
index dc9ec1b..e345776 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WIDESEAWCS_Server/WIDESEAWCS_Server/WIDESEAWCS_Tasks/PLCJob.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WIDESEAWCS_Server/WIDESEAWCS_Server/WIDESEAWCS_Tasks/PLCJob.cs"
@@ -2,6 +2,7 @@
using HslCommunication;
using HslCommunication.Core;
using Microsoft.VisualBasic.FileIO;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using Quartz;
using SixLabors.ImageSharp.PixelFormats;
using System;
@@ -36,7 +37,13 @@
_formulaDetailService = formulaDetailService;
_processInfoService = processInfoService;
}
-
+ private readonly string set = "0x16,0x4D,0x0D,0x30,0x34,0x30,0x31,0x44,0x30,0x35,0x2E";//涓绘満鍙戦�佽缃壂鎻忔ā寮忎负涓绘満妯″紡鐨勫懡浠�,鎵弿鍣ㄨ繑鍥炴帴鏀跺埌鐨勫懡浠ゅ拰<ACK>锛�0x06锛夊悗锛屽皢鎵弿妯″紡鏇存敼涓轰富鏈烘ā寮�
+ private readonly string Text = "寮�鍚壂鐮�";//涓绘満鍙戦�佽缃壂鎻忔ā寮忎负涓绘満妯″紡鐨勫懡浠�,鎵弿鍣ㄨ繑鍥炴帴鏀跺埌鐨勫懡浠ゅ拰<ACK>锛�0x06锛夊悗锛屽皢鎵弿妯″紡鏇存敼涓轰富鏈烘ā寮�
+ private readonly string command = "0x16,0x54,0x0D";//鍙戦�佸紑濮嬭В鐮佸懡浠わ紱"0x16,0x55,0x0D"鍙戦�佸仠姝㈣В鐮佸懡浠�
+ SerialPortCommunicator portCommunicator1 = new SerialPortCommunicator("COM1", 9600, "涓婄嚎鎵爜鏋�");
+ static bool IsConnected1 = false;
+ SerialPortCommunicator portCommunicator2 = new SerialPortCommunicator("COM2", 9600, "涓婄嚎鎵爜鏋�");
+ static bool IsConnected2 = false;
public Task Execute(IJobExecutionContext context)
{
@@ -48,6 +55,7 @@
OtherDevice device = (OtherDevice)value;
try
{
+
var Heart = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolHeart);
var EMG = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolEMG);
var AutoExecuting = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolAutoExecuting);
@@ -60,9 +68,32 @@
var Location1ScanDone = device.GetValue<W_PLCDBName, bool>(W_PLCDBName.wboolLocation1ScanDone);
if (Location1ScanStart && !Location1ScanDone)//鎺у埗鎵爜鏋壂鎻忔墭鐩樼爜锛屾牴鎹墭鐩樼爜鏌ヨ缁勭洏鏁版嵁锛屽垽鏂墭鐩樼粦瀹氭垚鍝佹槸鍚﹀凡缁戝畾鎵�鏈夋墍闇�闆朵欢
{
+ #region MyRegion
+ #region 涓插彛杩炴帴
+ if (!IsConnected1) IsConnected1 = portCommunicator1.Connect();
+ if (!IsConnected2) IsConnected2 = portCommunicator2.Connect();
+ byte[] dataToSend1 = Encoding.ASCII.GetBytes(command);//杞垚瀛楄妭鏁扮粍
+ portCommunicator1.Write(dataToSend1);
+ string receiveData = portCommunicator2.ToString(Encoding.UTF8);
+ //if (receiveData == "0x16,0x54,0x0D")
+ //{
+ // Console.WriteLine(receiveData);
+ byte[] dataToSend2 = Encoding.ASCII.GetBytes("PL106");//杞垚瀛楄妭鏁扮粍
+ portCommunicator2.Write(dataToSend2);
+ //}
+ string PalletCode = portCommunicator1.ToString(Encoding.UTF8);
+ if (PalletCode.IsNotEmptyOrNull())
+ {
+ var boxing = _boxingService.Repository.QueryFirst(x => x.PalletCode == PalletCode);
+ }
+ IsConnected1 = !portCommunicator1.Disconnect();
+ IsConnected2 = !portCommunicator2.Disconnect();
+ #endregion
+ #endregion
+
device.SetValue(W_PLCDBName.wboolLocation1ScanDone, true);
}
- else if (!Location1ScanDone && Location1ScanStart)
+ else if (!Location1ScanStart && Location1ScanDone)
{
device.SetValue(W_PLCDBName.wboolLocation1ScanDone, false);
}
--
Gitblit v1.9.3