/// <summary>
        /// Updates the tree node that represents communication lines and its child nodes.
        /// </summary>
        public void UpdateLinesNode(TreeNode linesNode)
        {
            ArgumentNullException.ThrowIfNull(linesNode, nameof(linesNode));

            try
            {
                linesNode.TreeView?.BeginUpdate();

                // remove existing line nodes
                foreach (TreeNode lineNode in new ArrayList(linesNode.Nodes))
                {
                    lineNode.Remove();
                }

                // add new line nodes
                CommNodeTag nodeTag = (CommNodeTag)linesNode.Tag;
                CommApp     commApp = nodeTag.CommApp;

                foreach (LineConfig lineConfig in commApp.AppConfig.Lines)
                {
                    linesNode.Nodes.Add(CreateLineNode(commApp, lineConfig));
                }
            }
            finally
            {
                linesNode.TreeView?.EndUpdate();
            }
        }
 /// <summary>
 /// Saves the Communicator configuration.
 /// </summary>
 private void SaveCommConfig(CommApp commApp)
 {
     if (!commApp.SaveConfig(out string errMsg))
     {
         adminContext.ErrLog.HandleError(errMsg);
     }
 }
Exemple #3
0
        private ChannelConfig channelConfigCopy;                         // the edited copy of the communication channel configuration


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public CtrlLineMain()
        {
            InitializeComponent();
            adminContext      = null;
            commApp           = null;
            changing          = false;
            channelConfigCopy = null;
        }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 public FrmGeneralOptions(ILog log, CommApp commApp)
     : this()
 {
     this.log     = log ?? throw new ArgumentNullException(nameof(log));
     this.commApp = commApp ?? throw new ArgumentNullException(nameof(commApp));
     commConfig   = commApp.AppConfig;
     changing     = false;
 }
 /// <summary>
 /// Gets the Communicator application from the selected node, and validates the node type.
 /// </summary>
 private bool GetCommApp(out CommApp commApp, params string[] allowedNodeTypes)
 {
     if (SelectedNode?.Tag is CommNodeTag commNodeTag &&
         (allowedNodeTypes == null || allowedNodeTypes.Contains(commNodeTag.NodeType)))
     {
         commApp = commNodeTag.CommApp;
         return(true);
     }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 public FrmLineConfig(IAdminContext adminContext, CommApp commApp, LineConfig lineConfig)
     : this()
 {
     this.adminContext  = adminContext ?? throw new ArgumentNullException(nameof(adminContext));
     this.commApp       = commApp ?? throw new ArgumentNullException(nameof(commApp));
     this.lineConfig    = lineConfig ?? throw new ArgumentNullException(nameof(lineConfig));
     mainOptionsReady   = false;
     customOptionsReady = false;
     devicePollingReady = false;
 }
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 public FrmDataSources(IAdminContext adminContext, CommApp commApp)
     : this()
 {
     this.adminContext   = adminContext ?? throw new ArgumentNullException(nameof(adminContext));
     this.commApp        = commApp ?? throw new ArgumentNullException(nameof(commApp));
     commConfig          = commApp.AppConfig;
     changing            = false;
     dataSourceClipboard = null;
     SetColumnNames();
 }
Exemple #8
0
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public FrmSync(IAdminContext adminContext, ScadaProject project, CommApp commApp)
            : this()
        {
            this.adminContext = adminContext ?? throw new ArgumentNullException(nameof(adminContext));
            this.project      = project ?? throw new ArgumentNullException(nameof(project));
            this.commApp      = commApp ?? throw new ArgumentNullException(nameof(commApp));
            commConfig        = commApp.AppConfig;
            lastErrorMessage  = "";

            SelectedLineNum = 0;
            AddedToComm     = false;
        }
        private DeviceConfig deviceClipboard; // contains the copied device


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public CtrlLinePolling()
        {
            InitializeComponent();
            numNumAddress.Maximum = int.MaxValue;

            SetColumnNames();
            adminContext    = null;
            commApp         = null;
            lineConfig      = null;
            changing        = false;
            deviceClipboard = null;
        }
Exemple #10
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 public FrmDeviceData(IAdminContext adminContext, CommApp commApp, DeviceConfig deviceConfig) :
     this()
 {
     this.adminContext = adminContext ?? throw new ArgumentNullException(nameof(adminContext));
     this.commApp      = commApp ?? throw new ArgumentNullException(nameof(commApp));
     this.deviceConfig = deviceConfig ?? throw new ArgumentNullException(nameof(deviceConfig));
     dataBox           = new RemoteLogBox(lbDeviceData)
     {
         FullLogView = true
     };
     frmDeviceCommand = null;
     isClosed         = false;
 }
 /// <summary>
 /// Creates a tree node that represents the device.
 /// </summary>
 public TreeNode CreateDeviceNode(CommApp commApp, DeviceConfig deviceConfig)
 {
     return(new TreeNode(CommUtils.GetDeviceTitle(deviceConfig))
     {
         ImageKey = ImageKey.Device,
         SelectedImageKey = ImageKey.Device,
         ContextMenuStrip = menuControl.DeviceMenu,
         Tag = new CommNodeTag(commApp, deviceConfig, CommNodeType.Device)
         {
             FormType = typeof(FrmDeviceData),
             FormArgs = new object[] { adminContext, commApp, deviceConfig }
         }
     });
 }
        /// <summary>
        /// Creates a tree node that represents communication lines.
        /// </summary>
        private TreeNode CreateLinesNode(CommApp commApp)
        {
            TreeNode linesNode = TreeViewExtensions.CreateNode(ExtensionPhrases.LinesNode, ImageKey.Lines);

            linesNode.ContextMenuStrip = menuControl.LineMenu;
            linesNode.Tag = new CommNodeTag(commApp, commApp.AppConfig, CommNodeType.Lines);

            foreach (LineConfig lineConfig in commApp.AppConfig.Lines)
            {
                linesNode.Nodes.Add(CreateLineNode(commApp, lineConfig));
            }

            return(linesNode);
        }
        /// <summary>
        /// Creates tree nodes for the explorer tree.
        /// </summary>
        public TreeNode[] CreateTreeNodes(CommApp commApp)
        {
            ArgumentNullException.ThrowIfNull(commApp, nameof(commApp));

            return(new TreeNode[]
            {
                new TreeNode(ExtensionPhrases.GeneralOptionsNode)
                {
                    ImageKey = ImageKey.Options,
                    SelectedImageKey = ImageKey.Options,
                    Tag = new CommNodeTag(commApp, null, CommNodeType.GeneralOptions)
                    {
                        FormType = typeof(FrmGeneralOptions),
                        FormArgs = new object[] { adminContext.ErrLog, commApp }
                    }
                },
                new TreeNode(ExtensionPhrases.DriversNode)
                {
                    ImageKey = ImageKey.Driver,
                    SelectedImageKey = ImageKey.Driver,
                    Tag = new CommNodeTag(commApp, null, CommNodeType.Drivers)
                    {
                        FormType = typeof(FrmDrivers),
                        FormArgs = new object[] { adminContext, commApp }
                    }
                },
                new TreeNode(ExtensionPhrases.DataSourcesNode)
                {
                    ImageKey = ImageKey.DataSource,
                    SelectedImageKey = ImageKey.DataSource,
                    Tag = new CommNodeTag(commApp, null, CommNodeType.DataSources)
                    {
                        FormType = typeof(FrmDataSources),
                        FormArgs = new object[] { adminContext, commApp }
                    }
                },
                CreateLinesNode(commApp),
                new TreeNode(ExtensionPhrases.LogsNode)
                {
                    ImageKey = ImageKey.Stats,
                    SelectedImageKey = ImageKey.Stats,
                    Tag = new CommNodeTag(commApp, null, CommNodeType.Logs)
                    {
                        FormType = typeof(FrmCommLogs),
                        FormArgs = new object[] { adminContext }
                    }
                }
            });
        }
Exemple #14
0
        /// <summary>
        /// Gets a new instance of the device user interface.
        /// </summary>
        public static bool GetDeviceView(IAdminContext adminContext, CommApp commApp, DeviceConfig deviceConfig,
                                         out DeviceView deviceView, out string errMsg)
        {
            ArgumentNullException.ThrowIfNull(adminContext, nameof(adminContext));
            ArgumentNullException.ThrowIfNull(commApp, nameof(commApp));
            ArgumentNullException.ThrowIfNull(deviceConfig, nameof(deviceConfig));
            deviceView = null;

            if (string.IsNullOrEmpty(deviceConfig.Driver))
            {
                errMsg = ExtensionPhrases.DriverNotSpecified;
                return(false);
            }
            else if (!GetDriverView(adminContext, commApp, deviceConfig.Driver,
                                    out DriverView driverView, out errMsg))
            {
                return(false);
            }
Exemple #15
0
        /// <summary>
        /// Gets a new instance of the module user interface.
        /// </summary>
        public static bool GetDriverView(IAdminContext adminContext, CommApp commApp, string driverCode,
                                         out DriverView driverView, out string message)
        {
            ArgumentNullException.ThrowIfNull(adminContext, nameof(adminContext));
            ArgumentNullException.ThrowIfNull(commApp, nameof(commApp));

            if (DriverFactory.GetDriverView(adminContext.AppDirs.LibDir, driverCode, out driverView, out message))
            {
                driverView.ConfigDataset = adminContext.CurrentProject.ConfigDatabase;
                driverView.AppDirs       = adminContext.AppDirs.CreateDirsForView(commApp.ConfigDir);
                driverView.AgentClient   = adminContext.MainForm.GetAgentClient(false);
                driverView.AppConfig     = commApp.AppConfig;
                driverView.LoadDictionaries();
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// Creates a tree node that represents the specified communication line.
        /// </summary>
        public TreeNode CreateLineNode(CommApp commApp, LineConfig lineConfig)
        {
            TreeNode lineNode = TreeViewExtensions.CreateNode(CommUtils.GetLineTitle(lineConfig),
                                                              lineConfig.Active ? ImageKey.Line : ImageKey.LineInactive);

            lineNode.ContextMenuStrip = menuControl.LineMenu;
            lineNode.Tag = new CommNodeTag(commApp, lineConfig, CommNodeType.Line);

            lineNode.Nodes.AddRange(new TreeNode[]
            {
                new TreeNode(ExtensionPhrases.LineOptionsNode)
                {
                    ImageKey         = ImageKey.Options,
                    SelectedImageKey = ImageKey.Options,
                    Tag = new CommNodeTag(commApp, null, CommNodeType.LineOptions)
                    {
                        FormType = typeof(FrmLineConfig),
                        FormArgs = new object[] { adminContext, commApp, lineConfig }
                    }
                },
                new TreeNode(ExtensionPhrases.LineStatsNode)
                {
                    ImageKey         = ImageKey.Stats,
                    SelectedImageKey = ImageKey.Stats,
                    Tag = new CommNodeTag(commApp, null, CommNodeType.LineStats)
                    {
                        FormType = typeof(FrmLineStats),
                        FormArgs = new object[] { adminContext, lineConfig }
                    }
                }
            });

            foreach (DeviceConfig deviceConfig in lineConfig.DevicePolling)
            {
                lineNode.Nodes.Add(CreateDeviceNode(commApp, deviceConfig));
            }

            return(lineNode);
        }
Exemple #17
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 public FrmDrivers(IAdminContext adminContext, CommApp commApp)
     : this()
 {
     this.adminContext = adminContext ?? throw new ArgumentNullException(nameof(adminContext));
     this.commApp      = commApp ?? throw new ArgumentNullException(nameof(commApp));
 }
Exemple #18
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 public CommNodeTag(CommApp commApp, object relatedObject, string nodeType)
     : base(relatedObject, nodeType)
 {
     CommApp = commApp ?? throw new ArgumentNullException(nameof(commApp));
 }
 /// <summary>
 /// Initializes the control.
 /// </summary>
 public void Init(IAdminContext adminContext, CommApp commApp, LineConfig lineConfig)
 {
     this.adminContext = adminContext ?? throw new ArgumentNullException(nameof(adminContext));
     this.commApp      = commApp ?? throw new ArgumentNullException(nameof(commApp));
     this.lineConfig   = lineConfig ?? throw new ArgumentNullException(nameof(lineConfig));
 }