I'm experiencing some issues with setting modeling scope and creating logic behavior on TxDevices.
With a TxDevice called Device, and a TxPlcLogicBehavior called plb, I'm running the following lines:
Device.SetModelingScope(); plb = Device.CreateLogicBehavior(new TxPlcLogicBehaviorCreationData("Actions"));
After the first line, I would expect either that the modeling scope would be set, or an exception raised, which does not always appear to be the case. With the study I was using for development it worked, but in a subsequent study for each of the devices, checking Device.IsOpenForModeling returns false for every device.
Furthermore, after the second line, I would have expected either that the device would have a logic behaviour attached, or an exception should be raised. Again this appears not to always be the case, this time on a device-by-deice basis rather than a study-by-study basis. On investigation it appears that if Device.CanBeModified is false, CreateLogicBehavior fails but does not give any indication that it has done (i.e. no exception).
Any pointers as to what it is about the study that causes SetModelingScope it be ineffective would be appreciated.
After you have set the device in the modeling you can check the property IsOpenForModeling to verify, that the device really opened for modeling.
Yes, that is what I was doing, but I'd like to know why it sometimes works and sometimes does not, and what needs to be done to get it to work.