Tcp/ip Trigger And Label Data 关注

0
Avatar
Legacy Poster

Hello.

Version is 10.0 SR1.

In the Commander whitepaper, under TCP/IP Socket Triggers, it states "TCP/IP socket communication ... can contain label data...".

I've been all over the SDK's, online documentation, the videos, and cannot find any information on what the format of the TCP/IP message is that would contain label data.

So, if I have a template with two "fields", one for a description and one for a barcode, how does TCP/IP with label data work? What do I need to send?

Thank you,

Mike

7 评论

0
Avatar
Legacy Poster
评论操作 固定链接

I have the same question. How can I send data to the TCP/IP Socket Trigger? I am guessing there is some delimeter that is needed?
0
Avatar
Shotaro Ito
评论操作 固定链接

Hi, For TCP packet you can send any text data with CSV, Commander script or XML etc.
Code below's sending CSV by C#. note this code doesn't handle response from Commander.

[code]
try
{
// Create connection (destination address can be remote computer's host name or IP address)
System.Net.Sockets.TcpClient tcp = new System.Net.Sockets.TcpClient("localhost", 5170);

// get stream
System.Net.Sockets.NetworkStream ns = tcp.GetStream();

// create CSV data
string triggerCSV = "";
triggerCSV += "ID,CODE" + "\r\n";
triggerCSV += "nC001,NR-01";

// change data to bytes
byte[] send_bytes = System.Text.Encoding.UTF8.GetBytes(triggerCSV);

// send data
ns.Write(send_bytes, 0, send_bytes.Length);

// sent
MessageBox.Show(triggerCSV);

// close
tcp.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

[/code]

Commander setup would be..
Trigger: TCP/IP Socket

[b]Trigger[/b]
Port: 5170
Trigger Event: Socket Disconnected
[Save Received data to file] enabled
File name: (any path and filename with local folder)
File Encoding: Unicode(UTF-8)

[b]Command(s)[/b]
BarTender command to print a document with saved trigger file.

SSL or other encryption method are not supported, so please use VPN etc to protect confidential data if sending over Internet.
0
Avatar
Legacy Poster
评论操作 固定链接

Hi.. I'm trying to do the same thing and I've gotten as far as this tutorial goes. But now how do I set up my label format to open a CSV file that is being passed in with /D ?
0
Avatar
Legacy Poster
评论操作 固定链接

Hi.. I'm trying to do the same thing and I've gotten as far as this tutorial goes. But now how do I set up my label format to open a CSV file that is being passed in with /D ?

 

I'm just trying to get this working today.. and after several hours messing around have figured out the answer.

 

Here is how you do it:

 

In BarTender

 

1) Create an ordinary CSV file with example data set up exactly how you will send it over the TCP connection later.  I want to use field labels in my CSV file, so I set it up as a two line file, the first line containing the labels, the second line containing sample data, eg:

 

"first_name", "last_name"

"John", "Public"

 

 

2) Use the normal "Database Connection Setup" to set up your CSV file as a data source.. it will detect all your field labels from the file you created.

 

3) Create your template as normal, using your CSV data source in the various fields etc...

 

Ok, now in Commander..

 

4) Create task with

 

TCP trigger

 

Trigger Event: TCP Disconnect

 

Save Received Data To File (I do not know if this file has to be the same one that you used when you set up the template.. I did it that way.  I kept another copy of my test data elsewhere, just in case I need it later)

 

5) Click "..." button on Bartender task.. which brings up config dialog.

 

6) Under "Documents" tab, select "Documents To Use" = YOUR TEMPLATE

 

AND HERE'S WHAT YOU'RE PROBABLY MISSING.. THIS WAS MY ISSUE RIGHT HERE:

 

7) Under "Text File " tab, check "Text File" Checkbox, and make sure that next to that, it says "%Trigger File Name%"

8) Also check "Delete File When Done" unless you want all your jobs saved in numbered files.

 

If you do all this, then all you have to do is open the socket and send the two-line CSV file contents (one line labels, one line data) and bartender will merge your data and print.

 

Except for me, this is just the beginning, because now I have to control the number of copies to print, as well as which printer.  So, I'll be learning to use scripts next...

 

Anyway, hope this helps.  The documentation for TCP sockets is pretty bad but hopefully we can help each other out.

 

 

 

 

0
Avatar
Legacy Poster
评论操作 固定链接

Just to follow up from the message I posted yesterday...

 

I've tested label printing via TCP with each of the following command types:

 

* BarTender (write just the CSV data to the socket)

* Commander Script (write the commander script in the first lines of the file, followed by the CSV data)

* BTXML (generate BTXML containing command and data, write to socket).

 

Of these three, BTXML is the most straightforward so far as configuration.  There are hardly any options to set in Commander since everything is within your XML.  In my case that's just great because I have complete control over the TCP client code and would rather select which printer I am using, how many copies, which template, etc.. all via TCP and not have a lot of extra configuration in Commander.  

 

So, to do that, just set up your Trigger as:

 

TCP with Trigger Event as "Sequence of Characters Received" using the characters "</XMLScript>".

Make sure "Include Sequence of Characters in File" is checked.

Make sure "Save Received Data in File" is checked and a file location selected.

 

Set up your Command as "BTXML" .. NO options needed!

 

Then of course it is your problem to create the correct XML and send it on the socket.. but it will work!  You control everything from your TCP client via the XML :)

 

If you want to get a response message back on your TCP socket, create a second Command of type "Send to TCP Socket",

And set the options on that to "BTXML Response", check "Send the response back through inbound connection"...

And depending on what you want, you might want to check "Terminate connection when done".  Since I'm triggering relatively few, large print jobs, that made the most sense for me.

 

Anyway, so the upshot is:

 

Sending CSV = Most configuration hassle, least client responsibility, very little control.

Sending Commander Script + CSV = Medium configuration hassle, moderate client responsibility, moderate control.

Sending BTXML = LEAST configuration hassle, MOST client responsibility.. but once you get the XML correct it is the best, because you'll never have to touch the commander settings again.
 
Hope this helps someone!
 
-Ben Mehlman
Sweet Sams Baking Company
0
Avatar
Legacy Poster
评论操作 固定链接

hey Ben,

 

Please share how did you generate xml and related TCP/Ip client code to use the BTXML in commander.You codeed  in Java,C#  your TCP/IP client code which took control of all 

1)selecting  which printer I am using,

2)how many copies,

3) use which template(here refers btw file only)

 

Please respond waiting for your reply.

0
Avatar
Legacy Poster
评论操作 固定链接

Hi viktux.. sorry it took me so long to respond, hope you have worked it out!

 

My application is written in python.. using the common python libraries for socket I/O and for xml ( xml.etree.ElementTree ).

 

In order to choose the printer, number of copies, and the template file, I create a FormatSetup tag, and then within that, tags to specify all the settings.

 

My whole XML hierarchy looks like this:

 

XMLScript

  Command

    FormatSetup

      Format

      Printer

      IdenticalCopiesOfLabel

    Print

请先登录再写评论。