Skip to content

Commit c23a2e4

Browse files
committed
Merge branch 'IncObjectName' into feature
# Conflicts: # libEDSsharp/eds.cs
2 parents f50327c + 062ffcc commit c23a2e4

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

.github/workflows/dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
# runs-on: ubuntu-latest # Error: setup-msbuild can only be run on Windows runners
1818
steps:
1919
- name: Checkout
20-
uses: actions/checkout@v5
20+
uses: actions/checkout@v6
2121
with:
2222
fetch-depth: 0
2323
- name: Setup .NET

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
contents: write
1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@v5
15+
uses: actions/checkout@v6
1616
with:
1717
fetch-depth: 0
1818
- name: Setup .NET

libEDSsharp/eds.cs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ public partial class DeviceInfo : InfoSection
679679
/// product revision number according to identity object sub-index 03h (Unsigned32)
680680
/// </summary>
681681
[EdsExport]
682-
public string RevisionNumber;
682+
public UInt32 RevisionNumber;
683683

684684
/// <summary>
685685
/// indicate the supported baud rates (Boolean, 0 = not supported, 1=supported)
@@ -1281,9 +1281,12 @@ public void AccessPDO(AccessPDO accessPDO)
12811281
break;
12821282
}
12831283
}
1284-
1285-
1286-
1284+
/// <summary>
1285+
/// Incremement number at end of string by given increment
1286+
/// </summary>
1287+
/// <param input>SubObject name as string to increment</param>
1288+
/// <param increment>increment for next SubObject</param>
1289+
/// <returns>incremented name or the original string if no number is found at the end</returns>
12871290
public static string IncrementNumberAtEnd(string input, int increment)
12881291
{
12891292
// Regex to match the last token if it's a number
@@ -1294,7 +1297,7 @@ public static string IncrementNumberAtEnd(string input, int increment)
12941297
{
12951298
// Extract the number and increment it
12961299
int number = int.Parse(match.Value);
1297-
number+= increment;
1300+
number += increment;
12981301

12991302
// Replace the old number with the new number
13001303
string result = regex.Replace(input, number.ToString());
@@ -1304,8 +1307,6 @@ public static string IncrementNumberAtEnd(string input, int increment)
13041307
// Return the original string if no number is found at the end
13051308
return input;
13061309
}
1307-
1308-
13091310
/// <summary>
13101311
/// Duplicate current sub entry and add it to parent
13111312
/// </summary>
@@ -1349,11 +1350,10 @@ public ODentry AddSubEntry()
13491350
}
13501351
else
13511352
{
1352-
lastSubIndex = lastSubOd.Subindex;
1353-
originalOd = (parent != null && this.Subindex > 0 && this.Subindex+1 != lastSubIndex) ? this : lastSubOd;
1353+
originalOd = (parent != null && this.Subindex > 0) ? this : lastSubOd;
13541354
newOd = originalOd.Clone(originalOd.parent);
13551355
maxSubIndex = EDSsharp.ConvertToUInt16(baseObject.subobjects[0].defaultvalue);
1356-
1356+
lastSubIndex = lastSubOd.Subindex;
13571357
}
13581358

13591359
// insert new sub od
@@ -1366,12 +1366,10 @@ public ODentry AddSubEntry()
13661366

13671367
newSubObjects.Add(newSubIndex++, subOd);
13681368

1369-
if (originalOd == subOd)
1370-
{
1371-
if(subOd.Subindex == (newSubIndex-1)) // if new subindex is the last one and parmeter name ends with number: increment number
1372-
newOd.parameter_name = IncrementNumberAtEnd(newOd.parameter_name,1);
1373-
newSubObjects.Add(newSubIndex++, newOd);
1374-
1369+
if (lastSubOd == subOd) {
1370+
newSubObjects.Add(newSubIndex, newOd);
1371+
// Auto increment if the parameter name has a number at the end
1372+
newSubObjects[newSubIndex].parameter_name = IncrementNumberAtEnd(newSubObjects[(ushort)(newSubIndex-1)].parameter_name, 1);
13751373
}
13761374
}
13771375
if (originalOd == null)

0 commit comments

Comments
 (0)