/// <summary> /// 设置区域下,边界告警设备的显示和隐藏 /// </summary> /// <param name="dep"></param> /// <param name="isEnable"></param> private void SetDepBorderDevEnable(DepNode dep, bool isEnable) { if (dep == null) { return; } List <DevNode> dev = RoomFactory.Instance.GetDepDevs(dep); if (dev == null || dev.Count == 0) { return; } List <DevNode> borderDevList = dev.FindAll(item => TypeCodeHelper.IsBorderAlarmDev(item.Info.TypeCode.ToString())); if (borderDevList == null || borderDevList.Count == 0) { return; } foreach (var item in borderDevList) { if (item.isAlarm) { continue; } BorderDevController borderDev = item as BorderDevController; borderDev.SetRendererEnable(isEnable); } }
static bool ValidateClass(DepNode d, List <DepNode> classes, int depth) { foreach (int i in d.Dependencies) { if (i == 0) { return(true); } //circular reference detection. //Simpler than keeping a list of visited nodes... if (depth > classes.Count) { return(false); } DepNode nextDep; try { nextDep = classes.Where(c => c.ClassID == i).First(); } catch { return(false); // The dependent class is not in the schedule } return(ValidateClass(nextDep, classes, depth + 1)); } return(true); }
protected override DepNode LoadRootObject(GameObject obj, bool isFocus = true) { DepNode depController = gameObject.GetComponent <DepNode>(); if (depController == null) { Debug.LogError("FloorController is null:" + gameObject.name); depController = transform.GetComponentInParent <DepNode>(); } if (depController != null) { depController.StaticDevContainer = obj; } obj.transform.parent = this.transform; AddScprits(obj.transform); //var renderers= obj.GetComponentsInChildren<MeshRenderer>(); //foreach (var item in renderers) //{ // var t = item.transform; // t.gameObject.AddMissingComponent<MeshCollider>(); // t.gameObject.AddMissingComponent<FacilityDevController>(); // //AddSubDevScripts(t); //} return(depController); }
private void AfterLoadBundle(bool isFocus) { try { IsLoading = false; IsLoaded = true; Debug.Log("GetSceneByName:" + SceneName); var scene = SceneManager.GetSceneByName(SceneName); rootObjs = scene.GetRootGameObjects(); DepNode depNode = null; if (rootObjs.Length > 0) { GameObject rootObj = rootObjs[0]; depNode = LoadRootObject(rootObj, isFocus);//代码运行到子类实现中 } else { Debug.LogError("rootObjs.Length == 0 "); } SceneAssetManager.Instance.AfterLoadAsset(this); SceneManager.UnloadSceneAsync(scene); //Hide(); AfterLoad(); if (callback != null) { callback(depNode); } } catch (Exception ex) { Debug.LogError("AssetBundleInfo.AfterLoadBundle:" + ex); } }
/// <summary> /// 获取区域下,设备告警信息 /// </summary> /// <param name="dep"></param> /// <returns></returns> private List <DeviceAlarm> GetDepAlarmInfo(DepNode dep) { try { if (dep == null) { return(null); } List <DeviceAlarm> alarmInfos = new List <DeviceAlarm>(); if (dep as FloorController) { alarmInfos.AddRange(AlarmInfoList.FindAll(i => i.AreaId == dep.NodeID)); foreach (var room in dep.ChildNodes) { if (room == null) { continue; } alarmInfos.AddRange(AlarmInfoList.FindAll(i => i.AreaId == room.NodeID)); } } else { alarmInfos = AlarmInfoList.FindAll(i => i.AreaId == dep.NodeID); } return(alarmInfos); }catch (Exception e) { Debug.LogError("Error:DevAlarmManage.GetDepAlarmInfo,Exception:" + e.ToString()); return(null); } }
public void ReplaceDepNode(DepNode buildingNode) { if (buildingNode == null) { Debug.LogError("MapLoadManage.ReplaceDepNode buildingNode == null"); return; } //foreach (var item in BuildingList) //{ // item.ReplaceDepNode(buildingNode); //} //if (CurrentBuilding) //{ // CurrentBuilding.ReplaceDepNode(buildingNode); //} MapBuilding mapBuilding = FindMapBuilding(buildingNode); if (mapBuilding) { mapBuilding.ReplaceDepNode(buildingNode); } else { Debug.LogWarning(string.Format("MapLoadManage.ReplaceDepNode Id={0},Name={1}", buildingNode.NodeID, buildingNode.NodeName)); } }
private void ReplaceDepNode(DepNode depNode, string tag) { if (depNode == null) { Debug.LogError("BuildingBox.ReplaceDepNode depNode == null "); return; } //Debug.Log("BuildingBox.ReplaceDepNode depNode :"+ depNode+ ",tag:"+ tag); if (roomFactory.Contains(depNode))//避免重复操作 { //Debug.Log("BuildingBox.ReplaceDepNode roomFactory.Contains(depNode) :" + depNode); return; } roomFactory.SetTopoNode(depNode, topoNode, true); if (topoNode != null && topoNode.Children != null) { roomFactory.BindingChild(depNode, topoNode.Children.ToList(), true); } if (mapManager == null) { mapManager = MapLoadManage.Instance; } if (mapManager != null) { mapManager.InitBuildingId(); mapManager.ReplaceDepNode(depNode); } FactoryDepManager.Instance.ReplaceNode(depNode); }
/// <summary> /// 获取parentID /// </summary> /// <returns></returns> private int GetPID(GameObject dev) { FactoryDepManager dep = FactoryDepManager.Instance; DepNode currentDep = FactoryDepManager.currentDep; int devPid; if (currentDep == null) { return(dep.NodeID); } if (currentDep as FloorController) { FloorController floor = currentDep as FloorController; Transform lastParent = dev.transform.parent; dev.transform.parent = floor.RoomDevContainer.transform; devPid = floor.GetDevBoundId(dev.transform.localPosition); dev.transform.parent = lastParent; } else if (currentDep as DepController || currentDep as BuildingController) { //区域和大楼,默认算厂区设备 return(dep.NodeID); } else { devPid = currentDep.NodeID; } return(devPid); }
private List <DepNode> CreateDeps = new List <DepNode>();//已经创建柱子的区域 /// <summary> /// 获取区域下的柱子节点 /// </summary> /// <param name="dep"></param> /// <returns></returns> private List <PhysicalTopology> TryGetRoomBlocks(DepNode dep) { List <PhysicalTopology> blockList = new List <PhysicalTopology>(); TopoTreeManager manager = TopoTreeManager.Instance; if (manager) { TreeNode <TreeViewItem> node = manager.TryGetAreaNode(dep.NodeID); if (node != null) { PhysicalTopology depPhysic = node.Item.Tag as PhysicalTopology; if (depPhysic != null) { foreach (var item in depPhysic.Children) { if (item.Name == blockName) { blockList.Add(item); } } } } } return(blockList.Count == 0 ? null : blockList);; }
/// <summary> /// 找到相关的节点(ID相同的) /// </summary> /// <param name="focusNode"></param> /// <returns></returns> public DepNode FindRelationNode(DepNode node) { if (node == null) { //Debug.LogError("DepNode.FindRelationNode node==null "); return(this);//漫游进入建筑,没有focusNode } DepNode rNode = null; if (this.NodeID == node.NodeID) { rNode = this; } else { if (ChildNodes != null) { foreach (DepNode child in ChildNodes) { rNode = child.FindRelationNode(node); if (rNode != null) { return(rNode); } } } } return(rNode); }
private void AlarmDepState(DepNode dep, bool isAlarm) { if (dep == null) { return; } if (FireAreas.Contains(dep.NodeID)) { if (dep.monitorRangeObject != null) { if (!isAlarm) { dep.monitorRangeObject.AlarmOff(); HideObjectFollowUI(AlarmDevUIName, dep); } else { dep.monitorRangeObject.AlarmOn(); DeviceAlarm alarmInfo = AlarmInfoList.Find(i => (int)i.AreaId == dep.NodeID); var obj = FollowTargetManage.Instance.CreateFireDevFollowUI(dep.monitorRangeObject.gameObject, dep, alarmInfo); if (obj != null) { obj.gameObject.SetActive(true); } } } } }
static void Main(string[] args) { int[] test = null; //Valid case... int[] data = { 0, 1, 0, 2, 3, 4, 1, 3 }; //Valid case... int[] data1 = { 0, 1, 0, 2, 3, 4, 5, 3, 2, 5 }; //Unscheduled dependency There is no class "5" assigned int[] data2 = { 0, 1, 0, 2, 3, 4, 5, 3 }; //Circular reference (4>-3 and 3->4) int[] data3 = { 0, 1, 0, 2, 3, 4, 4, 3 }; //Two depth circular reference 5->4 4->3 3->5 int[] data4 = { 0, 1, 0, 2, 3, 4, 5, 3, 4, 5 }; test = data1; List <DepNode> classes = new List <DepNode>(); for (int i = 0; i < test.Length - 1; i += 2) { var tmpNode = new DepNode(test[i + 1], test[i]); classes.Add(tmpNode); } var result = ValidateClassList(classes); }
/// <summary> /// 取消区域高亮 /// </summary> public void HighLightDepOff(DepNode highLightDep = null) { if (currentHighlightDep != null && highLightDep != currentHighlightDep) { currentHighlightDep.HighLightOff(); } }
public GameObject CreateCameraUI(GameObject cameraDev, DepNode devDep, DevNode info) { GameObject targetTagObj = UGUIFollowTarget.CreateTitleTag(cameraDev, Vector3.zero); if (UGUIFollowManage.Instance == null) { Debug.LogError("UGUIFollowManage.Instance==null"); return(null); } Camera mainCamera = GetMainCamera(); if (mainCamera == null) { return(null); } string cameraDepName = GetDepNodeId(devDep) + CameraListName; DisposeFollowTarget dispostTarget = targetTagObj.AddMissingComponent <DisposeFollowTarget>(); dispostTarget.SetInfo(cameraDepName); //if (!CameraDepNameList.Contains(cameraDepName)) CameraDepNameList.Add(cameraDepName); GameObject name = UGUIFollowManage.Instance.CreateItem(CameraUIPrefab, targetTagObj, cameraDepName, mainCamera, false, true); CameraMonitorFollowUI cameraInfo = name.GetComponent <CameraMonitorFollowUI>(); if (cameraInfo != null) { cameraInfo.SetInfo(info); } if (DevSubsystemManage.IsRoamState || !FunctionSwitchBarManage.Instance.CameraToggle.ison || ObjectAddListManage.IsEditMode) { UGUIFollowManage.Instance.SetGroupUIbyName(cameraDepName, false); } return(name); }
/// <summary> /// 区域开始切换 /// </summary> /// <param name="argOld"></param> /// <param name="argNew"></param> public static void OnDepNodeChangeStart(DepNode argOld, DepNode argNew) { if (DepNodeChangeStart != null) { DepNodeChangeStart(argOld, argNew); } }
internal void ReplaceDepNode(DepNode depNode) { if (depNode == null) { Debug.LogError("MapBuilding.ReplaceDepNode depNode == null"); return; } //if (Node == null) //{ // Debug.LogError("MapBuilding.ReplaceDepNode Node == null : BuildingName :" + BuildingName); // //return; //} if (BuildingId == depNode.NodeID) { //Node = depNode; SetNode(depNode); foreach (var item in FloorList) { item.ReplaceDepNode(depNode.ChildNodes); } if (CurrentFloor) { CurrentFloor.ReplaceDepNode(depNode.ChildNodes); } } else { Debug.LogWarning(string.Format("MapBuilding.ReplaceDepNode BuildingId != depNode.NodeID Id1={0},Name1={1};ID2={2},Name2={3}", BuildingId, BuildingName, depNode.NodeID, depNode.NodeName)); } }
/// <summary> /// 根据焦点切换设置大楼卸载 /// </summary> /// <param name="argOld"></param> /// <param name="argNew"></param> private static void SetUnLoad(DepNode argOld, DepNode argNew) { //if (argOld is BuildingController && (argNew is FactoryDepManager || argNew is BuildingController)) //{ // argOld.Unload(); //} if (argNew is FactoryDepManager) //焦点调到厂区 { BuildingController building = argOld.GetParentNode <BuildingController>(); //获取原来焦点所在大楼 if (building != null) { building.Unload(); } else { Debug.LogError("SceneEvents.OnDepNodeChanged 返回厂区 building ==null:" + argOld); } } else if (argNew is BuildingController)//对焦到另一个大楼 { BuildingController building = argOld.GetParentNode <BuildingController>(); if (building != null) { if (building.NodeID != argNew.NodeID) { building.Unload();//必须是另外一个大楼 } } else { Debug.LogError("SceneEvents.OnDepNodeChanged 返回厂区 building ==null:" + argOld); } } }
/// <summary> /// 区域创建完成事件(设备加载完成) /// </summary> /// <param name="dep">区域</param> public static void OnDepCreateCompleted(DepNode dep) { if (OnDepCreateComplete != null) { OnDepCreateComplete(dep); } }
public void ShowBg(DepNode node) { DepNode CurrentNode = node; MapLoadManage Map = MapLoadManage.Instance; if (IsParentFloor(CurrentNode)) { CurrentNode = node.ParentNode; } if (CurrentNode as FactoryDepManager || CurrentNode as DepController || CurrentNode as BuildingController) { if (Map) { Map.DisSelectLast(); } ExpandButton.gameObject.SetActive(false); CloseBg.SetActive(true); NormalBg.SetActive(false); ScaleTreeWindow(true); } else { if (Map && Map.ShowBuildingMap(CurrentNode)) { ExpandButton.gameObject.SetActive(true); //if (IsExpand) ExpandOut(); if (IsExpand) { ExpandOut(); ScaleTreeWindow(false); } } } }
private void SceneEvents_DepNodeChanged(DepNode arg1, DepNode arg2) { DepNode depNodeT = GetDepType(arg2); if (depNodeT == null) { SetMultHistoryToggleActive(true); LocationManager.Instance.SetPersonInfoHistoryUI(true); return; } //throw new System.NotImplementedException(); //在配置文件InitInfo.xml,区域类型设置为根节点或园区节点,否则在是否可以展示多人历史记录会有点问题 if (depNodeT.TopoNode == null) { Debug.LogError("PersonSubsystemManage.SceneEvents_DepNodeChanged depNodeT.TopoNode == null:" + arg1 + "," + arg2); return; } //if (depNodeT.TopoNode.Type == Types.园区) //{ // SetMultHistoryToggleActive(true); // LocationManager.Instance.SetPersonInfoHistoryUI(true); //} //else //{ // SetMultHistoryToggleActive(false); // LocationManager.Instance.SetPersonInfoHistoryUI(false); //} }
/// <summary> /// 开启摄像头UI /// </summary> /// <param name="cameraDev"></param> /// <param name="devDep"></param> /// <param name="info"></param> public void CreateCameraUI(GameObject cameraDev, DepNode devDep, DevNode info) { GameObject targetTagObj = UGUIFollowTarget.CreateTitleTag(cameraDev, Vector3.zero); if (UGUIFollowManage.Instance == null) { Debug.LogError("UGUIFollowManage.Instance==null"); return; } if (RoamCamera == null) { return; } GameObject ui = Instantiate(CameraUIPrefab); ui.transform.parent = CameraUIContainer.transform; ui.transform.localScale = Vector3.one; ui.transform.localEulerAngles = Vector3.zero; ui.SetActive(true); UGUIFollowTarget followTarget = UGUIFollowTarget.AddUGUIFollowTarget(ui, targetTagObj, RoamCamera, true, -1); followTarget.SetIsRayCheckCollision(true); followTarget.SetEnableDistace(true, MaxUIDis); CameraMonitorFollowUI cameraInfo = ui.GetComponent <CameraMonitorFollowUI>(); if (cameraInfo != null) { if (!RoamCameraList.Contains(cameraInfo)) { RoamCameraList.Add(cameraInfo); } cameraInfo.SetInfo(info); //cameraInfo.Show(); } }
/// <summary> /// 初始化 /// </summary> public void Init(PhysicalTopology areaInfo, RangeNode rangeNode, DepNode depNode) { this.Id = areaInfo.Id; this.info = areaInfo; this.depNode = depNode; this.rangeNode = rangeNode; InitDepNode(); oriSize = gameObject.GetGlobalSize();//三维物体的大小 UpdatePosSize(areaInfo); SetPosSize(); SetDepMonitorRange(); //isUpdate = true; //CreateBoundPoints(info.EditBound); if (areaInfo.Transfrom != null) { IsCreateAreaByData = areaInfo.Transfrom.IsCreateAreaByData; IsOnAlarmArea = areaInfo.Transfrom.IsOnAlarmArea; IsOnLocationArea = areaInfo.Transfrom.IsOnLocationArea; } //if (gameObject.name.Contains("电子设备间")) //{ // int i = 0; //} InitXZpointList(); }
/// <summary> /// 创建设备漂浮UI /// </summary> /// <param name="sisDev"></param> /// <param name="info"></param> /// <param name="isShow">是否显示</param> public GameObject CreateArchorFollowUI(GameObject archorDev, DepNode devDep, DevNode info) { GameObject targetTagObj = UGUIFollowTarget.CreateTitleTag(archorDev, Vector3.zero); if (UGUIFollowManage.Instance == null) { Debug.LogError("UGUIFollowManage.Instance==null"); return(null); } Camera mainCamera = GetMainCamera(); if (mainCamera == null) { return(null); } string devDepName = GetDepNodeId(devDep) + ArchorDevUIName; DisposeFollowTarget dispostTarget = targetTagObj.AddMissingComponent <DisposeFollowTarget>(); dispostTarget.SetInfo(devDepName); //if (!DevDepNameList.Contains(devDepName)) DevDepNameList.Add(devDepName); GameObject name = UGUIFollowManage.Instance.CreateItem(ArchorDevUIPrefab, targetTagObj, devDepName, mainCamera, false, true); UGUIFollowTarget followTarget = name.GetComponent <UGUIFollowTarget>(); BaseStationFollowUI archorFollow = name.GetComponent <BaseStationFollowUI>(); if (archorFollow != null) { archorFollow.InitInfo(info); } if (DevSubsystemManage.IsRoamState || !FunctionSwitchBarManage.Instance.ArchorInfoToggle.ison) { UGUIFollowManage.Instance.SetGroupUIbyName(devDepName, false); } return(name); }
/// <summary> /// 显示摄像头信息 /// </summary> private void ShowInfo() { if (CameraDev == null) { UGUIMessageBox.Show("Camera.Devinfo is null..."); return; } DevInfo devInfo = CameraDev.Info; TitleText.text = devInfo.Name; string info = ""; if (devInfo.ParentId != null) { DepNode node = RoomFactory.Instance.GetDepNodeById((int)devInfo.ParentId); if (node != null) { info = node.NodeName + "/"; } } CameraDevController cameraInfo = CameraDev as CameraDevController; Dev_CameraInfo camInfo = cameraInfo.GetCameraInfo(CameraDev.Info); if (camInfo != null) { info += camInfo.Ip; } InfoText.text = info; }
private void SelectAreaNode(TreeNode <TreeViewItem> node) { AreaNode togR = (AreaNode)node.Item.Tag; if (togR.Name == "厂区内") { RoomFactory.Instance.FocusNode(FactoryDepManager.Instance); } else { try { DepNode NodeRoom = RoomFactory.Instance.GetDepNodeById(togR.Id); if (NodeRoom != null) { RoomFactory.Instance.FocusNode(NodeRoom); } else { Debug.LogError("AreaDivideTree.SelectAreaNode NodeRoom==null"); } } catch (Exception ex) { Debug.LogError("AreaDivideTree.NodeSelected:" + ex); } } }
private void OnDepNodeChange(DepNode last, DepNode newNode) { IsArchorSet = false; InputX.text = ""; InputY.text = ""; InputZ.text = ""; }
/// <summary> /// 检查是否属于同一楼层 /// </summary> public bool CheckFloorDepNode(DepNode depNodeT) { if (depNode == null) { depNode = RoomFactory.Instance.GetDepNodeByTopo(info); } //if(depNodeT==null || depNodeT.TopoNode.Type== Types.楼层|| depNodeT.TopoNode.Type == Types.r) if (depNodeT == depNode) { return(true); } else { if (depNodeT == null) { return(false); } if (depNodeT.depType == DepType.Factory && depNode == null) { return(true); } else { if (depNode == null) { return(false); } } } if (depNodeT.NodeObject != null && depNode.NodeObject != null) { FloorController floorcontroller1 = depNodeT.NodeObject.GetComponentInParent <FloorController>(); FloorController floorcontroller2 = depNode.NodeObject.GetComponentInParent <FloorController>(); if (floorcontroller1 == floorcontroller2) { return(true); } else { return(false); } } else { if (depNodeT.NodeObject != depNode.NodeObject) { return(false); } else//两个都为空的情况 { return(true); } } }
/// <summary> /// 显示所有漂浮UI /// </summary> /// <param name="dep"></param> public void ShowAllFollowUI(DepNode dep = null) { ShowBuidingUI(); ShowCameraUI(dep); ShowDevInfoUI(dep); ShowArchorInfoUI(dep); SetAlarmDevUIState(true, dep); }
private void OnDepChanged(DepNode oldDep, DepNode currentDep) { if ((oldDep is RoomController && oldDep.ParentNode == currentDep) || (currentDep is RoomController && currentDep.ParentNode == oldDep)) { return; } HighOffLastDep(oldDep); }
private void AddParentNode(List <DepNode> nodeList, DepNode node) { if (nodeList != null && node.ParentNode != null) { nodeList.Insert(0, node.ParentNode); AddParentNode(nodeList, node.ParentNode); } }
public static void Main(string[] args) { foreach(string file in args) { DepNode root = new DepNode(); Console.WriteLine("==== Testing Input from {0} ====", file); DepLexer lexer = new DepLexer(new FileStream(file, FileMode.Open)); DepParser parser = new DepParser(lexer); parser.expr(root); PrintTree(root, 0); } }
public static void PrintTree(DepNode root, int indent) { for(int i = 0; i < indent; i++) Console.Write(" "); Console.Write("op = {0}, ", root.DepOp.ToString()); if (root.Constraint != null) { Console.Write("name = {0}", root.Constraint.Name); if (root.Constraint.Version != null) { DepVersion ver = root.Constraint.Version; Console.WriteLine(", version = {0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Patch); } else Console.WriteLine(); } else Console.WriteLine(); foreach(DepNode child in root.Children) PrintTree(child, indent + 1); }