示例#1
0
        /// <summary>
        /// 添加设备信息
        /// </summary>
        /// <param name="dev"></param>
        /// <param name="devBll"></param>
        private static bool AddDevInfo(DevInfoBackup dev, DevInfoBll devBll)
        {
            try
            {
                DevInfo devInfo = GetDevInfo(dev);
                DevPos  devPos  = GetDevPos(dev);
                devInfo.SetPos(devPos);
                //if (string.IsNullOrEmpty(devInfo.Local_DevID))
                //{

                //}
                DevInfo infoTemp = devBll.Find(i => i.Local_DevID == devInfo.Local_DevID);
                if (infoTemp == null)
                {
                    return(devBll.Add(devInfo));//新设备,加入
                }
                else
                {
                    UpgradeDevInfo(infoTemp, devInfo);//已经存在的设备,更新
                    bool value = devBll.Edit(infoTemp);
                    if (!value)
                    {
                        Log.Info("Error: EditDevinfo Error");
                    }
                    return(value);
                }
            }
            catch (Exception e)
            {
                Log.Info("Error in DevInfoHelper.AddDevInfo:" + e.ToString());
                return(false);
            }
        }
    /// <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();
        }
    }
    /// <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!");
        }
    }
示例#4
0
 /// <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>
    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>
    /// <param name="angleText"></param>
    private void OnAngleChange(string angleText)
    {
        DevPos pos = CurrentDev.Info.Pos;

        if (string.IsNullOrEmpty(angleText))
        {
            AngleField.text = pos.RotationY.ToString();
        }
    }
示例#7
0
        private void SaveArchorInfoToXml(List <TModel.Location.AreaAndDev.Archor> archorList, LocationService service)
        {
            LocationDeviceList backUpList = new LocationDeviceList();

            backUpList.DepList = new List <LocationDevices>();

            foreach (var item in archorList)
            {
                if (item.DevInfo == null)
                {
                    continue;
                }
                Area area = service.GetAreaById(item.ParentId);
                if (area == null)
                {
                    Log.Info(string.Format("Error: Dev {0} area not find...", item.DevInfo.Id));
                    continue;
                }
                LocationDevices areaList = backUpList.DepList.Find(i => i.Name == area.Name);
                if (areaList == null)
                {
                    areaList         = new LocationDevices();
                    areaList.Name    = area.Name;
                    areaList.DevList = new List <LocationDevice>();
                    backUpList.DepList.Add(areaList);
                }
                if (areaList.DevList == null)
                {
                    areaList.DevList = new List <LocationDevice>();
                }
                LocationDevice dev = new LocationDevice();
                dev.Name           = item.Name;
                dev.Abutment_DevID = item.DevInfo.Abutment_DevID;
                dev.AnchorId       = item.Code;
                dev.IP             = item.Ip;
                dev.AbsolutePosX   = item.X.ToString("f2");
                dev.AbsolutePosY   = item.Y.ToString("f2");
                dev.AbsolutePosZ   = item.Z.ToString("f2");

                DevPos pos = item.DevInfo.Pos;
                if (pos != null)
                {
                    dev.XPos = pos.PosX.ToString("f2");
                    dev.YPos = pos.PosY.ToString("f2");
                    dev.ZPos = pos.PosZ.ToString("f2");
                }
                else
                {
                    Log.Info("Error: dev.pos is null->" + item.DevInfo.Id);
                }
                areaList.DevList.Add(dev);
            }
            //string initFile = GetSaveDevDirectory() + "基站信息.xml";
            //XmlSerializeHelper.Save(backUpList, initFile, Encoding.UTF8);
            SaveArchorDevXml("基站信息.xml", backUpList);
        }
        /// <summary>
        /// 修改设备位置信息
        /// </summary>
        /// <param name="pos"></param>
        /// <returns></returns>
        public bool ModifyPosInfo(DevPos pos)
        {
            var devInfo = db.DevInfos.DbSet.FirstOrDefault(i => i.Local_DevID == pos.DevID);

            if (devInfo != null)
            {
                devInfo.SetPos(pos);
                return(db.DevInfos.Edit(devInfo));
            }
            return(false);
        }
