-
Notifications
You must be signed in to change notification settings - Fork 17
Conversation
What happens when you try to load a TwinCAT 4020-project (no variant handling) with this? |
By the way, thanks for this pull request. Looks very exciting. I'll try to review it during the week. |
Couldn't we reference Maybe sanity check if version > 4024.0 and variant flag set, pseudo code: if (!String.IsNullOrEmpty(Variant) && TcVersion >= 4024.0)
{
try
{
automationInterface.ITcSysManager.CurrentProjectVariant = Variant;
log.Info("Variant selected with name: " + Variant);
}
catch
{
log.Error("Unable to set variant: " + Variant + ". Please provide an existing variant from the project.");
CleanUpAndExitApplication(Constants.RETURN_INVALID_VARIANT);
}
} |
I wrote this suggestion in the matching issue:
@densogiaichned It seems more or less that is what your pseudo-code is doing. @densogiaichned I guess the version 3.3.0.0 is installed together with the 4024 XAE? It seems the version 3.2.0.0 is what is referenced from the project, which was probably the latest version I happened to have when I started TcUnit-Runner (and that was probably done on a computer with 4022.x). What happens if we include the 3.3.0.0 DLL, and run TcUnit-Runner on a machine with only the XAE for 4020.x or 4022.x? |
Linking this to #25, to have an issue for keeping history/track of why a PR was done (so I can use it in the release notes). |
The dll version was indeed my biggest concern regarding backwards compatibility. If we ship it with TcRunner we need to check if the license allows it. Or we need to find a way to detect what is installed and disable this feature if 3.3.0.0 isn't found. Regarding the older XAE versions. I haven't tested it yet with < 4024.0, but with the above psudo-code I don't see any extra benefit unless we display a specific message to inform the user he is using an older version. Either way, 3 things can happen:
In all these cases TcRunner will inform the user that it can't set the variant. If I was the user I would open the project to check if the variant is there. If it's not (because it's not configured/ or not supported), the user knows the problem is not with TcRunner but with the project itself. |
Makes total sense. But I guess it would still not work to run the project on a 4020 or 4022-machine if we use |
Also as @Beidendorfer noted, what happens if we load a project that has at least 2 variants, but none of them are selected? |
I have been using the old TcRunner with projects with variants without problems. TwinCat remembers the last used variant and keeps using it. One variant is also always the saved one (see: infosys I assume if it's the first time it selects that one. But I never experience a case where it failed because it wasn't defined. Yesterday I tried to figure out where it stores the last used variant. I saw that every time you run the new TcRunner it flags the used variant in the project file with some tag, but reverting this and running it again without specifying the variant doesn't seems to have effect (= it still runs the last used variant). It looks like it is stored outside the project. What could make sense is that every target remembers with variant last was used, but I don't have confirmation of that. |
I tried running it on a machine with 3.1.4022.4 / 3.1.4022.22 installed, and as expected I got this message because TCatSysManagerLib 3.3.0.0 isn't available:
Does someone knows how we could detect and change between available dll's? |
Hello I like the variants manager. Do you use the Variant Manager for different I/O´s or also for PLC Code? I just want to tell you one more experience with the Variant Manager. I plan to test different programs with different versions on my test server. Here I could imagine that there are problems if the last saved variant is not in the project. If you want me to test something else let me know. maybe an idee: If the TC Version is >= 4024.0 and the Option variant in TC Runner is != Null. Then we can call a Methode in the Automation Interface with |
@Hopperpop |
@densogiaichned The problem is that we would have to investigate the licensing issues. |
…and newer for variants
I made a version that first check the used twincat version and only uses (On a side note: I haven't used C# before, I'm just learning on the fly. I recommend that someone reviews the code for rookie mistakes. For example: Do I need to close any references?) |
@Hopperpop Thank you for your commits! I really like the update you've done to the BAT-script. Looks much cleaner now! I've reviewed your code and have only a few questions: Also, I saw that you changed the assembly from 3.2.0.0 to 3.3.0.0. I guess this means that a machine with 4024 is required to build the project now? Will it still run on a machine that only has 4020 or 4022 installed? (even though the assembly says 3.3.0.0)? |
I double checked @Hopperpop solution on a freshly installed 3.1.4020.10 and it works.
This does not work, because /* Select variant if provided as parameter
*/
if (!String.IsNullOrEmpty(Variant))
{
if (Utilities.CompareVersionStrings("3.1.4024.0", vsInstance.GetLoadedTcVersion()))
{
try
{
//Using newer version of ITcSysManager to be able to set variant
ITcSysManager14 sysManager = (ITcSysManager14)vsInstance.GetProject().Object;
sysManager.CurrentProjectVariant = Variant;
log.Info("Variant selected with name: " + Variant);
}
catch
{
log.Error("Unable to set variant: " + Variant + ". Please provide an existing variant from the project.");
CleanUpAndExitApplication(Constants.RETURN_FAILED_TO_SET_VARIANT);
}
}
else
{
log.Error("Variants are only supported from Tc3.1.4024.0 or higher.");
CleanUpAndExitApplication(Constants.RETURN_FAILED_TO_SET_VARIANT);
}
} If we would reference the newer version in Some options one could think of:
|
I was also able to run it on a system with only 4022 installed. I was thinking if it would be possible to use something like pragma's to detect the available libraries on the building machine and disable the variant support if the new version isn't there. Only downside is that there will be 2 release versions who will be hard to distinguished from each other, but you will be able to build it on all systems. @densogiaichned point seems valid. But I don't see the big benefit between what we have now and doing the cast trick. As both create a new sysManager object. It's just doing it in a different way. Or am I wrong? |
@Hopperpop you are right, doesn't make any difference.
|
@Hopperpop The usecase is simply that I want to be able to make sure that anyone that is running a version of TwinCAT that does not have variant management (so all 4020 and 4022), should still be able to do it using TcUnit-Runner. |
This project is archived. Replacement for it is in the works. |
Feature for setting a variant with an optional parameter -r (--Variant).
If a variant isn't provided, TwinCat uses the latest selected variant by default (stored outside the project?).
As ITcSysManager14 is used instead of ITcSysManager10, suggestion are welcome to keep it backwards compatible with older versions.