You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Aucma.Scada/HighWayIot.Config/PlcSpaceConfig.cs

86 lines
2.9 KiB
C#

using Aucma.Scada.Model.domain;
using HighWayIot.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Config
{
public sealed class PlcSpaceConfig
{
private static IniHelper iniHelper = new IniHelper(System.Environment.CurrentDirectory + "/config/PlcSpace.Ini");
private static readonly Lazy<PlcSpaceConfig> lazy = new Lazy<PlcSpaceConfig>(() => new PlcSpaceConfig());
public static PlcSpaceConfig Instance
{
get
{
return lazy.Value;
}
}
private PlcSpaceConfig()
{
}
/// <summary>
/// 通过货道列表获取对应货道plc地址
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public List<SpaceAddress> GetAllSpaceAddress(List<BaseSpaceInfo> list)
{
if(list == null) return null;
List<SpaceAddress> spaceAddresses = new List<SpaceAddress>();
foreach (BaseSpaceInfo info in list)
{
spaceAddresses.Add(GetSpaceAddress(info.storeCode, info.spaceCode));
}
return spaceAddresses;
}
public SpaceAddress GetSpaceAddress(string storeCode,string spaceCode)
{
SpaceAddress spaceAddress = new SpaceAddress();
spaceAddress.storeCode = storeCode;
spaceAddress.spaceCode = spaceCode;
spaceAddress.onStore = iniHelper.IniReadValue($"{storeCode}_{spaceCode}", "在库数量");
spaceAddress.onRoute = iniHelper.IniReadValue($"{storeCode}_{spaceCode}", "在途数量");
spaceAddress.inStoreFinish = iniHelper.IniReadValue($"{storeCode}_{spaceCode}", "入库完成");
spaceAddress.outStoreFinish = iniHelper.IniReadValue($"{storeCode}_{spaceCode}", "出库完成");
return spaceAddress;
// spaceAddress.isFull = iniHelper.IniReadValue($"{storeCode}_{spaceCode}", "是否已满");
// spaceAddress.spaceStatus = iniHelper.IniReadValue($"{storeCode}_{spaceCode}", "货道状态");
// spaceAddress.storeStatus = iniHelper.IniReadValue($"{storeCode}_{spaceCode}", "仓库状态");
// spaceAddress.alarmInfo = iniHelper.IniReadValue($"{storeCode}_{spaceCode}", "报警信息");
}
}
public class SpaceAddress
{
public string storeCode;
public string spaceCode;
public string onStore { get; set; }
public string onRoute { get; set; }
public string inStoreFinish { get; set; }
public string outStoreFinish { get; set; }
// public string isFull { get; set; }
// public string spaceStatus { get; set; }
// public string storeStatus { get; set; }
// public string alarmInfo { get; set; }
}
}