Пример #1
0
    /// <summary>
    /// 告警恢复
    /// </summary>
    /// <param name="alarmInfo"></param>
    private void RemoveAlarmInfo(DeviceAlarm alarmInfo)
    {
        //if (AlarmDevsId.Contains(alarmInfo.DevId)) AlarmDevsId.Remove(alarmInfo.DevId);
        //else
        //{
        //    Debug.Log("CancelAlarm Failed,Dev is null.DevId:" + alarmInfo.DevId);
        //    return;
        //}
        DeviceAlarm alarmInfoTemp = AlarmInfoList.Find(dev => dev.DevId == alarmInfo.DevId);

        if (alarmInfoTemp == null)
        {
            return;
        }
        AlarmInfoList.Remove(alarmInfoTemp);
        //恢复正在告警的设备
        if (IsDepDev(FactoryDepManager.currentDep, alarmInfo.AreaId.ToString()))
        {
            try
            {
                if (TypeCodeHelper.IsFireFightDevType(alarmInfo.DevTypeCode.ToString()))
                {
                    DepNode area = RoomFactory.Instance.GetDepNodeById((int)alarmInfo.AreaId);
                    if (area != null)
                    {
                        AlarmMonitorRange(false, alarmInfo, area);
                    }
                }
                else
                {
                    DevAlarmInfo dev = AlarmDevList.Find(i => i.AlarmInfo.DevId == alarmInfo.DevId);
                    if (dev == null)
                    {
                        return;
                    }
                    dev.AlarmOff(true);
                    AlarmDevList.Remove(dev);
                    DestroyImmediate(dev);
                }
            }
            catch (Exception e)
            {
                Debug.Log(e.ToString());
            }
        }
    }
Пример #2
0
    /// <summary>
    /// 服务端推送告警信息
    /// </summary>
    private void PushAlarmInfo(DeviceAlarm alarmInfo)
    {
        var logTag = "DevAlarmManage.PushAlarmInfo";

        Log.Info(logTag);
        //if (AlarmDevsId.Contains(alarmInfo.DevId))
        //{
        //    Debug.Log("Alarm is already exist.");
        //    return;
        //}
        //AlarmDevsId.Add(alarmInfo.DevId);
        if (AlarmInfoList.Contains(alarmInfo))
        {
            Debug.Log("Alarm is already exist.");
            return;
        }
        AlarmInfoList.Add(alarmInfo);

        string parentId           = alarmInfo.AreaId.ToString();
        bool   isDepDev           = IsDepDev(FactoryDepManager.currentDep, parentId);
        bool   isFireFightDevType = TypeCodeHelper.IsFireFightDevType(alarmInfo.DevTypeCode.ToString());

        Log.Info(logTag, string.Format("isDepDev:{0},isFireFightDevType:{1}", isDepDev, isFireFightDevType));
        if (isDepDev)
        {
            DevNode dev = RoomFactory.Instance.GetCreateDevById(alarmInfo.DevId.ToString(), int.Parse(parentId));
            if (dev == null && !isFireFightDevType)
            {
                Debug.LogError("Dev not find:" + alarmInfo.DevId);
                return;
            }
            AlarmDev(dev, alarmInfo);
        }
        else
        {
            if (isFireFightDevType)
            {
                int areaId = (int)alarmInfo.AreaId;
                if (!FireAreas.Contains(areaId))
                {
                    FireAreas.Add(areaId);
                }
            }
        }
    }
Пример #3
0
        /// <summary>
        /// 通过文件导入设备信息
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="devBll"></param>
        /// <returns></returns>
        public static bool ImportDevInfoFromFile(string filePath, Bll bll)
        {
            if (!File.Exists(filePath) || bll == null)
            {
                Log.Error("文件不存在:" + filePath);
                return(false);
            }
            var initInfo = XmlSerializeHelper.LoadFromFile <DevInfoBackupList>(filePath);

            if (initInfo == null || initInfo.DevList == null || initInfo.DevList.Count == 0)
            {
                return(false);
            }
            var areas = bll.Areas.ToList();

            //var devs = bll.DevInfos.Where(i => i.Local_TypeCode != TypeCodes.Archor);
            //bll.DevInfos.RemoveList(devs);//先清空所有设备
            foreach (var devInfo in initInfo.DevList)
            {
                if (devInfo.TypeCode == TypeCodes.Archor + "" || TypeCodeHelper.IsFireFightDevType(devInfo.TypeCode))
                {
                    continue;
                }
                if (devInfo.TypeCode == DeleteTypeCode)
                {
                    //RemoveDeleteDev(devInfo, bll.DevInfos);
                }
                else
                {
                    int?parentID = GetAreaIdByPath(devInfo.ParentName, areas);
                    if (parentID != null)
                    {
                        devInfo.ParentId = (int)parentID;
                        bool r = AddDevInfo(devInfo, bll.DevInfos);
                        if (r == false)
                        {
                            Log.Info("ImportDevInfoFromFile Error:" + devInfo.Name);
                        }
                    }
                }
            }
            return(true);
        }
Пример #4
0
    /// <summary>
    /// 显示设备告警
    /// </summary>
    /// <param name="dev"></param>
    /// <param name="alarmInfo"></param>
    private void AlarmDev(DevNode dev, DeviceAlarm alarmInfo)
    {
        var logTag = "DevAlarmManage.AlarmDev";

        Log.Info(logTag);
        if (TypeCodeHelper.IsFireFightDevType(alarmInfo.DevTypeCode.ToString()))
        {
            DepNode area = RoomFactory.Instance.GetDepNodeById((int)alarmInfo.AreaId);
            if (area != null)
            {
                AlarmMonitorRange(true, alarmInfo, area);
            }
        }
        else
        {
            if (dev == null || dev.gameObject == null)
            {
                return;
            }
            DevAlarmInfo info = dev.gameObject.GetComponent <DevAlarmInfo>();
            if (info == null)
            {
                info = dev.gameObject.AddMissingComponent <DevAlarmInfo>();
            }
            if (!AlarmDevList.Contains(info))
            {
                AlarmDevList.Add(info);
            }

            //Debug.LogError("增加告警信息:"+alarmInfo.Message);
            info.InitAlarmInfo(alarmInfo, dev); //设置告警内容
            info.AlarmOn();                     //高亮显示

            if (FollowTargetManage.Instance)    //告警跟随UI信息
            {
                FollowTargetManage.Instance.SetAlarmFollowUI(dev, alarmInfo);
            }
        }
    }
Пример #5
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);
        }
Пример #6
0
    /// <summary>
    /// 区域是否有消防告警
    /// </summary>
    /// <param name="depId"></param>
    /// <returns></returns>
    public bool IsDepFireAlarm(int depId)
    {
        DeviceAlarm alarmT = AlarmInfoList.Find(dev => dev != null && dev.AreaId == depId && TypeCodeHelper.IsFireFightDevType(dev.DevTypeCode.ToString()));

        return(alarmT == null ? false : true);
    }