Files
wcs/货架标准上位机/Models/ExcelDevice.cs
hehaibing-1996 e89b64ea3a !提交代码
2024-04-15 18:43:28 +08:00

214 lines
6.8 KiB
C#

using .ViewModel;
using Ping9719.WpfEx;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace
{
/// <summary>
/// 设备监控
/// </summary>
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<DeviceReadModel> GetDatas(string excelPath = null, string sheetName = "设备监控")
{
if (string.IsNullOrEmpty(excelPath))
excelPath = LocalFile.PlcDotPath;
return MiniExcelLibs.MiniExcel.Query<ExcelDeviceReadModel>(excelPath, sheetName)
.Where(o => !string.IsNullOrWhiteSpace(o.))
.Select(o => new DeviceReadModel()
{
Name = o.,
ExcelTag = o,
}).ToList();
}
}
/// <summary>
/// 设备控制
/// </summary>
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<DeviceWriteModel> GetDatas(string excelPath = null, string sheetName = "设备控制")
{
if (string.IsNullOrEmpty(excelPath))
excelPath = LocalFile.PlcDotPath;
return MiniExcelLibs.MiniExcel.Query<ExcelDeviceWriteModel>(excelPath, sheetName)
.Where(o => !string.IsNullOrWhiteSpace(o.))
.Select(o => new DeviceWriteModel()
{
Name = o.,
ExcelTag = o,
}).ToList();
}
}
/// <summary>
/// 设备气缸
/// </summary>
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<DeviceUrnModel> GetDatas(string excelPath = null, string sheetName = "设备气缸")
{
if (string.IsNullOrEmpty(excelPath))
excelPath = LocalFile.PlcDotPath;
return MiniExcelLibs.MiniExcel.Query<ExcelDeviceUrnModel>(excelPath, sheetName)
.Where(o => !string.IsNullOrWhiteSpace(o.))
.Select(o => new DeviceUrnModel()
{
Name = o.,
ExcelTag = o,
}).ToList();
}
}
/// <summary>
/// 设备伺服
/// </summary>
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<DeviceServoModel> GetDatas(string excelPath = null, string sheetName = "设备伺服")
{
if (string.IsNullOrEmpty(excelPath))
excelPath = LocalFile.PlcDotPath;
return MiniExcelLibs.MiniExcel.Query<ExcelDeviceServoModel>(excelPath, sheetName)
.Where(o => !string.IsNullOrWhiteSpace(o.))
.Select(o => new DeviceServoModel()
{
Name = o.,
ExcelTag = o,
}).ToList();
}
}
/// <summary>
/// 设备报警
/// </summary>
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<ExcelDeviceAlarmModel> GetDatas(string excelPath = null, string sheetName = "设备报警")
{
if (string.IsNullOrEmpty(excelPath))
excelPath = LocalFile.PlcDotPath;
return MiniExcelLibs.MiniExcel.Query<ExcelDeviceAlarmModel>(excelPath, sheetName).Where(o => !string.IsNullOrWhiteSpace(o.)).ToList();
}
/// <summary>
/// 是否触发警报
/// </summary>
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<IotDevice> UserChange;
/// <summary>
/// 控件名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 控件类型
/// </summary>
public string Type { get; set; }
/// <summary>
/// 控件值
/// </summary>
public object Val { get; set; }
/// <summary>
/// 功能
/// </summary>
public string Funct { get; set; }
/// <summary>
/// 操作方式(点动、切换)
/// </summary>
public string Mode { get; set; }
}
}