Ejemplo n.º 1
0
 public RegistrationService(bool UseCamera, TPadDevice device, CameraMonitor camera, SimCameraMonitor simCamera)
 {
     Device = device;
       cameraMonitor = camera;
       simCameraMonitor = simCamera;
 }
Ejemplo n.º 2
0
        public void Configure(TPadProfile profile, int deviceID, String groupIP, int port, int TTL)
        {
            log4net.Config.XmlConfigurator.Configure();
              logger = log4net.LogManager.GetLogger(typeof(TPadCore));

              Profile = profile;
              Device = new TPadDevice(deviceID) { Profile = Profile };

              Board = new BoardMonitor() { UpdateType = ContextAdapterUpdateType.Interval, UpdateInterval = 100 };
              SimBoard = new SimBoardMonitor() { UpdateType = ContextAdapterUpdateType.OnRequest };
              Camera = new CameraMonitor(UseCamera) { UpdateType = ContextAdapterUpdateType.Interval, UpdateInterval = 50 };
              SimCamera = new SimCameraMonitor() { UpdateType = ContextAdapterUpdateType.OnRequest };

              FlippingMonitor flippingMonitor = new FlippingMonitor() { UpdateType = ContextAdapterUpdateType.OnRequest };
              StackingMonitor stackingMonitor = new StackingMonitor() { UpdateType = ContextAdapterUpdateType.OnRequest };
              ShakingMonitor shakingMonitor = new ShakingMonitor() { UpdateType = ContextAdapterUpdateType.OnRequest };
              ButtonMonitor buttonMonitor = new ButtonMonitor() { UpdateType = ContextAdapterUpdateType.OnRequest };
              MulticastMonitor multicastMonitor = new MulticastMonitor(groupIP, port, TTL);

              Registration = new RegistrationService(UseCamera, Device, Camera, SimCamera);
              GlyphDetection = new GlyphDetectionService(Device);

              //Wiring up the components
              Board.OnNotifyContextServices += flippingMonitor.UpdateMonitorReading;
              Board.OnNotifyContextServices += stackingMonitor.UpdateMonitorReading;
              Board.OnNotifyContextServices += shakingMonitor.UpdateMonitorReading;
              Board.OnNotifyContextServices += buttonMonitor.UpdateMonitorReading;

              SimBoard.OnNotifyContextServices += flippingMonitor.UpdateMonitorReading;
              SimBoard.OnNotifyContextServices += stackingMonitor.UpdateMonitorReading;
              SimBoard.OnNotifyContextServices += shakingMonitor.UpdateMonitorReading;
              SimBoard.OnNotifyContextServices += buttonMonitor.UpdateMonitorReading;

              Camera.OnNotifyContextServices += Registration.UpdateMonitorReading;
              Camera.OnNotifyContextServices += GlyphDetection.UpdateMonitorReading;

              SimCamera.OnNotifyContextServices += Registration.UpdateMonitorReading;
              SimCamera.OnNotifyContextServices += GlyphDetection.UpdateMonitorReading;

              flippingMonitor.OnNotifyContextServices += this.UpdateMonitorReading;
              stackingMonitor.OnNotifyContextServices += this.UpdateMonitorReading;
              shakingMonitor.OnNotifyContextServices += this.UpdateMonitorReading;
              buttonMonitor.OnNotifyContextServices += this.UpdateMonitorReading;
              multicastMonitor.OnNotifyContextServices += this.UpdateMonitorReading;
              Registration.OnNotifyContextServiceListeners += this.ContextChanged;
              GlyphDetection.OnNotifyContextServiceListeners += this.ContextChanged;

              //Register the monitors to the container
              monitorsContainer.AddMonitor(Board);
              monitorsContainer.AddMonitor(SimBoard);
              monitorsContainer.AddMonitor(SimCamera);
              monitorsContainer.AddMonitor(Camera);
              monitorsContainer.AddMonitor(flippingMonitor);
              monitorsContainer.AddMonitor(stackingMonitor);
              monitorsContainer.AddMonitor(multicastMonitor);

              //Register the services to the container
              servicesContainer.AddContextService(this);
              servicesContainer.AddContextService(Registration);
              servicesContainer.AddContextService(GlyphDetection);
        }