There is For loop where I am given as condition as CDM =0 To CDM <1440 ie. CDM is the variable which is starting from zero min to 1440 min in a day.
It will check for the value of input tag whether it is zero or not with if condition but I am able to do it for current day.
and sTomorrow variable i m creating string by sub 86400 sec(ie no of sec in Day) from MyBase.Exe time ie current time. Will get yesterday date in Tommarrow i made mistake in written. it should be yesterday date. instade of tomorrow day.
I have shortened the title of your questions to make it easier to read and clearer for others when performing search on the site, I hope you are OK with the new title!
From your example I would guess that you run your calculation once per day, is this right? ( I have seen: MyBase.ExeTime - 86400 , this is why I thought that).
Your approach is not bad, but there are easier approaches to do that: I would use the TimeEQ Method*:
PIACEPoint.TimeEQ Method : Finds the total time in seconds, within a specified time range, when archive values for the point are equal to a given value.
* Source: PI ACE Documentation, PIACEReference.chm. It is located in C:\Program Files (x86)\PIPC\ACE\Help or %pihome%\PIPC\ACE\Help
Then I would probably do something like this:
Public Overrides Sub ACECalculations() Dim today As Date = PIACEBIFunctions.ParseTime("*").LocalDate.Date Dim yesterday As Date = Today.AddDays(-1) ' Check how many seconds the value was 0 during the interval between yesterday and today Dim numSecondsValueIsZero = AvaiFac_InputTag.TimeEQ(yesterday, today, 0) ' if numSecondsValueIsZero=86400 then ' ' value was 0 the entire day ' end if ' ... the rest of your logic here End Sub
Note: for PIACEBIFunctions.ParseTime to compile properly, you will need to add a reference to PITimeServer (double click on "my project" in visual studio, then select References):
Its fine that you shortened the title .
And You are right that i run my calculation once in a day. ie (MyBase.ExeTime current time) and MyBase.ExeTime - 86400 is the yesterday time.
I made change that i want in code . Please check it. I commented the error that i m getting while debugging the code. Plz check and reply.
Public Overrides Sub ACECalculations() ' today value is #2-12-15# Dim today As Date = PIACEBIFunctions.ParseTime("*").LocalDate.Date Dim yesterday As Date = today.AddDays(-1) Dim numMinValueISZero As Integer Dim numSecondsValueIsZero As Integer 'but While debugging not able to see the value of yesterday it shows nothing but can see the value of today as #2-12-15#. 'not able to see the value of numSecondsValueIsZero 'I Convert Sec into Min 'But the value for AvaiFac_OutputTag.Value showing nothing means 'there may not be any value present for given condition 'it is showing an error in below line as Conversion from string "" to type 'Double' is not valid. numSecondsValueIsZero = AvaiFac_InputTag.TimeEQ(yesterday, today, 0) numMinValueISZero = numSecondsValueIsZero / 60 AvaiFac_OutputTag.Value = (24 - (numMinValueISZero / 60)) / 24 End Sub
1 of 1 people found this helpful
I am not certain why you are getting the error, I tested the code and it works on my side.
Try to check the stack trace of the error ans see if you can get more details.
Also, since you are only calculating a percentage you don't need to do all those calculations, the only thing you need to do is to divide per 86400 seconds (one day).
Public Overrides Sub ACECalculations() Dim today As Date = PIACEBIFunctions.ParseTime("*").LocalDate.Date Dim yesterday As Date = today.AddDays(-1) Dim percentageWhenValueIsZero As Integer Dim numSecondsValueIsZero As Double numSecondsValueIsZero = AvaiFac_OutputTag.TimeEQ(yesterday, today, 0) ' Get percentage (Gives a value between 0 and 1) percentageWhenValueIsZero = numSecondsValueIsZero / 86400 AvaiFac_OutputTag.Value = percentageWhenValueIsZero End Sub
I don't see anything wrong regarding the variable yesterday, did you step over the variable (F10) so it is assigned? the AddDays Method is part of the .Net Framework and I see no reason why it could not work.
OK, Thank You..It really help me a lot.
No problem Mayur, we are here to help.
I believe you could mark the answer that helped you the most as the correct answer, that helps other users to find information.
Thanks, and have a nice day.