Seeq Team Shamus Cunningham Posted July 12, 2021 Seeq Team Share Posted July 12, 2021 A generally interest question I want to document this morning Quote I have a signal and I want to know how long it has been since the last sample has been recorded in the historian Step 1 - Create a condition from the last sample till "Now" $caps = $MySignal.toCapsules() $timeSinceSample = past().subtract($caps) $timeSinceSample Step 2 - Create a Scorecard to Capture the duration of the condition created in Step 1 Make sure the Maximum Capsule Duration is longer than the longest gap you would expect in your signal. In this example it is 180 days 1 Link to comment Share on other sites More sharing options...
Yanmin Xu Posted July 13, 2021 Share Posted July 13, 2021 Hi Shamus, If I understand correctly, is this used to calculate deltaT of the samples in a signal? Lets say we have a signal A. Will this formula give us the new signal B? t A B t1 a1 0 t2 a2 t2-t1 t3 a3 t3-t2 t4 a4 t4-t3 I tried on my end, but error shows like this. 1 Link to comment Share on other sites More sharing options...
Seeq Team Shamus Cunningham Posted July 13, 2021 Author Seeq Team Share Posted July 13, 2021 The formula above is only focused on getting the single value of the time period between the very last sample and "Now". It uses the past() operator which was added in Seeq Version 51 so the error you are seeing is because you are probably on an earlier version. On your separate question about a signal that represents the time since the last sample this formula will give you a continuous signal that calculates things are you outlined in your table. You can replace the durationkey() parameter with either startkey() or endkey() depending on if you want the time between samples to be plotted at the beginning or end of the interval. $CapsEachSample = $signal.toCapsules() //create a capsule for the time between each sample in the orignal signal $CapsEachSample.aggregate(totalduration(),$CapsEachSample,durationkey()) .convertUnits("min") //convert the duration of the capsules into their own signal Link to comment Share on other sites More sharing options...
Yanmin Xu Posted July 14, 2021 Share Posted July 14, 2021 Hi Shamus! Thank you very much for your explanation! 😀 Link to comment Share on other sites More sharing options...
Seeq Team Shamus Cunningham Posted July 20, 2021 Author Seeq Team Share Posted July 20, 2021 Final variation on this theme How do I calculates a running time since the last sample in my signal $cond = $VariableSampleRateSignal.toCondition().setMaximumDuration(30d) $cond.timeSince(1min) Link to comment Share on other sites More sharing options...
Yanmin Xu Posted July 27, 2021 Share Posted July 27, 2021 (edited) Hi Shamus, I have another question. I have a Rate signal (blue curve). My goal is to create a Volume signal (integral of the rate) starting from 05/01/2021. Ideally it would be similar as the red curve. I think the key is to create a series of capsules with increasing duration. (1st capsule has duration of 1 day, 2nd capsule has 2 days etc..) But I couldn't figure out how to do it. Is there any way to solve this problem? Thanks, Yanmin Edited July 27, 2021 by Yanmin Xu Link to comment Share on other sites More sharing options...
Seeq Team Shamus Cunningham Posted July 27, 2021 Author Seeq Team Share Posted July 27, 2021 Yasmin, This should be pretty straight forward using the integral function in formula Step 1 - Create a condition that marks the start and end time for when you want to calculate the integral. This could be done with a value search or manual condition Step 2 - Use the integral function to calculate the new signal $signal.integral($condition.removeLongerThan(5d)).convertUnits('kWh') 1 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