AiKju Posted January 7, 2019 Share Posted January 7, 2019 Hi lots, Is there a functionality of "If...then...else" statements in formulars. Or is there at least a workaround? Thanks for your answer in advance! Link to comment Share on other sites More sharing options...
Administrators Lindsey.Wilcox Posted January 7, 2019 Administrators Share Posted January 7, 2019 Hi AiKju- There are a couple methods to accomplish this, both of which are summarized in our Knowledge Base. Take a look at these articles: 1. Using Boolean Signals to Replace IF Statements ( 2. Using Conditions and the Splice Function to Replace IF Statements If there's any additional information you can provide about your Use Case, we may be able to provide some more specific work steps. Let me know if you have any additional questions. Lindsey 1 Link to comment Share on other sites More sharing options...
AiKju Posted January 7, 2019 Author Share Posted January 7, 2019 Hi Lindsey, Thank you for your answer. Actually I am looking for this: Cn=max[0,Xn - Number + Cn-1] Dn=min[0,Xn - Number + Dn-1] These are rolling sums with kind of a reset button if Cn becomes smaller then 0 it stays 0 and if Dn becomes greater then 0 it stays 0. (You did ask ;-)). By the way the rolling sums should be per value and not per time capsule... Kai Link to comment Share on other sites More sharing options...
Administrators Lindsey.Wilcox Posted January 7, 2019 Administrators Share Posted January 7, 2019 Hi Aikju- To calculate the rolling sums, use the .runningSum() function in Formula. Note that you will be required to provide a condition over which to calculate the rolling sum; this could be calendar days, a production mode condition etc: Now that you have a signal calculating the rolling sum, a combination of Value Search and the .splice() function in Formula can be used to set the signal equal to 0. First, lets use Value Search to identify when the running sum is greater than zero: Before we can use the .splice() function in Formula, we need to create a 0 signal in Formula: Now, we can use the .splice() function in Formula to splice in the 0 signal whenever the Rolling Sum signal is greater than 0. Please let me know if this gets you the results that you need or if you have any additional questions. Lindsey Link to comment Share on other sites More sharing options...
Thorsten Vogt Posted January 17, 2019 Share Posted January 17, 2019 Hi Lindsey, I tried solving this by using the externalCalculation-Function of Seeq. I created a python script and modified the functions initialize and compute as followed: def initialize(self): self.sum = 0 pass def compute(self, key, samples_for_key): self.sum += samples_for_key[0] if self.sum < 0: self.sum = 0 return key, self.sum The script is called by using externalCalculation('CusumP.py:NUMERIC:M6CBe8UAQoSN',$d) However, when I am using this script I get the following error message on execution: Error getting data: Client data source exception: Error processing external calculation request: Script CusumP.py:NUMERIC:M6CBe8UAQoSN is not respecting the requirement to do only calculations that operate on data at a single key. Script needs to be changed. Exception: java.lang.RuntimeException at 'externalCalculation', line=1, column=1. To retry, use the button to the right. Why is this behaviour blocked by Seeq? Thorsten Link to comment Share on other sites More sharing options...
Administrators Teddy Posted January 18, 2019 Administrators Share Posted January 18, 2019 Thorsten, It looks as if the second part of your code requires summing values at different keys (timestamps). At this time Seeq can only pass data for external calculations one key at a time so functions like summing data over time aren't possible because you need more than one key. I recommend doing the summation in Seeq as Lindsey suggested. Regards, Teddy Link to comment Share on other sites More sharing options...
Bella A Posted August 31, 2020 Share Posted August 31, 2020 what if you have more than 2 conditions? For example, you have a valve opening positions of 1 - 5. And you would need to apply different equation for each opening. How would i set up the Boolean signal for them? Link to comment Share on other sites More sharing options...
Thorsten Vogt Posted August 31, 2020 Share Posted August 31, 2020 Hi Bella, you can chain the splice command multiple times: You may also have a look at this post: Hope this helps. Regards, Thorsten Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now