Skip to content

Commit

Permalink
basic Functionalities work, filtering, Acknowledging, displaying.
Browse files Browse the repository at this point in the history
pls try it out, perfomance issues, when too many msgs incoming
  • Loading branch information
GemaTechnik committed Oct 30, 2023
1 parent 12a64ce commit c78f998
Show file tree
Hide file tree
Showing 11 changed files with 267 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/TcOpen.Hammer/PlcHammer.Hmi.Blazor/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void ConfigureServices(IServiceCollection services)
//.Enrich.With(new Serilog.Enrichers.EnvironmentNameEnricher())
//.Enrich.With(new Serilog.Enrichers.EnvironmentUserNameEnricher())
//.Enrich.With(new Serilog.Enrichers.MachineNameEnricher())
.MinimumLevel.Debug())) // Sets the logger configuration (default reports only to console).
.MinimumLevel.Verbose())) // Sets the logger configuration (default reports only to console).
.SetSecurity(SecurityManager.Manager.Service)
.SetEditValueChangeLogging(Entry.PlcHammer.Connector);

Expand Down Expand Up @@ -148,7 +148,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
});

Entry.PlcHammer.Connector.BuildAndStart();
Entry.PlcHammer.TECH_MAIN._app._logger.StartLoggingMessages(TcoCore.eMessageCategory.All);
Entry.PlcHammer.TECH_MAIN._app._logger.StartLoggingMessages(TcoCore.eMessageCategory.Debug);
}

