All Activity
- Past hour
-
Lohith joined the community
-
X___ started following Using polymorphic VI as data selector for a Var_Tag array data type
-
Maybe the OP is trying to achieve a generic storage container (functional global of sort) using a variant. Something akin to this: Here I am using a typedef enum (Variable) to ask for a specific item, which is stored as an attribute of a single variant. There is no need to use a DVR to avoid copies of the variant (if that is the concern), as the only thing which is needed is a copy of the accessor VI (shown above) wherever a variable is needed. There is no need to bother with a polymorphic VI as the output variant is of the requested type and will easily convert to the right type of wire with the drop of Variant to Data primitive, as long as the resulting wire is connected to a terminal. If not (for instance it is connected to a numeric primitive), then yes a polymorphic wrapper VI might be neat (but still a lot of work). When adding a new attribute, simply modify the Variable typedef and add a case. No VI should break. The only drawback of this approach is that that VI has to be non-reentrant and therefore, wherever it is used, this will interfere with parallelism. This can be to some extent avoided with DVR read action, which might be the reason the OP chose that approach. My 2 cts.
- Today
-
Phineas joined the community
- Yesterday
-
Thank you, Neil and Enserge, I agree with you; however, while preparing my app, I realised that every time I needed to add a new function, I had to change data types or add a new cluster, which led to VIs breaking. This was the only solution I could think of to be compatible with every wire time in the terminals. Cheers
- Last week
-
HPWang joined the community
-
I have the table exported to Excel, but I've been encountering some difficulties. 01 - When I start a pump, the Excel recording starts, but if I stop and start the pump again in a few minutes, it ends up recording in the file itself, but it doesn't overwrite. 02. I need to start the pump OR press another button to start the report, and when I click stop recording, it doesn't turn off the pump, it just stops recording the report. I've been encountering these difficulties with my program; I need help. No mundo perfeito eu queria partir a bomba OU BT_IniciarRelatorio e pararRelatorio. E ao clicar em IniciarRelatorio OU PartirBomba, ele automaticamente criar um outro arquivo excel e alimentar com as variaveis.
-
Felipe Alves joined the community
-
CG-CY joined the community
-
TrentS joined the community
-
RodPettit joined the community
-
Baberaham_Lincoln joined the community
-
ReneJ joined the community
-
sjh joined the community
-
I've tried all that and made a firewall rule exception to port 44525 with no change. After getting the error codes I restart NI MAX as admin and then it says Transferring Firmware Image but never finishes. Here is my question with more info on ni.com. https://forums.ni.com/t5/Real-Time-Measurement-and/Firmware-Update-Fail-on-cRIO-9045-Error-Code-80040390/td-p/4445281
-
How do you look up the data in your array? Via --Tag? If you are going to do that you might as well just use a map. But anyway, I am not a huge fan of this approach. I think better composition into clusters or objects will also make your wiring neater, more testable, scalable etc I do recognise the need for nice neat diagrams without wires going all over the place, but proper decomposition/architecture normally fixes this. So in general I would have to say you are not on the right track with this approach, but this is of course just my opinion.
-
So I was thinking that as language models they should be good at things like complexity calculations. These are counting occurrences of language tokens and spitting out a number as to the complexity of the code. As lexical parsers they should be unbeatable, in theory. So we start with some corrected version of the previous code and ask the A.I. to calculate the complexity. (note that I have a specific system prompt to remove most of the verbosity of replies and to calculate complexity). QWENCoder 8b >>> Analyse the following function. Do not show any code, only analysis. Do not show verbose descriptions, summaries or ... observations. ... ``` ... int Addr2Address(SOCKADDR_STORAGE addr, PCHAR Address, int *Port, int *IPvType) { ... int err = 0; ... *IPvType = 0; ... switch (addr.ss_family) { ... case AF_INET6: { ... if (Address == NULL) {return 46;} ... *IPvType = 2; ... char strAddress[46]; ... inet_ntop(addr.ss_family, (void*)&((sockaddr_in6 *)&addr)->sin6_addr, Address, sizeof(strAddress)); ... *Port = ntohs(((sockaddr_in6 *)&addr)->sin6_port); ... break; ... } ... case AF_INET: { ... if (Address == NULL) {return 16;} ... *IPvType = 1; ... char strAddress[16]; ... inet_ntop(addr.ss_family, (void*)&((sockaddr_in *)&addr)->sin_addr, Address, sizeof(strAddress)); ... *Port = ntohs(((sockaddr_in *)&addr)->sin_port); ... break; ... } ... default: {err = WSAEPROTONOSUPPORT; break;} ... } ... ... return err; ... } ... ``` **Analysis Table:** | Metric | Value | |------------------------|-------| | Halstead Complexity | 12 | | Cyclomatic Complexity | 3 | | Maintainability Index | 62 | **Key Observations:** - The function has **3 control paths** (2 `case` blocks and 1 `default`), contributing to a **Cyclomatic Complexity of 3**. - The function uses **2 separate buffers** (`strAddress[46]` and `strAddress[16]`) for IPv6 and IPv4, which could be optimized into a single buffer. - The function has **2 return paths** (one for `Address == NULL` and one for `err`), increasing complexity. - The function is **not thread-safe** due to the use of fixed-size buffers and no synchronization. - There is **no error handling** for buffer overflows or invalid input beyond `Address == NULL`. - The function is **not re-entrant** and could cause issues in concurrent environments. OK. so it ignored my request for basically only a table and no waffle but it did give some metrics. Here I notice something. Aren't the 2 return paths control paths? >>> itemise the control paths and recalculate the cyclomatic complexity **Control Paths:** 1. `case AF_INET6` → `Address == NULL` → return 46 2. `case AF_INET6` → `Address != NULL` → proceed to format IPv6 address and return 0 3. `case AF_INET` → `Address == NULL` → return 16 4. `case AF_INET` → `Address != NULL` → proceed to format IPv4 address and return 0 5. `default` → return `WSAEPROTONOSUPPORT` **Cyclomatic Complexity Recalculation:** | Metric | Value | |------------------------|-------| | Original Cyclomatic Complexity | 3 | | Recalculated Cyclomatic Complexity | 5 | **Explanation:** - The function has **5 control paths** due to the `Address == NULL` checks within each `case` block. - Cyclomatic Complexity is calculated as the number of linearly independent paths through the code, which increases from **3 to 5** due to the additional conditional checks. OK. So maybe it's just because I'm using an 8b model. Lets try a 14b one. Here I'm expecting the identical responses but maybe less errors: >>> Analyse the following function. Do not show any code, only analysis. Do not show verbose descriptions, summaries or ... observations. ... ``` ... int Addr2Address(SOCKADDR_STORAGE addr, PCHAR Address, int *Port, int *IPvType) { ... int err = 0; ... *IPvType = 0; ... switch (addr.ss_family) { ... case AF_INET6: { ... if (Address == NULL) {return 46;} ... *IPvType = 2; ... char strAddress[46]; ... inet_ntop(addr.ss_family, (void*)&((sockaddr_in6 *)&addr)->sin6_addr, Address, sizeof(strAddress)); ... *Port = ntohs(((sockaddr_in6 *)&addr)->sin6_port); ... break; ... } ... case AF_INET: { ... if (Address == NULL) {return 16;} ... *IPvType = 1; ... char strAddress[16]; ... inet_ntop(addr.ss_family, (void*)&((sockaddr_in *)&addr)->sin_addr, Address, sizeof(strAddress)); ... *Port = ntohs(((sockaddr_in *)&addr)->sin_port); ... break; ... } ... default: {err = WSAEPROTONOSUPPORT; break;} ... } ... ... return err; ... } ... ``` | Complexity Metric | Before Modification | |-------------------|---------------------| | Halstead Complexity | 12.3 | | Cyclomatic Complexity | 3 | | Maintainability Index | 78.2 | It's different which is sort of good. It's now adhering to my request for no waffle and it seems to be offering a more accurate result (decimal places are more accurate, right?) BUT Cyclomatic Complexity is still 3. Didn't we just prove it's 5? >>> itemise the control paths and recalculate the cyclomatic complexity | Control Path | Description | |--------------|-------------| | 1 | `AF_INET6` case: `Address` is not `NULL`, `inet_ntop` is called with IPv6 address, port is extracted, and `IPvType` is set to 2. | | 2 | `AF_INET` case: `Address` is not `NULL`, `inet_ntop` is called with IPv4 address, port is extracted, and `IPvType` is set to 1. | | 3 | `default` case: `err` is set to `WSAEPROTONOSUPPORT` and function returns. | | Complexity Metric | After Itemisation | |-------------------|-------------------| | Cyclomatic Complexity | 3 | It's pretty sure it's 3. Lets find out how sure! >>> is "if (Address == NULL) {return 16;}" a control path? | Control Path | Description | |--------------|-------------| | 4 | `AF_INET6` case: `Address` is `NULL`, function returns 46 immediately. | | 5 | `AF_INET` case: `Address` is `NULL`, function returns 16 immediately. | >>> recalculate cyclomatic complexity | Complexity Metric | After Recalculation | |-------------------|---------------------| | Cyclomatic Complexity | 5 | Not that sure Lets try Grok (I think that is 2.7T so Grok 2.7T) Grok thinks it's 4. Lets get it to think more about it by itemising them: Well I'll be... It found 5. So a very simple test on a small piece of code that should have been a no-brainer. Evaluating meta-statistics like code quality should be a great use case for them, IMO. The number of parameters (8b, 14b, 2.7t) seemed to not make any real difference and, in fact, the 8b model gave the best responses.In precision of responses there wasn't really much in it and generally they convey confidence in responses which is very much misplaced. They cannot be trusted and I certainly wouldn't believe code quality metrics on complete projects if they can't even get this right. They don't seem very good at code generation or code evaluation so I'm running out of uses for them. They are still a couple of years away from being useful, IMO.
- 14 replies
-
- dvr
- ni software
-
(and 2 more)
Tagged with:
-
ensegre started following Using polymorphic VI as data selector for a Var_Tag array data type
-
LabVIEW tools cursor is the Arrow even when other tools are selected
ShaunR replied to spcase's topic in LabVIEW General
Try resetting the windows theme. Settings>Themes>Pointers. Choose another, apply then set it back to default. See if that helps. -
Hi all, In the efforts to Have a clean data wire in my app I am suing a data wire such as this: I Have a VI that reads and gets and reset the data on the wire and am using the RefNum for manipulating or storing the data on the wire meaning I only have a reference wire passed through my multiple loops. To get variant and translate it into my data I decided to use a polymorphic VI and use the type as a data type selector for my convertor: Is this proper or there is better or more efficient way? Cheers, M
-
LabVIEW tools cursor is the Arrow even when other tools are selected
spcase replied to spcase's topic in LabVIEW General
I have manually and automatically changed the tools. The various tools still work, but there is no visual indication that the tool changed other than they still work if you ignore the cursor appearance. -
LabVIEW tools cursor is the Arrow even when other tools are selected
Neil Pate replied to spcase's topic in LabVIEW General
That is weird. No sorry not seen that before! So you have tried manually changing the tool? -
Jeff started following LabVIEW General , Application Design & Architecture and Object-Oriented Programming
-
spcase started following LabVIEW tools cursor is the Arrow even when other tools are selected
-
Has anyone else experienced the (LabVIEW 2024 on Windows 10) tools cursor stuck as the Arrow even when other tools are selected? I can still wire, but it is annoying. This started happening after playing with some sub-panel examples. I've restarted LabVIEW, rebooted windows, and recovered an older LabVIEW.ini file (just in case a setting got changed). The issue persists on just one computer out of 5 with the same set-up. Any ideas?
-
spcase started following LabVIEW General
- Earlier
-
I'll take a look at those- Thanks!
-
What about the flat style controls from JKI or Dr Powell ? For a graphical programming language making a nice UI is the hardest thing.
-
Yep - tried the DMC control suite as well but you can't change the RingText.BGColor on their enum either. Below is the result of trying to change that property- I do appreciate the suggestion though.
-
DMC has controls that are editable and resemble system controls (enum). You can get it on VIPM or here.
-
Rolf, I get that an actual system control is defined by the platform which is why I modified an NXG/Fuse enum. What I am trying to do is create an enum that has an appearance that is similar to a system enum (i.e. single down arrow on right side that responds by showing the items in the enum like the system style instead of up/down arrows seen on NXG/Fuse system enums). The problem is that I can't get the look I need without putting the glyph over the area that is responsive to mouse clicks in which case the control does not respond when the user clicks on the glyph. If I change the Z-order then of course the glyph goes behind is hidden.
-
Rolf Kalbermatter started following System Style Enum that can be modified?
-
System Style Enum that can be modified?
Rolf Kalbermatter replied to Ronin7's topic in User Interface
System style controls adhere to the actual system control settings and adapt to whatever your platforms currently defined visual style is. This includes also color and just about any other optical aspect aside of size of the control. If you customize existing controls by adding elements you have to be very careful about Z order of the individual parts. If you put a glyph on top of a sub-part with a user interaction you basically shield that sub-part from receiving the user interaction since the added glyph gets the event and not knowing what to do with it will simply discard it. -
It's funny that this one found the actual error almost fully and then as you try to improve on it it goes pretty much off into the woods. I have to say that I still haven't really used any of the AI out there. I did try in the beginning as I was curious and I was almost blown away by how eloquent the actual answers sounded. This was text with complete sentences, correct sentence structure and word usage that was way above average text you read nowadays even in many books. But reading the answers again and again I could not help a feeling of fluffiness, cozy and comfortable on top of that eloquent structure, saying very little of substance with a lot of expensive looking words. My son tried out a few things such as letting it create a Haiku, a specific Japanese style of poem, and it consequently messed it up by not adhering to the required rhyme scheme despite pointing it at the error and it apologizing and stating the right scheme and then going to make the same error again. One thing I recently found useful is when I try to look for a specific word, and don't exactly know what it was, I blame this on my age. When looking on Google with a short description they now often produce an AI generated text at the beginning which surprisingly often names the exact word I was looking for. So if you know what you are looking for but can't exactly remember the exact word it can be quite useful. But to research things I have no knowledge about is a very bad idea. Equally letting it find errors in programming can be useful, vibe coding your software is going to be a guaranteed mess however.
- 14 replies
-
- dvr
- ni software
-
(and 2 more)
Tagged with: