| 123456789101112131415161718192021222324 |
- namespace SHJX.Service.Control.PortProduction.PortProducerImpl
- {
- public class ReadPortProducer : IPortProducer
- {
- private static readonly ConcurrentDictionary<ArgType, IPortArg> PortArgs = new();
- public ReadPortProducer(OptCommand command) : base(command) { }
- protected override IPortArg GetPortArg(ArgType type)
- {
- if (PortArgs.TryGetValue(type, out var port))
- {
- return port;
- }
- IPortArg portArg = type switch
- {
- ArgType.Read => new ReadPortArg(),
- ArgType.HeatRead => new HeatReadPortArg(),
- ArgType.Humiture=>new HumiturePortArg(),
- _ => throw new ArgumentException("未找到对应的枚举!")
- };
- PortArgs.TryAdd(type, portArg);
- return portArg;
- }
- }
- }
|