public static void SelectDevice(string deviceTradeName, string deviceID, string filename)
 {
     var instance = new DeviceSetup(filename);
     SelectedDevice = instance.FindDevice(deviceTradeName);
     if (SelectedDevice != null){
         SelectedDevice.DeviceInfo.DeviceId = deviceID;
     }
 }
        public int InitializeDataStoreManager(string DBCnnString,
                                              CompanyInfoEx companyInfo, DeviceInfoEx deviceInfo)
        {
            _cnnDB          = DBCnnString;
            _redisInfo      = companyInfo.Redis;
            _redisTableName = $"[{companyInfo.CompanyCode}]-[{deviceInfo.DeviceCode}]";



            return(0);
        }
Exemple #3
0
        private void InitDeviceMap()
        {
            List <DeviceInfo> devices = TPLinkApi.GetDeviceStatus();

            foreach (DeviceInfo device in devices)
            {
                DeviceInfoEx devEx = new DeviceInfoEx();
                devEx.Update(device, true);
                DeviceMap[device.mac]            = devEx;
                devEx.DeviceOnlineStatusChanged += DevEx_DeviceOnlineStatusChanged;
            }
        }
        public void InitializeDeviceManager(CompanyInfoEx companyInfo)
        {
            _companyInfo = companyInfo;

            MySqlDataReader companyReader = MySqlHelper.ExecuteReader(Conn, CommandType.Text, $"select * from deviceconfig where CompanyCode='{companyInfo.CompanyCode}'", null);

            while (companyReader.Read())
            {
                DeviceInfoEx deviceItem = new DeviceInfoEx();

                deviceItem.CompanyCode = (string)companyReader["CompanyCode"];
                deviceItem.DeviceCode  = (string)companyReader["DeviceCode"];
                deviceItem.GPS         = (string)companyReader["DeviceGPS"];

                deviceItem.DeviceName = (string)companyReader["DeviceName"];
                deviceItem.DeviceType = (int)companyReader["DeviceType"];



                if (companyReader["DeviceTypeName"].Equals(DBNull.Value) == true)
                {
                    deviceItem.DeviceTypeName = "";
                }
                else
                {
                    deviceItem.DeviceTypeName = (string)companyReader["DeviceTypeName"];
                }


                if (companyReader["Address"].Equals(DBNull.Value) == true)
                {
                    deviceItem.Address = "";
                }
                else
                {
                    deviceItem.Address = (string)companyReader["Address"];
                }



                DeviceHelper tempCompanyItem = new DeviceHelper(deviceItem, _companyInfo);

                tempCompanyItem.InitializeDataStoreManager();
                _mapDevices.Add(deviceItem.DeviceCode, tempCompanyItem);
            }
        }
 public void LoadDefaultDevices()
 {
     data = new List<DeviceInfoEx>();
     DeviceInfoEx dev =  null; 
     
     // Android
     foreach (KeyValuePair<string, Dictionary<string, string>> entry in DeviceInfoHelper.DeviceInfoSets ) {
         dev = new DeviceInfoEx();
         dev.Tradename = entry.Key;
         dev.OSType = "Android";
         dev.DeviceInfo = new Signature.Types.DeviceInfo();
         dev.DeviceInfo.DeviceId = RandomDeviceId();
         dev.DeviceInfo.AndroidBoardName = entry.Value["AndroidBoardName"];
         dev.DeviceInfo.AndroidBootloader = entry.Value["AndroidBootloader"];
         dev.DeviceInfo.DeviceBrand = entry.Value["DeviceBrand"];
         dev.DeviceInfo.DeviceModel = entry.Value["DeviceModel"];
         dev.DeviceInfo.DeviceModelBoot = entry.Value["DeviceModelBoot"];
         dev.DeviceInfo.FirmwareBrand = entry.Value["FirmwareBrand"];
         dev.DeviceInfo.FirmwareFingerprint = entry.Value["FirmwareFingerprint"];
         dev.DeviceInfo.FirmwareTags = entry.Value["FirmwareTags"];
         dev.DeviceInfo.FirmwareType = entry.Value["FirmwareType"];
         dev.DeviceInfo.HardwareManufacturer = entry.Value["HardwareManufacturer"];
         dev.DeviceInfo.HardwareModel = entry.Value["HardwareModel"];
         data.Add(dev);
     }
     
     // IOS
     dev = new DeviceInfoEx();
     dev.Tradename = "iPhone 7";
     dev.OSType = "iOS";
     dev.UserAgent = "pokemongo/1 CFNetwork/889.3 Darwin/17.2.0";
     dev.DeviceInfo = new Signature.Types.DeviceInfo();
     dev.DeviceInfo.DeviceId = RandomDeviceId();
     dev.DeviceInfo.DeviceBrand = "Apple";
     dev.DeviceInfo.DeviceModel = "iPhone";
     dev.DeviceInfo.DeviceModelIdentifier = null;
     dev.DeviceInfo.DeviceModelBoot = "iPhone9,3";
     dev.DeviceInfo.FirmwareBrand = "iOS";
     dev.DeviceInfo.FirmwareType = "11.1.0";
     dev.DeviceInfo.FirmwareFingerprint = null;
     dev.DeviceInfo.HardwareModel = "D10AP";
     dev.DeviceInfo.HardwareManufacturer = "Apple";
     data.Add(dev);
 }
