String dynamic text change according input channel value

Forum Home Forums Understanding the Software Using Formulas String dynamic text change according input channel value

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #5761
    ns.fariz
    Participant

    Hi Mikhail,

    I have one input channel for several state machine condition. So if modbus read 5,i want dynamic text show “manual”, and when modbus read 4 it will show “auto”, if it read 3 it will show stop. How can I achieve that?

    Thanks,

    #5763
    Mikhail
    Moderator

    Hi,

    1. Create a new record in the Units table with Sign =
    -; Stop; Manual; Auto

    See “No; Yes” for example.

    2. Create a new formula in the Furmulas table. Something like that:

    function double MyFunc()
    {
      switch ((int)Cnl)
      {
        case 3:
          return 1;
        case 4:
          return 2;
        case 5:
          return 3;
        default:
          return 0;
      }
    }

    3. For your input channel set formula to MyFunc() and set unit to the unit you created.

    #5770
    ns.fariz
    Participant

    Hi Mikhail,
    I try to input your given formula, but my server turn error.

    function double MyFunc()
    {
     switch ((int)Cnl)
     {
      case 3:
       return 1;
      case 4:
       return 2;
      case 5:
       return 3;
      default:
       return 0;
     }
    }

    Is there something wrong?

    #5776
    Mikhail
    Moderator

    Hi,

    Please find the error details in C:\SCADA\ScadaServer\Log\ScadaServerSvc.log and copy the error message here.

    #5777
    ns.fariz
    Participant

    Hi Mikhail,
    Here is error log

    2019-08-01 08:53:56 <LAPTOPKU><SYSTEM><ACT> ScadaServerService 5.1.2.0 is started
    2019-08-01 08:53:57 <LAPTOPKU><SYSTEM><ACT> Check the existence of the data directories is completed successfully
    2019-08-01 08:53:57 <LAPTOPKU><SYSTEM><ACT> Check the existence of the configuration database files is completed successfully
    2019-08-01 08:53:57 <LAPTOPKU><SYSTEM><ACT> Input channels are read from the configuration database. Active channel count: 51
    2019-08-01 08:53:57 <LAPTOPKU><SYSTEM><ACT> Ouput channels are read from the configuration database
    2019-08-01 08:53:57 <LAPTOPKU><SYSTEM><ACT> Users are read from the configuration database
    2019-08-01 08:53:57 <LAPTOPKU><SYSTEM><ACT> Formulas are read from the configuration database
    2019-08-01 08:53:57 <LAPTOPKU><SYSTEM><ERR> Error compiling the source code of the formulas: 
    Line 514, column 10: error CS1519: Invalid token 'double' in class, struct, or interface member declaration
    See the file C:\SCADA\ScadaServer\Log\CalcEngine.cs with the source code
    2019-08-01 08:53:57 <LAPTOPKU><SYSTEM><ERR> Normal program execution is impossible
    #5778
    manjey73
    Participant

    Line 514, column 10:
    See the file C:\SCADA\ScadaServer\Log\CalcEngine.cs with the source code

    See the file for this line and the error symbol

    #5781
    Mikhail
    Moderator

    Hi,

    function double MyFunc()

    #5786
    ns.fariz
    Participant

    Hi Mikhail,
    Now no error again, but its only change the number. So, if the value is 3,it will show 1-;. I made new Unit named Control. With Sign -;Stop Mode;Auto Mode;Manual Mode;Test On Load
    Enable formula MyFunc() and choose unit Control. I choose dynamic text with unit.
    Am I miss something?

    #5787
    Mikhail
    Moderator

    Hi,

    Am I miss something?

    May be a little bit. Please provide links to screenshots of the settings you made. And I will check.

    #5788
    Mikhail
    Moderator

    Make sure that you set format of the input channel to Enum text.

    #5791
    ns.fariz
    Participant

    Hi Mikhail,
    It’s work after change to enum text.

    Thanks

    #13609
    IT0508
    Participant

    Hi Mikhail,
    I have a channel where I am receiving two values, 0 and 1, and I would like to display the words “normal” and “low”. Therefore, as you wrote, I created the sign -; normal; low; and I made the following formula:`double MyFunc()
    {
    switch ((int)Cnl)
    {
    case 0:
    return 1;
    case 1:
    return 2;
    default:
    return 0;
    }
    }`
    I set the channel to “calculated real”, inserted into the formula field “MyFunc()”, formatted “enum text” and the unit I created as the unit. The problem is that on the server the words alternate regularly displaying – then normal then low and so on ad infinitum even though the channel value is always 0.
    Some screenshots: https://ibb.co/ZMntnjj https://ibb.co/M6FDLrS

    #13610
    Mikhail
    Moderator

    Hi,
    In this case, you don’t need a formula. In Rapid SCADA 5, it enough to set Format = Enum text, and appropriate Unit. For example, see Off-On in HelloWorld project.

    #13662
    IT0508
    Participant

    Hi Mikhail,
    I did as you said following the HelloWorld project settings but now the word shown does not correspond to the input status, it does not change and appears silver.
    Does Scada automatically associate the value 0 with the first word inserted in the units and 1 with the second? I can’t understand how it works…

    #13669
    Mikhail
    Moderator

    Hi,
    Screenshots of the settings would help to solve the issue.

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