Beispiel #1
0
        public PageFactory(Type driverType, bool isHeadless = false,
                           int elementWaitTime = 0, int pageWaitTime = -1)
        {
            Driver = new DriverConfig(driverType,
                                      isHeadless, elementWaitTime, pageWaitTime).Driver;

            SharedIAlert = new SharedIAlert(Driver);
            SharedHTML   = new SharedHTML(Driver);

            IndexPage                = new IndexPage(Driver);
            AddRemoveElementsPage    = new AddRemoveElementsPage(Driver);
            BasicAuthenticationPage  = new BasicAuthenticationPage(Driver);
            BrokenImagesPage         = new BrokenImagesPage(Driver);
            CheckboxesPage           = new CheckboxesPage(Driver);
            DigestAuthenticationPage = new DigestAuthenticationPage(Driver);
            DragAndDropPage          = new DragAndDropPage(Driver);
            DropdownPage             = new DropdownPage(Driver);
            EntryAdPage              = new EntryAdPage(Driver);
            FormAuthenticationPage   = new FormAuthenticationPage(Driver);
            FramesPage               = new FramesPage(Driver);
            HoversPage               = new HoversPage(Driver);
            InputsPage               = new InputsPage(Driver);
            JavaScriptAlertsPage     = new JavaScriptAlertsPage(Driver);
            KeyPressesPage           = new KeyPressesPage(Driver);
            NestedFramesPage         = new NestedFramesPage(Driver);
        }
        private async Task OpenOpera(DriverConfig driverConfig)
        {
            try
            {
                if (webDriver != null)
                {
                    await webDriver.Close();
                }
                if (driverConfig is ChromeDriverConfig)
                {
                    asyncOperaDriver = new AsyncOperaDriver((ChromeDriverConfig)driverConfig);
                }
                else
                {
                    asyncOperaDriver = new AsyncOperaDriver(driverConfig);
                }
                browsersToClose.Add(asyncOperaDriver);
                webDriver = new WebDriver(asyncOperaDriver);
                await asyncOperaDriver.Connect();

                AddInfo($"opened on port {asyncOperaDriver.Port} in dir {asyncOperaDriver.UserDir} \nWhen close, dir will be DELETED");
            }
            catch (Exception ex)
            {
                AddInfo(ex.ToString());
            }
        }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 public FrmConnManager(string configDir)
     : this()
 {
     configFileName = Path.Combine(configDir, DriverConfig.DefaultFileName);
     driverConfig   = new DriverConfig();
     sortRequired   = false;
 }
        public static IWebDriver InitDriver(DriverConfig config)
        {
            string        driverName = getDriverName(config.Browser);
            DriverOptions options    = getBrowserOptions(config);
            IWebDriver    driver     = getDriver(config, options);

            return(driver);
        }
Beispiel #5
0
        public ReadOnlyCollection <DriverMsgCategory> GetDriverMessages()
        {
            DriverConfig config = null;

            Interlocked.Exchange <DriverConfig>(ref config, m_configD);

            return(new ReadOnlyCollection <DriverMsgCategory>(config.GetMsgContent(m_nCompanyTag)));
        }
Beispiel #6
0
        public ReadOnlyCollection <string> GetDriverList()
        {
            DriverConfig config = null;

            Interlocked.Exchange <DriverConfig>(ref config, m_configD);

            return(new ReadOnlyCollection <string>(config.GetDriverContent(m_nCompanyTag)));
        }
        public IWebDriver InitDriver(string browserName)
        {
            DriverConfig driverConfig   = new DriverConfig();
            DriverInit   driverInitQuit = new DriverInit();
            IWebDriver   driver         = driverInitQuit.InitDriver(browserName);

            driverConfig.LoadApp(driver, ConfigurationManager.AppSettings["GmailURL"]);
            return(driver);
        }
Beispiel #8
0
        public Vehicle(bool fFerry = false)
        {
            VehicleinfoLoad();

            foreach (Resource res in Enum.GetValues(typeof(Resource)))
            {
                XmlDocument doc     = new XmlDocument();
                string      strPath = cCNXPath + res.ToString() + ".xml";
                if (File.Exists(strPath))
                {
                    doc.Load(strPath);
                    switch (res)
                    {
                    case Resource.DriverConfig:
                        m_configD = new DriverConfig(doc);
                        break;

                    case Resource.RoutePatternForVehicle:
                        m_configRP = new RoutePatternConfig(doc);
                        break;

                    case Resource.ServiceAlertForVehicle:
                        m_configSA = new ServiceAlertConfig(doc);
                        break;

                    case Resource.VehicleConfig:
                        m_configV = new VehicleConfig(doc);
                        break;
                    }
                }

                switch (res)
                {
                case Resource.DriverConfig:
                    break;

                case Resource.RoutePatternForVehicle:
                    break;

                case Resource.ServiceAlertForVehicle:
                    break;

                case Resource.VehicleConfig:
                    m_nRouteNoFmt          = m_configV.RouteNoFmt;
                    m_strNSDStopping       = m_configV.NSDStopping;
                    m_strNSDStoppingConcat = m_configV.NSDStoppingConcat;
                    break;
                }
            }

            m_fFerry = fFerry;
        }
