Waveform Transfer for Tektronix DPO3000 Scope - vb.net

I'm trying to retrieve data from a DPO3034 scope by sending these these commands:
DATA:SOURCE CH1
DATA:ENCDG ASC
DATA:START
CURVE?
I get 98, 98, 98, 97, 97, 98, 98,...
How can I convert these ASCII formatted values to voltages?
I also tried retrieving data that are binary formatted
DATA:SOURCE CH1
DATA:ENCDG RIBINARY
DATA:START
CURVE?
I get #520000a b a b b a b c b c a b a a a b ^ b b a b a b....
How can I convert these to proper data points?
Command reference for the DPO3000

These values you are reading using CURVE? are digital value that has gain and offset for turning them into (usually) volts.
You should read also these values:
double YZero = double.Parse(io.Query("WFMO:YZE?"));
double YMult = double.Parse(io.Query("WFMO:YMU?"));
double YOff = double.Parse(io.Query("WFMO:YOF?"));
And then you should calculate the real voltage from each value rawValue in the array you get from CURVE?:
double voltValue = YZero - YOff * YMult + (YMult * double.Parse(rawValue));
same goes for binary data, just parse it into int16 (depending on the bit-length of each number)
P.S.
I believe your manual is not the latest, I'm recommending downloading these from Tektonix website.

Related

How to process mainframe numbers where "{" is the last character

