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.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
using SlnMesnac.Plc ;
using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Text ;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* 版权所有 (c) 2024 WenJY 保留所有权利。
* CLR版本: 4.0.30319.42000
* 机器名称: LAPTOP-E0N2L34V
* 命名空间: SlnMesnac.Business.base
* 唯一标识: b00d95c1-a164-43a3-9f34-2a5d2efb3f34
*
* 创建者: WenJY
* 电子邮箱: wenjy@mesnac.com
* 创建时间: 2024-04-12 17:36:19
* 版本: V1.0.0
* 描述:
*
*--------------------------------------------------------------------
* 修改人:
* 时间:
* 修改说明:
*
* 版本: V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Business.@base
{
internal class BaseBusiness
{
private readonly List < PlcAbsractFactory > _plcFactories ;
public BaseBusiness ( List < PlcAbsractFactory > plcFactories )
{
_plcFactories = plcFactories ;
}
/// <summary>
/// 根据Key获取PLC连接信息
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="InvalidOperationException"></exception>
public PlcAbsractFactory GetPlcByKey ( string key )
{
if ( _plcFactories = = null )
{
throw new ArgumentNullException ( $"根据Key获取PLC连接信息异常:PLC 连接信息为空" ) ;
}
if ( string . IsNullOrEmpty ( key ) )
{
throw new ArgumentNullException ( "根据Key获取PLC连接信息异常:设备Key参数为空" ) ;
}
try
{
var info = _plcFactories . Where ( x = > x . ConfigKey = = key ) . FirstOrDefault ( ) ;
return info ;
} catch ( Exception ex )
{
throw new InvalidOperationException ( $"根据Key获取PLC连接信息异常:{ex.Message}" ) ;
}
}
}
}