From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Looking for help with a project...

Solved!
Go to solution

In the attached project, I want to send one of two (right now) strings to a Zebra printer. I've kind of gotten stuck where I want to select the string to print (in the Process Class - Run.VI) I think the problem is with the overall architecture, but I'm not sure how to fix it. If someone could look over this and give me some input that would be appreciated.

0 Kudos
Message 1 of 7
(2,469 Views)

What specifically are you having problems with? I looked at your code and you have the basic ZPL there. I assume you want to replace some of your fields with actual data before sending to the printer. You can do this using basic string VIs. You can use VISA to communicate with the printer for parallel, serial and TCP communications. USB is possible but it is a bit tricky. Your printer classes seem a bit light. Since they only interact with the class data and not the printer itself. Ultimately, what is your goal?

 

BTW, if you are using the same label all the time and simply replacing some variable data you can use a stored format on the printer itself and then send just the variable data to the printer and recall the specific label you want to use.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 7
(2,448 Views)

Hi Mark,

 

I can send to the printer fine, and I'll replace the [[Sreial Number]] type stuff in the string with real numbers prior to printing.

 

At the part where the class name is converted to a string, I feel I should override an abstract class of some kind with either the 200 DPI class, or the 300 DPI class. The question I then come to is should all of the VIs I have in the Initialize (Run) method become overriden? Simple inheritance worked fine until I went to amend the printer string before printing. Then having an abstract that is overridden seemed the way to go there.

 

So where I am hung up on is kind of the overall approach to the problem.

 

Tay

0 Kudos
Message 3 of 7
(2,438 Views)

You can have methods in your base class that are shared by its children and not overridden. You can even have methods that are overridden using dynamic dispatch that you do not overwrite and use the parent method. It depends on the specifics of what you want to do. Depending on how your system will work you can simply pass an instance of the specific class you want to use and simply implement th eRun.vi with the base class. Let dynamic dispatch do the rest.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 7
(2,433 Views)

I followed your first sentence. You lost me on the rest. Smiley Sad

 

What would you do? I really don't want to pull the class name as I have, since then the VI is more tightly coupled to the 200 and 300 DPI classes. I want to have them as independent as possible. This object oriented stuff is hard. Smiley Happy

0 Kudos
Message 5 of 7
(2,424 Views)
Solution
Accepted by topic author elrathia

In Main.vi inistantiate the correct class type for the printer you are working with. There are different ways of doing this but I would recommend using a plugin approach. That way you can add new printers in the future without changing your code. Part of the plugin architecture would have some method of choosing the corect type based on what plugins are available. This could be done either via a configuration file specifying the type or a user selection.

 

Your Run.vi would just have methods of the parent class. The Class input on the connector pane would be of the parent class type. Wiring in a child class will work. The methods that are specific (need to be overridden) by the child classes would be configured for dynamic dispatch. This allows LabVIEW to pick the correct method at runtime.

 

Some of the other stuff I said was more general and not specific to your application.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 6 of 7
(2,416 Views)

Worked a treat. Thanks!Smiley Happy

0 Kudos
Message 7 of 7
(2,400 Views)