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.StackerCraneJob
{
///
/// 隔热&坯料堆垛机系统
///
public class StackerSocketState_BTI
{
public string IPAddress { get; set; } = string.Empty;
public bool IsEventSubscribed { get; set; }
}
///
/// 隔热&坯料堆垛机管理
///
public static class CraneManager_BTI
{
private static readonly ConcurrentDictionary> _ipCranes = new();
// 初始化3台堆垛机(一个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;
}
}
///
/// 成品堆垛机系统1
///
public class StackerSocketState_CP01
{
public string IPAddress { get; set; } = string.Empty;
public bool IsEventSubscribed { get; set; }
}
///
/// 成品堆垛机1管理
///
public static class CraneManager_CP01
{
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;
}
}
///
/// 成品堆垛机系统2
///
public class StackerSocketState_CP02
{
public string IPAddress { get; set; } = string.Empty;
public bool IsEventSubscribed { get; set; }
}
///
/// 成品堆垛机2管理
///
public static class CraneManager_CP02
{
private static readonly ConcurrentDictionary> _ipCranes = new();
// 初始化3台堆垛机(一个IP下)
public static Dictionary GetOrCreateCraneList(string ip)
{
return _ipCranes.GetOrAdd(ip, _ => new Dictionary
{
{ "CRAN31-01", new CraneStacker("CRAN31-01", "1#堆垛机") },
{ "CRAN31-02", new CraneStacker("CRAN31-02", "2#堆垛机") },
{ "CRAN31-03", new CraneStacker("CRAN31-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;
}
}
}