| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using System;
- using System.Threading;
- using SHJX.Service.Model.Control;
- using SHJX.Service.Common.ReadXML;
- using SHJX.Service.ServerClient.Interface;
- using SHJX.Service.ServerClient.TempController;
- using SHJX.Service.Common.Logging;
- using Microsoft.Extensions.Logging;
- namespace SHJX.Service.ServerClient.RS485Control
- {
-
- /// <summary>
- /// 升降台
- /// </summary>
- public class CagePort : SerialPortImp, PortControlImp
- {
- private static readonly ILogger logger = LogFactory.BuildLogger(typeof(CagePort));
- /// <summary>
- /// 升降台
- /// </summary>
- /// <param name="log">日志</param>
- /// <param name="config">配置</param>
- public CagePort( ReadConfigUtil config)
- : base( config) { }
- public object Read(PortArgs args)
- {
- object obj = args.ReadWay switch
- {
- "OriginalPosition" => JudgeStorage(args.NodeId),
- _ => throw new ArgumentNullException(args.ReadWay),
- };
- return obj;
- }
- public bool Write(PortArgs args)
- {
- (int address, string way)[] values = args.WriteWay switch
- {
- WriteWay.Normotopia => new[] { (1, "L"), (2, "H"), (3, "L") },
- WriteWay.Antiposition => new[] { (1, "L"), (3, "H"), (2, "L") },
- _ => throw new ArgumentNullException("None")
- };
- var result = true;
- for (var i = 0; i < values.Length; i++)
- {
- var res = MotorStorage(args.NodeId, values[i].address, values[i].way);
- result = result && res;
- }
- Thread.Sleep(5 * 1000);
- return result;
- }
- }
- }
|