예제 #1
0
    def get_mds_parser(self):

        self.timestamp = Struct("utc_timestamp", SBInt32("day"),
                                UBInt32("sec"), UBInt32("msec"))

        self.waveform_data = Struct(
            "wfm", Array(128, Per2048(UBInt16("average_wfm_if_corr_ku"))),
            Array(2, Per2048(UBInt16("central_filters_if_corr_ku"))),
            Array(64, Per8096(UBInt16("average_wfm_if_corr_s"))),
            Array(2, SBInt16("indexes_of_2_dft_samples")),
            Per256(SBInt16("delta_offset_fft_filter_units")), Padding(18),
            Per2048(SBInt16("noise_power_measurement")),
            OneHundredth(SBInt16("agc_of_noise_power_measurement")),
            OneHundredthDecibel(UBInt16("reference_power_value")), Padding(10))

        self.mds_record = Struct("mds_record", self.timestamp,
                                 SBInt8("quality_indicator"), Padding(3),
                                 UBInt32("source_packet_counter"), Padding(8),
                                 Array(20, self.waveform_data))

        self.mds = Array(self.n_records, self.mds_record)
        return self.mds
예제 #2
0
# respect or honor since no client will generate it. Instead, we will get two
# NULL bytes in a row.
AlphaString = functools.partial(PascalString,
                                length_field=UBInt16("length"),
                                encoding="utf8")

# Flying, position, and orientation, reused in several places.
grounded = Struct("grounded", UBInt8("grounded"))
position = Struct("position", BFloat64("x"), BFloat64("y"), BFloat64("stance"),
                  BFloat64("z"))
orientation = Struct("orientation", BFloat32("rotation"), BFloat32("pitch"))

# Notchian item packing
items = Struct(
    "items",
    SBInt16("primary"),
    If(
        lambda context: context["primary"] >= 0,
        Embed(
            Struct(
                "item_information",
                UBInt8("count"),
                UBInt16("secondary"),
            )),
    ),
)

