|
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
| 3 | +using System.Linq; |
3 | 4 | using System.Text; |
| 5 | +using TiaCodegen.Commands.Comparisons; |
4 | 6 | using TiaCodegen.Enums; |
5 | 7 | using TiaCodegen.Interfaces; |
6 | 8 |
|
@@ -352,13 +354,59 @@ public void AddXmlToStringBuilder(ulong id, StringBuilder sb) |
352 | 354 | { |
353 | 355 | i++; |
354 | 356 | p1 = Unescape(Escape(LocalName).Split('.')[i]); |
355 | | - if (p1.Contains("]")) |
| 357 | + if (p1.Contains(",")) |
356 | 358 | { |
357 | | - sb.AppendLine("<Component Name=\"" + p1.Substring(0, p1.Length - 1) + "\" />"); |
358 | | - p1 = null; |
| 359 | + var innerParts = p1.Split(','); |
| 360 | + sb.AppendLine("<Component Name=\"" + innerParts[0] + "\" />"); |
| 361 | + foreach (var p in innerParts.Skip(1)) |
| 362 | + { |
| 363 | + var pNe = p.Trim(); |
| 364 | + bool close = false; |
| 365 | + if (pNe.Contains("]")) |
| 366 | + { |
| 367 | + pNe = pNe.Substring(0, pNe.Length - 1); |
| 368 | + close = true; |
| 369 | + } |
| 370 | + if (int.TryParse(pNe, out _)) |
| 371 | + { |
| 372 | + sb.AppendLine("<Access Scope=\"LiteralConstant\">"); |
| 373 | + sb.AppendLine("<Constant>"); |
| 374 | + sb.AppendLine("<ConstantType>DInt</ConstantType>"); |
| 375 | + sb.AppendLine("<ConstantValue>" + pNe + "</ConstantValue>"); |
| 376 | + sb.AppendLine("</Constant>"); |
| 377 | + sb.AppendLine("</Access>"); |
| 378 | + } |
| 379 | + else |
| 380 | + { |
| 381 | + sb.AppendLine("</Symbol>"); |
| 382 | + sb.AppendLine("</Access>"); |
| 383 | + |
| 384 | + var accessTypePne = "GlobalVariable"; |
| 385 | + if (pNe[0] == '#') |
| 386 | + { |
| 387 | + pNe = pNe.Substring(1); |
| 388 | + accessTypePne = "LocalVariable"; |
| 389 | + } |
| 390 | + sb.AppendLine("<Access Scope=\"" + accessTypePne + "\">"); |
| 391 | + sb.AppendLine("<Symbol>"); |
| 392 | + sb.AppendLine("<Component Name=\"" + pNe + "\" />"); |
| 393 | + } |
| 394 | + } |
| 395 | + if (p1.Contains("]")) |
| 396 | + { |
| 397 | + p1 = null; |
| 398 | + } |
359 | 399 | } |
360 | 400 | else |
361 | | - sb.AppendLine("<Component Name=\"" + p1 + "\" />"); |
| 401 | + { |
| 402 | + if (p1.Contains("]")) |
| 403 | + { |
| 404 | + sb.AppendLine("<Component Name=\"" + p1.Substring(0, p1.Length - 1) + "\" />"); |
| 405 | + p1 = null; |
| 406 | + } |
| 407 | + else |
| 408 | + sb.AppendLine("<Component Name=\"" + p1 + "\" />"); |
| 409 | + } |
362 | 410 | } |
363 | 411 | sb.AppendLine("</Symbol>"); |
364 | 412 | sb.AppendLine("</Access>"); |
@@ -387,10 +435,10 @@ public void AddXmlToStringBuilder(ulong id, StringBuilder sb) |
387 | 435 | } |
388 | 436 | sb.AppendLine("</Component>"); |
389 | 437 | } |
390 | | - if (this is FixedPeripherySignal) |
391 | | - sb.AppendLine("<Address Area=\"PeripheryInput\" Type=\"Bool\" BitOffset=\"0\" Informative=\"true\" />"); |
392 | | - else |
393 | | - sb.AppendLine("<Address Area=\"None\" Type=\"Bool\" BlockNumber=\"0\" BitOffset=\"0\" Informative=\"true\" />"); |
| 438 | + //if (this is FixedPeripherySignal) |
| 439 | + // sb.AppendLine("<Address Area=\"PeripheryInput\" Type=\"Bool\" BitOffset=\"0\" Informative=\"true\" />"); |
| 440 | + //else |
| 441 | + // sb.AppendLine("<Address Area=\"None\" Type=\"Bool\" BlockNumber=\"0\" BitOffset=\"0\" Informative=\"true\" />"); |
394 | 442 | sb.AppendLine("</Symbol>"); |
395 | 443 | sb.AppendLine("</Access>"); |
396 | 444 | } |
|
0 commit comments