using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Model.Models;
namespace WIDESEAWCS_Tasks.ConveyorLineJob
{
///
/// 北侧输送线系统
///
public class ConveyorState_North
{
public string IPAddress { get; set; } = string.Empty;
public bool IsEventSubscribed { get; set; }
}
///
/// 北侧输送线管理
///
public static class ConveyorManager_North
{
private static readonly ConcurrentDictionary> _ipCranes = new();
// 初始化输送线堆垛机(一个IP下)
public static Dictionary GetOrCreateCraneList(string ip)
{
return _ipCranes.GetOrAdd(ip, _ => new Dictionary
{
{ "CRAN32-01", new CraneStacker("CRAN32-01", "1#堆垛机") },
{ "CRAN32-02", new CraneStacker("CRAN32-02", "2#堆垛机") },
{ "CRAN32-03", new CraneStacker("CRAN32-03", "3#堆垛机") },
});
}
// 获取某一台堆垛机
public static CraneStacker? GetCrane(string ip, string craneCode)
{
if (_ipCranes.TryGetValue(ip, out var list) && list.TryGetValue(craneCode, out var crane))
return crane;
return null;
}
}
///
/// 南侧输送线系统
///
public class ConveyorState_South
{
public string IPAddress { get; set; } = string.Empty;
public bool IsEventSubscribed { get; set; }
}
///
/// 南侧输送线系统管理
///
public static class ConveyorManager_South
{
private static readonly ConcurrentDictionary> _ipCranes = new();
// 初始化3台堆垛机(一个IP下)
public static Dictionary GetOrCreateCraneList(string ip)
{
return _ipCranes.GetOrAdd(ip, _ => new Dictionary
{
{ "CRAN30-01", new CraneStacker("CRAN30-01", "1#堆垛机") },
{ "CRAN30-02", new CraneStacker("CRAN30-02", "2#堆垛机") },
{ "CRAN30-03", new CraneStacker("CRAN30-03", "3#堆垛机") },
});
}
// 获取某一台堆垛机
public static CraneStacker? GetCrane(string ip, string craneCode)
{
if (_ipCranes.TryGetValue(ip, out var list) && list.TryGetValue(craneCode, out var crane))
return crane;
return null;
}
}
///
/// 单台输送线独立状态
///
public class CraneStacker
{
public string CraneCode { get; set; } = string.Empty;
public string DisplayName { get; set; } = string.Empty;
// 运行状态
public int RunMode { get; set; } = 0; // 1=自动 2=停止 3=手动/离线
public int ErrorState { get; set; } = 0; // 0=正常 1=故障
public string CurrentPosition { get; set; } = string.Empty;
public DateTime LastHeartbeat { get; set; } = DateTime.Now;
// 当前任务
public Dt_Task? CurrentTask { get; set; }
// 独立序列号(每台堆垛机自己计数)
public int SendSeq { get; set; } = 1;
public object SeqLock { get; set; } = new object();
public CraneStacker(string code, string name)
{
CraneCode = code;
DisplayName = name;
}
}
}