# Metadata inner container.
metadata_switch = {
    0: UBInt8("value"),
    1: UBInt16("value"),
예제 #3
0
    def get_mds_parser(self):

        self.timestamp = Struct("utc_timestamp", SBInt32("day"),
                                UBInt32("sec"), UBInt32("msec"))

        self.time_orbit = Struct(
            "time_orbit", self.timestamp, SBInt8("quality_indicator"),
            Padding(3), MicroDeg(SBInt32("latitude")),
            MicroDeg(SBInt32("longitude")), UBInt32("source_packet_counter"),
            UBInt32("instrument_mode_id"),
            BitStruct("measurement_confidence_data", Array(32, Bit("flag"))),
            MilliMeter(UBInt32("altitude")),
            Array(20, MilliMeter(SBInt16("18hz_altitude_differences"))),
            MilliMeter(SBInt16("instantaneous_altitude_rate")), Padding(50))

        self.range_information = Struct(
            "range_information",
            Array(20, MilliMeter(UBInt32("18hz_tracker_range_no_doppler_ku"))),
            Array(20, MilliMeter(UBInt32("18hz_tracker_range_no_doppler_s"))),
            UBInt32("map_valid_points_tracker_ku"), Padding(4),
            MilliMeter(UBInt32("ocean_range_ku")),
            MilliMeter(UBInt32("band_ocean_range_s")),
            Array(20, MilliMeter(UBInt32("18hz_ocean_range_ku"))),
            Array(20, MilliMeter(UBInt32("18hz_ocean_range_s"))),
            MilliMeter(UBInt16("sd_18hz_ocean_range_ku")),
            MilliMeter(UBInt16("sd_18hz_ocean_range_s")),
            UBInt16("18hz_n_valid_ocean_ku"), UBInt16("18hz_n_valid_ocean_s"),
            BitStruct("18hz_valid_points_ocean_ku", Array(32, Bit("flag"))),
            BitStruct("18hz_valid_points_ocean_s", Array(32, Bit("flag"))),
            Array(20, MilliMeter(UBInt32("18Hz_ice1_range_ku"))),
            Array(20, MilliMeter(UBInt32("18Hz_ice1_range_s"))),
            Array(20, MilliMeter(UBInt32("18Hz_ice2_range_ku"))),
            Array(20, MilliMeter(UBInt32("18Hz_ice2_range_s"))),
            Array(20, MilliMeter(UBInt32("18Hz_sea_ice_range_ku"))),
            Array(20, TenMicroDeg(SBInt16("18hz_latitude_differences"))),
            Array(20, TenMicroDeg(SBInt16("18hz_longitude_differences"))))

        self.range_correction = Struct(
            "range_correction",
            Array(20, MilliMeter(SBInt16("18Hz_ku_range_instrumental"))),
            Array(20, MilliMeter(SBInt16("18Hz_s_range_instrumental"))),
            Array(20, MilliMeter(SBInt16("18Hz_ku_range_doppler"))),
            Array(20, MilliMeter(SBInt16("18Hz_s_range_doppler"))),
            Array(20, MilliMeter(SBInt16("18Hz_ku_range_doppler_slope"))),
            Array(20, MilliMeter(SBInt16("18Hz_s_range_doppler_slope"))),
            MilliMeter(SBInt16("dry_troposphere")),
            MilliMeter(SBInt16("inverse_barometric")),
            MilliMeter(SBInt16("wet_troposphere_model")),
            MilliMeter(SBInt16("wet_troposphere_mwr")),
            MilliMeter(SBInt16("ra2_ionosphere_ku")),
            MilliMeter(SBInt16("ra2_ionosphere_s")),
            MilliMeter(SBInt16("doris_ionosphere_ku")),
            MilliMeter(SBInt16("doris_ionosphere_s")),
            MilliMeter(SBInt16("model_ionosphere_ku")),
            MilliMeter(SBInt16("model_ionosphere_s")),
            MilliMeter(SBInt16("sea_state_bias_ku")),
            MilliMeter(SBInt16("sea_state_bias_s")),
            MilliMeter(SBInt16("dib_hf")), Padding(10))

        self.significant_wave_height = Struct(
            "significant_wave_height", MilliMeter(SBInt32("swh_square_ku")),
            MilliMeter(SBInt32("swh_square_s")), MilliMeter(SBInt16("swh_ku")),
            MilliMeter(SBInt16("swh_s")),
            MilliMeter(SBInt16("swh_sd_18hz_ku")),
            MilliMeter(SBInt16("swh_sd_18hz_s")),
            UBInt16("shw_18hz_n_valid_ku"), UBInt16("shw_18hz_n_valid_s"),
            BitStruct("slope_model_present", Array(32, Bit("flag"))),
            Centimeter(SBInt32("1hz_elevation_echo_point")),
            Array(20, Centimeter(SBInt16("18hz_elevation_difference"))),
            Array(20, TenMicroDeg(SBInt16("18hz_slope_latitude_diff"))),
            Array(20, TenMicroDeg(SBInt16("18hz_slope_longitude_diff"))),
            Array(20, MilliMeter(SBInt16("18hz_ice2_leading_edge_width_ku"))),
            Array(20, MilliMeter(SBInt16("18hz_ice2_leading_edge_width_s"))),
            Padding(40))

        self.backscatter = Struct(
            "backscatter",
            Array(20, OneHundredthDecibel(SBInt16("18hz_ku_k_cal_ku"))),
            Array(20, OneHundredthDecibel(SBInt16("18hz_s_k_cal_s"))),
            BitStruct("map_valid_k_cal_ku", Array(32, Bit("flag"))),
            Padding(4), OneHundredthDecibel(SBInt16("ocean_sigma_corr_ku")),
            OneHundredthDecibel(SBInt16("ocean_sigma_corr_s")),
            OneHundredthDecibel(SBInt16("sd_18hz_ocean_sigma_ku")),
            OneHundredthDecibel(SBInt16("sd_18hz_ocean_sigma_s")),
            UBInt16("n_valid_18hz_ocean_sigma_ku"),
            UBInt16("n_valid_18hz_ocean_sigma_s"),
            Array(20, OneHundredthDecibel(SBInt16("18hz_ice1_sigma_ku"))),
            Array(20, OneHundredthDecibel(SBInt16("18hz_ice1_sigma_s"))),
            Array(20, OneHundredthDecibel(SBInt16("18hz_ice2_le_sigma_ku"))),
            Array(20, OneHundredthDecibel(SBInt16("18hz_ice2_le_sigma_s"))),
            Array(20, OneHundredthDecibel(SBInt16("18hz_ice2_sigma_ku"))),
            Array(20, OneHundredthDecibel(SBInt16("18hz_ice2_sigma_s"))),
            Array(20, OneHundredthDecibel(SBInt16("18hz_sea_ice_sigma_ku"))),
            Padding(40))

        self.backscatter_correction = Struct(
            "backscatter_correction",
            OneHundredthDecibel(SBInt16("agc_net_instrumental_ku")),
            OneHundredthDecibel(SBInt16("agc_net_instrumental_s")),
            OneHundredthDecibel(SBInt16("atmospheric_attenuation_ku")),
            OneHundredthDecibel(SBInt16("atmospheric_attenuation_s")),
            OneHundredthDecibel(SBInt32("rain_attenuation_ku")))

        self.off_nadir_information = Struct(
            "off_nadir_angle",
            TenThousands(SBInt16("square_angle_from_platform_data")),
            TenThousands(SBInt16("square_angle_from_waveform_data")),
            Array(20, SBInt32("slope_ice2_first_trailing_edge_ku")),
            Array(20, SBInt32("slope_ice2_first_trailing_edge_s")),
            Array(20, SBInt32("slope_ice2_second_trailing_edge_ku")),
            Array(20, SBInt32("slope_ice2_second_trailing_edge_s")),
            Padding(40))

        self.geophysical_information = Struct(
            "geophysical_information",
            MilliMeter(SBInt32("mean_sea_surface_height")),
            MilliMeter(SBInt32("geoid_height")),
            MilliMeter(SBInt32("ocean_depth_land_elevation")),
            MilliMeter(SBInt16("total_geocentric_ocean_tide_1")),
            MilliMeter(SBInt16("total_geocentric_ocean_tide_2")),
            MilliMeter(SBInt16("ocean_tide_long_period")),
            MilliMeter(SBInt16("ocean_loading_tide_2")),
            MilliMeter(SBInt16("solid_earth_tide")),
            MilliMeter(SBInt16("geocentric_polar_tide")),
            TenPascal(SBInt16("model_surface_atmospheric_pressure")),
            OneHundredth(SBInt16("mwr_water_vapour_content")),
            OneHundredth(SBInt16("mwr_liquid_water_content")),
            OneTenths(SBInt16("ra2_total_electron_content")),
            MilliMeter(SBInt16("ra2_wind_speed")),
            MilliMeter(SBInt16("model_wind_vector_u")),
            MilliMeter(SBInt16("model_wind_vector_v")),
            MilliMeter(SBInt16("ocean_loading_tide_1")), Padding(8))

        self.mwr_information = Struct(
            "mwr_information",
            OneHundredth(SBInt16("mwr_brightness_temp_23_8ghz")),
            OneHundredth(SBInt16("mwr_brightness_temp_36_5ghz")),
            OneHundredth(SBInt16("mwr_sd_brightness_temp_23_8ghz")),
            OneHundredth(SBInt16("mwr_sd_brightness_temp_36_5ghz")),
            Padding(2))

        self.flags = Struct(
            "flag", UBInt16("average_ku_chirp_band"),
            BitStruct("ku_chirp_band_id", Array(64, Bit("flag"))),
            BitStruct("error_chirp_band_id", Array(32, Bit("flag"))),
            BitStruct("instrument", Array(32, Bit("flag"))),
            BitStruct("fault_identifier", Array(64, Bit("flag"))), Padding(8),
            BitStruct("waveform_fault_identifier", Array(64, Bit("flag"))),
            BitStruct("instrument_mode_id", Array(96, Bit("flag"))),
            UBInt16("n_measures_flight_calibration_s"),
            UBInt16("n_measures_flight_calibration_ku"),
            BitStruct("mwr_instrument_quality", Array(16, Bit("flag"))),
            Padding(6), Padding(8), Padding(8),
            BitStruct("ocean_retracking_quality_ku", Array(32, Bit("flag"))),
            BitStruct("ocean_retracking_quality_s", Array(32, Bit("flag"))),
            BitStruct("ice1_retracking_quality_ku", Array(32, Bit("flag"))),
            BitStruct("ice1_retracking_quality_s", Array(32, Bit("flag"))),
            BitStruct("ice2_retracking_quality_ku", Array(32, Bit("flag"))),
            BitStruct("ice2_retracking_quality_s", Array(32, Bit("flag"))),
            BitStruct("sea_ice_retracking_quality_ku", Array(32, Bit("flag"))),
            OneThousands(UBInt16("1hz_pulse_peakiness_ku")),
            OneThousands(UBInt16("1hz_pulse_peakiness_s")),
            UBInt16("altimeter_surface_type"),
            UBInt16("radiometer_land_ocean"),
            UBInt16("mwr_quality_interpolation"), UBInt16("altimeter_rain"),
            UBInt16("interpolation"), UBInt8("sea_ice"),
            BitStruct("membership_01", Array(8, Bit("flag"))),
            BitStruct("membership_02", Array(8, Bit("flag"))),
            BitStruct("membership_03", Array(8, Bit("flag"))),
            BitStruct("membership_04", Array(8, Bit("flag"))), Padding(1))

        self.mds_record = Struct("mds_record", self.time_orbit,
                                 self.range_information, self.range_correction,
                                 self.significant_wave_height,
                                 self.backscatter, self.backscatter_correction,
                                 self.off_nadir_information,
                                 self.geophysical_information,
                                 self.mwr_information, self.flags)

        self.mds = Array(self.n_records, self.mds_record)

        return self.mds
예제 #4
0
    def get_mds_parser(self):

        self.timestamp = Struct("utc_timestamp", SBInt32("day"),
                                UBInt32("sec"), UBInt32("msec"))

        self.time_orbit = Struct(
            "time_orbit", self.timestamp, SBInt8("quality_indicator"),
            Padding(3), MicroDeg(SBInt32("latitude")),
            MicroDeg(SBInt32("longitude")), UBInt32("source_packet_counter"),
            UBInt32("instrument_mode_id"),
            BitStruct("measurement_confidence_data", Array(32, Bit("flag"))),
            MilliMeter(UBInt32("altitude")),
            Array(20, MilliMeter(SBInt16("18hz_altitude_differences"))),
            MilliMeter(SBInt16("instantaneous_altitude_rate")), Padding(50))

        self.range_information = Struct(
            "range_information",
            Array(20, MilliMeter(UBInt32("18hz_tracker_range_no_doppler_ku"))),
            Padding(80), UBInt32("map_valid_points_tracker_ku"), Padding(4),
            MilliMeter(UBInt32("ocean_range_ku")), Padding(580),
            Array(20, TenMicroDeg(SBInt16("18hz_latitude_differences"))),
            Array(20, TenMicroDeg(SBInt16("18hz_longitude_differences"))))

        self.range_correction = Struct(
            "range_correction",
            Array(20, MilliMeter(SBInt16("18Hz_ku_range_instrumental"))),
            Padding(40), Array(20,
                               MilliMeter(SBInt16("18Hz_ku_range_doppler"))),
            Padding(40),
            Array(20, MilliMeter(SBInt16("18Hz_ku_range_doppler_slope"))),
            Padding(40), MilliMeter(SBInt16("dry_troposphere")),
            MilliMeter(SBInt16("inverse_barometric")),
            MilliMeter(SBInt16("wet_troposphere_model")),
            MilliMeter(SBInt16("wet_troposphere_mwr")),
            MilliMeter(SBInt16("ra2_ionosphere_ku")), Padding(2),
            MilliMeter(SBInt16("doris_ionosphere_ku")), Padding(2),
            MilliMeter(SBInt16("model_ionosphere_ku")), Padding(2),
            MilliMeter(SBInt16("sea_state_bias_ku")), Padding(2),
            MilliMeter(SBInt16("dib_hf")), Padding(10))

        self.significant_wave_height = Padding(268)

        self.backscatter = Struct(
            "backscatter", Padding(340),
            Array(20, OneHundredthDecibel(SBInt16("18hz_sea_ice_sigma_ku"))),
            Padding(40))

        self.backscatter_correction = Padding(12)

        self.off_nadir_information = Padding(364)

        self.geophysical_information = Struct(
            "geophysical_information",
            MilliMeter(SBInt32("mean_sea_surface_height")),
            MilliMeter(SBInt32("geoid_height")),
            MilliMeter(SBInt32("ocean_depth_land_elevation")),
            MilliMeter(SBInt16("total_geocentric_ocean_tide_1")),
            MilliMeter(SBInt16("total_geocentric_ocean_tide_2")),
            MilliMeter(SBInt16("ocean_tide_long_period")),
            MilliMeter(SBInt16("ocean_loading_tide_2")),
            MilliMeter(SBInt16("solid_earth_tide")),
            MilliMeter(SBInt16("geocentric_polar_tide")),
            TenPascal(SBInt16("model_surface_atmospheric_pressure")),
            OneHundredth(SBInt16("mwr_water_vapour_content")),
            OneHundredth(SBInt16("mwr_liquid_water_content")),
            OneTenths(SBInt16("ra2_total_electron_content")),
            MilliMeter(SBInt16("ra2_wind_speed")),
            MilliMeter(SBInt16("model_wind_vector_u")),
            MilliMeter(SBInt16("model_wind_vector_v")),
            MilliMeter(SBInt16("ocean_loading_tide_1")), Padding(8))

        self.mwr_information = Padding(10)

        self.flags = Struct("flag", UBInt16("average_ku_chirp_band"),
                            Padding(112), UBInt16("altimeter_surface_type"),
                            UBInt16("radiometer_land_ocean"), Padding(6),
                            UBInt8("sea_ice"), Padding(5))

        self.mds_record = Struct("mds_record", self.time_orbit,
                                 self.range_information, self.range_correction,
                                 self.significant_wave_height,
                                 self.backscatter, self.backscatter_correction,
                                 self.off_nadir_information,
                                 self.geophysical_information,
                                 self.mwr_information, self.flags)

        self.mds = Array(self.n_records, self.mds_record)

        return self.mds
예제 #5
0
                       UBInt8("command"),
                       Field("data", lambda ctx: ctx.size - 7))