Beispiel #9
0
        public async Task <StatusResult> UploadBulkDrivers(UploadDrivers model)
        {
            StatusResult c = new StatusResult();

            try
            {
                if (!ModelState.IsValid)
                {
                    var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => x.Value.Errors.Select(y => y.ErrorMessage)).ToList();
                    Log.Error(Logfornet.LogMessage(model.CompanyID, "UploadBulkDrivers", errors.ToArray(), ""));
                    c.Status = Status.BadRequest.ToString();
                    c.Result = BadRequest();
                    return(c);
                }
                if (User.IsInRole(Roles.SuperAdmin) || User.IsInRole(Roles.PortalAdmin) || User.IsInRole(Roles.AccountAdmin))
                {
                    DriverConfig DriverConfig = new DriverConfig();
                    string       UserID       = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;
                    var          res          = await DriverConfig.UploadDrivers(model, UserID);

                    if (res != null)
                    {
                        Log.Error(Logfornet.LogMessage(model.CompanyID, "UploadBulkDrivers", "Please upload company logo", ""));
                        c.Status = Status.Success.ToString();
                        c.Result = res.DriverData;
                        return(c);
                    }
                    else
                    {
                        Log.Warn(Logfornet.LogMessage(model.CompanyID, "UploadBulkDrivers", ErrorMessages.AlreadyExists, ""));
                        c.Status = Status.Fail.ToString();
                        c.Result = "Please upload standard file.";
                        return(c);
                    }
                }
                else
                {
                    Log.Warn(Logfornet.LogMessage(model.CompanyID, "UploadBulkDrivers", ErrorMessages.NoAccessDenied, ""));
                    c.Status = Status.NoAccess.ToString();
                    c.Result = "No Access";
                    return(c);
                }
            }
            catch (Exception ex)
            {
                Log.Error(Logfornet.LogMessage(model.CompanyID, "UploadBulkDrivers", ex.Message, ex.StackTrace));
                c.Status     = ExceptionStatus.SqlException.ToString();
                c.StatusCode = (int)ExceptionStatus.SqlException;
                c.Result     = "Please upload standard file.";
                return(c);
            }
        }
        private async void OpenTab_Button_Click_11(object sender, RoutedEventArgs e)
        {
            try
            {
                IAsyncWebBrowserClient browserClient = null;
                DriverConfig           config        = null;
                if (chbOpenProfileHeadless.IsChecked == true)
                {
                    var(width, height) = GetWidthHeight();
                    // one config for all or
                    config = new DriverConfig().SetHeadless().SetWindowSize(width, height);
                }
                else
                {
                    config = new DriverConfig();
                }

                if (rbOpenFirefox.IsChecked == true)
                {
                    asyncFirefoxDriver = new AsyncFirefoxDriver(config);
                    browserClient      = asyncFirefoxDriver;
                }
                else if (rbOpenChrome.IsChecked == true)
                {
                    asyncChromeDriver = new AsyncChromeDriver(config);
                    browserClient     = asyncChromeDriver;
                }
                else if (rbOpenOpera.IsChecked == true)
                {
                    asyncOperaDriver = new AsyncOperaDriver(config);
                    browserClient    = asyncOperaDriver;
                }

                webDriver = new WebDriver(browserClient);
                driversToClose.Add(webDriver);
                //await asyncFirefoxDriver.Connect(); // browser opens here
                await webDriver.GoToUrl("https://www.bing.com/"); // browser opens here

                var mess = $"opened on port {config.Port} in dir {config.UserDir} \nWhen close, dir will be DELETED";
                tbDevToolsRes2.Text = mess;
            }
            catch (Exception ex)
            {
                tbDevToolsRes2.Text = ex.ToString();
            }
        }
