ElectroLund Posted October 15, 2024 Posted October 15, 2024 Hello, everyone! I have a data extraction challenge. I have several years worth of manufacturing data that has been collected using a DAQFactory template. There are two graphs and a couple other measurements that are represented. These test runs are all saved as CTL files, all of which I have access to. Unfortunately, the (long-gone) developer never went that extra step to write the data to any kind of text file, spreadsheet, etc. So now all that historical data is rather "locked up". So I'm looking into some sort of scripting solution, probably in DF?, that I could leverage to run through all these files and extract the data. Any such possibility? My company owns several sets of DF, so with any luck... Quote
AzeoTech Posted October 17, 2024 Posted October 17, 2024 I would start by trying an export set. This is what it was originally designed for, though I'm not sure how many people actually use it this way. But before you do anything, make sure you have backups of the files if that is the only source for the data! Quote
ElectroLund Posted October 17, 2024 Author Posted October 17, 2024 Huh, ok. Currently, I was going the route of making a new sequence, looping through each virtual channel array, writing each value to a separate file. I'm not seeing much in the way of syntax for these export sets in the help. Are there examples somewhere? I should add that my licenses are for very old version, 5.87. I see Exporting in that help though, section 9.7. Quote
AzeoTech Posted October 17, 2024 Posted October 17, 2024 You can actually automate that pretty fast if you are comfortable with a little scripting. Use v.channel.listall() to get a list of all the channels. So, for example (and this is off the cuff so might have syntax errors), to write all the v channels to separate files in the c:\data directory it'd be something like this: private string chanList = v.channel.listall() for (private i = 0, i < numrows(chanList), i++) private data = evaluate("v." + chanList[i]) private out = getTime(data) out[][1] = data private handle = file.Open("c:\data\" + chanList[i] + ".csv",0,1,0,1) file.writeDelim(handle, out, ",", chr(10)) file.Close(handle) ? chanList[i] + " Completed" endfor The timestamp is in seconds since 1970 which may not be what you want. For excel time, change the "private out = " line to: private out = getTime(data) / 86400 + 365*70 + 19 You'll still see numbers, but if you open the file in excel, you can format the column as date/time and it will display correctly. Quote
ElectroLund Posted October 17, 2024 Author Posted October 17, 2024 Oh nice, that's a great solution. I love that it writes the entire array in one swoop. Is there a way of grabbing a Text Component value from a Page? There is one Text component in each CTL file that contains a unique serial number. This component doesn't appear to have an identifier with which I can programmatically address to grab its value. Quote
AzeoTech Posted October 17, 2024 Posted October 17, 2024 If the component is named you can get it from script, but my guess is that it isn't named. Select it, then right click and select Change Component Name. If it is just named _Text or similar than you can only really access it programmatically if it is the only Text control on the page. If it has a name, then yes, you can access it. But is it a Static Text component or a Descriptive Text component or a Variable Value component. All three can display text. If it is Static Text and its display changes then most likely it is being changed from script so has a name. But if it is the other two, then the display is actually already based on a variable and you can just open the properties of the component and see what variable is being referenced and use that directly. Accessing components by name is simply: component.myComponentName. where myComponentName is the name of the component. Each component has a number of properties. A static text component will have one with the its contents. That will either be strText for older controls or just Text for release 20+ controls. Most likely the first, so: component.myComponentName.strText Quote
Recommended Posts
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.