public MyViewModel() { //ll = 100; _sensors = new ObservableCollection<sensor>(); _bacnet = new BacNet("10.81.32.211"); _bacnet.NetworkModelChangedEvent += OnNetworkModelChanged; Thread.Sleep(100); SetValueCommand = new DelegateCommand(SetValue); GetValueCommand = new DelegateCommand(GetValue); var tmpList = new List<uint>(); tmpList.Add(1100); tmpList.Add(1200); tmpList.Add(1400); tmpList.Add(1500); //_bacnet.FindSeveral(tmpList); //var tmp = _bacnet[1600].Objects["BI1101"].Get(); _bacnet[1400].Objects["BI1102"].ValueChangedEvent += OnBacnetValueChanged; _bacnet[1400].Objects["BV1102"].ValueChangedEvent += OnBacnetValueChanged; SchValues = new List<string>(); object obj = _bacnet[17811].Objects["AO1104"].Get(); ll = obj.ToString(); TestDali(); }
private void InitializeModule() { State = BacNetServerStates.Initializing; _allValues = new Dictionary <string, string>(); _changedValues = new Dictionary <string, string>(); try { Network = new BacNet(_configSource.Configs["BacNet"].Get("Ip")); } catch (Exception) { State = BacNetServerStates.Fault; StateDescription = "Cannot initialize BACnet provider, check ip address configuration."; return; } SubscribeToDatabaseObjects(); _pushValuesToClientTimer.Start(); //_container.RegisterInstance(_container.Resolve<AlarmChecker>()); _container.RegisterInstance(_container.Resolve <NotificationListener>()); _container.RegisterInstance(_container.Resolve <SchedulesService>()); State = BacNetServerStates.Normal; }
/// <summary> /// Инициализация провайдера /// </summary> /// <param name="configuration"></param> public void Initialize(Dictionary <string, object> configuration) { _state = DataProviderState.Initializing; try { // читаем конфиг var config = (XmlConfigSource)configuration["ConfigSource"]; _network = new BacNet(config.Configs["BacNet"].Get("Ip")); // выгребаем бакнет-адреса var addresses = ((List <string>)configuration["Addresses"]).Where(a => _backnetAddressRegex.IsMatch(a)).ToList(); // подписываемся addresses.ForEach(Subscribe); // считаем, что работатем _state = DataProviderState.Working; // уведомляем внимательных слушателей о инициализации данного провайдера if (DataProviderInitializedEvent != null) { DataProviderInitializedEvent(this); } } catch (Exception) { // бида-пичаль _state = DataProviderState.Fault; _subscribedAddresses.Clear(); } }
public SchedulesService() { _bacnetSchedule = new BacnetSchedule(); _masterController = (uint)_configSource.Configs["BacNet"].GetInt("SchedulesMainController"); _syncSchedules = _configSource.Configs["BacNet"].GetBoolean("SyncSchedules"); _network = BacNetServer.Network; Task.Factory.StartNew(SyncSchedules, TaskCreationOptions.LongRunning); }
public NewBacNetServer(IUnityContainer container) { _container = container; _addresses = new Dictionary <string, List <Address> >(); _planObjects = new Dictionary <int, BaseObject>(); _changedValues = new List <BaseObject>(); _pushValuesToClientTimer = new Timer(5000); _pushValuesToClientTimer.Elapsed += PushValuesToClientTimerTick; _plansDb = new PlansDc(@"Data Source=192.168.0.160\SQLEXPRESS;Initial Catalog=Ester;Persist Security Info=True;User ID=sa;Password=6*!vb9%q"); State = BacNetServerStates.Initializing; _rootObjects = _plansDb.PlanObjects.Where(po => po.Parent == null).Select(p => BaseObject.FromDbObject(p)).ToList(); FillPlanObjects(_planObjects, _rootObjects); try { Network = new BacNet(_configSource.Configs["BacNet"].Get("Ip")); } catch (Exception) { State = BacNetServerStates.Fault; StateDescription = "Cannot initialize BACnet provider, check ip address configuration."; return; } State = BacNetServerStates.Normal; foreach (var group in _plansDb.Addresses.GroupBy(g => g.Path)) { if (!group.Key.Contains('.')) { continue; } var objAddr = group.Key.Split('.')[1].Trim(); uint instance; instance = uint.TryParse(group.Key.Split('.')[0].Trim(), out instance) ? instance : 0; if (instance != 0 && !string.IsNullOrEmpty(objAddr)) { Network[instance].Objects[objAddr].ValueChangedEvent += OnBacnetValueChanged; } _addresses.Add(group.Key, group.ToList()); } _pushValuesToClientTimer.Start(); }
/// <summary> /// Возвращает объект bacnet-сети по его адресу /// </summary> public static PrimitiveObject Object(this BacNet network, string address) { if (!address.Contains('.')) { throw new ArgumentException("Адрес не содержит точек", "address"); } var objAddr = address.Split('.')[1].Trim(); uint instance; instance = uint.TryParse(address.Split('.')[0].Trim(), out instance) ? instance : 0; return(network[instance].Objects[objAddr]); }
public NewBacNetServer(IUnityContainer container) { _container = container; _addresses = new Dictionary<string, List<Address>>(); _planObjects = new Dictionary<int, BaseObject>(); _changedValues = new List<BaseObject>(); _pushValuesToClientTimer = new Timer(5000); _pushValuesToClientTimer.Elapsed += PushValuesToClientTimerTick; _plansDb = new PlansDc(@"Data Source=192.168.0.160\SQLEXPRESS;Initial Catalog=Ester;Persist Security Info=True;User ID=sa;Password=6*!vb9%q"); State = BacNetServerStates.Initializing; _rootObjects = _plansDb.PlanObjects.Where(po => po.Parent == null).Select(p => BaseObject.FromDbObject(p)).ToList(); FillPlanObjects(_planObjects, _rootObjects); try { Network = new BacNet(_configSource.Configs["BacNet"].Get("Ip")); } catch (Exception) { State = BacNetServerStates.Fault; StateDescription = "Cannot initialize BACnet provider, check ip address configuration."; return; } State = BacNetServerStates.Normal; foreach (var group in _plansDb.Addresses.GroupBy(g => g.Path)) { if (!group.Key.Contains('.')) continue; var objAddr = group.Key.Split('.')[1].Trim(); uint instance; instance = uint.TryParse(group.Key.Split('.')[0].Trim(), out instance) ? instance : 0; if (instance != 0 && !string.IsNullOrEmpty(objAddr)) Network[instance].Objects[objAddr].ValueChangedEvent += OnBacnetValueChanged; _addresses.Add(group.Key, group.ToList()); } _pushValuesToClientTimer.Start(); }
public DeviceFinder(BacNet network) { _network = network; _network.DeviceListChangedEvent += DeviceListChanged; }
/// <summary> /// Инициализация провайдера /// </summary> /// <param name="configuration"></param> public void Initialize(Dictionary<string, object> configuration) { _state = DataProviderState.Initializing; try { // читаем конфиг var config = (XmlConfigSource)configuration["ConfigSource"]; _network = new BacNet(config.Configs["BacNet"].Get("Ip")); // выгребаем бакнет-адреса var addresses = ((List<string>)configuration["Addresses"]).Where(a => _backnetAddressRegex.IsMatch(a)).ToList(); // подписываемся addresses.ForEach(Subscribe); // считаем, что работатем _state = DataProviderState.Working; // уведомляем внимательных слушателей о инициализации данного провайдера if (DataProviderInitializedEvent != null) DataProviderInitializedEvent(this); } catch (Exception) { // бида-пичаль _state = DataProviderState.Fault; _subscribedAddresses.Clear(); } }
private void InitializeModule() { State = BacNetServerStates.Initializing; _allValues = new Dictionary<string, string>(); _changedValues = new Dictionary<string, string>(); try { Network = new BacNet(_configSource.Configs["BacNet"].Get("Ip")); } catch (Exception) { State = BacNetServerStates.Fault; StateDescription = "Cannot initialize BACnet provider, check ip address configuration."; return; } SubscribeToDatabaseObjects(); _pushValuesToClientTimer.Start(); //_container.RegisterInstance(_container.Resolve<AlarmChecker>()); _container.RegisterInstance(_container.Resolve<NotificationListener>()); _container.RegisterInstance(_container.Resolve<SchedulesService>()); State = BacNetServerStates.Normal; }