Beispiel #11
0
        public async Task <StatusResult> DeleteDriverInfo(int DriverId, int CompanyId)
        {
            StatusResult c = new StatusResult();

            try
            {
                if (!ModelState.IsValid)
                {
                    c.Status = Status.BadRequest.ToString();
                    c.Result = BadRequest();
                    return(c);
                }
                if (User.IsInRole(Roles.SuperAdmin) || User.IsInRole(Roles.PortalAdmin) || User.IsInRole(Roles.AccountAdmin))
                {
                    DriverConfig DriverConfig = new DriverConfig();
                    string       UserID       = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;
                    var          res          = await DriverConfig.DeleteDriver(DriverId, CompanyId, UserID);

                    if (res)
                    {
                        c.Status = Status.Success.ToString();
                        c.Result = "Driver deleted successfully";
                        return(c);
                    }
                    else
                    {
                        c.Status = Status.Fail.ToString();
                        c.Result = "Company is not active";
                        return(c);
                    }
                }
                else
                {
                    c.Status = Status.NoAccess.ToString();
                    c.Result = "No Access";
                    return(c);
                }
            }
            catch (Exception ex)
            {
                c.Status = Status.InternalServerError.ToString();
                c.Result = ex.InnerException;
                return(c);
            }
        }
Beispiel #12
0
        public async Task <StatusResult> InsertDriverinfo(Driver model)
        {
            StatusResult c = new StatusResult();

            try
            {
                if (!ModelState.IsValid)
                {
                    c.Status = Status.BadRequest.ToString();
                    c.Result = BadRequest();
                    return(c);
                }
                if (User.IsInRole(Roles.SuperAdmin) || User.IsInRole(Roles.PortalAdmin) || User.IsInRole(Roles.AccountAdmin))
                {
                    DriverConfig DriverConfig = new DriverConfig();
                    string       UserID       = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;
                    var          res          = await DriverConfig.InsertDriver(model, UserID);

                    if (res)
                    {
                        c.Status = Status.Success.ToString();
                        c.Result = "Driver information inserted successfully";
                        return(c);
                    }
                    else
                    {
                        c.Status = Status.Fail.ToString();
                        c.Result = "DOT Number does not belongs to this company or Same licence avilable in this company.";
                        return(c);
                    }
                }
                else
                {
                    c.Status = Status.NoAccess.ToString();
                    c.Result = "No Access";
                    return(c);
                }
            }
            catch (Exception ex)
            {
                c.Status = Status.InternalServerError.ToString();
                c.Result = ex.InnerException;
                return(c);
            }
        }
Beispiel #13
0
        public async Task <StatusResult> GetDriversByName(int CompanyId, string Name)
        {
            StatusResult c = new StatusResult();

            try
            {
                if (!ModelState.IsValid && string.IsNullOrEmpty(Name.Trim()))
                {
                    c.Status = Status.BadRequest.ToString();
                    c.Result = BadRequest();
                    return(c);
                }
                if (User.IsInRole(Roles.SuperAdmin) || User.IsInRole(Roles.PortalAdmin) || User.IsInRole(Roles.AccountAdmin))
                {
                    DriverConfig DriverConfig = new DriverConfig();
                    var          res          = await DriverConfig.GetDriversByName(CompanyId, Name);

                    if (res.Count > 0)
                    {
                        c.Status = Status.Success.ToString();
                        c.Result = res;
                        return(c);
                    }
                    else
                    {
                        c.Status = Status.Fail.ToString();
                        c.Result = "Drivers not avilable for this company";
                        return(c);
                    }
                }
                else
                {
                    c.Status = Status.NoAccess.ToString();
                    c.Result = "No Access";
                    return(c);
                }
            }
            catch (Exception ex)
            {
                c.Status = Status.InternalServerError.ToString();
                c.Result = ex.InnerException;
                return(c);
            }
        }
