Skip to content

Commit

Permalink
Merge pull request #51 from RapidScada/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
2mik authored May 15, 2023
2 parents 9c64af6 + d1518dc commit 15c22ac
Show file tree
Hide file tree
Showing 82 changed files with 518 additions and 279 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public static bool GetModuleView(IAdminContext adminContext, ServerApp serverApp
{
moduleView.ConfigDataset = adminContext.CurrentProject.ConfigDatabase;
moduleView.AppDirs = adminContext.AppDirs.CreateDirsForView(serverApp.ConfigDir);
moduleView.AgentClient = adminContext.MainForm.GetAgentClient(false);
moduleView.AppConfig = serverApp.AppConfig;
moduleView.LoadDictionaries();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Product>Rapid SCADA</Product>
<Copyright>Copyright © 2023</Copyright>
<Version>6.0.1</Version>
<AssemblyVersion>6.0.1.0</AssemblyVersion>
<AssemblyVersion>6.0.1.1</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
using Scada.Forms;
using Scada.Lang;
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

Expand All @@ -43,10 +42,6 @@ namespace Scada.Admin.App.Forms.Deployment
/// </summary>
public partial class FrmInstanceStatus : Form, IDeploymentForm
{
/// <summary>
/// The time period for disabling the button after pressing, ms.
/// </summary>
private const int ButtonWait = 1000;
/// <summary>
/// The services which status is displayed.
/// </summary>
Expand Down Expand Up @@ -86,6 +81,11 @@ public FrmInstanceStatus(AppData appData, ScadaProject project, ProjectInstance
}


/// <summary>
/// Gets a value indicating whether the form is available to a user.
/// </summary>
private bool FormAvailable => Visible && !IsDisposed;

/// <summary>
/// Gets a value indicating whether the selected profile changed.
/// </summary>
Expand Down Expand Up @@ -184,43 +184,34 @@ await Task.Run(() =>
});
}

/// <summary>
/// Displays the button in waiting state.
/// </summary>
private static void DisplayWait(Button button)
{
Task.Run(() =>
{
button.Enabled = false;
Thread.Sleep(ButtonWait);
button.Enabled = true;
});
}

/// <summary>
/// Sends the command to the service.
/// </summary>
private static void ControlService(IAgentClient client, ServiceApp serviceApp, ServiceCommand command)
private async Task ControlServiceAsync(IAgentClient client, ServiceApp serviceApp, ServiceCommand command)
{
if (client == null)
return;

try
await Task.Run(() =>
{
bool result;
try
{
bool result;

lock (client)
lock (client)
{
result = client.ControlService(serviceApp, command, 0);
}

if (!result && FormAvailable)
ScadaUiUtils.ShowError(AppPhrases.UnableControlService);
}
catch (Exception ex)
{
result = client.ControlService(serviceApp, command, 0);
if (FormAvailable)
ScadaUiUtils.ShowError(ex.BuildErrorMessage(AppPhrases.ControlServiceError));
}

if (!result)
ScadaUiUtils.ShowError(AppPhrases.UnableControlService);
}
catch (Exception ex)
{
ScadaUiUtils.ShowError(ex.BuildErrorMessage(AppPhrases.ControlServiceError));
}
});
}


Expand Down Expand Up @@ -276,7 +267,7 @@ private void btnDisconnect_Click(object sender, EventArgs e)
Disconnect();
}

private void btnControlService_Click(object sender, EventArgs e)
private async void btnControlService_Click(object sender, EventArgs e)
{
Button button = (Button)sender;
string buttonName = button.Name;
Expand All @@ -302,8 +293,8 @@ private void btnControlService_Click(object sender, EventArgs e)
// send command to application
if (serviceApp != null && serviceCommand != null)
{
DisplayWait(button);
ControlService(agentClient, serviceApp.Value, serviceCommand.Value);
button.DisplayWait();
await ControlServiceAsync(agentClient, serviceApp.Value, serviceCommand.Value);
}
}

Expand Down
3 changes: 2 additions & 1 deletion ScadaAdmin/ScadaAdmin/ScadaAdmin/Forms/Tables/FrmCnl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ private bool ApplyChanges()
if (!(int.TryParse(txtCnlNum.Text, out int cnlNum) &&
ConfigDatabase.MinID <= cnlNum && cnlNum <= ConfigDatabase.MaxID))
{
sbError.AppendError(lblCnlNum, CommonPhrases.IntegerInRangeRequired, ConfigDatabase.MinID, ConfigDatabase.MaxID);
sbError.AppendError(lblCnlNum, CommonPhrases.IntegerInRangeRequired,
ConfigDatabase.MinID, ConfigDatabase.MaxID);
}

