04-09-2019 09:54 AM
I'm using LV2013 to collect data from an external "final test" computer. It sends a tab-string with 28 cols with ints but sometimes text are attached to the ints, i.e 43([3]). The first col has a long 15-digits identifier that are a unique ID that identifies the product that are tested. Sometimes same product are tested over and over again and it can also be testet another day too. So I get a rather huge amount of data in a text-file. To analyze it I need to import it to Excel and sort it with col 1 (unique ID). It is a rather big job to read this data. One batch can be 100 products and that can produce about 130-200 lines of data.
To save time and get more information out of the data I need to use some automatic analyzing tool. Which method should I use? Is it a better way to use LV:s Database Connectivity Toolkit or is that to "much"? The other way is to use the text-files and make a sort without a database tool and try to extract the information. That feels not so good.
The information I seek are rather simple I think. Sort by ID and analyze the errors for every unique product. I want a weekly "Top Ten" error by mail. I also want to see if any interesting value drives and alarms if it goes beyond limits. Perhaps presented in the weekly mail?
I hope you understand what I'm asking. I haven't study the DB VI:s but I know about databases. Not an expert i db:s but I have made a SQL db in Linux/PHP before.
Regards
Solved! Go to Solution.
04-10-2019 04:14 AM - edited 04-10-2019 04:16 AM
You don't have a database, so a database library won't do much good. To fill the database, you'd still need to parse the file.
200-300 lines with 28 numbers per line is not that much. 400 MB is a lot... Although of course it depends on the processing time you need... Or refactor to ditch the file altogether and put the result in a database.
EDIT: Don't assume it will be slow. Test it, and then optimize\refactor only if needed. The simplest working solution is the best solution.
Simply use Spreadsheet String To Array, regular expressions, and\or File Read (maybe one line at the time, although it seems overkill) and parse the data to an internal structure of your choice. An array with a cluster, a cluster with arrays, a 2D array, or a set (or variant attribute set) would work... Then make VIs to support basic functionality on that (type def'd) structure.
Of course, putting it in a class would make sense to me, but that's just icing on the cake...
There are other pragmatic solutions, like make a new file with the ID, and put the one line in it. Then you can find the ID from the file name.
It's your program, choose what suits you the best.
04-10-2019 06:12 AM
Imagine the steps you take in Excel and then automate them in LV.
Read file (You already have an easy to access text file, use that)
Sort by ID (Technically not necessary)
Calculate error frequency by ID
Report.
/Y
04-10-2019 06:16 AM
I like simplicity!
Based on what you saying I choose the "Spreadsheet String To Array" way. Why? Well, I know that technique better then I know about databases. One more thing, the batches I spoke about are done once a week so it is totally not so much data.
I can receive data and wash it/analyze it in real time. At the same time, a standardized file containing statistics can be created. That file can be sent as a weekly report. Later on, each stat-file can be read and combined into a monthly report.
I think each datapoint should have an attribute that contains error or warnings. That means each row of data needs an array of cluster.
It is no problems with speed. It is about 30 sec between each data coming from two channels.
Regards
04-10-2019 06:58 AM
Spreadsheet String To Array is incredibly fast. So it's a good choice. Doing the same manually is often 1000X slower.
If you'd put the file in a class's private data, you can use whatever you like in there. The rest of the code won't get more cluttered if you have for instance an array of ID's and an array of clusters. On top of that you can change the entire implementation (e.g. from array of clusters to separate arrays, variant attributes or whatever). The rest of the program won't even notice, as long as the contract (interface) doesn't change. The implementation is encapsulated...
If you're at all interested in learning OO (if you're new to it) this would be a nice introduction.
04-10-2019 07:34 AM
Normally, I like to start coding with "paper and pen". I have seen LV-code produced via (I suppose) a UML to LV converter. It was a huge project (I was the client and wrote the spec). The UML was graphically made with class-names and variables.
I have realized that big programs in LV needs either OO or much maintenance. I'm using "much maintenance" method.
Classes and so on are above my level of knowledge and perhaps I don't need to reach that level. I'm not normally a LV-programmer. More C and embedded. I'm using LV since 2003 just in simple test equipments but now I need to upgrade an application.
04-10-2019 08:09 AM
@Haddock01 wrote:
I have realized that big programs in LV needs either OO or much maintenance. I'm using "much maintenance" method.
Arguably, but no argument from me.
@Haddock01 wrote:
Classes and so on are above my level of knowledge and perhaps I don't need to reach that level.
Which is a bit funny, as I use OO now because it's easier (after 15 years of non-OO).
There is a learning curve, but more then that a certain required mindset.
Starting out with suitable and small problems is crucial, and this would be one.
04-10-2019 08:33 AM
Give me a hint where to find information about OO programming in LV. Thanks.
04-10-2019 10:49 AM
Haven't checked, but this seems to be 'a lot of information' (not sure about the quality):
Most important thing is to get started after reading about the very basics.
Like SCC, you'll get benefits very fast. But it's easy to get lost in all the discussions about fancy stuff. Fancy stuff you don't need when you start. Fancy stuff is a topic with OO, but note that this fancy stuff would be near impossible in plain LV (except by making your own OO-ish framework).
04-11-2019 06:33 AM
I have read the easieast totorial from the link you gave me and I understand how my first prototypes should look like. Typedefs and polymorphism seems to be the key to OOP. I will try to test some examples and build on them.
I remember from the big project. It consist of many VI:s that had name like "Fill tank", "Flush tank", "regulate tank" and so on. Every class had there own llb. Half was files that made things happen. The other half of vi:s had som code that was just junctions. I don't know what they did. Something with dataflow. Every vi had a blue-green thread that was coming from a source that was connection to that particular class. Typedef?
I didn't study it so much. I had other things to do in the code.
Thanks for helping me..