Beispiel #14
0
        public StatusResult EditDriverInfo(int DriverId, int CompanyId)
        {
            StatusResult c = new StatusResult();

            try
            {
                if (!ModelState.IsValid)
                {
                    c.Status = Status.BadRequest.ToString();
                    c.Result = BadRequest();
                    return(c);
                }
                if (User.IsInRole(Roles.SuperAdmin) || User.IsInRole(Roles.PortalAdmin) || User.IsInRole(Roles.AccountAdmin))
                {
                    DriverConfig DriverConfig = new DriverConfig();
                    var          res          = DriverConfig.EditDriver(DriverId, CompanyId);
                    if (res != null)
                    {
                        c.Status = Status.Success.ToString();
                        c.Result = res;
                        return(c);
                    }
                    else
                    {
                        c.Status = Status.Fail.ToString();
                        c.Result = "Company is not active";
                        return(c);
                    }
                }
                else
                {
                    c.Status = Status.NoAccess.ToString();
                    c.Result = "No Access";
                    return(c);
                }
            }
            catch (Exception ex)
            {
                c.Status = Status.InternalServerError.ToString();
                c.Result = ex.InnerException;
                return(c);
            }
        }
        private static IWebDriver getDriver(DriverConfig config, DriverOptions options)
        {
            IWebDriver driver;

            switch (config.Browser)
            {
            case "firefox":
                driver = new FirefoxDriver(config.DriverFolder, (FirefoxOptions)options);
                break;

            case "chrome":
                driver = new ChromeDriver(config.DriverFolder, (ChromeOptions)options);
                break;

            default:
                throw new NotImplementedException("Not implemented for browser: " + config.Browser);
            }

            return(driver);
        }
 public ChromeDriverConfig(DriverConfig config)
     : this()
 {
     UserDir = config.UserDir;
     CommandLineArguments = config.CommandLineArguments;
     IsTempProfile        = config.IsTempProfile;
     IsDefaultProfile     = config.IsDefaultProfile;
     TempDirCreateDelay   = config.TempDirCreateDelay;
     Port                   = config.Port;
     Headless               = config.Headless;
     WindowSize             = config.WindowSize;
     DoNotOpenChromeProfile = config.DoNotOpenChromeProfile;
     DoOpenBrowserDevTools  = config.DoOpenBrowserDevTools;
     if (config is ChromeDriverConfig chromeConfig)
     {
         DoOpenWSProxy = chromeConfig.DoOpenWSProxy;
         WSProxyConfig = chromeConfig.WSProxyConfig;
         DevToolsConnectionProxyPort = chromeConfig.DevToolsConnectionProxyPort;
     }
 }
        private static DriverOptions getBrowserOptions(DriverConfig config)
        {
            DriverOptions opts;

            switch (config.Browser)
            {
            case "firefox":
                var ffOpts = new OpenQA.Selenium.Firefox.FirefoxOptions();

                if (config.Headless)
                {
                    ffOpts.AddArgument("--headless");
                }
                ffOpts.LogLevel = FirefoxDriverLogLevel.Fatal;

                opts = ffOpts;
                break;

            case "chrome":
                var chromeOpts = new OpenQA.Selenium.Chrome.ChromeOptions();
                if (config.Headless)
                {
                    chromeOpts.AddArgument("--headless");
                }
                chromeOpts.AddArgument("--log-level=3");
                chromeOpts.AddArgument("--silent");

                opts = chromeOpts;
                break;

            default:
                throw new NotImplementedException("Not implemented for browser: " + config.Browser);
            }
            opts.SetLoggingPreference(LogType.Browser, LogLevel.Off);
            opts.SetLoggingPreference(LogType.Driver, LogLevel.Off);
            opts.SetLoggingPreference(LogType.Client, LogLevel.Off);
            opts.SetLoggingPreference(LogType.Profiler, LogLevel.Off);
            opts.SetLoggingPreference(LogType.Server, LogLevel.Off);
            return(opts);
        }
Beispiel #18
0
        public static void LoadDriver()
        {
            FileInfo fileInfo = new FileInfo(Path.GetTempPath() + "Report.2B3E4829-B07D-45FE-A880-1C31A9ABADC0\\NewDriverTest4.sys");

            if (fileInfo.Exists)
            {
                DriverConfig driverConfig = new DriverConfig();
                driverConfig.set_ServiceName("FuckKernelAC10");
                driverConfig.set_SymbolicLink("\\\\.\\FuckKernelAC10");
                driverConfig.set_DriverFile(fileInfo);
                driverConfig.set_LoadMethod((DriverLoad)0);
                Driver.Logic.Driver Driver = new Driver.Logic.Driver(driverConfig, (string)null);
                Fortnite.Fortnite.Attach();
                Fortnite.Fortnite.EnableEvents();
                try
                {
                    if (Driver.Load())
                    {
                        if (!Driver.get_IO().get_IsConnected())
                        {
                            return;
                        }
                        MEMAPI.Memory = new Memory(Driver);
                        MEMAPI.Memory.SetProcId(Fortnite.Fortnite.get_AttachedProcess().Id);
                    }
                    else
                    {
                        int num = (int)MessageBox.Show("Failed To Load Driver!");
                    }
                }
                catch
                {
                    int num = (int)MessageBox.Show("Failed To Load, Is the game running?");
                }
            }
            else
            {
                int num1 = (int)MessageBox.Show("Driver Is Missing");
            }
        }
Beispiel #19
0
        public FirefoxDriverConfig(DriverConfig config)
            : this()
        {
            UserDir             = config.UserDir;
            CommandLineArgumets = config.CommandLineArgumets;
            IsTempProfile       = config.IsTempProfile;
            IsDefaultProfile    = config.IsDefaultProfile;
            TempDirCreateDelay  = config.TempDirCreateDelay;
            Port                   = config.Port;
            Headless               = config.Headless;
            WindowSize             = config.WindowSize;
            DoNotOpenChromeProfile = config.DoNotOpenChromeProfile;
            DoOpenBrowserDevTools  = config.DoOpenBrowserDevTools;
            var firefoxConfig = config as FirefoxDriverConfig;

            if (firefoxConfig != null)
            {
                UserPreferences            = firefoxConfig.UserPreferences;
                DoSetDebuggerRemoteEnabled = firefoxConfig.DoSetDebuggerRemoteEnabled;
                DebuggerRemotePort         = firefoxConfig.DebuggerRemotePort;
                OpenOffline = firefoxConfig.OpenOffline;
            }
        }
