05-11-2019 12:49 PM
that's true ! didn't think about upload my VI ><
sorry
05-11-2019 12:59 PM
I am with Bob Here. It is much easier both for you and for us of you simply attach your VI. You don't need to capture, crop&save multiple screenshots and we have something that we can run. Win-Win!
Also never attach screenshots. The forum has a tool to insert pictures into the post if needed so we don't need to click things.
You apparently did not understand my point of duplicate code. All you need is parse the string outside the case structure, then branch to the desired indicators according to the case
What's the significance of the values 2^31-1? (What that once a NaN before you changed it to I32??? 😮 Come on!)
@siwalex wrote:Like what? what's an unbroken code?
Unbroken code (as the name implies!) does not have a broken run arrow.
I doubt the current code works: All you'll ever execute is the default case because the string will never be "43.1" or 45.1". The string is always longer than that, triggering the default.
05-11-2019 01:17 PM
Replace your convoluted case structure with the following:
mcduff
05-11-2019 01:19 PM
ok,
i think the code is beter like this
just need help to do the graph now with the "NaN"
05-11-2019 01:31 PM - edited 05-11-2019 01:36 PM
Yopu cannot have NaN for integers, so you need DBL.
Here's what I would do (all ideas from my first post, now some repeated by others). Fully scalable for as many channels as you want after a few more simple changes.
Also remember to chose a plot style with actual points, not just lines. with only lines you will no see point surrounded by NaN on each side! Another option would be to graph stale values in the case of missing values. Maybe even better.
(Also note that you code still has potential race conditions because you cannot guarantee that the chart history gets reset before the loop starts. Right?)
05-11-2019 01:44 PM
05-11-2019 01:51 PM
true.
Thank's for the help.
tomorow i will continue my code and i will post it when it's done 🙂
(with means etc)
and i will post the full project with database comunication.
maybe you will tell me if i can optimise my code.
have a good end of weekend
05-11-2019 02:16 PM
As I already hinted, I would recommend to retain the stale (=last seen on that detector) values instead of using NaN. Now the 5 point average looks nice and there are no gaps.
05-12-2019 06:59 AM
The problem of mean is, i have a Hub to recieve informations from nodes (43 and 45). I will have 4 nodes in total (maybe more later)
the hub can recieve only 1 information for exemple node 43 in one time. if he recieve node 43 on time then 10 times in a raw node 45, the mean will be wrong.
is it possible the mean not take in consideration the NaN? or just take the last value who was not a NaN for the calculs?
05-12-2019 10:20 AM - edited 05-12-2019 06:31 PM
@siwalex wrote:
the hub can recieve only 1 information for exemple node 43 in one time. if he recieve node 43 on time then 10 times in a raw node 45, the mean will be wrong.
is it possible the mean not take in consideration the NaN? or just take the last value who was not a NaN for the calculs?
My latest code does not use any NaN except at the beginning before any values have been received. After that, each channel shows the mean of the last five iterations. If there are more than five iterations with no new data, the displayed value will be constant of course. I don't consider that wrong by any definition and I am not sure why you are bringing up that ugly word.
LabVIEW is a full featured programming language and you can implement any exception handling you want, but first you need to know what you actually want. For us to help we need to know what you consider "right", not what you think is "wrong".