Skip to content

Commit

Permalink
feat(v0.4/#59): Port Submodule - Add attributes for *.xti
Browse files Browse the repository at this point in the history
Closes #59.
Also, update dependencies.
  • Loading branch information
densogiaichned committed Jul 11, 2024
1 parent f311541 commit 0d915a7
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 13 deletions.
5 changes: 5 additions & 0 deletions src/dsian.TcPnScanner.CLI/Export/TC/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ internal static class Constants

internal const uint SUBMODULE_INDEX_START = 0x031C0000u;

internal const ushort SUBSLOT_NR_PORT1 = 32769;

internal const ushort SUBSLOT_NR_PORT2 = 32770;

internal const uint BOX_IMAGE_ID = 121;

internal const uint API_IMAGE_ID = 4;
Expand All @@ -35,4 +39,5 @@ internal static class Constants
internal const uint BOX_PROFINET_FLAGS = 0x410u;

internal const uint BOX_PROFINET_FRAME_OFFSET = 0x8000u;

}
33 changes: 33 additions & 0 deletions src/dsian.TcPnScanner.CLI/Export/TC/TcSmItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2965,6 +2965,9 @@ public partial class TcSmItemDeviceBoxProfinetAPIModuleSubModule

private uint subModuleIdentNumberField;

private uint typeOfSubmoduleField;
private bool typeOfSubmoduleFieldSpecified;

private uint subSlotNumberField;

private bool isFixSubmoduleField;
Expand Down Expand Up @@ -3091,6 +3094,35 @@ public uint SubModuleIdentNumber
}
}

/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public uint TypeOfSubModule
{
get
{
return this.typeOfSubmoduleField;
}
set
{
this.typeOfSubmoduleField = value;
this.typeOfSubmoduleFieldSpecified = true;
}
}

/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool TypeOfSubModuleSpecified
{
get
{
return this.typeOfSubmoduleFieldSpecified;
}
set
{
this.typeOfSubmoduleFieldSpecified = value;
}
}

/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public uint SubSlotNumber
Expand Down Expand Up @@ -3144,6 +3176,7 @@ public uint AddSubModFlags
set
{
this.addSubModFlagsField = value;
this.addSubModFlagsFieldSpecified = true;
}
}

Expand Down
17 changes: 15 additions & 2 deletions src/dsian.TcPnScanner.CLI/Export/TC/XtiExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private static TcSmItemDeviceBoxProfinetAPIModuleSubModule[] GetSubModules(APIEx

foreach (var submodule in api.Submodules)
{
subModules.Add(new TcSmItemDeviceBoxProfinetAPIModuleSubModule
var subModuleToAdd = new TcSmItemDeviceBoxProfinetAPIModuleSubModule
{
Id = PrintAsHex(CreateModuleIndex(Constants.SUBMODULE_INDEX_START, (ushort)(submodule.SubslotNumber + 1))),
Name = $"Subterm {submodule.SubslotNumber}{PrintSubTermIoLabel(submodule)}",
Expand All @@ -195,7 +195,16 @@ private static TcSmItemDeviceBoxProfinetAPIModuleSubModule[] GetSubModules(APIEx
APINr = api.APIId,
APINrSpecified = api.APIId != 0,
Vars = GetIoVarsForSubmodule(submodule)
});

};
if (IsPortSubmodule(submodule))
{
subModuleToAdd.Name += $" (Port {submodule.SubslotNumber - (Constants.SUBSLOT_NR_PORT1 - 1)})";
subModuleToAdd.PortData = "";
subModuleToAdd.TypeOfSubModule = 2;
subModuleToAdd.AddSubModFlags = 28;
}
subModules.Add(subModuleToAdd);
}

return subModules.ToArray();
Expand Down Expand Up @@ -292,4 +301,8 @@ private static string PrintAsHex(uint index)
{
return $"#x{index:X08}";
}
private static bool IsPortSubmodule(in Submodule submodule)
{
return submodule.SubslotNumber >= Constants.SUBSLOT_NR_PORT1 && submodule.SubslotNumber <= Constants.SUBSLOT_NR_PORT2;
}
}
10 changes: 5 additions & 5 deletions src/dsian.TcPnScanner.CLI/dsian.TcPnScanner.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<Description>Scans a PROFINET and adds all Stations to a PROFINET IO Device (TF6270)</Description>
<Copyright>Copyright (c) 2023 densogiaichned</Copyright>
<Title>TwinCAT Profinet Device Scanner</Title>
<Version>0.3.1</Version>
<Version>0.4.0</Version>
<AssemblyVersion>$(Version)</AssemblyVersion>
<FileVersion>$(Version)</FileVersion>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
Expand Down Expand Up @@ -55,11 +55,11 @@
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog" Version="4.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="SharpPcap" Version="6.2.5" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="SharpPcap" Version="6.3.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Verify" Version="23.1.0" />
<PackageReference Include="Verify.Xunit" Version="23.1.0" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Verify" Version="25.3.1" />
<PackageReference Include="Verify.Xunit" Version="25.3.1" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down

0 comments on commit 0d915a7

Please sign in to comment.