示例#9
0
    /// <summary>
    /// 获取门禁所有信息
    /// </summary>
    private void GetDoorAccessData(GameObject door, string doorID, int?areaId, out DoorAccessDevController controller, out Dev_DoorAccess doorAccessInfo)
    {
        DevInfo devInfo = GetDevInfo(areaId);

        controller = SetDevController(door, devInfo, areaId);
        DevPos pos = GetDevPos(devInfo.DevID, door);

        devInfo.Pos               = pos;
        doorAccessInfo            = GetDoorAccessInfo(devInfo, doorID, areaId);
        doorAccessInfo.DevInfo    = devInfo;
        controller.DoorAccessInfo = doorAccessInfo;
    }
示例#10
0
 /// <summary>
 /// 添加基站设备
 /// </summary>
 /// <param name="devList">设备列表</param>
 /// <param name="devBlls">数据信息</param>
 /// <param name="areaId">设备所属区域ID</param>
 private static void AddLocationDev(List <LocationDevice> devList, ArchorBll archorBll, int?areaId)
 {
     foreach (var locationDev in devList)
     {
         DevInfo devInfo = GetDevInfo(locationDev, areaId);
         DevPos  devPos  = GetDevPos(locationDev, devInfo.DevID);
         Archor  archor  = GetAnchorInfo(locationDev, devInfo.DevID);
         devInfo.Pos = devPos;
         archor.Dev  = devInfo;
         archorBll.Add(archor);
         //devBlls.Add(devInfo);
     }
 }
