Why does my text not print? - c#

Realizing that I should be using Line Print mode (as opposed to label mode) for sending CPCL to the Zebra QL 220 belt printer, I'm in the process of refactoring my working code (Why does everything print on the same line, even though I'm adding crlfs?) to this:
serialPort.Write("! 0 200 200 210 1\r\n");
serialPort.Write(string.Format("! U1 setvar {0} {1}", "device.languages", "line_print"));
serialPort.Write("Hallo die Welt\r\n\r\n"); //Bonjour le Monde --- Hola el Mundo --- Hallo die Welt
serialPort.Write("BARCODE-TEXT 7 0 5\r\n");
serialPort.Write(string.Format("BARCODE 128 1 1 50 150 130 {0}\r\n\r\n", barcode));
serialPort.Write("POSTFEED 120\r\n"); // empirical observation shows 120 is about the right amount of extra tape to expel after printing
serialPort.Write("PRINT\r\n");
This prints the barcode and its human-readable number beneath it (the value in "barcode"),but the text "Hallo die Welt" is not printed. Why not? Do I need a call to Print after each line, or...???
UPDATE
It still prints the barcode only (not "Hallo die Welt") with this code:
serialPort.Write("! 0 200 200 210 1\r\n");
serialPort.Write("! U1 SETLP 7 0 24\r\n");
serialPort.Write("Hallo die Welt\r\n\r\n");
serialPort.Write("BARCODE-TEXT 7 0 5\r\n");
serialPort.Write(string.Format("BARCODE 128 1 1 50 150 130 {0}\r\n\r\n", barcode));
serialPort.Write("POSTFEED 120\r\n");
serialPort.Write("PRINT\r\n");
UPDATE 2
This works (label mode):
serialPort.Write("! 0 200 200 210 1\r\n");
serialPort.Write("TEXT 4 0 30 40 Hallo die Welt\r\n\r\n"); //Bonjour le Monde --- Hola el Mundo --- Hallo die Welt
serialPort.Write("BARCODE-TEXT 7 0 5\r\n");
serialPort.Write(string.Format("BARCODE 128 1 1 50 150 130 {0}\r\n\r\n", barcode));
serialPort.Write("POSTFEED 120\r\n");
serialPort.Write("PRINT\r\n");
It prints:
~~~~~~~~~~~~~~~~~~~~~~~
Hallo die Welt
<barcode as a barcode>
<barcode as a number>
~~~~~~~~~~~~~~~~~~~~~~~
...but this doesn't work (line print mode):
serialPort.Write(string.Format("! U1 setvar {0} {1}", "device.languages", "line_print"));
serialPort.Write("! U1 SETLP 7 0 24\r\n");
serialPort.Write("Hallo die Welt\r\n\r\n");
serialPort.Write("! U1 BARCODE-TEXT 7 0 5\r\n");
serialPort.Write(string.Format("! U1 BARCODE 128 1 1 50 150 130 {0}\r\n\r\n", barcode));
serialPort.Write("! U1 SETLP 5 2 46");
serialPort.Write(barcode);
serialPort.Write("! U1 PRINT\r\n");
The problem is, I need to use Line Print mode.

You also need a \r\n after every SGD command (your setvar in this case)
It should be
! U1
setvar "device.languages" "line_print"\r\n
You also need to put the double quotes around the 2 parameters of the SETVAR command.
UPDATE:
oh, btw, just because the printer is in line_print mode, doesn't mean that it doesn't understand CPCL code. So the code above in your example is CPCL code, not just line print. If you put TEXT in front, it should work

Related

TwinCAT3 - Automation Interface - Display O/P on Jenkins console