I have a one mainframe file data like as below
000000720000{
I need to parse the data and load into a hive table like below
72000
the above field is income column and "{" sign which denotes +ve amount
datatype used while creating table income decimal(11,2)
in layout.cob copybook using INCOME PIC S9(11)V99
could someone help?
The number you want is 7200000 which would be 72000.00.
The conversion you are looking for is:
Positive numbers
{ = 0
A = 1
B = 2
C = 3
D = 4
E = 5
F = 6
G = 7
H = 8
I = 9
Negative numbers (this makes the whole value negative)
} = 0
J = 1
K = 2
L = 3
M = 4
N = 5
O = 6
P = 7
Q = 8
R = 9
Let's explain why.
Based on your question the issue you are having is when packed decimal data is unpacked UNPK into character data. Basically, the PIC S9(11)V2 actually takes up 7 bytes of storage and looks like the picture below.
You'll see three lines. The top is the character representation (missing in the first picture because the hex values do not map to displayable characters) and the lines below are the hexadecimal values. Most significant digit on top and least below.
Note that in the rightmost byte the sign is stored as C which is positive, to represent a negative value you would see a D.
When it is converted to character data it will look like this
Notice the C0 which is a consequence of the unpacking to preserve the sign. Be aware that this display is on z/OS which is EBCDIC. If the file has been transferred and converted to another code-page you will see the correct character but the hex values will be different.
Here are all the combinations you will likely see for positive numbers
and here for negative numbers
To make your life easy, if you see one of the first set of characters then you can replace it with the corresponding number. If you see something from the second set then it is a negative number.

Unable to convert char array to decimal in the pig

Hi I am new to pig programming. I have one csv file and tab as a delimiter. In my price column I have lacs and crores. It looks like this 40.85 Lacs, 36.73 Lacs, 2.01 cr. I want to convert into decimal like this
40.85 Lacs - 40,85,000
36.73 Lacs - 36,73,000
2.01 cr - 2,01,00000
I tried the following code:
a = LOAD '/user/user1/input/city/cityname.CSV' using PigStorage('|') as (SourceWebSite:chararray,PropertyID:chararray,ListedOn:chararray,ContactName:chararray,TotalViews:int,Price:chararray,PriceperArea:chararray,NoOfBedRooms:int,NoOfBathRooms:int,FloorNoOfProperty:chararray,TotalFloors:int,Possession:chararray,BuiltUpArea:chararray,Furnished:chararray,Ownership:chararray,NewResale:chararray,Facing:chararray,title:chararray,PropertyAddress:chararray,NearByFacilities:chararray,PropertyFeatures:chararray,Sellerinfo:chararray,Description:chararray);
DUMP a;
b = FOREACH a GENERATE Price;
dump b;
c = FILTER b BY (Price matches '.*Lacs.*');
d = FOREACH c GENERATE Price * 10000.0,SUBSTRING(Price,00000);
d = foreach c generate Price,TOKENIZE(REPLACE(Price,'.','')) AS e;
I am struggling for two days in this. Any help will be appreciated.
Use REGEX_EXTRACT to get the first part of the value, until the blank, cast it to BigDecimal and then multiply it. With this input data, for example:
(40.85 Lacs,1)
(36.73 Lacs,2)
(2.01 cr,3)
The following code would work:
A = load 'data' using PigStorage(';');
B = foreach A generate (bigdecimal)REGEX_EXTRACT($0, '(.*) (.*)', 1) * 1000000;
dump B;
And the output would be:
(40850000.00)
(36730000.00)
(2010000.00)

How to convert hex to binary?

For Objective-C:
Hi everyone, I'm trying to convert a hex input into binary. For example, someone enters in :
A55
I want that to convert to
101001010101
I've tried looking through past posts and none seem to be working for me. Any help would be greatly appreciated.
Use a lookup table: there are only 16 possible characters in a HEX representation, each corresponding to a four-character binary code group. Go through the HEX character-by-character, obtain a lookup, and put it in the resultant NSString.
Here is a copy of the lookup table for you.
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
A 1010
B 1011
C 1100
D 1101
E 1110
F 1111
There are multiple options as to how to do lookups. The simplest way would be making a 128-element array, and placing NSStrings at the elements corresponding to codes of the characters (i.e. at positions '0', '1', ..., 'E', 'F', with single quotes; these are very important).
I believe there is a built-in function for this. If not, you should at least be able to go hex->dec then dec->bin
You can write the conversion from scratch if you know the number of characters, bin to hex is common enough algorithmically.
A mathematical look at the algorithms
SO Answers in C/C++ Another
Base 10 to base n in Objective C
C Hex->Bin
Build a lookup table (an array where you can supply a value between 0 and 15 to get the binary for that hex digit):
char *hex_to_bin[] = {
"0000", "0001", "0010", "0011",
/* ... */
"1100", "1101", "1110", "1111"
};
There should be 16 elements in that table. The conversion process for multiple digits is to handle one digit at a time, appending the results onto the end of your result storage.
Use getchar() to read a char:
int c = getchar();
if (c < 0) { puts("Error: Invalid input or premature closure."); }
Use strchr() to determine which array index to retrieve:
char *digits = "00112233445566778899AaBbCcDdEeFf";
size_t digit = (strchr(digits, c) - digits) / 2;
Look up the corresponding binary values for digit:
printf("%s", hex_to_bin[digit]); // You'll want to use strcat here.

Using textscan() in Octave... How to properly format?

I have a data set on disk that I'm reading line by line, and I would like to convert one of the columns of data into a vector of floats (with a range of 0-23.99999) (for that day).
The data looks something like the following:
2010/01/01,00:00:00.979131, 27.4485, 51.9362, 14.8, 6
2010/01/01,00:00:01.021977, 27.5149, 51.9375, 16.0, 6
2010/01/01,00:00:01.074032, 27.4797, 51.9446, 14.5, 10
2010/01/01,00:00:01.663689, 25.8441,-152.8141, 14.6, 6
2010/01/01,00:00:01.639541, 25.8744,-152.6122, 1.5, 5
2010/01/01,00:00:02.232099, -2.2447, 11.5023, 18.8, 6
2010/01/01,00:00:02.256351, -0.8135, 27.3139, 17.7, 5
2010/01/01,00:00:02.306734, -2.7797, 28.5109, 26.0, 5
2010/01/01,00:00:02.620765, 25.6656,-154.2029, 26.2, 9
2010/01/01,00:00:02.658495, 25.6698,-154.2157, 23.0, 6
2010/01/01,00:00:02.731266, -5.7106, 126.4517, 3.6, 5
2010/01/01,00:00:02.787495, -5.7138, 126.5210, 24.4, 8
2010/01/01,00:00:02.811636, -3.2453, 124.6919, 21.1, 8
column 2 (e.g., 00:00:00.979131) is of interest and I would like to do something like
setenv GNUTERM 'x11';
fid = fopen('myfile.txt', 'r');
m = textscan(fid, '%d%d%d%d/%d%d/%d%d, %d%d:%d%d:%d%f, %f, %f, %f, %d');
mx = m(:, 5); %here, I would expect to grab 14.8, 16.0, etc
my = m(:, 2) / 24.0; %here, all data from timestamp column (00:00:00.979131, for ex)
plot(mx, my);
The issue is that the string I pass to textscan is malformatted for my data.
The formatting of that number is "hrs:minutes:seconds", in military time.
How can I access/convert the values for the vars mx, or my?
Thanks,
jml
The output of textscan is a cell array. If you use the command in your answer:
m = textscan(fid, '%d/%d/%d %d:%d:%f %f %f %f %d', 'delimiter', ',');
Then to get a vertical vector of 14.9, 16.0, 14.5:
MyNinthField = m{9};
MyNinthField =
14.8000
16.0000
14.5000
14.6000
1.5000
18.8000
17.7000
26.0000
26.2000
23.0000
3.6000
24.4000
21.1000
Then, to get the timestamp (seconds since the beginning of the day):
Hours = double(m{4});
Minutes = double(m{5});
Seconds = m{6};
For Seconds double is not needed, because m{6} is already double. However, m{4} and m{5} are both int32.
To get the time of the day in seconds, all you need is:
TimeOfDayInSeconds = 3600*Hours+60*Minutes+Seconds;
TimeOfDayInSeconds =
0.97913
1.02198
1.07403
1.66369
1.63954
2.23210
2.25635
2.30673
2.62077
2.65849
2.73127
2.78749
2.81164
If you didn't do type conversion from int32 to double, Octave would truncate the values to integers. MATLAB however does not even allow the sum between integer and double arrays.
Hope this helps.
Looks like you can do something like:
m = textscan(fid, '%d/%d/%d %d:%d:%f %f %f %f %d', 'delimiter', ',');
...which, although it works, it puts the time format var that I wanted into multiple portions of a var. Better than nothing. If anyone has suggestions on how to concatenate those variables after, I would love to read more. Thanks!

Adding a number with zero's

Using VB.Net
When i add a the number with zeros means, it is showing exact result without zero's
For Example
Dim a, b, c as int32
a = 001
b = 5
c = a + b
a = 009
b = 13
c = a + b
Showing output as 6 instead of 006, 22 instead of 022
Expected output
006
022
How to do this.
Need vb.net code help
You need to store a number as a string if you want to store the exact number of zeros. Then addition won't work though.
If you just want to display the number with 3 digits, you can store it as an integer and format the result when you print it.
c.ToString("D3")
zero is nothing.. If you do a regular mathematical calculation of 001 + 5 the result is still 6. I would suggest you check out string padding.