Skip to content

Commit

Permalink
Merge pull request #97 from RapidScada/develop
Browse files Browse the repository at this point in the history
Merge Develop to Master
  • Loading branch information
2mik authored Jun 23, 2020
2 parents 2ee893a + 3e6e6d4 commit 9ad920a
Show file tree
Hide file tree
Showing 141 changed files with 2,986 additions and 1,575 deletions.
Binary file modified Base/model/scada_6.0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
108 changes: 61 additions & 47 deletions Base/model/scada_6.0.xml

Large diffs are not rendered by default.

30 changes: 22 additions & 8 deletions ScadaAdmin/ScadaAdmin5/ScadaAdmin/Code/ColumnBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ private DataGridViewColumn NewButtonColumn(string dataPropertyName, ColumnOption
/// <summary>
/// Creates a new column that hosts cells which values are selected from a combo box.
/// </summary>
private DataGridViewColumn NewComboBoxColumn(string dataPropertyName,
string valueMember, string displayMember, object dataSource, bool addEmptyRow = false)
private DataGridViewColumn NewComboBoxColumn(string dataPropertyName, string valueMember,
string displayMember, object dataSource, bool addEmptyRow = false, bool prependID = false)
{
if (ScadaUtils.IsRunningOnMono)
{
Expand All @@ -114,7 +114,7 @@ private DataGridViewColumn NewComboBoxColumn(string dataPropertyName,
else
{
if (dataSource is IBaseTable baseTable)
dataSource = CreateComboBoxSource(baseTable, valueMember, displayMember, addEmptyRow);
dataSource = CreateComboBoxSource(baseTable, valueMember, ref displayMember, addEmptyRow, prependID);

return new DataGridViewComboBoxColumn
{
Expand All @@ -134,19 +134,34 @@ private DataGridViewColumn NewComboBoxColumn(string dataPropertyName,
/// Creates a new column that hosts cells which values are selected from a combo box.
/// </summary>
private DataGridViewColumn NewComboBoxColumn(string dataPropertyName,
string displayMember, IBaseTable dataSource, bool addEmptyRow = false)
string displayMember, IBaseTable dataSource, bool addEmptyRow = false, bool prependID = false)
{
return NewComboBoxColumn(dataPropertyName, dataPropertyName, displayMember, dataSource, addEmptyRow);
return NewComboBoxColumn(dataPropertyName, dataPropertyName,
displayMember, dataSource, addEmptyRow, prependID);
}

/// <summary>
/// Creates a data table for using as a data source of a combo box.
/// </summary>
private DataTable CreateComboBoxSource(
IBaseTable baseTable, string valueMember, string displayMember, bool addEmptyRow)
IBaseTable baseTable, string valueMember, ref string displayMember, bool addEmptyRow, bool prependID)
{
DataTable dataTable = baseTable.ToDataTable(true);

if (prependID)
{
// display ID and name
string columnName = valueMember + "_" + displayMember;
dataTable.Columns.Add(columnName, typeof(string),
string.Format("'[' + {0} + '] ' + {1}", valueMember, displayMember));
displayMember = columnName;
dataTable.DefaultView.Sort = valueMember;
}
else
{
dataTable.DefaultView.Sort = displayMember;
}

if (addEmptyRow)
{
DataRow emptyRow = dataTable.NewRow();
Expand All @@ -155,7 +170,6 @@ private DataTable CreateComboBoxSource(
dataTable.Rows.Add(emptyRow);
}

dataTable.DefaultView.Sort = displayMember;
return dataTable;
}

Expand Down Expand Up @@ -418,7 +432,7 @@ private DataGridViewColumn[] CreateRightTableColumns()
return TranslateHeaders("RightTable", new DataGridViewColumn[]
{
NewTextBoxColumn("RightID", new ColumnOptions(1, ushort.MaxValue)),
NewComboBoxColumn("ItfID", "Descr", configBase.InterfaceTable),
NewComboBoxColumn("ItfID", "Descr", configBase.InterfaceTable, false, true),
NewComboBoxColumn("RoleID", "Name", configBase.RoleTable),
NewCheckBoxColumn("ViewRight"),
NewCheckBoxColumn("CtrlRight")
Expand Down
25 changes: 23 additions & 2 deletions ScadaAdmin/ScadaAdmin5/ScadaAdmin/Code/ExplorerBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019 Mikhail Shiryaev
* Copyright 2020 Mikhail Shiryaev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,7 @@
*
* Author : Mikhail Shiryaev
* Created : 2018
* Modified : 2019
* Modified : 2020
*/

using Scada.Admin.App.Forms.Tables;
Expand Down Expand Up @@ -374,6 +374,27 @@ public void FillInterfaceNode(TreeNode interfaceNode)
FillFileNode(interfaceNode, interfaceObj.InterfaceDir);
}

/// <summary>
/// Fills the instances node without creating child nodes.
/// </summary>
public void FillInstancesNode()
{
try
{
treeView.BeginUpdate();
InstancesNode.Nodes.Clear();

foreach (Instance instance in project.Instances)
{
InstancesNode.Nodes.Add(CreateInstanceNode(instance));
}
}
finally
{
treeView.EndUpdate();
}
}

/// <summary>
/// Fills the instance node, creating child nodes.
/// </summary>
Expand Down
11 changes: 9 additions & 2 deletions ScadaAdmin/ScadaAdmin5/ScadaAdmin/Code/LiveInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/

using Scada.Admin.Project;
using Scada.Agent.Connector;
using Scada.Comm.Shell.Code;
using Scada.Server.Shell.Code;
using System;
Expand All @@ -42,6 +43,7 @@ internal class LiveInstance
public LiveInstance(Instance instance)
{
Instance = instance ?? throw new ArgumentNullException("instance");
AgentClient = null;
ServerEnvironment = null;
CommEnvironment = null;
IsReady = false;
Expand All @@ -52,7 +54,12 @@ public LiveInstance(Instance instance)
/// Gets the system instance.
/// </summary>
public Instance Instance { get; private set; }


/// <summary>
/// Gets or sets the client of the Agent service.
/// </summary>
public IAgentClient AgentClient { get; set; }

/// <summary>
/// Gets or sets the Server environment.
/// </summary>
Expand All @@ -64,7 +71,7 @@ public LiveInstance(Instance instance)
public CommEnvironment CommEnvironment { get; set; }

/// <summary>
/// Gets or sets a value indicating whether this object is not ready to use.
/// Gets or sets a value indicating whether this object is ready to use.
/// </summary>
public bool IsReady { get; set; }
}
Expand Down
23 changes: 16 additions & 7 deletions ScadaAdmin/ScadaAdmin5/ScadaAdmin/Code/RecentSelection.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019 Mikhail Shiryaev
* Copyright 2020 Mikhail Shiryaev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,7 @@
*
* Author : Mikhail Shiryaev
* Created : 2019
* Modified : 2019
* Modified : 2020
*/

namespace Scada.Admin.App.Code
Expand All @@ -36,11 +36,7 @@ public class RecentSelection
/// </summary>
public RecentSelection()
{
InstanceName = "";
CommLineNum = 0;
KPNum = 0;
KPTypeID = 0;
ObjNum = 0;
Reset();
}


Expand Down Expand Up @@ -68,5 +64,18 @@ public RecentSelection()
/// Gets or sets the ID of the recently selected object.
/// </summary>
public int ObjNum { get; set; }


/// <summary>
/// Resets the selected objects.
/// </summary>
public void Reset()
{
InstanceName = "";
CommLineNum = 0;
KPNum = 0;
KPTypeID = 0;
ObjNum = 0;
}
}
}
17 changes: 17 additions & 0 deletions ScadaAdmin/ScadaAdmin5/ScadaAdmin/Config/ScadaAdminConfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<ScadaAdminConfig>
<PathOptions>
<Param name="ServerDir" value="C:\SCADA\ScadaServer\" descr="Server directory" />
<Param name="CommDir" value="C:\SCADA\ScadaComm\" descr="Communicator directory" />
</PathOptions>
<ChannelOptions>
<Param name="CnlMult" value="100" descr="Multiplicity of the first channel of a device" />
<Param name="CnlShift" value="1" descr="Shift of the first channel of a device" />
<Param name="CnlGap" value="10" descr="Gap between channel numbers of different devices" />
<Param name="PrependDeviceName" value="true" descr="To prepend a device name in channel names" />
</ChannelOptions>
<FileAssociations>
<Association ext="sch" path="C:\SCADA\ScadaSchemeEditor\ScadaSchemeEditor.exe" />
<Association ext="tbl" path="C:\SCADA\ScadaTableEditor\ScadaTableEditor.exe" />
</FileAssociations>
</ScadaAdminConfig>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<ScadaAdminConfig>
<PathOptions>
<Param name="ServerDir" value="/opt/scada/ScadaServer/" descr="Server directory" />
<Param name="CommDir" value="/opt/scada/ScadaComm/" descr="Communicator directory" />
</PathOptions>
<ChannelOptions>
<Param name="CnlMult" value="100" descr="Multiplicity of the first channel of a device" />
<Param name="CnlShift" value="1" descr="Shift of the first channel of a device" />
<Param name="CnlGap" value="10" descr="Gap between channel numbers of different devices" />
<Param name="PrependDeviceName" value="true" descr="To prepend a device name in channel names" />
</ChannelOptions>
<FileAssociations>
<Association ext="sch" path="/opt/scada/ScadaSchemeEditor/ScadaSchemeEditor.exe" />
<Association ext="tbl" path="/opt/scada/ScadaTableEditor/ScadaTableEditor.exe" />
</FileAssociations>
</ScadaAdminConfig>
68 changes: 42 additions & 26 deletions ScadaAdmin/ScadaAdmin5/ScadaAdmin/Forms/FrmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public partial class FrmMain : Form
/// <summary>
/// The hyperlink to the documentation in English.
/// </summary>
private const string DocEnUrl = "http://doc.rapidscada.net/content/latest/en/";
private const string DocEnUrl = "https://rapidscada.net/doc/content/latest/en/";
/// <summary>
/// The hyperlink to the documentation in Russian.
/// </summary>
private const string DocRuUrl = "http://doc.rapidscada.net/content/latest/ru/";
private const string DocRuUrl = "https://rapidscada.net/doc/content/latest/ru/";
/// <summary>
/// The hyperlink to the support in English.
/// </summary>
Expand Down Expand Up @@ -692,14 +692,12 @@ private void PrepareInstanceNode(TreeNode instanceNode, LiveInstance liveInstanc
{
if (!liveInstance.IsReady)
{
Instance instance = liveInstance.Instance;

if (instance.LoadAppSettings(out string errMsg))
if (liveInstance.Instance.LoadAppSettings(out string errMsg))
{
LoadDeploymentSettings();
IAgentClient agentClient = CreateAgentClient(instance);
liveInstance.ServerEnvironment = CreateServerEnvironment(instance, agentClient);
liveInstance.CommEnvironment = CreateCommEnvironment(instance, agentClient);
InitAgentClient(liveInstance);
liveInstance.ServerEnvironment = CreateServerEnvironment(liveInstance);
liveInstance.CommEnvironment = CreateCommEnvironment(liveInstance);
explorerBuilder.FillInstanceNode(instanceNode);
liveInstance.IsReady = true;
}
Expand Down Expand Up @@ -732,25 +730,39 @@ private void RefreshInstanceNode(TreeNode instanceNode, LiveInstance liveInstanc
PrepareInstanceNode(instanceNode, liveInstance);
}

/// <summary>
/// Recreates Server and Communicator environments of the instance, if the instance is ready.
/// </summary>
private void RefreshEnvironments(LiveInstance liveInstance)
{
if (liveInstance.IsReady)
{
liveInstance.ServerEnvironment = CreateServerEnvironment(liveInstance);
liveInstance.CommEnvironment = CreateCommEnvironment(liveInstance);
}
}

/// <summary>
/// Creates a new Server environment for the specified instance.
/// </summary>
private ServerEnvironment CreateServerEnvironment(Instance instance, IAgentClient agentClient)
private ServerEnvironment CreateServerEnvironment(LiveInstance liveInstance)
{
return new ServerEnvironment(new ServerDirs(appData.AppSettings.PathOptions.ServerDir, instance), log)
return new ServerEnvironment(
new ServerDirs(appData.AppSettings.PathOptions.ServerDir, liveInstance.Instance), log)
{
AgentClient = agentClient
AgentClient = liveInstance.AgentClient
};
}

/// <summary>
/// Creates a new Communicator environment for the specified instance.
/// </summary>
private CommEnvironment CreateCommEnvironment(Instance instance, IAgentClient agentClient)
private CommEnvironment CreateCommEnvironment(LiveInstance liveInstance)
{
return new CommEnvironment(new CommDirs(appData.AppSettings.PathOptions.CommDir, instance), log)
return new CommEnvironment(
new CommDirs(appData.AppSettings.PathOptions.CommDir, liveInstance.Instance), log)
{
AgentClient = agentClient
AgentClient = liveInstance.AgentClient
};
}

Expand All @@ -771,38 +783,38 @@ private DeploymentProfile GetDeploymentProfile(string profileName)
}

/// <summary>
/// Creates a new Agent client.
/// Initializes an Agent client of the specified instance.
/// </summary>
private IAgentClient CreateAgentClient(Instance instance)
private void InitAgentClient(LiveInstance liveInstance)
{
DeploymentProfile profile = GetDeploymentProfile(instance.DeploymentProfile);
DeploymentProfile profile = GetDeploymentProfile(liveInstance.Instance.DeploymentProfile);

if (profile == null)
{
return null;
liveInstance.AgentClient = null;
}
else
{
ConnectionSettings connSettings = profile.ConnectionSettings.Clone();
connSettings.ScadaInstance = instance.Name;
return new AgentWcfClient(connSettings);
connSettings.ScadaInstance = liveInstance.Instance.Name;
liveInstance.AgentClient = new AgentWcfClient(connSettings);
}
}

/// <summary>
/// Updates the Agent client of the instance.
/// Updates the Agent client of the specified instance.
/// </summary>
private void UpdateAgentClient(LiveInstance liveInstance)
{
if (liveInstance.ServerEnvironment != null || liveInstance.CommEnvironment != null)
{
IAgentClient agentClient = CreateAgentClient(liveInstance.Instance);
InitAgentClient(liveInstance);

if (liveInstance.ServerEnvironment != null)
liveInstance.ServerEnvironment.AgentClient = agentClient;
liveInstance.ServerEnvironment.AgentClient = liveInstance.AgentClient;

if (liveInstance.CommEnvironment != null)
liveInstance.CommEnvironment.AgentClient = agentClient;
liveInstance.CommEnvironment.AgentClient = liveInstance.AgentClient;
}
}

Expand Down Expand Up @@ -897,6 +909,7 @@ private void NewProject()
frmNewProject.ProjectTemplate, out ScadaProject newProject, out string errMsg))
{
appData.AppState.AddRecentProject(newProject.FileName);
appData.AppState.RecentSelection.Reset();
project = newProject;
LoadConfigBase();
Text = string.Format(AppPhrases.ProjectTitle, project.Name);
Expand Down Expand Up @@ -1681,7 +1694,8 @@ private void miProjectRename_Click(object sender, EventArgs e)

Text = string.Format(AppPhrases.ProjectTitle, project.Name);
selectedNode.Text = project.Name;
UpdateChildFormHints(selectedNode);
CloseChildForms(selectedNode);
explorerBuilder.FillInstancesNode();
SaveProjectSettings();
}
}
Expand Down Expand Up @@ -2186,7 +2200,9 @@ private void miInstanceRename_Click(object sender, EventArgs e)
appData.ProcError(errMsg);

selectedNode.Text = instance.Name;
UpdateChildFormHints(selectedNode);
CloseChildForms(selectedNode);
RefreshEnvironments(liveInstance);
RefreshInstanceNode(selectedNode, liveInstance);
SaveProjectSettings();
}
}
Expand Down
Loading

0 comments on commit 9ad920a

Please sign in to comment.