Skip to content

Commit

Permalink
wip parking sfhera
Browse files Browse the repository at this point in the history
  • Loading branch information
clezag committed Jul 3, 2024
1 parent 5f6eca1 commit d3c7b92
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions transformers/parking-offstreet-sfhera/src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,28 @@ func main() {
lat, _ := strconv.ParseFloat(payload.Lat, 64)
lon, _ := strconv.ParseFloat(payload.Long, 64)

s := bdplib.CreateStation(payload.Uid, payload.Park, ParkingStation, lat, lon, b.Origin)
if err := b.SyncStations(ParkingStation, []bdplib.Station{s}, true, true); err != nil {
sname := fmt.Sprintf("parking-bz:%s", payload.Uid)
s := bdplib.CreateStation(sname, payload.Park, ParkingStation, lat, lon, b.Origin)

floor, _ := strconv.Atoi(payload.Floor)
s.MetaData = map[string]any{
"floor": floor,
"capacity": payload.Lots,
}
if err := b.SyncStations(ParkingStation, []bdplib.Station{s}, true, false); err != nil {
slog.Error("Error syncing stations", "err", err, "msg", m)
msgReject(&d)
continue
}

dm := b.CreateDataMap()
dm.AddRecord(s.Id, dtFree.Name, bdplib.CreateRecord(raw.Timestamp.UnixMilli(), payload.Tot, 300))
tot, _ := strconv.Atoi(payload.Tot)
dm.AddRecord(s.Id, dtFree.Name, bdplib.CreateRecord(raw.Timestamp.UnixMilli(), tot, 300))
in, _ := strconv.Atoi(payload.In)
dm.AddRecord(s.Id, dtEnter.Name, bdplib.CreateRecord(raw.Timestamp.UnixMilli(), in, 300))
out, _ := strconv.Atoi(payload.Out)
dm.AddRecord(s.Id, dtExit.Name, bdplib.CreateRecord(raw.Timestamp.UnixMilli(), out, 300))

if err := b.PushData(ParkingStation, dm); err != nil {
slog.Error("Error pushing data to bdp", "err", err, "msg", m)
msgReject(&d)
Expand Down

0 comments on commit d3c7b92

Please sign in to comment.