|
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Controls;
-
- namespace BPASmartClient.MorkCL.Server
- {
- /// <summary>
- /// 其它服务类
- /// </summary>
- internal class OtherServer : OtherDeviceSet, IModbus
- {
- public void Init(string IP = "", int Port = 502, string PortName = "")
- {
- MyModbus = new ModbusRtu();
- MyModbus.WithModbusRtu(PortName).UseConnected(() =>
- {
- TaskManage.GetInstance.StartLong(new Action(() =>
- {
- MyModbus.Read<bool[]>("LB100".ToModbusAdd(), 4).OnSuccess(s =>
- {
- for (byte i = 0; i < s.Length; i++) BoxDetection[i] = s[i];
- });
-
- MyModbus.Read<float>("LW20".ToModbusAdd()).OnSuccess(s => { CurrentWeight = s; });
-
- Thread.Sleep(10);
- }), $"其它外部设备-{PortName}", true);
- });
- }
- }
- }
|