Forum Home › Forums › Understanding the Software › Using Formulas › Questions regarding formular
- This topic has 9 replies, 2 voices, and was last updated 3 years, 4 months ago by Mikhail.
-
AuthorPosts
-
November 27, 2020 at 3:52 pm #7607zzzParticipant
Hi there ,
I am trying out RapidScada in my recent project. I have the following question regarding formula.
I saw examples in RU forum defining global variable before the user defined function body in order to retain state information between each execution.. My question is:
– Are these variables shared between input channels, among all user defined functions ?
– Does input and output Channel also share the same scope to access them ?
– Does Calculated Real and Real makes any difference in this aspect ?– Is it possible to retrieve channel properties e.g Object/Device Name/ID by CnlNum, or simply current channel’s such properties ?
November 28, 2020 at 7:35 am #7608MikhailModeratorHi,
– Are these variables shared between input channels, among all user defined functions ?
Yes. You can see the result file C:\SCADA\ScadaServer\Log\CalcEngine.cs
– Does input and output Channel also share the same scope to access them ?
Yes.
– Does Calculated Real and Real makes any difference in this aspect ?
The difference is WHEN the channel formula is calculated. For Real channel – only when a value is received from a device. For Calculated channel – permanently.
– Is it possible to retrieve channel properties e.g Object/Device Name/ID by CnlNum, or simply current channel’s such properties ?
No. If you need channel properties, you should develop a module for the Server app.
November 29, 2020 at 3:35 pm #7610zzzParticipantHi MikHal,
> Yes. You can see the result file C:\SCADA\ScadaServer\Log\CalcEngine.cs
Thank you, that’s very clear.
Some more questions:
– Is it possible to return an empty value (–) ?
Since “–” and NaN are displayed differently on data table.– Is it possible to make a channel [Now Only] ?
Making the channel data only appear in formula and Now table (for debug). But not shown in minute/hour archive.– Can you add code page option for “binary” type in Automatic Control plugin ?
CJK strings got messed up with the current default setup. Or maybe provide a way to pass the specified string to output channel UDF for decoding?– Can you not grey out the “Copy value or data” in event trigger to make passing event data possible ? though Am not quite sure what is event data,
e.g. for a event {Name:”Changed”, NewValue:1, CnlName:”State”}, is the event data “1”, or “Cahnged: 1” ?Thanks.
November 30, 2020 at 1:36 pm #7615MikhailModeratorHi,
– Is it possible to return an empty value (–) ?
If your formula returns double.Nan, channel status is set automatically to 0 and you will see —.
Making the channel data only appear in formula and Now table (for debug). But not shown in minute/hour archive.
You should create an input channel and set Active = false when it’s not needed. I debug complex formulas in Visual Studio. I can provide more info about it, if needed.
– Can you add code page option for “binary” type in Automatic Control plugin ?
If you need to modify a string, do it in the formula of an output channel.
Can you not grey out the “Copy value or data” in event trigger to make passing event data possible ?
I’ve wrote this as a suggestion. Thank you. If you need this feature in time, it might be a commercial development.
December 4, 2020 at 6:29 am #7646zzzParticipantHi Mikhail,
Regarding the Auto Control encoding issue. I guess I didn’t make the problem clear. After string is entered into textbox in AutoControl. AC send the encoded byte array to UDF in output channel.
- This reply was modified 3 years, 4 months ago by zzz.
December 4, 2020 at 6:30 am #7648zzzParticipantI am guessing AC is not using Unicode code page to encode the string, this make double-byte characters (e.g. C J K characters) cause error (unable to encode using that code-page -> Command Canceled) or encoded into garbage bytes that can’t be decoded using the correct codepage.
The solution I can think of is either
1. Use unicode e.g. UTF8 to encode all string, which can handle most doublebyte characters.
UDF can re-encode them by GetStr then GetBytes using the code-page of their choice.
Or provide a option to encode by UTF8, if Unicode as default code page is inconvenient.December 4, 2020 at 6:30 am #7649zzzParticipant2. Let user select a codepage for the text they entered in AC.
The current implementation doesn’t work for me. Since the string either can’t be encoded and cause Cmd Canceled or U DF receives garbage bytes that can’t be re-encoded into the correct bytes.
December 4, 2020 at 6:32 am #7650zzzParticipantWeird, I can’t post them as one reply.
It always tell me the you look like spam 🙁December 4, 2020 at 1:53 pm #7663MikhailModeratorIt always tell me the you look like spam
The is a protection plugin in the forum. The used rules like a back box. Without the plugin, there would be plenty of spam messages.
December 4, 2020 at 1:54 pm #7664 -
AuthorPosts
- You must be logged in to reply to this topic.