/// <summary> /// 运行 /// </summary> /// <param name="curRollerVo"></param> private void running(RunningRollerVo curRollerVo) { if (curRollerVo == null) { return; } // 查找下一节滚筒 string targetRollerKey = curRollerVo.BandProduct.TargetNode; var nextRoller = getNextRoller(curRollerVo.Roller, targetRollerKey); if (nextRoller == null) { // 结束 if (_exitRollers.Exists(a => a.Key == curRollerVo.RollerKey)) { curRollerVo.BandProduct = null; _runningProducts.Remove(curRollerVo.BandProduct); //TODO: 此时是否应该记录日志 return; } throw new Exception($"({curRollerVo.RollerKey})下一节为空"); } var nextRunningRoller = _runningRollers.FirstOrDefault(a => a.RollerKey == nextRoller.Key); if (nextRunningRoller == null) { throw new Exception($"下一节({nextRoller.Key})不在运行时中"); } var hasProduct = _runningRollers.Any(a => a.RollerKey == nextRoller.Key && a.HasProduct); if (hasProduct) { return; //TODO: 报警 } if (nextRoller.IsEnabled == false) { return; //下一节滚筒禁用时不能流转 //TODO: 给出日志 } nextRunningRoller.BandProduct = curRollerVo.BandProduct; curRollerVo.BandProduct = null; }
//TODO:大小板速度不一致 //TODO:逻辑上不允许先走 private void init(DiagramViewModel diagramViewModel) { if (diagramViewModel == null) { return; } _diagramViewModel = diagramViewModel; _connectors = diagramViewModel.Items.OfType <ConnectorViewModel>().ToList(); _roller = diagramViewModel.Items.OfType <RollerDesignerItemViewModel>().ToList(); foreach (var rollerDesignerItemViewModel in _roller) { var runningRoller = new RunningRollerVo { Roller = rollerDesignerItemViewModel }; runningRoller.In += runningRollerOnIn; runningRoller.Out += RunningRoller_Out; _runningRollers.Add(runningRoller); } var sinkDataItemIdArray = _connectors .Where(a => a.SinkConnectorInfo is FullyCreatedConnectorInfo) .Select(a => (((FullyCreatedConnectorInfo)a.SinkConnectorInfo).DataItem as RollerDesignerItemViewModel)?.Key) .ToList(); _beginRollers = diagramViewModel.Items .OfType <RollerDesignerItemViewModel>() .Where(a => false == sinkDataItemIdArray.Contains(a.Key)).ToList(); var sourceDataItemIdArray = _connectors .Where(a => a.SourceConnectorInfo != null) .Select(a => (a.SourceConnectorInfo.DataItem as RollerDesignerItemViewModel)?.Key) .ToList(); _exitRollers = diagramViewModel.Items .OfType <RollerDesignerItemViewModel>() .Where(a => false == sourceDataItemIdArray.Contains(a.Key)).ToList(); }