private void btnProperties_Click(object sender, EventArgs e)
 {
     // show data source properties
     if (GetSelectedItem(out _, out DataSourceConfig dataSourceConfig))
     {
         if (string.IsNullOrEmpty(dataSourceConfig.Driver))
         {
             ScadaUiUtils.ShowError(ExtensionPhrases.DriverNotSpecified);
         }
         else if (!ExtensionUtils.GetDriverView(adminContext, commApp, dataSourceConfig.Driver,
                                                out DriverView driverView, out string message))
         {
             ScadaUiUtils.ShowError(message);
         }
Exemple #2
0
        /// <summary>
        /// Fills the list of the channel types.
        /// </summary>
        private void FillChannelTypeList()
        {
            // fill shared list
            if (sharedChannelTypes == null)
            {
                ValidateInit();
                sharedChannelTypes = new List <ChannelTypeItem>();
                DirectoryInfo dirInfo = new(adminContext.AppDirs.LibDir);

                sharedChannelTypes.Add(new ChannelTypeItem
                {
                    TypeCode = "",
                    TypeName = ExtensionPhrases.UndefinedChannelType,
                    Driver   = ""
                });

                if (dirInfo.Exists)
                {
                    foreach (FileInfo fileInfo in
                             dirInfo.EnumerateFiles("DrvCnl*.View.dll", SearchOption.TopDirectoryOnly))
                    {
                        string driverCode = ScadaUtils.RemoveFileNameSuffixes(fileInfo.Name);

                        if (ExtensionUtils.GetDriverView(adminContext, commApp, driverCode,
                                                         out DriverView driverView, out string message))
                        {
                            if (driverView.CanCreateChannel &&
                                driverView.ChannelTypes is ICollection <ChannelTypeName> channelTypeNames)
                            {
                                foreach (ChannelTypeName channelTypeName in channelTypeNames)
                                {
                                    sharedChannelTypes.Add(new ChannelTypeItem
                                    {
                                        TypeCode = channelTypeName.Code,
                                        TypeName = channelTypeName.Name,
                                        Driver   = driverCode
                                    });
                                }
                            }
                        }
                        else
                        {
                            adminContext.ErrLog.WriteError(message);
                        }
                    }
                }
Exemple #3
0
        /// <summary>
        /// Initializes the driver item if needed.
        /// </summary>
        private void InitDriverItem(DriverItem driverItem)
        {
            if (!driverItem.IsInitialized)
            {
                driverItem.IsInitialized = true;

                if (ExtensionUtils.GetDriverView(adminContext, commApp, driverItem.DriverCode,
                                                 out DriverView driverView, out string message))
                {
                    driverItem.Descr      = BuildDriverDescr(driverView);
                    driverItem.DriverView = driverView;
                }
                else
                {
                    driverItem.Descr      = message;
                    driverItem.DriverView = null;
                }
            }
Exemple #4
0
        /// <summary>
        /// Sets the default polling options of the added device.
        /// </summary>
        private void SetPollingOptions()
        {
            if (!string.IsNullOrEmpty(DeviceConfig.Driver))
            {
                if (ExtensionUtils.GetDriverView(adminContext, Instance.CommApp, DeviceConfig.Driver,
                                                 out DriverView driverView, out string message))
                {
                    if (driverView.CanCreateDevice)
                    {
                        DeviceView     deviceView     = driverView.CreateDeviceView(LineConfig, DeviceConfig);
                        PollingOptions pollingOptions = deviceView?.GetPollingOptions();

                        if (pollingOptions != null)
                        {
                            pollingOptions.CopyTo(DeviceConfig.PollingOptions);
                        }
                    }
                }
                else
                {
                    ScadaUiUtils.ShowError(message);
                }
            }
Exemple #5
0
        /// <summary>
        /// Sets the default polling options for the specified device.
        /// </summary>
        private void SetPollingOptions(DeviceConfig deviceConfig)
        {
            if (!string.IsNullOrEmpty(deviceConfig.Driver))
            {
                if (ExtensionUtils.GetDriverView(adminContext, commApp, deviceConfig.Driver,
                                                 out DriverView driverView, out string message))
                {
                    if (driverView.CanCreateDevice)
                    {
                        DeviceView     deviceView     = driverView.CreateDeviceView(deviceConfig.ParentLine, deviceConfig);
                        PollingOptions pollingOptions = deviceView?.GetPollingOptions();

                        if (pollingOptions != null)
                        {
                            pollingOptions.CopyTo(deviceConfig.PollingOptions);
                        }
                    }
                }
                else
                {
                    lastErrorMessage = message;
                }
            }