kazelee
2025-05-23 e2ec31cc0062b3c1af621437554aa9a3505d2a56
Program.cs
@@ -1,17 +1,15 @@
using System;
using System.Collections.Generic;
using System.Threading;
using HH.WCS.Mobox3.DSZSH.AppStart;
using HH.WCS.Mobox3.DSZSH.device;
using HH.WCS.Mobox3.DSZSH.Helpers;
using HH.WCS.Mobox3.DSZSH.ServiceCore;
using HH.WCS.Mobox3.DSZSH.core;
using Microsoft.Owin.Hosting;
using Topshelf;
using Task = System.Threading.Tasks.Task;
using Monitor = HH.WCS.Mobox3.DSZSH.core.Monitor;
namespace HH.WCS.Mobox3.DSZSH {
    internal class Program
@@ -24,7 +22,7 @@
            // 2.0 开启tcp
            StartTcp();
            // 3.0 开启S7
            StartS7();
            //StartS7();
            // 4.0 开启Modbus
            //StartModbus();
@@ -54,7 +52,7 @@
            Console.WriteLine("Startup ApiController");
            Task.Run(() =>
            {
                var url = AppStart.Settings.Config.WebApiUrl; // 运行时修改 config.json 无效
                var url = Settings.WebApiUrl; // 运行时修改 config.json 无效
                Console.WriteLine(url);
                using (WebApp.Start<Startup>(url))
                {
@@ -69,8 +67,8 @@
        /// </summary>
        private static void StartTcp()
        {
            var tcpServerIP = AppStart.Settings.Config.TcpServerIp; // 运行时修改 config.json 无效
            var tcpServerPort = AppStart.Settings.Config.TcpServerPort; // 运行时修改 config.json 无效
            var tcpServerIP = Settings.TcpServerIp; // 运行时修改 config.json 无效
            var tcpServerPort = Settings.TcpServerPort; // 运行时修改 config.json 无效
            new TcpServer(tcpServerIP, tcpServerPort);
        }
@@ -91,18 +89,6 @@
            //        Console.WriteLine("S7ProductionLineHelper," + item.ProductionLine_IP);
            //    }
            //}
            ////称重的S7设备
            //var weightPLCDevice = Settings.WeightDevices;
            //if (weightPLCDevice.Count > 0)
            //{
            //    foreach (var item in weightPLCDevice)
            //    {
            //        new S7Helper(item.WeightDevice_IP, (short)item.WeightDevice_Rack, (short)item.WeightDevice_Slot);
            //        Console.WriteLine("S7WeightDeviceHelper," + item.WeightDevice_Name);
            //    }
            //}
        }
        /// <summary>
@@ -111,7 +97,7 @@
        private static void StartModbus()
        {
            // 所有的Modbus设备
            var allPLCDevice = AppStart.Settings.Config.ProductionLines; // 运行时修改 config.json 无效
            var allPLCDevice = Settings.ProductionLines; // 运行时修改 config.json 无效
            
            if (allPLCDevice.Count > 0) {
                foreach (var item in allPLCDevice) {
@@ -127,19 +113,16 @@
            {
                List<Task> tasks = new List<Task>();
                //tasks.Add(GetTask(CheckCore.CheckOrderState));
                tasks.Add(GetTask(WCSCore.Dispatch));
                tasks.Add(GetTask(OutboundCore.CheckOrderState));
                // 轮询:出库单状态
                tasks.Add(GetTask(Monitor.CheckOutboundOrder));
                // 轮询:抽检单状态
                tasks.Add(GetTask(Monitor.CheckCheckOrder));
                // 添加任务推送线程
                //tasks.Add(GetTask(WCSCore.Dispatch));
                // 添加自定义线程
                //tasks.Add(GetTask(Monitor.CheckEmptyCnt));//检测空托盘
                // 根据S7/Modbus协议判断输送线的信号  原材料产线库区=>满托缓存库区,空托缓存库区=>原材料产线库区
                //tasks.Add(GetTask(Monitor.CheckS7Devices));
                // 轮询:移库单状态
                tasks.Add(GetTask(Monitor.CheckShiftOrder));
                Task.WaitAll(tasks.ToArray());
            }