Search the Community
Showing results for tags 'reduce()'.
Use Case: Users are often interested in identifying when a particular process is operating in a specific mode, or when it is in transition between modes. When looking at these transition periods, you may want to know what the modes of operation were immediately before and after the transition. If you can assign the starting and ending modes during a transition period to each transition capsule, you can filter for specific types of transitions and get a better idea of what to expect during like transitions. Solution: For Versions R.21.0.43 + 1. Add a signal to your display that describes the mode of operation you are interested in. In this example I have added the Example Data > Cooling Tower 1 > Area A > Compressor Stage string signal. Other signals that this use case applies to may include: production grade code, equipment operating mode, signal for step in a sequential or batch process. 2. Next we can use Formula to create a new condition comprised of capsules each time our Compressor Stage signal changes value. These capsules will contain a new capsule property called 'StartModeEndMode' that represents the value of the compressor stage immediately before and immediately after the signal changed value, or transitioned. The formula syntax to achieve this is: //creates a condition for 1 minute of time encompassing 30 seconds on either side of a transition $Transition = $CompressorStage.toCondition().beforeStart(0.5min).afterStart(1min) //Assigns the mode on both sides of the step change to a concatenated string that is a property of the capsule. $Transition .transform( $cap -> $cap.setProperty('StartModeEndMode', $CompressorStage.toCondition() .toGroup($cap, CAPSULEBOUNDARY.INTERSECT) .reduce("", ($seq, $stepCap) -> $seq + $stepCap.getProperty('Value') //Changes the format of the stage names for more clear de-lineation as a property in the capsules pane. .replace('STAGE 1','-STAGE1-').replace('STAGE 2','-STAGE2-').replace('TRANSITION','-TRANSITION-').replace('OFF','-OFF-') ))) and the Output is: Note that we added the new property 'StartModeEndMode' to the Capsules Pane. 3. We can now filter this condition to look for specific transitions of interest. In this example, we are interested in every time our compressor went from a TRANSITION state to STAGE2. Use Formula and the filter() function with the following syntax to achieve this. //Create a new condition comprised only of capsules where the 'StartModeEndMode' property is equal to '-TRANSITION--STAGE2-' $ConditionCreatedInStep2.filter( $capsule -> $capsule.getProperty('StartModeEndMode').isEqualTo('-TRANSITION--STAGE2-')) and the Output is: 4. Now we are able to add other signals of interest to the display and switch to Capsule Time view to observe how those signals behave during these similar transition events.
Background In this Use Case, a user created a condition to identify when the compressor is running. During each Compressor Running capsule, the compressor operates in a variety of modes. The user would like a summary of the modes of operation for each capsule in the form of a new signal that reports all modes for each capsule (i.e. Transition;Stage 1;Transition;Stage 2;Transition, Stage 1;Transition). Method 1. The first step is to resample the string value to only have data points at the value changes. It's possible the signal is already sampled this way, but if it is not, use the following Formula syntax to create a "compressed" signal: $stringSignal.tocondition().setMaximumDuration(3d).transformToSamples($capsule -> sample($capsule.getStart(), $capsule.getProperty('Value')), 4d) 2. Now, you can create a signal that concatenates the string values during each capsule. This is achieved using the following Formula syntax: $compressorRunning.setmaximumduration(10d).transformToSamples($cap-> sample( $cap.getStart(), $compressedStringSignal.toGroup($cap).reduce("", ($s, $capsule) -> $s + $capsule.getvalue())), 7d).toStep()
Hi All, I'm generating 2 signals (say A and B) from a signal C.For first time step the value of A is constant. I calculate the value of B in current time step from current value of A and the value of C. Then for the next time step value of A is calculated based on value of B in previous time step and so on. How to achieve this in seeq. Thanks,