Skip to content

Commit

Permalink
feat: v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasper De Keukelaere (imec) authored and Jasper De Keukelaere (imec) committed Jul 25, 2024
1 parent bb0add3 commit 292f975
Show file tree
Hide file tree
Showing 9 changed files with 423 additions and 382 deletions.
16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

This is a major update with a lot of new features and improvements, mainly for the UI.
## [0.1.0] - 2024-07-25

This is a major update with some new features and improvements, mainly for the UI.
The single page approach was getting too cluttered.
The UI now has a navigation panel and dedicate pages for each instance and settings.
The UI now has a navigation panel and dedicate pages for every instance and the settings.


### Changes

- Add controler name to overview table
- IP settings dialog now has tabs for every interface
- BREAKING: snapshots are now stored in the folder `/Manager/Snapshots` instead of `/Snapshots`. If you have created snapshots in the previous version, you can manually create the folder and move them.

### Features

- Logs (e.g. start/stop/ new download) of instances are collected and shown in the UI
- Navigation menu
- Dedicated page for each instance (click on the instance or open the navigation panel on the left to get there)
- Dedicated page for settings
- When multiadapter is selected, you can select specific network interfaces for each adapter in the network settings of the instance now
- some more smaller features

### Fix

- Data view more stable now

## [0.0.6] - 2024-05-08

Expand Down
70 changes: 42 additions & 28 deletions PLCsimAdvanced_Manager/Components/DataTable.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@inject ManagerFacade managerFacade


@if (SelectedInstance.OperatingState!= EOperatingState.Off)
@if (SelectedInstance.OperatingState != EOperatingState.Off)
{
<MudTable ServerData="@(new Func<TableState, Task<TableData<SDataValueByName>>>(ServerReload))"
Dense="true" Hover="true" @ref="table" Loading="false" LoadingProgressColor="Color.Transparent">
Expand Down Expand Up @@ -56,7 +56,7 @@ else
}

@code {

[Parameter] public string InstanceName { get; set; }
[Parameter] public EArea Area { get; set; }
private IInstance SelectedInstance;
Expand All @@ -68,32 +68,37 @@ else
private SDataValueByName[] _DataValueByNames;

private System.Timers.Timer refreshTimer;

protected override async Task OnInitializedAsync()
{
OnSelectInstance(InstanceName);

// Set up the timer to refresh data every 500 milliseconds
SelectedInstance.OnOperatingStateChanged -= onOperatingStateChanged;
SelectedInstance.OnOperatingStateChanged += onOperatingStateChanged;
startDataValueByNames();
}

private void startDataValueByNames()
{
OnSelectInstance(InstanceName);

refreshTimer = new System.Timers.Timer(100);
refreshTimer.Elapsed += async (sender, e) => await RefreshData();
refreshTimer.AutoReset = true;

if (SelectedInstance.OperatingState == EOperatingState.Run)
{
refreshTimer = new System.Timers.Timer(100);
refreshTimer.Elapsed += async (sender, e) => await RefreshData();
refreshTimer.AutoReset = true;
refreshTimer.Start();

}
}

private void OnSelectInstance(string name)
{
SelectedInstance = SimulationRuntimeManager.CreateInterface(name);
SelectedInstance.OnOperatingStateChanged += onOperatingStateChanged;

if (SelectedInstance.OperatingState == EOperatingState.Run)

if (SelectedInstance.OperatingState != EOperatingState.Off)
{
InstanceRegistered = true;
StateHasChanged();
setDataValueByNames();
}
}
Expand All @@ -103,29 +108,36 @@ else
switch (in_operatingstate)
{
case EOperatingState.InvalidOperatingState:
refreshTimer?.Stop();
refreshTimer?.Dispose();
break;
case EOperatingState.Off:
refreshTimer?.Stop();
refreshTimer?.Dispose();
break;
case EOperatingState.Booting:
break;
case EOperatingState.Stop:
refreshTimer.Stop();
startDataValueByNames();
refreshTimer?.Stop();
refreshTimer?.Dispose();
break;
case EOperatingState.Startup:
break;
case EOperatingState.Run:
refreshTimer = new System.Timers.Timer(100);
refreshTimer.Elapsed += async (sender, e) => await RefreshData();
refreshTimer.AutoReset = true;
refreshTimer.Start();
setDataValueByNames();
RefreshData();
startDataValueByNames();
break;
case EOperatingState.Freeze:
refreshTimer?.Stop();
refreshTimer?.Dispose();
break;
case EOperatingState.ShuttingDown:
refreshTimer?.Stop();
refreshTimer?.Dispose();
break;
case EOperatingState.Hold:
refreshTimer?.Stop();
refreshTimer?.Dispose();
break;
default:
throw new ArgumentOutOfRangeException(nameof(in_operatingstate), in_operatingstate, null);
Expand Down Expand Up @@ -164,6 +176,7 @@ else
OnSelectInstance(SelectedInstance.Name);
return Task.FromResult(new TableData<SDataValueByName>());
}

for (int i = 0; i < _DataValueByNamesToGet.Length; i++)
{
try
Expand All @@ -181,9 +194,10 @@ else

pagedData = _DataValueByNamesToGet.Skip(state.Page * state.PageSize).Take(state.PageSize).ToArray();
}

return Task.FromResult(new TableData<SDataValueByName>() { TotalItems = totalItems, Items = pagedData });
}