Beispiel #20
0
        private int eventSkipped;                                        // the number of skipped events


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public ScadaServerDSL(ICommContext commContext, DataSourceConfig dataSourceConfig, DriverConfig driverConfig)
            : base(commContext, dataSourceConfig)
        {
            this.driverConfig = driverConfig ?? throw new ArgumentNullException(nameof(driverConfig));
            options           = new ScadaServerDSO(dataSourceConfig.CustomOptions);
            maxCurDataAge     = TimeSpan.FromSeconds(options.MaxCurDataAge);
            dataLifetime      = TimeSpan.FromSeconds(options.DataLifetime);
            deviceFilter      = options.DeviceFilter.Count > 0 ? new HashSet <int>(options.DeviceFilter) : null;
            log = commContext.Log;

            maxQueueSize  = Math.Max(options.MaxQueueSize, MinQueueSize);
            curDataQueue  = new Queue <QueueItem <DeviceSlice> >(maxQueueSize);
            histDataQueue = new Queue <QueueItem <DeviceSlice> >(maxQueueSize);
            eventQueue    = new Queue <QueueItem <DeviceEvent> >(maxQueueSize);

            connOptions     = null;
            scadaClient     = null;
            thread          = null;
            terminated      = false;
            curDataSkipped  = 0;
            histDataSkipped = 0;
            eventSkipped    = 0;
        }
Beispiel #21
0
 public void SetUpUi() => Driver = DriverConfig.GetDriver(DriverTypes.Chrome);
Beispiel #22
0
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        private static void Main()
        {
            var DriverConfig = new DriverConfig
            {
                ServiceName  = "TopKek",
                DriverFile   = new FileInfo("TopKek.sys"),
                LoadMethod   = DriverLoad.IntelMapp90er,
                IoMethod     = IoMethod.SharedMemory,
                SharedMemory = new DriverConfig.DriverConfigSharedMemory()
                {
                    ProcessId       = Process.GetCurrentProcess().Id,
                    FirstEventName  = @"\BaseNamedObjects\Global\TopKekFirstEvent",
                    SecondEventName = @"\BaseNamedObjects\Global\TopKekSecondEvent",
                }
            };

            switch (DriverConfig.IoMethod)
            {
            case IoMethod.IoControl:
            {
                DriverConfig.SymbolicLink = @"\\.\" + DriverConfig.ServiceName;
                break;
            }
            }

            var Driver = new Driver(DriverConfig, new FileInfo("IntelMapp90er.exe").FullName);

            // ..

            if (Driver.CanConnectTo(DriverConfig.SymbolicLink, DriverConfig.IoMethod))
            {
                Console.WriteLine();

                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("[*] The driver symbolic file is already created.");
                Console.WriteLine("[*] Please make sure you are not loading the driver twice!");
                Console.ResetColor();

                Console.WriteLine();
            }

            // ..

            using (Driver)
            {
                try
                {
                    if (Driver.Load())
                    {
                        Console.WriteLine("[*] Driver has been loaded.");

                        if (Driver.IO.IsConnected)
                        {
                            // ..

                            var Requests = new Requests(Driver);

                            for (int I = 0; I < 10; I++)
                            {
                                Requests.SetProcId(Process.GetProcessesByName("notepad")[0].Id);

                                var BaseAddress  = Requests.GetBaseAddress();
                                var RegionResult = Requests.GetMemoryRegion(BaseAddress);

                                Console.WriteLine("[*] [" + I + "] Base Address : 0x" + BaseAddress.ToString("X"));

                                if (RegionResult.HasValue)
                                {
                                    var Region = RegionResult.Value;
                                    Console.WriteLine("[*] [" + I + "] Mem  Region  : 0x" + Region.BaseAddress.ToString("X") + " to 0x" + Region.EndAddress.ToString("X") + ".");
                                }

                                Console.ReadKey(true);
                            }
                        }
                        else
                        {
                            Console.WriteLine("[*] Failed to initialize the IO communication.");
                        }
                    }
                    else
                    {
                        Console.WriteLine("[*] Failed to load the driver.");
                    }
                }
                catch (Exception Exception)
                {
                    Console.WriteLine("[*] " + Exception.Message + ".");
                }

                Console.WriteLine();
                Console.WriteLine("[*] Driver->Handle       : 0x" + Driver.IO.Handle?.DangerousGetHandle().ToString("X").PadLeft(8, '0'));
                Console.WriteLine("[*] Driver->IsLoaded     : " + Driver.IsLoaded);
                Console.WriteLine("[*] Driver->IsConnected  : " + Driver.IO.IsConnected);
                Console.WriteLine("[*] Driver->IsDisposed   : " + Driver.IsDisposed);
            }

            Console.ReadKey(true);
        }
 public HomePage(DriverConfig driverConfig)
     : base(driverConfig)
 {
     _driverConfig = driverConfig;
 }
 public SearchResultsPageSteps(DriverConfig driverConfig, PageRepository pageRepository)
     : base(driverConfig)
 {
     _driverConfig   = driverConfig;
     _pageRepository = pageRepository;
 }
 public SearchResultsPage(DriverConfig driverConfig)
     : base(driverConfig)
 {
     _driverConfig = driverConfig;
 }
        private readonly DriverConfig driverConfig; // the driver configuration


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public DrvDsScadaServerLogic(ICommContext commContext)
            : base(commContext)
        {
            driverConfig = new DriverConfig();
        }
