Channel.AddValue Time

Recommended Posts

Doing a new app in Daq-Factory but used it for years with another application modifying that occasionally so I might be a bit rusty.

I have Modbus data acquisition all working ok getting raw values each 0.5 second which adds to the channel table fine, updating the Time column correctly. On that channel I have an event BotWind_ms.AddValue(fWScale(CH4_BotWind[0], cCompactMax )) that adds a scaled value to a different channel,  the value gets added correctly but the time doesn't update, all values in the channel have the same time stamp as the first value added.

If I add a value manually from the command line such as BotWind_ms.AddValue(54), the timestamp is updated correctly.

Doing BotWind_ms.AddValue(fWScale(CH4_BotWind[0], cCompactMax )) from the command line and the time stamp is again the first timestamp on the BotWind_ms channel.

Doing just BotWind_ms.AddValue(CH4_BotWind[0]) on the command line adds the raw data but with the timestamp of the CH4_BotWind[0] entry.

I must be missing something obvious although I've compared the way I'm doing this with the old application I did and just don't see anything I'm doing wrong but I must be!

Can you help?


Link to comment
Share on other sites

This is because when you do math using two different variables, DAQFactory doesn't know which associated timestamp to use.  So for example, if you have:


then the time stamp associated with the result will be the same time stamp as X, since "2" is a scalar and doesn't have a time stamp.  However, if you do:


then there is a time stamp for x and one for y and DAQFactory doesn't know which one to use.  It uses the first one it finds, but since internally it rearranges the expressions based on order of operations, it is not always clear what DAQFactory considers the "first" one.  

In your case, you are doing:

myChannel[0] + someVariableConstant

and it happens to be using the timestamp of someVariableConstant which is never changing, instead of using the one associated with MyChannel.

The solution is to explicitly add a timestamp using inserttime().  So:

BotWind_ms.AddValue(inserttime(fWScale(CH4_BotWind[0], cCompactMax ),CH4_BotWInd.time[0],1)) 

Though truthfully, I would probably put the inserttime() inside the fWScale() function...



Link to comment
Share on other sites

I understand it now - that's great, I've tried it and it works. I don't know why I've not come across this problem before - must just be luck of how I've arranged equations used in the OnEvent of channels.

I'm not quite sure how I would use it inside the scaling function which is below as I would then have to return it back to the calling part in the OnEvent part of the channel?

//Used from the Event of the Modbus Channels
function fWScale(vRaw, cMax)
   private vWork = 0  //Temporary local variable
   vWork = (vRaw/c16bit) * cMax //16bit full scale = 65535, cMax depending on Type of Anemometer

Thanks for the super quick reply. I'm enjoying getting back into Daq-Factory and will likely need another runtime license once I've got it finished.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.