| | |
| | | |
| | | ProcessState = DeviceState.DSOpen; |
| | | |
| | | QueryRobotIO(); |
| | | //QueryRobotIO(); |
| | | |
| | | //Task.Run(() => |
| | | //{ |
| | |
| | | }); |
| | | } |
| | | |
| | | //Dictionary<string, MethodInfo> InvokeMethodDict = new Dictionary<string, MethodInfo>(); |
| | | public List<ProcessMethodAttribute> CollectProcessMethods() |
| | | { |
| | | List<ProcessMethodAttribute> resultList = new List<ProcessMethodAttribute>(); |
| | |
| | | if (attr != null) |
| | | { |
| | | resultList.Add(attr); |
| | | //InvokeMethodDict[attr.MethodCode] = m; |
| | | } |
| | | }); |
| | | |
| | |
| | | StationConfig = LoadStationConfig(configPath); |
| | | |
| | | #region 个别配置的特别处理 |
| | | |
| | | #endregion |
| | | |
| | | _warningRemains.CollectionChanged -= _warningRemains_CollectionChanged; |
| | | _warningRemains.CollectionChanged += _warningRemains_CollectionChanged; |
| | | |
| | | InitialPLCs(); |
| | | InitialRobots(); |
| | | InitialAGVs(); |
| | | InitialRobots(); |
| | | InitialCameras(); |
| | | InitialAGVBindUnit(); |
| | | InitialMachineTrayNums(); |
| | | |
| | | AutoFacRegister(); |
| | | |
| | | LogAsync(DateTime.Now, "Process Initialized", ""); |
| | | } |
| | | |
| | | private void InitialMachineTrayNums() |
| | | { |
| | | machineEmptyTrayDict = Config.PositionCollection.Where(u => u.Description == PathPositionDefinition.UnloadEmptyTray).ToDictionary(p => p.PositionNo, p => 0); |
| | | |
| | | machineFullTrayDict = Config.PositionCollection.Where(u => u.Description == PathPositionDefinition.LoadFullTray).ToDictionary(p => p.PositionNo, p => 0); |
| | | } |
| | | |
| | | private void InitialAGVBindUnit() |
| | | { |
| | | Config.AGVBindCollection.ForEach(u => |
| | | { |
| | | if (AGVDict.ContainsKey(u.AGVId)) |
| | | { |
| | | u.AGV = AGVDict[u.AGVId]; |
| | | } |
| | | |
| | | if (RobotDict.ContainsKey(u.RobotId)) |
| | | { |
| | | u.Robot = RobotDict[u.RobotId]; |
| | | } |
| | | |
| | | if (CameraDict.ContainsKey(u.CameraId)) |
| | | { |
| | | u.Camera = CameraDict[u.CameraId]; |
| | | } |
| | | |
| | | //u.OnMethodInvoke = OnBindUnitTaskInvoke; |
| | | }); |
| | | } |
| | | |
| | | private void InitialCameras() |
| | |
| | | plc.InitialConfig = c; |
| | | PLCDict[plc.InitialConfig.ID] = plc; |
| | | |
| | | plc.OnMonitorAlarm -= Plc_OnMonitorAlarm; |
| | | plc.OnMonitorInvoke -= Plc_OnMonitorInvoke; |
| | | plc.OnMonitorAlarm -= OnMonitorAlarm; |
| | | plc.OnMonitorInvoke -= OnMonitorInvoke; |
| | | |
| | | plc.OnMonitorAlarm += Plc_OnMonitorAlarm; |
| | | plc.OnMonitorInvoke += Plc_OnMonitorInvoke; |
| | | plc.OnMonitorAlarm += OnMonitorAlarm; |
| | | plc.OnMonitorInvoke += OnMonitorInvoke; |
| | | }); |
| | | } |
| | | |
| | |
| | | AuboRobotDriver robot = new AuboRobotDriver(); |
| | | robot.InitialConfig = c; |
| | | RobotDict[robot.InitialConfig.ID] = robot; |
| | | |
| | | robot.OnLog = OnDeviceLog; |
| | | |
| | | robot.OnMsgReceived = OnRobotMsgReceived; |
| | | |
| | | robot.OnMonitorAlarm -= OnMonitorAlarm; |
| | | robot.OnMonitorInvoke -= OnMonitorInvoke; |
| | | |
| | | robot.OnMonitorAlarm += OnMonitorAlarm; |
| | | robot.OnMonitorInvoke += OnMonitorInvoke; |
| | | }); |
| | | } |
| | | |
| | |
| | | SeerAGVDriver agv = new SeerAGVDriver(); |
| | | agv.InitialConfig = c; |
| | | AGVDict[agv.InitialConfig.ID] = agv; |
| | | |
| | | agv.OnLog = OnDeviceLog; |
| | | agv.OnAGVPositoinChanged = OnAGVPositionChanged; |
| | | agv.OnAGVTaskStatusChanged = OnAGVTaskStatusChanged; |
| | | agv.OnAGVBatteryLvlChanged = OnAGVBatteryLvlChanged; |
| | | }); |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | protected Dictionary<string, HDevEngineTool> _halconToolDict = new Dictionary<string, HDevEngineTool>(); |
| | | |
| | | private void InitialProcessMethods() |
| | | public virtual void InitialProcessMethods() |
| | | { |
| | | _processMethodDict = new Dictionary<string, MethodInfo>(); |
| | | var methods = this.GetType().GetMethods().ToList(); |
| | |
| | | { |
| | | _processMethodDict[attr.MethodCode] = m; |
| | | |
| | | #region 初始化HalconTool |
| | | #region 初始化HalconTool 根据processMethod的特性来配置 |
| | | //if (attr.DeviceType.EndsWith("Camera")) |
| | | //{ |
| | | // if (StationConfig.ProcessOpConfigDict.Keys.Contains(attr.MethodCode)) |
| | |
| | | } |
| | | }); |
| | | |
| | | #region 初始化HalconTool |
| | | #region 初始化HalconTool 根据配置的接口类型来配置 |
| | | _halconToolDict = new Dictionary<string, HDevEngineTool>(); |
| | | Config.PLCConfigCollection.SelectMany(plcConfig => plcConfig.MonitorSetCollection).Select(ms => ms.OpConfig).ToList().ForEach(c => |
| | | { |
| | | InitialHalconTool(c as IHalconToolPath); |
| | | }); |
| | | |
| | | Config.VisionConfigCollection.ForEach(c => |
| | | { |
| | | InitialHalconTool(c as IHalconToolPath); |
| | | }); |
| | | |
| | | Config.ProcessOpConfigDict.Values.ToList().ForEach(c => |
| | | { |
| | | InitialHalconTool(c as IHalconToolPath); |
| | | }); |
| | | #endregion |
| | | } |
| | | |
| | | private void InitialHalconTool(IHalconToolPath toolPath) |
| | | { |
| | | //IHalconToolPath toolPath = c as IHalconToolPath; |
| | | if (toolPath != null) |
| | | { |
| | | toolPath.GetHalconToolPathList().ForEach(path => |
| | | { |
| | | IHalconToolPath toolPath = c as IHalconToolPath; |
| | | if (toolPath != null) |
| | | if (!string.IsNullOrWhiteSpace(path) && !_halconToolDict.ContainsKey(path)) |
| | | { |
| | | toolPath.GetHalconToolPathList().ForEach(path => |
| | | { |
| | | if (!string.IsNullOrWhiteSpace(path)) |
| | | { |
| | | string directoryPath = Path.GetDirectoryName(path); |
| | | string fileName = Path.GetFileNameWithoutExtension(path); |
| | | string directoryPath = Path.GetDirectoryName(path); |
| | | string fileName = Path.GetFileNameWithoutExtension(path); |
| | | |
| | | HDevEngineTool tool = new HDevEngineTool(directoryPath); |
| | | tool.LoadProcedure(fileName); |
| | | HDevEngineTool tool = new HDevEngineTool(directoryPath); |
| | | tool.LoadProcedure(fileName); |
| | | |
| | | _halconToolDict[path] = tool; |
| | | } |
| | | }); |
| | | _halconToolDict[path] = tool; |
| | | } |
| | | }); |
| | | #endregion |
| | | } |
| | | } |
| | | |
| | | public List<IDevice> GetDeviceList() |
| | |
| | | return list; |
| | | } |
| | | |
| | | #region PLC监听 |
| | | |
| | | private void Plc_OnMonitorInvoke(DateTime dt, MonitorSet monitorSet) |
| | | #region IMonitor监听 |
| | | private void OnMonitorInvoke(DateTime dt, IDevice device, MonitorSet monitorSet) |
| | | { |
| | | IOperationConfig config = monitorSet.OpConfig; |
| | | string methodCode = monitorSet.MethodCode; |
| | |
| | | try |
| | | { |
| | | //有IOperationConfig参数的调用 |
| | | res = _processMethodDict[methodCode].Invoke(this, new object[] { config }); |
| | | res = _processMethodDict[methodCode].Invoke(this, new object[] { config, device }); |
| | | reTryTimes = -1; |
| | | } |
| | | catch (Exception invokeEX) //流程动作异常失败 |
| | |
| | | #endregion |
| | | } |
| | | |
| | | private void Plc_OnMonitorAlarm(DateTime dt, WarningSet warning, bool isAlarmRaised) |
| | | private void OnMonitorAlarm(DateTime dt, IDevice device, WarningSet warning, bool isAlarmRaised) |
| | | { |
| | | } |
| | | |
| | |
| | | protected Dictionary<string, Queue<string>> CameraBitmapDict = new Dictionary<string, Queue<string>>(); |
| | | //protected Dictionary<string, Bitmap> CameraBitmapDict = new Dictionary<string, Bitmap>(); |
| | | |
| | | protected HObject CollectHImage(CameraBase camera, IOperationConfig opConfig, string cameraId, string methodCode) |
| | | protected HObject CollectHImage(CameraBase camera, IOperationConfig opConfig, string methodCode) |
| | | { |
| | | HObject hImage = null; |
| | | |
| | |
| | | |
| | | camera.UploadOperationConfig(opConfig); |
| | | camera.Snapshot(opConfig, out hImage); |
| | | |
| | | //SaveTempImage(cameraName, camera.ImageFilePath); |
| | | //SaveTempImage(camera, cameraId); |
| | | |
| | | if (cameraConifg.DelayAfter > 0) |
| | | { |