Esempio n. 1
0
        private bool UpdateDeviceInfo(ControllerType controllerType, ref LoopModel loop)
        {
            bool result = false;

            switch (controllerType)
            {
            case ControllerType.NT8001:
                break;

            case ControllerType.NT8007:
                break;

            case ControllerType.NT8021:
                break;

            case ControllerType.NT8036:
                break;

            case ControllerType.FT8000:
            {
                List <DeviceInfo8000> lstDeviceInfo = loop.GetDevices <DeviceInfo8000>();
                foreach (var device in lstDeviceInfo)
                {
                    if (device.TypeCode > 36 && device.TypeCode < 66)
                    {
                        device.Feature = 0;
                    }
                    else if (device.TypeCode >= 101 && device.TypeCode <= 129)
                    {
                        device.Feature  = 1;
                        device.TypeCode = System.Convert.ToInt16(device.TypeCode - 64);
                    }
                }
            }
            break;

            case ControllerType.FT8003:
            {
                List <DeviceInfo8003> lstDeviceInfo = loop.GetDevices <DeviceInfo8003>();
                foreach (var device in lstDeviceInfo)
                {
                    if (device.TypeCode > 36 && device.TypeCode < 66)
                    {
                        device.Feature = 0;
                    }
                    else if (device.TypeCode >= 101 && device.TypeCode <= 129)
                    {
                        device.Feature  = 1;
                        device.TypeCode = System.Convert.ToInt16(device.TypeCode - 64);
                    }
                }
            }
            break;
            }
            return(result);
        }
