Exemplo n.º 1
0
        public void DownloadExecute()
        {
            List <DeviceInfo8003> list     = TheLoop.GetDevices <DeviceInfo8003>();
            List <DeviceInfoBase> baseList = new List <DeviceInfoBase>();

            foreach (var item in list)
            {
                DeviceInfoBase baseItem = (DeviceInfoBase)item;
                baseList.Add(baseItem);
            }

            ProjectManager.GetInstance.NTConnection.SetDeviceSetup(baseList, TheLoop.DeviceAmount, TheLoop.Controller.Type);

            //InvokeControllerCom iCC = InvokeControllerCom.Instance;
            //if (iCC.GetPortStatus())
            //{
            //    if (iCC.TheControllerType != null) //如果已经取得当前的控制器类型
            //    {
            //        if (iCC.TheControllerType.ControllerType == ControllerType.FT8003) //如果控制器类型不相符,则不执行操作
            //        {

            //            List<LoopModel> lstLoopsModel = new List<LoopModel>();
            //            lstLoopsModel.Add(TheLoop);
            //            ((ControllerType8003)iCC.TheControllerType).Loops = lstLoopsModel;

            //            iCC.TheControllerType.OperableDataType = OperantDataType.Device;
            //            iCC.TheControllerType.Status = ControllerStatus.DataSending;
            //            iCC.TheControllerType.UpdateProgressBarEvent += UpdateProcessBarStatus;
            //        }
            //    }
            //}
        }
Exemplo n.º 2
0
        public void DownloadExecute()
        {
            List <DeviceInfo8053> list     = TheLoop.GetDevices <DeviceInfo8053>();
            List <DeviceInfoBase> baseList = new List <DeviceInfoBase>();

            foreach (var item in list)
            {
                DeviceInfoBase baseItem = (DeviceInfoBase)item;
                baseList.Add(baseItem);
            }

            ProjectManager.GetInstance.NTConnection.SetDeviceSetup(baseList, TheLoop.DeviceAmount, TheLoop.Controller.Type);
        }
Exemplo n.º 3
0
        public List <DeviceInfo8053> Create(int amount)
        {
            //List<DeviceInfo8053> lstDeviceInfo8053 = new List<DeviceInfo8053>();
            //int currentMaxCode = GetMaxCode();
            //for (int i = 0; i < amount; i++)
            //{
            //    currentMaxCode++;
            //    DeviceInfo8053 dev = new DeviceInfo8053();
            //    dev.Loop = TheLoop;
            //    //需要根据器件编码指定编码位数
            //    dev.Code = currentMaxCode.ToString();
            //    lstDeviceInfo8053.Add(dev);
            //}
            //return lstDeviceInfo8053;
            List <DeviceInfo8053> lstDeviceInfo8053 = new List <DeviceInfo8053>();
            int currentMaxCode = GetMaxCode();

            if (currentMaxCode >= MaxDeviceAmount)
            {
                amount = 0;
            }
            else
            {
                if ((currentMaxCode + amount) > MaxDeviceAmount) //如果需要添加的行数将达上限,则增加剩余的行数
                {
                    amount = MaxDeviceAmount - currentMaxCode;
                }
                int deviceID = ProjectManager.GetInstance.MaxDeviceIDInController8053;
                for (int i = 0; i < amount; i++)
                {
                    currentMaxCode++;
                    deviceID++;
                    DeviceInfo8053 dev = new DeviceInfo8053();
                    dev.Loop = TheLoop;
                    //需要根据器件编码指定编码位数
                    //dev.Code = currentMaxCode.ToString();
                    dev.Code = TheLoop.Code + currentMaxCode.ToString().PadLeft(3, '0');//暂时将器件长度固定为3
                    dev.ID   = deviceID;
                    lstDeviceInfo8053.Add(dev);
                }
                //更新最大ID值
                BusinessLib.ProjectManager.GetInstance.MaxDeviceIDInController8053 = deviceID;
                foreach (var singleItem in lstDeviceInfo8053)
                {
                    Update(singleItem);
                }
                TheLoop.DeviceAmount = TheLoop.GetDevices <DeviceInfo8053>().Count;
            }
            return(lstDeviceInfo8053);
        }
