Jump to content

AiKju
Go to solution Solved by Lindsey.Wilcox,

Recommended Posts

  • Seeq Team
  • Solution

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

 

  • Thanks 1
Link to comment
Share on other sites

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

  • Seeq Team

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:

image.png

 

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:

image.png

Before we can use the .splice() function in Formula, we need to create a 0 signal in Formula:

image.png

Now, we can use the .splice() function in Formula to splice in the 0 signal whenever the Rolling Sum signal is greater than 0.

image.png

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

  • 2 weeks later...

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

  • Administrators

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

  • 1 year later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...