Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excplicit item fix #179

Merged
merged 3 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions HISTORY
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,9 @@ Issue #169 Problem decoding BDS 4,5 reserved bits
Issue #171 Hexdata presentation is not correct for multiple records in block
RE item added to CAT010

Not versioned yet
2.8.0 (python_v0.7.0)
Issue #175 Cat021 Ed2.4 SelH is not reasonable
Issue #174 Warning: ‘char* strncpy(char*, const char*, size_t)’ output may be truncated
Issue #122 glibc version 2.1 behaves diffrently than glibc 2.0.6
Added CAT004 v1.12
Added CAT004 v1.12
Issue #178 Explicit items with more elements then in definition should be put to list
2 changes: 1 addition & 1 deletion asterix/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.6.1'
__version__ = '0.7.0'
77 changes: 64 additions & 13 deletions install/sample_output/filter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,25 +145,65 @@ CAT004:I060:APW
CAT004:I060:CLAM
CAT004:I060:STCA
CAT004:I060:FX
CAT004:I060:AFDA
CAT004:I060:APM
CAT004:I060:RIMCA
CAT004:I060:ACASRA
CAT004:I060:NTCA
CAT004:I060:DG
CAT004:I060:OF
CAT004:I060:OL
CAT004:I060:FX
CAT004:I060:AIW
CAT004:I060:PAIW
CAT004:I060:OCAT
CAT004:I060:SAM
CAT004:I060:VCD
CAT004:I060:CHAM
CAT004:I060:DSAM
CAT004:I060:FX
CAT004:I060:DBPSMARR
CAT004:I060:DBPSMDEP
CAT004:I060:DBPSMTL
CAT004:I060:VRAMCRM
CAT004:I060:VRAMVTM
CAT004:I060:VRAMVRM
CAT004:I060:HAMHD
CAT004:I060:FX
CAT004:I060:HAMRD
CAT004:I060:HAMVD
CAT004:I060:HVI
CAT004:I060:LTW
CAT004:I060:VPM
CAT004:I060:TTA
CAT004:I060:CRA
CAT004:I060:FX
CAT004:I060:ASM
CAT004:I060:IAVM
CAT004:I060:FTD
CAT004:I060:ITD
CAT004:I060:IIA
CAT004:I060:SQW
CAT004:I060:CUW
CAT004:I060:FX
CAT004:I060:CATS
CAT004:I060:NOCLR
CAT004:I060:NOMOV
CAT004:I060:NOH
CAT004:I060:WRTY
CAT004:I060:STOCC
CAT004:I060:ONGOING
CAT004:I060:FX
CAT004:I070:TC Time to Conflict
CAT004:I070:TCA Time to Closest Approach
CAT004:I070:CHS Current Horizontal Separation
CAT004:I070:MHS Estimated Minimun Horizontal Separation
CAT004:I070:CVS Current Vertical Separation
CAT004:I070:MVS Estimated Minimun Vertical Separation
CAT004:I074:LD Longitudinal deviation
CAT004:I075:CHS Current horizontal separation)
CAT004:I076:LD Longitudinal deviation
CAT004:I100:AN Characters 1-8 (coded on 6 Bits each) defining the name of the area.
CAT004:I100:CAN Crossing area name.
CAT004:I075:TDD Transversal Distance Deviation
CAT004:I076:VD Vertical deviation
CAT004:I100:AN Area name
CAT004:I100:CAN Crossing area name
CAT004:I100:RT1 Runway/Taxiway Designator 1
CAT004:I100:RT2 Runway/Taxiway Designator 2
CAT004:I100:SB Stop Bar Designator
Expand All @@ -181,12 +221,23 @@ CAT004:I120:FX Field extension ind
CAT004:I120:RRC Runway/Runway crossing in RIMCAS
CAT004:I120:RTC Runway/Taxiway Crossing in RIMCAS
CAT004:I120:MRVA
CAT004:I120:VRAMCRM
CAT004:I120:VRAMVRM
CAT004:I120:VRAMVTM
CAT004:I120:HAMHD
CAT004:I120:FX
CAT004:I120:HAMRD
CAT004:I120:HAMVD
CAT004:I120:DBPSMARR
CAT004:I120:DBPSMDEP
CAT004:I120:DBPSMTL
CAT004:I120:AIW
CAT004:I120:spare Spare bits set to 0
CAT004:I120:FX
CAT004:I120:TableId Table Id
CAT004:I120:SeverityClass Conflict severity class
CAT004:I120:TableId Identification of conflict categories definition table
CAT004:I120:CPC Conflict Properties Class
CAT004:I120:CS Conflict severity
CAT004:I120:Probability Probability of the conflict
CAT004:I120:CP Probability of the conflict
CAT004:I120:CD Conflict duration
CAT004:I170:AI1 Aircraft Identifier 1
CAT004:I170:spare Spare bits set to 0
Expand All @@ -199,8 +250,8 @@ CAT004:I170:Y Starting Y-position
CAT004:I170:Z Starting Z-position of the conflict
CAT004:I170:TTA1 Time to Threshold Aircraft 1
CAT004:I170:DTA1 Distance to Threshold Aircraft 1
CAT004:I170:GAT/OAT
CAT004:I170:FR1/FR2
CAT004:I170:GATOAT
CAT004:I170:FR1FR2
CAT004:I170:RVSM
CAT004:I170:HPR
CAT004:I170:FX
Expand All @@ -224,8 +275,8 @@ CAT004:I171:Y Starting Y-position
CAT004:I171:Z Starting Z-position of the conflict
CAT004:I171:TTA2 Time to Threshold Aircraft 2
CAT004:I171:DTA2 Distance to Threshold Aircraft 2
CAT004:I171:GAT/OAT
CAT004:I171:FR1/FR2
CAT004:I171:GATOAT
CAT004:I171:FR1FR2
CAT004:I171:RVSM
CAT004:I171:HPR
CAT004:I171:FX
Expand All @@ -238,7 +289,7 @@ CAT004:I171:MS2 Mode-S Identifier A
CAT004:I171:spare Spare bits set to 0
CAT004:I171:NBR Number of the Flight Plan Correlated to Aircraft 2 Involved in the Conflict
CAT004:I171:CFL Cleared Flight Level
CAT004:ISP:TRI TargetReportIdentifier
CAT004:ISP:val SP value
CAT004:IRE:Lat Latitude
CAT004:IRE:Lon Longitude
CAT004:IRE:X X-Coordinate
Expand Down
98 changes: 65 additions & 33 deletions src/asterix/DataItemFormatExplicit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ bool DataItemFormatExplicit::getText(std::string &strResult, std::string &strHea

std::string tmpStr = "";

switch (formatType) {
case CAsterixFormat::EJSON:
case CAsterixFormat::EJSONH:
case CAsterixFormat::EJSONE: {
tmpStr += format("[");
if (nFullLength != bodyLength) {
switch (formatType) {
case CAsterixFormat::EJSON:
case CAsterixFormat::EJSONH:
case CAsterixFormat::EJSONE: {
tmpStr += format("[");
}
}
}

Expand All @@ -86,24 +88,28 @@ bool DataItemFormatExplicit::getText(std::string &strResult, std::string &strHea
ret |= di->getText(tmpStr, strHeader, formatType, pData, bodyLength);
pData += bodyLength;

switch (formatType) {
case CAsterixFormat::EJSON:
case CAsterixFormat::EJSONH:
case CAsterixFormat::EJSONE: {
tmpStr += format(",");
if (nFullLength != bodyLength) {
switch (formatType) {
case CAsterixFormat::EJSON:
case CAsterixFormat::EJSONH:
case CAsterixFormat::EJSONE: {
tmpStr += format(",");
}
}
}
}
}

switch (formatType) {
case CAsterixFormat::EJSON:
case CAsterixFormat::EJSONH:
case CAsterixFormat::EJSONE: {
if (tmpStr[tmpStr.length() - 1] == ',') {
tmpStr[tmpStr.length() - 1] = ']';
} else {
tmpStr += ']';
if (nFullLength != bodyLength) {
switch (formatType) {
case CAsterixFormat::EJSON:
case CAsterixFormat::EJSONH:
case CAsterixFormat::EJSONE: {
if (tmpStr[tmpStr.length() - 1] == ',') {
tmpStr[tmpStr.length() - 1] = ']';
} else {
tmpStr += ']';
}
}
}
}
Expand Down Expand Up @@ -200,24 +206,50 @@ fulliautomatix_data* DataItemFormatExplicit::getData(unsigned char* pData, long,

PyObject* DataItemFormatExplicit::getObject(unsigned char* pData, long nLength, int verbose)
{
PyObject* p = PyDict_New();
insertToDict(p, pData, nLength, verbose);
return p;
std::list<DataItemFormat *>::iterator it;
int bodyLength = 0;

pData++; // skip explicit length byte (it is already in nLength)

// calculate the size of all sub items
for (it = m_lSubItems.begin(); it != m_lSubItems.end(); it++) {
DataItemFormat *di = (DataItemFormat *) (*it);
bodyLength += di->getLength(pData + bodyLength); // calculate length of body
}

int nFullLength = nLength - 1; // calculate full length

// full length must be multiple of body length
if (bodyLength == 0 || nFullLength % bodyLength != 0) {
//TODO Tracer::Error("Wrong data length in Explicit. Needed=%d and there is %d bytes.", bodyLength, nFullLength);
return NULL;
}

if (nFullLength == bodyLength) {
PyObject* p = PyDict_New();
DataItemFormat *di = m_lSubItems.size() ? (DataItemFormatFixed*)m_lSubItems.front() : NULL;
if (di != NULL) {
di->insertToDict(p, pData, bodyLength, verbose);
}
return p;
}
else {
PyObject* p = PyList_New(0);
for (int i = 0; i < nFullLength; i += bodyLength) {
for (it = m_lSubItems.begin(); it != m_lSubItems.end(); it++) {
DataItemFormat *di = (DataItemFormat *) (*it);
PyObject* p1 = di->getObject(pData, bodyLength, verbose);
PyList_Append(p, p1);
Py_DECREF(p1);
pData += bodyLength;
}
}
return p;
}
}

void DataItemFormatExplicit::insertToDict(PyObject* p, unsigned char* pData, long nLength, int verbose)
{
DataItemFormatFixed* pFixed = m_lSubItems.size() ? (DataItemFormatFixed*)m_lSubItems.front() : NULL;
if (pFixed == NULL)
{
//TODO Tracer::Error("Wrong format of explicit item");
return;
}

int fixedLength = pFixed->getLength(pData);
//unsigned char nFullLength = *pData;
pData++;

pFixed->insertToDict(p, pData, fixedLength, verbose);
// Not supported
}
#endif
4 changes: 2 additions & 2 deletions src/main/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#ifndef VERSION_H
#define VERSION_H

#define _VERSION 2.7.1
#define _VERSION_STR "2.7.1"
#define _VERSION 2.8.0
#define _VERSION_STR "2.8.0"

#endif