fulup-bzh / GeoGate

GeoGate is an opensource tracking GPS/AIS framework to implement GTS applications.
Apache License 2.0
75 stars 39 forks source link

fixed horviz calculation and added horviz range indicator #56

Closed KEGustafsson closed 9 months ago

KEGustafsson commented 9 months ago

More info here. Original was correct so last commit is reverted. https://github.com/SignalK/nmea0183-signalk/pull/245#issuecomment-1902175992

afischerdev commented 9 months ago

There are more comments above

  1. horvisib < 127 should be horvisib != 127 to fit the rule
  2. when a MSB is present use something like this (horvisib & 127) / 10.0 - follow the sample 0x10110010 = >5 mi
  3. don't add horvisibrange when horvisib == 127
KEGustafsson commented 9 months ago

There are more comments above

1. horvisib < 127 should be `horvisib != 127` to fit the rule

All data is between 0 - 126 (0 - 12.6Nm , so nothing else needed to put horvisib variable. What rule need != ?

2. when a MSB is present use something like this `(horvisib & 127) / 10.0` - follow the sample 0x10110010 = >5 mi

MSB is indepent indicator of equipment limit saturation. Horvisib value and MSB are device independet and might vary between equipment. If equpment limit is reached then MSB is set. If results are within measurement range then MSB is false.

3. don't add `horvisibrange` when horvisib == 127

No. Then no data available.

afischerdev commented 9 months ago

What rule need != ?

The start is when horvisib != 127 then use the data.

All data is between 0 - 126

The test files contain several samples where value is above 127.

KEGustafsson commented 9 months ago

I would propose something similar.

var horvisib       = parseInt(this.GetInt(194, 7));
if (horvisib < 127) {
    this.horvisib = horvisib / 10.0;
    var horvisibrange  = parseInt(this.GetInt(193, 1));
    if (horvisibrange == 0){
            this.horvisibrange = "=";
        } 
        else if (horvisibrange == 1) {
            this.horvisibrange = ">";
        }
}
KEGustafsson commented 9 months ago

What rule need != ?

The start is when horvisib != 127 then use the data.

All data is between 0 - 126

The test files contain several samples where value is above 127.

Lowest 7 bits are range data and MSB saturation indicator bit. If we read 8 bit in the there will be values over 127 because MSB bit, all possible values between 128-255.

Horizontal visibility, in 0.1 Nautical Miles steps (00000000 to 01111111). 0.0 – 12.6 Nautical Miles (data values 0 - 126) The most significant bit (MSB, (00000000 to 11111111) indicates that the maximum range of the visibility equipment was reached. 127 = data not available = default

There are two measurements combined into this same 8bit data. Should not be mixed when parsing and decoding the data.