| | |
| | | using Microsoft.Owin.BuilderProperties; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using Opc.Ua; |
| | | using S7.Net; |
| | | using S7.Net.Types; |
| | | using SqlSugar; |
| | |
| | | var db = new SqlHelper<WCSTask>().GetInstance(); |
| | | try |
| | | { |
| | | var linkplc = Settings.linePlcInfos.Find(a => a.enable == 1); |
| | | var plc = new Plc(CpuType.S71500, linkplc.address, 0, 1); |
| | | var linkplc = Settings.SafeInteractions.FindAll(a => a.code == 1|| a.code == 7).ToList(); |
| | | var plc = new Plc(CpuType.S71500, linkplc[1].ip, 0, 1); |
| | | Link(plc); |
| | | var plc1 = new Plc(CpuType.S71200, linkplc[0].ip, 0, 1); |
| | | Link(plc1); |
| | | //拆托机 |
| | | //object rawValue = plc.Read(DataType.DataBlock, 8, 230, VarType.Byte, 1); |
| | | //LogHelper.Info($"Raw value: {rawValue} (Type: {rawValue?.GetType()})"); |
| | |
| | | LogHelper.Info($"拆托机接收信号====={requestPut1},{requestTake1},{requestPut2},{requestTake2}"); |
| | | |
| | | //RGV |
| | | //var rawValue = plc1.Read(DataType.DataBlock, 51, 0, VarType.Int, 1); |
| | | //LogHelper.Info($"Raw value: {rawValue}, Type: {rawValue?.GetType()}"); |
| | | |
| | | // RGV允许卸货状态读取 (从DB51读取) |
| | | int rgv1AllowUnload = (int)plc.Read(DataType.DataBlock, 51, 0, VarType.Int, 1); |
| | | int rgv2AllowUnload = (int)plc.Read(DataType.DataBlock, 51, 2, VarType.Int, 1); |
| | | int rgv3AllowUnload = (int)plc.Read(DataType.DataBlock, 51, 4, VarType.Int, 1); |
| | | int rgv4AllowUnload = (int)plc.Read(DataType.DataBlock, 51, 6, VarType.Int, 1); |
| | | int rgv5AllowUnload = (int)plc.Read(DataType.DataBlock, 51, 8, VarType.Int, 1); |
| | | int rgv6AllowUnload = (int)plc.Read(DataType.DataBlock, 51, 10, VarType.Int, 1); |
| | | int rgv1AllowUnload = Convert.ToInt32(plc1.Read(DataType.DataBlock, 51, 0, VarType.Int, 1)); |
| | | int rgv2AllowUnload = Convert.ToInt32(plc1.Read(DataType.DataBlock, 51, 2, VarType.Int, 1)); |
| | | int rgv3AllowUnload = Convert.ToInt32(plc1.Read(DataType.DataBlock, 51, 4, VarType.Int, 1)); |
| | | int rgv4AllowUnload = Convert.ToInt32(plc1.Read(DataType.DataBlock, 51, 6, VarType.Int, 1)); |
| | | int rgv5AllowUnload = Convert.ToInt32(plc1.Read(DataType.DataBlock, 51, 8, VarType.Int, 1)); |
| | | int rgv6AllowUnload = Convert.ToInt32(plc1.Read(DataType.DataBlock, 51, 10, VarType.Int, 1)); |
| | | |
| | | LogHelper.Info($"RGV接收信号=== 1={rgv1AllowUnload}, 2={rgv2AllowUnload}, 3={rgv3AllowUnload}, 4={rgv4AllowUnload}, 5={rgv5AllowUnload}, 6={rgv6AllowUnload}"); |
| | | |
| | | //存到缓存 |
| | |
| | | } |
| | | |
| | | //S7写入信号 测试用 |
| | | internal static Results S7Write(int offsetAddr) |
| | | internal static Results S7Write(Isusing offsetAddr) |
| | | { |
| | | var linkplcs = Settings.linePlcInfos.Find(a => a.deviceNo == "1"); |
| | | var plc = new Plc(CpuType.S71500, linkplcs.address, 0, 1); |
| | | //var linkplcs = Settings.linePlcInfos.Find(a => a.deviceNo == "1"); |
| | | //var plc = new Plc(CpuType.S71200, linkplcs.address, 0, 1); |
| | | var linkplc = Settings.SafeInteractions.First(); |
| | | var plc = new Plc(CpuType.S71200, linkplc.ip, 0, 1); |
| | | Link(plc); |
| | | plc.WriteBit(DataType.DataBlock, 9, 182, offsetAddr, false); |
| | | S7Helper.WriteInt(50, 0, (short)(offsetAddr.S_STATUS * 10 + int.Parse(offsetAddr.S_TYPE))); |
| | | //plc.WriteBit(DataType.DataBlock, 9, 182, offsetAddr, false); |
| | | return new Results() { Code = "0", Message = $"写入成功", Data = null }; |
| | | } |
| | | |