ErrorItems errors = dte.ToolWindows.ErrorList.ErrorItems;
I could only read and display message 1 to 10.TwinCAT System (10000) or PlcTask (350
):dte.ToolWindows.ErrorList.ErrorItems;
?Show output from build and Show output from twinCAT
.VS2013 console output:
Message 1 The application is up to date 0 0
Message 2 Build complete -- 0 errors, 0 warnings : ready for download! 0 0
Message 3 Additional code checks ... 0 0
Error 4 SA0033: Unused Variable 'fbSum_Test' UnitTestJenkins (UnitTestJenkins\UnitTestJenkins)
Error 5 SA0033: Unused Variable 'fbDegreesToRadians' 4 1 UnitTestJenkins (UnitTestJenkins\UnitTestJenkins)
Error 6 SA0033: Unused Variable 'data' FB_DegreesToRadians_Test.DegreesToRadians_Test1 3 1 UnitTestJenkins (UnitTestJenkins\UnitTestJenkins)
Message 7 Additional code checks complete -- 3 errors 0 0
Message 8 Generate TMC information ... 0 0
Message 9 Import symbol information ... 0 0
Message 10 generate boot information... PLC.UnitTestJenkins 0 0 UnitTestJenkins (UnitTestJenkins\UnitTestJenkins)
Message 11 29.11.2019 09:52:58 477 ms | 'TwinCAT System' (10000): Ein Neustart des TwinCAT Systems wurde von AmsNetId: 10.73.8.239.1.1 Port 32867 angefordert.
Message 12 29.11.2019 09:52:58 614 ms | 'TwinCAT System' (10000): Konfiguration des COM Servers TcEventLogger wird gesichert!
Message 13 29.11.2019 09:52:59 440 ms | 'TwinCAT System' (10000): COM Servers TcEventLogger wird heruntergefahren!
Message 14 29.11.2019 09:53:01 467 ms | 'TwinCAT System' (10000): Konfiguration des COM Servers TcEventLogger wird geladen!
Message 15 29.11.2019 09:53:01 468 ms | 'TwinCAT System' (10000): COM Server TcEventLogger wird initialisiert!
Message 16 29.11.2019 09:53:01 517 ms | 'TwinCAT System' (10000): TcIo Server wurde gestartet: TcIo.
Message 17 29.11.2019 09:53:01 530 ms | 'TwinCAT System' (10000): TcPlc30 Server wurde gestartet: TcPlc30.
Message 18 29.11.2019 09:53:01 537 ms | 'TwinCAT System' (10000): TcRtsObjects Server wurde gestartet: TcRtsObjects.
Message 19 29.11.2019 09:53:01 543 ms | 'TwinCAT System' (10000): TcRTime Server wurde gestartet: TcRTime.
Message 20 29.11.2019 09:53:01 660 ms | 'License Server' (30): license validation status is Valid(3)
Message 21 29.11.2019 09:53:01 704 ms | 'TCRTIME' (200): Intel(R) Core(TM)-i 4'th generation detected
Message 22 29.11.2019 09:53:02 078 ms | 'TwinCAT System' (10000): COM Server TcEventLogger wird gestartet!
Error 23 29.11.2019 09:53:02 108 ms | 'PlcTask' (350): FAILED TEST 'PRG_TEST.fbSum_Test@TwoPlusTwoEqualsFour', EXP: 4, ACT: 3, MSG: The calculation is not correct
Error 24 29.11.2019 09:53:02 168 ms | 'PlcTask' (350): FAILED TEST 'PRG_TEST.fbDegreesToRadians@DegreesToRadians_Test1', EXP: 0.0, ACT: 0.01745329, MSG: The calculation is not correct
Error 25 29.11.2019 09:53:02 228 ms | 'PlcTask' (350): FAILED TEST 'PRG_TEST.fbDegreesToRadians@DegreesToRadians_Test2', EXP: 1.0, ACT: 0.01745329, MSG: The calculation is not correct
Error 26 29.11.2019 09:53:02 388 ms | 'PlcTask' (350): | ==========TESTS FINISHED RUNNING==========
Error 27 29.11.2019 09:53:02 708 ms | 'PlcTask' (350): | Test suites: 2
Error 28 29.11.2019 09:53:03 028 ms | 'PlcTask' (350): | Tests: 4
Error 29 29.11.2019 09:53:03 348 ms | 'PlcTask' (350): | Successful tests: 1
Error 30 29.11.2019 09:53:03 668 ms | 'PlcTask' (350): | Failed tests: 3
Error 31 29.11.2019 09:53:03 988 ms | 'PlcTask' (350): | ======================================
Output on the Jenkins Console: [Could read only first 10 messages]
ActivateConfiguration Errors count: 10
vsBuildErrorLevelLow: Description: The application is up to date
vsBuildErrorLevelLow: Description: Build complete -- 0 errors, 0 warnings : ready for download!
vsBuildErrorLevelLow: Description: Additional code checks ...
vsBuildErrorLevelHigh: Description: SA0033: Unused Variable 'fbSum_Test'
vsBuildErrorLevelHigh: Description: SA0033: Unused Variable 'fbDegreesToRadians'
vsBuildErrorLevelHigh: Description: SA0033: Unused Variable 'data'
vsBuildErrorLevelLow: Description: Additional code checks complete -- 3 errors
vsBuildErrorLevelLow: Description: Generate TMC information ...
vsBuildErrorLevelLow: Description: Import symbol information ...
vsBuildErrorLevelLow: Description: generate boot information...
Exit code is 1
C# Code:
//5.4.1 ITcPlcProject - Automation Interface document
ITcSmTreeItem plcProjectRootItem = sysMan.LookupTreeItem("TIPC^UnitTestJenkins");
ITcPlcProject iecProjectRoot = (ITcPlcProject)plcProjectRootItem;
iecProjectRoot.BootProjectAutostart = true;
iecProjectRoot.GenerateBootProject(true);
sysMan.ActivateConfiguration();
sysMan.StartRestartTwinCAT();
ErrorItems ActivateConfigurationErrors = dte.ToolWindows.ErrorList.ErrorItems;
Console.WriteLine("ActivateConfiguration Errors count: " + ActivateConfigurationErrors.Count);
for (int i = 1; i <= ActivateConfigurationErrors.Count; i++)
{
ErrorItem item = ActivateConfigurationErrors.Item(i);
Console.WriteLine(item.ErrorLevel + ": " + "Description: " + item.Description);
}
Please look in to screenshots of the outputs: Build&TwinCAToutput
I see that you are using TcUnit. The problem is that you’re not waiting for TcUnit to finish before you are collecting your ErrorItems. You are only collecting the error items after doing the ActivateConfiguration() and StartRestartTwincat() (that’s why you only get the first 10). You need to wait for TcUnit to finish.
Wrap the running of TcUnit in a while-loop, and ask TcUnit for the results. Once all results are returned (which is done when you have all prints done), you can then use your ErrorItems. So basically, collect the ErrorItems in a while-true loop (but make sure to use a sleep every second or so), and once you have all the results from TcUnit (in other words, the lines ==========TESTS FINISHED RUNNING========== and everything that follows), you can print all error items (or parse them, or do whatever you want with them).
Good luck!