10-23-2018 10:55 AM
Hi,
I have a program that uses the same code for different boards. The only difference is the cases inside the case structure. For eg : 1 board have cases 276-308 and the next 309 to 340 and so on. The function inside the case is also same, these numbers are just ids of the boards. So every time a new board comes I need to create a new VI with the same code and change the case in the next board, i.e as said first board 276-308, next I copy the code in another vi and make it 309-340 and so on. My doubt is can I just create one VI with same code but gives me an option to set the cases in the beginning, so I give number 309-340, it automatically creates the cases with 309-340 with same code inside each case. Also these numbers are just numerical values. They are ids coming from the board which is just a numerical value.
10-23-2018 11:02 AM
Hi Govind,
I cannot picture your code from your description. If you are duplicating a lot of code, there is almost certainly a better way to do it. However, it seems like you might need different numbers of cases (your first set has 33 cases inclusive, your second set has 32). Do these numbers represent a type of board, a serial number, a type of test, or something else?
It is often much more readable to use type-defined enums, rather than integer values, to select your cases, so you may want to think about how to do that as well.
10-23-2018 11:13 AM
If you have the same set of cases/code for each board but only the case selection value is changing then why don't you use an offset value for each board. You would subtract the board offset from the board ID number you are getting and end up with a number that would be 0 to 32, or whatever your particular core set of selections are. When you cann the subVI you would need to pass in the correct board offset value.
10-23-2018 11:27 AM
Hi Govind,
I cannot picture your code from your description. If you are duplicating a lot of code, there is almost certainly a better way to do it. However, it seems like you might need different numbers of cases (your first set has 33 cases inclusive, your second set has 32). Do these numbers represent a type of board, a serial number, a type of test, or something else?
It is often much more readable to use type-defined enums, rather than integer values, to select your cases, so you may want to think about how to do that as well.
------------------------------------------
Sorry my numbering was wrong, ever board has the same number of cases, i.e 32 cases. These numbers are actually CAN bus IDs. That is 32 readings from 1st board will be read through CAN bus with ids 276 - 307 and board 2 for the next 32 can bus values. So it will be wired to a case structure where the reading coming out of id 276 will be shown on case value 276 and the reading from id 277 will be shown on case 277 and so on and when the next board comes it begins from value coming from id 308 for case 308 which will be in another VI. This is how it is done, so inside the case there is nothing but representing the value. Its the cases which need to change.
10-23-2018 11:27 AM
If the only thing differs between the cases is a number, you don't need a case structure at all. Please show us a simplified version of your code so we get a better idea about your problem.
10-23-2018 11:29 AM
yes the only difference between the cases is the number in the case.
10-23-2018 11:49 AM - edited 10-23-2018 11:51 AM
@govindsankar wrote:
yes the only difference between the cases is the number in the case.
So why is there even a case structure if the only difference is a number and that number is an input? Obviously we have difficulties understanding the problem because you don't show us any code. Where does the number come from? What is wired to the case selector?
10-24-2018 03:56 AM
You can see there are two case structures. Ignore the first, the important one is the second case structure with the number 276. You can see the read message VI which is reading message from the can bus which gives a cluster of 3 things. Here comes the ID, so the ID will be one number between 276 and 307 for 1st board. So if the id is for eg 302, then case 302 will be executed. Hope this helps.
10-24-2018 03:59 AM
@Mark Yedinak wrote:
If you have the same set of cases/code for each board but only the case selection value is changing then why don't you use an offset value for each board. You would subtract the board offset from the board ID number you are getting and end up with a number that would be 0 to 32, or whatever your particular core set of selections are. When you can the subVI you would need to pass in the correct board offset value.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
So that is a good idea to use the offset and all I have to do is change the offset for each board. If that is the best idea for this, then I will go through with that.
10-24-2018 04:06 AM - edited 10-24-2018 04:07 AM