08-27-2023 08:07 PM
A new feature was added with version 2.2 of the Nexeed Station Lamp Addon to check all DialogRequest variables at its level and below. I think this is a good change, and I'm using this addon on a couple stations. In my experience this feature works well if you don't have SubTrees, and it works well if the StationLamp is part of a SubTree. I have recently noticed an issue when the Station Lamp isn't part of a SubTree, but has a SubTree referenced at a lower level of the Model tree. In this situation, the export is unable to collect the Dialog Request Variables that are part of the SubTree.
The desired behaviour (for me at least) is to include all the DialogRequest variables at its level and below even if they are part of SubTree. I'm including a modified version of the UnitFb.otd file with a possible solution. The export from my modified code looks okay, and it builds in TwinCat, but I haven't had an opportunity to tested it on real hardware yet.
<%List<string> DialogRequestVars = new List<string>();%>
<%SearchDialogRequestVars(@ownerObject.AddOnHost, ref DialogRequestVars);%>
<* FunctionBlock name="<%=@this.Name%>" extends="StationLampAddon" path="<%=@this.Path%>" overwrite="false" *>
<%T= ?system?_Common\CodeEntityDeclaration.otd %>
<* DeclarationEnd *>
<% // ---------------------------------------------------------------------------------------------------------%>
<* method name="CheckAnyDialogIsActive" type="VOID" comment="This function returns true if a dialog request variable is set" overwrite="true" *>
<* DeclarationEnd *>
<% // ---------------------------------------------------------------------------------------------------------%>
<%if ( DialogRequestVars != null ){%>
<%if ( DialogRequestVars.Count > 0 ){%>
_dialogActive :=
<%for(int i = 0; i < DialogRequestVars.Count; i++){%>
<%if (i != DialogRequestVars.Count-1){%>
( <%=DialogRequestVars[i]%> <> '' ) OR
<%}%>
<%else{%>
( <%=DialogRequestVars[i]%> <> '' );
<%}%>
<%}%>
<%}%>
<%}%>
<%CodeMemberStart
public static void SearchDialogRequestVars(Bosch.OpCon.Engineering.ControlSystems.ConfigUnitDrop @object, ref List<string> Vars )
{
if (@object.RequestDialogVariable != null)
{
Vars.Add(@object.RequestDialogVariable.FullName);
}
if(@object.ChildUnitsAndSubTreeReferences.Count != 0)
{
foreach (var item in @object.ChildUnitsAndSubTreeReferences)
{
var configUnit = item as Bosch.OpCon.Engineering.ControlSystems.ConfigUnitDrop;
if(configUnit != null)
{
SearchDialogRequestVars(configUnit, ref Vars);
}
var subTree = item as Bosch.OpCon.Engineering.ControlSystems.SubTreeReferenceDrop;
if(subTree != null)
{
List<string> SubTreeVars = new List<string>();
SearchDialogRequestVars(subTree.SubTreeDefinition, ref SubTreeVars);
foreach(var subTreeVar in SubTreeVars)
{
Vars.Add(subTreeVar.Replace("InstIdx", subTree.SubTreeInstanceIndex.FullName));
}
}
}
}
}
CodeMemberEnd%>
08-28-2023 12:42 PM
Thanks for your input! The origins of this object are probably older than the subtree feature, that may be the reason why this wasn't implemented. We will check this and integrate it in the next version.