Skip to content

Commit

Permalink
Version 4.0.2403.2201
Browse files Browse the repository at this point in the history
  • Loading branch information
gurux01 committed Mar 22, 2024
1 parent e47d955 commit c3e4c15
Show file tree
Hide file tree
Showing 30 changed files with 998 additions and 493 deletions.
6 changes: 3 additions & 3 deletions Gurux.DLMS.AMI.Agent/Gurux.DLMS.AMI.Agent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Gurux.DLMS.AMI.Agent.Shared" Version="4.0.2403.601" />
<PackageReference Include="Gurux.DLMS.AMI.Agent.Worker" Version="4.0.2403.801" />
<PackageReference Include="Gurux.DLMS.AMI.Shared" Version="4.0.2403.601" />
<PackageReference Include="Gurux.DLMS.AMI.Agent.Shared" Version="4.0.2403.1901" />
<PackageReference Include="Gurux.DLMS.AMI.Agent.Worker" Version="4.0.2403.2201" />
<PackageReference Include="Gurux.DLMS.AMI.Shared" Version="4.0.2403.1901" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
// Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt
//---------------------------------------------------------------------------
-->

@using Gurux.DLMS.AMI.Module;
@using Gurux.DLMS.AMI.Module.Enums;
@using Gurux.DLMS.AMI.Shared.DTOs;
Expand All @@ -45,7 +44,7 @@
Description="Importing devices">
</ProgressBar>
<fieldset style="width:100%; height:100%"
disabled="@(_progressBar != null && _progressBar.Current != 0)">
disabled="@_importing">
<MenuControl RightCorner="true">
<ChildContent>
<MenuItem Text="@Properties.Resources.Import" Icon="oi oi-flash" OnClick="@(async () => await Import())" />
Expand Down Expand Up @@ -73,11 +72,15 @@
</select>
</div>
<div class="form-group">
<Switch Text="Meter establishes the connection." Value="@AutoConnect"
OnChange="AutoConnectionUpdated" />
<Switch id="" Text="Serial number." @bind-Value="@SerialNumber"
OnChange="UpdateHelp" />
</div>
<div class="form-group">
<Switch Text="Meter establishes the connection." @bind-Value="@AutoConnect"
OnChange="UpdateHelp" />
</div>
<div class="form-group">
<Switch Text="Update existing devices." Value="@UpdateExistingDevices" />
<Switch Text="Update existing devices." @bind-Value="@UpdateExistingDevices" />
</div>
<div class="form-group">
<label>Batch name</label>
Expand All @@ -97,6 +100,8 @@
</fieldset>

