/// <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 DeleteDev(DevNode dev) { DevNode currentDev = CurrentDevList.Find(item => item == dev); if (currentDev != null && currentDev.Info != null) { CommunicationObject service = CommunicationObject.Instance; if (service) { if (!ClearSubDev(currentDev)) { service.DeleteDevInfo(currentDev.Info); } RemoveDevCache(currentDev); Close(); //RemoveFollowObject(currentDev.gameObject); RemoveObjectFromSelection(currentDev.gameObject); DestroyImmediate(currentDev.gameObject); CurrentDevList.Remove(currentDev); if (CurrentDevList.Count == 0) { ClearSelection(); } else { RefleshGizmoPosition(); } } } }
/// <summary> /// 房间闪烁 /// </summary> /// <param name="isShow">是否闪烁</param> private void FlashingRoom() { if (monitorRangeObject == null) { return; } if (RoomFactory.Instance) { List <DevNode> devs = RoomFactory.Instance.GetDepDevs(this); DevNode dev = devs.Find(i => i.isAlarm == true); if (dev != null) { return; } } if (monitorRangeObject.isAlarming) { return; //如果机房正处于告警就返回 } monitorRangeObject.FlashingOn(Color.green, 2f); if (IsInvoking("FlashingOff")) { CancelInvoke("FlashingOff"); Invoke("FlashingOff", 1.5f); } else { Invoke("FlashingOff", 1.5f); } }
/// <summary> /// 取消设备高亮 /// </summary> public void HighLightDevOff(DevNode highLightDev = null) { if (currentHighlightDev != null && highLightDev != currentHighlightDev) { currentHighlightDev.HighLightOff(); } }
/// <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> /// <param name="dev"></param> private void ShowArchorPart(DevNode dev) { if (TypeCodeHelper.IsLocationDev(dev.Info.TypeCode.ToString())) { ArchorToolManage.Instance.Show(dev); } }
public void Show(DevNode dev) { InitManager(); currentDev = dev; SetWindowState(dev); ShowDeleteButton(dev); //Window.SetActive(true); if (TypeCodeHelper.IsStaticDev(dev.Info.TypeCode.ToString())) { if (!IsCopyDev) { DevNameNormal.text = dev.Info != null ? dev.Info.Name + " " : ""; } else { DevNameCopy.text = dev.Info != null ? dev.Info.Name + " " : ""; } } else { if (!IsCopyDev) { DevNameNormal.text = dev.Info != null ? dev.Info.Name : ""; } else { DevNameCopy.text = dev.Info != null ? dev.Info.Name : ""; } } }
/// <summary> /// 保存其他信息 /// </summary> /// <param name="devInfo"></param> /// <param name="service"></param> private void SaveDevSubInfo(List <GameObject> copyDevList, CommunicationObject service) { List <Dev_CameraInfo> cameraInfoList = new List <Dev_CameraInfo>(); foreach (var devObjT in copyDevList) { DevNode devInfoT = devObjT.GetComponent <DevNode>(); if (devInfoT == null) { continue; } DevInfo devInfo = devInfoT.Info; if (TypeCodeHelper.IsCamera(devInfo.TypeCode.ToString())) { Dev_CameraInfo cameraInfoT = new Dev_CameraInfo(); cameraInfoT.Ip = "127.0.0.1"; cameraInfoT.DevInfoId = devInfo.Id; cameraInfoT.UserName = "******"; cameraInfoT.PassWord = "******"; cameraInfoT.Port = 80; cameraInfoT.CameraIndex = 0; cameraInfoT.Local_DevID = devInfo.Abutment_DevID; cameraInfoT.ParentId = devInfo.ParentId; //CameraDevController camera = devInfoT as CameraDevController; //Dev_CameraInfo value = service.AddCameraInfo(cameraInfo); cameraInfoList.Add(cameraInfoT); //Debug.Log("Add cameraInfo value:" + value == null); } } if (cameraInfoList.Count != 0) { service.AddCameraInfo(cameraInfoList); } }
/// <summary> /// 显示设备编辑界面 /// </summary> public void SetDeviceInfo(DevNode dev) { Window.SetActive(true); SingleEditPart.SetDeviceInfo(dev); MultiDevEditPart.Close(); NoDevicePart.gameObject.SetActive(false); }
/// <summary> /// 获取设备CAD位置信息 /// </summary> /// <param name="devId"></param> /// <returns></returns> private DevPos GetDevPos(DevNode devNode, string devId) { if (devNode == null) { Debug.LogError(String.Format("devNode is null:{0}", devId)); return(null); } else { DevPos posInfo = new DevPos(); posInfo.DevID = devId; //Vector3 pos = model.transform.localPosition; Vector3 CadPos = UnityPosToCad(devNode.transform, devNode); posInfo.PosX = CadPos.x; posInfo.PosY = CadPos.y; posInfo.PosZ = CadPos.z; Vector3 rotation = devNode.transform.eulerAngles; posInfo.RotationX = rotation.x; posInfo.RotationY = rotation.y; posInfo.RotationZ = rotation.z; Vector3 scale = devNode.transform.localScale; posInfo.ScaleX = scale.x; posInfo.ScaleY = scale.y; posInfo.ScaleZ = scale.z; return(posInfo); } }
/// <summary> /// 清除输入框值 /// </summary> /// <param name="dev"></param> private void ClearArchorValue(DevNode dev) { CommunicationObject service = CommunicationObject.Instance; Archor archor = service.GetArchorByDevId(dev.Info.Id); if (archor != null && !string.IsNullOrEmpty(archor.Code)) { try { DevTypeDropdown.value = (int)archor.Type; }catch (Exception e) { DevTypeDropdown.value = 0; } DevCode.text = archor.Code.ToString(); XPosInput.text = archor.X.ToString(); YPosInput.text = archor.Y.ToString(); ZPosInput.text = archor.Z.ToString(); } else { DevTypeDropdown.value = 0; DevCode.text = ""; XPosInput.text = ""; YPosInput.text = ""; ZPosInput.text = ""; } DevName.text = dev.Info.Name; valueText.text = ""; SaveInfoResult.text = ""; }
/// <summary> /// 设置批量复制按钮 /// </summary> /// <param name="devList"></param> private void SetBatchCopyState(List <DevNode> devList) { SurroundEditMenu_BatchCopy copyPart = SurroundEditMenu_BatchCopy.Instacne; if (copyPart) { if (devList.Count > 1) { copyPart.CloseUI(); } else if (devList.Count == 1) { DevNode dev = devList[0]; if (dev is RoomDevController || dev is DepDevController || !TypeCodeHelper.IsLocationDev(dev.Info.TypeCode.ToString())) { if (ObjectAddListManage.IsEditMode) { copyPart.Open(dev); } } else { copyPart.CloseUI(); } } } }
/// <summary> /// 设置编辑的设备信息 /// </summary> /// <param name="dev"></param> public void SetDeviceInfo(DevNode dev) { SetCameraWindow(dev); window.SetActive(true); CurrentDev = dev; NameField.text = dev.Info.Name; IDField.text = dev.Info.KKSCode; AbtmentIDField.text = dev.Info.Abutment_DevID; DevPos devPos = dev.Info.Pos; if (devPos != null) { Vector3 cadPos = new Vector3(devPos.PosX, devPos.PosY, devPos.PosZ); bool isLocal = CurrentDev.IsLocal(); Vector3 pos = LocationManager.CadToUnityPos(cadPos, isLocal); XPosField.text = Math.Round(pos.x, 2).ToString(CultureInfo.InvariantCulture); YPosField.text = Math.Round(pos.y, 2).ToString(CultureInfo.InvariantCulture); ZPosField.text = Math.Round(pos.z, 2).ToString(CultureInfo.InvariantCulture); AngleField.text = Math.Round(devPos.RotationY, 2).ToString(CultureInfo.InvariantCulture); CadPosA.text = Math.Round(devPos.PosZ, 2).ToString(CultureInfo.InvariantCulture); CadPosB.text = Math.Round(devPos.PosX, 2).ToString(CultureInfo.InvariantCulture); } else { Debug.LogError("DevPos is null:" + dev.Info.Name); //ClearValue(); } SetAnglePosInputState(dev); }
/// <summary> /// 保存 /// </summary> public void AddSave() { //ToDo:设备创建完成后,放置在合适位置 CommunicationObject service = CommunicationObject.Instance; if (service) { DevInfo devInfo = GetDevInfo(); DevNode dev = SetDevController(devInfo); if (dev == null) { return; } DevPos pos = GetDevPos(devInfo.DevID); devInfo.Pos = pos; service.AddDevInfo(ref dev.Info); //Debug.LogError("DevID:"+ dev.Info.Id+" DevName"+dev.gameObject.name); SaveDevSubInfo(dev, service); ShowEditUI(model); } else { Debug.LogError("CommunicationObject.Instance is null!"); } }
private Color unInteractableColor = new Color(109f / 255f, 236f / 255f, 254f / 255);//不可输入文本框颜色 /// <summary> /// 设置角度和位置,是否可以输入 /// </summary> /// <param name="devTemp"></param> private void SetAnglePosInputState(DevNode devTemp) { if (devTemp.Info != null && TypeCodeHelper.IsStaticDev(devTemp.Info.TypeCode.ToString())) { XPosField.interactable = false; XPosField.textComponent.color = unInteractableColor; YPosField.interactable = false; YPosField.textComponent.color = unInteractableColor; ZPosField.interactable = false; ZPosField.textComponent.color = unInteractableColor; AngleField.interactable = false; AngleField.textComponent.color = unInteractableColor; } else { XPosField.interactable = true; XPosField.textComponent.color = Color.white; YPosField.interactable = true; YPosField.textComponent.color = Color.white; ZPosField.interactable = true; ZPosField.textComponent.color = Color.white; AngleField.interactable = true; AngleField.textComponent.color = Color.white; } }
/// <summary> /// 设置编辑的设备信息 /// </summary> /// <param name="dev"></param> public void SetDeviceInfo(DevNode dev) { window.SetActive(true); CurrentDev = dev; NameInput.text = dev.Info.Name; IDField.text = dev.Info.KKSCode; DevPos devPos = dev.Info.Pos; if (devPos != null) { Vector3 cadPos = new Vector3(devPos.PosX, devPos.PosY, devPos.PosZ); bool isLocation = !(CurrentDev.ParentDepNode == FactoryDepManager.Instance); Vector3 pos = LocationManager.CadToUnityPos(cadPos, isLocation); XPosInput.text = Math.Round(pos.x, 2).ToString(); YPosInput.text = Math.Round(pos.y, 2).ToString(); ZPosInput.text = Math.Round(pos.z, 2).ToString(); AngleInput.text = Math.Round(devPos.RotationY, 2).ToString(); ScaleXInput.text = Math.Round(devPos.ScaleX, 2).ToString(); ScaleYInput.text = Math.Round(devPos.ScaleY, 2).ToString(); ScaleZInput.text = Math.Round(devPos.ScaleZ, 2).ToString(); } else { Debug.LogError("DevPos is null:" + dev.Info.Name); //ClearValue(); } }
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); }
public void Open(DevNode dev) { currentDev = dev; ClearArchorValue(dev); currentArchor = null; InitSignObject(); SignObject.SetActive(true); }
/// <summary> /// 初始化告警信息 /// </summary> /// <param name="dev"></param> /// <param name="alarmContent"></param> public void InitAlarmInfo(DeviceAlarm alarmContent, DevNode dev) { currentDev = dev; currentDev.isAlarm = true; AlarmInfo = alarmContent; dev.AddAlarm(alarmContent); SetNormalFollowUIState(dev, false); }
/// <summary> /// 显示摄像头数据 /// </summary> /// <param name="dev"></param> public void ShowCameraInfo(DevNode dev) { GetCameraInfo(dev.Info); if (CameraInfo != null) { Debug.LogError(string.Format("OpenVideoStream-> IP:{0} UserName:{1} PassWord:{2} Port:{3} Index:{4}", CameraInfo.Ip, CameraInfo.PassWord, CameraInfo.Port, CameraInfo.CameraIndex)); } }
/// <summary> /// 初始化设备信息 /// </summary> /// <param name="roomDev"></param> /// <param name="info"></param> /// <param name="parentNode"></param> private DevNode InitDevInfo(DevNode devController, DevInfo info, DepNode parentNode) { devController.Info = info; devController.ParentDepNode = parentNode; if (RoomFactory.Instance) { RoomFactory.Instance.SaveDepDevInfo(parentNode, devController, info); } return(devController); }
/// <summary> /// 设置告警跟随UI的信息 /// </summary> /// <param name="dev"></param> /// <param name="alarmInfo"></param> public void SetAlarmFollowUI(DevNode dev, DeviceAlarm alarmInfo) { if (dev.alarmUi == null) { dev.alarmUi = CreateAlarmFollowUI(dev, dev.ParentDepNode, alarmInfo); } else { dev.alarmUi.InitInfo(alarmInfo); } }
/// <summary> /// 设置摄像头设置界面 /// </summary> /// <param name="dev"></param> private void SetCameraWindow(DevNode dev) { if (dev is CameraDevController) { CameraInfoSetting.Show(dev as CameraDevController); } else { CameraInfoSetting.Close(); } }
/// <summary> /// 显示设备编辑界面 /// </summary> private void ShowEditUI(GameObject dev) { DevNode devNode = dev.GetComponent <DevNode>(); DeviceEditUIManager editManager = DeviceEditUIManager.Instacne; if (editManager && devNode) { editManager.Show(devNode); } SetDevSelection(dev); }
/// <summary> /// 设置设备位置信息 /// </summary> /// <param name="pos"></param> public void ChangePos(DevNode dev, Vector3 pos) { if (dev != CurrentDev) { return; } NameField.text = dev.Info.Name; XPosField.text = Math.Round(pos.x, 2).ToString(CultureInfo.InvariantCulture); YPosField.text = Math.Round(pos.y, 2).ToString(CultureInfo.InvariantCulture); ZPosField.text = Math.Round(pos.z, 2).ToString(CultureInfo.InvariantCulture); SaveInfo(); }
/// <summary> /// 显示设备编辑部分 /// </summary> /// <param name="dev"></param> private void ShowEditPart(DevNode dev) { if (TypeCodeHelper.IsBorderAlarmDev(dev.Info.TypeCode.ToString())) { EditPart.Close(); MonitorRangePart.SetDeviceInfo(dev); } else { MonitorRangePart.Close(); EditPart.SetDeviceInfo(dev); } }
/// <summary> /// 保存其他信息 /// </summary> /// <param name="devInfo"></param> /// <param name="service"></param> private void SaveDevSubInfo(DevNode devNode, CommunicationObject service) { DevInfo devInfo = devNode.Info; if (devInfo == null) { return; } if (TypeCodeHelper.IsLocationDev(devInfo.TypeCode.ToString())) { Archor archor = new Archor(); archor.Code = ""; archor.DevInfoId = devInfo.Id; archor.ParentId = (int)devInfo.ParentId; archor.X = 0; archor.Y = 0; archor.Z = 0; archor.Name = devInfo.Name; archor.Type = ArchorTypes.副基站; archor.IsAutoIp = true; archor.Ip = ""; archor.ServerIp = ""; archor.ServerPort = 0; archor.Power = 0; archor.AliveTime = 0; archor.Enable = IsStart.是; //archor.DevInfo = devInfo; bool value = service.AddArchor(archor); Debug.Log("Add archor value:" + value); } else if (TypeCodeHelper.IsCamera(devInfo.TypeCode.ToString())) { Dev_CameraInfo cameraInfo = new Dev_CameraInfo(); cameraInfo.Ip = ""; cameraInfo.DevInfoId = devInfo.Id; cameraInfo.UserName = ""; cameraInfo.PassWord = ""; cameraInfo.Port = 0; cameraInfo.CameraIndex = 0; cameraInfo.Local_DevID = devInfo.Abutment_DevID; cameraInfo.ParentId = devInfo.ParentId; CameraDevController camera = devNode as CameraDevController; //camera.SetCameraInfo(cameraInfo); Dev_CameraInfo value = service.AddCameraInfo(cameraInfo); if (value != null) { camera.SetCameraInfo(value); } Debug.Log("Add cameraInfo value:" + value == null); } }
/// <summary> /// 移除设备漂浮UI /// </summary> /// <param name="dev"></param> public void RemoveAlarmDevFollowUI(DevNode dev) { if (dev.ParentDepNode == null) { return; } string groupName = string.Format("{0}{1}", AlarmDevUIName, dev.ParentDepNode.NodeID); Transform titleTag = dev.gameObject.transform.Find("TitleTag"); if (titleTag != null) { UGUIFollowManage.Instance.RemoveUIbyTarget(groupName, titleTag.gameObject); } }
private void SetNormalFollowUIState(DevNode dev, bool isShow) { if (dev == null || dev.FollowUI == null) { return; } UGUIFollowTarget follow = dev.FollowUI.GetComponent <UGUIFollowTarget>(); if (follow) { follow.enabled = isShow; dev.FollowUI.SetActive(isShow); } }
/// <summary> /// 通过devinfo,获取机组信息 /// </summary> /// <param name="dev"></param> /// <param name="onDataRecieved"></param> private void TryGetPowerGroupValue(DevNode dev, Action <bool> onDataRecieved = null) { if (dev == null) { return; } DevInfo info = dev.Info; if (info == null || string.IsNullOrEmpty(info.KKSCode)) { return; } TryGetPowerValueByKKS(info.KKSCode, onDataRecieved); }