private async Task RefreshData()
{
if (!InstanceRegistered)
Expand All @@ -192,7 +206,7 @@ else
return;
}

// Assuming _dbDataValueByNames is your source data
// Assuming _dbDataValueByNames is your source data
for (int i = 0; i < _DataValueByNames.Length; i++)
{
try
Expand All @@ -208,7 +222,7 @@ else
}
}

// Update paged data and reload the table
// Update paged data and reload the table
table.ReloadServerData();
}

Expand All @@ -217,7 +231,7 @@ else
searchString = text;
// table.ReloadServerData();
}

private void setDataValueByNames()
{
if (SelectedInstance == null)
Expand All @@ -227,14 +241,14 @@ else
}

SelectedInstance.UpdateTagList();

InvokeAsync(StateHasChanged);

_DataValueByNames = SelectedInstance.TagInfos.Where(e => e.Area == Area && e.PrimitiveDataType != EPrimitiveDataType.Struct)
.Select(e => new SDataValueByName { Name = e.Name, DataValue = new SDataValue { Type = e.PrimitiveDataType } })
.ToArray();
}

public object parseData(SDataValue dataValue)
{
switch (dataValue.Type)
Expand Down Expand Up @@ -274,7 +288,7 @@ else
}
}


public void ChangeData(SDataValueByName dataValueByName)
{
var parameters = new DialogParameters<ChangeDataDialog>();
Expand All @@ -288,8 +302,8 @@ else

public void Dispose()
{
SelectedInstance.Dispose();
refreshTimer.Dispose();
SelectedInstance?.Dispose();
refreshTimer?.Dispose();
Snackbar?.Dispose();
}

Expand Down
2 changes: 1 addition & 1 deletion PLCsimAdvanced_Manager/Components/DeleteDialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

void Submit()
{
string pathToDirectory = Instance.StoragePath;
string pathToDirectory = Instance?.StoragePath;
unregisterInstance(fullDeleteCheckbox);

MudDialog.Close(DialogResult.Ok(true));
Expand Down
32 changes: 0 additions & 32 deletions PLCsimAdvanced_Manager/Components/NetworkSettings.razor
Original file line number Diff line number Diff line change
Expand Up @@ -91,38 +91,6 @@
</MudTable>
</MudCardContent>
</MudCard>
<MudCard Style="overflow-wrap:break-word;">
<MudCardHeader>
<CardHeaderContent>
<MudText Typo="Typo.h6">Port</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardContent>
<MudText>@SimulationRuntimeManager.Port </MudText>
</MudCardContent>
</MudCard>
<MudCard Style="overflow-wrap:break-word;">
<MudCardHeader>
<CardHeaderContent>
<MudText Typo="Typo.h6">Remote Connection Info</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardContent>
<MudText>
@if (SimulationRuntimeManager.RemoteConnectionInfo.Length == 0)
{
<div>No Remote Connections</div>
}
else
{
foreach (var v in SimulationRuntimeManager.RemoteConnectionInfo)
{
<div>@v.IP:@v.Port</div>
}
}
</MudText>
</MudCardContent>
</MudCard>
</DialogContent>
</MudDialog>

Expand Down
7 changes: 4 additions & 3 deletions PLCsimAdvanced_Manager/Components/SnapshotsDialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@

[Parameter] public IInstance selectedInstance { get; set; }
static string SnapshotFolder = "Snapshots";
static string PlcManagerFolder = "Manager";
static string label;
private bool setNameDialog;
private string directoryToRename;
Expand All @@ -82,7 +83,7 @@
protected override void OnInitialized()
{
base.OnInitialized();
var path = Path.Combine(selectedInstance.StoragePath, SnapshotFolder);
var path = Path.Combine(selectedInstance.StoragePath, PlcManagerFolder, SnapshotFolder);
// Check if the directory exists, if not, create it
if (!Directory.Exists(path))
{
Expand All @@ -105,7 +106,7 @@

private string[] GetSnapshots()
{
var path = Path.Combine(selectedInstance.StoragePath, SnapshotFolder);
var path = Path.Combine(selectedInstance.StoragePath, PlcManagerFolder, SnapshotFolder);
label = Path.Combine(path, "test");
if (!Directory.Exists(path))
{
Expand All @@ -128,7 +129,7 @@
{
try
{
var path = Path.Combine(selectedInstance.StoragePath, SnapshotFolder);
var path = Path.Combine(selectedInstance.StoragePath, PlcManagerFolder, SnapshotFolder);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
Expand Down
2 changes: 1 addition & 1 deletion PLCsimAdvanced_Manager/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
_open = !_open;
}

string version = "0.0.6";
string version = "0.1.0";
bool newVersionAvailable = false;

// protected override async Task OnInitializedAsync()
Expand Down
Loading

0 comments on commit 292f975

Please sign in to comment.