Esempio n. 2
0
 public bool AddDevice(LoopModel loop)
 {
     try
     {
         List <DeviceInfo8003> lstDevices = loop.GetDevices <DeviceInfo8003>();
         foreach (var device in lstDevices)
         {
             device.Loop.ID = loop.ID;
             device.LoopID  = loop.ID;
             //StringBuilder sbDeviceInfoSQL = new StringBuilder("REPLACE INTO DeviceInfo8003(");
             //sbDeviceInfoSQL.Append("ID,");
             //sbDeviceInfoSQL.Append("Code,");
             //sbDeviceInfoSQL.Append("Disable,");
             //sbDeviceInfoSQL.Append("Feature,");
             //sbDeviceInfoSQL.Append("DelayValue,");
             //sbDeviceInfoSQL.Append("SensitiveLevel,");
             //sbDeviceInfoSQL.Append("LinkageGroup1,");
             //sbDeviceInfoSQL.Append("LinkageGroup2,");
             //sbDeviceInfoSQL.Append("LinkageGroup3,");
             //sbDeviceInfoSQL.Append("sdpKey,");
             //sbDeviceInfoSQL.Append("BroadcastZone,");
             //sbDeviceInfoSQL.Append("ZoneNo,");
             //sbDeviceInfoSQL.Append("Location,");
             //sbDeviceInfoSQL.Append("LoopID,");
             //sbDeviceInfoSQL.Append("TypeCode)");
             //sbDeviceInfoSQL.Append(" VALUES(");
             //sbDeviceInfoSQL.Append(device.ID + ",'");
             //sbDeviceInfoSQL.Append(device.Code + "','");
             //sbDeviceInfoSQL.Append(device.Disable + "','");
             //sbDeviceInfoSQL.Append(device.Feature + "','");
             //sbDeviceInfoSQL.Append(device.DelayValue + "','");
             //sbDeviceInfoSQL.Append(device.SensitiveLevel + "','");
             //sbDeviceInfoSQL.Append(device.LinkageGroup1 + "','");
             //sbDeviceInfoSQL.Append(device.LinkageGroup2 + "','");
             //sbDeviceInfoSQL.Append(device.LinkageGroup3 + "','");
             //sbDeviceInfoSQL.Append(device.sdpKey + "','");
             //sbDeviceInfoSQL.Append(device.BroadcastZone + "','");
             //sbDeviceInfoSQL.Append(device.ZoneNo + "','");
             //sbDeviceInfoSQL.Append(device.Location + "','");
             //sbDeviceInfoSQL.Append(device.LoopID + "','");
             //sbDeviceInfoSQL.Append(device.TypeCode + "');");
             //_databaseService.ExecuteBySql(sbDeviceInfoSQL);
             _dbFileVersionService.AddDeviceForControllerType8003(device);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 3
0
 bool IDeviceDBServiceTest.AddDevice(LoopModel loop)
 {
     try
     {
         List <DeviceInfo8036> lstDevices = loop.GetDevices <DeviceInfo8036>();
         foreach (var device in lstDevices)
         {
             device.Loop.ID = loop.ID;
             device.LoopID  = loop.ID;
             //StringBuilder sbDeviceInfoSQL = new StringBuilder("REPLACE INTO DeviceInfo8036");
             //sbDeviceInfoSQL.Append("(ID,");
             //sbDeviceInfoSQL.Append("Code ,");
             //sbDeviceInfoSQL.Append("Disable,");
             //sbDeviceInfoSQL.Append("LinkageGroup1,");
             //sbDeviceInfoSQL.Append("LinkageGroup2,");
             //sbDeviceInfoSQL.Append("AlertValue ,");
             //sbDeviceInfoSQL.Append("ForcastValue ,");
             //sbDeviceInfoSQL.Append("DelayValue ,");
             //sbDeviceInfoSQL.Append("BuildingNo ,");
             //sbDeviceInfoSQL.Append("ZoneNo ,");
             //sbDeviceInfoSQL.Append("FloorNo ,");
             //sbDeviceInfoSQL.Append("RoomNo ,");
             //sbDeviceInfoSQL.Append("Location ,");
             //sbDeviceInfoSQL.Append("LoopID,");
             //sbDeviceInfoSQL.Append("TypeCode");
             //sbDeviceInfoSQL.Append(") VALUES(");
             //sbDeviceInfoSQL.Append(device.ID + ",'");
             //sbDeviceInfoSQL.Append(device.Code + "','");
             //sbDeviceInfoSQL.Append(device.Disable + "','");
             //sbDeviceInfoSQL.Append(device.LinkageGroup1 + "','");
             //sbDeviceInfoSQL.Append(device.LinkageGroup2 + "','");
             //sbDeviceInfoSQL.Append(device.AlertValue + "','");
             //sbDeviceInfoSQL.Append(device.ForcastValue + "','");
             //sbDeviceInfoSQL.Append(device.DelayValue + "','");
             //sbDeviceInfoSQL.Append(device.BuildingNo + "','");
             //sbDeviceInfoSQL.Append(device.ZoneNo + "','");
             //sbDeviceInfoSQL.Append(device.FloorNo + "','");
             //sbDeviceInfoSQL.Append(device.RoomNo + "','");
             //sbDeviceInfoSQL.Append(device.Location + "','");
             //sbDeviceInfoSQL.Append(device.LoopID + "','");
             //sbDeviceInfoSQL.Append(device.TypeCode + "');");
             //_databaseService.ExecuteBySql(sbDeviceInfoSQL);
             _dbFileVersionService.AddDeviceForControllerType8036(device);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 4
0
 public bool AddDevice(LoopModel loop)
 {
     try
     {
         List <DeviceInfo8007> lstDevices = loop.GetDevices <DeviceInfo8007>();
         foreach (var device in lstDevices)
         {
             device.Loop.ID = loop.ID;
             device.LoopID  = loop.ID;
             StringBuilder sbDeviceInfoSQL = new StringBuilder("REPLACE INTO DeviceInfo8007(");
             sbDeviceInfoSQL.Append("ID,");
             sbDeviceInfoSQL.Append("Code,");
             sbDeviceInfoSQL.Append("Disable,");
             sbDeviceInfoSQL.Append("Feature,");
             sbDeviceInfoSQL.Append("SensitiveLevel,");
             sbDeviceInfoSQL.Append("LinkageGroup1,");
             sbDeviceInfoSQL.Append("LinkageGroup2,");
             sbDeviceInfoSQL.Append("BuildingNo,");
             sbDeviceInfoSQL.Append("ZoneNo,");
             sbDeviceInfoSQL.Append("FloorNo,");
             sbDeviceInfoSQL.Append("RoomNo,");
             sbDeviceInfoSQL.Append("Location,");
             sbDeviceInfoSQL.Append("LoopID,");
             sbDeviceInfoSQL.Append("TypeCode)");
             sbDeviceInfoSQL.Append(" VALUES(");
             sbDeviceInfoSQL.Append(device.ID + ",'");
             sbDeviceInfoSQL.Append(device.Code + "','");
             sbDeviceInfoSQL.Append(device.Disable + "','");
             sbDeviceInfoSQL.Append(device.Feature + "','");
             sbDeviceInfoSQL.Append(device.SensitiveLevel + "','");
             sbDeviceInfoSQL.Append(device.LinkageGroup1 + "','");
             sbDeviceInfoSQL.Append(device.LinkageGroup2 + "','");
             sbDeviceInfoSQL.Append(device.BuildingNo + "','");
             sbDeviceInfoSQL.Append(device.ZoneNo + "','");
             sbDeviceInfoSQL.Append(device.FloorNo + "','");
             sbDeviceInfoSQL.Append(device.RoomNo + "','");
             sbDeviceInfoSQL.Append(device.Location + "','");
             sbDeviceInfoSQL.Append(device.LoopID + "','");
             sbDeviceInfoSQL.Append(device.TypeCode + "');");
             _databaseService.ExecuteBySql(sbDeviceInfoSQL);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 5
0
 public bool AddDevice(LoopModel loop)
 {
     try
     {
         List <DeviceInfo8021> lstDevices = loop.GetDevices <DeviceInfo8021>();
         foreach (var device in lstDevices)
         {
             device.Loop.ID = loop.ID;
             device.LoopID  = loop.ID;
             //StringBuilder sbDeviceInfoSQL = new StringBuilder("REPLACE INTO DeviceInfo8021(");
             //sbDeviceInfoSQL.Append("ID,");
             //sbDeviceInfoSQL.Append("Code,");
             //sbDeviceInfoSQL.Append("Disable,");
             //sbDeviceInfoSQL.Append("CurrentThreshold,");
             //sbDeviceInfoSQL.Append("TemperatureThreshold,");
             //sbDeviceInfoSQL.Append("BuildingNo,");
             //sbDeviceInfoSQL.Append("ZoneNo,");
             //sbDeviceInfoSQL.Append("FloorNo,");
             //sbDeviceInfoSQL.Append("RoomNo,");
             //sbDeviceInfoSQL.Append("Location,");
             //sbDeviceInfoSQL.Append("LoopID,");
             //sbDeviceInfoSQL.Append("TypeCode)");
             //sbDeviceInfoSQL.Append(" VALUES(");
             //sbDeviceInfoSQL.Append(device.ID + ",'");
             //sbDeviceInfoSQL.Append(device.Code + "','");
             //sbDeviceInfoSQL.Append(device.Disable + "','");
             //sbDeviceInfoSQL.Append(device.CurrentThreshold + "','");
             //sbDeviceInfoSQL.Append(device.TemperatureThreshold + "','");
             //sbDeviceInfoSQL.Append(device.BuildingNo + "','");
             //sbDeviceInfoSQL.Append(device.ZoneNo + "','");
             //sbDeviceInfoSQL.Append(device.FloorNo + "','");
             //sbDeviceInfoSQL.Append(device.RoomNo + "','");
             //sbDeviceInfoSQL.Append(device.Location + "','");
             //sbDeviceInfoSQL.Append(device.LoopID + "','");
             //sbDeviceInfoSQL.Append(device.TypeCode + "');");
             //_databaseService.ExecuteBySql(sbDeviceInfoSQL);
             _dbFileVersionService.AddDeviceForControllerType8021(device);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
     return(true);
 }
        private int GetDeviceCodeLength(ControllerType controllerType, LoopModel loop)
        {
            int deviceCodeLength = 0;

            switch (controllerType)
            {
            case ControllerType.NT8001:
            {
                List <DeviceInfo8001> lstDeviceInfo = loop.GetDevices <DeviceInfo8001>();
                if (lstDeviceInfo.Count > 0)
                {
                    deviceCodeLength = lstDeviceInfo[0].Code.Length;
                }
            }
            break;

            case ControllerType.NT8007:
            {
                List <DeviceInfo8007> lstDeviceInfo = loop.GetDevices <DeviceInfo8007>();
                if (lstDeviceInfo.Count > 0)
                {
                    deviceCodeLength = lstDeviceInfo[0].Code.Length;
                }
            }
            break;

            case ControllerType.NT8021:
            {
                List <DeviceInfo8021> lstDeviceInfo = loop.GetDevices <DeviceInfo8021>();
                if (lstDeviceInfo.Count > 0)
                {
                    deviceCodeLength = lstDeviceInfo[0].Code.Length;
                }
            }
            break;

            case ControllerType.NT8036:
            {
                List <DeviceInfo8036> lstDeviceInfo = loop.GetDevices <DeviceInfo8036>();
                if (lstDeviceInfo.Count > 0)
                {
                    deviceCodeLength = lstDeviceInfo[0].Code.Length;
                }
            }
            break;

            case ControllerType.FT8000:
            {
                List <DeviceInfo8000> lstDeviceInfo = loop.GetDevices <DeviceInfo8000>();
                if (lstDeviceInfo.Count > 0)
                {
                    deviceCodeLength = lstDeviceInfo[0].Code.Length;
                }
            }
            break;

            case ControllerType.FT8003:
            {
                List <DeviceInfo8003> lstDeviceInfo = loop.GetDevices <DeviceInfo8003>();
                if (lstDeviceInfo.Count > 0)
                {
                    deviceCodeLength = lstDeviceInfo[0].Code.Length;
                }
            }
            break;
            }
            return(deviceCodeLength);
        }
Esempio n. 7
0
 protected override void SetDownloadedDeviceInfoTotalAmountInCurrentLoop(LoopModel loopModel)
 {
     DownloadedDeviceInfoTotalAmountInCurrentLoop = loopModel.GetDevices <DeviceInfo8036>().Count; //设置当前回路的器件总数2017-04-06
 }
Esempio n. 8
0
        private bool GenerateDeviceID(ControllerType controllerType, ref LoopModel loop)
        {
            bool resultFlag = false;

            try
            {
                switch (controllerType)
                {
                case ControllerType.NT8001:
                {
                    int maxDeviceID = ProjectManager.GetInstance.MaxDeviceIDInController8001;
                    List <DeviceInfo8001> lstDeviceInfo = loop.GetDevices <DeviceInfo8001>();
                    for (int i = 0; i < lstDeviceInfo.Count; i++)
                    {
                        maxDeviceID++;
                        DeviceInfo8001 deviceInfo = lstDeviceInfo[i];
                        deviceInfo.ID    = maxDeviceID;
                        lstDeviceInfo[i] = deviceInfo;
                    }
                    ProjectManager.GetInstance.MaxDeviceIDInController8001 = maxDeviceID;
                }
                break;

                case ControllerType.NT8007:
                {
                    int maxDeviceID = ProjectManager.GetInstance.MaxDeviceIDInController8007;
                    List <DeviceInfo8007> lstDeviceInfo = loop.GetDevices <DeviceInfo8007>();
                    foreach (var device in lstDeviceInfo)
                    {
                        maxDeviceID++;
                        device.ID = maxDeviceID;
                    }
                    ProjectManager.GetInstance.MaxDeviceIDInController8007 = maxDeviceID;
                }
                break;

                case ControllerType.NT8021:
                {
                    int maxDeviceID = ProjectManager.GetInstance.MaxDeviceIDInController8021;
                    List <DeviceInfo8021> lstDeviceInfo = loop.GetDevices <DeviceInfo8021>();
                    for (int i = 0; i < lstDeviceInfo.Count; i++)
                    {
                        maxDeviceID++;
                        DeviceInfo8021 deviceInfo = lstDeviceInfo[i];
                        deviceInfo.ID    = maxDeviceID;
                        lstDeviceInfo[i] = deviceInfo;
                    }
                    ProjectManager.GetInstance.MaxDeviceIDInController8021 = maxDeviceID;
                }
                break;

                case ControllerType.NT8036:
                {
                    int maxDeviceID = ProjectManager.GetInstance.MaxDeviceIDInController8036;
                    List <DeviceInfo8036> lstDeviceInfo = loop.GetDevices <DeviceInfo8036>();
                    for (int i = 0; i < lstDeviceInfo.Count; i++)
                    {
                        maxDeviceID++;
                        DeviceInfo8036 deviceInfo = lstDeviceInfo[i];
                        deviceInfo.ID    = maxDeviceID;
                        lstDeviceInfo[i] = deviceInfo;
                    }
                    ProjectManager.GetInstance.MaxDeviceIDInController8036 = maxDeviceID;
                }
                break;

                case ControllerType.FT8000:
                {
                    int maxDeviceID = ProjectManager.GetInstance.MaxDeviceIDInController8000;
                    List <DeviceInfo8000> lstDeviceInfo = loop.GetDevices <DeviceInfo8000>();
                    for (int i = 0; i < lstDeviceInfo.Count; i++)
                    {
                        maxDeviceID++;
                        DeviceInfo8000 deviceInfo = lstDeviceInfo[i];
                        deviceInfo.ID    = maxDeviceID;
                        lstDeviceInfo[i] = deviceInfo;
                    }
                    ProjectManager.GetInstance.MaxDeviceIDInController8000 = maxDeviceID;
                }
                break;

                case ControllerType.FT8003:
                {
                    int maxDeviceID = ProjectManager.GetInstance.MaxDeviceIDInController8003;
                    List <DeviceInfo8003> lstDeviceInfo = loop.GetDevices <DeviceInfo8003>();
                    for (int i = 0; i < lstDeviceInfo.Count; i++)
                    {
                        maxDeviceID++;
                        DeviceInfo8003 deviceInfo = lstDeviceInfo[i];
                        deviceInfo.ID    = maxDeviceID;
                        lstDeviceInfo[i] = deviceInfo;
                    }
                    ProjectManager.GetInstance.MaxDeviceIDInController8003 = maxDeviceID;
                }
                break;
                }
                resultFlag = true;
            }
            catch
            {
            }
            return(resultFlag);
        }
Esempio n. 9
0
        public void NavigateToDeviceInfoExecute(object o)
        {
            NavigatorItemViewModel item   = (SCA.WPF.ViewModelsRoot.ViewModels.Navigator.NavigatorItemViewModel)((SCA.WPF.ViewsRoot.Views.Navigator.NavigatorView)((RoutedEventArgs)o).Source).HierarchyTreeView.SelectedItem;
            LoopModel      loop           = (SCA.Model.LoopModel)item.DataItem;
            ControllerType controllerType = loop.Controller.Type;

            switch (controllerType)
            {
            case ControllerType.NT8036:
                _deviceInfoViewModel8036.TheLoop = loop;
                _deviceInfoViewModel8036.DeviceInfoObservableCollection = new EditableDeviceInfo8036Collection(loop, loop.GetDevices <DeviceInfo8036>());
                CurrentView = _deviceInfoViewModel8036;
                break;

            case ControllerType.NT8001:
                _deviceInfoViewModel8001.TheLoop = loop;
                _deviceInfoViewModel8001.DeviceInfoObservableCollection = new EditableDeviceInfo8001Collection(loop, loop.GetDevices <DeviceInfo8001>());
                CurrentView = _deviceInfoViewModel8001;
                break;

            case ControllerType.NT8007:
                _deviceInfoViewModel8007.TheLoop = loop;
                _deviceInfoViewModel8007.DeviceInfoObservableCollection = new EditableDeviceInfo8007Collection(loop, loop.GetDevices <DeviceInfo8007>());
                CurrentView = _deviceInfoViewModel8007;
                break;

            case ControllerType.FT8000:
                _deviceInfoViewModel8000.TheLoop = loop;
                _deviceInfoViewModel8000.DeviceInfoObservableCollection = new EditableDeviceInfo8000Collection(loop, loop.GetDevices <DeviceInfo8000>());
                CurrentView = _deviceInfoViewModel8000;
                break;

            case ControllerType.FT8003:
                _deviceInfoViewModel8003.TheLoop = loop;
                _deviceInfoViewModel8003.DeviceInfoObservableCollection = new EditableDeviceInfo8003Collection(loop, loop.GetDevices <DeviceInfo8003>());
                CurrentView = _deviceInfoViewModel8003;
                break;

            case ControllerType.NT8021:
                _deviceInfoViewModel8021.TheLoop = loop;
                _deviceInfoViewModel8021.DeviceInfoObservableCollection = new EditableDeviceInfo8021Collection(loop, loop.GetDevices <DeviceInfo8021>());
                CurrentView = _deviceInfoViewModel8021;
                break;
            }
        }