UNICO2 Posted January 27, 2017 Report Posted January 27, 2017 Hi All - I made a complex function that has used all 10 inputs, so I can't just add another input for this, I just need the name of the tag in the function (call it CBA bit or whatever it is called) that triggers a bad condition, and I need to post that tag name to a string (in a data table struct). I am just looking for the easiest way to get that info into the data table from inside the function without a string input so that I don't have to do it 240 times elsewhere, and I figure getting the tag name( which I know already) into a string would work best, if I can do it. I am using a bunch of UID-0016R's and they have addresses with Alias Names which seem to be strings too but this is in the function output. Any ideas how or any other options? Also, is it possible to see inside a function while in Online mode for troubleshooting - all I seem to be able to see is the inputs and outputs? Thanks!
Saragani Posted January 30, 2017 Report Posted January 30, 2017 Hi, No, you cannot convert the tag name into string. I've having hard time understanding why you need it, or why you have to repeat something 240 times.
UNICO2 Posted January 30, 2017 Author Report Posted January 30, 2017 Hi, 3 schedules for 80 different relays = 240 possible configurations that could be in conflict with one another. What I did was use an output for the function (I still had one left) and attached a string to that and used the string's power up default value as the error message and that seems to work. BTW, I was thinking more like in C# you could do something like this: string TagName = nameof(obj.Tag); So it might be an easy addition to the source code. Thanks.
Saragani Posted January 31, 2017 Report Posted January 31, 2017 Well, C# is a managed language with code that compiles at run time, and it is not Real-Time. On the other hand, the PLC must be real-time and the code is compiled to C++ and then to machine code. Furthermore, we allow having tag names with non-English characters and with spaces (which is not a valid variable name in c#, for example). When code is compiled, the tag names are compiled to a string with English characters only in the C++ code, and when it's compiled to machine code, it compiles to an absolute address, a value or a pointer (if for example, the value comes by ref in a UDFB input/output). 1
UNICO2 Posted January 31, 2017 Author Report Posted January 31, 2017 Ok, my point is that the tag string name could be added as a member of the tag structure or class or memory allocation or whatever it is, then maybe add a function like IP to string, it could be called Tag to string, any character that doesn't work disappears/not converted. The benefit would be in a UDFB you can do something once for troubleshooting or logging or alarms and not 100's of times. For example- how can I see the code inside the function in Online mode? My understanding is that I can only see the inputs and outputs in real time. With a Tag to string I could log the tag name and value to a file with a time stamp or iteration etc. Again I have 240 possible conditions. Right now I have to take the logic out of the function and put it somewhere else on the ladder and then change all the tag names just to troubleshoot that function code.
Saragani Posted February 1, 2017 Report Posted February 1, 2017 But the tag is not a structure. It's not like in c# where everything derives from Object. It's c++, so a INT8 consumes 1 byte exactly. converting the tag name to a string could be done on compile time, so we know which tags are passed to the " magic function", and we compile their name as a const, but it cannot be done in run-time, whereas you pass a different argument to a UDFB each time. The reason why you can't see the actual in/out/locals of a function is because each time you enter the function, it is called with different parameters, and the local tags are not allocated in the global area, but in the stack. When a function exists, the stack is used for the call of another function. However, we are currently working on a solution for watching locals inside a function. 2
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now