Using Automation Interface I could able to build and initiate Activate Configuration in TwinCAT 3.1.4024.4.
If same project under normal run and Activate Configuration, Messages and errors are displayed in the output console of VS2013.
In Automation Interface, Using ErrorItems errors = dte.ToolWindows.ErrorList.ErrorItems; I could only read and display message 1 to 10.
Other Messages has different format TwinCAT System (10000) or PlcTask (350):
Is this will not be captured by dte.ToolWindows.ErrorList.ErrorItems; ?
In the output console of VS2013 there are two options: Show output from build and Show output from twinCAT.
In Automation Interface,I think, i could only read messages from build and no Messages from TwinCAT
Is there any way to read TwinCAT messages Also?
VS2013 console output:
Message 1 The application is up to date 0 0
Message 2 Build complete -- 0 errors, 0 warnings : ready for download! 0 0
Message 3 Additional code checks ... 0 0
Error 4 SA0033: Unused Variable 'fbSum_Test' UnitTestJenkins (UnitTestJenkins\UnitTestJenkins)
Error 5 SA0033: Unused Variable 'fbDegreesToRadians' 4 1 UnitTestJenkins (UnitTestJenkins\UnitTestJenkins)
Error 6 SA0033: Unused Variable 'data' FB_DegreesToRadians_Test.DegreesToRadians_Test1 3 1 UnitTestJenkins (UnitTestJenkins\UnitTestJenkins)
Message 7 Additional code checks complete -- 3 errors 0 0
Message 8 Generate TMC information ... 0 0
Message 9 Import symbol information ... 0 0
Message 10 generate boot information... PLC.UnitTestJenkins 0 0 UnitTestJenkins (UnitTestJenkins\UnitTestJenkins)
Message 11 29.11.2019 09:52:58 477 ms | 'TwinCAT System' (10000): Ein Neustart des TwinCAT Systems wurde von AmsNetId: 10.73.8.239.1.1 Port 32867 angefordert.
Message 12 29.11.2019 09:52:58 614 ms | 'TwinCAT System' (10000): Konfiguration des COM Servers TcEventLogger wird gesichert!
Message 13 29.11.2019 09:52:59 440 ms | 'TwinCAT System' (10000): COM Servers TcEventLogger wird heruntergefahren!
Message 14 29.11.2019 09:53:01 467 ms | 'TwinCAT System' (10000): Konfiguration des COM Servers TcEventLogger wird geladen!
Message 15 29.11.2019 09:53:01 468 ms | 'TwinCAT System' (10000): COM Server TcEventLogger wird initialisiert!
Message 16 29.11.2019 09:53:01 517 ms | 'TwinCAT System' (10000): TcIo Server wurde gestartet: TcIo.
Message 17 29.11.2019 09:53:01 530 ms | 'TwinCAT System' (10000): TcPlc30 Server wurde gestartet: TcPlc30.
Message 18 29.11.2019 09:53:01 537 ms | 'TwinCAT System' (10000): TcRtsObjects Server wurde gestartet: TcRtsObjects.
Message 19 29.11.2019 09:53:01 543 ms | 'TwinCAT System' (10000): TcRTime Server wurde gestartet: TcRTime.
Message 20 29.11.2019 09:53:01 660 ms | 'License Server' (30): license validation status is Valid(3)
Message 21 29.11.2019 09:53:01 704 ms | 'TCRTIME' (200): Intel(R) Core(TM)-i 4'th generation detected
Message 22 29.11.2019 09:53:02 078 ms | 'TwinCAT System' (10000): COM Server TcEventLogger wird gestartet!
Error 23 29.11.2019 09:53:02 108 ms | 'PlcTask' (350): FAILED TEST 'PRG_TEST.fbSum_Test#TwoPlusTwoEqualsFour', EXP: 4, ACT: 3, MSG: The calculation is not correct
Error 24 29.11.2019 09:53:02 168 ms | 'PlcTask' (350): FAILED TEST 'PRG_TEST.fbDegreesToRadians#DegreesToRadians_Test1', EXP: 0.0, ACT: 0.01745329, MSG: The calculation is not correct
Error 25 29.11.2019 09:53:02 228 ms | 'PlcTask' (350): FAILED TEST 'PRG_TEST.fbDegreesToRadians#DegreesToRadians_Test2', EXP: 1.0, ACT: 0.01745329, MSG: The calculation is not correct
Error 26 29.11.2019 09:53:02 388 ms | 'PlcTask' (350): | ==========TESTS FINISHED RUNNING==========
Error 27 29.11.2019 09:53:02 708 ms | 'PlcTask' (350): | Test suites: 2
Error 28 29.11.2019 09:53:03 028 ms | 'PlcTask' (350): | Tests: 4
Error 29 29.11.2019 09:53:03 348 ms | 'PlcTask' (350): | Successful tests: 1
Error 30 29.11.2019 09:53:03 668 ms | 'PlcTask' (350): | Failed tests: 3
Error 31 29.11.2019 09:53:03 988 ms | 'PlcTask' (350): | ======================================
Output on the Jenkins Console: [Could read only first 10 messages]
ActivateConfiguration Errors count: 10
vsBuildErrorLevelLow: Description: The application is up to date
vsBuildErrorLevelLow: Description: Build complete -- 0 errors, 0 warnings : ready for download!
vsBuildErrorLevelLow: Description: Additional code checks ...
vsBuildErrorLevelHigh: Description: SA0033: Unused Variable 'fbSum_Test'
vsBuildErrorLevelHigh: Description: SA0033: Unused Variable 'fbDegreesToRadians'
vsBuildErrorLevelHigh: Description: SA0033: Unused Variable 'data'
vsBuildErrorLevelLow: Description: Additional code checks complete -- 3 errors
vsBuildErrorLevelLow: Description: Generate TMC information ...
vsBuildErrorLevelLow: Description: Import symbol information ...
vsBuildErrorLevelLow: Description: generate boot information...
Exit code is 1
C# Code:
//5.4.1 ITcPlcProject - Automation Interface document
ITcSmTreeItem plcProjectRootItem = sysMan.LookupTreeItem("TIPC^UnitTestJenkins");
ITcPlcProject iecProjectRoot = (ITcPlcProject)plcProjectRootItem;
iecProjectRoot.BootProjectAutostart = true;
iecProjectRoot.GenerateBootProject(true);
sysMan.ActivateConfiguration();
sysMan.StartRestartTwinCAT();
ErrorItems ActivateConfigurationErrors = dte.ToolWindows.ErrorList.ErrorItems;
Console.WriteLine("ActivateConfiguration Errors count: " + ActivateConfigurationErrors.Count);
for (int i = 1; i <= ActivateConfigurationErrors.Count; i++)
{
ErrorItem item = ActivateConfigurationErrors.Item(i);
Console.WriteLine(item.ErrorLevel + ": " + "Description: " + item.Description);
}
Please look in to screenshots of the outputs:
Build&TwinCAToutput
I see that you are using TcUnit.
The problem is that you’re not waiting for TcUnit to finish before you are collecting your ErrorItems. You are only collecting the error items after doing the ActivateConfiguration() and StartRestartTwincat() (that’s why you only get the first 10). You need to wait for TcUnit to finish.
Wrap the running of TcUnit in a while-loop, and ask TcUnit for the results. Once all results are returned (which is done when you have all prints done), you can then use your ErrorItems. So basically, collect the ErrorItems in a while-true loop (but make sure to use a sleep every second or so), and once you have all the results from TcUnit (in other words, the lines ==========TESTS FINISHED RUNNING========== and everything that follows), you can print all error items (or parse them, or do whatever you want with them).
Good luck!
Thank you #Jakob
Your suggestion helped to solve this issue.
After restart, 10 seconds of wait and after each read, 5 seconds of sleep.
sysMan.ActivateConfiguration();
sysMan.StartRestartTwinCAT();
System.Threading.Thread.Sleep(10000);
ErrorItems ACErrors = dte.ToolWindows.ErrorList.ErrorItems;
ErrorItem ACErrorsItems;
int j = 1;
do
{
System.Threading.Thread.Sleep(5000);
ACErrorsItems = ACErrors.Item(j);
j++;
if (ACErrorsItems.ErrorLevel != vsBuildErrorLevel.vsBuildErrorLevelLow)
{
Console.WriteLine("Description: " + ACErrorsItems.Description);
}
} while (!ACErrorsItems.Description.Contains("| 'PlcTask' (350): | ================"));
Independent of the VS ErrorList, another way to access the output window, e. g. to catch the build information:
// access output window in VS
EnvDTE.OutputWindow outWin = ((DTE2)dte).ToolWindows.OutputWindow;
try
{
// get specific output window of the collection
EnvDTE.OutputWindowPane Buildpane = outWin.OutputWindowPanes.Item("Build");
// get text document of the selected pane
EnvDTE.TextDocument BuildtextDoc = Buildpane.TextDocument;
// select all text in the output window
EnvDTE.EditPoint BuildeditPoint = BuildtextDoc.StartPoint.CreateEditPoint();
string Buildtext = BuildeditPoint.GetText(BuildtextDoc.EndPoint);
Console.WriteLine(Buildtext);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}

