Quick Notes and Array History


BeeHay

Recommended Posts

Hello there, thought while I was here, I should post a few questions I have on my mind...

1st, I've recently been messing with the Quick Note feature, and not quite sure about viewing the submitted notes...

I have made a button with the quick seq System.NoteDialog() to open and write in a note.

I have also made a Variable Value with the expression "strNote".

Is there a way to better way to view the typed in notes?

What I'm trying to accomplish is a small note area where we can type a note and review when/why the note was typed in.

2nd, is there a way to add history to Arrays?

Say I have 200 values in an array, and the running pc decides to re-boot, all the array history is gone, but with persist or using a V.Channel, all my channel/variable data is saved.

I would like to know if there is a way to save the array data to a history.

Thanks for everything,

Brandon

Link to comment
Share on other sites

1st: strNote is just an internal variable so you can display it however you want using whichever of the screen controls are appropriate. Just remember that it has a history (I believe the last 100 notes) so you'll probably want [0], and it has time stamped, so you can use GetTime() to retrieve it, for example GetTime(strNote[0]) returns the time of the last note. strNote.Time[0] is not supported. .Time is only for channels.

2nd: history is arrays. I think you are talking about persisting an array to disk, yes? You can use the File. functions to write pretty much anything to disk. The file.writedelim() and file.readdelim() are usually the easiest functions to use for this along, of course with file.open(), and file.close().

That all said, unless your data is a string array, random access writing, and unless you need fast performance, why not just use a test channel to hold the data and persist it there? Just create a test channel with Timing = 0, then use MyChannel.AddValue() to stick a new value into it.

Link to comment
Share on other sites

Thanks for the note explanation, will def. come in handy. :)

But about the arrays, can I do something like this -

MyNewTestChan.AddValue(Array1[0])

Or this? Clear my channel, then re-write the whole array? -

MyNewTestChan.ClearHistory()

MyNewTestChan.AddValue(Array1)

Can I do append on a channel? -

MyNewTestChan.Append(Array1[0])

Thanks!

Link to comment
Share on other sites

yes, yes, and no.

Yes you can add an array with addvalue. If its an array of rows, it will create multiple rows, if its an array in columns you end up with a "spectra" in the channel. Basically it should add as you expect.

Yes, you can clear the history and add the whole thing.

No, you can't append. You can only do addvalue() which puts it at the top of the array. You could, technically, I suppose, make a copy of the channel: array = mychannel, then append to array, then do the clearhistory/addvalue to repopulate the channel, but it wouldn't be too efficient. But that's relative. If the array is only a few thousand points, no big deal. If its 100,000, then it might be.

Link to comment
Share on other sites

  • 1 month later...

Hmm, having a tough time getting my arrayed data saved in the correct order...

I have attached a .ctl file showing what I'm trying...

If you fill the first 5 data points with 1, 2, 3, 4, 5, save to the channel, clear the array variable, and then append the channel to the array variable, the data is reversed displaying 5, 4, 3, 2, 1.

Any help would be great!

B)

Link to comment
Share on other sites

That is because the channel sorts the data based on time before adding it to the channel. Graphs, and other functions require channel data to be in order by time (most recent first), so it is done automatically for you with AddValue. The array elements are being time stamped when you set them, and presumably you are setting them in order 1,2,3,4,5 so that 5 is the most recent. When it sorts, it flips it making the most recent, 5, first.

Link to comment
Share on other sites

Hmm, so a way around the numbers being reversed would be to subtract time from the previous value?

I possibly need to learn the evaluate() function you talked about. :)

Link to comment
Share on other sites

Well, what I'm trying to do is be able to back up my variables "arrays" to a channel so if the pc restarts or the DAQ hangs, all my arrayed data is saved being persisted to a channel...

But the way it is now, when the pc restarts or I restart the DAQ, the arrayed data is saved, but completely reversed...

Say the user adds 4 sizes of drill pipe in my global variable Array1 -

31.5

30.25

32.5

31.75

The Array1 is now saved in the channel "SavedData", and magically the pc restarts...

Upon re-boot, the DAQ restarts and all the data is there, but the persisted "SavedData" is spit back into Array1 like this -

31.75

32.5

30.25

31.5

I understand the fact that the most recent data is newest at the top, but I'm trying to get the newest data at the bottom...

:)

Thanks!

Link to comment
Share on other sites

You are trying to use something designed for something else to do this. V channels shouldn't be used, and truthfully, its only going to persist anyway if you save the document. If you are using the Auto-Persist timer, you should consider using other techniques as this is deprecated because it can cause corruption to your document if power is lost during a save.

To persist variables you should either use the registry, it you only have a few variables, or use the File. functions to write them to a file. The File.WriteDelim() / File.ReadDelim() are very simple to use to write and read arrays to file.

Link to comment
Share on other sites

Archived

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