LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

saved data in string on front panel

Solved!
Go to solution

Hi Tim,

 


@tominsek wrote:

I tried this method as Yamadea mentioed, only for COM port first to see if it works but it doesn't. If i close the app and i reopen it, i have to select the com port again, it doesnt save it in the ini file.


Where did you implement the INI file functions?

I don't see them in the code…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 21 of 35
(430 Views)

Hi Gerdw, 

Sorry i sent you the wrong version.

 

Here is the right version and i implement it in INI section

0 Kudos
Message 22 of 35
(423 Views)

Hi Tim,

 

you did not follow the suggestions given by Yamaeda!

 

That's your code (after using CodeCleanup):

You implemented:

  • writing to a key named by the content of the VISA resource
  • setting NO VALUE to this key as there is no wire to the value input of the WriteKey function!!!
  • reading the same key name (as given by the VISA resource) as string - even though you wrote it milliseconds before as a boolean key…
  • NOT using the read value of the ReadKey function: why do you use a ReadKey function when you don't use the output???

Other questions:

  • Why do you use a "value" property node AND a local variable of the same control? They both give the same value, but the first one is even slower than the second one!
  • What's the point in writing the value to the file and reading it back immediately???
  • Do you even understand (or atleast try to) what we try to explain? Yamaeda gave an example of both steps, reading and writing. And he wrote when to use the write and when to use the read part…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 23 of 35
(403 Views)

Hi Gerdw

 

So now the com port is saved and when the app is opened is loaded and i dont need to choose again, but now the program dont work, it dont show me the values of regulator.

 

How should i load values when program start, When to do that?

And how to write values when program stops?

0 Kudos
Message 24 of 35
(391 Views)

Hi Tim,

 

suggestions:

Edit: our messages crossed, I will look at the latest code later…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 25 of 35
(388 Views)

Hi Gerdw, 

I made it like you suggested me, if i place in any state the reading, dont work...no matter where i put stuff in flat sequnce dont work. No offense but i Don't know what i'm doing wrong.

0 Kudos
Message 26 of 35
(377 Views)

Hi Tim,

 


@tominsek wrote:

i Don't know what i'm doing wrong.


You don't seem to debug your own code.

Ever worked with breakpoints and highlight execution?

(This is basic LabVIEW stuff, explained in Core1 training courses. I expect you already knew that! And I expect you to actually take all those Training resources offered at the top of the LabVIEW board!)

 

Debugging:

  • Is the code executed at all?
  • Which data is written?
  • Is there any error after CloseIniFile?

 

Why do you need one more local variable? Using them extensively is (most often) WRONG!

 

See this:

You already have the data in the shift register, so use that data instead of reading a local!

(You even put a typo in the string constant…)

 

Why don't you cleanup your code?

Why don't you use subVIs as one step to improve code readability?

Do you use a LabVIEW project file yet?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 27 of 35
(369 Views)

Hi Gerdw, 

 

So lets leave this latest version i was only trying how to do it but lets leave this,

 

now i understand how that works (writing key to file, reading from it ect...), but i dont understand in wich state in my code  i should put write key to file and in wich state i should put read key from file, because i need to save to file not only visa com port but also password for tab (nastavitve), parameters of sql data base( uid, pid ect...) and i have all these parameters scattered throughout the code in different cases. All these parameters should be saved in a file so when the application will be open you don't have to set them all up again and the program will already read data from controller.

0 Kudos
Message 28 of 35
(347 Views)

Hi Tim,

 


@tominsek wrote:

but i dont understand in wich state in my code  i should put write key to file and in wich state i should put read key from file, because i need to save to file not only visa com port but also password for tab (nastavitve), parameters of sql data base( uid, pid ect...) and i have all these parameters scattered throughout the code in different cases.


That's why I (probably) mentioned before to use a better program architecture and get rid of all those local variables!

 

  • Use one state to handle ALL UI actions by the user: each value change event of each control.
  • Put ALL relevant parameters into the cluster in your shift register. (You may even use clusters inside this clusters to organize those parameters by purpose.)

NOW you can:

  • add one more state (labelled like "read parameters from file") that reads all relevant parameters from INI file and puts them into the cluster, execute this state as the first state after program start
  • add one state to update frontpanel from the data in the shift register
  • add one state to write all the parameters from shift register into INI file, execute this state as last state before EXIT (or inside the EXIT state)

All this becomes very easy once you have a clear program architecture with a well-defined state machine, cleaned up code, more subVIs ("one VI per function, one function per VI"), and using all the suggestions I already gave…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 29 of 35
(335 Views)

So how can i put for example string of database name to cluster?

if i understant all parameters need to be in cluster and connected to my shift register in the state for example (''read parameters...'')

 

is it possible that you make me only for visa com port, what you wrote in previous message. Just so i can imagine, for other parameters i will do it by myself

0 Kudos
Message 30 of 35
(324 Views)