diff --git a/core/pipeline_replay.go b/core/pipeline_replay.go index 1997b38..08a2db2 100644 --- a/core/pipeline_replay.go +++ b/core/pipeline_replay.go @@ -94,9 +94,9 @@ func replaySanitizeFunc() flow.MapFunc { } sd.Timestamp = sd.Servertime.Add(time.Duration(lastOff)) } - if sd.Servertime.Before(time.Unix(1608422400, 0)) && sd.Speed != 0 && sd.Source() == SOURCE_SERIAL { - sd.Speed = sd.Speed * 3.6 - } + //if sd.Servertime.Before(time.Unix(1608422400, 0)) && sd.Speed != 0 && sd.Source() == SOURCE_SERIAL { + // sd.Speed = sd.Speed * 3.6 + //} return sd } } diff --git a/core/service.go b/core/service.go index ba6446e..87df9a7 100644 --- a/core/service.go +++ b/core/service.go @@ -99,7 +99,7 @@ func (t *TrackingService) IsRecording() bool { } // creates a new Pipeline with requested collectors -func (t *TrackingService) StartPipeline(cols ...CollectorType) (string, error) { +func (t *TrackingService) StartLivetracking(cols ...CollectorType) (string, error) { logrus.Info("SERVICE: NEW PIPELINE") // check if state machine is in right state if t.opMode == RECORDING { @@ -107,6 +107,11 @@ func (t *TrackingService) StartPipeline(cols ...CollectorType) (string, error) { logrus.Warn(txt) return "RECORDING", errors.New(txt) } + if t.opMode == REPLAY { + txt := "trackingservice: please stop Replay before resetting pipeline" + logrus.Warn(txt) + return "RECORDING", errors.New(txt) + } if t.opMode == LIVE { txt := "trackingservice: stop tracking running stream before creating new one" logrus.Warnln(txt) @@ -215,11 +220,17 @@ func (t *TrackingService) StopAll() (*TrackingMetadata, error) { // retrieves tracking with all data and starts replay pipeline if desired. // in that case the application behaves like in live mode. func (t *TrackingService) LoadTracking(trackingId uuid.UUID, replay bool) (*Tracking, error) { - if !(t.opMode == REPLAY || t.opMode == STOPPED || t.opMode == LIVE || t.opMode == RECORDING) { + if t.opMode == RECORDING { + txt := "trackingservice: please stop recording before load another tracking" + logrus.Warn(txt) + return nil, errors.New(txt) + } + if t.opMode == REPLAY || t.opMode == LIVE { t.StopAll() } logrus.Info("LOAD TRACKING from database") tracking, err := t.store.Load(trackingId) + fixSpeedValues(tracking) if err != nil { return nil, err } @@ -247,3 +258,18 @@ func (t *TrackingService) safelyReplaceTracking(tr Tracking) { *t.tracking = tr t.recSem.Release(1) } + +// helper function to fixSpeedValues wrong values recorded before 12/20/2020 +func fixSpeedValues(tracking *Tracking) { + logrus.Debugln("fixing speed values") + for i := 0; i < len(tracking.Data); i++ { + if tracking.Data[i].Servertime.Before(time.Unix(1608422400, 0)) && tracking.Data[i].Source() == SOURCE_SERIAL && tracking.Data[i].Speed != 0 { + tracking.Data[i].Speed = tracking.Data[i].Speed * 3.6 + } + } + //for _, sd := range tracking.Data { + // if sd.Servertime.Before(time.Unix(1608422400, 0)) && sd.Speed != 0 && sd.Source() == SOURCE_SERIAL { + // sd.Speed = sd.Speed * 3.6 + // } + //} +} diff --git a/readme.md b/readme.md index d8205b7..0c03bd7 100644 --- a/readme.md +++ b/readme.md @@ -1,9 +1,11 @@ # gyropsc ⚡ **Realtime Location Dashboard 🚀** ## Quickstart +First copy `example_config.yml` to `gpsconfig.yml` and adjust your parameters. if you intend to use this tool with ublox over USB or Serial, you need to set the name of your port in this config file. otherwise the program will panic. ### Requirements * Win, Linux or Mac Computer, ideally with serial port and WiFi -* +* download latest Release and unzip it +* execute `gyropgsc-$OS`, according to your operating system ## Build from source ### Requirements diff --git a/static/scripts/websocket.js b/static/scripts/websocket.js index ca85e42..cd32146 100644 --- a/static/scripts/websocket.js +++ b/static/scripts/websocket.js @@ -199,7 +199,7 @@ window.addEventListener("load", function(evt) { checkBoxSmartphone.disabled = false; checkBoxUblox.disabled = false; document.getElementById("tracking state").innerHTML = "Tracking state: PIPELINE CLOSED" - ws.close(); + //ws.close(); } return false; }; diff --git a/web/http.go b/web/http.go index 29dc37d..f4b2226 100644 --- a/web/http.go +++ b/web/http.go @@ -108,7 +108,7 @@ func startPipelineHandler(s *core.TrackingService, c *core.Configuration) fiber. if tcp == "true" { collecs = append(collecs, core.TCP) } - res, err := s.StartPipeline(collecs...) + res, err := s.StartLivetracking(collecs...) prepres := make(map[string]interface{}) prepres["tracking_state"] = res @@ -209,7 +209,7 @@ func createFiberWebsocketHandler(s core.Subscriber) func(conn *websocket.Conn) { logrus.Traceln("write to ws:", cmsg) err := c.WriteMessage(websocket.TextMessage, []byte(cmsg)) if err != nil { - logrus.Info("close websocket connection") + logrus.Infoln("close websocket connection", err) c.Close() break }