Change printer setting between printing job - Zebra printer - vb.net

I can change the printer setting from the printer setting as well as from the Zebra Setup Utilities. What I would like to know is if their is a way to automatically change the settings (darkness or print mode) in between two printing job. Like one job as darkness set to 15 and the other to 3.
I am sending the print job from Visual Basic as a ThermalLabel object.
I already tried using :
PrintUtils.SetDarkness(03)
as well as :
PrintUtils.ExecuteCommand(ligneZPL)
where ligneZPL is this string -> "~SD3 \n"
But the printer (Zebra - GC420T) doesn't take it into account.

There are two values in play for darkness. ~SD sets the darkness generally. ^MD modifies the ~SD value by a delta. If the ~SD value is 10, and the ^MD value is 5, then the overall darkness will be 15.
If you want to print most labels at 15, set ~SD15. For the label you want to print at 3, set ^MD-12 as part of the code at the top of the label.
Either of these commands might already be embedded in the label you are trying to print. That may be the reason why the setting seems to be ignored.

Related

gnuplot 'set title' with sprintf : representing angle in terms of fractions of pi

I'd like to run a gnuplot .inp file so all the angles in the script show up automatically in the title as fractions based on the Greek letter pi - instead of a decimal form for the angle. I already know how to use {/Symbol p}, but that is a manual intervention that is impractical in this case.
I have an example sprintf line in a gnuplot input file which can produce nice title information :
angle=( (3*pi) /4 )
set title sprintf ("the angle is %g radians", angle)
plot sin(x)
... the output file (e.g. svg) or terminal (e.g. wxt) shows "2.35619", which is correct, however ; it would be nice to see the Greek letter for pi and the fraction itself, as is typically read off of a polar plot, e.g " 3/4 pi". Likewise for more complex or interesting representations of pi, such as "square root of two over two".
I already know I can manually go into the file and type in by hand "3{/Symbol p}/4", but this needs to be done automatically, because the actual title I am working with has numerous instances of pi showing up as a result of a setting of an angle.
I tried searching for examples of gnuplot being used with sprintf to produce the format of the angle I am interested in, and could not find anything. I am not aware of sprintf being capable of this. So if this is in fact impossible with gnuplot and sprintf, it will be helpful to know. Any tips on what to try next appreciated.
UPDATE: not a solution, but very interesting, might help :
use sprintf after the 'plot' to set the title that appears in the key (but not the overall title):
gnuplot setting line titles by variables
so for example here, the idea would be :
foo=20
plot sin(x)+foo t sprintf ("The angle is set to %g", foo)```
Here is an attempt to define a function to find fractions of Pi.
Basically, sum (check help sum) is used to find suitable multiples/fractions of Pi within a certain tolerance (here: 0.0001). It is "tested" until a denominator of 32. If no integer number is found, the number itself is returned.
In principle, the function could be extended to find multiples or fractions of roots, sqrt(2) or sqrt(3), etc.
This approach can certainly be improved, maybe there are smarter solutions.
Script:
### format number as multiple of pi
reset session
$Data <<EOD
1.5707963267949
-1.5707963267949
6.28318530717959
2.35619449019234
2.0943951023932
-0.98174770424681
2.24399475256414
1.0
1.04
1.047
1.0471
1.04719
EOD
set xrange[-10:10]
set yrange[:] reverse
set offset 0.25,0.25,0.25,0.25
set key noautotitle
dx = 0.0001
fPi(x) = (_x=x/pi, _p=sprintf("%g",x), _d=NaN, sum [_i=1:32] \
(_d!=_d && (abs(_x*_i - floor(_x*_i+dx)) < dx) ? \
(_n=floor(_x*_i+dx),_d=_i, \
_p=sprintf("%sπ%s",abs(_n)==1?_n<0?'-':'':sprintf("%d",_n),\
abs(_d)==1 ? '' : sprintf("/%d",_d)),0) : 0 ), _p)
plot $Data u (0):0:(fPi($1)) w labels font "Times New Roman, 16"
### end of script
Result:
I have [1] a workaround below that might be feasible, and [2] apparently what I was looking for below that (I am writing this in haste). I will mark the question "answered" anyway. To avoid reproducing theozh's script, I offer :
[1]:
add three lines to theozh's script - ideally, immediately before the 'plot' command :
set title sprintf ("Test: %g $\\sqrt{\\pi \\pi \\pi \\pi}$", pi)
set terminal tikz standalone
set output 'gnuplot_test.tex'
one can observe a little testing going on with nonsensical expressions of pi - it is just to see the vinculum extend, and this is a hasty thing - and the double-escapes - they appear to have made it to Stack Overflow correctly.
change the 'plot' line to remove the Times Roman part, but this might not be necessary :
plot $Data u (0):0:(fPi($1)) w labels
importantly, edit gnuplot_test.tex so an \end{document} is on the last line.
run 'pdflatex gnuplot_test.tex'.
This should help move things along - it appears the best approach is to go into the LaTeX world for this - thanks. I tried cairolatex pdf and eps but I was very confused with the LaTeX output. the tikz works almost perfectly.
[2]: What I was looking for : put this below the fPi(x) expression in gnuplot :
set title sprintf ("Testing : \n wxt terminal : \
%g %s %s %s \n tikz output : $\\sqrt{\\pi \\pi \\pi \\pi}$", \
pi, fPi(myAngle01), fPi(myAngle02), fPi(myAngle03) )
# set terminal tikz standalone
# set output 'gnuplot_test.tex'
plot $Data u (0):0:(fPi($1)) w labels t sprintf ("{/Symbol p}= %g, %s, %s, %s, %s", \
pi, fPi(pi), fPi(myAngle01), fPi(myAngle02), fPi(myAngle03) )
... the wxt terminal displays the angles as fractions of pi. I didn't test the output in the LaTeX pipeline - remove if undesired. I think the gnuplot script has to be written for the terminal or output desired - but at least the values can be computed - instead of writing them in "manually".

Sets in python (using iterator)

When we usually enter scrambled numbers in a set later on if we print the set it automatically sorts the numbers and default it prints the set in ascending order..but today I got confused with this example..could anyone help me with this..output
Program where i used iterator for sets

Colored output in Runnig console in IDEA (PyCharm)

I try log colored messages to PyCharm running console.
Yes, I have read that running console and embedded terminal is different thing, but:
For my code emited log message printed white, but it look colored if I just print() message. So looks like running console support colors, but I don't understand how enable it.
class DefaultHandler(logging.Handler):
def emit(self, record):
log_entry = self.format(record)
m = re.match('^(\[.*?\])', log_entry)
if m:
time = click.style(m.groups()[0], fg='magenta')
msg = click.style(log_entry[m.end():], **get_log_format(record))
click.echo(time + msg) # <- log emit
print(time, msg) # <- just print
else:
click.secho(log_entry, **get_log_format(record))
As you can see log message is white, but printed message is colored.
I'm not positive what your question is, but PyCharm has support for different colors on the console.
Console: Background, Error, output, Standard output, System output, User input
Log Console: Error, Expired entry, Warning
ANSI Colors
You have the ability to look at the defaults and modify them through Settings | Editor | Color Scheme | Console Colors. Is this what you're looking for?

Update current line with command line tool in Swift

I built a OS X command line tool in Swift (same problem in Objective-C) for downloading certain files. I am trying to update the command line with download progress. Unfortunately, I cannot prevent the print statement to jump to the next line.
According to my research, the carriage return \r should jump to the beginning of the same line (while \n would insert a new line).
All tests have been performed in the OS X Terminal app, not the Xcode console.
let logString = String(format: "%2i%% %.2fM \r", percentage, megaBytes)
print(logString)
Still, the display inserts a new line. How to prevent this?
Note: This won't work in Xcode's debugger window because it's not a real terminal emulator and doesn't fully support escape sequences. So, to test things, you have to compile it and then manually run it in a Terminal window.
\r should work to move to the beginning of the current line in most terminals, but you should also take a look at VT100 Terminal Control Escape Sequences. They work by sending an escape character, \u{1B} in Swift, and then a command. (Warning: they make some pretty ugly string definitions)
One that you'll probably need is \u{1B}[K which clears the line from the current cursor position to the end. If you don't do this and your progress output varies in length at all, you'll get artifacts left over from previous print statements.
Some other useful ones are:
Move to any (x, y) position: \u{1B}[\(y);\(x)H Note: x and y are Ints inserted with string interpolation.
Save cursor state and position: \u{1B}7
Restore cursor state and position: \u{1B}8
Clear screen: \u{1B}[2J
You can also do interesting things like set text foreground and background colors.
If for some reason you can't get \r to work, you could work around it by saving the cursor state/position just before you print your logString and then restoring it after:
let logString = String(format: "\u{1B}7%2i%% %.2fM \u{1B}8", percentage, megaBytes)
print(logString)
Or by moving to a pre-defined (x, y) position, before printing it:
let x = 0
let y = 1 // Rows typically start at 1 not 0, but it depends on the terminal and shell
let logString = String(format: "\u{1B}[\(y);\(x)H%2i%% %.2fM ", percentage, megaBytes)
print(logString)
Here's an example assuming some async task is taking place with callbacks that pass a Progress type.
// Print an empty string first otherwise whichever line is above the printed out progress will be removed
print("")
let someProgressCallback: ExampleAsyncCallbackType = { progress in
let percentage = Int(progress.fractionCompleted * 100)
print("\u{1B}[1A\u{1B}[KDownloaded: \(percentage)%")
}
The key part is \u{1B}[1A\u{1B}[K and then whatever you want to print out to the screen following.
Your example will only work on the actual command line, not in the debugger console. And you also need to flush stdout for every iteration, like this:
var logString = String(format: "%2i%% %.2fM \r", 10, 5)
print(logString)
fflush(__stdoutp)

xdotool with mountain lion and macbook retina

xdotool doesn't seem to work with my new macbook retina with mountain lion installed. It launchs XQuartz but does't seem to simulate mouse click or keyboard inputs like before. I don't know if it's related to mountain lion or to the retina display. A tool like cliclick (http://www.bluem.net/en/mac/cliclick/) seems to work though and does the job. Nevertheless, I prefer a tool that work both on mac and on linux. Does anyone experience the same issue?
Using:
OS X 10.8.1
MacBook Pro Retina
xdotool 2.20110530.1 from macports
XQuartz 2.7.3
I've found this one for Mac OS X which does the same job as xdotool:
Website Url: http://www.bluem.net/en/mac/cliclick/
It works with Retina Display and Mountain Lion. It's pretty simple to use. Here the manual :
cliclick ("Command Line Interface Click") is a tool for executing mouse- and keyboard-related actions from the shell/Terminal
USAGE
cliclick [-m <mode>] [-r] command1 [command2] [...]
OPTIONS
-r Restore initial mouse location when finished
-m <mode> The mode can be either “verbose” (cliclick will print a
description of each action to stdout just before it is
performed) or “test” (cliclick will only print the
description, but not perform the action)
COMMANDS
To use cliclick, you pass an arbitrary number of commands as arguments. A command consists of a command identifier (a string that tells cliclick what kind of action to perform) and usually one or more arguments to the command, which are separated from the command identifier by a colon. Example: “c:123,456” is the command for clicking (the “c” is the command identifier for clicking) at the position with x coordinate 123 and y coordinate 456. See below for a list of all commands and the arguments they expect.
LIST OF COMMANDS
m:x,y MOVE the mouse to the point with the given coordinates.
Example: “m:12,34” will move the mouse to the point with
x coordinate 12 and y coordinate 34.
c:x,y Will CLICK at the point with the given coordinates.
Example: “c:12,34” will click at the point with x coordinate
12 and y coordinate 34. Instead of x and y values, you may
also use “.”, which means: the current position.
dc:x,y Will DOUBLE-CLICK at the point with the given coordinates.
Example: “dc:12,34” will double-click at the point with x
coordinate 12 and y coordinate 34. Instead of x and y values,
you may also use “.”, which means: the current position.
tc:x,y Will TRIPLE-CLICK at the point with the given coordinates.
Example: “tc:12,34” will triple-click at the point with x
coordinate 12 and y coordinate 34. Instead of x and y values,
you may also use “.”, which means: the current position.
kd:keys Will trigger a KEY DOWN event for a comma-separated list of
modifier keys (“cmd”, “alt” or “ctrl”).
Example: “kd:cmd,alt” will press the command key and the
option key (and will keep them down until you release them
with another command)
ku:keys Will trigger a KEY UP event for a comma-separated list of
modifier keys (“cmd”, “alt” or “ctrl”).
Example: “ku:cmd,ctrl” will release the command key and the
control key (which will only have an effect if you performed
a “key down” before)
p[:str] Will PRINT the given string. If the string is “.”, the
current MOUSE POSITION is printed. As a convenience, you can skip
the string completely and just write “p” to get the current position.
Example: “p:.” or “p” will print the current mouse position
Example: “p:'Hello world'” will print “Hello world”
w:ms Will wait/pause for the given number of milliseconds.
Example: “w:500” will pause command execution for half a second
Version 2.0, released 08/17/2012
Author: Carsten Blüm, <macapps#bluem.net>
Website: www.bluem.net/jump/cliclick/