Output command value

Forum Home Forums Understanding the Software Using Formulas Output command value

This topic contains 14 replies, has 4 voices, and was last updated by Mikhail Mikhail 1 week, 6 days ago.

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #98
    Avatar
    teleco
    Participant

    Hello,

    I would like write the next script toma formula:

    public int Formula(double commandValue)
    {
    int a;
    switch(commandValue)
    {
    //case “Off”
    case 1:
    a=0;
    break;

    //case “Execute”
    case 4:
    a=10;
    break;

    }
    return a;
    }

    Is possible write a formula that sends a value command depending on the command selected from the list?

    #99
    Mikhail
    Mikhail
    Moderator

    Yes, it’s possible. You need to:
    1. Add the list of command values into Command values table using SCADA-Administrator.
    2. Add an output channel of Standard type. Select your list in Command values field of the output channel.
    3. Create a formula and specify it for the output channel.
    4. When you send a command the formula converts the given index of list value to the new value. Pay the attention that the list is indexed starting from 0.

    #157
    Avatar
    teleco
    Participant

    I have defined an output channel and I have specified “Off – On” in “Command values” field. I need to send an 0 or 1 to the “Command number” indicated, but when I select Off or On in SCADA-Web, it doesn´t send any of these values.

    Which kind of formula do I have to use in order to send an 1 selecting On and to send 0 selecting Off. How can I make the relationship 1-On and 0-Off?

    In order to make some checking, when I send a command with the SCADA-Server Generator, the Stats log says:

    Command 0x06 (command) is received from the client…

    The answer is the same selecting either 0 or 1.

    I don´t know how to proceed.

    #159
    Mikhail
    Mikhail
    Moderator

    Hello,
    No formula is needed for sending Off and On.
    Have you got a message “The command is in the queue for execution” from SCADA-Web?
    Probably you didn’t click Execute button after selecting command value.
    You can change command radio buttons to buttons in this web form using SCADA-Web Configurator (Simple commands sending checkbox).

    #791
    Avatar
    babeshkin
    Participant

    Hello Mikhail,
    (yesterday you helped me to output 0x10 type of command)
    I have the same problem:
    In communicator I created command for Holding registers (4x) with multiple command option.
    When I use binary type for command output in SCADA-Administrator for the my command channel it’s possible to put any value in Web-browser and command sends. This I also checked with Modbus Tracer.
    But when I use Standard type for command and put in formula any value (with option use formula) the command outputted with zero value (I check it in Modbus Tracer). But in event list in Web-browser and in on-line log of SCADA-Communicator I see that the command was outputted with right value I set before.

    #792
    Mikhail
    Mikhail
    Moderator

    Hello,

    When you use Multiple Modbus command with Standard type of output channel, its value transformed using BitConverter.GetBytes(cmd.CmdVal) method. Where CmdVal is a value of double type. The result of this conversion is unpredictable for normal guy.

    Describe your business case and I could advice you the simplest way to implement it.

    #794
    Avatar
    babeshkin
    Participant

    Mikhail,
    С наступающим Новым Годом или уже с Новым Годом!

    I have very simple task:
    User pushes button and see conformation window for command output.
    In command conformation window user just puts password and pushes OK. The write command must be following: 01 10 00 64 00 01 02 38 08 i.e. data to be transmitted equal to 38 08.

    #796
    Mikhail
    Mikhail
    Moderator

    Hi,

    Thanks ) Happy New Year for you!

    I think the most clear way is using Binary type of the output channel. The formula of the channel should return array of bytes: new byte[] {0x38, 0x08}
    May be I’ve made a mistake in this formula, I just tried to show the idea.

    #801
    Avatar
    babeshkin
    Participant

    Hello, Mikhail again!
    Your formula is correct, I checked it.
    I put your formula directly to SCADA-administrator control channel in formula column and change command type to binary type also. But in Web-browser I still have annoying command dialog which requires to put something in the text-box for command value…
    Is that possible to make custom dialog window for commands or change it somehow in order to avoid putting the command value?

    #802
    Mikhail
    Mikhail
    Moderator

    Hi,
    To avoid setting a command value you can create an output channel with Standard command type, Execute command value and the following formula: BitConverter.ToDouble(new byte[]{0x38,0x08,0,0,0,0,0,0})
    If my formula contains error, please let me know.

    #803
    Avatar
    babeshkin
    Participant

    Perfect! Thank you, Mikhail!
    You forgot to put in formula startIndex parameter:
    BitConverter.ToDouble(byte[] value, int startIndex)

    Now everything looks OK.

    #6069
    Avatar
    calebishaya
    Participant

    Hello Mikhail,

    i have a challenge and i believe the solution is related to “BitConverter.GetBytes(cmd.CmdVal) method”.

    My challenge:
    I have a modbus device that connect through an RTU with GPRS to Rapid scada. i have been able to connect it successfully.

    For receiving data:
    On the modbus device, the register i poll is of 4-bytes. the HMI of the modbus device indicates 15.000 but rapid scada shows 15000 (which is equivalent to 00-00-3A-98 in HEX), so i use a formula of CnlVal/1000 to get 15.000.
    The device template, data type i selected for this input is int(4-byte).

    For sending data:
    if i input 15, the modbus device receives no data

    if i input 15000, the modbus device receives the data as 15.000 which is actually what i want to send, but what i want to input is 15 and not 15000.

    i tried using the formula of CmdVal*1000 but its not successfull.
    The device template, data type i selected for this command is int(4-byte)

    What i need is this: i need a formula that will convert 15 to 15000 in an output channel. if the solution is related to “BitConverter.GetBytes(cmd.CmdVal) method”, please, how do i implement this method to achieve my desired result? i don’t really understand C#.

    Thanks for your clear advice…

    #6070
    Mikhail
    Mikhail
    Moderator

    Hi,

    CmdVal * 1000 is a correct formula for an output channel. What is the issue with it?

    #6071
    Avatar
    calebishaya
    Participant

    Hello,

    I checked it again, i realised the formula i used before was Cmd*1000 and not CmdVal*1000, i thought they were the same thing.

    Its working fine now. Thanks

    #6075
    Mikhail
    Mikhail
    Moderator

    Cmd and CmdVal – the both are correct and mean the same.

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic.