public CMSViewAdapter(CMSModel model, CMSController controller, CMSVideoSource videoSource)
 {
     this.videoSource = videoSource;
     this.model       = model;
     this.controller  = controller;
 }
Beispiel #2
0
        public void Start(CMSVideoSource videoSource, CMSVideoDisplay videoDisplay, CMSControlToggler controlToggler)
        {
            mutex = new object();

            try
            {
                ProcessKeys[] procKeysDelegates = null;
                lock (mutex)
                {
                    CMSConstants.Init();
                    controllerState = CMSState.Starting;


                    model = new CMSModel();
                    model.Init("./" + CMSConstants.SUITE_LIB_DIR, "./" + CMSConstants.SUITE_CONFIG_DIR,
                               "./" + CMSConstants.MAIN_CONFIG_FILE,
                               "./" + CMSConstants.MAIN_CAMERA_CONFIG_FILE,
                               "./" + CMSConstants.MAIN_LOG_CONFIG_FILE,
                               "./" + CMSConstants.MAIN_ID_CONFIG_FILE);

                    model.Load();
                    model.IncrementAndSaveSessionNum();

                    CMSLogger.SetUidReceivedDelegate(model.UidUpdated);
                    CMSLogger.Init(model.LogConfig, model.IdConfig);

                    //CMSLogger.CanCreateLogEvent(

                    if (CMSLogger.CanCreateLogEvent(false, false, false, "CMSLogStartEvent"))
                    {
                        CMSLogStartEvent startEvent = new CMSLogStartEvent();
                        startEvent.SetDateTime(DateTime.Now);
                        CMSLogger.SendLogEvent(startEvent);
                    }

                    this.videoSource         = videoSource;
                    videoSource.CameraLost  += new CameraLost(CameraLost);
                    videoSource.CameraFound += new CameraFound(CameraFound);
                    videoSource.VideoInputSizesDetermined += new VideoInputSizesDetermined(VideoInputSizesDetermined);
                    videoSource.ProcessFrame += new ProcessFrame(ProcessFrameFromSource);
                    videoSource.Init(videoDisplay.GetParentForm());


                    this.videoDisplay = videoDisplay;
                    videoDisplay.Init(new CMSViewAdapter(model, this, videoSource));

                    model.SelectedSuite.CMSTrackingSuiteAdapter = new CMSStandardTrackingSuiteAdapter(model, this, videoDisplay);

                    string currentMoniker = model.CurrentMonikor;
                    if (videoSource.StartSource(currentMoniker))
                    {
                        string newMoniker = videoSource.GetCurrentMonikor();
                        model.CurrentMonikor = newMoniker;
                        controllerState      = CMSState.Setup;
                    }
                    else
                    {
                        controllerState = CMSState.CameraNotFound;
                    }


                    this.controlToggler                 = controlToggler;
                    controlToggler.GetState             = GetState;
                    controlToggler.ToggleControl        = ToggleControl;
                    controlToggler.GetCursorPos         = GetCursorPos;
                    controlToggler.ControlTogglerConfig = model.GeneralConfig.ControlTogglerConfig;
                    controlToggler.Start();


                    procKeysDelegates    = new ProcessKeys[2];
                    procKeysDelegates[0] = ProcessKeys;
                    procKeysDelegates[1] = controlToggler.ProcessKeys;
                }
                CMSKeyHook.initHook(procKeysDelegates);
                Application.Run(videoDisplay.GetParentForm());
                CMSKeyHook.removeHook();
            }
            catch (Exception e)
            {
                try
                {
                    if (CMSLogger.CanCreateLogEvent(true, true, false, "CMSLogExceptionEvent"))
                    {
                        CMSLogExceptionEvent exceptionEvent = new CMSLogExceptionEvent();

                        exceptionEvent.SetException(e);
                        CMSLogger.SendLogEvent(exceptionEvent);
                    }
                }
                catch
                {
                }
                MessageBox.Show("Error occurred during startup:" + e.Message);
                Application.Exit();
            }
        }
Beispiel #3
0
 public CMSStandardTrackingSuiteAdapter(CMSModel model, CMSController controller, CMSVideoDisplay view)
 {
     this.model      = model;
     this.controller = controller;
     this.view       = view;
 }