Forum Home › Forums › Understanding the Software › Using Formulas › String dynamic text change according input channel value
- This topic has 17 replies, 4 voices, and was last updated 9 months, 3 weeks ago by IT0508.
-
AuthorPosts
-
July 28, 2019 at 10:26 am #5761ns.farizParticipant
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,
July 28, 2019 at 12:00 pm #5763MikhailModeratorHi,
1. Create a new record in the Units table with Sign =
-; Stop; Manual; AutoSee “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.
July 30, 2019 at 9:37 pm #5770ns.farizParticipantHi 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?
July 31, 2019 at 11:03 am #5776MikhailModeratorHi,
Please find the error details in C:\SCADA\ScadaServer\Log\ScadaServerSvc.log and copy the error message here.
August 1, 2019 at 1:39 am #5777ns.farizParticipantHi Mikhail,
Here is error log2019-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
August 1, 2019 at 6:42 am #5778manjey73ParticipantLine 514, column 10:
See the file C:\SCADA\ScadaServer\Log\CalcEngine.cs with the source codeSee the file for this line and the error symbol
August 1, 2019 at 2:45 pm #5781MikhailModeratorHi,
functiondouble MyFunc()August 2, 2019 at 9:40 pm #5786ns.farizParticipantHi 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?August 3, 2019 at 8:05 am #5787MikhailModeratorHi,
Am I miss something?
May be a little bit. Please provide links to screenshots of the settings you made. And I will check.
August 3, 2019 at 8:08 am #5788MikhailModeratorMake sure that you set format of the input channel to Enum text.
August 5, 2019 at 9:08 pm #5791ns.farizParticipantHi Mikhail,
It’s work after change to enum text.Thanks
November 11, 2023 at 4:11 pm #13609IT0508ParticipantHi 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/M6FDLrSNovember 12, 2023 at 7:24 am #13610MikhailModeratorHi,
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.November 17, 2023 at 7:17 pm #13662IT0508ParticipantHi 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…November 20, 2023 at 11:34 am #13669MikhailModeratorHi,
Screenshots of the settings would help to solve the issue. -
AuthorPosts
- You must be logged in to reply to this topic.