Exemple #6
0
        public DeviceHelper(DeviceInfoEx deviceInfo, CompanyInfoEx companyInfo)
        {
            _deviceInfo = deviceInfo;

            _deviceStatus.DeviceName    = _deviceInfo.DeviceName;
            _deviceStatus.DeviceCode    = _deviceInfo.DeviceCode;
            _deviceStatus.DeviceType    = _deviceInfo.DeviceTypeName;
            _deviceStatus.DeviceAddress = _deviceInfo.Address;
            _deviceStatus.GPS           = _deviceInfo.GPS;

            _deviceStatus.ConnectStatus   = CONNECT_STATUS.OFF_LINE;
            _deviceStatus.UpdateTimestamp = 0;

            _deviceRedisHashName = $"[{deviceInfo.CompanyCode}]-[{deviceInfo.DeviceCode}]";

            _parentCompanyInfo = companyInfo;

            companyRedisTableName = $"[IotConfig]-[{_deviceInfo.CompanyCode}]";

            _deviceAlarmStoreManager = new DeviceAlarmStoreManager(deviceInfo);
        }
Exemple #7
0
        /// <summary>
        /// 心跳函数,依赖外部触发
        /// 触发后自动更新设备信息,并且计算网速
        /// </summary>
        public void DoHeartBeat()
        {
            foreach (DeviceInfoEx devEx in DeviceMap.Values)
            {
                devEx.Tag = 0;
            }

            //更新每个设备的在线状态
            List <DeviceInfo> devices = TPLinkApi.GetDeviceStatus();

            foreach (DeviceInfo device in devices)
            {
                if (DeviceMap.TryGetValue(device.mac, out DeviceInfoEx devEx))
                {
                    devEx.Update(device, true);
                }
                else
                {
                    devEx = new DeviceInfoEx();
                    devEx.Update(device, true);
                    DeviceMap[device.mac]            = devEx;
                    devEx.DeviceOnlineStatusChanged += DevEx_DeviceOnlineStatusChanged;
                }
                devEx.Tag = 1;
            }

            foreach (DeviceInfoEx devEx in DeviceMap.Values)
            {
                if (devEx.Tag == 0)
                {
                    devEx.Update(null, false);
                }
            }

            var speed = TPLinkApi.GetDeviceNetSpeed();

            UploadSpeed   = speed.network.wan_status.up_speed;
            DownloadSpeed = speed.network.wan_status.down_speed;
        }
Exemple #8
0
 private void DevEx_DeviceOnlineStatusChanged(DeviceInfoEx obj)
 {
     DeviceOnlineStatusChanged?.Invoke(obj);
 }
Exemple #9
0
        public DeviceAlarmStoreManager(DeviceInfoEx deviceInfo)
        {
            _parentDeviceInfo = deviceInfo;

            _alarmTableName = $"History-Alarm-[{_parentDeviceInfo.CompanyCode}-{_parentDeviceInfo.DeviceCode}]";
        }