示例#11
0
 /// <summary>
 /// 添加摄像头信息
 /// </summary>
 /// <param name="cameraDev"></param>
 /// <param name="bll"></param>
 private static void AddCameraInfo(CameraInfoBackup cameraDev, Bll bll)
 {
     try
     {
         DevInfoBackup dev     = CameraToDevInfo(cameraDev);
         DevInfo       devInfo = GetDevInfo(dev);
         DevPos        devPos  = GetDevPos(dev);
         devInfo.SetPos(devPos);
         DevInfo infoTemp = bll.DevInfos.Find(i => i.Local_DevID == devInfo.Local_DevID);
         //Devinfo中,能通过Devid找到的就更新。找不到就新增
         if (infoTemp == null)
         {
             bll.DevInfos.Add(devInfo);
             Dev_CameraInfo cameraBackup = GetCameraInfo(cameraDev, devInfo);
             cameraBackup.RtspUrl = cameraDev.RtspURL;
             bll.Dev_CameraInfos.Add(cameraBackup);
         }
         else
         {
             UpgradeDevInfo(infoTemp, devInfo);
             bool value = bll.DevInfos.Edit(infoTemp);
             if (!value)
             {
                 Log.Info("Error: EditDevinfo Error");
             }
             Dev_CameraInfo cameraBackup = GetCameraInfo(cameraDev, infoTemp);
             if (!string.IsNullOrEmpty(cameraDev.RtspURL))
             {
                 cameraBackup.RtspUrl = cameraDev.RtspURL;
             }
             Dev_CameraInfo cameraDatabase = bll.Dev_CameraInfos.Find(cameraT => cameraT.Local_DevID == infoTemp.Local_DevID);
             if (cameraDatabase == null)
             {
                 bll.Dev_CameraInfos.Add(cameraBackup);
             }
             else
             {
                 UpgradeCameraInfo(cameraBackup, cameraDatabase);
                 bool valueT = bll.Dev_CameraInfos.Edit(cameraDatabase);
                 if (!valueT)
                 {
                     Log.Info("Error: EditDevinfo Error");
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Info("Error in DevInfoHelper.AddDevInfo:" + e.ToString());
     }
 }
示例#12
0
 /// <summary>
 /// 添加设备信息
 /// </summary>
 /// <param name="dev"></param>
 /// <param name="devBll"></param>
 private static void AddDevInfo(DevInfoBackup dev, DevInfoBll devBll)
 {
     try
     {
         DevInfo devInfo = GetDevInfo(dev);
         DevPos  devPos  = GetDevPos(dev);
         devInfo.SetPos(devPos);
         devBll.Add(devInfo);
     }
     catch (Exception e)
     {
         Console.WriteLine("Error in DevInfoHelper.AddDevInfo:" + e.ToString());
     }
 }
示例#13
0
        /// <summary>
        /// 保存通用设备
        /// </summary>
        private void SaveNormalDev(List <Location.TModel.Location.AreaAndDev.DevInfo> devInfoList, LocationService service)
        {
            DevInfoBackupList backUpList = new DevInfoBackupList();

            backUpList.DevList = new List <DevInfoBackup>();
            foreach (var item in devInfoList)
            {
                string typeCodeT = item.TypeCode.ToString();
                if (TypeCodeHelper.IsLocationDev(typeCodeT) || TypeCodeHelper.IsCamera(typeCodeT) || TypeCodeHelper.IsDoorAccess(item.ModelName) || TypeCodeHelper.IsFireFightDevType(typeCodeT))
                {
                    continue;
                }
                DevInfoBackup dev = new DevInfoBackup();
                dev.DevId          = item.DevID;
                dev.KKSCode        = item.KKSCode;
                dev.Abutment_DevID = item.Abutment_DevID;
                dev.ModelName      = item.ModelName;
                dev.Name           = item.Name;
                dev.ParentName     = GetAreaPath((int)item.ParentId, service);
                dev.TypeCode       = item.TypeCode.ToString();

                DevPos pos = item.Pos;

                dev.RotationX = pos.RotationX.ToString();
                dev.RotationY = pos.RotationY.ToString();
                dev.RotationZ = pos.RotationZ.ToString();

                dev.XPos = pos.PosX.ToString();
                dev.YPos = pos.PosY.ToString();
                dev.ZPos = pos.PosZ.ToString();

                dev.ScaleX = pos.ScaleX.ToString();
                dev.ScaleY = pos.ScaleY.ToString();
                dev.ScaleZ = pos.ScaleZ.ToString();

                backUpList.DevList.Add(dev);
            }
            List <DevInfoBackup> deleteDevs = AddDeleteDev(devInfoList);

            if (devInfoList != null && devInfoList.Count != 0)
            {
                backUpList.DevList.AddRange(deleteDevs);
            }
            //string dirctory = GetSaveDevDirectory();
            //string initFile = dirctory+"DevInfoBackup.xml";
            //XmlSerializeHelper.Save(backUpList, initFile, Encoding.UTF8);
            SaveNormalDevXml("DevInfoBackup.xml", backUpList);
        }
示例#14
0
        /// <summary>
        /// 保存设备信息至Xml文件
        /// </summary>
        private void SaveCameraInfoToXml(List <TModel.Location.AreaAndDev.Dev_CameraInfo> cameraList, LocationService service)
        {
            CameraInfoBackUpList backUpList = new CameraInfoBackUpList();

            backUpList.DevList = new List <CameraInfoBackup>();

            foreach (var item in cameraList)
            {
                if (item.DevInfo == null)
                {
                    continue;
                }
                CameraInfoBackup dev = new CameraInfoBackup();
                dev.DevId          = item.DevInfo.DevID;
                dev.KKSCode        = item.DevInfo.KKSCode;
                dev.Abutment_DevID = item.DevInfo.Abutment_DevID;
                dev.ModelName      = item.DevInfo.ModelName;
                dev.Name           = item.DevInfo.Name;
                dev.ParentName     = GetAreaPath((int)item.ParentId, service);
                dev.TypeCode       = item.DevInfo.TypeCode.ToString();

                DevPos pos = item.DevInfo.Pos;

                dev.RotationX = pos.RotationX.ToString();
                dev.RotationY = pos.RotationY.ToString();
                dev.RotationZ = pos.RotationZ.ToString();

                dev.XPos = pos.PosX.ToString();
                dev.YPos = pos.PosY.ToString();
                dev.ZPos = pos.PosZ.ToString();

                dev.ScaleX = pos.ScaleX.ToString();
                dev.ScaleY = pos.ScaleY.ToString();
                dev.ScaleZ = pos.ScaleZ.ToString();

                dev.IP          = item.Ip;
                dev.UserName    = item.UserName;
                dev.PassWord    = item.PassWord;
                dev.CameraIndex = item.CameraIndex.ToString();
                dev.Port        = item.Port.ToString();
                dev.RtspURL     = item.RtspUrl;

                backUpList.DevList.Add(dev);
            }
            //string initFile = GetSaveDevDirectory()+"CameraInfoBackup.xml";
            //XmlSerializeHelper.Save(backUpList, initFile, Encoding.UTF8);
            SaveCameraDevXml("CameraInfoBackup.xml", backUpList);
        }
示例#15
0
        public DevPos GetPos()
        {
            DevPos pos = new DevPos();

            pos.DevID     = this.Local_DevID;
            pos.PosX      = this.PosX;
            pos.PosY      = this.PosY;
            pos.PosZ      = this.PosZ;
            pos.ScaleX    = this.ScaleX;
            pos.ScaleY    = this.ScaleY;
            pos.ScaleZ    = this.ScaleZ;
            pos.RotationX = this.RotationX;
            pos.RotationY = this.RotationY;
            pos.RotationZ = this.RotationZ;
            return(pos);
        }
示例#16
0
 public void SetPos(DevPos pos)
 {
     if (pos == null)
     {
         return;
     }
     this.PosX      = pos.PosX;
     this.PosY      = pos.PosY;
     this.PosZ      = pos.PosZ;
     this.ScaleX    = pos.ScaleX;
     this.ScaleY    = pos.ScaleY;
     this.ScaleZ    = pos.ScaleZ;
     this.RotationX = pos.RotationX;
     this.RotationY = pos.RotationY;
     this.RotationZ = pos.RotationZ;
 }
示例#17
0
        /// <summary>
        /// 获取设备位置信息
        /// </summary>
        /// <param name="locationDev"></param>
        /// <returns></returns>
        private static DevPos GetDevPos(LocationDevice locationDev, string devId)
        {
            DevPos pos = new DevPos();

            pos.DevID     = devId;
            pos.PosX      = TryParseFloat(locationDev.XPos);
            pos.PosZ      = TryParseFloat(locationDev.YPos);
            pos.PosY      = TryParseFloat(locationDev.ZPos);
            pos.RotationX = 0;
            pos.RotationY = 0;
            pos.RotationZ = 0;
            pos.ScaleX    = 1;
            pos.ScaleY    = 1;
            pos.ScaleZ    = 1;
            return(pos);
        }
示例#18
0
 /// <summary>
 /// 添加门禁信息
 /// </summary>
 /// <param name="cameraDev"></param>
 /// <param name="bll"></param>
 private static void AddDoorAccessInfo(DoorAccess doorAccess, Bll bll)
 {
     try
     {
         DevInfoBackup dev     = DoorAccessToDevInfo(doorAccess);
         DevInfo       devInfo = GetDevInfo(dev);
         DevPos        devPos  = GetDevPos(dev);
         devInfo.SetPos(devPos);
         bll.DevInfos.Add(devInfo);
         DbModel.Location.AreaAndDev.Dev_DoorAccess doorAccessDev = GetDoorAccessInfo(doorAccess, devInfo);
         bll.Dev_DoorAccess.Add(doorAccessDev);
     }
     catch (Exception e)
     {
         Console.WriteLine("Error in DevInfoHelper.AddDevInfo:" + e.ToString());
     }
 }
示例#19
0
 /// <summary>
 /// 添加摄像头信息
 /// </summary>
 /// <param name="cameraDev"></param>
 /// <param name="bll"></param>
 private static void AddCameraInfo(CameraInfoBackup cameraDev, Bll bll)
 {
     try
     {
         DevInfoBackup dev     = CameraToDevInfo(cameraDev);
         DevInfo       devInfo = GetDevInfo(dev);
         DevPos        devPos  = GetDevPos(dev);
         devInfo.SetPos(devPos);
         bll.DevInfos.Add(devInfo);
         Dev_CameraInfo camera = GetCameraInfo(cameraDev, devInfo);
         bll.Dev_CameraInfos.Add(camera);
     }
     catch (Exception e)
     {
         Console.WriteLine("Error in DevInfoHelper.AddDevInfo:" + e.ToString());
     }
 }
示例#20
0
 /// <summary>
 /// 获取输入坐标
 /// </summary>
 /// <returns></returns>
 private Vector3 TryParsePos()
 {
     try
     {
         DevPos  devPos = CurrentDev.Info.Pos;
         float   xPos   = XPosField.text.ToFloat();
         float   yPos   = YPosField.text.ToFloat();
         float   zPos   = ZPosField.text.ToFloat();
         Vector3 pos    = new Vector3(xPos, yPos, zPos);
         return(pos);
     }
     catch (Exception e)
     {
         Debug.LogError("Input Pos Error:" + e);
         return(Vector3.zero);
     }
 }
 /// <summary>
 /// 获取输入坐标
 /// </summary>
 /// <returns></returns>
 private Vector3 TryParsePos()
 {
     try
     {
         DevPos  devPos = CurrentDev.Info.Pos;
         float   xPos   = TryParseFloat(XPosInput.text);
         float   yPos   = TryParseFloat(YPosInput.text);
         float   zPos   = TryParseFloat(ZPosInput.text);
         Vector3 pos    = new Vector3(xPos, yPos, zPos);
         return(pos);
     }
     catch (Exception e)
     {
         Debug.LogError("Input Pos Error");
         return(Vector3.zero);
     }
 }
 /// <summary>
 /// 获取物体的缩放
 /// </summary>
 /// <returns></returns>
 private Vector3 TryParseScale()
 {
     try
     {
         DevPos  devPos    = CurrentDev.Info.Pos;
         float   scaleX    = TryParseFloat(ScaleXInput.text);
         float   scaleY    = TryParseFloat(ScaleYInput.text);
         float   scaleZ    = TryParseFloat(ScaleZInput.text);
         Vector3 scaleTemp = new Vector3(scaleX, scaleY, scaleZ);
         return(scaleTemp);
     }
     catch (Exception e)
     {
         Debug.LogError("Input Pos Error");
         return(Vector3.one);
     }
 }
示例#23
0
 /// <summary>
 /// 添加门禁信息
 /// </summary>
 /// <param name="cameraDev"></param>
 /// <param name="bll"></param>
 private static void AddDoorAccessInfo(DoorAccess doorAccess, Bll bll)
 {
     try
     {
         DevInfoBackup dev     = DoorAccessToDevInfo(doorAccess);
         DevInfo       devInfo = GetDevInfo(dev);
         DevPos        devPos  = GetDevPos(dev);
         devInfo.SetPos(devPos);
         DevInfo infoTemp = bll.DevInfos.Find(i => i.Local_DevID == devInfo.Local_DevID);
         if (infoTemp == null)
         {
             bll.DevInfos.Add(devInfo);
             DbModel.Location.AreaAndDev.Dev_DoorAccess doorAccessDev = GetDoorAccessInfo(doorAccess, devInfo);
             bll.Dev_DoorAccess.Add(doorAccessDev);
         }
         else
         {
             UpgradeDevInfo(infoTemp, devInfo);
             bool value = bll.DevInfos.Edit(infoTemp);
             if (!value)
             {
                 Log.Info("Error: EditDevinfo Error");
             }
             DbModel.Location.AreaAndDev.Dev_DoorAccess doorAccessBackup   = GetDoorAccessInfo(doorAccess, infoTemp);
             DbModel.Location.AreaAndDev.Dev_DoorAccess doorAccessDatabase = bll.Dev_DoorAccess.Find(door => door.Local_DevID == devInfo.Local_DevID);
             if (doorAccessDatabase == null)
             {
                 bll.Dev_DoorAccess.Add(doorAccessBackup);
             }
             else
             {
                 UpgradeDoorAccessInfo(doorAccessBackup, doorAccessDatabase);
                 bool valueT = bll.Dev_DoorAccess.Edit(doorAccessDatabase);
                 if (!valueT)
                 {
                     Log.Info("Error:Edit Dev_DoorAccess Error");
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Info("Error in DevInfoHelper.AddDevInfo:" + e.ToString());
     }
 }
示例#24
0
        /// <summary>
        /// 获取设备位置信息
        /// </summary>
        /// <param name="dev"></param>
        /// <returns></returns>
        private static DevPos GetDevPos(DevInfoBackup dev)
        {
            DevPos pos = new DevPos
            {
                DevID     = dev.DevId,
                PosX      = TryParseFloat(dev.XPos),
                PosY      = TryParseFloat(dev.YPos),
                PosZ      = TryParseFloat(dev.ZPos),
                RotationX = TryParseFloat(dev.RotationX),
                RotationY = TryParseFloat(dev.RotationY),
                RotationZ = TryParseFloat(dev.RotationZ),
                ScaleX    = TryParseFloat(dev.ScaleX),
                ScaleY    = TryParseFloat(dev.ScaleY),
                ScaleZ    = TryParseFloat(dev.ScaleZ)
            };

            return(pos);
        }
示例#25
0
 /// <summary>
 /// 添加基站设备
 /// </summary>
 /// <param name="devList">设备列表</param>
 /// <param name="devBlls">数据信息</param>
 /// <param name="areaId">设备所属区域ID</param>
 private static void AddLocationDev(List <LocationDevice> devList, ArchorBll archorBll, Area area)
 {
     for (int i = 0; i < devList.Count; i++)
     {
         var     locationDev = devList[i];
         DevInfo devInfo     = GetDevInfo(locationDev, area);
         DevPos  devPos      = GetDevPos(locationDev, devInfo.Local_DevID);
         Archor  archor      = GetAnchorInfo(locationDev, devInfo.Id);
         archor.ParentId = area.Id;
         if (string.IsNullOrEmpty(archor.Code) || archor.Code.Contains("Code"))
         {
             archor.Code = "Code_" + i;
         }
         devInfo.SetPos(devPos);
         archor.DevInfo = devInfo;
         archorBll.Add(archor);
         //devBlls.Add(devInfo);
     }
 }
示例#26
0
        private void SaveDoorAccessToXml(IList <Location.TModel.Location.AreaAndDev.Dev_DoorAccess> doorList, LocationService service)
        {
            DoorAccessList backUpList = new DoorAccessList();

            backUpList.DevList = new List <DoorAccess>();
            foreach (var item in doorList)
            {
                if (item.DevInfo == null)
                {
                    continue;
                }
                DoorAccess dev = new DoorAccess();
                dev.DevId          = item.DevInfo.DevID;
                dev.KKSCode        = item.DevInfo.KKSCode;
                dev.Abutment_DevID = item.DevInfo.Abutment_DevID;
                dev.ModelName      = item.DevInfo.ModelName;
                dev.Name           = item.DevInfo.Name;
                dev.ParentName     = GetAreaPath((int)item.ParentId, service);
                dev.TypeCode       = item.DevInfo.TypeCode.ToString();

                DevPos pos = item.DevInfo.Pos;

                dev.RotationX = pos.RotationX.ToString();
                dev.RotationY = pos.RotationY.ToString();
                dev.RotationZ = pos.RotationZ.ToString();

                dev.XPos = pos.PosX.ToString();
                dev.YPos = pos.PosY.ToString();
                dev.ZPos = pos.PosZ.ToString();

                dev.ScaleX = pos.ScaleX.ToString();
                dev.ScaleY = pos.ScaleY.ToString();
                dev.ScaleZ = pos.ScaleZ.ToString();

                dev.DoorId      = item.DoorId;
                dev.Local_DevId = item.DevID;
                backUpList.DevList.Add(dev);
            }
            //string initFile = GetSaveDevDirectory() + "DoorAccessBackup.xml";
            //XmlSerializeHelper.Save(backUpList, initFile, Encoding.UTF8);
            SaveDoorAccessDevXml("DoorAccessBackup.xml", backUpList);
        }
    /// <summary>
    /// 保存信息
    /// </summary>
    private void SaveInfo()
    {
        Debug.Log("SaveInfo:" + CurrentDev.Info.Name);
        CheckInputValue();
        DeviceEditUIManager manager = DeviceEditUIManager.Instacne;

        if (CurrentDev != null)
        {
            CurrentDev.Info.Name    = NameInput.text;
            CurrentDev.Info.KKSCode = IDField.text;
            string typeCode = CurrentDev.Info.TypeCode.ToString();
            DevPos posInfo  = null;
            if (!TypeCodeHelper.IsStaticDev(typeCode))
            {
                ChangeDevPosAngle();
                bool    isLocation = !(CurrentDev.ParentDepNode == FactoryDepManager.Instance);
                Vector3 cadPos     = LocationManager.UnityToCadPos(TryParsePos(), isLocation);
                posInfo = CurrentDev.Info.Pos;
                if (posInfo != null)
                {
                    posInfo.PosX      = cadPos.x;
                    posInfo.PosY      = cadPos.y;
                    posInfo.PosZ      = cadPos.z;
                    posInfo.RotationY = TryParseFloat(AngleInput.text);
                    posInfo.ScaleX    = TryParseFloat(ScaleXInput.text);
                    posInfo.ScaleY    = TryParseFloat(ScaleYInput.text);
                    posInfo.ScaleZ    = TryParseFloat(ScaleZInput.text);
                }
                manager.RefleshGizmoPosition();
            }
            manager.ChangeDevFollowInfo(CurrentDev);
            CommunicationObject service = CommunicationObject.Instance;
            if (service)
            {
                service.ModifyDevInfo(CurrentDev.Info);
                if (!TypeCodeHelper.IsStaticDev(typeCode))
                {
                    service.ModifyDevPos(posInfo);
                }
            }
        }
    }
示例#28
0
    /// <summary>
    /// 检测输入框的值
    /// </summary>
    private void CheckInputValue()
    {
        if (TypeCodeHelper.IsStaticDev(CurrentDev.Info.TypeCode.ToString()))
        {
            return;
        }
        DevPos  devPos    = CurrentDev.Info.Pos;
        Vector3 cadPos    = new Vector3(devPos.PosX, devPos.PosY, devPos.PosZ);
        bool    isRoomDev = CurrentDev.IsLocal();
        Vector3 pos       = LocationManager.CadToUnityPos(cadPos, isRoomDev);

        if (string.IsNullOrEmpty(NameField.text))
        {
            NameField.text = CurrentDev.Info.Name;
        }
        CheckEmptyField(XPosField, pos.x);
        CheckEmptyField(YPosField, pos.y);
        CheckEmptyField(ZPosField, pos.z);
        CheckEmptyField(AngleField, devPos.RotationY);
    }
示例#29
0
    /// <summary>
    /// 保存数据信息
    /// </summary>
    private void SaveData()
    {
        CommunicationObject service = CommunicationObject.Instance;

        if (service == null)
        {
            return;
        }
        DevNode modelTemp = CopyObj.GetComponent <DevNode>();

        if (modelTemp == null)
        {
            return;
        }
        modelTemp.Info.Pos.RotationY = CopyObj.transform.eulerAngles.y;
        service.ModifyDevPos(modelTemp.Info.Pos);
        if (list != null && list.Count != 0)
        {
            //DataAccessController.Instance.ModifyDevInRoomEx(model);
            List <DevInfo> devinfoList = new List <DevInfo>();
            for (int i = 0; i < list.Count; i++)
            {
                GameObject devModel = list[i];
                DevInfo    devInfo  = GetDevInfo(modelTemp.Info, i);
                devModel.transform.parent = CopyObj.transform.parent;
                devModel.layer            = CopyObj.layer;
                DevNode dev = SetDevController(devInfo, devModel);
                if (dev == null)
                {
                    continue;
                }
                DevPos pos = GetDevPos(dev, devInfo.DevID);
                devInfo.Pos = pos;
                devinfoList.Add(devInfo);
            }
            List <DevInfo> infoList = service.AddDevInfo(devinfoList);
            SetDevInfoId(devinfoList, infoList);
            SaveDevSubInfo(list, service);
        }
        AddSelectionDevs(list);
    }
示例#30
0
        /// <summary>
        /// 保存通用设备
        /// </summary>
        private void SaveNormalDev(List <Location.TModel.Location.AreaAndDev.DevInfo> devInfoList, LocationService service)
        {
            DevInfoBackupList backUpList = new DevInfoBackupList();

            backUpList.DevList = new List <DevInfoBackup>();
            foreach (var item in devInfoList)
            {
                string typeCodeT = item.TypeCode.ToString();
                if (TypeCodeHelper.IsLocationDev(typeCodeT) || TypeCodeHelper.IsCamera(typeCodeT) || TypeCodeHelper.IsDoorAccess(item.ModelName))
                {
                    continue;
                }
                DevInfoBackup dev = new DevInfoBackup();
                dev.DevId      = item.DevID;
                dev.KKSCode    = item.KKSCode;
                dev.ModelName  = item.ModelName;
                dev.Name       = item.Name;
                dev.ParentName = GetAreaPath((int)item.ParentId, service);
                dev.TypeCode   = item.TypeCode.ToString();

                DevPos pos = item.Pos;

                dev.RotationX = pos.RotationX.ToString();
                dev.RotationY = pos.RotationY.ToString();
                dev.RotationZ = pos.RotationZ.ToString();

                dev.XPos = pos.PosX.ToString();
                dev.YPos = pos.PosY.ToString();
                dev.ZPos = pos.PosZ.ToString();

                dev.ScaleX = pos.ScaleX.ToString();
                dev.ScaleY = pos.ScaleY.ToString();
                dev.ScaleZ = pos.ScaleZ.ToString();

                backUpList.DevList.Add(dev);
            }
            string initFile = AppDomain.CurrentDomain.BaseDirectory + "Data\\设备信息\\DevInfoBackup.xml";

            XmlSerializeHelper.Save(backUpList, initFile, Encoding.UTF8);
        }