Forum Replies Created
-
AuthorPosts
-
manjey73Participantand if the value is 5 but you read 10, will there be an error or just zeros? and how are the events arranged? are these consistent occurrences? how will you identify them?
manjey73ParticipantThe division command for the input channel looks like this Cnl/1000
manjey73ParticipantThe module does not support multi-channel like. Or no more than 2 in the 6th version. I haven’t watched it for a long time. You can create a Calculated channel for applying any scripts in which you will compare the required channels and only then apply the module to this channel.
manjey73Participant1. ModDiffCalculator – One of the options that solves this problem.
2. Channel 1, to save the total reading every hourEveryHour(() => Data(327))
(Channel 327 – Total Energy from device)
Channel 2 –EveryHour(() => Val(360) - PrevVal(360))(Difference. Channel 360 here is Channel 1)There may be different approaches.
manjey73ParticipantAs the author noted, the delay in hourly formulas can be useful, but here it is necessary to combine the minute with the hour, and this usefulness went sideways 🙂
manjey73ParticipantThe reason turned out to be that the HourStarted formula was triggered after 30 seconds, as the hour arrived, and EveryMin was triggered at 0 seconds. The delay in the HourStarted formula is useful in some cases. You can update the Scripts table in the Calendar entry to make it work.:EveryMin(() => HourStarted() ? 0 : Val() + 1)These changes will be included in the project template in the next release.-
This reply was modified 4 months, 1 week ago by
manjey73.
manjey73ParticipantHourStarted() is running with a delay. The revision of the formulas has apparently not yet been included in the release.
Use a translator if you need to understand.
manjey73Participantif you are using an enumeration, then add your own.
ONN: green; OFF:red
by analogy, or any other at your discretion
manjey73ParticipantSetVal(500.34) does not work, presumably because the Val() formula cannot display the channel value without a status. I also came across this. There is also the Data() formula, but I haven’t tried it yet, somehow it wasn’t necessary. It works a little differently, if I understood correctly.
You can change the values from the range directly in the channel formula, try using the combined CheckComm formulas inside the SetVal formula as shown above.If you plan to use formulas inside other formulas, make it a rule to convert to double yourself, even if returning bool is enough for you. Then it becomes possible.
manjey73ParticipantCheckComm – The multiplier formula
CheckComm1 – The formula is without using a multiplier, in fact, the multiplier is 1 if you use the first one
manjey73Participantpublic double CheckComm(double min, double max, double mult, string str = "" ) { if (Cmd < min || Cmd > max) throw new Exception($"The value must be within {min} - {max} {str}"); return Cmd*mult; } public double CheckComm1(double min, double max, string str = "" ) { if (Cmd < min || Cmd > max) throw new Exception($"The value must be within {min} - {max} {str}"); return Cmd; }You can also use formulas with verification to control the input parameters.
I’ve been making universal ones for myself here.The method of application in the output formula of the channel
Output channel
CheckComm(16, 32, 10, "degrees")Calculated/Output
SetVal(CnlNum, CheckComm(16, 32, 10, "degrees"))
manjey73ParticipantTry different options, as different channel processing scripts are required for different tasks.
manjey73ParticipantAn example of using formulas in Calculated channels
The Val() formula allows you to show the value after you enter it, but it will reset on reboots.
There is a formula that allows you to use the default value for reboots, suggested by Mikhail.// Set the default setpoint value. // For channels of the Calculated/output type public CnlData GetDefaultData(double val) { return Stat() > 0 ? Data() : NewData(val, 1); }
manjey73Participantyou need to use formulas in channels. the simplest is Val() for input and SetVal(CnlNum, Cmd) for output formulas.
well, there is also the possibility of using more complex formulas. The channel must be Calculated/Output
manjey73ParticipantStart with scripts in which you read or write to files, and the like. That is, some more complex scripts that you use.
-
This reply was modified 4 months, 1 week ago by
-
AuthorPosts