Can Photoshop Caption Digest metadata be added by another program?

I have to analyse a picture and figure out if it has been modified by Photoshop. Using MetadataExtractor I got the following information (in the format of Directory:TagName=TagDescription):
JPEG:Data Precision=8 bits
JPEG:Image Height=1600 pixels
JPEG:Image Width=1200 pixels
JPEG:Number of Components=3
JPEG:Component 1=Y component: Quantization table 0
Sampling factors 2 horiz/2 vert
JPEG:Component 2=Cb component: Quantization table 1
Sampling factors 1 horiz/1 vert
JPEG:Component 3=Cr component: Quantization table 1
Sampling factors 1 horiz/1 vert
JFIF:Version=1.1
JFIF:Resolution Units=none
JFIF:X Resolution=72 dots
JFIF:Y Resolution=72 dots
JFIF:Thumbnail Width Pixels=0
JFIF:Thumbnail Height Pixels=0
Exif IFD0:Orientation=Top
left side (Horizontal / normal)
Exif SubIFD:Color Space=sRGB
Exif SubIFD:Exif Image Width=1200 pixels
Exif SubIFD:Exif Image Height=1600 pixels
Photoshop:Caption Digest=212 29 140 217 143 0 178 4 233 128 9 152 236 248 66 126
File:File Name=mypicture.jpg
File:File Size=175794 bytes
File:File Modified Date=Thu Sep 29 14:22:44 +02:00 2016
Now, question is: can the Photoshop:Caption Digest=212 29 140 217 143 0 178 4 233 128 9 152 236 248 66 126 metadata be generated by a program that is NOT Photoshop? Or is it an evidence that the image was photoshopped?

