Skip to content

Commit

Permalink
changing to RFC3RFC3339Nano, so that we can covert back to and use ms…
Browse files Browse the repository at this point in the history
… in the client
  • Loading branch information
petervolvowinz committed May 31, 2024
1 parent b243a87 commit f81bbe6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
14 changes: 7 additions & 7 deletions server/vissv2server/serviceMgr/curvelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ func clCapture1dim(clChan chan CLPack, subscriptionId int, path string, bufSize
// { CLBufElement{0, 0}, "", -1, CLBufElement{0, 0}, "", -1, CLBufElement{0, 0}, "", -1 }
for {
newTime := getCurrentUtcTime()
sleepPeriod := getSleepDuration(newTime, oldTime, 800) // TODO: Iteration period should be configurable, set to less than sample freq of signal.
sleepPeriod := getSleepDuration(newTime, oldTime, 90) // TODO: Iteration period should be configurable, set to less than sample freq of signal.
if sleepPeriod < 0 {
utils.Warning.Printf("Curve logging may have missed to capture.")
}
Expand All @@ -427,7 +427,7 @@ func clCapture1dim(clChan chan CLPack, subscriptionId int, path string, bufSize
}
mcloseClSubId.Unlock()
dp := getVehicleData(path)
utils.Info.Printf("dp=%s", dp)
utils.Info.Printf("**** dp =%s ", dp)
utils.MapRequest(dp, &dpMap)
_, ts := readRing(&aRingBuffer, 0) // read latest written
if ts != dpMap["ts"].(string) {
Expand Down Expand Up @@ -598,7 +598,7 @@ func saveNonPdrDp(postProc []PostProcessBufElement1dim, maxError float64) bool {
func transformDataPoints(aRingBuffer *RingBuffer, clBuffer []CLBufElement, bufSize int) []CLBufElement {
var status bool
_, tsBaseStr := readRing(aRingBuffer, bufSize-1) // get ts for first dp in buffer
tsBase, _ := time.Parse(time.RFC3339, tsBaseStr)
tsBase, _ := time.Parse(time.RFC3339Nano, tsBaseStr)
for index := 0; index < bufSize; index++ {
clBuffer[index], status = transformDataPoint(aRingBuffer, index, tsBase)
if status == false {
Expand All @@ -616,16 +616,16 @@ func transformDataPoint(aRingBuffer *RingBuffer, index int, tsBase time.Time) (C
utils.Error.Printf("Curve logging failed to convert value=%s to float err=%s", val, err)
return cLBufElement, false
}
cLBufElement.Value = (float64)(value)
t, err := time.Parse(time.RFC3339, ts)
cLBufElement.Value = value
t, err := time.Parse(time.RFC3339Nano, ts)
if err != nil {
t2, err := strconv.ParseInt(ts, 10, 64)
if err != nil {
utils.Error.Printf("Curve logging failed to convert time to Unix time err=%s", err)
return cLBufElement, false
}
tstr := time.UnixMilli(t2).Format(time.RFC3339)
t, err = time.Parse(time.RFC3339, tstr)
tstr := time.UnixMilli(t2).Format(time.RFC3339Nano)
t, err = time.Parse(time.RFC3339Nano, tstr)
if err != nil {
utils.Error.Printf("Curve logging failed to convert time to Unix time err=%s", err)
return cLBufElement, false
Expand Down
3 changes: 2 additions & 1 deletion utils/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ func GetTimeInMilliSecs() string {
}

func GetRfcTime() string {
withTimeZone := time.Now().Format(time.RFC3339) // 2020-05-01T15:34:35+02:00
time.Now()
withTimeZone := time.Now().Format(time.RFC3339Nano) // 2020-05-01T15:34:35+02:00
if withTimeZone[len(withTimeZone)-6] == '+' {
return withTimeZone[:len(withTimeZone)-6] + "Z"
} else {
Expand Down

0 comments on commit f81bbe6

Please sign in to comment.