/// <summary> /// 关闭工站/设备,释放各种资源 /// </summary> public void Close() { string errInfo = ""; ///关闭工站 IJFMainStation mainStation = StationMgr.MainStation; if (null != mainStation) { mainStation.Stop(out errInfo); } string[] stationNames = StationMgr.AllStationNames(); if (null != stationNames && stationNames.Length > 0) { foreach (string stationName in stationNames) { IJFStation station = StationMgr.GetStation(stationName); station.Stop(); } } ///关闭所有设备 string[] deviceIDs = InitorManager.GetIDs(typeof(IJFDevice)); if (null != deviceIDs && deviceIDs.Length > 0) { foreach (string devID in deviceIDs) { IJFDevice dev = InitorManager.GetInitor(devID) as IJFDevice; dev.CloseDevice(); } } ///释放其他对象 ///添加代码 ... }
public IJFStation GetStation(string stationName) { //foreach (IJFStation station in _lstDeclearStations) //查询申明的工站列表 // if (station.Name == stationName) // return station; JFInitorManager initorMgr = JFHubCenter.Instance.InitorManager; string[] allInitorStation = initorMgr.GetIDs(typeof(IJFStation)); //通过架构UI创建的工站对象 if (null == allInitorStation) { return(null); } foreach (string stName in allInitorStation) { if (stationName == stName) { return(initorMgr.GetInitor(stationName) as IJFStation); } } return(null); }
void _AddCmrNames() { string[] allChnNames = null; //系统中所有已命名的通道 string[] existChnNames = null; //已存在的通道名称 JFInitorManager initorMgr = JFHubCenter.Instance.InitorManager; allChnNames = initorMgr.GetIDs(typeof(IJFDevice_Camera)); existChnNames = _station.CameraNames; //工站中已有的DI通道名称 if (null == allChnNames || 0 == allChnNames.Length) { MessageBox.Show("不存在" + _chnType.ToString() + "命名通道"); return; } List <string> lstAddNames = new List <string>(); //可供添加的DI通道名称 if (null == existChnNames || 0 == existChnNames.Length) { lstAddNames.AddRange(allChnNames); } else { foreach (string chnName in allChnNames) { if (!existChnNames.Contains(chnName)) { lstAddNames.Add(chnName); } } } if (lstAddNames.Count == 0) { MessageBox.Show("没有可供添加的" + _chnType.ToString() + "命名通道"); return; } List <string> lstAddInfos = new List <string>(); foreach (string addName in lstAddNames) { StringBuilder sbDevInfo = new StringBuilder(); IJFDevice_Camera cmr = initorMgr.GetInitor(addName) as IJFDevice_Camera; string[] paramNames = cmr.InitParamNames; if (null != paramNames) { foreach (string paramName in paramNames) { sbDevInfo.Append(paramName + ":" + cmr.GetInitParamValue(paramName).ToString() + " "); } } lstAddInfos.Add(sbDevInfo.ToString()); } FormAddNames frm = new FormAddNames(); frm.Text = "为工站:" + _station.Name + " 添加Camera命名通道"; frm.SetAvailedNames(lstAddNames.ToArray(), lstAddInfos.ToArray()); if (DialogResult.OK == frm.ShowDialog()) { string[] chnNamesWillAdd = null; string[] chnInfosWillAdd = null; frm.GetSelectNameInfos(out chnNamesWillAdd, out chnInfosWillAdd); for (int i = 0; i < chnNamesWillAdd.Length; i++) { string chnName = chnNamesWillAdd[i]; _station.AddCamera(chnName); } _station.SaveCfg(); UpdateStation2UI(); } }