Calculation of input data & storage to VChannel


asaikk

Recommended Posts

Its actually similar to your recent inquiry concerning hourly logging files and a technique used in a number of similar inquiries on this forum when you want to do something on the hour, day, week, etc. But first, I'd recommend using a Test channel instead of a V channel. Make it device type "Test", A to D, Timing = 0. Call it MyChannelAverage for this exercise. The script would be:

if (formatDateTime("%H", myChannel.time[0])  != formatDateTime("%H", myChannel.time[1]))
   private endtime = myChannel.time[1]
   private starttime = endtime - (endtime % 3600)
   private themean = mean(myChannel[starttime, endtime]
   themean.time = endtime
   myChannelAverage.addValue(themean)
endif

This should go in the Event for myChannel, not in a sequence.

Link to comment
Share on other sites

Concerning the sequence above, would you teach me the two questions below?

1)When executing the sequence, I think new channel "myChannelAverage" should be created.

If it is right, then how the items (I/O Type, Chn #, Timing, etc) of the "myChannelAverage" should be set?

2)Does this sequence calculate the hourly mean every minute?

Thanks in advance

Link to comment
Share on other sites

Would you give me the explanation of the meaning of the line below, which is in the parentheses of the "if" sentence?

formatDateTime("%H", myChannel.time[0]) != formatDateTime("%H", myChannel.time[1])

especilly,

!=

Thank you in advance.

Link to comment
Share on other sites

!= is the not equals operator. Its the same as C and JavaScript and Java and a number of other languages. Please review section 4.12 of the user's guide for all the operators and functions.

The expression itself is simply looking at the current hour of the most recent data point and comparing it to the hour of the second most recent data point. If they are not equal, then the hour has turned over.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.