/// <summary>
 /// Return a DriverFactory instance. Default to using Edge for IE testing on Windows (required for Windows 11).
 /// Driver paths should not need to be provided for Drivers installed by packages or on the System Path.
 /// </summary>
 /// <param name="driverOptionsFactory"></param>
 /// <param name="webDriverReSizer"></param>
 /// <param name="driverPath"></param>
 public DefaultLocalWebDriverFactory(IDriverOptionsFactory driverOptionsFactory,
                                     IWebDriverReSizer webDriverReSizer,
                                     DriverPath driverPath = null)
 {
     InstalledDriverPath  = driverPath?.PathString;
     DriverOptionsFactory = driverOptionsFactory ?? new DefaultDriverOptionsFactory();
     WebDriverReSizer     = webDriverReSizer;
 }
Пример #2
0
        public void DriverPathReturnedWhenPassedInIsAsExpected()
        {
            DriverPath driverPathReturned = ServiceCollectionFactory
                                            .GetDefaultServiceCollection(ExpectedDriverPath)
                                            .BuildServiceProvider()
                                            .GetService <DriverPath>();

            driverPathReturned.Should().BeEquivalentTo(ExpectedDriverPath);
        }
Пример #3
0
        public void DriverPathReturnedShouldBeNullIfNoPathIsSpecified()
        {
            DriverPath driverPathReturnedWhenNoPathIsSpecified = ServiceCollectionFactory
                                                                 .GetDefaultServiceCollection()
                                                                 .BuildServiceProvider()
                                                                 .GetService <DriverPath>();

            driverPathReturnedWhenNoPathIsSpecified.Should().BeNull();
        }
Пример #4
0
        public static IServiceCollection GetDefaultServiceCollection(
            IWebDriverConfiguration driverConfig,
            DriverPath driverPath)
        {
            IServiceCollection services = new ServiceCollection();

            services.AddSingleton <IDriverOptionsFactory, DefaultDriverOptionsFactory>();
            services.AddSingleton <IWebDriverReSizer, WebDriverReSizer>();

            if (driverPath != null)
            {
                services.AddSingleton <DriverPath>(driverPath);
            }

            services.AddSingleton(driverConfig ?? WebDriverConfigurationBuilder.Start().Build());
            services.AddSingleton <ILocalWebDriverFactory, DefaultLocalWebDriverFactory>();
            services.AddSingleton <IRemoteWebDriverFactory, DefaultRemoteWebDriverFactory>();

            services.AddSingleton <IWebDriverFactory, DefaultWebDriverFactory>();
            services.AddSingleton <IWebDriverManager, WebDriverManager>();

            return(services);
        }
Пример #5
0
 public static IServiceCollection GetDefaultServiceCollection(
     DriverPath driverPath)
 {
     return(GetDefaultServiceCollection((IWebDriverConfiguration)null, driverPath));
 }
Пример #6
0
 public static IServiceCollection GetDefaultServiceCollection(Uri gridUri, DriverPath driverPath)
 {
     return(GetDefaultServiceCollection(GetDefaultWebDriverConfigurationFromUri(gridUri), driverPath));
 }
Пример #7
0
        private void StartProgram()
        {
            try
            {
                if (!IsProgramRunning)
                {
                    LogDateTimeStart = DateTime.Now;
                    PropertiesToolStripMenuItem.Enabled = false;
                    SPort.PortName = PortName;
                    SPort.Open();
                    _continue            = true;
                    TimeLeft             = 0;
                    TimeLeftTextBox.Text = ((TimerSetting - TimeLeft) / 1000) + @" сек.";
                    // Включаем таймер обновления времени и даты.
                    DateTimeUpdateTimer.Enabled  = true;
                    RotateTimer.Interval         = TimerSetting;
                    RotateTimer.Enabled          = true;
                    ErrorEmailSendTimer.Interval = (2 * TimerSetting + 1000 * 60 * 10);
                    ErrorEmailSendTimer.Enabled  = true;

                    // Считаем угол азимута и элевации.
                    CalculateCurrentAngles(false);

                    DrawAzimuth((int)Math.Round(_SPAData.Azimuth, 0));
                    DrawElevation((int)Math.Round(90 - _SPAData.Zenith, 0));

                    AzimuthTextBox.Text   = Math.Round(_SPAData.Azimuth, 1) + @"°";
                    ElevationTextBox.Text = Math.Round(90 - _SPAData.Zenith, 1) + @"°";

                    ToggleProgramStatus(true);

                    Program.ConsoleForm.Show();
                    Program.ConsoleForm.Invoke(СonsoleDelegate, new Object[] { "Программа запущена (" +
                                                                               $"Широта: {AreaLatitude}, " +
                                                                               $"Долгота: {AreaLongitude}, " +
                                                                               $"Часовой пояс: {(TimeZone > 0 ? "+" + TimeZone : TimeZone.ToString())} (GTM), " +
                                                                               $"Уставка по времени: {$"{(TimerSetting) / 1000 / 60 / 60 % 24} ч. {(TimerSetting) / 1000 / 60 % 60} м. {(TimerSetting) / 1000 % 60} с."}, " +
                                                                               $"Порт: {PortName}, " +
                                                                               $"Драйвер трекера: {DriverPath.Split('\\').Last()}).",
                                                                               Color.Red });

                    CalculateCurrentAngles(true);

                    // Если солнце не зашло, то поворачиваемся.
                    if (90 - _SPAData.Zenith > 0)
                    {
                        SPortWrite((string)DriverMethod.Invoke(null, new object[] { Math.Round(_SPAData.Azimuth, 1), Math.Round(_SPAData.Zenith, 1) }));
                        Program.ConsoleForm.Invoke(СonsoleDelegate, new Object[] { $"Производится поворот на угол по азимуту: {Math.Round(_SPAData.Azimuth, 1)}°, по элевации: {Math.Round(90 - _SPAData.Zenith, 1)}° (команда: {(string)DriverMethod.Invoke(null, new object[] { Math.Round(_SPAData.Azimuth, 1), Math.Round(_SPAData.Zenith, 1) })}).", Color.Green });
                    }
                    else
                    {
                        Program.ConsoleForm.Invoke(СonsoleDelegate, new Object[] { $"Солнце зашло (расчетная элевация {Math.Round(90 - _SPAData.Zenith, 1)}°). Поворот не требуется.", Color.Green });
                    }
                }
                else
                {
                    ToggleProgramStatus(false);
                    Program.ConsoleForm.Invoke(СonsoleDelegate, new Object[] { "Программа остановлена.", Color.Red });
                    SPort.Close();
                }
            }
            catch (Exception ex)
            {
                ToggleProgramStatus(false);
                CalculateCurrentAngles(false);
                Program.ConsoleForm.Invoke(СonsoleDelegate, new Object[] { "Программа остановлена.", Color.Red });
                SPort.Close();
                Program.ConsoleForm.Invoke(СonsoleDelegate, new Object[] { $"В ходе запуска программы возникла ошибка: {ex}. \n\nПожалуйста, проверьте настройки программы.", Color.Red });
            }
        }