FFmpeg missed packets (from time to time) while copying RTP stream to file

I have and RTP video broadcast stream (using NOVUS – H.264 / MPEG-4 HD/SD Broadcast Encoder). And I have a Windows Server 2012 (Intel Xeon E5-2690, 128Gb RAM) with service which is recording this stream to file (using lastest FFmpeg, calling it as external process). Every 2-5 minutes recording stops and starts again to a new file.
From time to time there are significant (and not) lags in video. At most these lags are at the beginning file, sometimes in the center/end. Regarding log there are missed packets.
It could be network problems, but:
I ran manually from console in parallel another instance of ffmpeg and started to record the same broadcast stream with segmentation by time. And in this case recording is very good (missed packets 1..5 very very rarely), no lags. At moments, when the first ffmpeg records the second ffmpeg has no problems.
What could be the reason of this behavior? Two ffmpeg instances run in parallel and read the same udp input, but the first misses packets when the second feels good. No memory problems, no hdd problems, no CPU overload. I also tried to set highest priority of the first ffmpeg process, but it didn't help. The only difference between them I see is that first ffmpeg is run from service, and the second is run from from local administrator. To be honest, I used vlc as recorder before, but it had the same problems too... And I can surely say that video stream is ok, because it is played in VLC player 24h/day on another PC without lags...
That is how I run ffmpeg from windows service (C#):
_process = new Process();
var startInfo = new ProcessStartInfo(#"ffmpeg\ffmpeg.exe");
startInfo.UseShellExecute = false;
startInfo.RedirectStandardInput = true;
startInfo.Arguments = "-loglevel debug -y -ss 1 -i \"" + _url + "\" -vcodec copy -y -an \"" + _outputFileName + "\"";
startInfo.CreateNoWindow = true;
Command to record video automatically from windows service:
ffmpeg.exe -loglevel debug -y -ss 1 -i "rtp://225.1.1.1:1024" -vcodec copy -y -an "Session-021221.ts"
Command to record video manually.
D:\ffmpeg\ffmpeg -i "rtp://225.1.1.1:1024" -vcodec copy -an -f segment -strftime 1 -segment_time 300 "novus-%Y-%m-%d_%H-%M-%S.ts"
This is part of the log of one of the broken recordings (some other full logs are attached):
...
2017.09.01 18R:22:56.171 frame= 172 fps= 45 q=-1.0 size= 2816kB time=00:00:03.45 bitrate=6674.9kbits/s speed=0.909x
2017.09.01 18R:22:56.174 [NULL # 0000000000a89ee0] ct_type:0 pic_struct:0
2017.09.01 18R:22:56.686 Last message repeated 26 times
2017.09.01 18R:22:56.687 frame= 199 fps= 46 q=-1.0 size= 3072kB time=00:00:03.99 bitrate=6297.7kbits/s speed=0.926x
2017.09.01 18R:23:04.554 [NULL # 0000000000a89ee0] ct_type:0 pic_struct:0
2017.09.01 18R:23:04.571 Last message repeated 26 times
2017.09.01 18R:23:04.571 frame= 226 fps= 47 q=-1.0 size= 3584kB time=00:00:04.53 bitrate=6472.7kbits/s speed=0.939x
2017.09.01 18R:23:04.571 [NULL # 0000000000a89ee0] ct_type:0 pic_struct:0
2017.09.01 18R:23:04.572 Last message repeated 26 times
2017.09.01 18R:23:04.572 frame= 253 fps= 47 q=-1.0 size= 4096kB time=00:00:05.07 bitrate=6610.4kbits/s speed=0.948x
2017.09.01 18R:23:04.572 [NULL # 0000000000a89ee0] ct_type:0 pic_struct:0
2017.09.01 18R:23:04.572 frame= 254 fps= 21 q=-1.0 size= 4096kB time=00:00:05.09 bitrate=6584.5kbits/s speed=0.418x
2017.09.01 18R:23:04.572 [NULL # 0000000000a89ee0] ct_type:0 pic_struct:0
2017.09.01 18R:23:04.655 Last message repeated 5 times
2017.09.01 18R:23:04.684 [rtp # 0000000000a3a9a0] max delay reached. need to consume packet
2017.09.01 18R:23:04.684 [rtp # 0000000000a3a9a0] RTP: missed 4147 packets
2017.09.01 18R:23:04.685 [rtp # 0000000000a3a9a0] RTP: PT=21: bad cseq a237 expected=9204
2017.09.01 18R:23:04.685 [rtp # 0000000000a3a9a0] max delay reached. need to consume packet
2017.09.01 18R:23:04.685 [rtp # 0000000000a3a9a0] RTP: missed 4148 packets
2017.09.01 18R:23:04.685 [rtp # 0000000000a3a9a0] Continuity check failed for pid 256 expected 8 got 15
2017.09.01 18R:23:04.686 [rtp # 0000000000a3a9a0] Continuity check failed for pid 272 expected 10 got 15
2017.09.01 18R:23:04.686 [rtp # 0000000000a3a9a0] Continuity check failed for pid 32 expected 13 got 4
2017.09.01 18R:23:04.686 [rtp # 0000000000a3a9a0] Continuity check failed for pid 0 expected 14 got 6
2017.09.01 18R:23:04.767 [NULL # 0000000000a89ee0] ct_type:0 pic_struct:0
2017.09.01 18R:23:05.255 Last message repeated 25 times
2017.09.01 18R:23:05.256 frame= 286 fps= 22 q=-1.0 size= 4608kB time=00:00:12.51 bitrate=3016.0kbits/s speed=0.971x
2017.09.01 18R:23:05.257 [NULL # 0000000000a89ee0] ct_type:0 pic_struct:0
2017.09.01 18R:23:05.77 Last message repeated 26 times
2017.09.01 18R:23:05.77 frame= 313 fps= 23 q=-1.0 size= 5120kB time=00:00:13.05 bitrate=3212.5kbits/s speed=0.974x
2017.09.01 18R:23:05.773 [NULL # 0000000000a89ee0] ct_type:0 pic_struct:0
2017.09.01 18R:23:06.287 Last message repeated 26 times
2017.09.01 18R:23:06.288 frame= 340 fps= 24 q=-1.0 size= 5376kB time=00:00:13.59 bitrate=3239.2kbits/s speed=0.977x
2017.09.01 18R:23:06.29 [NULL # 0000000000a89ee0] ct_type:0 pic_struct:0
2017.09.01 18R:23:06.803 Last message repeated 26 times
2017.09.01 18R:23:06.804 frame= 367 fps= 25 q=-1.0 size= 5888kB time=00:00:14.13 bitrate=3412.2kbits/s speed=0.979x
2017.09.01 18R:23:06.808 [NULL # 0000000000a89ee0] ct_type:0 pic_struct:0
2017.09.01 18R:23:07.324 Last message repeated 26 times
2017.09.01 18R:23:07.324 frame= 394 fps= 26 q=-1.0 size= 6144kB time=00:00:14.67 bitrate=3429.5kbits/s speed=0.981x
...
Some full logs:
Full log #1
Full log #2

How to Export data from WebBrowser to Excel using C#?

I have taken the data from a web browser. Now I want to export the data from the web browser to excel.
I get data from web browser such formats:
1
20 143
10 180
1 653
8 310
1 280
1 280
1 280
1 280
:
:
:
2
19 339
9 800
1 767
7 773
1 280
1 280
1 280
1 280
H2:DA_MI
H2:DA_MI
H2:DA_MI

GNUPlot: From 3D scatter plot to Countour map

Given the following list of x,y,z points (z is actually a signal strength indicator in dBm):
63 371 -21
142 371 -9
233 374 -18
288 371 -36
310 373 -38
349 374 -39
415 348 -44
507 334 -49
689 337 -56
635 254 -57
422 284 -42
380 278 -39
281 280 -39
214 299 -34
146 285 -30
81 302 -39
76 246 -39
80 214 -44
137 200 -44
64 134 -48
73 87 -48
200 101 -46
230 202 -44
246 105 -53
285 109 -53
278 191 -50
334 87 -54
395 189 -56
513 208 -58
510 99 -61
553 101 -62
593 100 -65
634 101 -64
679 102 -68
731 196 -70
I can quite easily generate a 3D scatter plot using this command in gnuplot:
splot "C:/path/to/points.dat" with points
What I'm really after is a way to "fill in the gaps" and create a surface. The ultimate goal is to use data like the points shown above to generate an RF map for a given WiFi access point. The resulting map would be used to calculate the possible locations of a device, given its RSSI (received signal strength indicator).
(Several APs and their associated RF maps will be used, however I don't think the specifics are relevant to this question.)
What would be the best way to interpolate the z-values (RSSI in dBm, in this case) for the remaining points?
EDIT :
I seem to have made some progress. Using set dgrid3d 50,100 splines before the splot command seems to generate more or less what I'm looking for. So the next question is: how can I replicate this kind of function in code (C#, ideally)?

Categories