Exemplo n.º 1
0
 private void ProcessSensors()
 {
     ISensorBase[] toProcess;
     lock (sensorSync) {
         if (sensors.Length > 0)
         {
             toProcess = new ISensorBase[sensors.Length];
             Array.Copy(sensors, toProcess, sensors.Length);
         }
         else
         {
             return;
         }
     }
     // process all available sensors
     // and relay captured data
     for (int i = 0; i < toProcess.Length; i++)
     {
         if (toProcess[i] == null || !toProcess[i].Capturing)
         {
             continue;
         }
         SensorDataPacket packet = toProcess[i].Process(-1);
         if (packet == null)
         {
             continue;
         }
         SensorObservable observable;
         lock (observableSync) {
             observable = observables[i];
         }
         observable.OnDataAvailable(packet);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Reports data availablility of the observed sensor.
 /// </summary>
 /// <param name="args">Sensor and data information.</param>
 public void OnDataAvailable(SensorDataPacket args)
 {
     lock (observerSync) {
         foreach (var observer in observers)
         {
             observer.OnDataAvailable(args);
         }
     }
 }