Пример #1
0
        public override List<Tuple<PropertyTypes, string>> GetChanges(BaseObject newObj)
        {
            var values = newObj as TemperatureSensor;
            if (values == null)
                throw new ArgumentException("јргумент не соответствует типу");

            var result = new List<Tuple<PropertyTypes, string>>();
            if (TemperatureSetpoint.Value != values.TemperatureSetpoint.Value)
                result.Add(new Tuple<PropertyTypes, string>(PropertyTypes.Thermometer_Setpoint, values.TemperatureSetpoint.Value.ToString()));

            if (AllowManual.BoolValue != values.AllowManual.BoolValue)
                result.Add(new Tuple<PropertyTypes, string>(PropertyTypes.Thermometer_AllowManual, values.AllowManual.Value.ToString()));

            return result;
        }
Пример #2
0
        public override List<Tuple<PropertyTypes, string>> GetChanges(BaseObject newObj)
        {
            var changes = new List<Tuple<PropertyTypes, string>>();

            var value = newObj as LightGroup;
            if (value == null)
                throw new ArgumentException("Типы объектов не совпадают", "newObj");

            if (IsOn != value.IsOn)
                changes.Add(new Tuple<PropertyTypes, string>(PropertyTypes.LightGroup_State, value.IsOn.ToString()));

            if (LightLevelSetpoint != value.LightLevelSetpoint)
                changes.Add(new Tuple<PropertyTypes, string>(PropertyTypes.LightGroup_Setpoint, value.LightLevelSetpoint.ToString()));

            return changes;
        }
Пример #3
0
 public override void Update(BaseObject newObject)
 {
     base.Update(newObject);
     LightLevel = ((Lamp)newObject).LightLevel;
 }
Пример #4
0
 public override void Update(BaseObject newObject)
 {
     base.Update(newObject);
     FanLevel = ((Conditioner)newObject).FanLevel;
     IsOn = ((Conditioner)newObject).IsOn;
 }
Пример #5
0
        /// <summary>
        /// Процедура для обновления планов из БД
        /// </summary>
        private void OnPlansModified(BaseObject obj)
        {
            // прекращаем отправлять значения
            _pushValuesToClientTimer.Stop();

            // очищаем адреса и изменившиеся объекты
            _addresses.Clear();
            _changedValues.Clear();
            _planObjects.Clear();

            using (var plansDb = new PlansDc(_esterConnectionString))
            {
                // обновляем информцию из бд
                _rootObjects = plansDb.PlanObjects.Where(po => po.Parent == null).Select(p => ServerExtensions.FromDbObject(p)).ToList();
                foreach (var group in plansDb.Properties.GroupBy(g => g.Path)) _addresses.Add(group.Key, group.ToList());
            }

            FillPlanObjects(_planObjects, _rootObjects);

            // обновляем подписку на всех работающих провайдерах данных
            foreach (var dataProvider in _providers.Where(p => p.State == DataProviderState.Working))
                dataProvider.UpdateSubscription(_addresses.Keys.ToList());

            // возобновляем ход времени :)
            _pushValuesToClientTimer.Start();

            // уведомляем подписчиков о необходимости перечитать дерево целиком
            PushValuesToClients(true);
        }
Пример #6
0
        /// <summary>
        /// Обновляет значения в сетях контроллеров
        /// </summary>
        /// <param name="obj">Объект для сохранения</param>
        internal object UpdateObjectProperties(BaseObject obj)
        {
            var currentState = _planObjects[obj.Id];
            if (currentState == null)
                return false;

            var updateValues = currentState.GetChanges(obj);
            foreach (var updateValue in updateValues)
            {
                var save = _addresses
                    .SelectMany(a => a.Value)
                    .Where(a => a.ObjectId == obj.Id && a.AddressTypeId == (int)updateValue.Item1)
                    .ToDictionary(d => d.Path, d => updateValue.Item2);
                SaveToNetwork(save);
            }
            return true;
        }
Пример #7
0
 public override void Update(BaseObject newObject)
 {
     base.Update(newObject);
     ManualLevel = ((Heater)newObject).ManualLevel;
     IsBacstatAllowed = ((Heater)newObject).IsBacstatAllowed;
 }
Пример #8
0
 private BaseObject SavePlanObjectToDb(string id, BaseObject planObject)
 {
     BaseObject res;
     var plan = new PlanObject();
     using (var context = new PlansDc(_esterConnectionString))
     {
         if (!string.IsNullOrEmpty(id))
             plan = GetPlanObjectById(id, context);
         else
             context.PlanObjects.InsertOnSubmit(plan);
         planObject.ExportToDbObject(plan, context);
         context.SubmitChanges();
         res = ServerExtensions.FromDbObject(plan);
     }
     if (_eventAggregator != null)
         _eventAggregator.GetEvent<PlansModifiedEvent>().Publish(planObject);
     return res;
 }
Пример #9
0
 public override void Update(BaseObject newObject)
 {
     base.Update(newObject);
     Temperature = ((TemperatureSensor)newObject).Temperature;
     TemperatureSetpoint = ((TemperatureSensor)newObject).TemperatureSetpoint;
 }
Пример #10
0
 private void SaveObject(BaseObject obj)
 {
     if (obj == null)
         return;
     _planObjectsrepository.SubmitProperties(obj);
 }
Пример #11
0
 public override void Update(BaseObject newObject)
 {
     base.Update(newObject);
     IsOn = ((LightGroup)newObject).IsOn;
     LightLevel = ((LightGroup)newObject).LightLevel;
     LightLevelSetpoint = ((LightGroup)newObject).LightLevelSetpoint;
 }
Пример #12
0
 public virtual void Update(BaseObject newObject)
 {
     Description = newObject.Description;
     Height = newObject.Height;
     Id = newObject.Id;
     Left = newObject.Left;
     Name = newObject.Name;
     ParentId = newObject.ParentId;
     Path = newObject.Path;
     Top = newObject.Top;
     Type = newObject.Type;
     TypeId = newObject.TypeId;
     Width = newObject.Width;
 }
Пример #13
0
 public virtual List<Tuple<PropertyTypes, string>> GetChanges(BaseObject newObj)
 {
     throw new NotImplementedException();
 }
Пример #14
0
		public void SubmitProperties(BaseObject obj)
		{
			_dataTransport.PostRequest<bool>(obj, Urls.Data + "/" + obj.Id, true);
		}
Пример #15
0
 public override void Update(BaseObject newObject)
 {
     base.Update(newObject);
     IsLeaked = ((WdSensor)newObject).IsLeaked;
 }