Forum Home › Forums › Understanding the Software › Displaying string instead of input
Tagged: counter, formula, input channels, string, Table
- This topic has 15 replies, 6 voices, and was last updated 2 years, 11 months ago by Mikhail.
-
AuthorPosts
-
November 9, 2017 at 3:53 pm #2784hybridParticipant
Hi there,
So I’ve got modbus device input set up and displaying in a table. Is it possible for a string to be displayed instead of the integer input and have that string change depending on the input.
i.e.
input X
x = 1 , display “Running”
x = 2 , display “Not running”
etcIs this don’t in formula or elsewhere ? Could you give me an example.
Thanks
November 9, 2017 at 7:07 pm #2788MikhailModeratorHi,
Yes.Option 1.
Use “Enum text” format of input channel and choose a unit with a list of values.Option 2.
Use “ASCII text” or “Unicode text” format of input channel and create a special formula, for example: EncodeAscii(Cnl < 2 ? "Running" : "Not Running")November 13, 2017 at 11:07 am #2803hybridParticipantPerfect, option 1 did it. Thanks.
I presume if I have an list of options greater that 100 chcaracters then I must use option 2 yes ?
November 13, 2017 at 1:18 pm #2806MikhailModeratorDefinitely.
January 19, 2019 at 3:16 pm #4920aluy069ParticipantHow it can be done using Option 1
My text are lest than 20 characters
Can you give me directions to doit
regards
January 20, 2019 at 1:24 pm #4922MikhailModerator1. Open Administrator.
2. Open the Units table, and create your row, for example,
Running; Not Running
3. Create an input channel.
4. Set the Format field to “Enum text”.
5. Set the Unit field to your the unit you created on step 2.February 4, 2021 at 7:36 pm #8245AshashashParticipantHello,
I tried to use option 2,
entered EncodeAscii(Cnl < 2 ? “Running” : “Not Running”) in formula,
but received server error. What I am doing wrong?Line 514, column 1: error CS1520: Method must have a return type
Line 514, column 19: error CS1031: Type expectedFebruary 5, 2021 at 2:17 pm #8248MikhailModeratorHello,
Please provide screenshots of all changes you made related to this issue.February 5, 2021 at 7:08 pm #8253AshashashParticipantI only tried to create a formula:
- This reply was modified 3 years, 8 months ago by Mikhail.
February 7, 2021 at 6:51 am #8263MikhailModeratorThanks. Such kind of formula works for input channel, but not for the formula table.
Formula for a channel:
EncodeAscii(Cnl < 2 ? "Running" : "Not Running")
Formula for the Formulas table:
public double MyFunc() { return EncodeAscii(Cnl < 2 ? "Running" : "Not Running"); }
October 18, 2021 at 12:43 pm #9567AofTParticipantI have used the Formula in Testing,
public double MyFunc()
{
return EncodeAscii(Cnl == 2 ? “1234567890” : “I need 20 Letters”);but only get the first 8 Numbers in the output to a Table. ie 12345678 and not the Full word (1234567890), why would this happen..?
Electrician by trade and new to coding, Thanks in advance.October 19, 2021 at 12:56 pm #9571MikhailModeratorbut only get the first 8 Numbers
Input channels has 8 byte data size internally. That’s why string is truncated.
If you have a set of predefined strings, you could use enumerations. The string values are entered in the Units table, and then the unit is specified for an input channel. Check Off-On unit for example. Input channel format should be set to enumeration.
October 20, 2021 at 7:32 am #9572AofTParticipantHello Mikhail,
I have used the enumerations previously. This particular Tag is an Alarm word being sent from a PLC (0-35 Different Alarm States) hence why I tried the “Formula” approach so I could list all 35 Alarm descriptions depending on the Alarm Word Value. (Too many characters for enumerations)
Do you have any other suggestion for Displaying this Alarm / Event.?
Thanks in advance.October 20, 2021 at 12:14 pm #9575MikhailModeratorHi,
Despite the inconvenience, I suggest using enumerations. You could prepare the text in another text editor and then insert into the grid cell.In v6 it will be allowed to start each enumeration value from a new line with 1000 chars total limit. So, working with enumerations will be simplified in the future.
October 25, 2021 at 9:52 am #9586Isnan AParticipantHi Mikhail,
I made a toggle button without connecting to device and line (only input and output channels). Is it possible?
I have tried but it doesn’t work
this my input and output channel :
https://i.ibb.co/sKzh6dH/image.png
https://i.ibb.co/y8ZbpTW/image.pngThanks
-
AuthorPosts
- You must be logged in to reply to this topic.