/// <summary> /// 下发堆垛机库外取放货任务 相对于站台来说的 /// </summary> /// <param name="stocker"></param> /// <param name="plc"></param> /// <param name="task"></param> /// <param name="taskEntityStatus"></param> /// <param name="forkTaskFlag"></param> /// <param name="station"></param> /// <returns></returns> protected BllResult SendTaskToStation(Equipment stocker, IPLC plc, TaskEntity task, TaskEntityStatus taskEntityStatus, SRMForkTaskFlag forkTaskFlag, Equipment station, int tempStatus) { task.TaskStatus = taskEntityStatus.GetIndexInt(); //task.ArrivaEquipmentCode = stocker.Code; var tempResult = AppSession.Dal.UpdateCommonModel <TaskEntity>(task); if (tempResult.Success) { BllResult sendResult = SendTaskToStocker(stocker, plc, SRMForkAction.货叉1号, forkTaskFlag, "0", "0", "0", station.StationIndex.ToString(), task.Id.ToString()); if (sendResult.Success) { Logger.Log($"下发堆垛机{stocker.Name},任务:{task.Id},任务类型:{task.TaskType},货叉类型:{forkTaskFlag}成功,接货站台为:{station.Name}", LogLevel.Success); return(BllResultFactory.Sucess()); } else { Logger.Log($"下发堆垛机{stocker.Name},任务:{task.Id},任务类型:{task.TaskType},货叉类型:{forkTaskFlag}失败:{sendResult.Msg};回滚任务{task.Id}状态。", LogLevel.Error); //回滚任务状态,记录日志 task.TaskStatus = tempStatus; //task.ArriveEquipmentCode = tempGateway; AppSession.Dal.UpdateCommonModel <TaskEntity>(task); return(BllResultFactory.Error()); } } else { Logger.Log($"下发堆垛机{stocker.Name},任务:{task.Id},任务类型:{task.TaskType},货叉类型:{forkTaskFlag}失败,更新任务{task.Id}状态失败:{tempResult.Msg};任务未下发", LogLevel.Error); return(BllResultFactory.Error($"下发堆垛机{stocker.Name}库外放货时,更新任务{task.Id}状态失败:{tempResult.Msg}")); } }
private void BtnConnect_Click(object sender, RoutedEventArgs e) { List <S7PLCHelper> list = new List <S7PLCHelper>(); foreach (var item in Equipments) { list.Add(new S7PLCHelper() { PLCIP = item.IP, PLCType = PLCType.S7_1500.ToString() }); } plc?.DisConnect(); plc = new S7Implement() { S7PLCHelpers = list }; var temp = plc.Connect(); if (temp.Success) { MessageBox.Show("连接成功"); } else { MessageBox.Show($"连接失败:{temp.Msg}"); } }
/// <summary> /// 发送小车任务,行:1.打标 2.坡口短缓存架 3.坡口长缓存架 4.坡口短缓存架 5.坡口机 6.组队输送架 /// </summary> /// <param name="car"></param> /// <param name="plc"></param> /// <param name="task"></param> /// <returns></returns> public BllResult SendTaskToCar(Equipment car, CarTask task, IPLC plc) { try { List <EquipmentProp> propsToWriter = new List <EquipmentProp>(); var props = car.EquipmentProps; var wcsConfirmTaskFinish = props.Find(t => t.EquipmentTypeTemplateCode == CarProps.wcsConfirmTaskFinish.ToString()); wcsConfirmTaskFinish.Value = "0"; var wcsActionType = props.Find(t => t.EquipmentTypeTemplateCode == CarProps.wcsActionType.ToString()); wcsActionType.Value = task.Type.ToString(); var wcsStartRow = props.Find(t => t.EquipmentTypeTemplateCode == CarProps.wcsStartRow.ToString()); wcsStartRow.Value = task.FromLocation.ToString(); var wcsDestinationRow = props.Find(t => t.EquipmentTypeTemplateCode == CarProps.wcsDestinationRow.ToString()); wcsDestinationRow.Value = task.ToLocation.ToString(); var wcsTaskHeaderId = props.Find(t => t.EquipmentTypeTemplateCode == CarProps.wcsTaskHeaderId.ToString()); wcsTaskHeaderId.Value = task.StepTraceId.ToString(); var wcsTaskCarId = props.Find(t => t.EquipmentTypeTemplateCode == CarProps.wcsTaskCarId.ToString()); wcsTaskCarId.Value = task.Id.ToString(); var wcsSwitch = props.Find(t => t.EquipmentTypeTemplateCode == CarProps.wcsSwitch.ToString()); wcsSwitch.Value = "1"; propsToWriter.AddRange(new List <EquipmentProp>() { wcsConfirmTaskFinish, wcsStartRow, wcsDestinationRow, wcsTaskHeaderId, wcsTaskCarId, wcsActionType, wcsSwitch }); //return S7Helper.PlcSplitWrite(plc, propsToWriter, 20); return(plc.Writes(propsToWriter)); } catch (Exception ex) { return(BllResultFactory.Error(ex.Message)); } }
/// <summary> /// 中船项目发送定长切割处理 /// </summary> /// <param name="machine">切割机</param> /// <param name="plc">目标plc</param> /// <param name="WCSCutMaterialID">原材料ID</param> /// <param name="WCSCutMaterialLength">原材料长度</param> /// <param name="WCSCutDiameter">原材料直径</param> /// <param name="WCSCutThickness">原材料壁厚</param> /// <param name="WCSCutLength">切断长</param> /// <param name="WCSCutPipeEnd">管端</param> /// <param name="WCSCutAssemblyStation">下料工位</param> /// <returns></returns> protected BllResult SendCutToPlcZC(Equipment machine, IPLC plc, int i, int WCSCutMaterialID, int WCSCutMaterialLength, int WCSCutDiameter, int WCSCutThickness, int WCSCutLength, int WCSCutPipeEnd, int WCSCutAssemblyStation) { List <EquipmentProp> props = null; var prop1 = machine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == "WCSCutMaterialID_" + i.ToString()); prop1.Value = WCSCutMaterialID.ToString(); var prop2 = machine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == "WCSCutMaterialLength_" + i.ToString()); prop2.Value = WCSCutMaterialLength.ToString(); var prop3 = machine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == "WCSCutDiameter_" + i.ToString()); prop3.Value = (WCSCutDiameter * 10).ToString(); var prop4 = machine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == "WCSCutThickness_" + i.ToString()); prop4.Value = (WCSCutThickness * 10).ToString(); var prop5 = machine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == "WCSCutLength_" + i.ToString()); prop5.Value = WCSCutLength.ToString(); var prop6 = machine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == "WCSCutPipeEnd_" + i.ToString()); prop6.Value = WCSCutPipeEnd.ToString(); var prop7 = machine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == "WCSCutAssemblyStation_" + i.ToString()); prop7.Value = WCSCutAssemblyStation.ToString(); props = new List <EquipmentProp> { prop1, prop2, prop3, prop4, prop5, prop6, prop7 }; BllResult plcResult = plc.Writes(props); return(plcResult); }
/// <summary> /// 清理WCS交换区 /// </summary> /// <param name="srm"></param> /// <param name="plc"></param> /// <returns></returns> public BllResult ClearWCSData(Equipment truss, IPLC plc) { //var rowIndex1 = truss.RowIndex1; //var rowIndex2 = truss.RowIndex2; //truss.RowIndex1 = 0; //truss.RowIndex2 = 0; //var updateResult = AppSession.Dal.UpdateCommonModel<Equipment>(truss); //if (updateResult.Success) //{ //表示桁车已经收到WCS发送给他的任务完成信号,此时WCS可以清除自己的交换区地址 BllResult sendResult = SendTaskToTruss(truss, plc, TrussTaskFlag.无任务, "0", "0", "0", "0", "0"); if (sendResult.Success) { Logger.Log($"任务完成后,清除桁车{truss.Name}交换区地址成功", LogLevel.Info); return(BllResultFactory.Sucess()); } else { //truss.RowIndex1 = rowIndex1; //truss.RowIndex2 = rowIndex2; //AppSession.Dal.UpdateCommonModel<Equipment>(truss); Logger.Log($"任务完成后,清除桁车{truss.Name}交换区地址失败, 原因:${sendResult.Msg}", LogLevel.Error); return(BllResultFactory.Error()); } //} //Logger.Log($"任务完成后,清除桁车{truss.Name}交换区地址失败,更新桁车路径数据失败,原因{updateResult.Msg}", LogLevel.Error); //return BllResultFactory.Error(); }
/// <summary> /// 心跳 /// </summary> /// <param name="srm"></param> /// <param name="plc"></param> public BllResult Heartbeat(Equipment srm, IPLC plc) { var prop = srm.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == TrussNormalProps.WCSHeartBeat.ToString()); if (prop.Value == "1") { prop.Value = "0"; } else { prop.Value = "1"; } var result = plc.Writes(new List <EquipmentProp>() { prop }); if (result.Success) { return(BllResultFactory.Sucess()); } else { Logger.Log($"发送桁车{srm.Name}心跳数据失败:{result.Msg}", LogLevel.Error); return(BllResultFactory.Error()); } }
/// <summary> /// 下发数据到桁车 /// </summary> /// <param name="truss"></param> /// <param name="plc"></param> /// <param name="taskFlag"></param> /// <param name="productId"></param> /// <param name="position"></param> /// <param name="taskNo"></param> /// <returns></returns> public BllResult SendTaskToTruss(Equipment truss, IPLC plc, TrussTaskFlag taskFlag, string productId, string stationId, string wcsLine, string wcsLayer, string taskNo) { try { List <EquipmentProp> propsToWriter = new List <EquipmentProp>(); var props = truss.EquipmentProps; var WCSProductId = props.Find(t => t.EquipmentTypeTemplateCode == TrussNormalProps.WCSProductId.ToString()); WCSProductId.Value = productId; var WCSStationId = props.Find(t => t.EquipmentTypeTemplateCode == TrussNormalProps.WCSStationId.ToString()); WCSStationId.Value = stationId; var WCSLine = props.Find(t => t.EquipmentTypeTemplateCode == TrussNormalProps.WCSLine.ToString()); WCSLine.Value = wcsLine; var WCSLayer = props.Find(t => t.EquipmentTypeTemplateCode == TrussNormalProps.WCSLayer.ToString()); WCSLayer.Value = wcsLayer; var WCSTaskNo = props.Find(t => t.EquipmentTypeTemplateCode == TrussNormalProps.WCSTaskNo.ToString()); WCSTaskNo.Value = taskNo; var WCSForkAction = props.Find(t => t.EquipmentTypeTemplateCode == TrussNormalProps.WCSForkAction.ToString()); WCSForkAction.Value = TrussForkAction.一号机械手.GetIndexString(); var WCSTaskFlag = props.Find(t => t.EquipmentTypeTemplateCode == TrussNormalProps.WCSTaskFlag.ToString()); WCSTaskFlag.Value = taskFlag.GetIndexString(); propsToWriter.AddRange(new List <EquipmentProp>() { WCSProductId, WCSStationId, WCSLine, WCSLayer, WCSTaskNo, WCSForkAction, WCSTaskFlag }); return(plc.Writes(propsToWriter)); } catch (Exception ex) { return(BllResultFactory.Error($"写入plc失败,下发任务出现异常:{ex.Message}")); } }
/// <summary> /// 写入或清除 ECS允许上料信号,True为写入,False为清除 /// </summary> /// <param name="plc"></param> /// <param name="robot"></param> /// <param name="result"></param> /// <returns></returns> protected BllResult SendLoadReadyToPlc(bool load_Ready, Equipment robot, IPLC plc, int pipeMaterial, int pipeLength, decimal pipeDiameter, decimal pipeThickness) { var operate = load_Ready ? "写入" : "清除"; var status = load_Ready ? MachineMessageFlag.WCS回复允许上料.GetIndexString() : MachineMessageFlag.默认.GetIndexString(); var WCSACKMessage = robot.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKMessage.ToString()); var WCS_Pipe_Material = robot.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKMaterial.ToString()); var WCS_Pipe_Length = robot.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKLength.ToString()); var WCS_Pipe_Diameter = robot.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKDiameter.ToString()); var WCS_Pipe_Thickness = robot.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKThickness.ToString()); WCS_Pipe_Material.Value = pipeMaterial.ToString(); WCS_Pipe_Length.Value = pipeLength.ToString(); WCS_Pipe_Diameter.Value = pipeDiameter.ToString(); WCS_Pipe_Thickness.Value = pipeThickness.ToString(); WCSACKMessage.Value = status.ToString(); var propsToWriter = new List <EquipmentProp> { WCSACKMessage, WCS_Pipe_Material, WCS_Pipe_Length, WCS_Pipe_Diameter, WCS_Pipe_Thickness }; BllResult plcResult = plc.Writes(propsToWriter); if (plcResult.Success) { Logger.Log($"{operate}设备【{robot.Name}】上料准备完成 信号成功", LogLevel.Success); } else { Logger.Log($"{operate}设备【{robot.Name}】上料准备完成 信号失败,写入PLC失败:原因:{plcResult.Msg}", LogLevel.Error); } return(plcResult); }
public BllResult SendCleanTaskToCar(Equipment car, CarTask task, IPLC plc) { try { List <EquipmentProp> propsToWriter = new List <EquipmentProp>(); var props = car.EquipmentProps; var action = props.Find(t => t.EquipmentTypeTemplateCode == "wcsActionType"); action.Value = "0"; var taskRow = props.Find(t => t.EquipmentTypeTemplateCode == "wcsTaskRow"); taskRow.Value = "0"; //var taskLine = props.Find(t => t.EquipmentTypeTemplateCode == "wcsTaskLine"); //taskLine.Value = "0"; //var taskLayer = props.Find(t => t.EquipmentTypeTemplateCode == "wcsTaskLayer"); //taskLayer.Value = "0"; var taskHeader = props.Find(t => t.EquipmentTypeTemplateCode == "wcsTaskHeaderId"); taskHeader.Value = "0"; var taskCar = props.Find(t => t.EquipmentTypeTemplateCode == "wcsTaskCarId"); taskCar.Value = "0"; var switchEnable = props.Find(t => t.EquipmentTypeTemplateCode == "wcsSwitch"); switchEnable.Value = "0"; var hasPallet = props.Find(t => t.EquipmentTypeTemplateCode == "hasPallet"); hasPallet.Value = "1"; propsToWriter.AddRange(new List <EquipmentProp>() { action, taskRow, taskHeader, taskCar, switchEnable, hasPallet }); //return S7Helper.PlcSplitWrite(plc, propsToWriter, 20); return(plc.Writes(propsToWriter)); } catch (Exception ex) { return(BllResultFactory.Error(ex.Message)); } }
/// <summary> /// 发送穿梭车的信息 /// </summary> /// <param name="car">穿梭车</param> /// <param name="plc">plc</param> /// <param name="carActionType">小车执行的动作类型</param> /// <param name="carRow">行</param> /// <param name="carColumn">列</param> /// <param name="carLayer">层</param> /// <param name="taskHeaderId">任务-关联WCS的TaskHeader表格</param> /// <param name="taskCarId">子任务</param> /// <returns></returns> public BllResult SendTaskToCar(Equipment car, IPLC plc, CarActionType carActionType, string carRow, string carColumn, string carLayer, string taskHeaderId, string taskCarId) { try { List <EquipmentProp> propsToWriter = new List <EquipmentProp>(); var props = car.EquipmentProps; var action = props.Find(t => t.EquipmentTypeTemplateCode == "wcsActionType"); action.Value = carActionType.GetIndexString(); var taskRow = props.Find(t => t.EquipmentTypeTemplateCode == "wcsRow"); taskRow.Value = carRow; var taskLine = props.Find(t => t.EquipmentTypeTemplateCode == "wcsLine"); taskLine.Value = carColumn; var taskLayer = props.Find(t => t.EquipmentTypeTemplateCode == "wcsLayer"); taskLayer.Value = carLayer; var taskHeader = props.Find(t => t.EquipmentTypeTemplateCode == "wcsTaskHeaderId"); taskHeader.Value = taskHeaderId; var taskCar = props.Find(t => t.EquipmentTypeTemplateCode == "wcsTaskCarId"); taskCar.Value = taskCarId; var switchEnable = props.Find(t => t.EquipmentTypeTemplateCode == "wcsSwitch"); switchEnable.Value = "1"; propsToWriter.AddRange(new List <EquipmentProp>() { action, taskHeader, taskCar, taskRow, taskLine, taskLayer, switchEnable }); //return S7Helper.PlcSplitWrite(plc, propsToWriter, 20); return(plc.Writes(propsToWriter)); } catch (Exception ex) { return(BllResultFactory.Error(ex.Message)); } }
/// <summary> /// 下发库内取货与放货任务 相对于库位来说 /// </summary> /// <param name="srm"></param> /// <param name="plc"></param> /// <param name="task"></param> /// <param name="tempFirstStatus"></param> /// <param name="tempStatus"></param> /// <param name="tempGateway"></param> /// <param name="tempLocation"></param> /// <returns></returns> protected BllResult SendTaskToLocation(Equipment srm, IPLC plc, TaskEntity task, Location tempLocation, TaskEntityStatus taskEntityStatus, SRMForkTaskFlag forkTaskFlag, int tempStatus) { task.TaskStatus = taskEntityStatus.GetIndexInt(); var tempResult = AppSession.Dal.UpdateCommonModel <TaskEntity>(task); if (tempResult.Success) { // short rowIndex = srm.Code == tempLocation.SrmCode ? tempLocation.RowIndex1.Value : tempLocation.RowIndex2.Value; short rowIndex = 0; BllResult sendResult = SendTaskToSRM(srm, plc, SRMForkAction.货叉1号, forkTaskFlag, rowIndex.ToString(), tempLocation.Line.ToString(), tempLocation.Layer.ToString(), "0", task.Id.ToString()); if (sendResult.Success) { Logger.Log($"下发堆垛机{srm.Name},任务:{task.Id},任务类型:{task.TaskType},货叉类型:{forkTaskFlag}成功,目标库位:{tempLocation.Code}", LogLevel.Success); return(BllResultFactory.Sucess()); } else { Logger.Log($"下发堆垛机{srm.Name},任务:{task.Id},任务类型:{task.TaskType},货叉类型:{forkTaskFlag}失败:{sendResult.Msg};回滚任务{task.Id}状态。", LogLevel.Error); //回滚任务状态,记录日志 task.TaskStatus = tempStatus; AppSession.Dal.UpdateCommonModel <TaskEntity>(task); return(BllResultFactory.Error()); } } else { Logger.Log($"下发堆垛机{srm.Name},任务:{task.Id},任务类型:{task.TaskType},货叉类型:{forkTaskFlag}失败,更新任务{task.Id}状态失败:{tempResult.Msg};任务未下发", LogLevel.Error); return(BllResultFactory.Error($"下发堆垛机{srm.Name}{forkTaskFlag},更新任务{task.Id}状态失败:{tempResult.Msg}")); } }
/// <summary> /// 写入或清除 任务信息 /// 到达处理 /// </summary> /// <param name="plc"></param> /// <param name="cutter"></param> /// <param name="product">是否生产,true为生产,false为清除</param> /// <param name="result"></param> /// <returns></returns> protected BllResult SendStepTraceToPlc(IPLC plc, Equipment cutter, bool allow, string wcsStepTraceId, int pipeMaterial, int pipeLength, int pipeDiameter, int pipeThickness) { var operate = allow ? "写入" : "清除"; var status = allow ? StationMessageFlag.地址回复.GetIndexString() : StationMessageFlag.默认.GetIndexString(); var WCSReplyMessage = cutter.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSReplyMessage.ToString()); var WCS_Allow_Load = cutter.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKMessage.ToString()); var WCSACKTaskId = cutter.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKTaskId.ToString()); var WCS_Pipe_Material = cutter.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKMaterial.ToString()); var WCS_Pipe_Length = cutter.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKLength.ToString()); var WCS_Pipe_Diameter = cutter.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKDiameter.ToString()); var WCS_Pipe_Thickness = cutter.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKThickness.ToString()); WCS_Pipe_Material.Value = pipeMaterial.ToString(); WCS_Pipe_Length.Value = pipeLength.ToString(); WCS_Pipe_Diameter.Value = pipeDiameter.ToString(); WCS_Pipe_Thickness.Value = pipeThickness.ToString(); WCSReplyMessage.Value = status.ToString(); WCSACKTaskId.Value = wcsStepTraceId; var propsToWriter = new List <EquipmentProp> { WCS_Allow_Load, WCSACKTaskId, WCS_Pipe_Material, WCS_Pipe_Length, WCS_Pipe_Diameter, WCS_Pipe_Thickness }; return(plc.Writes(propsToWriter)); }
/// <summary> /// 下发数据到WCS交换区 /// </summary> /// <param name="stocker"></param> /// <param name="plc"></param> /// <param name="forkAction"></param> /// <param name="forkTaskFlag"></param> /// <param name="forkRow"></param> /// <param name="forkColumn"></param> /// <param name="forkLayer"></param> /// <param name="forkStation"></param> /// <param name="taskNo"></param> /// <returns></returns> public BllResult SendTaskToStocker(Equipment stocker, IPLC plc, SRMForkAction forkAction, SRMForkTaskFlag forkTaskFlag, string forkRow, string forkColumn, string forkLayer, string forkStation, string taskNo) { try { List <EquipmentProp> propsToWriter = new List <EquipmentProp>(); var props = stocker.EquipmentProps; var action = props.Find(t => t.EquipmentTypeTemplateCode == SRMProps.WCSForkAction.ToString()); action.Value = forkAction.GetIndexString(); var taskFlag = props.Find(t => t.EquipmentTypeTemplateCode == SRMProps.WCSFork1TaskFlag.ToString()); taskFlag.Value = forkTaskFlag.GetIndexString(); var row = props.Find(t => t.EquipmentTypeTemplateCode == SRMProps.WCSFork1Row.ToString()); row.Value = forkRow; var column = props.Find(t => t.EquipmentTypeTemplateCode == SRMProps.WCSFork1Column.ToString()); column.Value = forkColumn; var layer = props.Find(t => t.EquipmentTypeTemplateCode == SRMProps.WCSFork1Layer.ToString()); layer.Value = forkLayer; var station = props.Find(t => t.EquipmentTypeTemplateCode == SRMProps.WCSFork1Station.ToString()); station.Value = forkStation; var task = props.Find(t => t.EquipmentTypeTemplateCode == SRMProps.WCSFork1Task.ToString()); task.Value = taskNo; propsToWriter.AddRange(new List <EquipmentProp>() { action, taskFlag, row, column, layer, station, task }); return(plc.Writes(propsToWriter)); } catch (Exception ex) { return(BllResultFactory.Error($"下发任务出现异常:{ex.Message}")); } }
/// <summary> /// 打标请求处理 /// </summary> /// <param name="machine"></param> /// <param name="flipFlag"></param> /// <param name="plc"></param> /// <returns></returns> protected BllResult SendPintToPlc(Equipment machine, IPLC plc, PrintFlag wcsPint) { var WCSPint = machine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSPint.ToString()); WCSPint.Value = wcsPint.GetIndexString(); BllResult plcResult = plc.Write(WCSPint); return(plcResult); }
/// <summary> /// 翻转请求处理 /// </summary> /// <param name="machine"></param> /// <param name="flipFlag"></param> /// <param name="plc"></param> /// <returns></returns> protected BllResult SendFlipToPlc(Equipment machine, IPLC plc, FlipFlag wcsAllowFlip) { var WCSAllowFlip = machine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSAllowFlip.ToString()); WCSAllowFlip.Value = wcsAllowFlip.GetIndexString(); BllResult plcResult = plc.Write(WCSAllowFlip); return(plcResult); }
/// <summary> /// 位置到达回复 /// </summary> /// <param name="machine"></param> /// <param name="plc"></param> /// <param name="message"></param> /// <param name="loadStatus"></param> /// <param name="number"></param> /// <param name="backup"></param> /// <returns></returns> public BllResult SendAckToPlc(Equipment machine, IPLC plc, MachineMessageFlag messageFlag, string number, string taskId, string barcode, string requestProductId, string pipeMaterial, string pipeLength, string pipeDiameter, string pipeThickness, string address) { pipeDiameter = (Convert.ToInt32(decimal.Parse(pipeDiameter) * 10)).ToString(); pipeThickness = (Convert.ToInt32(decimal.Parse(pipeThickness) * 10)).ToString(); List <EquipmentProp> props = null; var prop1 = machine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKMessage.ToString()); prop1.Value = messageFlag.GetIndexString(); var prop2 = machine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKNumber.ToString()); prop2.Value = number; var prop3 = machine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKTaskId.ToString()); prop3.Value = taskId; var prop4 = machine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKBarcode.ToString()); prop4.Value = barcode; var prop5 = machine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKProductId.ToString()); prop5.Value = requestProductId; var prop6 = machine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKMaterial.ToString()); prop6.Value = pipeMaterial; var prop7 = machine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKLength.ToString()); prop7.Value = pipeLength; var prop8 = machine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKDiameter.ToString()); prop8.Value = pipeDiameter; var prop9 = machine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKThickness.ToString()); prop9.Value = pipeThickness; var prop10 = machine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSReplyAddress.ToString()); prop10.Value = address; if (messageFlag == MachineMessageFlag.默认) { props = new List <EquipmentProp>() { prop1, prop2, prop3, prop4, prop5, prop6, prop7, prop8, prop9, prop10 }; } else { props = new List <EquipmentProp>() { prop2, prop3, prop4, prop5, prop6, prop7, prop8, prop9, prop10, prop1 }; } return(plc.Writes(props)); }
/// <summary> /// 实现到达清除 /// </summary> /// <param name="plc"></param> /// <param name="station"></param> /// <param name="result"></param> /// <returns></returns> private BllResult ExcuteArriveClear(IPLC plc, Equipment station) { var result = SendAckToPlcForInOrOut(station, plc, StationMessageFlag.默认, StationLoadStatus.默认, "0", "0"); if (result.Success) { return(BllResultFactory.Sucess($"站台{station.Name}响应位置到达完成后,清除WCS地址区成功")); } else { return(BllResultFactory.Error($"站台{station.Name}响应位置到达完成后,清除WCS地址区失败")); } }
/// <summary> /// 执行清除请求 /// </summary> /// <param name="station"></param> /// <param name="plc"></param> /// <returns></returns> public BllResult ExcuteRequestClear(Equipment station, IPLC plc) { var result = SendAddressReplyToPlc(station, plc, StationMessageFlag.默认, StationLoadStatus.默认, "0", "0", "0", "0", "0", "0", "0", "0"); if (result.Success) { return(BllResultFactory.Sucess($"站台{station.Name}响应地址请求完成后,清除WCS地址区成功")); } else { return(BllResultFactory.Error($"站台{station.Name}响应地址请求完成后,清除WCS地址区失败")); } }
/// <summary> /// 地址请求清除 /// </summary> /// <param name="machine"></param> /// <param name="plc"></param> /// <returns></returns> public BllResult ExcuteRequestClear(Equipment machine, IPLC plc) { var result = SendAddressReplyToPlc(machine, plc, MachineMessageFlag.默认, "0", "0", "", "0", "0", "0", "0", "0", "0"); if (result.Success) { return(BllResultFactory.Sucess($"处理工位[{machine.StationCode}]对应的设备[{machine.Name}]响应地址请求完成后,清除WCS地址区成功")); } else { return(BllResultFactory.Error($"处理工位[{machine.StationCode}]对应的设备[{machine.Name}]响应地址请求完成后,清除WCS地址区失败")); } }
public ThreadingTest(string IP, string addr, IPLC PLCTextBox) { isFirst = true; timer1.Elapsed += timer1_Elapsed; _PLCDriver = PLCTextBox; this._IP = IP; _Addr = addr; AsyncMultiDBStart(); Name = "单线程多DB块同时读取,地址:" + _Addr + "PLC IP:" + IP + "\r\n"; timer1.Interval = 3000; timer1.Start(); }
/// <summary> /// 位置到达清除 /// </summary> /// <param name="plc"></param> /// <param name="machine"></param> /// <param name="result"></param> /// <returns></returns> private BllResult ExcuteArriveClear(Equipment machine, IPLC plc) { var result = SendAckToPlc(machine, plc, MachineMessageFlag.默认, "0", "0", "", "0", "0", "0", "0", "0", "0"); if (result.Success) { return(BllResultFactory.Sucess($"处理工位[{machine.StationCode}]对应的设备[{machine.Name}]响应位置到达完成后,清除WCS地址区成功")); } else { return(BllResultFactory.Error($"处理工位[{machine.StationCode}]对应的设备[{machine.Name}]响应位置到达完成后,清除WCS地址区失败")); } }
/// <summary> /// 切割请求清除 /// </summary> /// <param name="machine"></param> /// <param name="plc"></param> /// <returns></returns> public BllResult ExcuteCutClear(Equipment machine, IPLC plc) { var result = SendCutToPlc(machine, plc, CutFlag.默认, "0", "0", "0", "0", "0"); if (result.Success) { return(BllResultFactory.Sucess($"处理工位[{machine.StationCode}]对应的设备[{machine.Name}]响应切割请求完成后,清除WCS响应切割信息成功")); } else { return(BllResultFactory.Error($"处理工位[{machine.StationCode}]对应的设备[{machine.Name}]响应切割请求完成后,清除WCS响应切割信息失败")); } }
private PLC() { ServerFactory.CreatePLCServer(); myPlcA = PLCServers.GetServer("Crane1"); myPlcA.StartScan(); myPlcB = PLCServers.GetServer("Crane2"); myPlcB.StartScan(); myPlcC = PLCServers.GetServer("C"); //myPlcC.StartScan(); }
/// <summary> /// 地址请求时,回退 /// </summary> /// <param name="station"></param> /// <param name="plc"></param> /// <param name="barcode"></param> public void SendBack(Equipment station, IPLC plc, string barcode) { var result = SendAddressReplyToPlc(station, plc, StationMessageFlag.地址回复, StationLoadStatus.默认, station.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == StationProps.RequestNumber.ToString()).Value, barcode, station.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == StationProps.RequestWeight.ToString()).Value, station.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == StationProps.RequestLength.ToString()).Value, station.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == StationProps.RequestWidth.ToString()).Value, station.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == StationProps.RequestHeight.ToString()).Value, station.BackAddress, ""); LogResult(result); }
/// <summary> /// 写入或清除 任务信息 /// </summary> /// <param name="plc"></param> /// <param name="robot"></param> /// <param name="product">是否生产,true为生产,false为清除</param> /// <param name="result"></param> /// <returns></returns> protected BllResult SendStepTraceToPlc(IPLC plc, Equipment machineTool, bool wcsAllowLoad, string wcsStepTraceId) { var WCS_Allow_Load = machineTool.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == EcsToMachineToolPorps.WCS_Allow_Load.ToString()); var WCS_Step_Trace_Id = machineTool.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == EcsToMachineToolPorps.WCS_Step_Trace_Id.ToString()); WCS_Allow_Load.Value = wcsAllowLoad.ToString(); WCS_Step_Trace_Id.Value = wcsStepTraceId; var propsToWriter = new List <EquipmentProp> { WCS_Allow_Load, WCS_Step_Trace_Id }; return(plc.Writes(propsToWriter)); }
protected IO Register(IPLC plc, ICollection <Door> doors, Notifier engineUpNotifier, Notifier engineDownNotifier) { IO io = new IO( plc, new IOContext( doors, engineUpNotifier, engineDownNotifier ) ); return(io); }
/// <summary> /// 翻转请求清除 /// </summary> /// <param name="machine"></param> /// <param name="plc"></param> /// <returns></returns> public BllResult ExcuteFlipClear(Equipment machine, IPLC plc) { var result = SendFlipToPlc(machine, plc, FlipFlag.默认); if (result.Success) { return(BllResultFactory.Sucess($"处理工位[{machine.StationCode}]对应的设备[{machine.Name}]响应翻转请求完成后,清除WCS响应翻转信息成功")); } else { return(BllResultFactory.Error($"处理工位[{machine.StationCode}]对应的设备[{machine.Name}]响应翻转请求完成后,清除WCS响应翻转信息失败")); } }
/// <summary> /// 地址请求回复 /// </summary> /// <param name="pipeLine"></param> /// <param name="plc"></param> /// <param name="message"></param> /// <param name="loadStatus"></param> /// <param name="number"></param> /// <param name="barcode"></param> /// <param name="weight"></param> /// <param name="lenght"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="address"></param> /// <param name="backup"></param> /// <returns></returns> public BllResult SendAddressReplyToPlc(Equipment pipeLine, IPLC plc, StationMessageFlag messageFlag, StationLoadStatus loadStatus, string number, string taskId, string barcode, string pipeMaterial, string pipeLength, string pipeDiameter, string pipeThickness, string address) { pipeDiameter = (Convert.ToInt32(decimal.Parse(pipeDiameter) * 10)).ToString(); pipeThickness = (Convert.ToInt32(decimal.Parse(pipeThickness) * 10)).ToString(); List <EquipmentProp> props = null; var prop1 = pipeLine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == PipeLineProps.WCSReplyMessage.ToString()); prop1.Value = messageFlag.GetIndexString(); var prop2 = pipeLine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == PipeLineProps.WCSReplyLoadStatus.ToString()); prop2.Value = loadStatus.GetIndexString(); var prop3 = pipeLine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == PipeLineProps.WCSReplyNumber.ToString()); prop3.Value = number; var prop4 = pipeLine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == PipeLineProps.WCSReplyTaskId.ToString()); prop4.Value = taskId; var prop5 = pipeLine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == PipeLineProps.WCSReplyBarcode.ToString()); prop5.Value = barcode; var prop6 = pipeLine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == PipeLineProps.WCSReplyMaterial.ToString()); prop6.Value = pipeMaterial; var prop7 = pipeLine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == PipeLineProps.WCSReplyLength.ToString()); prop7.Value = pipeLength; var prop8 = pipeLine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == PipeLineProps.WCSReplyDiameter.ToString()); prop8.Value = pipeDiameter; var prop9 = pipeLine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == PipeLineProps.WCSReplyThickness.ToString()); prop9.Value = pipeThickness; var prop10 = pipeLine.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == PipeLineProps.WCSReplyAddress.ToString()); prop10.Value = address; if (messageFlag == StationMessageFlag.默认) { props = new List <EquipmentProp> { prop1, prop2, prop3, prop4, prop5, prop6, prop7, prop8, prop9, prop10 }; } else { props = new List <EquipmentProp> { prop2, prop3, prop4, prop5, prop6, prop7, prop8, prop9, prop10, prop1 }; } return(plc.Writes(props)); }
/// <summary> /// 创建ThroughputMeasured新实例 /// </summary> /// <param name="scope">示波器接口</param> /// <param name="plc">PLC接口</param> public ThroughputMeasurement(IScope scope, IPLC plc) { if (scope?.IsConnect != true) { throw new ArgumentException("scope invalid"); } if (plc?.IsConnect != true) { throw new ArgumentException("plc invalid"); } Scope = scope; PLC = plc; }
/// <summary> /// 创建频率测量新实例 /// </summary> /// <param name="scope">示波器接口</param> /// <param name="plc">PLC接口</param> public PositiveAndNegativeVoltageMeasurement(IScope scope, IPLC plc) { if (scope?.IsConnect != true) { throw new ArgumentException("scope invalid"); } if (plc?.IsConnect != true) { throw new ArgumentException("plc invalid"); } Scope = scope; PLC = plc; }