diff --git a/Aggregates/arrays_updaters.py b/Aggregates/arrays_updaters.py index 02524dfae626809238757ca0bd28adced89d4c61..1be307ea5e63169c7e55ee4d6e1ef83d318f1285 100644 --- a/Aggregates/arrays_updaters.py +++ b/Aggregates/arrays_updaters.py @@ -903,520 +903,6 @@ def updateGauge(gauge): else: gauge.dataParts[to_update_index] = "{} cm".format(gauge.dataParts[to_update_index]) -def updateReservedSlot(slot): - to_update_index = slot.fields.find("\tTime-out") - slot.dataParts[to_update_index] = "{} minutes".format(slot.dataParts[to_update_index]) - - to_update_index = wind.fields.index("\t\tForecast Duration") - if wind.dataParts[to_update_index] == 0: - wind.dataParts[to_update_index] = "cancel forecast" - elif wind.dataParts[to_update_index] == 255: - wind.dataParts[to_update_index] = "N/A" - else: - wind.dataParts[to_update_index] = "{} minutes".format(wind.dataParts[to_update_index]) - -def updateWaterLevelPayload(water): - to_update_index = water.fields.index("\t\tWater Level Type") - level_types = ["relative to reference datum", "not relative to reference datum"] - water.dataParts[to_update_index] = level_types[water.dataParts[to_update_index]] - - to_update_index = water.fields.index("\t\tWater Level") - if water.dataParts[to_update_index] == -32767: - water.dataParts[to_update_index] = "-327.67 metres or less" - elif water.dataParts[to_update_index] == 32767: - water.dataParts[to_update_index] = "327.67 metres or more" - elif water.dataParts[to_update_index] == -32768: - water.dataParts[to_update_index] = "N/A" - else: - water.dataParts[to_update_index] = "{} meter steps".format(water.dataParts[to_update_index]*0.01) - - to_update_index = water.fields.index("\t\tWater Level Trend") - wtrends = ["increasing", "decreasing", "steady", "N/A"] - water.dataParts[to_update_index] = wtrends[water.dataParts[to_update_index]] - - to_update_index = water.fields.index("\t\tVertical Reference Datum") - water.dataParts[to_update_index] = enums.verticalReferenceDatum[water.dataParts[to_update_index]] - - to_update_index = water.fields.index("\t\tSensor Description") - water.dataParts[to_update_index] = enums.sensorTypes[water.dataParts[to_update_index]] - - to_update_index = water.fields.index("\t\tForecast Water Level Type") - level_types = ["relative to reference datum", "not relative to reference datum"] - water.dataParts[to_update_index] = level_types[water.dataParts[to_update_index]] - - to_update_index = water.fields.index("\t\tForecast Water Level") - if water.dataParts[to_update_index] == -32767: - water.dataParts[to_update_index] = "-327.67 metres or less" - elif water.dataParts[to_update_index] == 32767: - water.dataParts[to_update_index] = "327.67 metres or more" - elif water.dataParts[to_update_index] == -32768: - water.dataParts[to_update_index] = "N/A" - else: - water.dataParts[to_update_index] = "{} meter steps".format(water.dataParts[to_update_index]*0.01) - - to_update_index = water.fields.index("\t\tDay (UTC)") - if(water.dataParts[to_update_index]) == 0: - water.dataParts[to_update_index] = "N/A" - to_update_index = water.fields.index("\t\tHour (UTC)") - if(water.dataParts[to_update_index]) == 24: - water.dataParts[to_update_index] = "N/A (UTC)" - to_update_index = water.fields.index("\t\tMinute (UTC)") - if(water.dataParts[to_update_index]) == 60: - water.dataParts[to_update_index] = "N/A" - - to_update_index = water.fields.index("\t\tForecast Duration") - if water.dataParts[to_update_index] == 0: - water.dataParts[to_update_index] = "cancel forecast" - elif water.dataParts[to_update_index] == 255: - water.dataParts[to_update_index] = "N/A" - else: - water.dataParts[to_update_index] = "{} minutes".format(water.dataParts[to_update_index]) - -def updateCurrentFlow2dPayload(current): - to_update_index = current.fields.index("\t\tCurrent Speed 1") - if current.dataParts[to_update_index] == 24.6: - current.dataParts[to_update_index] = "24.6 knots or more" - elif current.dataParts[to_update_index] == 24.7: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} knots".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tCurrent Direction 1") - if current.dataParts[to_update_index] == 360: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} deg from true north".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tMeasurement Depth 1") - if current.dataParts[to_update_index] == 361: - current.dataParts[to_update_index] = "361 metres or greater" - elif current.dataParts[to_update_index] == 362: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} metres down".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tCurrent Speed 2") - if current.dataParts[to_update_index] == 24.6: - current.dataParts[to_update_index] = "24.6 knots or more" - elif current.dataParts[to_update_index] == 24.7: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} knots".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tCurrent Direction 2") - if current.dataParts[to_update_index] == 360: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} deg from true north".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tMeasurement Depth 2") - if current.dataParts[to_update_index] == 361: - current.dataParts[to_update_index] = "361 metres or greater" - elif current.dataParts[to_update_index] == 362: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} metres down".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tCurrent Speed 3") - if current.dataParts[to_update_index] == 24.6: - current.dataParts[to_update_index] = "24.6 knots or more" - elif current.dataParts[to_update_index] == 24.7: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} knots".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tCurrent Direction 3") - if current.dataParts[to_update_index] == 360: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} deg from true north".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tMeasurement Depth 3") - if current.dataParts[to_update_index] == 361: - current.dataParts[to_update_index] = "361 metres or greater" - elif current.dataParts[to_update_index] == 362: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} metres down".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tSensor Description") - current.dataParts[to_update_index] = enums.sensorTypes[current.dataParts[to_update_index]] - -def updateCurrentFlow3dPayload(current): - to_update_index = current.fields.index("\t\tCurrent Vector component North (u) 1") - if current.dataParts[to_update_index] == 24.6: - current.dataParts[to_update_index] = "24.6 knots or more" - elif current.dataParts[to_update_index] == 24.7: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} knots".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tCurrent Vector component North (v) 1") - if current.dataParts[to_update_index] == 24.6: - current.dataParts[to_update_index] = "24.6 knots or more" - elif current.dataParts[to_update_index] == 24.7: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} knots".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tCurrent Vector component North (z) 1") - if current.dataParts[to_update_index] == 24.6: - current.dataParts[to_update_index] = "24.6 knots or more" - elif current.dataParts[to_update_index] == 24.7: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} knots".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tMeasurement Depth 1") - if current.dataParts[to_update_index] == 361: - current.dataParts[to_update_index] = "361 metres or greater" - elif current.dataParts[to_update_index] == 362: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} metres down".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tCurrent Vector component North (u) 2") - if current.dataParts[to_update_index] == 24.6: - current.dataParts[to_update_index] = "24.6 knots or more" - elif current.dataParts[to_update_index] == 24.7: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} knots".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tCurrent Vector component North (v) 2") - if current.dataParts[to_update_index] == 24.6: - current.dataParts[to_update_index] = "24.6 knots or more" - elif current.dataParts[to_update_index] == 24.7: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} knots".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tCurrent Vector component North (z) 2") - if current.dataParts[to_update_index] == 24.6: - current.dataParts[to_update_index] = "24.6 knots or more" - elif current.dataParts[to_update_index] == 24.7: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} knots".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tMeasurement Depth 2") - if current.dataParts[to_update_index] == 361: - current.dataParts[to_update_index] = "361 metres or greater" - elif current.dataParts[to_update_index] == 362: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} metres down".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tSensor Description") - current.dataParts[to_update_index] = enums.sensorTypes[current.dataParts[to_update_index]] - -def updateHorizontalCurrentFlowPayload(current): - to_update_index = current.fields.index("\t\tCurrent Bearing 1") - if current.dataParts[to_update_index] == 360: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} deg from true north".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tCurrent Distance 1") - if current.dataParts[to_update_index] == 121: - current.dataParts[to_update_index] = "121 metres or greater" - elif current.dataParts[to_update_index] == 122: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} metres".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tCurrent Speed 1") - if current.dataParts[to_update_index] == 24.6: - current.dataParts[to_update_index] = "24.6 knots or more" - elif current.dataParts[to_update_index] == 24.7: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} knots".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tCurrent Direction 1") - if current.dataParts[to_update_index] == 360: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} deg from true north".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tMeasurement Depth 1") - if current.dataParts[to_update_index] == 361: - current.dataParts[to_update_index] = "361 metres or greater" - elif current.dataParts[to_update_index] == 362: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} metres down".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tCurrent Bearing 2") - if current.dataParts[to_update_index] == 360: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} deg from true north".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tCurrent Distance 2") - if current.dataParts[to_update_index] == 121: - current.dataParts[to_update_index] = "121 metres or greater" - elif current.dataParts[to_update_index] == 122: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} metres".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tCurrent Speed 2") - if current.dataParts[to_update_index] == 24.6: - current.dataParts[to_update_index] = "24.6 knots or more" - elif current.dataParts[to_update_index] == 24.7: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} knots".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tCurrent Direction 2") - if current.dataParts[to_update_index] == 360: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} deg from true north".format(current.dataParts[to_update_index]) - - to_update_index = current.fields.index("\t\tMeasurement Depth 2") - if current.dataParts[to_update_index] == 361: - current.dataParts[to_update_index] = "361 metres or greater" - elif current.dataParts[to_update_index] == 362: - current.dataParts[to_update_index] = "N/A" - else: - current.dataParts[to_update_index] = "{} metres down".format(current.dataParts[to_update_index]) - -def updateSeaStatePayload(sea): - to_update_index = sea.fields.index("\t\tSwell Height") - if sea.dataParts[to_update_index] == 24.6: - sea.dataParts[to_update_index] = "24.6 metres or more" - elif sea.dataParts[to_update_index] == 24.7: - sea.dataParts[to_update_index] = "N/A" - else: - sea.dataParts[to_update_index] = "{} metres".format(sea.dataParts[to_update_index]) - - to_update_index = sea.fields.index("\t\tSwell Period") - if sea.dataParts[to_update_index] == 61: - sea.dataParts[to_update_index] = "N/A" - else: - sea.dataParts[to_update_index] = "{} seconds".format(sea.dataParts[to_update_index]) - - to_update_index = sea.fields.index("\t\tSwell Direction") - if sea.dataParts[to_update_index] == 360: - sea.dataParts[to_update_index] = "N/A" - else: - sea.dataParts[to_update_index] = "{} deg from true north".format(sea.dataParts[to_update_index]) - - to_update_index = sea.fields.index("\t\tSea State") - if sea.dataParts[to_update_index] == 13: - sea.dataParts[to_update_index] = "N/A" - else: - sea.dataParts[to_update_index] = "{} (Beaufort scale)".format(sea.dataParts[to_update_index]) - - to_update_index = sea.fields.index("\t\tSwell Sensor Description") - sea.dataParts[to_update_index] = enums.sensorTypes[sea.dataParts[to_update_index]] - - to_update_index = sea.fields.index("\t\tWater Temperature") - if sea.dataParts[to_update_index] == 60.1: - sea.dataParts[to_update_index] = "N/A" - else: - sea.dataParts[to_update_index] = "{} deg C".format(sea.dataParts[to_update_index] - 10) - - to_update_index = sea.fields.index("\t\tWater Temperature Depth") - if sea.dataParts[to_update_index] == 12.1: - sea.dataParts[to_update_index] = "12.1 metres or greater" - elif sea.dataParts[to_update_index] == 12.2: - sea.dataParts[to_update_index] = "N/A" - else: - sea.dataParts[to_update_index] = "{} metres".format(sea.dataParts[to_update_index]) - - to_update_index = sea.fields.index("\t\tDepth Sensor Description") - sea.dataParts[to_update_index] = enums.sensorTypes[sea.dataParts[to_update_index]] - - to_update_index = sea.fields.index("\t\tWave Height") - if sea.dataParts[to_update_index] == 24.6: - sea.dataParts[to_update_index] = "24.6 metres or more" - elif sea.dataParts[to_update_index] == 24.7: - sea.dataParts[to_update_index] = "N/A" - else: - sea.dataParts[to_update_index] = "{} metres".format(sea.dataParts[to_update_index]) - - to_update_index = sea.fields.index("\t\tWave Period") - if sea.dataParts[to_update_index] == 61: - sea.dataParts[to_update_index] = "N/A" - else: - sea.dataParts[to_update_index] = "{} seconds".format(sea.dataParts[to_update_index]) - - to_update_index = sea.fields.index("\t\tWave Direction") - if sea.dataParts[to_update_index] == 360: - sea.dataParts[to_update_index] = "N/A" - else: - sea.dataParts[to_update_index] = "{} deg from true north".format(sea.dataParts[to_update_index]) - - to_update_index = sea.fields.index("\t\tWave Sensor Description") - sea.dataParts[to_update_index] = enums.sensorTypes[sea.dataParts[to_update_index]] - - to_update_index = sea.fields.index("\t\tSalinity") - if sea.dataParts[to_update_index] == 50.1: - sea.dataParts[to_update_index] = "50.1 percent or more" - elif sea.dataParts[to_update_index] == 50.2: - sea.dataParts[to_update_index] = "data N/A" - elif sea.dataParts[to_update_index] == 50.3: - sea.dataParts[to_update_index] == "sensor N/A" - else: - sea.dataParts[to_update_index] = "{}%".format(sea.dataParts[to_update_index]) - -def updateSalinityPayload(salinity): - to_update_index = salinity.fields.index("\t\tWater Temperature") - if salinity.dataParts[to_update_index] == 60.1: - salinity.dataParts[to_update_index] = "N/A" - else: - salinity.dataParts[to_update_index] = "{} deg C".format(salinity.dataParts[to_update_index] - 10) - - to_update_index = salinity.fields.index("\t\tConductivity") - if salinity.dataParts[to_update_index] == 70.1: - salinity.dataParts[to_update_index] = "7.01 Siemens/m or more" - elif salinity.dataParts[to_update_index] == 70.2: - salinity.dataParts[to_update_index] = "data N/A" - elif salinity.dataParts[to_update_index] == 70.3: - salinity.dataParts[to_update_index] == "sensor N/A" - else: - salinity.dataParts[to_update_index] = "{} Siemens/m".format(salinity.dataParts[to_update_index]) - - to_update_index = salinity.fields.index("\t\tWater Pressure") - if salinity.dataParts[to_update_index] == 6000.1: - salinity.dataParts[to_update_index] = "6000.1 decibars or more" - elif salinity.dataParts[to_update_index] == 6000.2: - salinity.dataParts[to_update_index] = "data N/A" - elif salinity.dataParts[to_update_index] == 6000.3: - salinity.dataParts[to_update_index] == "sensor N/A" - else: - salinity.dataParts[to_update_index] = "{} decibars".format(salinity.dataParts[to_update_index]) - - to_update_index = salinity.fields.index("\t\tSalinity") - if salinity.dataParts[to_update_index] == 50.1: - salinity.dataParts[to_update_index] = "50.1 percent or more" - elif salinity.dataParts[to_update_index] == 50.2: - salinity.dataParts[to_update_index] = "data N/A" - elif salinity.dataParts[to_update_index] == 50.3: - salinity.dataParts[to_update_index] == "sensor N/A" - else: - salinity.dataParts[to_update_index] = "{}%".format(salinity.dataParts[to_update_index]) - - to_update_index = salinity.fields.index("\t\tSalinity Type") - types = ["measured", "calculated using PSS-78", "calculated using other method", "reserved"] - salinity.dataParts[to_update_index] = types[salinity.dataParts[to_update_index]] - - to_update_index = salinity.fields.index("\t\tSensor Description") - salinity.dataParts[to_update_index] = enums.sensorTypes[salinity.dataParts[to_update_index]] - -def updateWeatherPayload(weather): - to_update_index = weather.fields.index("\t\Air Temperature") - if weather.dataParts[to_update_index] == -1024: - weather.dataParts[to_update_index] = "N/A" - else: - weather.dataParts[to_update_index] = "{} deg C".format(weather.dataParts[to_update_index]*0.1) - - to_update_index = weather.fields.index("\t\tTemperature Sensor Type") - weather.dataParts[to_update_index] = enums.sensorTypes[weather.dataParts[to_update_index]] - - to_update_index = weather.fields.index("\t\tPrecipitation Type") - ptypes = ["rain", "rain and snow", "rain and snow", "other"] - weather.dataParts[to_update_index] = ptypes[weather.dataParts[to_update_index]] - - to_update_index = weather.fields.index("\t\tHorizontal Visibility") - if weather.dataParts[to_update_index] == 24.1: - weather.dataParts[to_update_index] = "24.1 nautical miles or more" - elif weather.dataParts[to_update_index] == 23.2: - weather.dataParts[to_update_index] = "data N/A" - elif weather.dataParts[to_update_index] == 24.3: - weather.dataParts[to_update_index] == "sensor N/A" - else: - weather.dataParts[to_update_index] = "{} nautical miles".format(weather.dataParts[to_update_index]) - - to_update_index = weather.fields.index("\t\tDew Point") - if weather.dataParts[to_update_index] == 501: - weather.dataParts[to_update_index] = "N/A" - else: - weather.dataParts[to_update_index] = "{} deg C".format(weather.dataParts[to_update_index]*0.1) - - to_update_index = weather.fields.index("\t\tDewpoint Sensor Type") - weather.dataParts[to_update_index] = enums.sensorTypes[weather.dataParts[to_update_index]] - - to_update_index = weather.fields.index("\t\tAir Pressure") - if weather.dataParts[to_update_index] == 0: - weather.dataParts[to_update_index] = "800 hPa" - elif weather.dataParts[to_update_index] == 402: - weather.dataParts[to_update_index] = "1201 hPa or more" - elif weather.dataParts[to_update_index] == 403: - weather.dataParts[to_update_index] = "data N/A" - else: - weather.dataParts[to_update_index] = "{} hPa".format(weather.dataParts[to_update_index]+799) - - to_update_index = weather.fields.index("\t\tPressure Tendency") - tendencies = ["steady", "decreasing", "increasing", "N/A"] - weather.dataParts[to_update_index] = tendencies[weather.dataParts[to_update_index]] - - to_update_index = weather.fields.index("\t\tPressure Sensor Type") - weather.dataParts[to_update_index] = enums.sensorTypes[weather.dataParts[to_update_index]] - - to_update_index = weather.fields.index("\t\tSalinity") - if weather.dataParts[to_update_index] == 50.1: - weather.dataParts[to_update_index] = "50.1 percent or more" - elif weather.dataParts[to_update_index] == 50.2: - weather.dataParts[to_update_index] = "data N/A" - elif weather.dataParts[to_update_index] == 50.3: - weather.dataParts[to_update_index] == "sensor N/A" - else: - weather.dataParts[to_update_index] = "{}%".format(weather.dataParts[to_update_index]) - -def updateAirGapPayload(air): - to_update_index = air.fields.index("\t\tAir Draught") - if air.dataParts[to_update_index] == 819.1: - air.dataParts[to_update_index] = "81.91 metres or more" - elif air.dataParts[to_update_index] == 0: - air.dataParts[to_update_index] == "N/A" - else: - air.dataParts[to_update_index] = "{} metres".format(air.dataParts[to_update_index]*0.1) - - to_update_index = air.fields.index("\t\tAir Gap") - if air.dataParts[to_update_index] == 819.1: - air.dataParts[to_update_index] = "81.91 metres or more" - elif air.dataParts[to_update_index] == 0: - air.dataParts[to_update_index] == "N/A" - else: - air.dataParts[to_update_index] = "{} metres".format(air.dataParts[to_update_index]*0.1) - - to_update_index = air.fields.index("\t\tAir Gap Trend") - trends = ["steady", "rising", "falling", "N/A"] - air.dataParts[to_update_index] = trends[air.dataParts[to_update_index]] - - to_update_index = air.fields.index("\t\tForecast Air Gap") - if air.dataParts[to_update_index] == 819.1: - air.dataParts[to_update_index] = "81.91 metres or more" - elif air.dataParts[to_update_index] == 0: - air.dataParts[to_update_index] == "N/A" - else: - air.dataParts[to_update_index] = "{} metres".format(air.dataParts[to_update_index]*0.1) - - to_update_index = air.fields.index("\tDay (UTC)") - if(air.dataParts[to_update_index]) == 0: - air.dataParts[to_update_index] = "N/A" - to_update_index = air.fields.index("\tHour (UTC)") - if(air.dataParts[to_update_index]) == 24: - air.dataParts[to_update_index] = "N/A (UTC)" - to_update_index = air.fields.index("\tMinute (UTC)") - if(air.dataParts[to_update_index]) == 60: - air.dataParts[to_update_index] = "N/A" - -def updateGauge(gauge): - to_update_index = gauge.fields.index("\tGauge ID") - if gauge.dataParts[to_update_index] == 0: - gauge.dataParts[to_update_index] = "Unknown" - - to_update_index = gauge.fields.index("\tWater Level") - if gauge.dataParts[to_update_index] == 0: - gauge.dataParts[to_update_index] = "Unknown" - else: - gauge.dataParts[to_update_index] = "{} cm".format(gauge.dataParts[to_update_index]) - def updateReservedSlot(slot): to_update_index = slot.fields.find("\tTime-out") slot.dataParts[to_update_index] = "{} minutes".format(slot.dataParts[to_update_index]) \ No newline at end of file diff --git a/Aggregates/message_aggregates.py b/Aggregates/message_aggregates.py index c3839894503e58fea4f484cad32f281fedd5f78e..05087566289a13d3649e6cbc6ceec8beaaf99482 100644 --- a/Aggregates/message_aggregates.py +++ b/Aggregates/message_aggregates.py @@ -620,6 +620,9 @@ class messageType_13(): updaters.updateType_13(self) +# UWAGA: wydaje mi się, że w tym przypadku znaki tekstu są 8-bitowe z dwoma zerami na początku +# (patrz uwagę pod tym typem); ale może tylko 2 ostatnie bity są nadmiarowe - dobrze by było o to dopytać +# Siwickiego datapartsBitlengths['14'] = (6, 2, 30, 2, 968) datapartsTypes['14'] = ("u", "u", "u", "x", "t") class messageType_14(): @@ -633,10 +636,8 @@ class messageType_14(): # UWAGA: rzeczywista długość całkowita może być mniejsza od tej wynikającej z poniższej krotki (160 bitów) # dekoder musi sprawdzać długość i w odpowiednim momencie olewać kolejne pola krotki -# (patrz uwagę pod tym typem) 88, 110, 160 -datapartsBitlengths['15'] = (6, 2, 30, 2, 30, 6, 12, 2, 6, 12, 2, 30, 6, 12, 2) #160 -#datapartsBitlengths['15'] = (6, 2, 30, 2, 30, 6, 12) #88 -#datapartsBitlengths['15'] = (6, 2, 30, 2, 30, 6, 12, 2, 6, 12, 2) #110 +# (patrz uwagę pod tym typem) +datapartsBitlengths['15'] = (6, 2, 30, 2, 30, 6, 12, 2, 6, 12, 2, 30, 6, 12, 2) datapartsTypes['15'] = ("u", "u", "u", "x", "u", "u", "u", "x", "u", "u", "x", "u", "u", "u", "x") class messageType_15(): def __init__(self, dataParts): @@ -650,9 +651,8 @@ class messageType_15(): # UWAGA: rzeczywista długość całkowita może być mniejsza od tej wynikającej z poniższej krotki (144 bity) # dekoder musi sprawdzać długość i w odpowiednim momencie olewać kolejne pola krotki -# (patrz uwagę pod tym typem) 144 -datapartsBitlengths['16'] = (6, 2, 30, 2, 30, 12, 10, 30, 12, 10) #140 -#datapartsBitlengths['16'] = (6, 2, 30, 2, 30, 12, 10) #92 (96, ale 4 bity "for future use" +# (patrz uwagę pod tym typem) +datapartsBitlengths['16'] = (6, 2, 30, 2, 30, 12, 10, 30, 12, 10) datapartsTypes['16'] = ("u", "u", "u", "x", "u", "u", "u", "u", "u", "u") class messageType_16(): def __init__(self, dataParts): diff --git a/Decoder/array_decoder_new_version.py b/Decoder/array_decoder_new_version.py index d5374d7a228031a4bf745fe2e6566d6603b93886..88cf6c42494b7999cc38fc32b2cba90c520415cf 100644 --- a/Decoder/array_decoder_new_version.py +++ b/Decoder/array_decoder_new_version.py @@ -1,11 +1,12 @@ from Aggregates import arrays_aggregates from Aggregates import message_aggregates +from Decoder import decode_fragment from Decoder import dictionaries # specyficzne typy wiadomości need_adjustment = ["8_6", "24", "25", "26"] #chyba wsio? has_array = ['6_2', '6_7', '6_8', '6_9', '6_11', '7', '8_4', '8_7', '8_9', '8_10', '8_15', '20'] -shorter_than_expected = ["15", "16"] +shorter_than_expected = ["16", "17", "14", "15"] #czy na pewno jeszzce to 14 i 15? def decode_message(message): # funkcja decode_message wywoływana w mainie, dostajemy słownik z polami "type" i "payload"(czyli wiadomość) if message["type"] in need_adjustment: @@ -65,7 +66,7 @@ def split_to_fields(message): # wykorzystaj krotkę z typami danych, którą? to powie parametr type -def decode_bitstrings(bit_strings, message): +def decode_bitstrings(fragment, message): i = 0 position = 0 dataParts = [] @@ -74,14 +75,9 @@ def decode_bitstrings(bit_strings, message): while i < field_count: field_bits = message_aggregates.datapartsBitlengths[message["type"]][i] field_type = message_aggregates.datapartsTypes[message["type"]][i] -<<<<<<< HEAD if message["type"] != 'x': one_decoded_field = dictionaries.field_type_dictionary(fragment, field_type) dataParts.append(one_decoded_field) -======= - one_decoded_field = dictionaries.field_type_dictionary(bit_strings[i], field_type) - dataParts.append(one_decoded_field) ->>>>>>> 2a1096728def607f518986ed44bff92e2fc9450b position += field_bits i += 1 @@ -177,10 +173,10 @@ def recognize_what_type(numb_of_type_bits, array, l, position, type): position += 1 j += 1 - if type == '8_9': - recognized_type = dictionaries.report_dictionary[value] - if type == '6_7' or '8_7': - recognized_type = dictionaries.shape_dictionary[value] + if type == '8_9': + recognized_type = dictionaries.report_dictionary[value] + if type == '6_7' or '8_7': + recognized_type = dictionaries.shape_dictionary[value] return recognized_type @@ -190,7 +186,7 @@ def field_of_array(type, mess, n): field_type = arrays_aggregates.arraysDataTypes[type][n] fragment = mess[n] endgame_field = dictionaries.field_type_dictionary(fragment, field_type) - pack = [field_bits, endgame_field] #nie wiem czy jest sens z tym field bits, zastanowię się jak będę przytomna + pack = [field_bits, endgame_field] #nie wiem czy jest sens z tym field type, zastanowię się jak będę przytomna return pack diff --git a/Decoder/dictionaries.py b/Decoder/dictionaries.py index 92558c93d9b4e8712879bc9d0c151b6914c6bd18..d9d78b79bfba75806206264b9856cb2c77d1601a 100644 --- a/Decoder/dictionaries.py +++ b/Decoder/dictionaries.py @@ -1,11 +1,12 @@ +#from Agregates import arrays_aggregates from Aggregates import message_aggregates from Decoder import decode_fragment array_dictionary = { - '6_2': 1, '6_7': 2, #'6_7': 29, + '6_2': 1, '6_7': 29, '6_8': 10, '6_9': 11, '6_11': 12, '7': 13, - '8_4': 14, '8_7': 2, #'8_7': 29, + '8_4': 14, '8_7': 29, '8_9': 15, '8_10': 11, '8_15': 27, '20': 28 }