public void ModbusLinkSuccess(string id, string message) { var device = Z; if (id == "从站") { device = C; } //GetDeviceParameter(device); // 心跳包保证链接 Task.Run(() => { while (device.Client != null && device.Client.Connected && device.IsSuccess) { device.F05(PLCSite.M(0), true, null); device.F03(PLCSite.D(0), 8, (data) => { _clients.All.SendAsync("LiveData", new { name = device.Name, data = ReceiveData.F03(data, 8) }); }); Thread.Sleep(10); } }); //if (_clients != null) //{ // _clients.All.SendAsync("Send", new { Id = id, Message = message }); //} }
/// <summary> /// 获取设备参数 /// </summary> public void GetDeviceParameter() { ModbusSocket device = Z; device.F03(PLCSite.D(500), 17, (data) => { _clients.All.SendAsync("DeviceParameter", new { name = device.Name, data = ReceiveData.F03(data, 17) }); }); }
public void F06(InPLC data) { if (data.Id == 1) { Z.F06(PLCSite.D(data.Address), data.F06, null); } else { C.F06(PLCSite.D(data.Address), data.F06, null); } }
public void DF03(InPLC data) { Z.F03(PLCSite.D(data.Address), data.F03, (rdata) => { _clients.All.SendAsync("F03Return", new { name = Z.Name, data = ReceiveData.F03(rdata, data.F03) }); }); C.F03(PLCSite.D(data.Address), data.F03, (rdata) => { _clients.All.SendAsync("F03Return", new { name = C.Name, data = ReceiveData.F03(rdata, data.F03) }); }); }
public Boolean SetDeviceParameter(SetDeviceParameterData data) { try { Z.F06(PLCSite.D(data.Address), data.Value, null); C.F06(PLCSite.D(data.Address), data.Value, null); return(true); } catch (Exception) { return(false); } }
public void Tension(TensionModle t) { if (t.Mode == 0 || t.Mode == 1) { Z.F06(PLCSite.D(410), t.A1, null); } if (t.Mode == 2 || t.Mode == 3) { Z.F06(PLCSite.D(411), t.B1, null); } if (t.Mode == 1) { C.F06(PLCSite.D(410), t.A2, null); } if (t.Mode == 3) { C.F06(PLCSite.D(411), t.B2, null); } if (t.Mode == 4) { Z.F16(PLCSite.D(410), new int[] { t.A1, t.B1 }, null); C.F16(PLCSite.D(410), new int[] { t.A2, t.B2 }, null); } }