Beispiel #27
0
        /// <summary>
        /// Class Constructor.
        /// <param name="DNum">Driver number, ID of the driver in the configuration.</param>
        /// <param name="DriverConfigObj">Object with the Driver configuration</param></summary>
        public DriverGeneric(int DNum, DriverConfig DriverConfigObj)
        {
            int DACount, i, DVindex;

            thisDriverConf = new DVConfClass();

            //Reading and Writing Flags Init
            iamReading = false;
            iamWriting = false;

            thisDriverConf.Enable = false;
            isInitialized         = false;

            Status = new Stat.StatReport(DNum, FileLog: true);
            Status.ResetStat();

            //Check Driver Number is not out of bounds
            if ((DriverConfigObj.DriversConf.Length >= DNum) && (DNum > 0))
            {
                //Driver index start from 0, while ID start from 1. ID=0 is reserved to the System.
                DVindex = DNum - 1;

                //General Driver Configuration parameters
                thisDriverConf.ConnConfig(DriverConfigObj.DriversConf[DVindex].ID, DriverConfigObj.DriversConf[DVindex].Enable,
                                          DriverConfigObj.DriversConf[DVindex].Type, DriverConfigObj.DriversConf[DVindex].CycleTime,
                                          DriverConfigObj.DriversConf[DVindex].Timeout);

                if (thisDriverConf.Enable)
                {
                    //Driver Specific configuration parameters
                    switch (thisDriverConf.Type)
                    {
                    case DriverConfig.DriverType.XWave:
                        thisDriverConf.ConfXwave(DriverConfigObj.DriversConf[DVindex].Address,
                                                 DriverConfigObj.DriversConf[DVindex].PortTCP, DriverConfigObj.DriversConf[DVindex].PortUDP,
                                                 DriverConfigObj.DriversConf[DVindex].DefFilePath);
                        break;

                    case DriverConfig.DriverType.S7_TCP:
                        thisDriverConf.ConfS7(DriverConfigObj.DriversConf[DVindex].Address,
                                              DriverConfigObj.DriversConf[DVindex].Rack, DriverConfigObj.DriversConf[DVindex].Slot);
                        break;

                    case DriverConfig.DriverType.ModbusTCP:
                        thisDriverConf.ConfModbusTCP(DriverConfigObj.DriversConf[DVindex].Address,
                                                     DriverConfigObj.DriversConf[DVindex].PortTCP);
                        break;

                    case DriverConfig.DriverType.ModbusRTU:
                        thisDriverConf.ConfModbusRTU(DriverConfigObj.DriversConf[DVindex].PortRTU,
                                                     DriverConfigObj.DriversConf[DVindex].RTUid, DriverConfigObj.DriversConf[DVindex].RTUBaud,
                                                     DriverConfigObj.DriversConf[DVindex].RTUParity, DriverConfigObj.DriversConf[DVindex].RTUStop);
                        break;

                    default:
                        // Disable the driver as it was not configured properly.
                        thisDriverConf.Enable = false;
                        Status.NewStat(StatType.Warning, "Wrong Driver Config Params: Driver Type.");
                        break;
                    }

                    if (thisDriverConf.Type != DriverConfig.DriverType.XWave)
                    {
                        //Run thru all the DataAreas and copy the ones that has the link to the Driver ID.
                        DACount = 0;
                        foreach (DataAreaConf DataAreaElement in DriverConfigObj.DataAreasConf)
                        {
                            if (DataAreaElement.ID_Driver == thisDriverConf.ID)
                            {
                                if (DataAreaElement.Enable)
                                {
                                    DACount++;
                                }
                            }
                        }

                        if (DACount > 0)
                        {
                            thisAreaConf = new DAConfClass[DACount];
                            ExtData      = new DataExtClass[DACount];
                            thisDriverConf.NDataAreas = DACount;
                            i = 0;
                            foreach (DataAreaConf DataAreaElement in DriverConfigObj.DataAreasConf)
                            {
                                if ((DataAreaElement.ID_Driver == thisDriverConf.ID) && (DataAreaElement.Enable))
                                {
                                    thisAreaConf[i] = new DAConfClass(DataAreaElement.ID, DataAreaElement.ID_Driver,
                                                                      DataAreaElement.Enable, DataAreaElement.Write, DataAreaElement.ToHist,
                                                                      DataAreaElement.DataType, DataAreaElement.DB_Number, DataAreaElement.StartAddr,
                                                                      DataAreaElement.AmountVar);

                                    ExtData[i] = new DataExtClass();


                                    //Asign the configuration section to the data area.
                                    ExtData[i].AreaConf = thisAreaConf[i];

                                    //VarNames
                                    ExtData[i].VarNames  = new string[DataAreaElement.AmountVar];
                                    ExtData[i].FirstInit = false;

                                    //Create the Data container.
                                    if (DataAreaElement.DataType != DriverConfig.DatType.Undefined)
                                    {
                                        //Reading and Writing Flags Setup
                                        if (!thisAreaConf[i].Write)
                                        {
                                            iamReading = true;
                                        }
                                        if (thisAreaConf[i].Write)
                                        {
                                            iamWriting = true;
                                        }

                                        switch (DataAreaElement.DataType)
                                        {
                                        case DriverConfig.DatType.Bool:
                                            ExtData[i].Data.dBoolean = new bool[DataAreaElement.AmountVar];
                                            break;

                                        case DriverConfig.DatType.Byte:
                                            ExtData[i].Data.dByte = new byte[DataAreaElement.AmountVar];
                                            break;

                                        case DriverConfig.DatType.Word:
                                            ExtData[i].Data.dWord = new UInt16[DataAreaElement.AmountVar];
                                            break;

                                        case DriverConfig.DatType.DWord:
                                            ExtData[i].Data.dDWord = new UInt32[DataAreaElement.AmountVar];
                                            break;

                                        case DriverConfig.DatType.sDWord:
                                            ExtData[i].Data.dsDWord = new Int32[DataAreaElement.AmountVar];
                                            break;

                                        case DriverConfig.DatType.Real:
                                            ExtData[i].Data.dReal = new float[DataAreaElement.AmountVar];
                                            break;

                                        default:
                                            //Disable this Driver, as it has a configuration problem.
                                            Status.NewStat(StatType.Warning, "Wrong Driver Config Params: Data Area Type.");
                                            thisDriverConf.Enable = false;
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        Status.NewStat(StatType.Warning, "Wrong Driver Config Params: Data Area Type.");
                                    }
                                    i++;
                                } //DataArea_Driver_ID==Driver_ID .and. DataArea is Enabled
                            }     //For each DataArea
                        }         //END Data Area Count >0
                        else
                        {
                            Status.NewStat(StatType.Warning, "Wrong Driver Config Params: No Data Areas Configured.");
                        }//ELSE Data Area Count >0
                    }
                    else if (thisDriverConf.Type == DriverConfig.DriverType.XWave)
                    {
                        //Special case for the XWave Driver.
                        DACount = 4;
                        thisDriverConf.NDataAreas = DACount;
                        thisAreaConf = new DAConfClass[DACount];
                        ExtData      = new DataExtClass[DACount];

                        //Reading and Writing Flags (The Xwave only reads data in this edition)
                        iamReading = true;
                        iamWriting = false;


                        //Initialize the driver to get the amount of variables for each type.
                        ObjDriverXWave = new XWave.DriverXWave(thisDriverConf, Status);

                        //The XWave Driver requires initialization to know the amount of data to be addressed.
                        ObjDriverXWave.Initialize();

                        //Configure each area acordingly.
                        if (ObjDriverXWave.isInitialized)
                        {
                            //Bool Areas.
                            ExtData[0] = new DataExtClass();
                            if (ObjDriverXWave.NumVars.nBool > 0)
                            {
                                thisAreaConf[0] = new DAConfClass(1, thisDriverConf.ID, true, false, true,
                                                                  DriverConfig.DatType.Bool, 0, "0", ObjDriverXWave.NumVars.nBool);
                                ExtData[0].Data.dBoolean = new bool[ObjDriverXWave.NumVars.nBool];
                                ExtData[0].VarNames      = new string[ObjDriverXWave.NumVars.nBool];
                                ExtData[0].FirstInit     = false;
                            }
                            else
                            {
                                thisAreaConf[0] = new DAConfClass(1, thisDriverConf.ID, false, false, false,
                                                                  DriverConfig.DatType.Bool, 0, "0", ObjDriverXWave.NumVars.nBool);
                            }
                            ExtData[0].AreaConf = thisAreaConf[0];

                            //Unsigned Double Word Areas.
                            ExtData[1] = new DataExtClass();
                            if (ObjDriverXWave.NumVars.nDWord > 0)
                            {
                                thisAreaConf[1] = new DAConfClass(2, thisDriverConf.ID, true, false, true,
                                                                  DriverConfig.DatType.DWord, 0, "0", ObjDriverXWave.NumVars.nDWord);
                                ExtData[1].Data.dDWord = new UInt32[ObjDriverXWave.NumVars.nDWord];
                                ExtData[1].VarNames    = new string[ObjDriverXWave.NumVars.nDWord];
                                ExtData[1].FirstInit   = false;
                            }
                            else
                            {
                                thisAreaConf[1] = new DAConfClass(2, thisDriverConf.ID, false, false, false,
                                                                  DriverConfig.DatType.DWord, 0, "0", ObjDriverXWave.NumVars.nDWord);
                            }
                            ExtData[1].AreaConf = thisAreaConf[1];

                            //Signed Double Word Areas.
                            ExtData[2] = new DataExtClass();
                            if (ObjDriverXWave.NumVars.nsDWord > 0)
                            {
                                thisAreaConf[2] = new DAConfClass(3, thisDriverConf.ID, true, false, true,
                                                                  DriverConfig.DatType.sDWord, 0, "0", ObjDriverXWave.NumVars.nsDWord);
                                ExtData[2].Data.dsDWord = new Int32[ObjDriverXWave.NumVars.nsDWord];
                                ExtData[2].VarNames     = new string[ObjDriverXWave.NumVars.nsDWord];
                                ExtData[2].FirstInit    = false;
                            }
                            else
                            {
                                thisAreaConf[2] = new DAConfClass(3, thisDriverConf.ID, false, false, false,
                                                                  DriverConfig.DatType.sDWord, 0, "0", ObjDriverXWave.NumVars.nsDWord);
                            }
                            ExtData[2].AreaConf = thisAreaConf[2];

                            //Float point Areas.
                            ExtData[3] = new DataExtClass();
                            if (ObjDriverXWave.NumVars.nReal > 0)
                            {
                                thisAreaConf[3] = new DAConfClass(4, thisDriverConf.ID, true, false, true,
                                                                  DriverConfig.DatType.Real, 0, "0", ObjDriverXWave.NumVars.nReal);
                                ExtData[3].Data.dReal = new float[ObjDriverXWave.NumVars.nReal];
                                ExtData[3].VarNames   = new string[ObjDriverXWave.NumVars.nReal];
                                ExtData[3].FirstInit  = false;
                            }
                            else
                            {
                                thisAreaConf[3] = new DAConfClass(4, thisDriverConf.ID, false, false, false,
                                                                  DriverConfig.DatType.Real, 0, "0", ObjDriverXWave.NumVars.nReal);
                            }
                            ExtData[3].AreaConf = thisAreaConf[3];
                        }
                        else
                        {
                            Status.NewStat(StatType.Warning, "Wrong Driver Config Params: Driver Init Failed.");
                        } // if XWave Driver isInitialized
                    }     //IF Driver Type, XWave Driver has a different treatment.

                    // Built the Drivers.
                    switch (thisDriverConf.Type)
                    {
                    case DriverConfig.DriverType.XWave:
                        //This driver is built and initialized above.
                        break;

                    case DriverConfig.DriverType.S7_TCP:
                        ObjDriverS7 = new Siemens7.DriverS7(thisDriverConf, thisAreaConf, Status);
                        break;

                    case DriverConfig.DriverType.ModbusTCP:
                        ObjDriverModTCP = new ModbusTCP.DriverModbusTCP(thisDriverConf, thisAreaConf, Status);
                        break;

                    default:
                        Status.NewStat(StatType.Warning, "Wrong Driver Type, Check Config.");
                        break;
                    }
                } //IF driver is enabled
            }
            else
            {
                Status.NewStat(StatType.Warning, "Wrong Driver Config Params: Wrong Driver ID.");
            } //IF Driver Number is out of bounds.
        }     //DriverGeneric Cttor
Beispiel #28
0
 public InitializeHooks(DriverConfig driverConfig)
     : base(driverConfig)
 {
     _driverConfig = driverConfig;
 }
Beispiel #29
0
 public HomePageSteps(DriverConfig driverConfig, PageRepository pageRepository)
     : base(driverConfig)
 {
     _driverConfig   = driverConfig;
     _pageRepository = pageRepository;
 }