using 智能仓储WCS管理系统.ViewModel;
using Ping9719.WpfEx;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 智能仓储WCS管理系统
{
///
/// 设备监控
///
public class ExcelDeviceReadModel
{
public string 名称 { get; set; }
public string 组名 { get; set; }
public string 类型 { get; set; }
public string 地址 { get; set; }
public string 单位 { get; set; }
public static List GetDatas(string excelPath = null, string sheetName = "设备监控")
{
if (string.IsNullOrEmpty(excelPath))
excelPath = LocalFile.PlcDotPath;
return MiniExcelLibs.MiniExcel.Query(excelPath, sheetName)
.Where(o => !string.IsNullOrWhiteSpace(o.名称))
.Select(o => new DeviceReadModel()
{
Name = o.名称,
ExcelTag = o,
}).ToList();
}
}
///
/// 设备控制
///
public class ExcelDeviceWriteModel
{
public string 名称 { get; set; }
public string 组名 { get; set; }
public string 类型 { get; set; }
public string 读地址 { get; set; }
public string 写地址 { get; set; }
public string 点动切换 { get; set; }
public string 单位 { get; set; }
public static List GetDatas(string excelPath = null, string sheetName = "设备控制")
{
if (string.IsNullOrEmpty(excelPath))
excelPath = LocalFile.PlcDotPath;
return MiniExcelLibs.MiniExcel.Query(excelPath, sheetName)
.Where(o => !string.IsNullOrWhiteSpace(o.名称))
.Select(o => new DeviceWriteModel()
{
Name = o.名称,
ExcelTag = o,
}).ToList();
}
}
///
/// 设备气缸
///
public class ExcelDeviceUrnModel
{
public string 名称 { get; set; }
public string 组名 { get; set; }
public string 推地址 { get; set; }
public string 回地址 { get; set; }
public string 推到位地址 { get; set; }
public string 回到位地址 { get; set; }
public string 点动切换 { get; set; }
public static List GetDatas(string excelPath = null, string sheetName = "设备气缸")
{
if (string.IsNullOrEmpty(excelPath))
excelPath = LocalFile.PlcDotPath;
return MiniExcelLibs.MiniExcel.Query(excelPath, sheetName)
.Where(o => !string.IsNullOrWhiteSpace(o.名称))
.Select(o => new DeviceUrnModel()
{
Name = o.名称,
ExcelTag = o,
}).ToList();
}
}
///
/// 设备伺服
///
public class ExcelDeviceServoModel
{
public string 名称 { get; set; }
public string 组名 { get; set; }
public string 手动速度获取 { get; set; }
public string 手动速度设置 { get; set; }
public string 自动速度获取 { get; set; }
public string 自动速度设置 { get; set; }
public string 当前位置获取 { get; set; }
public string 位置点动加 { get; set; }
public string 位置点动减 { get; set; }
public string 位置移动 { get; set; }
public static List GetDatas(string excelPath = null, string sheetName = "设备伺服")
{
if (string.IsNullOrEmpty(excelPath))
excelPath = LocalFile.PlcDotPath;
return MiniExcelLibs.MiniExcel.Query(excelPath, sheetName)
.Where(o => !string.IsNullOrWhiteSpace(o.名称))
.Select(o => new DeviceServoModel()
{
Name = o.名称,
ExcelTag = o,
}).ToList();
}
}
///
/// 设备报警
///
public class ExcelDeviceAlarmModel
{
public string 名称 { get; set; }
public string 地址 { get; set; }
public string 类型 { get; set; }
public string 触发 { get; set; }
public string 级别 { get; set; }
public string 解决方式 { get; set; }
public static List GetDatas(string excelPath = null, string sheetName = "设备报警")
{
if (string.IsNullOrEmpty(excelPath))
excelPath = LocalFile.PlcDotPath;
return MiniExcelLibs.MiniExcel.Query(excelPath, sheetName).Where(o => !string.IsNullOrWhiteSpace(o.名称)).ToList();
}
///
/// 是否触发警报
///
public bool IsOnAlarm(object? val)
{
try
{
if (val == null)
return false;
string vs = val.ToString().ToLower();
if (类型.Trim().ToLower().Contains("bool"))
{
if (vs == 触发.Trim().ToLower())
return true;
else
return false;
}
else if (类型.Trim().ToLower().Contains("int"))
{
if (string.IsNullOrWhiteSpace(触发))
return false;
if (!触发.Contains(vs))
return false;
foreach (var item in 触发.Split(';'))
{
var kv = item.Split(':');
if (kv.Length != 2)
continue;
if (kv[0] == vs)
return true;
}
}
return false;
}
catch (Exception)
{
return false;
}
}
}
public class IotDevice
{
public static Action UserChange;
///
/// 控件名称
///
public string Name { get; set; }
///
/// 控件类型
///
public string Type { get; set; }
///
/// 控件值
///
public object Val { get; set; }
///
/// 功能
///
public string Funct { get; set; }
///
/// 操作方式(点动、切换)
///
public string Mode { get; set; }
}
}