Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Messenger should display also the help text #539

Merged
merged 8 commits into from
Jan 27, 2025
Merged
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using AXOpen.Messaging.Static;
using AXSharp.Connector;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
Expand Down Expand Up @@ -79,8 +81,10 @@ private void InitializeMessenger()
new KeyValuePair<ulong, AxoMessengerTextItem>(702, new AxoMessengerTextItem("Input variable `hwIdDO_64_bytes` has invalid value in `Run` method!", "Check the call of the `Run` method, if the `hwIdDO_64_bytes` parameter is assigned.")),

new KeyValuePair<ulong, AxoMessengerTextItem>(703, new AxoMessengerTextItem("Error reading the hwIdDI_64_bytes in the UpdateInputs method!", "Check the value of the hwIdDI_64_bytes and reacheability of the device!")),

new KeyValuePair<ulong, AxoMessengerTextItem>(704, new AxoMessengerTextItem("Error writing the hwIdDO_64_bytes in the UpdateOutputs method!", "Check the value of the hwIdDO_64_bytes and reacheability of the device!")),
new KeyValuePair<ulong, AxoMessengerTextItem>(705, new AxoMessengerTextItem("Emergency stop activated!", "Check the status of the `Inputs.EmgStop` signal. Required value is 'FALSE'")),
new KeyValuePair<ulong, AxoMessengerTextItem>(706, new AxoMessengerTextItem("Safety circuit interupted!", "Check the status of the `Inputs.SafetyOk` signal.Required value is 'TRUE'")),
new KeyValuePair<ulong, AxoMessengerTextItem>(705, new AxoMessengerTextItem("Program error active!", "Check the status of the `Inputs.ProgExecError` signal. Required value is 'FALSE'")),

new KeyValuePair<ulong, AxoMessengerTextItem>(800, new AxoMessengerTextItem("Start at main finished with error!", "Check the details.")),
new KeyValuePair<ulong, AxoMessengerTextItem>(801, new AxoMessengerTextItem("Start at main was aborted, while not yet completed!", "Check the details.")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ private void InitializeMessenger()

new KeyValuePair<ulong, AxoMessengerTextItem>(704, new AxoMessengerTextItem("Error writing the hwIdDO_64_bytes in the UpdateOutputs method!", "Check the value of the hwIdDO_64_bytes and reacheability of the device!")),

new KeyValuePair<ulong, AxoMessengerTextItem>(705, new AxoMessengerTextItem("Emergency stop activated!", "Check the status of the `Inputs.EmgStop` signal. Required value is 'FALSE'")),
new KeyValuePair<ulong, AxoMessengerTextItem>(706, new AxoMessengerTextItem("Safety circuit interupted!", "Check the status of the `Inputs.SafetyOk` signal.Required value is 'TRUE'")),
new KeyValuePair<ulong, AxoMessengerTextItem>(705, new AxoMessengerTextItem("Program error active!", "Check the status of the `Inputs.ProgExecError` signal. Required value is 'FALSE'")),

new KeyValuePair<ulong, AxoMessengerTextItem>(800, new AxoMessengerTextItem("Start at main finished with error!", "Check the details.")),
new KeyValuePair<ulong, AxoMessengerTextItem>(801, new AxoMessengerTextItem("Start at main was aborted, while not yet completed!", "Check the details.")),
new KeyValuePair<ulong, AxoMessengerTextItem>(810, new AxoMessengerTextItem("Start motors and program finished with error!", "Check the details.")),
Expand Down
11 changes: 11 additions & 0 deletions src/core/app/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,14 @@ scripts:
START=$(date +%s)
..\\..\\scripts\\all.sh $DEFAULT_NAMESPACE $PLC_NAME $AXTARGET $AXTARGETPLATFORMINPUT $AX_USERNAME $AX_TARGET_PWD $USE_PLC_SIM_ADVANCED
echo $(date +%D)"-"$(date +%H)":"$(date +%M)":"$(date +%S) " - Finished in :" $(expr $(date +%s) - $START) "s"

mm1: |
apax mon -t 10.10.10.120 -f messages1.mon -C .\\certs\\plc_line\\plc_line.cer -c
mm2: |
apax mon -t 10.10.10.120 -f messages2.mon -C .\\certs\\plc_line\\plc_line.cer -c
mm3: |
apax mon -t 10.10.10.120 -f messages3.mon -C .\\certs\\plc_line\\plc_line.cer -c
mm: |
apax mon -t 10.10.10.120 -f messages.mon -C .\\certs\\plc_line\\plc_line.cer -c


Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger5condition_7" Presentation="Command-Control" />
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger5condition_8" Presentation="Command-Control" />
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger5condition_9" Presentation="Command-Control" />
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger5condition_10" Presentation="Command-Control" />
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger5callcondition" Presentation="Command-Control" />
<AXOpen.Messaging.Static.AxoMessengerDetailedCommandView Component="@Entry.Plc.AxoMessengers._messenger5" />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private void InitializeMessenger5()
new KeyValuePair<ulong, AxoMessengerTextItem>(7, new AxoMessengerTextItem("Messenger 5: message text 7", "Messenger 5: help text 7")),
new KeyValuePair<ulong, AxoMessengerTextItem>(8, new AxoMessengerTextItem("Messenger 5: message text 8", "Messenger 5: help text 8")),
new KeyValuePair<ulong, AxoMessengerTextItem>(9, new AxoMessengerTextItem("Messenger 5: message text 9", "Messenger 5: help text 9")),
new KeyValuePair<ulong, AxoMessengerTextItem>(10, new AxoMessengerTextItem("Messenger 5: message text 10", "Messenger 5: help text 10"))
new KeyValuePair<ulong, AxoMessengerTextItem>(10, new AxoMessengerTextItem("Messenger 5: message text 10"))
};

