| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using TeamAAS.Motion.Interfaces;
- using TeamAAS.Motion.Models;
- using TeamAAS.Motion.Motions;
- namespace TeamAAS.Motion.AdapterFactorys
- {
- public interface IDeviceAdapterFactory
- {
- /// <summary>
- /// 工厂的唯一标识符,必须与配置文件中的 AdapterKey 完全匹配
- /// </summary>
- string Key { get; }
- /// <summary>
- /// 根据配置创建设备实例
- /// </summary>
- IMotionControl Create(MotionDeviceConfig config);
- }
- // 仿真卡工厂
- public class SimulatedDeviceFactory : IDeviceAdapterFactory
- {
- public string Key => "Simulated";
- public IMotionControl Create(MotionDeviceConfig config)
- => new SimulatedMotionCard(config);
- }
- // 汇川卡工厂
- public class InovanceDeviceFactory : IDeviceAdapterFactory
- {
- public string Key => "Inovance";
- public IMotionControl Create(MotionDeviceConfig config)
- {
- // 实例化汇川卡,使用 config.ConnectionString 等参数
- return new InovanceMotionCard(config);
- }
- }
- // 雷赛卡工厂
- public class LeadshineDeviceFactory : IDeviceAdapterFactory
- {
- public string Key => "Leadshine";
- public IMotionControl Create(MotionDeviceConfig config)
- {
- // 实例化雷赛卡,使用 config.ConnectionString 等参数
- return new LeadshineMotionCard(config);
- }
- }
- }
|