LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Security CLD sample exam

This is my answer to the CLD sample exam "security system" Does anyone have any suggestions or comments?

Download All
0 Kudos
Message 1 of 5
(2,802 Views)

Some very quick cosmetic (not algorithmic) comments: (no functional testing)

 

 

  • The big diagram comment is not sized to the text. the last few lines are cut off. (probably depending on the font settings)
  • You only need to get the control references of the status indicators once, and not every 5 milliseconds and in different states. Place the node before the loop, only once instance needed.
  • hidden wire (lower right of initialize case).
  • Code is a bit cramped. You have plenty of space.
  • I don't like the fact that the file is opened in the subVI and closed on the main diagram.
  • inside "file.vi"" "Write to spreadsheet file" opens the file automatically, so I am not sure why you are carrying the file reference around. Locking perhaps? Seems artificial. Maybe all you need to see is if the file exists. Also, write to spreadsheet file is duplicated in both cases, and thus belongs outside the case as a single instance. Only the string and "append" boolean should be inside the case structure.
  • Do you really need a 5ms loop time (200 times per second). Nobody can click this fast.
  • Your cluster elements are not aligned vertically
  • Why is the stop button called "stop 2"?
  • ...

 

Message 2 of 5
(2,787 Views)

Thanks for looking at this. I see what you mean, and made most of the changes, but I'm not sure what to do about the file reference. I use this to close the file at the end (that's why I circulate it). Since I log an event every time there is a change, I access the file many times, but I want to close the file at the end, only once.

 

 So... Should I place the close function inside the "File" subVI with a Boolean to indicate the close function within the VI ? (seems like a waste). Maybe create a new VI just for close funtion ...nahh....I will look through other code for an example.

 

Thanks again for the critique, just what I was looking for.

0 Kudos
Message 3 of 5
(2,764 Views)

 


@Islandman wrote:

... but I'm not sure what to do about the file reference. I use this to close the file at the end (that's why I circulate it). Since I log an event every time there is a change, I access the file many times, but I want to close the file at the end, only once.


 

No, you're not understanding. You are using "write to spreadsheet file", which is a high-level function. You can open it like a plain subVI and see what's inside. You will notice that it opens the file, writes (or appends) the data, then closes the file, all inside the function. Thus there is no need to open or close the file externally. At all!  Ever! You have a useless and redundant mix of high-level and low-level file functions. 😉

Sure, if performance is an issues, that constant file opening and closing could be a bottleneck. So an alternative would be to use all low-level file function. You would open/create the file before the loop, keep the file open during the loop and write using plain low-level functions, then close the file after (outside) the main loop once the program finishes.

ALSO: Your subVI needs a makeover anyway. Use intuitive control labels (not "numeric"!). Arrange the FP nicely. Add some documentation. You should also do something about the icon. It is surrounded by blank space, making the wires seem to hang off in thin air. It is also a bit disconcerting that you are not doing much error handling. The main program would never know if the file program encounters an error. Then you are abusing the file open error to determine if the file exists or not. There is a function for that! You don't need to get the date/time in the error case, so this function belong inside the other case.

Message 4 of 5
(2,742 Views)

Thank you very much for your advice. I'm attaching a much improved version, not quite finished with all documentation, but much better design.

Download All
0 Kudos
Message 5 of 5
(2,689 Views)