asterix_parser 0.1.1

Playground do Protocolo ASTERIX
Documentation
pub mod dataitems;

use std::any::Any;

use crate::asterix::category::CategoryIndex;
use crate::asterix::uap::common::dataitems::*;
use crate::asterix::uap::{DataItem, UAPDataItem, UAPEntry};


pub struct CAT048EntryList {
    pub entries: Vec<UAPEntry>
}

impl CAT048EntryList {
    fn _new() -> CAT048EntryList {
        CAT048EntryList {
            entries: vec![
                UAPEntry::create( "1", "010", "Data Source Identifier", "2", DataSourceId.type_id() /*DataSourceId::get_attributes()*/).unwrap(),
                UAPEntry::create( "2", "140", "Time-of-Day", "3", TimeOfDday.type_id()/*TimeOfDday::get_attributes()*/).unwrap(),
                UAPEntry::create( "3", "020", "Target Report Descriptor", "1+", TargetReportDesc.type_id()/*TargetReportDesc::get_attributes()*/).unwrap(),
                UAPEntry::create( "4", "040", "Measured Position in Slant Polar Coordinates", "4", PositionPolarCoord.type_id()/*PositionPolarCoord::get_attributes()*/).unwrap(),
                UAPEntry::create( "5", "070", "Mode-3/A Code in Octal Representation", "2", Mode3ACodeOctal.type_id()/*Mode3ACodeOctal::get_attributes()*/).unwrap(),
                UAPEntry::create( "6", "090", "Flight Level in Binary Representation", "2", FlightLevelBin.type_id()/*FlightLevelBin::get_attributes()*/).unwrap(),
                UAPEntry::create( "7", "130", "Radar Plot Characteristics", "1+1+", RadarPlotCharac.type_id()/*RadarPlotCharac::get_attributes()*/).unwrap(),
                UAPEntry::create( "8", "220", "Aircraft Address", "3", AircraftAddr.type_id()/*AircraftAddr::get_attributes()*/).unwrap(),
                UAPEntry::create( "9", "240", "Aircraft Identification", "6", AircraftId.type_id()/*AircraftId::get_attributes()*/).unwrap(),
                UAPEntry::create("10", "250", "Mode S MB Data", "1+8*n", ModeSMBData.type_id()/*ModeSMBData::get_attributes()*/).unwrap(),
                UAPEntry::create("11", "161", "Track Number", "2", TrackNumber.type_id()/*TrackNumber::get_attributes()*/).unwrap(),
                UAPEntry::create("12", "042", "Calculated Position in Cartesian Coordinates", "4", PositionCartesianCoord.type_id()/*PositionCartesianCoord::get_attributes()*/).unwrap(),
                UAPEntry::create("13", "200", "Calculated Track Velocity in Polar Representation", "4", TrackVelocPolar.type_id()/*TrackVelocPolar::get_attributes()*/).unwrap(),
                UAPEntry::create("14", "170", "Track Status", "1+", TrackStatus.type_id()/*TrackStatus::get_attributes()*/).unwrap(),
                UAPEntry::create("15", "210", "Track Quality", "4", TrackQuality.type_id()/*TrackQuality::get_attributes()*/).unwrap(),
                UAPEntry::create("16", "030", "Warning/Error Conditions/Target Classification", "1+", WarnErrorConditions.type_id()/*WarnErrorConditions::get_attributes()*/).unwrap(),
                UAPEntry::create("17", "080", "Mode-3/A Code Confidence Indicator", "2", Mode3AConfid.type_id()/*Mode3AConfid::get_attributes()*/).unwrap(),
                UAPEntry::create("18", "100", "Mode-C Code and Confidence Indicator", "4", ModeCCodeAndConfid.type_id()/*ModeCCodeAndConfid::get_attributes()*/).unwrap(),
                UAPEntry::create("19", "110", "Height Measured by 3D Radar", "2", Height3DRadar.type_id()/*Height3DRadar::get_attributes()*/).unwrap(),
                UAPEntry::create("20", "120", "Radial Doppler Speed", "1+", RadialDopplerSpeed.type_id()/*RadialDopplerSpeed::get_attributes()*/).unwrap(),
                UAPEntry::create("21", "230", "Communications / ACAS Capability and Flight Status", "2", CommACASAndFlitghtStatus.type_id()/*CommACASAndFlitghtStatus::get_attributes()*/).unwrap(),
                UAPEntry::create("22", "260", "ACAS Resolution Advisory Report", "7", ACASResolReport.type_id()/*ACASResolReport::get_attributes()*/).unwrap(),
                UAPEntry::create("23", "055", "Mode-1 Code in Octal Representation", "1", Mode1CodeOctal.type_id()/*Mode1CodeOctal::get_attributes()*/).unwrap(),
                UAPEntry::create("24", "050", "Mode-2 Code in Octal Representation", "2", Mode2CodeOctal.type_id()/*Mode2CodeOctal::get_attributes()*/).unwrap(),
                UAPEntry::create("25", "065", "Mode-1 Code Confidence Indicator", "1", Mode1CodeConfid.type_id()/*Mode1CodeConfid::get_attributes()*/).unwrap(),
                UAPEntry::create("26", "060", "Mode-2 Code Confidence Indicator", "2", Mode2CodeConfid.type_id()/*Mode2CodeConfid::get_attributes()*/).unwrap(),
                // todo: if needed                 // todo: if needed 
                UAPEntry::create("27", "SPF", "Special Purpose Field", "1+1+", SPF.type_id() /*Vec::new()*/).unwrap(),
                // todo: if needed
                UAPEntry::create("28", "REF", "Reserved Expansion Field", "1+1+", REF.type_id() /*Vec::new() */).unwrap()
            ]
        }
    }
}