_messenger5.DotNetMessengerTextList = messengerTextList;
Expand Down
5 changes: 5 additions & 0 deletions src/core/app/messages.mon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
AxoMessengers._messenger1.MessengerState
AxoMessengers._messenger2.MessengerState
AxoMessengers._messenger3.MessengerState
AxoMessengers._messenger4.MessengerState
AxoMessengers._messenger5.MessengerState
1 change: 1 addition & 0 deletions src/core/app/messages1.mon
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AxoMessengers._messenger1
1 change: 1 addition & 0 deletions src/core/app/messages2.mon
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AxoMessengers._messenger2
1 change: 1 addition & 0 deletions src/core/app/messages3.mon
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AxoMessengers._messenger3
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ NAMESPACE AxoStaticMessengerExample
_messenger5condition_8 : BOOL;
{#ix-set:AttributeName = "<#Set to high to activate the messenger 5 with code 9#>"}
_messenger5condition_9 : BOOL;
{#ix-set:AttributeName = "<#Set to high to activate the messenger 5 with code 10, with no help text defined#>"}
_messenger5condition_10 : BOOL;
{#ix-set:AttributeName = "<#Set to high to call the messenger 5#>"}
_messenger5callcondition : BOOL;
END_VAR
Expand All @@ -72,9 +74,11 @@ NAMESPACE AxoStaticMessengerExample
IF _messenger1condition AND NOT _messenger1conditionWithCode THEN
_messenger1.Activate(eAxoMessageCategory#Error);
END_IF;
_messenger1.ActivateOnCondition(_messenger1code,NOT _messenger1condition AND _messenger1conditionWithCode,eAxoMessageCategory#Error);
_messenger2.ActivateOnCondition(_messenger2code,_messenger2condition,eAxoMessageCategory#Warning).RequireAcknowledgement();
IF NOT _messenger1condition THEN
_messenger1.ActivateOnCondition(_messenger1code, _messenger1conditionWithCode,eAxoMessageCategory#Error);
END_IF;
_messenger2.Serve(THIS);
_messenger2.ActivateOnCondition(_messenger2code,_messenger2condition,eAxoMessageCategory#Warning).RequireAcknowledgement();
_messenger3.ActivateOnCondition(_messenger3condition,eAxoMessageCategory#Info);
_messenger3.Serve(THIS);
_messenger4.ActivateOnCondition(_messenger4condition,eAxoMessageCategory#Info).RequireAcknowledgement();
Expand All @@ -89,6 +93,7 @@ NAMESPACE AxoStaticMessengerExample
_messenger5.ActivateOnCondition(ULINT#7,_messenger5condition_7,eAxoMessageCategory#Error).RequireAcknowledgement();
_messenger5.ActivateOnCondition(ULINT#8,_messenger5condition_8,eAxoMessageCategory#Error).RequireAcknowledgement();
_messenger5.ActivateOnCondition(ULINT#9,_messenger5condition_9,eAxoMessageCategory#Error).RequireAcknowledgement();
_messenger5.ActivateOnCondition(ULINT#10,_messenger5condition_10,eAxoMessageCategory#Error).RequireAcknowledgement();
_messenger5.Serve(THIS);
ELSE
_messenger5.Restore();
Expand Down
29 changes: 20 additions & 9 deletions src/core/ctrl/src/AxoMessaging/Static/AxoMessenger.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ USING AXOpen.Core;
NAMESPACE AXOpen.Messaging.Static

TYPE
eAxoMessengerState : (Idle, ActiveNoAck, ActiveAckn, NotActiveWaitingAckn);
eAxoMessengerState : (ActiveAckn,Idle, Active, ActiveNoAck, NotActiveWaitingAckn) := Idle;
END_TYPE

{#ix-prop: public string MessageText }
Expand Down Expand Up @@ -61,10 +61,12 @@ NAMESPACE AXOpen.Messaging.Static
Context := _context; // Duplicity!!!
END_IF;

THIS.MessengerState := eAxoMessengerState#Idle;

IF THIS.IsActive THEN
THIS.MessengerState := eAxoMessengerState#ActiveNoAck;
IF THIS.IsActive AND NOT THIS.AcknowledgedBeforeFallen THEN
IF AcknowledgementRequired THEN
THIS.MessengerState := eAxoMessengerState#ActiveNoAck;
ELSE
THIS.MessengerState := eAxoMessengerState#Active;
END_IF;
END_IF;

IF MessageCode = ULINT#0 THEN
Expand Down Expand Up @@ -114,10 +116,12 @@ NAMESPACE AXOpen.Messaging.Static
Context := _context_; // Duplicity!!!
END_IF;

THIS.MessengerState := eAxoMessengerState#Idle;

IF THIS.IsActive THEN
THIS.MessengerState := eAxoMessengerState#ActiveNoAck;
IF THIS.IsActive AND NOT THIS.AcknowledgedBeforeFallen THEN
IF AcknowledgementRequired THEN
THIS.MessengerState := eAxoMessengerState#ActiveNoAck;
ELSE
THIS.MessengerState := eAxoMessengerState#Active;
END_IF;
END_IF;

IF MessageCode = ULINT#0 THEN
Expand Down Expand Up @@ -276,6 +280,7 @@ NAMESPACE AXOpen.Messaging.Static
IF AcknowledgementRequired AND NOT AcknowledgedBeforeFallen THEN
WaitingForAcknowledge := TRUE;
ELSE
THIS.MessengerState := eAxoMessengerState#Idle;
MessageCode := ULINT#0;
END_IF;
END_IF;
Expand All @@ -295,6 +300,8 @@ NAMESPACE AXOpen.Messaging.Static
Context.GetLogger().Log('Fallen', eLogLevel#Information, THIS);
IF AcknowledgementRequired AND NOT AcknowledgedBeforeFallen THEN
WaitingForAcknowledge := TRUE;
ELSE
THIS.MessengerState := eAxoMessengerState#Idle;
END_IF;
END_IF;
END_IF;
Expand All @@ -315,7 +322,9 @@ NAMESPACE AXOpen.Messaging.Static
IF MessageCode = _messageCode THEN
IF NOT WaitingForAcknowledge THEN
AcknowledgedBeforeFallen := TRUE;
THIS.MessengerState := eAxoMessengerState#ActiveAckn;
ELSE
THIS.MessengerState := eAxoMessengerState#Idle;
WaitingForAcknowledge := FALSE;
MessageCode := ULINT#0;
END_IF;
Expand All @@ -335,8 +344,10 @@ NAMESPACE AXOpen.Messaging.Static

IF NOT WaitingForAcknowledge THEN
AcknowledgedBeforeFallen := TRUE;
THIS.MessengerState := eAxoMessengerState#ActiveAckn;
ELSE
WaitingForAcknowledge := FALSE;
THIS.MessengerState := eAxoMessengerState#Idle;
MessageCode := ULINT#0;
END_IF;
AcknowledgeRequest := FALSE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,27 @@

<tr class="@TableRowBackgroundColor">
<th scope="row">@Component.GetParent()?.AttributeName</th>
<td>
<span class="@(IsActive ? "fw-bold" : "") @(AcknowledgedBeforeFallen ? "line-through" : "")">
@Category
</span>
</td>
<td>
<span class="@(IsActive ? "fw-bold" : "") @(AcknowledgedBeforeFallen ? "line-through" : "")">
@MessageText
</span>
</td>
@if (!ShowHelpText )
{
<td>
<span class="@(IsActive ? "fw-bold" : "") @(AcknowledgedBeforeFallen ? "line-through" : "")">
@Category
</span>
</td>
<td>
<span class="@(IsActive ? "fw-bold" : "") @(AcknowledgedBeforeFallen ? "line-through" : "")">
@MessageText
</span>
</td>
}
else
{
<td>
<span class="@TableRowBackgroundColor">
@HelpText
</span>
</td>
}
<td style="font-size: 0.55em; margin-top: 0.15em;"></td>
<td style="font-size: 0.55em; margin-top: 0.15em;">
<AuthorizeView Roles="can_attempt_repair">
Expand All @@ -28,7 +39,12 @@

</td>
<td style="font-size: 0.55em; margin-top: 0.15em;">
<button class="btn @AckBtnBackgroundColor equal-button" type="button" @onclick="@AcknowledgeTask" hidden="@HideAckowledgeButton">
<button class="btn @AckBtnBackgroundColor equal-button" type="button" @onclick="@HelpTextTask" hidden="@HideHelpButton">
<span class="oi oi-question-mark" aria-hidden="true"></span>
</button>
</td>
<td style="font-size: 0.55em; margin-top: 0.15em;">
<button class="btn @AckBtnBackgroundColor equal-button" type="button" @onclick="@AcknowledgeTask" hidden="@HideAcknowledgeButton">
<span class="oi oi-x" aria-hidden="true"></span>
</button>
</td>
Expand All @@ -40,7 +56,7 @@
</td>
<td style="font-size: 0.55em; margin-top: 0.15em;">@Risen</td>
<td style="font-size: 0.55em; margin-top: 0.15em;">@Fallen</td>
<td style="font-size: 0.55em; margin-top: 0.15em;;">@Acknowledged</td>
<td style="font-size: 0.55em; margin-top: 0.15em;">@Acknowledged</td>

</tr>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using static System.Runtime.InteropServices.JavaScript.JSType;
using AXSharp.Presentation.Blazor.Controls.RenderableContent;


namespace AXOpen.Messaging.Static
{
public partial class AxoMessengerView : RenderableComplexComponentBase<AxoMessenger>, IDisposable
Expand All @@ -33,10 +34,15 @@ public partial class AxoMessengerView : RenderableComplexComponentBase<AxoMessen

private async void AcknowledgeTask()
{
this.ShowHelpText = false;
Component.AcknowledgeRequest.Cyclic = true;
AxoApplication.Current.Logger.Information($"Message '{this.MessageText}' acknowledged.", this.Component, await GetCurrentUserIdentity());
}

private async void HelpTextTask()
{
this.ShowHelpText = !this.ShowHelpText;
}
private async void RestoreTask()
{
if (this.Component.GetParent() is AxoTask t)
Expand All @@ -60,14 +66,16 @@ protected override void OnInitialized()
UpdateValuesOnChange(Component.Risen);
UpdateValuesOnChange(Component.Fallen);
UpdateValuesOnChange(Component.Acknowledged);

}



public override void Dispose()
{
Component.StopPolling(this);
base.Dispose();
}

private string BackgroundColor
{
get
Expand Down Expand Up @@ -156,20 +164,30 @@ private string Category
private string Symbol => !(string.IsNullOrEmpty(Component.Symbol)) ? Component.Symbol : "Unable to retrieve symbol!";
private string MessageText => Component.GetMessageText();
private string HelpText => GetHelpText();
private bool HelpTextDefined => Component.HelpTextDefined;
private string Risen => !(string.IsNullOrEmpty(Component.Risen.Cyclic.ToString())) ? Component.Risen.Cyclic.ToString() : "";
private string Fallen => !(string.IsNullOrEmpty(Component.Fallen.Cyclic.ToString())) ? Component.Fallen.Cyclic.ToString() : "";
private string Acknowledged => !(string.IsNullOrEmpty(Component.Acknowledged.Cyclic.ToString())) ? Component.Acknowledged.Cyclic.ToString() : "";
private bool IsActive => Component.State > eAxoMessengerState.Idle && Component.State != eAxoMessengerState.NotActiveWaitingAckn;

private bool AcknowledgementRequired => true; //Component.State >= eAxoMessengerState.ActiveAckn;
private bool AcknowledgedBeforeFallen => Component.AcknowledgedBeforeFallen.Cyclic;
private bool AcknowledgementDoesNotRequired => !AcknowledgementRequired;
private bool WaitingForAcknowledge => Component.State >= eAxoMessengerState.NotActiveWaitingAckn;
private bool HideAckowledgeButton => !AcknowledgementRequired || AcknowledgedBeforeFallen || (!IsActive && !WaitingForAcknowledge);

private bool HideRepairButton =>(!IsActive || this.Component.GetParent() is not AxoTask);
private eAxoMessengerState MessengerState
{
get
{
if (Component.State == eAxoMessengerState.Idle)
{
ShowHelpText = false;
}
return Component.State;
}
}
private bool IsActive => Component.State == eAxoMessengerState.ActiveNoAck || Component.State == eAxoMessengerState.ActiveAckn || Component.State == eAxoMessengerState.Active;

private bool AcknowledgedBeforeFallen => Component.State == eAxoMessengerState.ActiveAckn;
private bool HideAcknowledgeButton => Component.State <= eAxoMessengerState.Idle || Component.State == eAxoMessengerState.Active;
private bool HideHelpButton => MessengerState == eAxoMessengerState.Idle || !HelpTextDefined;

private bool HideRepairButton => (!IsActive || this.Component.GetParent() is not AxoTask);
private bool ShowHelpText;


private string GetHelpText()
{
ulong messageCode = Component.MessageCode.Cyclic;
Expand Down Expand Up @@ -237,4 +255,6 @@ public AxoMessengerDetailedStatusView()
{
}
}


}
Loading
Loading