V.W_gust_graph.Time[0] =R_count.Time[0]


Recommended Posts

// Code snippet from R_count channel event 30 Jan 09

// assignment of max

V.W_gust_graph.AddValue(max(V.W_gust[]))

// if following line is executed, the value added in above assignment

// becomes something like 123333xxxx.xxx, when it should be something like 5.xxx

V.W_gust_graph.Time[0] =R_count.Time[0]

What am I misunderstanding??????

ek

Link to comment
Share on other sites

You can't assign time to a channel or v channel separate from the value. If you want to put time in, you have to insert it into the value before you do addvalue. Something like this:

V.W_gust_graph.AddValue(inserttime(max(V.W_gust),r_count.time[0],0))

Note also you don't need the []. Just specifying the channel name gives you the whole history. Note also that max() automatically inserts the time of the max point as well.

Link to comment
Share on other sites

I'm evidently not making myself clear.

I want to get the VALUE of maximum of "V_W_gust" into the "V_W_gust_graph" VALUE, but I want

"V_W_gust_graph"'s TIME to be the TIME of "R_count".

I want V.W_gust_graph to "inherit" time of r_count, rather than what it does get which is time of maximum (V_W_gust).

Your snippet of.... IF I understand it from text on page 60 of DF UG, inserts R_count's [0] time into the max of V.W_gust's array. However, I don't see how V.W_gust_graph gets the Max of V.W_gust.

V.W_gust_graph.AddValue(inserttime(max(V.W_gust),r_count.time[0],0))

The way I read the DF UG doc, the ff would set all times in whole V.W_gust array to R_count's current time.

inserttime(V.W_gust, r_count.time[0], 0)

This would make sense, BUT doc says "If you have an array that does not have time associated with it,...." Note the NOT, and V.W_gust DOES have times associated with it.

I'm lost, altho I think I've found our that ACTUAL DF channel "data" is a merged value of actual data and it's time stamp fitted into a 16byte "single" value. And that's why my original code munged the "real" data value.

I'll try your snippet on a grunge variable, if it works OK. Ours not to understand why, ours but to do or die...

ek

Link to comment
Share on other sites

OK, first InsertTime() is a function that returns a new array with the data inserted. It does not affect the original array. So inserttime(V.W_gust, r_count.time[0], 0) won't change the time of V.W_gust, but will return an array with the data from V.W_gust, and, as you predicted, the same r.count.time[0] assigned to every data point.

However, in the snippet I sent, max(V.W_gust) is an array of size one (scalar). We then take this array and set the time of it to r_count.time[0]. Since its a scalar, only one element gets set to this time. As I said, InsertTime then returns the value with the time changed, which we then pass to AddValue() to insert it into the V.W_gust_graph channel.

Link to comment
Share on other sites

Archived

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