示例#1
0
 public EventMapper(BleSystemConfiguration systemConfiguration)
 {
     var receiverPaths = systemConfiguration.ReceiverPaths;
     _useWeightedPath = systemConfiguration.UseWeightedPaths;
     _receiverPaths = receiverPaths.ToDictionary(rp => rp);
     _eventGroupHandler = new ActionBlock<List<SignalEventDetails>>(deg => HandleEventGroup(deg), new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 1 });
     _eventsByReceiver = new Dictionary<BleReceiver, Dictionary<string, SignalEventDetails>>(systemConfiguration.BleReceivers.Count);
     _monitoredReceivers = systemConfiguration.BleReceivers.Values.ToList();
     _monitoredTransmitters = systemConfiguration.BleTransmitters.Values.ToList();
     _receiverPathsTree = new Dictionary<BleReceiver, Dictionary<ReceiverPath, ReceiverPath>>();
     foreach (var bleReceiver in _monitoredReceivers)
     {
         if (_eventsByReceiver.ContainsKey(bleReceiver))
             continue;
         var pathDictionary = new Dictionary<ReceiverPath, ReceiverPath>();
         _receiverPathsTree.Add(bleReceiver, pathDictionary);
         foreach (var receiverPath in receiverPaths)
         {
             if (Equals(receiverPath.From, bleReceiver) || Equals(receiverPath.To, bleReceiver))
                 pathDictionary.Add(receiverPath, receiverPath);
         }
         var receiverTransmitters = new Dictionary<string, SignalEventDetails>(_monitoredTransmitters.Count);
         _monitoredTransmitters.ForEach(t =>
         {
             if (receiverTransmitters.ContainsKey(t.MacAddress))
                 return;
             receiverTransmitters.Add(t.MacAddress,
                 new SignalEventDetails { Transmitter = t, BleReceiver = bleReceiver });
         });
         _eventsByReceiver.Add(bleReceiver, receiverTransmitters);
     }
     _scanTimer = new Timer(ScanInterval);
     _scanTimer.Elapsed += ScanIntervalElapsed;
     _scanTimer.Enabled = true;
 }
示例#2
0
 public MapWindow(BleSystemConfiguration configuration)
 {
     InitializeComponent();
     PrepareMap(configuration);
 }
示例#3
0
        private void PrepareMap(BleSystemConfiguration configuration)
        {
            //_mapSizeMetric = new SizeF(60f,60f);
            //_conversionRatio = new SizeF((float) (MapCanvas.Width/_mapSizeMetric.Width), (float) (MapCanvas.Height/_mapSizeMetric.Height));
            _conversionRatio = new SizeF(20f, 20f);
            _mapOrigin = new PointF(20,20);
            SetOrigin();
            _receiverDetections = new Dictionary<string, Dictionary<string, Ellipse>>();
            foreach (var bleReceiver in configuration.BleReceivers)
            {
                if(!bleReceiver.Value.IsEnabled)
                    continue;
                AddReceiver(bleReceiver.Value);
                AddReceiverTransmitters(bleReceiver.Value, configuration.BleTransmitters);
            }
            _transmitterPositions = new Dictionary<string, FrameworkElement>(configuration.BleTransmitters.Count);
            foreach (var bleTransmitter in configuration.BleTransmitters)
            {
                AddTransmitter(bleTransmitter.Value);

            }
            AddRoomContour();
        }