Exemplo n.º 4
0
 public bool Update(DeviceInfo8001 deviceInfo)
 {
     try
     {
         DeviceInfo8001 result = TheLoop.GetDevices <DeviceInfo8001>().Find(
             delegate(DeviceInfo8001 x)
         {
             return(x.Code == deviceInfo.Code);
         }
             );
         if (result != null)
         {
             result.Loop   = deviceInfo.Loop;
             result.LoopID = deviceInfo.LoopID;
             //deviceInfo.MachineNo = result.MachineNo;//临时应用
             //  result.ID = deviceInfo.ID;
             //  result.Code = deviceInfo.Code;
             //result.SimpleCode = deviceInfo.SimpleCode;
             result.TypeCode       = deviceInfo.TypeCode;
             result.LinkageGroup1  = deviceInfo.LinkageGroup1;
             result.LinkageGroup2  = deviceInfo.LinkageGroup2;
             result.LinkageGroup3  = deviceInfo.LinkageGroup3;
             result.BoardNo        = deviceInfo.BoardNo;
             result.SubBoardNo     = deviceInfo.SubBoardNo;
             result.KeyNo          = deviceInfo.KeyNo;
             result.BroadcastZone  = deviceInfo.BroadcastZone;
             result.DelayValue     = deviceInfo.DelayValue;
             result.SensitiveLevel = deviceInfo.SensitiveLevel;
             result.Feature        = deviceInfo.Feature;
             result.Disable        = deviceInfo.Disable;
             result.BuildingNo     = deviceInfo.BuildingNo;
             result.ZoneNo         = deviceInfo.ZoneNo;
             result.FloorNo        = deviceInfo.FloorNo;
             result.RoomNo         = deviceInfo.RoomNo;
             result.Location       = deviceInfo.Location;
             result.sdpKey         = deviceInfo.sdpKey;
             result.MCBCode        = deviceInfo.MCBCode;
         }
         else
         {
             TheLoop.SetDevice <DeviceInfo8001>(deviceInfo);
         }
         this.TheLoop.IsDeviceDataDirty = true;
     }
     catch
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 5
0
 /// <summary>
 /// 在回路内是否存在相同的器件代码
 /// </summary>
 /// <param name="deviceCode"></param>
 /// <returns></returns>
 public bool IsExistSameDeviceCode(string deviceCode)
 {
     if (TheLoop != null)
     {
         int deviceCount = TheLoop.GetDevices <DeviceInfo8021>().Count((d) => d.Code == deviceCode);
         if (deviceCount > 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else //TheLoop不应为空
     {
         return(true);
     }
 }
Exemplo n.º 6
0
 public bool DeleteBySpecifiedID(int id)
 {
     try
     {
         var            result = from dev in TheLoop.GetDevices <DeviceInfo8021>() where dev.ID == id select dev;
         DeviceInfo8021 o      = result.FirstOrDefault();
         if (o != null)
         {
             TheLoop.GetDevices <DeviceInfo8021>().Remove(o);
             TheLoop.DeviceAmount = TheLoop.GetDevices <DeviceInfo8021>().Count;
             DeleteDeviceFromDB(id);
         }
     }
     catch
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 7
0
 public bool Update(DeviceInfo8036 deviceInfo)
 {
     try
     {
         DeviceInfo8036 result = TheLoop.GetDevices <DeviceInfo8036>().Find(
             delegate(DeviceInfo8036 x)
         {
             return(x.Code == deviceInfo.Code);
         }
             );
         if (result != null)
         {
             result.Loop   = deviceInfo.Loop;
             result.LoopID = deviceInfo.LoopID;
             //   result.ID = deviceInfo.ID;
             //result.Code = deviceInfo.Code;
             // result.SimpleCode = deviceInfo.SimpleCode;
             result.TypeCode      = deviceInfo.TypeCode;
             result.Disable       = deviceInfo.Disable;
             result.LinkageGroup1 = deviceInfo.LinkageGroup1;
             result.LinkageGroup2 = deviceInfo.LinkageGroup2;
             result.AlertValue    = deviceInfo.AlertValue;
             result.ForcastValue  = deviceInfo.ForcastValue;
             result.DelayValue    = deviceInfo.DelayValue;
             result.BuildingNo    = deviceInfo.BuildingNo;
             result.ZoneNo        = deviceInfo.ZoneNo;
             result.FloorNo       = deviceInfo.FloorNo;
             result.RoomNo        = deviceInfo.RoomNo;
             result.Location      = deviceInfo.Location;
         }
         else
         {
             TheLoop.SetDevice <DeviceInfo8036>(deviceInfo);
         }
     }
     catch
     {
         return(false);
     }
     this.TheLoop.IsDeviceDataDirty = true;
     return(true);
 }
Exemplo n.º 8
0
 public bool IsExistSameDeviceCode()
 {
     if (TheLoop != null)
     {
         bool existFlag = false;
         foreach (var device in TheLoop.GetDevices <DeviceInfo8021>())
         {
             existFlag = IsExistSameDeviceCode(device.Code);
             if (existFlag)
             {
                 return(true);
             }
         }
     }
     else
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 9
0
        public bool Update(DeviceInfo8003 deviceInfo)
        {
            try
            {
                DeviceInfo8003 result = TheLoop.GetDevices <DeviceInfo8003>().Find(
                    delegate(DeviceInfo8003 x)
                {
                    return(x.Code == deviceInfo.Code);
                }
                    );
                if (result != null)
                {
                    result.Loop   = deviceInfo.Loop;
                    result.LoopID = deviceInfo.LoopID;
                    // result.ID = deviceInfo.ID;
                    // result.Code = deviceInfo.Code;
                    result.TypeCode       = deviceInfo.TypeCode;
                    result.SensitiveLevel = deviceInfo.SensitiveLevel;
                    result.Disable        = deviceInfo.Disable;
                    result.LinkageGroup1  = deviceInfo.LinkageGroup1;
                    result.LinkageGroup2  = deviceInfo.LinkageGroup2;
                    result.LinkageGroup3  = deviceInfo.LinkageGroup3;
                    result.DelayValue     = deviceInfo.DelayValue;
                    result.sdpKey         = deviceInfo.sdpKey;
                    result.ZoneNo         = deviceInfo.ZoneNo;
                    result.BroadcastZone  = deviceInfo.BroadcastZone;
                    result.Location       = deviceInfo.Location;
                }
                else
                {
                    TheLoop.SetDevice <DeviceInfo8003>(deviceInfo);
                }
                this.TheLoop.IsDeviceDataDirty = true;
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 10
0
        private int GetMaxCode()
        {
            int result = 0;

            if (TheLoop != null)
            {
                var query = from r in TheLoop.GetDevices <DeviceInfo8021>() select r.Code;
                if (query != null)
                {
                    foreach (var i in query)
                    {
                        string deviceCode = i.Substring(TheLoop.Code.Length);
                        if (Convert.ToInt32(deviceCode) > result)
                        {
                            result = Convert.ToInt32(deviceCode);
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 11
0
 public bool Update(DeviceInfo8021 deviceInfo)
 {
     try
     {
         DeviceInfo8021 result = TheLoop.GetDevices <DeviceInfo8021>().Find(
             delegate(DeviceInfo8021 x)
         {
             return(x.Code == deviceInfo.Code);
         }
             );
         if (result != null)
         {
             result.Loop   = deviceInfo.Loop;
             result.LoopID = deviceInfo.LoopID;
             //result.ID = deviceInfo.ID;
             //   result.Code = deviceInfo.Code;
             //result.SimpleCode = deviceInfo.SimpleCode;
             result.TypeCode             = deviceInfo.TypeCode;
             result.Disable              = deviceInfo.Disable;
             result.CurrentThreshold     = deviceInfo.CurrentThreshold;
             result.TemperatureThreshold = deviceInfo.TemperatureThreshold;
             result.BuildingNo           = deviceInfo.BuildingNo;
             result.ZoneNo   = deviceInfo.ZoneNo;
             result.FloorNo  = deviceInfo.FloorNo;
             result.RoomNo   = deviceInfo.RoomNo;
             result.Location = deviceInfo.Location;
         }
         else
         {
             TheLoop.SetDevice <DeviceInfo8021>(deviceInfo);
         }
     }
     catch
     {
         return(false);
     }
     this.TheLoop.IsDeviceDataDirty = true;
     return(true);
 }
Exemplo n.º 12
0
        public bool UpdateViaSpecifiedColumnName(int id, string[] columnNames, string[] data)
        {
            try
            {
                DeviceInfo8021 result = TheLoop.GetDevices <DeviceInfo8021>().Find(
                    delegate(DeviceInfo8021 x)
                {
                    return(x.ID == id);
                }
                    );
                for (int i = 0; i < columnNames.Length; i++)
                {
                    switch (columnNames[i])
                    {
                    //case "编码":
                    //    result.Code = data[i];
                    //    break;
                    case "器件类型":
                        result.TypeCode = data[i] == "" ? (short)0 : Convert.ToInt16(data[i]);
                        break;

                    case "屏蔽":
                        result.Disable = data[i] == "" ? null : new Nullable <bool>(data[i].ToString().ToUpper() == "TRUE" ? true : false);
                        break;

                    case "电流报警值":
                        result.CurrentThreshold = data[i] == "" ? null : new Nullable <float>(Convert.ToSingle((data[i])));
                        break;

                    case "温度报警值":
                        result.TemperatureThreshold = data[i] == "" ? null : new Nullable <float>(Convert.ToSingle((data[i])));
                        break;

                    case "楼号":
                        result.BuildingNo = data[i] == "" ? null : new Nullable <short>(Convert.ToInt16(data[i]));
                        break;

                    case "区号":
                        result.ZoneNo = data[i] == "" ? null : new Nullable <short>(Convert.ToInt16(data[i]));
                        break;

                    case "层号":
                        result.FloorNo = data[i] == "" ? null : new Nullable <short>(Convert.ToInt16(data[i]));
                        break;

                    case "房间号":
                        result.RoomNo = data[i] == "" ? null : new Nullable <short>(Convert.ToInt16(data[i]));
                        break;

                    case "安装地点":
                        result.Location = data[i];
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 13
0
        public bool UpdateViaSpecifiedColumnName(int id, string[] columnNames, string[] data)
        {
            try
            {
                DeviceInfo8036 result = TheLoop.GetDevices <DeviceInfo8036>().Find(
                    delegate(DeviceInfo8036 x)
                {
                    return(x.ID == id);
                }
                    );
                for (int i = 0; i < columnNames.Length; i++)
                {
                    switch (columnNames[i])
                    {
                    //case "编码":
                    //    result.Code = data[i];
                    //    break;
                    case "器件类型":
                        result.TypeCode = data[i] == "" ? (short)0 : Convert.ToInt16(data[i]);
                        break;

                    case "屏蔽":
                        //需要将Disable存储为0或1
                        result.Disable = data[i] == "" ? null : new Nullable <bool>(data[i].ToString().ToUpper() == "TRUE" ? true : false);
                        break;

                    case "输出组1":
                        result.LinkageGroup1 = data[i];
                        break;

                    case "输出组2":
                        result.LinkageGroup2 = data[i];
                        break;

                    case "报警浓度":
                        result.AlertValue = data[i] == "" ? null : new Nullable <float>(Convert.ToSingle((data[i])));
                        break;

                    case "预警浓度":
                        result.ForcastValue = data[i] == "" ? null : new Nullable <float>(Convert.ToSingle((data[i])));
                        break;

                    case "延时":
                        result.DelayValue = data[i] == "" ? null : new Nullable <short>(Convert.ToInt16(data[i]));
                        break;

                    case "楼号":
                        result.BuildingNo = data[i] == "" ? null : new Nullable <short>(Convert.ToInt16(data[i]));
                        break;

                    case "区号":
                        result.ZoneNo = data[i] == "" ? null : new Nullable <short>(Convert.ToInt16(data[i]));
                        break;

                    case "层号":
                        result.FloorNo = data[i] == "" ? null : new Nullable <short>(Convert.ToInt16(data[i]));
                        break;

                    case "房间号":
                        result.RoomNo = data[i] == "" ? null : new Nullable <short>(Convert.ToInt16(data[i]));
                        break;

                    case "安装地点":
                        result.Location = data[i];
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 14
0
        /// <summary>
        /// 更新指定ID的数据
        /// </summary>
        /// <param name="id">待更新数据的ID</param>
        /// <param name="columnNames">列名</param>
        /// <param name="data">新数据</param>
        /// <returns></returns>
        public bool UpdateViaSpecifiedColumnName(int id, string[] columnNames, string[] data)
        {
            try
            {
                DeviceInfo8000 result = TheLoop.GetDevices <DeviceInfo8000>().Find(
                    delegate(DeviceInfo8000 x)
                {
                    return(x.ID == id);
                }
                    );
                for (int i = 0; i < columnNames.Length; i++)
                {
                    switch (columnNames[i])
                    {
                    //case "编码":
                    //    result.Code = data[i];
                    //    break;
                    case "器件类型":
                        result.TypeCode = data[i] == "" ? (short)0 : Convert.ToInt16(data[i]);
                        break;

                    case "特性":
                        result.Feature = data[i] == "" ? null : new Nullable <short>(Convert.ToInt16(data[i]));
                        break;

                    case "屏蔽":
                        result.Disable = data[i] == "" ? null : new Nullable <bool>(data[i].ToString().ToUpper() == "TRUE" ? true : false);
                        break;

                    case "灵敏度":
                        result.SensitiveLevel = data[i] == "" ? null : new Nullable <short>(Convert.ToInt16(data[i]));
                        break;

                    case "输出组1":
                        result.LinkageGroup1 = data[i];
                        break;

                    case "输出组2":
                        result.LinkageGroup2 = data[i];
                        break;

                    case "输出组3":
                        result.LinkageGroup3 = data[i];
                        break;

                    case "延时":
                        result.DelayValue = data[i] == "" ? null : new Nullable <short>(Convert.ToInt16(data[i]));
                        break;

                    case "手操号":
                        result.sdpKey = data[i];
                        break;

                    case "区号":
                        result.ZoneNo = data[i] == "" ? null : new Nullable <short>(Convert.ToInt16(data[i]));
                        break;

                    case "广播分区":
                        result.BroadcastZone = data[i];
                        break;

                    case "安装地点":
                        result.Location = data[i];
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }