예제 #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
파일: LightGroup.cs 프로젝트: kib357/Ester2
        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
파일: Lamp.cs 프로젝트: kib357/Ester2
 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
파일: Heater.cs 프로젝트: kib357/Ester2
 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
파일: LightGroup.cs 프로젝트: kib357/Ester2
 public override void Update(BaseObject newObject)
 {
     base.Update(newObject);
     IsOn = ((LightGroup)newObject).IsOn;
     LightLevel = ((LightGroup)newObject).LightLevel;
     LightLevelSetpoint = ((LightGroup)newObject).LightLevelSetpoint;
 }
예제 #12
0
파일: BaseObject.cs 프로젝트: kib357/Ester2
 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
파일: BaseObject.cs 프로젝트: kib357/Ester2
 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
파일: WdSensor.cs 프로젝트: kib357/Ester2
 public override void Update(BaseObject newObject)
 {
     base.Update(newObject);
     IsLeaked = ((WdSensor)newObject).IsLeaked;
 }