pub struct  CAT048Definition {    
    pub cat048_uap_data_items: Vec<UAPDataItem>
}

impl CAT048Definition {
    fn _load() -> CAT048Definition {
        let mut cat048_definition = CAT048Definition { cat048_uap_data_items: vec![]};

        for entry in CAT048EntryList::_new().entries {
            cat048_definition.cat048_uap_data_items.push(UAPDataItem {
                frn: entry.frn,
                data_item: DataItem {
                    category: CategoryIndex::_048,
                    data_item_index: entry.code,
                    content: entry.description,
                    length: entry.length,
                    type_id: entry.type_id /*,
                    attributes: entry.attributes,*/
                }
            });
        }

        cat048_definition
    }
}

/*
pub fn get_definition() -> Vec<UAPDefinition> {

    let cat048_data_items = CAT048Definition::load().cat048_uap_data_items;

    let uap048 = UAP {
        category: CategoryIndex::_048.as_u8(),
        message_type: "Monoradar Target Reports, Edition 1.31, 03 October 2022, REF: Edition 1.11, 01 December 2022".to_string(),
        data_items: cat048_data_items,
    };

    
    let uap_cat048_definition = UAPDefinition {
        category: CategoryIndex::_048,
        provider: Provider::Standard,
        uap: uap048
    };
    
    vec![uap_cat048_definition]
}  */



/* FRN,Data Item,Data Item Description,Length in Octets,System Units
1,I048/010,Data Source Identifier,2,N.A. 
2,I048/140,Time-of-Day,3,1/128 s 
3,I048/020,Target Report Descriptor,1+,N.A. 
4,I048/040,Measured Position in Slant Polar Coordinates,4,RHO: 1/256 NM THETA: 360°/(216) 
5,I048/070,Mode-3/A Code in Octal Representation,2,N.A. 
6,I048/090,Flight Level in Binary Representation,2,1/4 FL 
7,I048/130,Radar Plot Characteristics,1+1+,N.A. 
FX,n.a.,Field Extension Indicator,n.a.,
8,I048/220,Aircraft Address,3,N.A. 
9,I048/240,Aircraft Identification,6,N.A. 
10,I048/250,Mode S MB Data,1+8*n,N.A. 
11,I048/161,Track Number,2,N.A. 
12,I048/042,Calculated Position in Cartesian Coordinates,4,"X, Y: 1/128 NM "
13,I048/200,Calculated Track Velocity in Polar Representation,4,Speed: (2-14) NM/s Heading:360°/(216) 
14,I048/170,Track Status,1+,N.A. 
FX,n.a.,Field Extension Indicator,n.a.,
15,I048/210,Track Quality,4,N.A. 
16,I048/030,Warning/Error Conditions/Target Classification,1+,N.A. 
17,I048/080,Mode-3/A Code Confidence Indicator,2,N.A. 
18,I048/100,Mode-C Code and Confidence Indicator,4,N.A. 
19,I048/110,Height Measured by 3D Radar,2,25 ft 
20,I048/120,Radial Doppler Speed,1+,N.A. 
21,I048/230,Communications / ACAS Capability and Flight Status,2,N.A. 
FX,n.a.,Field Extension Indicator,n.a.,
22,I048/260,ACAS Resolution Advisory Report,7,N.A. 
23,I048/055,Mode-1 Code in Octal Representation,1,N.A. 
24,I048/050,Mode-2 Code in Octal Representation,2,N.A. 
25,I048/065,Mode-1 Code Confidence Indicator,1,N.A. 
26,I048/060,Mode-2 Code Confidence Indicator,2,N.A. 
27,SP-Data Item,Special Purpose Field,1+1+,?
28,RE-Data Item,Reserved Expansion Field,1+1+,?
FX,n.a.,Field Extension Indicator,n.a.,
*/