pull/516/head
Christopher Young 2016-10-24 15:22:57 -04:00
rodzic 5eb079dae6
commit 04ee9d8b1b
4 zmienionych plików z 48 dodań i 48 usunięć

Wyświetl plik

@ -745,11 +745,10 @@ type WeatherMessage struct {
Time string
Data string
LocaltimeReceived time.Time
Ticks int64
TowerLon float64
TowerLat float64
Ticks int64
TowerLon float64
TowerLat float64
TisId byte
}
// Send update to connected websockets.
@ -774,7 +773,7 @@ func registerADSBTextMessageReceived(msg string, uatMsg *uatparse.UATMsg) {
globalStatus.UAT_PIREP_total++
}
if x[0] == "NEXRAD" {
log.Printf("registerADSBTextMessageReceived: %s\n",msg)
log.Printf("registerADSBTextMessageReceived: %s\n", msg)
wm.Type = x[0]
wm.Data = strings.Join(x[1:], " ")
wm.Location = "NEXRAD"
@ -788,9 +787,9 @@ func registerADSBTextMessageReceived(msg string, uatMsg *uatparse.UATMsg) {
wm.LocaltimeReceived = stratuxClock.Time
wm.TowerLon = uatMsg.Lon
wm.TowerLat = uatMsg.Lat
// now := time.Now()
// Year := time.Year()
uatTime := time.Date(2016, time.Month(uatMsg.Frames[0].FISB_month),int(uatMsg.Frames[0].FISB_day), int(uatMsg.Frames[0].FISB_hours), int(uatMsg.Frames[0].FISB_minutes), int(uatMsg.Frames[0].FISB_seconds), 0, time.UTC)
// now := time.Now()
// Year := time.Year()
uatTime := time.Date(2016, time.Month(uatMsg.Frames[0].FISB_month), int(uatMsg.Frames[0].FISB_day), int(uatMsg.Frames[0].FISB_hours), int(uatMsg.Frames[0].FISB_minutes), int(uatMsg.Frames[0].FISB_seconds), 0, time.UTC)
wm.Ticks = uatTime.UnixNano() / 1000000
wmJSON, _ := json.Marshal(&wm)

Wyświetl plik

@ -69,7 +69,7 @@ func handleJsonIo(conn *websocket.Conn) {
// Subscribe the socket to receive updates.
trafficUpdate.AddSocket(conn)
weatherUpdate.AddSocket(conn)
trafficMutex.Unlock()
// Connection closes when function returns. Since uibroadcast is writing and we don't need to read anything (for now), just keep it busy.

Wyświetl plik

@ -75,7 +75,7 @@ const (
)
type TrafficInfo struct {
Type string //
Type string //
Icao_addr uint32
Reg string // Registration. Calculated from Icao_addr for civil aircraft of US registry.
Tail string // Callsign. Transmitted by aircraft.

Wyświetl plik

@ -4,13 +4,14 @@ import (
"encoding/hex"
"errors"
"fmt"
"log"
"io/ioutil"
"log"
"strconv"
"strings"
)
var elementIdentifier byte
const (
UPLINK_BLOCK_DATA_BITS = 576
UPLINK_BLOCK_BITS = (UPLINK_BLOCK_DATA_BITS + 160)
@ -26,9 +27,9 @@ const (
// assume 6 byte frames: 2 header bytes, 4 byte payload
// (TIS-B heartbeat with one address, or empty FIS-B APDU)
UPLINK_MAX_INFO_FRAMES = (424 / 6)
COLS_PER_BIN = 32
ROWS_PER_BIN = 4
COLS_PER_BIN = 32
ROWS_PER_BIN = 4
dlac_alpha = "\x03ABCDEFGHIJKLMNOPQRSTUVWXYZ\x1A\t\x1E\n| !\"#$%&'()*+,-./0123456789:;<=>?"
)
@ -194,27 +195,27 @@ func formatDLACData(p string) []string {
func (f *UATFrame) decodeNexradFrame() {
ret := make([]string, 0)
builder := make([]string, 0)
if len(f.FISB_data) < int(f.FISB_length) {
return
}
mEmpty := make([]int32, 1)
mData := make([]int32, COLS_PER_BIN * ROWS_PER_BIN)
mData := make([]int32, COLS_PER_BIN*ROWS_PER_BIN)
elementIdentifier := f.FISB_data[0] & 0x80
mBlock := uint32(f.FISB_data[0] & 0x0f) << 16
mBlock = mBlock | uint32(f.FISB_data[1]) << 8
mBlock := uint32(f.FISB_data[0]&0x0f) << 16
mBlock = mBlock | uint32(f.FISB_data[1])<<8
mBlock = mBlock | uint32(f.FISB_data[2])
index := 3
// Make 32 * 4 array
if elementIdentifier != 0 {
// Clear the array
for c:=0; c < (COLS_PER_BIN * ROWS_PER_BIN); c++ {
for c := 0; c < (COLS_PER_BIN * ROWS_PER_BIN); c++ {
mData[c] = 0
}
j := 0
for index < int(f.FISB_length) {
numberOfBins := ((f.FISB_data[index] & 0xf8) >> 3) + 1
for i:=0; i < int(numberOfBins); i++ {
for i := 0; i < int(numberOfBins); i++ {
if j >= int(COLS_PER_BIN*ROWS_PER_BIN) {
return
}
@ -226,7 +227,7 @@ func (f *UATFrame) decodeNexradFrame() {
} else {
bitmapLen := int32(f.FISB_data[index] & 0x0f)
// Start with 1 element
mEmpty[0] = int32(mBlock)
if (f.FISB_data[index] & 0x10) != 0 {
mEmpty = append(mEmpty, int32(mBlock+1))
@ -240,69 +241,69 @@ func (f *UATFrame) decodeNexradFrame() {
if (f.FISB_data[index] & 0x40) != 0 {
mEmpty = append(mEmpty, int32(mBlock+4))
}
for i:=1; i<int(bitmapLen); i++ {
for i := 1; i < int(bitmapLen); i++ {
if (f.FISB_data[index+i] & 0x01) != 0 {
mEmpty = append(mEmpty, int32(mBlock + uint32(i) * 8 - 3))
mEmpty = append(mEmpty, int32(mBlock+uint32(i)*8-3))
}
if (f.FISB_data[index+i] & 0x02) != 0 {
mEmpty = append(mEmpty, int32(mBlock + uint32(i) * 8 - 2))
mEmpty = append(mEmpty, int32(mBlock+uint32(i)*8-2))
}
if (f.FISB_data[index+i] & 0x04) != 0 {
mEmpty = append(mEmpty, int32(mBlock + uint32(i) * 8 - 1))
mEmpty = append(mEmpty, int32(mBlock+uint32(i)*8-1))
}
if (f.FISB_data[index+i] & 0x08) != 0 {
mEmpty = append(mEmpty, int32( mBlock + uint32(i) * 8 - 0))
mEmpty = append(mEmpty, int32(mBlock+uint32(i)*8-0))
}
if (f.FISB_data[index+i] & 0x10) != 0 {
mEmpty = append(mEmpty, int32(mBlock + uint32(i) * 8 + 1))
mEmpty = append(mEmpty, int32(mBlock+uint32(i)*8+1))
}
if (f.FISB_data[index+i] & 0x20) != 0 {
mEmpty = append(mEmpty, int32(mBlock + uint32(i) * 8 + 2))
mEmpty = append(mEmpty, int32(mBlock+uint32(i)*8+2))
}
if (f.FISB_data[index+i] & 0x40) != 0 {
mEmpty = append(mEmpty, int32(mBlock + uint32(i) * 8 + 3))
mEmpty = append(mEmpty, int32(mBlock+uint32(i)*8+3))
}
if (f.FISB_data[index+i] & 0x80) != 0 {
mEmpty = append(mEmpty, int32(mBlock + uint32(i) * 8 + 4))
mEmpty = append(mEmpty, int32(mBlock+uint32(i)*8+4))
}
}
}
log.Printf("NEXRAD: elementIdentifier %d mBlock %d\n",elementIdentifier, mBlock)
log.Printf("NEXRAD: mEmpty %d mData %d\n",mEmpty, mData)
log.Printf("NEXRAD: elementIdentifier %d mBlock %d\n", elementIdentifier, mBlock)
log.Printf("NEXRAD: mEmpty %d mData %d\n", mEmpty, mData)
// field 1 - NEXRAD
builder = append(builder,"NEXRAD")
builder = append(builder, "NEXRAD")
// CONUS
if f.Product_id == 63 {
builder = append(builder,"0")
builder = append(builder, "0")
} else {
builder = append(builder,"1")
builder = append(builder, "1")
}
// Field 3 block
builder = append(builder,fmt.Sprintf("%d",mBlock))
builder = append(builder, fmt.Sprintf("%d", mBlock))
// Field 4 Columns
builder = append(builder,fmt.Sprintf("%d",COLS_PER_BIN))
builder = append(builder, fmt.Sprintf("%d", COLS_PER_BIN))
// Field 5 Rows
builder = append(builder,fmt.Sprintf("%d",ROWS_PER_BIN))
builder = append(builder, fmt.Sprintf("%d", ROWS_PER_BIN))
if elementIdentifier != 0 {
builder = append(builder,"1")
builder = append(builder, "1")
bin := ""
for br := range mData {
bin = bin + fmt.Sprintf("%d,",mData[br])
bin = bin + fmt.Sprintf("%d,", mData[br])
}
if bin[len(bin)-1] == ',' {
bin = bin[0:len(bin)-1]
bin = bin[0 : len(bin)-1]
}
builder = append(builder,bin)
builder = append(builder, bin)
} else {
builder = append(builder,"0")
builder = append(builder, "0")
bin2 := ""
for be := range mEmpty {
bin2 = bin2 + fmt.Sprintf("%d,",mEmpty[be])
bin2 = bin2 + fmt.Sprintf("%d,", mEmpty[be])
}
if bin2[len(bin2)-1] == ',' {
bin2 = bin2[0:len(bin2)-1]
bin2 = bin2[0 : len(bin2)-1]
}
builder = append(builder,bin2)
builder = append(builder, bin2)
}
ret = append(ret, fmt.Sprintf(strings.Join(builder, " ")))
f.Text_data = ret
@ -621,9 +622,9 @@ func (f *UATFrame) decodeInfoFrame() {
case 8, 11, 13:
f.decodeAirmet()
*/
case 63, 64:
case 63, 64:
f.decodeNexradFrame()
default:
fmt.Fprintf(ioutil.Discard, "don't know what to do with product id: %d\n", f.Product_id)
}