Get data from SmartCard UEC - c++

I already asked a question here (https://stackoverflow.com/questions/28658283/c-getslotlisttokenpresent-pslotlist-pulcount-return-pulcount-0) about my SmartCard (https://en.wikipedia.org/wiki/Universal_electronic_card), but I would like to know: is it possible to get a specific record from a smart card, knowing the pin code and where the record is located?
Map developed by ISO-7816, so the APDU-command must be based on the following scheme:
[CLA] [INS] [P1] [P2] [Lc field] [Data field] [Le field]
How APDU-command should look like and what the library is better to use on C++/C#, if I need the data from the field 5F20?
P.s.: here is data from file sectors.ini:
[Sector1_11]
Icon = "IDENTIFICATION SECTOR"
BlockDescr1 = "0 | 0 | The data block for sharing"
BlockDescr2 = "0 | 0 | block public access to the PIN"
DataDescr21 = "DF27 | 1 | 6 | 0,0,0 | 1 | SNILS"
DataDescr22 = "DF2B | 4 | 8 | 0,0,0 | 1 | Number of MHI"
DataDescr23 = "5F20 | 0 | 26 | 0,0,0 | 1 | Name"
DataDescr24 = "DF23 | 0 | 100 | 0,0,0 | 1 | Address of the issuer"
DataDescr25 = "5F2B | 4 | 4 | 0,0,0 | 1 | Born"
DataDescr26 = "DF24 | 0 | 100 | 0,0,0 | 1 | Birthplace"
DataDescr27 = "5F35 | 3 | 1 | 0,0,0 | 1 | Paul"
DataDescr28 = "DF2D | 0 | 40 | 0,0,0 | 1 | Last"
DataDescr29 = "DF2E | 0 | 40 | 0,0,0 | 1 | Name"
DataDescr210 = "DF2F | 0 | 40 | 0,0,0 | 1 | Middle"
I only know that the third number indicates the amount of data in bytes.

Related

How to Sum all working days for each month but restart from 0 for every month in power Bi Dax

I would like to know how could I get the Sum of all working days for specific month but in the table starting each month's Sum over again.
This is my DateTable Now with this query for Work Days Sum:
Work Days Sum =
CALCULATE (
SUM ( 'DateTable'[Is working Day] ),
ALL ( 'DateTable' ),
'DateTable'[Date] <= EARLIER ( 'DateTable'[Date] )
)
Date | Month Order | Is working day | Work Days Sum |
January - 21 331
2022/01/01 | 1 | 0 | |
2022/01/02 | 1 | 0 | |
2022/01/03 | 1 | 1 | 1 |
2022/01/04 | 1 | 1 | 2 |
2022/01/05 | 1 | 1 | 3 |
2022/01/06 | 1 | 1 | 4 |
.....
2022/01/27 | 1 | 1 | 19 |
2022/01/28 | 1 | 1 | 20 |
2022/01/29 | 1 | 0 | 20 |
2022/01/30 | 1 | 0 | 20 |
2022/01/31 | 1 | 1 | 21 |
February 20 890
2022/02/01 | 2 | 1 | 22 |
2022/02/02 | 2 | 1 | 23 |
2022/02/03 | 2 | 1 | 24 |
2022/02/04 | 2 | 1 | 25 |
|
|
V
Date | Month Order | Is working day | Work Days Sum |
January - 21 21
2022/01/01 | 1 | 0 | |
2022/01/02 | 1 | 0 | |
2022/01/03 | 1 | 1 | 1 |
2022/01/04 | 1 | 1 | 2 |
2022/01/05 | 1 | 1 | 3 |
2022/01/06 | 1 | 1 | 4 |
.....
2022/01/27 | 1 | 1 | 19 |
2022/01/28 | 1 | 1 | 20 |
2022/01/29 | 1 | 0 | 20 |
2022/01/30 | 1 | 0 | 20 |
2022/01/31 | 1 | 1 | 21 |
February 20 41
2022/02/01 | 2 | 1 | 1 |
2022/02/02 | 2 | 1 | 2 |
2022/02/03 | 2 | 1 | 3 |
2022/02/04 | 2 | 1 | 4 |
2022/02/05 | 2 | 0 | 4 |
.....
Any idea on how I can change my dax query to achieve output of second table below the down arrow would be much appreciated.

How to increase the verbosity level of SCIP solver log

I have the following SCIP solver log
time | node | left |LP iter|LP it/n| mem |mdpt |frac |vars |cons |cols |rows |
0.0s| 1 | 0 | 4 | - | 6k| 0 | 0 | 6 | 200 | 6 | 200 |
0.0s| 1 | 0 | 7 | - | 6k| 0 | 0 | 8 | 200 | 8 | 200 |
0.0s| 1 | 0 | 10 | - | 6k| 0 | 0 | 9 | 200 | 9 | 200 |
0.0s| 1 | 0 | 10 | - | 6k| 0 | 0 | 9 | 200 | 9 | 200 |
0.0s| 1 | 0 | 10 | - | 6k| 0 | 0 | 9 | 200 | 9 | 200 |
0.0s| 1 | 0 | 10 | - | 6k| 0 | 0 | 9 | 200 | 9 | 200 |
I want the log to be more verbose, as in display a new line at each LP iteration. So far I only came across
SCIP_CALL( SCIPsetIntParam(scip, "display/verblevel", 5));
This is increasing but not as much as I want and not where I want. Essentially I would like to have lines at LP iter 4, 5, 6, 7, 8, 9 and 10 too.
You cannot print a line of SCIP output at every LP iteration. You can set display/freq to 1, then SCIP will display a line at every node.
Additionally you can set display/lpinfo to true, then the LP solver will print additional information. I don't think any LP solver will print you a line for every LP iteration though . Do you use SCIP with SoPlex?
Edit: Looked and you can set the SoPlex frequency to 1 with the parameter "--int:displayfreq". I don't think you can set this through the SCIP api though. If you only want to solve the LP you could just do it in SoPlex or you would have to edit the lpi_spx2 source code.

How to assemble wavefront .obj data into element and vertex arrays of minimal size?

I'm having trouble putting the data inside a wavefront .obj file together.
These are the vec3 and vec2 definitions
template <typename T>
struct vec3 {
T x;
T y;
T z;
};
template <typename T>
struct vec2 {
T x;
T y;
};
Used in a vector:
+-----------------------------------+--------------+--------------+-------+
| std::vector<vec3<uint32_t>> f_vec | 0 | 1 | (...) |
+-----------------------------------+--------------+--------------+-------+
| | v_vec_index | v_vec_index | (...) |
| +--------------+--------------+-------+
| | vt_vec_index | vt_vec_index | (...) |
| +--------------+--------------+-------+
| | vn_vec_index | vn_vec_index | (...) |
+-----------------------------------+--------------+--------------+-------+
Where:
v_vec_index is an index of std::vector<vec3<float>> v_vec with its fields containing vertex x, y and z coordinates
vt_vec_index is an index of std::vector<vec2<float>> vt_vec containing texture u and v coordinates
vn_vec_index is an index of std::vector<vec3<float>> vn_vec with normal x, y and z coordinates
Every f_vec field is used to create a sequence of vert_x, vert_y, vert_z, tex_u, tex_v, norm_x, norm_y, norm_z float values inside std::vector<float> vertex_array.
Also, every index of f_vec's field is by default a value of std::vector<uint32_t>> element_array - that is it contains the range of integers from 0 to f_vec.size() - 1.
The problem is vec3 fields inside f_vec may repeat. So in order to assemble only the unique sequences mentioned above I planned to turn something like this:
+-----------------+---+---+---+---+---+
| f_vec | 0 | 1 | 2 | 3 | 4 |
+-----------------+---+---+---+---+---+
| | 1 | 3 | 1 | 3 | 4 |
| +---+---+---+---+---+
| | 2 | 2 | 2 | 2 | 5 |
| +---+---+---+---+---+
| | 2 | 4 | 2 | 4 | 5 |
+-----------------+---+---+---+---+---+
Into this:
+------------------------+-----------------+---+---+---+---+---+
| whatever that would be | index | 0 | 1 | 2 | 3 | 4 |
+------------------------+-----------------+---+---+---+---+---+
| | key | 0 | 1 | 0 | 1 | 2 |
| +-----------------+---+---+---+---+---+
| | | 1 | 3 | 1 | 3 | 4 |
| | +---+---+---+---+---+
| | vec3 of indices | 2 | 2 | 2 | 2 | 5 |
| | +---+---+---+---+---+
| | | 2 | 4 | 2 | 4 | 5 |
+------------------------+-----------------+---+---+---+---+---+
Where every time an element of f_vec would be put into the "whatever container"
It would be checked if it is unique
If it is then it would be pushed to the end of the container with its key being the next natural number after the biggest key - the key's value would be pushed to the element_array and new vertex would be created inside vertex_array
If it isn't then it would be pushed to the end of the container with its key being the same as the key of its duplicate - the key's value would be pushed to the element_array but vertex_array would remain unchanged
How am I supposed to do it?

Create column to classify rows based on realted tables DAX PowerBI

I have simplified my problem to solve. Lets suppose I have three tables. One containing data and specific codes that identify objects lets say Apples.
+-------------+------------+-----------+
| Data picked | Color code | Size code |
+-------------+------------+-----------+
| 1-8-2018 | 1 | 1 |
| 1-8-2018 | 1 | 3 |
| 1-8-2018 | 2 | 2 |
| 1-8-2018 | 2 | 3 |
| 1-8-2018 | 2 | 2 |
| 1-8-2018 | 3 | 3 |
| 1-8-2018 | 4 | 1 |
| 1-8-2018 | 4 | 1 |
| 1-8-2018 | 5 | 3 |
| 1-8-2018 | 6 | 1 |
| 1-8-2018 | 6 | 2 |
| 1-8-2018 | 6 | 2 |
+-------------+------------+-----------+
And i have two related helping tables to help understand the codes (their relationships are inactive in the model due to ambiguity with other tables in the real case).
+-----------+--------+
| Size code | Size |
+-----------+--------+
| 1 | Small |
| 2 | Medium |
| 3 | Large |
+-----------+--------+
and
+------------+----------------+-------+
| Color code | Color specific | Color |
+------------+----------------+-------+
| 1 | Light green | Green |
| 2 | Green | Green |
| 3 | Semi green | Green |
| 4 | Red | Red |
| 5 | Dark | Red |
| 6 | Pink | Red |
+------------+----------------+-------+
Lets say that I want to create an extra column in the original table to determine which apples are class A and class B given that medium green Apples are class A and large Red apples are class B, the other remain blank as the example below.
+-------------+------------+-----------+-------+
| Data picked | Color code | Size code | Class |
+-------------+------------+-----------+-------+
| 1-8-2018 | 1 | 1 | |
| 1-8-2018 | 1 | 3 | |
| 1-8-2018 | 2 | 2 | A |
| 1-8-2018 | 2 | 3 | |
| 1-8-2018 | 2 | 2 | A |
| 1-8-2018 | 3 | 3 | |
| 1-8-2018 | 4 | 1 | |
| 1-8-2018 | 4 | 1 | |
| 1-8-2018 | 5 | 3 | B |
| 1-8-2018 | 6 | 1 | |
| 1-8-2018 | 6 | 2 | |
| 1-8-2018 | 6 | 2 | |
+-------------+------------+-----------+-------+
What's the proper DAX to use given the relationships are initially inactive. Preferably solvable without creating any further additional columns in any table. I already tried codes like:
CALCULATE (
"A" ;
FILTER ( 'Size Table' ; 'Size Table'[Size] = "Medium");
FILTER ( 'Color Table' ; 'Color Table'[Color] = "Green")
)
And many variations on the same principle
Given that the relationships are inactive, I'd suggest using LOOKUPVALUE to match ID values on the other tables. You should be able to create a calculated column as follows:
Class =
VAR Size = LOOKUPVALUE('Size Table'[Size],
'Size Table'[Size code], 'Data Table'[Size code])
VAR Color = LOOKUPVALUE('Color Table'[Color],
'Color Table'[Color code], 'Data Table'[Color code])
RETURN SWITCH(TRUE(),
(Size = "Medium") && (Color = "Green"), "A",
(Size = "Large") && (Color = "Red"), "B", BLANK())
If your relationships are active, then you don't need the lookups:
Class = SWITCH(TRUE(),
(RELATED('Size Table'[Size]) = "Medium") &&
(RELATED('Color Table'[Color]) = "Green"),
"A",
(RELATED('Size Table'[Size]) = "Large") &&
(RELATED('Color Table'[Color]) = "Red"),
"B",
BLANK())
Or a bit more elegantly written (especially for more classes):
Class =
VAR SizeColor = RELATED('Size Table'[Size]) & " " & RELATED('Color Table'[Color])
RETURN SWITCH(TRUE(),
SizeColor = "Medium Green", "A",
SizeColor = "Large Red", "B",
BLANK())

predicted_value1 = regr1.predict(9) meaning of this statement

I am a newbe to the data science and I have downloaded the code which will tell the viewers for the next week.
But in this following code I am not able to understand the what the following function does, and how it will predict the values.
The data set is of 7 values for each. Why only 9 are inserted into the braces?
regr1 = linear_model.LinearRegression()
regr1.fit(x1, y1)
predicted_value1 = regr1.predict(9)
What thess lines will do?
Here is the full code:
import pandas as pd
def get_data(file_name):
data = pd.read_csv(file_name)
flash_x_parameter = []
flash_y_parameter = []
arrow_x_parameter = []
arrow_y_parameter = []
for x1,y1,x2,y2 in zip(data['flash_episode_number'],
data['flash_us_viewers'],
data['arrow_episode_number'],data['arrow_us_viewers']):
flash_x_parameter.append([float(x1)])
flash_y_parameter.append(float(y1))
arrow_x_parameter.append([float(x2)])
arrow_y_parameter.append(float(y2))
return flash_x_parameter,
flash_y_parameter,arrow_x_parameter,arrow_y_parameter
def more_viewers(x1,y1,x2,y2):
regr1 = linear_model.LinearRegression()
regr1.fit(x1, y1)
predicted_value1 = regr1.predict(9)
regr2 = linear_model.LinearRegression()
regr2.fit(x2, y2)
predicted_value2 = regr2.predict(9)
print predicted_value1,"are the flash viewers"
print predicted_value2,"are the arrow viewers"
if predicted_value1 > predicted_value2:
print "The Flash Tv Show will have more viewers for next week"
else:
print "Arrow Tv Show will have more viewers for next week"
x1,y1,x2,y2 = get_data('C:\\Users\\SHIVAPRASAD\\Desktop\\test.csv')
more_viewers(x1,y1,x2,y2)
No, your data is NOT the set of 7 values, it has 9 rows:
+----------------+-------------------+----------------+------------------+
| FLASH_EPISODE | FLASH_US_VIEWERS | ARROW_EPISODE | ARROW_US_VIEWERS |
+----------------+-------------------+----------------+------------------+
| 1 | 4.83 | 1 | 2.84 |
| 2 | 4.27 | 2 | 2.32 |
| 3 | 3.59 | 3 | 2.55 |
| 4 | 3.53 | 4 | 2.49 |
| 5 | 3.46 | 5 | 2.73 |
| 6 | 3.73 | 6 | 2.6 |
| 7 | 3.47 | 7 | 2.64 |
| 8 | 4.34 | 8 | 3.92 |
| 9 | 4.66 | 9 | 3.06 |
+----------------+-------------------+----------------+------------------+
(as your code is from Dataconomy Linear Regression Implementation in Python.)
So the value 9 in the command
predicted_value1 = regr1.predict(9)
is OK.