Skip to content

Commit

Permalink
AxoTextList warning level and error level defined by attributes insid…
Browse files Browse the repository at this point in the history
…e the PLC code
  • Loading branch information
Tomas Kovac committed Aug 3, 2023
1 parent 4ad01b2 commit 7f8729b
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 20 deletions.
4 changes: 4 additions & 0 deletions src/components.abstractions/ctrl/src/AxoComponent_Status.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ NAMESPACE AXOpen.Components.Abstractions
CLASS PUBLIC AxoComponent_Status
VAR PUBLIC
{#ix-set:AttributeName = "ActionDescription: |[[1]ActionDescription]|"}
{#ix-attr:[WarningLevel(600)]}
{#ix-attr:[ErrorLevel(700)]}
Action : AXOpen.Core.AxoTextList;
{#ix-set:AttributeName = "ErrorDescription: |[[1]ErrorDescription]|"}
{#ix-attr:[WarningLevel(600)]}
{#ix-attr:[ErrorLevel(700)]}
Error : AXOpen.Core.AxoTextList;
END_VAR
END_CLASS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
namespace AXOpen.Core
using AXSharp.Connector;

namespace AXOpen.Core
{
public partial class AxoTextListView : IDisposable
{
private uint _warningLevel => this.Component.GetAttribute<WarningLevelAttribute>() != null ? this.Component.GetAttribute<WarningLevelAttribute>().Level : 0;
private uint _errorLevel => this.Component.GetAttribute<ErrorLevelAttribute>() != null ? this.Component.GetAttribute<ErrorLevelAttribute>().Level : 0;

private string _cardClass
{
get
{
if (Component.Id.Cyclic < (int)Messaging.eAxoMessageCategory.Warning)
return "card bg-primary text-light mb-1";
else if (Component.Id.Cyclic >= (int)Messaging.eAxoMessageCategory.Error)
return "card bg-danger text-white mb-1";
if(_warningLevel>0 && _errorLevel > _warningLevel)
{
if (Component.Id.Cyclic < _warningLevel)
return "card bg-primary text-light mb-1";
else if (Component.Id.Cyclic >= _errorLevel)
return "card bg-danger text-white mb-1";
else
return "card bg-warning text-black mb-1";
}
else
return "card bg-warning text-black mb-1";
return "card bg-primary text-light mb-1";


}
}

Expand Down
34 changes: 27 additions & 7 deletions src/core/src/AXOpen.Core/AxoTextList/AxoTextList.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
using System;
using AXSharp.Connector;
using AXSharp.Connector.ValueTypes;
using System.Collections.Generic;
using AXOpen;
using System.ComponentModel;
using System.Security.Principal;

namespace AXOpen.Core
{
public partial class AxoTextList
{

}
}
public class WarningLevelAttribute : Attribute
{
public WarningLevelAttribute()
{
}
public WarningLevelAttribute(uint level)
{
Level = level;
}

public uint Level { get; }
}

public class ErrorLevelAttribute : Attribute
{
public ErrorLevelAttribute()
{
}
public ErrorLevelAttribute(uint level)
{
Level = level;
}

public uint Level { get; }
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,33 @@ NAMESPACE AxoTextListExample
_set2zeroTask : AXOpen.Core.AxoTask;

{#ix-set:AttributeName = "Description: |[[1]Description]|"}
_myTextList : AXOpen.Core.AxoTextList;
{#ix-attr:[WarningLevel(600)]}
{#ix-attr:[ErrorLevel(700)]}
_myTextList1 : AXOpen.Core.AxoTextList;
{#ix-set:AttributeName = "Same description: |[[1]Description]|"}
{#ix-attr:[WarningLevel(300)]}
{#ix-attr:[ErrorLevel(500)]}
_myTextList2 : AXOpen.Core.AxoTextList;
{#ix-set:AttributeName = "Totaly different description without error elevation: |[[1]Description3]|"}
_myTextList3 : AXOpen.Core.AxoTextList;
END_VAR

METHOD PROTECTED OVERRIDE Main
_incrementTask.Initialize(THIS);
_set2zeroTask.Initialize(THIS);

IF(_incrementTask.Execute()) THEN
_myTextList.Id := _myTextList.Id + UINT#1;
_incrementTask.DoneWhen(_myTextList.Id>= UINT#1000);
_myTextList1.Id := _myTextList1.Id + UINT#1;
_incrementTask.DoneWhen(_myTextList1.Id>= UINT#1000);
END_IF;

IF(_set2zeroTask.Execute()) THEN
_incrementTask.Restore();
_myTextList.Id := UINT#0;
_myTextList1.Id := UINT#0;
_set2zeroTask.DoneWhen(TRUE);
END_IF;
END_METHOD
_myTextList2.Id := _myTextList1.Id;
_myTextList3.Id := _myTextList1.Id;
END_METHOD
END_CLASS
END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@
</div>
</div>
<div class="col">
<RenderableContentControl Context="@Entry.Plc.AxoTextListExampleContext._myTextList" Presentation="Command" />
<RenderableContentControl Context="@Entry.Plc.AxoTextListExampleContext._myTextList1" Presentation="Command" />
</div>
<div class="col">
<RenderableContentControl Context="@Entry.Plc.AxoTextListExampleContext._myTextList2" Presentation="Command" />
</div>
<div class="col">
<RenderableContentControl Context="@Entry.Plc.AxoTextListExampleContext._myTextList3" Presentation="Command" />
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public partial class AxoTextListExampleContext : AXOpen.Core.AxoContext
{
Dictionary<uint, string> descriptionDict = new Dictionary<uint, string>();
Dictionary<uint, string> descriptionDict3 = new Dictionary<uint, string>();

public string Description
{
Expand All @@ -19,7 +20,7 @@ public string Description

}
string description = " ";
if (descriptionDict.TryGetValue(_myTextList.Id.LastValue, out description))
if (descriptionDict.TryGetValue(_myTextList1.Id.LastValue, out description))
{
return description;
}
Expand All @@ -31,6 +32,32 @@ public string Description
}
}

public string Description3
{
get
{
if (descriptionDict3 == null) { descriptionDict3 = new Dictionary<uint, string>(); }
if (descriptionDict3.Count == 0)
{
descriptionDict3.Add(0, " ");
for (int i = 1; i < 1000; i++)
{
descriptionDict3.Add((uint)i, "Item from the totally different text list : " + i.ToString());
}

}
string description3 = " ";
if (descriptionDict3.TryGetValue(_myTextList3.Id.LastValue, out description3))
{
return description3;
}
else

{
return " ";
}
}
}
}

}

0 comments on commit 7f8729b

Please sign in to comment.