| | |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public Results S7Write(int offsetAddr) |
| | | public Results S7Write(Isusing offsetAddr) |
| | | { |
| | | LogHelper.Info("S7Write 参数:" + offsetAddr, "WMSAPI"); |
| | | var res = S7Helper.S7Write(offsetAddr); |
| | |
| | | //LogHelper.Info($"拆托机货位{endLoc}不存在或已被锁"); |
| | | return; |
| | | } |
| | | //校验是否允许放货 |
| | | var plcDeviceTable = S7Helper.plcDeviceTables; |
| | | LogHelper.Info($"自动送托 拆托机{dev}:{plcDeviceTable.requestPut1}"); |
| | | if ((plcDeviceTable.requestPut1 && dev == "1") || |
| | |
| | | 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 }; |
| | | } |
| | | |
| | |
| | | if (reservoirs.type.Equals("RGV")) |
| | | { |
| | | LogHelper.Info($"RGV安全交互 请求点位:{model.STATION_NAME}请求码:{model.APPLY_CODE}"); |
| | | //根据ip读状态 |
| | | LogHelper.Info($"RGV安全交互缓存信号{JsonConvert.SerializeObject(plcDeviceTable.RGVAllowUnload)}"); |
| | | //处理信号 |
| | | var res = plcDeviceTable.RGVAllowUnload[reservoirs.code]; |
| | | var res =int.Parse(plcDeviceTable.RGVAllowUnload[reservoirs.code].ToString().Substring(1, 1)); |
| | | //根据ip读状态 |
| | | LogHelper.Info($"RGV安全交互缓存信号{res},{JsonConvert.SerializeObject(plcDeviceTable.RGVAllowUnload)}"); |
| | | //卸货请求进入 |
| | | if (model.APPLY_CODE.Equals("5")) |
| | | { |
| | |
| | | //卸货后已离开 |
| | | else if (model.APPLY_CODE.Equals("8")) |
| | | { |
| | | //发送卸货完成、复位信号 |
| | | safeAssistant(reservoirs.code,res); |
| | | LogHelper.Info($"RGV安全交互 卸货完成"); |
| | | return new safeResult() { code = "0", msg = "success" }; |
| | |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | //循环发送信号 |
| | | private static void safeAssistant(int code,int res) { |
| | | //2卸货完成确认 |
| | | if (res != 2) |
| | |
| | | if (db.Queryable<LocCntrRel>().Count(a => a.S_CNTR_CODE.Trim() == cntrCode) == 0) |
| | | { |
| | | var cir = new LocCntrRel { S_LOC_CODE = loc, S_CNTR_CODE = cntrCode}; |
| | | var con = new Container { S_CODE = cntrCode,N_DETAIL_COUNT = 1,C_FULL="0" }; |
| | | var con = new Container { S_CODE = cntrCode,N_DETAIL_COUNT = 1,C_FULL="2" };//默认满 主动绑定服务用 |
| | | db.Insertable<LocCntrRel>(cir).ExecuteCommand(); |
| | | db.Insertable<Container>(con).ExecuteCommand(); |
| | | if (!string.IsNullOrEmpty(itemCode)) |
| | | { |
| | | LogHelper.Info($"绑定容器参数:{JsonConvert.SerializeObject(con)}"); |
| | | ContainerHelper.BindCntrItem(cntrCode, itemCode, itemName); |
| | | //有物料的话就是满的 |
| | | con.C_FULL = "2"; |
| | | db.Updateable(con).UpdateColumns(it => it.C_FULL).ExecuteCommand(); |
| | | ////有物料的话就是满的 |
| | | //con.C_FULL = "2"; |
| | | //db.Updateable(con).UpdateColumns(it => it.C_FULL).ExecuteCommand(); |
| | | } |
| | | } |
| | | } |