Displaying string instead of input

Forum Home Forums Understanding the Software Displaying string instead of input

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #2784
    hybrid
    Participant

    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”
    etc

    Is this don’t in formula or elsewhere ? Could you give me an example.

    Thanks

    #2788
    Mikhail
    Moderator

    Hi,
    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")

    #2803
    hybrid
    Participant

    Perfect, 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 ?

    #2806
    Mikhail
    Moderator

    Definitely.

    #4920
    aluy069
    Participant

    How it can be done using Option 1

    My text are lest than 20 characters

    Can you give me directions to doit

    regards

    #4922
    Mikhail
    Moderator

    1. 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.

    #8245
    Ashashash
    Participant

    Hello,

    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 expected

    #8248
    Mikhail
    Moderator

    Hello,
    Please provide screenshots of all changes you made related to this issue.

    #8253
    Ashashash
    Participant

    I only tried to create a formula:

    https://ibb.co/qj0067F

    • This reply was modified 3 years, 9 months ago by Mikhail.
    #8263
    Mikhail
    Moderator

    Thanks. 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");
    }
    #9567
    AofT
    Participant

    I 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.

    #9571
    Mikhail
    Moderator

    but 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.

    #9572
    AofT
    Participant

    Hello 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.

    #9575
    Mikhail
    Moderator

    Hi,
    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.

    #9586
    Isnan A
    Participant

    Hi 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.png

    Thanks

Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.