@code {
private bool _importing;

[Parameter]
public DeviceImportSettings Settings
{
Expand Down Expand Up @@ -184,11 +189,11 @@
public ProgressBar? _progressBar;

/// <summary>
/// Help is updated when auto connection is changed.
/// Update help text.
/// </summary>
private void AutoConnectionUpdated(bool value)
private void UpdateHelp(bool value)
{
AutoConnect = value;
_dirty = true;
StateHasChanged();
}

Expand All @@ -213,21 +218,25 @@
get
{
string help = "#Import format is" + Environment.NewLine +
"#Device Name;";
"#Device Name";
if (!AutoConnect)
{
help += ";IP Address;IP Port;";
help += ";IP Address:IP Port";
}
if (SerialNumber)
{
help += ";Serial Number";
}
//If security is used.
if (_security != 0)
{
if (_preEstablished)
{
help += "Server system title;";
help += ";Server system title";
}
else
{
help += "Client system title;Authentication key;Block Cipher key.";
help += ";Client system title;Authentication key;Block Cipher key";
}
}
return help;
Expand All @@ -242,6 +251,11 @@
StateHasChanged();
}

/// <summary>
/// Serial number is added.
/// </summary>
private bool SerialNumber { get; set; }

/// <summary>
/// In default devices are appended to the database.
/// </summary>
Expand All @@ -257,6 +271,7 @@
/// </summary>
public async Task Import()
{
_importing = true;
Notifier.ClearStatus();
Notifier.ProgressStart();
//Hide progress bar.
Expand All @@ -280,6 +295,28 @@
List<GXDevice> devices = new List<GXDevice>();
Gurux.Net.GXNet net = new Net.GXNet();
_progressBar?.Reset(0, 2 * lines.Length);
int expectedColumnCount = 3;
if (AutoConnect)
{
expectedColumnCount -= 2;
}
if (SerialNumber)
{
++expectedColumnCount;
}
GXDLMSSettings? settings = null;
if (SerialNumber || _security != 0)
{
if (!string.IsNullOrEmpty(_defaultDeviceTemplate.Settings))
{
settings = JsonSerializer.Deserialize<GXDLMSSettings>(_defaultDeviceTemplate.Settings);
}
else
{
settings = new GXDLMSSettings();
}
}

foreach (var it in lines)
{
_progressBar?.Step();
Expand All @@ -301,12 +338,9 @@
throw new Exception(string.Format("Invalid device import format.{0}", it));
}
}
else
else if (line.Length != expectedColumnCount)
{
if (line.Length != 3)
{
throw new Exception(string.Format("Invalid device import format.{0}", it));
}
throw new Exception(string.Format("Invalid device import format. There should be {0} columns, but {1} exists.\r\n{2}", expectedColumnCount, line.Length, it));
}
int pos = 1;
if (!AutoConnect)
Expand All @@ -316,45 +350,75 @@
net.Port = int.Parse(line[pos]);
++pos;
}
long sn = 0;
if (SerialNumber)
{
sn = long.Parse(line[pos]);
if (sn < 1)
{
throw new Exception("Invalid serial number.");
}
}
GXDevice device = new GXDevice()
{
Template = _defaultDeviceTemplate,
Settings = _defaultDeviceTemplate.Settings,
WaitTime = _defaultDeviceTemplate.WaitTime,
ResendCount = _defaultDeviceTemplate.ResendCount,
Name = line[0],
MediaType = "Gurux.Net.GXNet",
MediaSettings = net.Settings
MediaSettings = net.Settings,
};
GXDLMSSettings? settings = null;
if (_security != 0)
if (settings != null && sn != 0)
{
//If security is used.
settings = new GXDLMSSettings();
if (_preEstablished)
//If serial number is used.
if (sn != 0)
{
if (GXDLMSTranslator.HexToBytes(line[pos]).Length != 8)
{
throw new ArgumentException(string.Format("Invalid server system title {0}.", line[pos]));
}
settings.DeviceSystemTitle = line[pos];
}
++pos;
if (GXDLMSTranslator.HexToBytes(line[pos]).Length != 8)
{
throw new ArgumentException(string.Format("Invalid client system title {0}.", line[pos]));
settings.PhysicalAddress = sn;
}
settings.ClientSystemTitle = line[pos];
++pos;
int keySize = _securitySuite == 2 ? 32 : 16;
if (GXDLMSTranslator.HexToBytes(line[pos]).Length != keySize)
}
if (settings != null)
{
if (_security == 0)
{
throw new ArgumentException(string.Format("Invalid authentication key {0}.", line[pos]));
settings.DeviceSystemTitle = null;
settings.ClientSystemTitle = null;
settings.AuthenticationKey = null;
settings.BlockCipherKey = null;
settings.DedicatedKey = null;
}
settings.AuthenticationKey = line[pos];
++pos;
if (GXDLMSTranslator.HexToBytes(line[pos]).Length != keySize)
else
{
throw new ArgumentException(string.Format("Invalid block cipher key {0}.", line[pos]));
//If security is used.
if (_preEstablished)
{
if (GXDLMSTranslator.HexToBytes(line[pos]).Length != 8)
{
throw new ArgumentException(string.Format("Invalid server system title {0}.", line[pos]));
}
settings.DeviceSystemTitle = line[pos];
}
++pos;
if (GXDLMSTranslator.HexToBytes(line[pos]).Length != 8)
{
throw new ArgumentException(string.Format("Invalid client system title {0}.", line[pos]));
}
settings.ClientSystemTitle = line[pos];
++pos;
int keySize = _securitySuite == 2 ? 32 : 16;
if (GXDLMSTranslator.HexToBytes(line[pos]).Length != keySize)
{
throw new ArgumentException(string.Format("Invalid authentication key {0}.", line[pos]));
}
settings.AuthenticationKey = line[pos];
++pos;
if (GXDLMSTranslator.HexToBytes(line[pos]).Length != keySize)
{
throw new ArgumentException(string.Format("Invalid block cipher key {0}.", line[pos]));
}
settings.BlockCipherKey = line[pos];
}
settings.BlockCipherKey = line[pos];
}
if (settings != null)
{
Expand Down Expand Up @@ -390,21 +454,20 @@
Groups = batch == null ? null : new GXDeviceGroup[] { batch }
});
index += BatchSize;
_progressBar?.Step(BatchSize, string.Format("Importing devices {0}/{1}", index, _progressBar.Maximum));
_progressBar?.Step(BatchSize, string.Format("Importing devices {0}/{1}", index, _progressBar.Maximum / 2));
}
//Hide progress bar automatically
// only when import succeeded.
//Hide progress bar automatically only when import succeeded.
_progressBar?.Reset(0, 0);
Notifier?.ShowInformation(string.Format("{0}Meters imported.", devices.Count));
//Enable UI again.
//StateHasChanged();
Notifier?.ShowInformation(string.Format("{0} Meters imported.", devices.Count));
}
catch (Exception ex)
{
Notifier?.ProcessError(ex);
}
finally
{
_importing = false;
StateHasChanged();
Notifier.ProgressEnd();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Gurux.DLMS" Version="9.0.2402.2201" />
<PackageReference Include="Gurux.DLMS.AMI.Components" Version="4.0.2403.801" />
<PackageReference Include="Gurux.DLMS" Version="9.0.2403.1902" />
<PackageReference Include="Gurux.DLMS.AMI.Components" Version="4.0.2403.1801" />
<PackageReference Include="Gurux.DLMS.AMI.Module" Version="4.0.2403.801" />
<PackageReference Include="Gurux.DLMS.AMI.Script" Version="4.0.2403.601" />
<PackageReference Include="Gurux.DLMS.AMI.Shared" Version="4.0.2403.601" />
<PackageReference Include="Gurux.DLMS.AMI.Script" Version="4.0.2403.1901" />
<PackageReference Include="Gurux.DLMS.AMI.Shared" Version="4.0.2403.1901" />
<PackageReference Include="Gurux.Net" Version="8.4.2302.904" />
<PackageReference Include="Gurux.Serial" Version="8.4.2401.401" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.3" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="8.0.3" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.3" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
</ItemGroup>

Expand Down
4 changes: 4 additions & 0 deletions Gurux.DLMS.AMI/Gurux.DLMS.AMI/Client/Helpers/ClientHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,10 @@ public static CrudAction GetAction(string? value)
{
ret = CrudAction.Delete;
}
else if (string.Compare(value, "Clone", true) == 0)
{
ret = CrudAction.Clone;
}
else
{
throw new ArgumentException(Properties.Resources.InvalidTarget);
Expand Down
13 changes: 13 additions & 0 deletions Gurux.DLMS.AMI/Gurux.DLMS.AMI/Client/Helpers/Tab/TabPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@
[Parameter]
public int PadgeCount { get; set; }

///<summary>
///The number of padge stamps as a string.
///</summary>
public string PadgeCountToString()
{
if (PadgeCount > 99)
{
return "99+";
}
return PadgeCount.ToString();
}


/// <summary>
/// Notified when number of padge stamps is updated.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
@if (context.PadgeCount != 0)
{
<span class="@context.GetPadgeClass()">
@context.PadgeCount
@context.PadgeCountToString()
<span class="visually-hidden">@context.Padge</span>
</span>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
// Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt
//---------------------------------------------------------------------------
-->

@page "/Agent"
@page "/AgentGroup"
@page "/AgentLog/{Id:guid?}"
Expand Down Expand Up @@ -83,7 +82,7 @@ else
@if (context.PadgeCount != 0)
{
<span class="@context.GetPadgeClass()">
@context.PadgeCount
@context.PadgeCountToString()
<span class="visually-hidden">@context.Padge</span>
</span>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@

@if (Active != null)
{
<div class="form-group">
<InputNullableSwitch Text="@Properties.Resources.Active" @bind-Value="Active.Active" />
</div>
@if (Parent?.Templates != null && Parent.Templates.Any())
{
@if (Notifier.Action != CrudAction.Create)
Expand Down

0 comments on commit c3e4c15

Please sign in to comment.