struct_byte = Struct("byte",
                     UBInt8("byte"))

struct_batt_connected = Struct("batt_connected",
                               UBInt8("slots_number"),
                               Array(lambda ctx: ctx.slots_number,
                                     UBInt8("slots")))
struct_batt_get_status = Struct("batt_get_status",
                                UBInt8("batt_number"),
                                Array(lambda ctx: ctx.batt_number,
                                      Struct("batt_data",
                                             UBInt8("slot_number"),
                                             UBInt16("tension"),
                                             SBInt16("corriente"),
                                             LFloat32("temp"),
                                             UBInt16("remaining"),
                                             UBInt16("full_charge"),
                                             UBInt16("ciclos"))))
struct_batt_params = Struct("batt_params",
                            UBInt8("batt_number"),
                            Array(lambda ctx: ctx.batt_number,
                                  Struct("batt_data",
                                         UBInt8("slot_number"),
                                         UBInt16("design_capacity"),
                                         Array(11, UBInt8("manufacturer")),
                                         UBInt16("serial_number"),
                                         Array(7, UBInt8("model")),
                                         Array(4, UBInt8("chem")),
                                         UBInt16("date_manuf"),
예제 #6
0
from empower.core.app import EmpowerApp
from empower.datatypes.etheraddress import EtherAddress
from empower.lvapp import PT_VERSION
from empower.core.module import Module
from empower.core.module import ModuleLVAPPWorker

from empower.main import RUNTIME

PT_ADD_SUMMARY = 0x22
PT_SUMMARY = 0x23
PT_DEL_SUMMARY = 0x24

ADD_SUMMARY = Struct("add_summary", UBInt8("version"), UBInt8("type"),
                     UBInt16("length"), UBInt32("seq"), UBInt32("module_id"),
                     Bytes("addrs", 6), Bytes("hwaddr", 6), UBInt8("channel"),
                     UBInt8("band"), SBInt16("limit"), UBInt16("period"))

SUMMARY_ENTRY = Sequence("frames", Bytes("addr", 6), UBInt64("tsft"),
                         UBInt16("seq"), SBInt8("rssi"), UBInt8("rate"),
                         UBInt8("type"), UBInt8("subtype"), UBInt32("length"))

SUMMARY_TRIGGER = Struct("summary", UBInt8("version"), UBInt8("type"),
                         UBInt16("length"), UBInt32("seq"),
                         UBInt32("module_id"), Bytes("wtp", 6),
                         UBInt16("nb_entries"),
                         Array(lambda ctx: ctx.nb_entries, SUMMARY_ENTRY))

DEL_SUMMARY = Struct("del_summary", UBInt8("version"), UBInt8("type"),
                     UBInt16("length"), UBInt32("seq"), UBInt32("module_id"))

예제 #7
0
                         BitStruct("flags", Padding(15), Bit("dir")),
                         UBInt32("seq"),
                         UBInt16("length"),
                         UBInt16("action"),
                         UBInt8("opcode"),
                         UBInt8("meas_id"),
                         UBInt16("rnti"),
                         UBInt16("earfcn"),
                         UBInt16("interval"),
                         UBInt16("max_cells"),
                         UBInt16("max_meas"))

UE_MEAS_ENTRY = Struct("ue_meas_entries",
                       UBInt8("meas_id"),
                       UBInt16("pci"),
                       SBInt16("rsrp"),
                       SBInt16("rsrq"))

UE_MEAS_RESPONSE = Struct("ue_meas_response",
                          UBInt32("nof_meas"),
                          Array(lambda ctx: ctx.nof_meas, UE_MEAS_ENTRY))


class UEMeasurements(ModulePeriodic):
    """ UEMurements object. """

    MODULE_NAME = "ue_measurements"
    REQUIRED = ['module_type', 'worker', 'tenant_id', 'ue', 'measurements']

    def __init__(self):
예제 #8
0
                            UBInt16("cellid"), UBInt32("xid"),
                            BitStruct("flags", Padding(15), Bit("dir")),
                            UBInt32("seq"), UBInt16("length"),
                            UBInt16("action"), UBInt8("opcode"),
                            Rename("options", OptionalGreedyRange(OPTIONS)))

UE_MEASURE_RESPONSE = Struct("ue_measure_response",
                             Rename("options", OptionalGreedyRange(OPTIONS)))

RRC_MEASURE_REQUEST = Struct("rrc_measure_request", UBInt16("measure_id"),
                             UBInt16("rnti"), UBInt16("earfcn"),
                             UBInt16("interval"), UBInt16("max_cells"),
                             UBInt16("max_measure"))

RRC_MEASURE_REPORT = Struct("rrc_measure_report", UBInt16("measure_id"),
                            UBInt16("pci"), SBInt16("rsrp"), SBInt16("rsrq"))

EP_RRC_MEASURE_REQUEST = 0x0600
EP_RRC_MEASURE_REPORT = 0x0601

UE_MEASURE_TYPES = {EP_RRC_MEASURE_REPORT: RRC_MEASURE_REPORT}


class UEMeasurements(ModulePeriodic):
    """ UEMurements object. """

    MODULE_NAME = "ue_measurements"
    REQUIRED = ['module_type', 'worker', 'tenant_id', 'ue', \
                'rrc_measurements_param']

    def __init__(self):
예제 #9
0
    return StringAdapter(MetaField("data", lambda ctx: ctx[size_name]),
                         encoding=encoding)


class NBTAdapter(Adapter):
    def _decode(self, obj, context):
        return NBTFile(StringIO(obj), compression=NBTFile.Compression.GZIP)


def NBTdata(name, size_name):
    return NBTAdapter(MetaField(name, lambda ctx: ctx[size_name]))


# item packing
slotdata = Struct(
    "slotdata", SBInt16("id"),
    If(
        lambda context: context["id"] >= 0,
        Embed(
            Struct(
                "item_information", UBInt8("count"), UBInt16("damage"),
                SBInt16("size"),
                If(lambda context: context["size"] >= 0,
                   NBTdata("data", size_name="size"))))))


def itemstack_as_slotdata(itemstack):
    if itemstack is None:
        data = {'id': -1}
    else:
        data = {
예제 #10
0
from empower.main import RUNTIME

PT_ADD_SUMMARY = 0x23
PT_SUMMARY = 0x24
PT_DEL_SUMMARY = 0x25

ADD_SUMMARY = Struct("add_summary", UBInt8("version"),
                     UBInt8("type"),
                     UBInt32("length"),
                     UBInt32("seq"),
                     UBInt32("module_id"),
                     Bytes("addr", 6),
                     Bytes("hwaddr", 6),
                     UBInt8("channel"),
                     UBInt8("band"),
                     SBInt16("limit"),
                     UBInt16("period"))

SUMMARY_ENTRY = Sequence("frames",
                         Bytes("ra", 6),
                         Bytes("ta", 6),
                         UBInt64("tsft"),
                         BitStruct("flags",
                                   Padding(6),
                                   Bit("mcs"),
                                   Padding(9)),
                         UBInt16("seq"),
                         SBInt8("rssi"),
                         UBInt8("rate"),
                         UBInt8("type"),
                         UBInt8("subtype"),
예제 #11
0
파일: packets.py 프로젝트: alucas/bravo
# Boolean converter.
def Bool(*args, **kwargs):
    return Flag(*args, default=True, **kwargs)


# Flying, position, and orientation, reused in several places.
grounded = Struct("grounded", UBInt8("grounded"))
position = Struct("position", BFloat64("x"), BFloat64("y"), BFloat64("stance"),
                  BFloat64("z"))
orientation = Struct("orientation", BFloat32("rotation"), BFloat32("pitch"))

# TODO: this must be replaced with 'slot' (see below)
# Notchian item packing (slot data)
items = Struct(
    "items",
    SBInt16("primary"),
    If(
        lambda context: context["primary"] >= 0,
        Embed(
            Struct(
                "item_information",
                UBInt8("count"),
                UBInt16("secondary"),
                Magic("\xff\xff"),
            )),
    ),
)

Speed = namedtuple('speed', 'x y z')

예제 #12
0
def Bool(*args, **kwargs):
    return Flag(*args, default=True, **kwargs)

# Flying, position, and orientation, reused in several places.
grounded = Struct("grounded", UBInt8("grounded"))
position = Struct("position",
    BFloat64("x"),
    BFloat64("y"),
    BFloat64("stance"),
    BFloat64("z")
)
orientation = Struct("orientation", BFloat32("rotation"), BFloat32("pitch"))

# Notchian item packing
items = Struct("items",
    SBInt16("primary"),
    If(lambda context: context["primary"] >= 0,
        Embed(Struct("item_information",
            UBInt8("count"),
            UBInt16("secondary"),
            Magic("\xff\xff"),
        )),
    ),
)

Metadata = namedtuple("Metadata", "type value")
metadata_types = ["byte", "short", "int", "float", "string", "slot",
    "coords"]

# Metadata adaptor.
class MetadataAdapter(Adapter):
예제 #13
0
    def get_mds_parser(self):

        self.mdsr_timestamp = Struct(
            "tai_timestamp",
            SBInt32("day"),
            UBInt32("sec"),
            UBInt32("msec"))

        self.time_orbit_group = Struct(
            "time_orbit",
            self.mdsr_timestamp,
            UBInt16("uso_corr"),
            UBInt32("mode_id"),
            UBInt16("source_sequence_counter"),
            UBInt32("instrument_configuration"),
            UBInt32("burst_counter"),
            OneTenthMicroDeg(SBInt32("latitude")),
            OneTenthMicroDeg(SBInt32("longitude")),
            MilliMeter(SBInt32("altitude")),
            MilliMeter(SBInt32("altitude_rate")),
            Array(3, MilliMeter(SBInt32("satellite_velocity"))),
            Array(3, Micrometer(SBInt32("real_beam"))),
            Array(3, Micrometer(SBInt32("interferometry_baseline"))),
            UBInt16("star_tracker_usage"),
            OneTenthMicroDeg(SBInt32("antenna_roll")),
            OneTenthMicroDeg(SBInt32("antenna_pitch")),
            OneTenthMicroDeg(SBInt32("antenna_yaw")),
            UBInt32("fbr_confidence_flag"),
            Padding(4))

        self.measurement_group = Struct(
            "measurement",
            PicoSecond(SBInt64("window_delay")),
            SBInt32("h0"),
            SBInt32("cor2"),
            SBInt32("lai"),
            SBInt32("fai"),
            OneHundredthDecibel(SBInt32("agc_1")),
            OneHundredthDecibel(SBInt32("agc_2")),
            OneHundredthDecibel(SBInt32("fixed_gain_1")),
            OneHundredthDecibel(SBInt32("fixed_gain_2")),
            MicroWatts(SBInt32("tx_power")),
            MilliMeter(SBInt32("doppler_range_correction")),
            MilliMeter(SBInt32("instrument_range_correction_txrx")),
            MilliMeter(SBInt32("instrument_range_correction_rx")),
            OneHundredthDecibel(SBInt32("instrument_gain_correction_txrx")),
            OneHundredthDecibel(SBInt32("instrument_gain_correction_rx")),
            MicroRadians(SBInt32("phase_correction_internal")),
            MicroRadians(SBInt32("phase_correction_external")),
            OneHundredthDecibel(SBInt32("noise_power")),
            MicroRadians(SBInt32("phase_slope_correction")),
            Padding(4))

        self.corrections_group = Struct(
            "corrections",
            MilliMeter(SBInt32("dry_troposphere")),
            MilliMeter(SBInt32("wet_troposphere")),
            MilliMeter(SBInt32("inverse_barometric")),
            MilliMeter(SBInt32("dynamic_atmosphere")),
            MilliMeter(SBInt32("ionospheric_gim")),
            MilliMeter(SBInt32("ionospheric_mod")),
            MilliMeter(SBInt32("ocean_tide_elastic")),
            MilliMeter(SBInt32("ocean_tide_long_period")),
            MilliMeter(SBInt32("ocean_loading_tide")),
            MilliMeter(SBInt32("solid_earth_tide")),
            MilliMeter(SBInt32("geocentric_polar_tide")),
            UBInt32("surface_type"),
            Padding(4),
            UBInt32("correction_status"),
            UBInt32("correction_error"),
            Padding(4))

#        self.onehz_waveform_group = Struct(
#            "avg_waveform",
#            self.mdsr_timestamp,
#            OneTenthMicroDeg(SBInt32("latitude")),
#            OneTenthMicroDeg(SBInt32("longitude")),
#            MilliMeter(SBInt32("altitude")),
#            PicoSecond(UBInt64("window_delay")),
#            Array(512, UBInt16("wfm")),
#            SBInt32("linear_scale"),
#            SBInt32("power_scale"),
#            UBInt16("num_avg_echoes"),
#            UBInt16("flags"))
        self.onehz_waveform_group = Padding(1068)
        # stop

#        self.waveform_flag_group = BitStruct(
#            "flag",
#            Bit("approximate_beam_steering"),
#            Bit("exact_beam_steering"),
#            Bit("doppler_weighting_computed"),
#            Bit("dopple_weighting_applied_before_stack"),
#            Bit("multi_look_incomplete"),
#            Bit("beam_angle_steering_error"),
#            Bit("anti_aliased_power_echoes"),
#            Bit("auto_beam_steering"),
#            Padding(8))

        self.waveform_flag_group = Padding(2)

        self.waveform_beam_group = Struct(
            "beam",
            OneHundredth(UBInt16("stack_standard_deviation")),
            OneHundredth(UBInt16("stack_centre")),
            OneHundredthDecibel(SBInt16("stack_scaled_amplitude")),
            OneHundredth(SBInt16("stack_skewness")),
            OneHundredth(SBInt16("stack_kurtosis")),
            MicroRadians(SBInt16("stack_standard_deviation_boresight")),
            MicroRadians(SBInt16("stack_centre_angle")),
            OneTenthMicroRadians(SBInt32("doppler_angle_start")),
            OneTenthMicroRadians(SBInt32("doppler_angle_stop")),
            OneTenthMicroRadians(SBInt32("look_angle_start")),
            OneTenthMicroRadians(SBInt32("look_angle_stop")),
            UBInt16("n_beams_after_weighing"),
            UBInt16("n_beams_before_weighing"),
            Padding(66))

#        self.waveform_group = Struct(
#            "waveform",
#            Array(1024, UBInt16("wfm")),
#            SBInt32("linear_scale"),
#            SBInt32("power_scale"),
#            UBInt16("num_avg_echoes"),
#            self.waveform_flag_group,
#            self.waveform_beam_group,
#            Array(1024, UBInt16("coherence")),
#            Array(1024, SBInt32("phase_difference")))

        self.waveform_group = Struct(
            "waveform",
            Array(1024, UBInt16("wfm")),
            SBInt32("linear_scale"),
            SBInt32("power_scale"),
            UBInt16("num_avg_echoes"),
            self.waveform_flag_group,
            self.waveform_beam_group,
            Padding(6144))

        self.mds_record = Struct(
            "mds_record",
            Array(self.n_blocks, self.time_orbit_group),
            Array(self.n_blocks, self.measurement_group),
            self.corrections_group,
            self.onehz_waveform_group,
            Array(self.n_blocks, self.waveform_group))

        self.mds = Array(self.n_records, self.mds_record)

        return self.mds
예제 #14
0
from empower.lvapp import PT_LVAP_JOIN
from empower.lvapp import PT_LVAP_LEAVE

from empower.main import RUNTIME

import empower.logger

LOG = empower.logger.get_logger()

PT_ADD_SUMMARY = 0x22
PT_SUMMARY = 0x23
PT_DEL_SUMMARY = 0x24

ADD_SUMMARY = Struct("add_summary", UBInt8("version"), UBInt8("type"),
                     UBInt16("length"), UBInt32("seq"), UBInt32("trigger_id"),
                     SBInt16("limit"), UBInt16("every"), Bytes("sta", 6))

SUMMARY_ENTRY = Sequence("frames", Bytes("addr", 6), UBInt64("tsft"),
                         UBInt16("seq"), SBInt8("rssi"), UBInt8("rate"),
                         UBInt8("type"), UBInt8("subtype"), UBInt32("length"),
                         UBInt32("dur"))

SUMMARY_TRIGGER = Struct("summary", UBInt8("version"), UBInt8("type"),
                         UBInt16("length"), UBInt32("seq"),
                         UBInt32("trigger_id"), Bytes("wtp", 6),
                         Bytes("sta", 6), UBInt16("nb_entries"),
                         Array(lambda ctx: ctx.nb_entries, SUMMARY_ENTRY))

DEL_SUMMARY = Struct("del_summary", UBInt8("version"), UBInt8("type"),
                     UBInt16("length"), UBInt32("seq"), UBInt32("trigger_id"),
                     Bytes("sta", 6))
예제 #15
0
struct_base = Struct("base", UBInt8("version"), SizeAdapter(Field("size", 3)))

struct_common = Struct("common", Embed(struct_base), UBInt8("msg_type"),
                       UBInt8("device"), UBInt8("command"),
                       Field("data", lambda ctx: ctx.size - 7))
struct_byte = Struct("byte", UBInt8("byte"))

struct_batt_connected = Struct(
    "batt_connected", UBInt8("slots_number"),
    Array(lambda ctx: ctx.slots_number, UBInt8("slots")))
struct_batt_get_status = Struct(
    "batt_get_status", UBInt8("batt_number"),
    Array(
        lambda ctx: ctx.batt_number,
        Struct("batt_data", UBInt8("slot_number"), UBInt16("tension"),
               SBInt16("corriente"), LFloat32("temp"), UBInt16("remaining"),
               UBInt16("full_charge"), UBInt16("ciclos"))))
struct_batt_params = Struct(
    "batt_params", UBInt8("batt_number"),
    Array(
        lambda ctx: ctx.batt_number,
        Struct("batt_data", UBInt8("slot_number"), UBInt16("design_capacity"),
               Array(11, UBInt8("manufacturer")), UBInt16("serial_number"),
               Array(7, UBInt8("model")), Array(4, UBInt8("chem")),
               UBInt16("date_manuf"), UBInt16("nominal_tension"))))
struct_power_check = Struct("power_check", LFloat32("v_24"), LFloat32("v_12"),
                            LFloat32("v_5"), LFloat32("v_3"))
struct_batt_level = Struct("batt_level", UBInt8("slot_number"),
                           UBInt8("level_empty"), UBInt8("level_critical"),
                           UBInt8("level_min"), UBInt8("full_charge"),
                           UBInt16("full_charge_current"))