Recommended Posts

Hello, I require help. I want to graph, in DAQFactory, existing data that DAQF collected in the past, logged as a CSV file. I want to load the data into the two (2) data channel tables named "mV" and "PV" with the corresponding DateTime stamp. This DT-Stamp was recorded "in XL format", i.g., "44693.39602" (General Fmt in Excel viewed CSV) or if saved as an XL file can be represented in a custom format as "5/12/2022  9:30:16 AM" (=TEXT(44693.3960185185, "m/d/yyyy h:mm:ss.000")). The timing is asynchronous, so I want to move the exact DateTime stamp to each channel table and each trend value.

I have reviewed the use of:

Var.FileHandle = File.Open("C:\MyBriefcase\Desktop\Boeing Data\FVSMdata_05007_220512_0932.csv",1,0,0,1)

Var.strIn = File.ReadDelim(FileHandle,-1,",",Chr(10),0,1)

//Looping code "For(Var.x = NoRsNoH, x>0, x--) ... Endfor" - Skip header when loading channel tables, load Channel Tables backwards for DAQFactory (FILO) as the 0th element is the most recent, NoRsNoH = Number of CSV Rows No Header included



strln = {{"TheTime","mV","PV"},{44693.39601,5377808,0}, ... {44693.40212,1450.296,1432.906}}

where this can be represented by

{Var.strIn[0][0,2], Var.strIn[1][0,2], ... Var.strIn[NoRsNoH-1][0,2]}

I can fill the "mV" and "PV" tables with the inverted list of values but I am stuck with the current DateTime Stamping when I want the exact historic stamps.

The User Guide suggests using the function "InsertTime(Value, Start, Increment)" but it is unclear how to use this with "MyChannel(mV/PV).AddValue(Value=Var.strIn[x][1/2]) and convert the XL time stamp back to DAQFactory format ( formatDateTIme("", timeStamp)?) 

Also, how do you get the channel tables to graph? When I load the values to the undesirable "current time," my graphs don't materialize on the 2D Graph Component like when the data is added to the mV/PV channels via Modbus using a communications module.

Thank you.


Link to comment
Share on other sites

OK, first, I wouldn't put the data back into channels.  Just put them in global variables. 

Second, you'll want to add a before your readDelim() function so that the header gets read and ignored.  Then strIn won't have "TheTime", etc as the first element.  

Third, using Var. notation is very deprecated.  You should instead declare variables, so:

private FileHandle = ....

private datain = file.readDelim(...)

If you do a to remove the header, then you can read the data into a numeric variable instead of a string.

Now to the meat.  Let's assume that you've done those changes, so now datain is going be something like {{44693.39601,5377808,0}, ... {44693.40212,1450.296,1432.906}}

The formula to convert from Excel time (decimal days since 1900) to DAQFactory time (seconds since 1970, also called UNIX time) is:

DFTime = (ExcelTime - 365*70 - 19) * 86400

We simply subtract the number of days between 1970 and 1900 (365 * 70) including the 19 leap years, then take that and multiply by the number of seconds in a day.

If the exceltime is in the first column, you can just do:

datain[][0] = (datain[][0] - 365*70-19) * 86400

Now, you really want to end up with two global variables, lets say mV and PV, so after converting the time you'll just do:

global mV = datain[][1]
global pV = datain[][2]

Now you just need to assign the time.  You don't want insertTime() because that just creates a constantly incrementing time stamp.  Instead, we need to use column 0:

mV.Time = datain[][0]
pV.Time = datain[][0]

Finally, we need to sort the data so that newest is first, which is exactly what sorttime does:

mV = sortTime(mV)
pV = sortTime(pV)

Now you can graph mV and pV the same way you would any other channel.

The whole thing is pretty straight forward if you remove my long winded explanations...





Link to comment
Share on other sites

I appreciate your help.  Now I see that it is straightforward and that I do not need to use the channel tables to repopulate a 2D graph.

Thanks again,


Edited by Shawn
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.