public void Delelet(ProCommon.Communal.WebProperty webProperty) { if (_list.ContainsKey(webProperty.ID)) { _list.Remove(webProperty.ID); } }
public void Add(ProCommon.Communal.WebProperty webProperty) { if (!_list.ContainsKey(webProperty.ID)) { _list.Add(webProperty.ID, webProperty); } }
public ProCommon.Communal.WebProperty this[string webPropertyID] { get { ProCommon.Communal.WebProperty cam = null; if (_list.ContainsKey(webPropertyID)) { cam = (ProCommon.Communal.WebProperty)_list[webPropertyID]; } return(cam); } }
public ProCommon.Communal.WebProperty this[int indx] { get { ProCommon.Communal.WebProperty webProperty = null; if (_list.Count > 0 && indx >= 0 && indx < _list.Count) { webProperty = (ProCommon.Communal.WebProperty)_list.GetByIndex(indx); } return(webProperty); } }
/// <summary> /// 检测配置文件 /// </summary> /// <param name="fileDirectory"></param> /// <param name="fileName"></param> /// <param name="bkgrdWorker"></param> private bool CheckConfigFile(string fileDirectory, string fileName, System.ComponentModel.BackgroundWorker bkgrdWorker) { SysChkStepNumber += 1; bool rt = false; if (!System.IO.File.Exists(fileDirectory + "\\" + fileName)) { try { switch (fileName) { #region 系统配置 case ProLaminator.Config.CfgManager.SYSTEM_CONFIG_FILE_NAME: { _cfgSysTmp = new ProLaminator.Config.CfgSystem(); _cfgSysTmp.LanguageVersion = ProCommon.Communal.Language.Chinese; _cfgSysTmp.EnableAutoLaunch = false; _cfgSysTmp.GlassStationName = "GLASS"; _cfgSysTmp.Membrane1StationName = "UPMEMBRANE"; _cfgSysTmp.Membrane2StationName = "DOWNMEMBRANE"; _cfgSysTmp.SerialPortNameForPlc = "COM1"; _cfgSysTmp.SpeedLow = 10.0f; _cfgSysTmp.SpeedMedium = 30.0f; _cfgSysTmp.SpeedHigh = 60.0f; _cfgSysTmp.ToolCenterOffsetX = 0.0f; _cfgSysTmp.ToolCenterOffsetY = 0.0f; _cfgSysTmp.ClientName = "深圳市智显科技有限公司"; _cfgSysTmp.CtrllerCategoryArray = new ProCommon.Communal.DeviceCategory[] { ProCommon.Communal.DeviceCategory.Camera, //ProCommon.Communal.DeviceCategory.Board, ProCommon.Communal.DeviceCategory.SerialPort //ProCommon.Communal.DeviceCategory.Socket, //ProCommon.Communal.DeviceCategory.Web }; _cfgSysTmp.EnableLastRoutine = false; //运行软件时不启用上次生产程式 _cfgSysTmp.LastRoutinePath = null; //上次生产程式(默认为空) _cfgSysTmp.RoutineDirectory = null; //生产程式目录(转到默认) _cfgSysTmp.DataBaseDirectory = null; //数据和日志目录(数据库,转到默认) _cfgSysTmp.RunDataSheetName = null; //流水结果表名称(转到默认) _cfgSysTmp.EnableSaveRunData = false; _cfgSysTmp.SaveRunDataDays = 7; _cfgSysTmp.DisplayRunDataCount = 10; _cfgSysTmp.RunLogSheetName = null; //流水日志表名称(转到默认) _cfgSysTmp.EnableSaveRunLog = false; _cfgSysTmp.SaveRunLogDays = 7; _cfgSysTmp.DisplayRunLogCount = 15; _cfgSysTmp.AlarmLogSheetName = null; //报警日志表名称(转到默认) _cfgSysTmp.EnableSaveAlarmLog = false; _cfgSysTmp.SaveAlarmLogDays = 7; _cfgSysTmp.SystemLogFilePath = null; //系统日志文件路径(转到默认) _cfgSysTmp.ExceptionLogFilePath = null; //异常日志文件路径(转到默认) ProCommon.Communal.CfgAPI.Save <ProLaminator.Config.CfgSystem>(_cfgSysTmp, ProLaminator.Config.CfgManager.ConfigDirectory + "\\" + ProLaminator.Config.CfgManager.SYSTEM_CONFIG_FILE_NAME); } break; #endregion #region 用户配置 case ProLaminator.Config.CfgManager.ACCOUNT_CONFIG_FILE_NAME: { //新增加账户时,按照如下规则:账户列表中最后一个账户的Number,然后加1 ProCommon.Communal.Account acc = new ProCommon.Communal.Account(0, "ACC_0000"); acc.Name = "Admin"; acc.Authority = ProCommon.Communal.AccountAuthority.Administrator; acc.PassWord = ProCommon.Communal.DESEncrypt.Encrypt("123"); ProLaminator.Config.CfgAccount cfgAcc = new Config.CfgAccount(); cfgAcc.AccList.Add(acc); ProCommon.Communal.CfgAPI.Save <ProLaminator.Config.CfgAccount>(cfgAcc, ProLaminator.Config.CfgManager.ConfigDirectory + "\\" + ProLaminator.Config.CfgManager.ACCOUNT_CONFIG_FILE_NAME); } break; #endregion #region 报警配置 case ProLaminator.Config.CfgManager.ALARM_CONFIG_FILE_NAME: break; #endregion #region 相机配置 case ProLaminator.Config.CfgManager.CAMERA_CONFIG_FILE_NAME: { if (_cfgSysTmp != null && _cfgSysTmp.CtrllerCategoryArray != null) { bool isCreate = false; foreach (ProCommon.Communal.DeviceCategory cc in _cfgSysTmp.CtrllerCategoryArray) { if (cc == ProCommon.Communal.DeviceCategory.Camera) { isCreate = true; break; } } if (isCreate) { if (_cfgCam == null) { _cfgCam = new Config.CfgCamera(); } _defaultCameraName = "玻璃工位"; //根据项目需要,创建建默的相机配置文件 //新增加相机属性时,按照如下规则:相机属性列表中最后一个相机属性的Number,然后加1 ProCommon.Communal.CameraProperty camProGlass = new ProCommon.Communal.CameraProperty(ProCommon.Communal.DeviceBrand.HikVision, 0, "Cam_00"); camProGlass.Name = _defaultCameraName; camProGlass.ExposureTime = 0.5f; camProGlass.FPS = 15; camProGlass.Gain = 1.0f; camProGlass.ReconnectInterval = 500; camProGlass.SerialNo = "00D22898505"; camProGlass.StationName = _cfgSysTmp.GlassStationName; _cfgCam.PropertyList.Add(camProGlass); _defaultCameraName = "左片工位"; ProCommon.Communal.CameraProperty camProMembrane1 = new ProCommon.Communal.CameraProperty(ProCommon.Communal.DeviceBrand.HikVision, 1, "Cam_01"); camProMembrane1.Name = _defaultCameraName; camProMembrane1.ExposureTime = 0.35f; camProMembrane1.FPS = 15; camProMembrane1.Gain = 1.0f; camProMembrane1.ReconnectInterval = 500; camProMembrane1.SerialNo = "00D22898327"; camProMembrane1.StationName = _cfgSysTmp.Membrane1StationName; _cfgCam.PropertyList.Add(camProMembrane1); _defaultCameraName = "右片工位"; ProCommon.Communal.CameraProperty camProMembrane2 = new ProCommon.Communal.CameraProperty(ProCommon.Communal.DeviceBrand.HikVision, 2, "Cam_02"); camProMembrane2.Name = _defaultCameraName; camProMembrane2.ExposureTime = 0.35f; camProMembrane2.FPS = 15; camProMembrane2.Gain = 1.0f; camProMembrane2.ReconnectInterval = 500; camProMembrane2.SerialNo = "00D22898383"; camProMembrane2.StationName = _cfgSysTmp.Membrane2StationName; _cfgCam.PropertyList.Add(camProMembrane2); ProCommon.Communal.CfgAPI.Save <ProLaminator.Config.CfgCamera>(_cfgCam, ProLaminator.Config.CfgManager.ConfigDirectory + "\\" + ProLaminator.Config.CfgManager.CAMERA_CONFIG_FILE_NAME); } } } break; #endregion #region 标定方案配置 case ProLaminator.Config.CfgManager.CALIBRATIONSOLUTION_CONFIG_FILE_NAME: { if (_cfgSysTmp != null && _cfgSysTmp.CtrllerCategoryArray != null) { bool isCreate = false; foreach (ProCommon.Communal.DeviceCategory cc in _cfgSysTmp.CtrllerCategoryArray) { if (cc == ProCommon.Communal.DeviceCategory.Camera) { isCreate = true; } } if (isCreate) { ProLaminator.Config.CfgCalibration cfgCal = new ProLaminator.Config.CfgCalibration(); //根据项目需要,创建建默的标定方案配置文件 //新增加标定方案时,按照如下规则:标定方案ID与相机ID一致 if (_cfgCam != null && _cfgCam.PropertyList != null) { int cnt = _cfgCam.PropertyList.Count; for (int i = 0; i < cnt; i++) { ProVision.Communal.CalibrationSolution calSl = new ProVision.Communal.CalibrationSolution(ProVision.Communal.CalibrationType.CALIBRATION_UNIT, _cfgCam.PropertyList[i].Name, _cfgCam.PropertyList[i].ID); calSl.IsActive = true; calSl.IsEffective = true; calSl.RowUnit = 0.0f; calSl.ColUnit = 0.0f; cfgCal.CalSolutionList.Add(calSl); } } ProCommon.Communal.CfgAPI.Save <ProLaminator.Config.CfgCalibration>(cfgCal, ProLaminator.Config.CfgManager.ConfigDirectory + "\\" + ProLaminator.Config.CfgManager.CALIBRATIONSOLUTION_CONFIG_FILE_NAME); } } } break; #endregion #region 控制卡配置 case ProLaminator.Config.CfgManager.BOARD_CONFIG_FILE_NAME: { if (_cfgSysTmp != null && _cfgSysTmp.CtrllerCategoryArray != null) { bool isCreate = false; foreach (ProCommon.Communal.DeviceCategory cc in _cfgSysTmp.CtrllerCategoryArray) { if (cc == ProCommon.Communal.DeviceCategory.Board) { isCreate = true; break; } } if (isCreate) { if (_cfgBoard == null) { _cfgBoard = new ProLaminator.Config.CfgBoard(); } //根据项目需要,创建建默的控制卡配置文件 //新增加控制卡属性时,按照如下规则:控制卡属性列表中最后一个控制卡属性的Number,然后加1 ProCommon.Communal.BoardProperty boardPro = new ProCommon.Communal.BoardProperty(ProCommon.Communal.DeviceBrand.ZMotion, 0, "Brd_0000"); boardPro.IsConnected = false; boardPro.ReconnectInterval = 500; boardPro.EtherNetIP = "192.168.1.30"; boardPro.EtherNetPort = 8089; boardPro.ReconnectInterval = 50; boardPro.Name = "BrdForShller"; boardPro.StationName = _cfgSysTmp.GlassStationName; //创建硬件配置时的板卡轴配置 ProCommon.Communal.AxisList axisList = new ProCommon.Communal.AxisList(); CreateAxesInstance(ref axisList); for (int i = 0; i < axisList.Count; i++) { boardPro.AxisList.Add(axisList[i]); } _cfgBoard.PropertyList.Add(boardPro); ProCommon.Communal.CfgAPI.Save <ProLaminator.Config.CfgBoard>(_cfgBoard, ProLaminator.Config.CfgManager.ConfigDirectory + "\\" + ProLaminator.Config.CfgManager.BOARD_CONFIG_FILE_NAME); } } } break; #endregion #region 通信Socket配置 case ProLaminator.Config.CfgManager.COMSOCKET_CONFIG_FILE_NAME: { if (_cfgSysTmp != null && _cfgSysTmp.CtrllerCategoryArray != null) { bool isCreate = false; foreach (ProCommon.Communal.DeviceCategory cc in _cfgSysTmp.CtrllerCategoryArray) { if (cc == ProCommon.Communal.DeviceCategory.Socket) { isCreate = true; break; } } if (isCreate) { //根据项目需要,创建建默的Socket配置文件 //新增加Socket属性时,按照如下规则:Socekt属性列表中最后一个Socket属性的Number,然后加1 ProLaminator.Config.CfgSocket cfgSkt = new ProLaminator.Config.CfgSocket(); ProCommon.Communal.SocketProperty sktPro = new ProCommon.Communal.SocketProperty(ProCommon.Communal.DeviceBrand.Microsoft, 0, "Skt_0000"); sktPro.IP = "192.168.1.11"; sktPro.Name = "测试网口"; sktPro.StationName = _cfgSysTmp.GlassStationName; cfgSkt.PropertyList.Add(sktPro); ProCommon.Communal.CfgAPI.Save <ProLaminator.Config.CfgSocket>(cfgSkt, ProLaminator.Config.CfgManager.ConfigDirectory + "\\" + ProLaminator.Config.CfgManager.COMSOCKET_CONFIG_FILE_NAME); } } } break; #endregion #region 通信Serial配置 case ProLaminator.Config.CfgManager.COMSERIAL_CONFIG_FILE_NAME: { if (_cfgSysTmp != null && _cfgSysTmp.CtrllerCategoryArray != null) { bool isCreate = false; foreach (ProCommon.Communal.DeviceCategory cc in _cfgSysTmp.CtrllerCategoryArray) { if (cc == ProCommon.Communal.DeviceCategory.SerialPort) { isCreate = true; break; } } if (isCreate) { ProLaminator.Config.CfgSerialPort cfgSrlPt = new ProLaminator.Config.CfgSerialPort(); //根据项目需要,创建建默的SerialPort配置文件 //新增加SerialPort属性时,按照如下规则:SerialPort属性列表中最后一个SerialPort属性的Number,然后加1 ProCommon.Communal.SerialPortProperty srlPro = new ProCommon.Communal.SerialPortProperty(ProCommon.Communal.DeviceBrand.Microsoft, 0, "Srl_0000"); srlPro.ReceiveTimeOut = 500; srlPro.ReconnectInterval = 1000; srlPro.SendTimeOut = 500; srlPro.HandShake = System.IO.Ports.Handshake.None; srlPro.BaudRate = 115200; srlPro.DataBits = 8; srlPro.StopBits = System.IO.Ports.StopBits.One; srlPro.Parity = System.IO.Ports.Parity.Even; srlPro.DtrEnable = true; srlPro.RtsEnable = true; srlPro.ReceivedBytesThreshold = 8; srlPro.NewLine = "/r/n"; srlPro.StationName = _cfgSysTmp.SerialPortNameForPlc; cfgSrlPt.PropertyList.Add(srlPro); ProCommon.Communal.CfgAPI.Save <ProLaminator.Config.CfgSerialPort>(cfgSrlPt, ProLaminator.Config.CfgManager.ConfigDirectory + "\\" + ProLaminator.Config.CfgManager.COMSERIAL_CONFIG_FILE_NAME); } } } break; #endregion #region 通信WebService配置 case ProLaminator.Config.CfgManager.COMWEB_CONFIG_FILE_NAME: { if (_cfgSysTmp != null && _cfgSysTmp.CtrllerCategoryArray != null) { bool isCreate = false; foreach (ProCommon.Communal.DeviceCategory cc in _cfgSysTmp.CtrllerCategoryArray) { if (cc == ProCommon.Communal.DeviceCategory.Web) { isCreate = true; break; } } if (isCreate) { //根据项目需要,创建建默的Web配置文件 //新增加Web属性时,按照如下规则:Web属性列表中最后一个Web属性的Number,然后加1 ProLaminator.Config.CfgWeb cfgWb = new ProLaminator.Config.CfgWeb(); ProCommon.Communal.WebProperty webPro = new ProCommon.Communal.WebProperty(ProCommon.Communal.DeviceBrand.Microsoft, 0, "Web_00"); webPro.Name = "测试网络"; webPro.StationName = _cfgSysTmp.GlassStationName; cfgWb.PropertyList.Add(webPro); ProCommon.Communal.CfgAPI.Save <ProLaminator.Config.CfgWeb>(cfgWb, ProLaminator.Config.CfgManager.ConfigDirectory + "\\" + ProLaminator.Config.CfgManager.COMWEB_CONFIG_FILE_NAME); } } } break; #endregion #region 视觉参数配置 case ProLaminator.Config.CfgManager.VISIONPARA_CONFIG_FILE_NAME: { ProLaminator.Config.CfgVisionPara cfgVsPara = new ProLaminator.Config.CfgVisionPara(); ProCommon.Communal.CfgAPI.Save <ProLaminator.Config.CfgVisionPara>(cfgVsPara, ProLaminator.Config.CfgManager.ConfigDirectory + "\\" + ProLaminator.Config.CfgManager.VISIONPARA_CONFIG_FILE_NAME); } break; #endregion #region 运控参数配置 case ProLaminator.Config.CfgManager.MOTIONPARA_CONFIG_FILE_NAME: { } break; #endregion default: break; } SysChkError = ChkLangIsChinese?("创建文件[" + fileName + "]成功!") : ("Create file[" + fileName + "]successfully!"); if (bkgrdWorker != null) { bkgrdWorker.ReportProgress(SysChkStepNumber, SysChkError); } rt = true; } catch (System.Exception ex) { SysChkError = (ChkLangIsChinese?("创建文件[" + fileName + "]失败!异常描述:\r\n") : ("Create file[" + fileName + "]failed!Description:\r\n")) + ex.Message; if (bkgrdWorker != null) { bkgrdWorker.ReportProgress(SysChkStepNumber, SysChkError); } } } else { //若系统配置文件存在,加载系统配置文件,为其他依赖系统配置的配置做准备 if (fileName == ProLaminator.Config.CfgManager.SYSTEM_CONFIG_FILE_NAME) { _cfgSysTmp = ProCommon.Communal.CfgAPI.Load <ProLaminator.Config.CfgSystem>(ProLaminator.Config.CfgManager.ConfigDirectory + "\\" + ProLaminator.Config.CfgManager.SYSTEM_CONFIG_FILE_NAME); } SysChkError = ChkLangIsChinese ?("找到文件[" + fileName + "]"): ("Find file[" + fileName + "]"); if (bkgrdWorker != null) { bkgrdWorker.ReportProgress(SysChkStepNumber, SysChkError); } rt = true; } return(rt); }