int dataLen = -1;
Expand Down
2 changes: 1 addition & 1 deletion ScadaAdmin/ScadaAdmin/ScadaAdmin/ScadaAdmin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Copyright>Copyright © 2023</Copyright>
<ApplicationIcon>lamp.ico</ApplicationIcon>
<Version>6.1.0</Version>
<AssemblyVersion>6.1.0.1</AssemblyVersion>
<AssemblyVersion>6.1.0.2</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Configuration" Version="1.4.371.41" />
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Server" Version="1.4.371.41" />
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Configuration" Version="1.4.371.86" />
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Server" Version="1.4.371.86" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Product>Rapid SCADA</Product>
<Copyright>Copyright © 2023</Copyright>
<Version>6.0.0</Version>
<AssemblyVersion>6.0.0.2</AssemblyVersion>
<AssemblyVersion>6.0.0.3</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Rapid Software LLC. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Globalization;

namespace Scada.Comm.Drivers.DrvModbus.Protocol
{
/// <summary>
Expand Down Expand Up @@ -183,7 +185,7 @@ public static string GetAddressRange(int address, int count, bool zeroAddr, bool
}

/// <summary>
/// Parses a byte order array from the string notation like '01234567'.
/// Parses a byte order array from the string notation like '0123456789ABCDEF'.
/// </summary>
public static int[] ParseByteOrder(string byteOrderStr)
{
Expand All @@ -198,7 +200,8 @@ public static int[] ParseByteOrder(string byteOrderStr)

for (int i = 0; i < len; i++)
{
byteOrder[i] = int.TryParse(byteOrderStr[i].ToString(), out int n) ? n : 0;
byteOrder[i] = int.TryParse(byteOrderStr[i].ToString(),
NumberStyles.HexNumber, CultureInfo.InvariantCulture, out int n) ? n : 0;
}

return byteOrder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Product>Rapid SCADA</Product>
<Copyright>Copyright © 2023</Copyright>
<Version>6.0.0</Version>
<AssemblyVersion>6.0.0.2</AssemblyVersion>
<AssemblyVersion>6.0.0.3</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion ScadaComm/OpenDrivers/DrvModbus.View/DrvModbus.View.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Product>Rapid SCADA</Product>
<Copyright>Copyright © 2023</Copyright>
<Version>6.0.0</Version>
<AssemblyVersion>6.0.0.2</AssemblyVersion>
<AssemblyVersion>6.0.0.3</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Product>Rapid SCADA</Product>
<Copyright>Copyright © 2023</Copyright>
<Version>6.0.0</Version>
<AssemblyVersion>6.0.0.1</AssemblyVersion>
<AssemblyVersion>6.0.0.2</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,7 @@ private void ExecuteJavaScript(ReceivedMessage message, SubscriptionTag subscrip
{
int tagIndex = subscriptionTag.TagIndex + i;
double tagValue = subscriptionTag.JsValues[i];

if (double.IsNaN(tagValue))
DeviceData.Invalidate(tagIndex);
else
DeviceData.Set(tagIndex, tagValue);

DeviceData.Set(tagIndex, tagValue);
updateTimestamps[tagIndex] = LastSessionTime;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Product>Rapid SCADA</Product>
<Copyright>Copyright © 2023</Copyright>
<Version>6.0.0</Version>
<AssemblyVersion>6.0.0.1</AssemblyVersion>
<AssemblyVersion>6.0.0.2</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Product>Rapid SCADA</Product>
<Copyright>Copyright © 2023</Copyright>
<Version>6.0.0</Version>
<AssemblyVersion>6.0.0.1</AssemblyVersion>
<AssemblyVersion>6.0.0.2</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions ScadaComm/OpenDrivers/DrvOpcUa.Common/DrvOpcUa.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Configuration" Version="1.4.371.41" />
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Client" Version="1.4.371.41" />
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Configuration" Version="1.4.371.86" />
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Client" Version="1.4.371.86" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion ScadaComm/ScadaComm/ScadaCommApp/ScadaCommApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Product>Rapid SCADA</Product>
<Copyright>Copyright © 2023</Copyright>
<Version>6.1.0</Version>
<AssemblyVersion>6.1.0.0</AssemblyVersion>
<AssemblyVersion>6.1.0.1</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion ScadaComm/ScadaComm/ScadaCommEngine/CoreLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ public void StopProcessing()
terminated = true;
serviceStatus = ServiceStatus.Terminating;

if (thread.Join(AppConfig.GeneralOptions.StopWait))
if (thread.Join(TimeSpan.FromSeconds(AppConfig.GeneralOptions.StopWait)))
Log.WriteAction(CommonPhrases.LogicStopped);
else
Log.WriteAction(CommonPhrases.UnableToStopLogic);
Expand Down
2 changes: 1 addition & 1 deletion ScadaComm/ScadaComm/ScadaCommEngine/ScadaCommEngine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Product>Rapid SCADA</Product>
<Copyright>Copyright © 2023</Copyright>
<Version>6.1.0</Version>
<AssemblyVersion>6.1.0.0</AssemblyVersion>
<AssemblyVersion>6.1.0.1</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion ScadaComm/ScadaComm/ScadaCommWkr/ScadaCommWkr.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Product>Rapid SCADA</Product>
<Copyright>Copyright © 2023</Copyright>
<Version>6.1.0</Version>
<AssemblyVersion>6.1.0.0</AssemblyVersion>
<AssemblyVersion>6.1.0.1</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
8 changes: 8 additions & 0 deletions ScadaCommon/ScadaCommon.Forms/ListViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ public static ListViewItem GetSelectedItem(this ListView listView)
return listView.SelectedItems.Count > 0 ? listView.SelectedItems[0] : null;
}

/// <summary>
/// Gets an object associated with the first selected list item.
/// </summary>
public static object GetSelectedObject(this ListView listView)
{
return listView.GetSelectedItem()?.Tag;
}

/// <summary>
/// Moves up the selected list item.
/// </summary>
Expand Down
27 changes: 22 additions & 5 deletions ScadaCommon/ScadaCommon.Forms/ScadaUiUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Scada.Forms
Expand All @@ -27,7 +29,11 @@ public static class ScadaUiUtils
/// The maximum column width in DataGridView in pixels.
/// </summary>
private const int MaxColumnWidth = 500;

/// <summary>
/// The time period for disabling the button after pressing, ms.
/// </summary>
private const int ButtonWait = 1000;

/// <summary>
/// The log refresh interval for local access, ms.
/// </summary>
Expand Down Expand Up @@ -115,17 +121,15 @@ public static void SetValue(this NumericUpDown numericUpDown, decimal val)
/// </summary>
public static void SetTime(this DateTimePicker dateTimePicker, DateTime time)
{
DateTime date = dateTimePicker.MinDate;
dateTimePicker.Value = new DateTime(date.Year, date.Month, date.Day, time.Hour, time.Minute, time.Second);
dateTimePicker.Value = dateTimePicker.MinDate + time.TimeOfDay;
}

/// <summary>
/// Sets the time of the DateTimePicker control.
/// </summary>
public static void SetTime(this DateTimePicker dateTimePicker, TimeSpan timeSpan)
{
DateTime date = dateTimePicker.MinDate;
dateTimePicker.Value = new DateTime(date.Year, date.Month, date.Day).Add(timeSpan);
dateTimePicker.Value = dateTimePicker.MinDate + timeSpan;
}

/// <summary>
Expand Down Expand Up @@ -174,6 +178,19 @@ public static void DrawTabItem(this ListBox listBox, DrawItemEventArgs e)
e.DrawFocusRectangle();
}

/// <summary>
/// Displays the button in waiting state.
/// </summary>
public static void DisplayWait(this Button button)
{
Task.Run(() =>
{
button.Enabled = false;
Thread.Sleep(ButtonWait);
button.Enabled = true;
});
}

/// <summary>
/// Tests whether the specified area is visible on any of the available screens.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion ScadaCommon/ScadaCommon.Log/ScadaCommon.Log.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>Scada.Log</RootNamespace>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Version>6.1.0</Version>
<Version>6.0.0</Version>
<Product>Rapid SCADA</Product>
<Company>Rapid Software LLC</Company>
<Authors>Mikhail Shiryaev</Authors>
Expand Down
2 changes: 1 addition & 1 deletion ScadaCommon/ScadaCommon.MultiDb/ScadaCommon.MultiDb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<ItemGroup>
<PackageReference Include="MySql.Data" Version="8.0.31" />
<PackageReference Include="Npgsql" Version="6.0.6" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.80" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.90" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
</ItemGroup>

Expand Down
Loading

0 comments on commit 15c22ac

Please sign in to comment.