private static void SetUpRepositories(IRepository<PlainStation001_ProductionData> processRecipiesRepository,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<div class="d-flex">
@if (UseNative)
{
<input type="date" class="form-control w-auto d-inline" @bind-value="@Date" disabled="@IsDisabled" />
<TimePickerComponent @bind-SecondOfDay="SecondOfDay" UseNativeTimePicker="@UseNative" IsDisabled="IsDisabled" />
}
else
{
<input type="datetime-local" class="form-control w-auto d-inline" value="@(DateAndTime.ToString("yyyy-MM-ddTHH:mm"))" disabled="@IsDisabled"
@onchange="async (e) =>
{
var dateString = e.Value.ToString();
if(!string.IsNullOrEmpty(dateString))
{
DateAndTime = DateTime.Parse(dateString);
}
else
{
DateAndTime = new DateTime(2022, 01, 01, 12, 0, 0);
}
await NotifyChanged();
}"
/>

}
</div>

@code {

[Parameter]
public DateTime DateAndTime
{
get; set;
}

[Parameter]
public EventCallback<DateTime> DateAndTimeChanged
{
get; set;
}

[Parameter]
public bool IsDisabled
{
get; set;
}

[Parameter]
public bool UseNative
{
get; set;
}

private DateTime Date
{
get
{
return DateAndTime.Date;
}
set
{
DateAndTime = value.AddSeconds(SecondOfDay);
_ = NotifyChanged();
}
}

private int SecondOfDay
{
get
{
return DateAndTime.Hour * 3600 + DateAndTime.Minute * 60;
}
set
{
DateAndTime = DateAndTime.Date.AddSeconds(value);
_ = NotifyChanged();
}
}

private Task NotifyChanged()
{
return DateAndTimeChanged.InvokeAsync(DateAndTime);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
@using Microsoft.AspNetCore.Components;

@if (UseNativeTimePicker)
{
<input type="time" value="@(new DateTime(2000, 1, 1).AddSeconds(SecondOfDay).ToString("HH:mm"))"
class="form-control w-auto d-inline" disabled="@IsDisabled"
@onchange="async (e) =>
{
var time = Convert.ToDateTime(e.Value);
Hour = time.Hour;
Minute = time.Minute;
await NotifyChanged();
}" />
}
else
{
<select @onchange="async (e) =>
{
Hour = Convert.ToInt32(e.Value);
await NotifyChanged();
}" @attributes="InputAttributes" disabled="@IsDisabled">
@foreach (var hour in Enumerable.Range(0, 24))
{
<option value="@hour" selected="@(hour == Hour)">@hour.ToString("00")</option>
}
</select>
<span class="pl-0">:</span>
<select @onchange="async (e) =>
{
Minute = Convert.ToInt32(e.Value);
await NotifyChanged();
}" @attributes="InputAttributes" disabled="@IsDisabled">

@foreach (var minute in Enumerable.Range(0, 60))
{
<option value="@minute" selected="@(minute == Minute)">@(minute.ToString("00"))</option>
}
</select>
}

@code {
[Parameter]
public int SecondOfDay
{
get
{
return Hour * 3600 + Minute * 60;
}

set
{
Hour = value / 3600;
Minute = (value % 3600) / 60;
}
}

[Parameter]
public EventCallback<int> SecondOfDayChanged
{
get; set;
}

[Parameter]
public bool UseNativeTimePicker
{
get; set;
}

[Parameter]
public bool IsDisabled
{
get; set;
}

public int Hour
{
get; set;
}

public int Minute
{
get; set;
}

private Task NotifyChanged()
{
return SecondOfDayChanged.InvokeAsync(SecondOfDay);
}

public Dictionary<string, object> InputAttributes
{
get; set;
} =
new Dictionary<string, object>()
{
{ "class", "form-control w-auto d-inline" }
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,20 @@ private async Task<PlainTcoMessage> ProcessMessageAsync(PlainTcoMessage message)

return null;
}

public static DateTime AdjustForDaylightSavingTime(DateTime date)
{
TimeZoneInfo localZone = TimeZoneInfo.Local;
if (localZone.IsDaylightSavingTime(date))
{
// Summertime
return date.AddHours(2);
}
else
{
// Wintertime
return date.AddHours(1);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ public async Task<UpdateResult> UpdateTimeStampAcknowledgeAsync(ObjectId? id, Up

var count = await collection.CountDocumentsAsync(filter);

foreach (var message in messages) {
message.AdjustForDaylightSavingTime();
}

return (messages, count);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,31 @@ static MongoDbLogItem()
}
}

public void AdjustForDaylightSavingTime()
{
TimeZoneInfo localZone = TimeZoneInfo.Local;

if (localZone.IsDaylightSavingTime(UtcTimeStamp))
{
// Summertime
UtcTimeStamp = UtcTimeStamp.AddHours(2);
if (TimeStampAcknowledged.HasValue)
{
TimeStampAcknowledged = TimeStampAcknowledged.Value.AddHours(2);
}
}
else
{
// Wintertime
UtcTimeStamp = UtcTimeStamp.AddHours(1);
if (TimeStampAcknowledged.HasValue)
{
TimeStampAcknowledged = TimeStampAcknowledged.Value.AddHours(1);
}
}
}



[BsonId]
public ObjectId Id { get; set; }
Expand Down Expand Up @@ -168,6 +193,7 @@ public override PayloadProperties Deserialize(BsonDeserializationContext context
}
}


}


Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
<BSInput InputType="InputType.Range" @bind-Value="DepthValue" min="1" max="@MaxDiagnosticsDepth" />
</BSCol>
</BSRow>
<BSTable IsBordered="true">
<BSTable IsBordered="true" IsStriped="true">
<thead>
<tr>
<th>Timestamp</th>
<th>Acknowledged Timestamp</th>
<th>Icon</th>
<th>Severity Level</th>
<th>Message Content</th>
<th>Level</th>
<th>Message</th>
<th>Message Source</th>
<th>Cycle </th>
<th>Actions</th>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

.icon-container {
font-size: 1.4rem;
font-size: 1.8rem;
display: flex;
height: 100%;
align-items: center;
justify-content: center;
}
Expand All @@ -20,7 +21,7 @@ th:nth-child(3) { /* Message Content column */
}

th:nth-child(4), td:nth-child(4) { /* Message Content column */
width: 8%; /* Adjust as needed */
width: 6%; /* Adjust as needed */
}

.icon-bg-primary {
Expand Down Expand Up @@ -52,3 +53,4 @@ th:nth-child(4), td:nth-child(4) { /* Message Content column */
background-color: rgba(220, 53, 69, 0.9); /* danger color at 70% opacity */
color: #ffffff; /* white text color for contrast */
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
@using BlazorStrap

<BSRow class="d-flex m-3" Justify="Justify.Center" Align="Align.Center">
<BSCol Column="1">Messages: @TotalCount </BSCol>
<BSCol Column="2">
<BSInput InputType="InputType.Select" @bind-Value="@DropDownSelectedCategory" class="w-100">
@foreach (var category in Enum.GetValues(typeof(eMessageCategory)))
Expand All @@ -17,6 +16,21 @@
<BSCol Column="3">
<BSInput InputType="InputType.Text" @bind-Value="@Keyword" @oninput="GetDataFilteredAsyncForArchive" placeholder="Enter keyword to filter..." class="w-100"/>
</BSCol>
<BSCol ColumnSmall="2">
<TcOpen.Inxton.TcoCore.Blazor.TcoDiagnosticsAlternative.Helper.DateTimePicker.DateTimePickerComponent
@bind-DateAndTime="DateLower"
UseNative="UseNative"
IsDisabled="IsDisabled"/>
</BSCol>
<BSCol ColumnSmall="2">
<TcOpen.Inxton.TcoCore.Blazor.TcoDiagnosticsAlternative.Helper.DateTimePicker.DateTimePickerComponent
@bind-DateAndTime="DateUpper"
UseNative="UseNative"
IsDisabled="IsDisabled"/>
</BSCol>
</BSRow>
<BSRow class="d-flex m-3" Justify="Justify.Center" Align="Align.Center">
<BSCol Column="1">Messages: @TotalCount </BSCol>
<BSCol ColumnSmall="1">
<BSLabel>Depth Value: @DepthValue</BSLabel>
</BSCol>
Expand All @@ -25,7 +39,7 @@
</BSCol>
</BSRow>

<BSTable IsBordered="true" IsStriped="true" table-layout >
<BSTable IsBordered="true" IsStriped="true">
<thead>
<tr>
<th>Timestamp</th>
Expand All @@ -34,6 +48,7 @@
<th>Level</th>
<th>Message</th>
<th>Message Source</th>
<th>Cycle</th>
</tr>
</thead>
<tbody>
Expand All @@ -50,6 +65,7 @@
<td>@message.Level</td>
<td>@ExtractMessageFromTemplateText.ExtractMessageWithoutBraces(message.MessageTemplate?.Text)</td>
<td>@message.Properties?.sender?.Payload?.ParentSymbol</td>
<td>@message.Properties?.sender?.Payload?.Cycle</td>
</tr>
}
}
Expand Down
Loading

0 comments on commit c78f998

Please sign in to comment.