asaikk Posted February 12, 2012 Share Posted February 12, 2012 What would be the procedure and sequence to process below 1) & 2) 1)Calculate the hourly average of input data from "MyChannel" 2)Store the average data in the VChannel named "MyVChannel" Thanks in advance Link to comment Share on other sites More sharing options...
AzeoTech Posted February 13, 2012 Share Posted February 13, 2012 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 More sharing options...
asaikk Posted February 13, 2012 Author Share Posted February 13, 2012 Thank you for the advice. However the program installed with the event (which I attach on this reply) does not work. I would appreciate if you would check it. Thanks in advance. test_HourlyLog_Average.ctl Link to comment Share on other sites More sharing options...
asaikk Posted February 13, 2012 Author Share Posted February 13, 2012 Please replace the attached file with this one, as the former one may not reflect all the change I made, though this one does not work either. test_HourlyLog_Average.ctl Link to comment Share on other sites More sharing options...
AzeoTech Posted February 13, 2012 Share Posted February 13, 2012 I'm sorry. I seem to be off this week, putting all sorts of typos in the forum script. Anyhow, you can't have a variable called "mean" because its a reserved word for the function mean() that we actually use. Anyhow, I've corrected the post above. Link to comment Share on other sites More sharing options...
asaikk Posted February 15, 2012 Author Share Posted February 15, 2012 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 More sharing options...
AzeoTech Posted February 15, 2012 Share Posted February 15, 2012 1) No, you have to create MyChannelAverage yourself in the Channel Table. 2) No, it calculates it once an hour. Link to comment Share on other sites More sharing options...
asaikk Posted February 15, 2012 Author Share Posted February 15, 2012 Thank you for the reply. When creating MyChannelAverage in the Channel Table, what values should I input for the items (I/O Type, Chn #, Timing, etc)? Link to comment Share on other sites More sharing options...
AzeoTech Posted February 16, 2012 Share Posted February 16, 2012 Device Type: Test I/O type: A to D D# : 0 Chan #: something unique to your other Test channels Timing: 0 rest, whatever you want. Link to comment Share on other sites More sharing options...
asaikk Posted February 16, 2012 Author Share Posted February 16, 2012 Many thanks for the advice. I succeeded in making the program run. PS I corrected the command you wrote ; myChannelAverage.addValue(mean) to myChannelAverage.addValue(themean) Link to comment Share on other sites More sharing options...
asaikk Posted February 16, 2012 Author Share Posted February 16, 2012 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 More sharing options...
AzeoTech Posted February 17, 2012 Share Posted February 17, 2012 != 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.