Пример #1
0
 /// <summary>
 /// Timer event handler to reinitialize the nikon to avoid bugs
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TimerNikon_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     try
     {
         nikonCamera = new NikonCamera();
         #region Log
         DateTime date = DateTime.Now;
         string   str  = string.Format("{0}-{1}-{2}, {3:00}:{4:00}:{5:00}: Nikon camera reinitialized",
                                       date.Year,
                                       date.Month,
                                       date.Day,
                                       date.Hour,
                                       date.Minute,
                                       date.Second);
         using StreamWriter writer = new StreamWriter("log.txt", true);
         writer.WriteLine(str);
         #endregion
     }
     catch (NoCameraDetectedException ex)
     {
         #region Log
         DateTime date1 = DateTime.Now;
         string   str1  = string.Format("{0}-{1}-{2}, {3:00}:{4:00}:{5:00}: ERROR: ",
                                        date1.Year,
                                        date1.Month,
                                        date1.Day,
                                        date1.Hour,
                                        date1.Minute,
                                        date1.Second) + ex.Message;
         using StreamWriter writer = new StreamWriter("log.txt", true);
         writer.WriteLine(str1);
         #endregion
         MessageBox.Show("No Nikon camera detected. Check if it is on.", "Error", MessageBoxButtons.OK);
     }
 }
Пример #2
0
        /// <summary>
        /// Initialize the control class by setting the timers, creating the channels and a Point Grey camera
        /// </summary>
        /// <exception cref="FormatNotRespectedException">Thrown when the setting file for the camera doesn't respect the expected format</exception>
        /// <exception cref="NoCameraDetectedException">Thrown when there isn't any camera detected</exception>
        public AControl()
        {
            SetTimer();

            timerNikon = new System.Timers.Timer
            {
                Interval  = 2 * 3600 * 1000 + 15000, //we create a timer to reinitialize the nikon to avoid bugs
                Enabled   = false,
                AutoReset = true
            };
            timerNikon.Elapsed += TimerNikon_Elapsed;

            timerNikon.Start();

            shutterControl = new ComponentControl(ConfigurationManager.AppSettings["Shutter"], "Shutter");
            lampControl    = new RelayBoxComponent(ConfigurationManager.AppSettings["LampControl"], "Main lamp");
            redLampControl = new ComponentControl(ConfigurationManager.AppSettings["RedLampControl"], "Red Lamp");
            traverse       = new Traverse();
            nikonCamera    = new NikonCamera();

            try
            {
                PtGreyCameraSetting setting = new PtGreyCameraSetting("PtGreySetting.txt");
                ptGreyCamera = new PtGreyCamera(setting);
            }
            catch (FileNotFoundException)
            {
                ptGreyCamera = new PtGreyCamera();
            }
            using StreamWriter writer = new StreamWriter("log.txt", true);
            writer.WriteLine(ProtocolDescription());
        }
Пример #3
0
        public NikonSettingsViewModel(NikonCamera c)
        {
            base.DisplayName = "NikonSettingsViewModel";
            _camera          = c;

            CommandWhiteBalance    = new RelayCommand(param => this.ExecuteWhiteBalance());
            CommandClearSaturation = new RelayCommand(param => this.ClearSaturation());
            CommandClearHue        = new RelayCommand(param => this.ClearHue());
            CommandClearWBRed      = new RelayCommand(param => this.ClearWBRed());
            CommandClearWBBlue     = new RelayCommand(param => this.ClearWBBlue());
        }